@openmrs/esm-form-engine-app 13.0.1-pre.12708 → 13.0.1-pre.12711

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/4388.js CHANGED
@@ -1,5 +1,5 @@
1
- (globalThis.webpackChunk_openmrs_esm_form_engine_app=globalThis.webpackChunk_openmrs_esm_form_engine_app||[]).push([["4388"],{9908(e,t,n){"use strict";n.r(t),n.d(t,{createAttachment:()=>l,fetchClobData:()=>h,fetchOpenMRSForm:()=>m,getAllLocations:()=>c,getConcept:()=>s,getLatestObs:()=>f,getLatestObsForConceptSet:()=>p,getLocationsByTag:()=>u,getPatientEnrolledPrograms:()=>g,getPreviousEncounter:()=>d,markPatientAsDeceased:()=>_,saveEncounter:()=>a,savePatientIdentifier:()=>v,savePersonAttribute:()=>b,saveProgramEnrollment:()=>y});var r=n(2664),i=n(498),o=n(1809);function a(e,t,n){let o=n?`${r.restBaseUrl}/encounter/${n}?v=${i.RZ}`:`${r.restBaseUrl}/encounter?v=${i.RZ}`;return(0,r.openmrsFetch)(o,{headers:{"Content-Type":"application/json"},method:"POST",body:t,signal:e.signal})}async function l(e,t,n){let i=new FormData;return i.append("fileCaption",n.fileDescription),i.append("patient",e),n.file?i.append("file",n.file,n.fileName):(i.append("file",new File([""],n.fileName),n.fileName),i.append("base64Content",n.base64Content)),i.append("encounter",t),i.append("formFieldNamespace",n.formFieldNamespace),i.append("formFieldPath",n.formFieldPath),(0,r.openmrsFetch)(`${r.attachmentUrl}`,{method:"POST",body:i})}function s(e,t){return(0,r.openmrsFetch)(`${r.restBaseUrl}/concept/${e}?v=${t}`).then(({data:e})=>e.results)}function u(e){return(0,r.openmrsFetch)(`${r.restBaseUrl}/location?tag=${e}&v=custom:(uuid,display)`).then(({data:e})=>e.results)}function c(){return(0,r.openmrsFetch)(`${r.restBaseUrl}/location?v=custom:(uuid,display)`).then(({data:e})=>e.results)}async function d(e,t){let n=`patient=${e}&_sort=-date&_count=1&type=${t}`,o=await (0,r.openmrsFetch)(`${r.fhirBaseUrl}/Encounter?${n}`);if(o?.data?.entry?.length){let e=o.data.entry[0].resource.id;return(o=await (0,r.openmrsFetch)(`${r.restBaseUrl}/encounter/${e}?v=${i.RZ}`)).data}return null}async function f(e,t,n){let i=`patient=${e}&code=${t}${n?`&encounter.type=${n}`:""}`;i+="&_sort=-date&_count=1";let{data:o}=await (0,r.openmrsFetch)(`${r.fhirBaseUrl}/Observation?${i}`);return o.entry?.length?o.entry[0].resource:null}async function p(e,t,n){let i=await f(e,t,n);if(!i)return[];let o=i.encounter?.reference?.split("/").pop();if(!o)return[i];let a=`patient=${e}&code=${t}&encounter=${o}`,{data:l}=await (0,r.openmrsFetch)(`${r.fhirBaseUrl}/Observation?${a}`);return l.entry?.map(e=>e.resource)??[]}async function m(e){if(!e)return null;let{url:t,isUUID:n}=(0,o.O)(e)?{url:`${r.restBaseUrl}/form/${e}?v=full`,isUUID:!0}:{url:`${r.restBaseUrl}/form?q=${e}&v=full`,isUUID:!1},{data:i}=await (0,r.openmrsFetch)(t);if(n)return i;if(i.results?.length){let e=i.results.find(e=>!1===e.retired);if(e)return e}throw Error(`Form with ID "${e}" was not found`)}async function h(e){if(!e)return null;let t=e.resources?.find(({name:e})=>"JSON schema"===e);if(!t)return null;let n=`${r.restBaseUrl}/clobdata/${t.valueReference}`,{data:i}=await (0,r.openmrsFetch)(n);return i}function g(e){return(0,r.openmrsFetch)(`${r.restBaseUrl}/programenrollment?patient=${e}&v=custom:(uuid,display,program:(uuid,name,allWorkflows),dateEnrolled,dateCompleted,location:(uuid,display),states:(state:(uuid,name,concept:(uuid),programWorkflow:(uuid)))`).then(({data:e})=>e||null)}function y(e,t){if(!e)throw Error("Program enrollment cannot be created because no payload is supplied");let n=e.uuid?`${r.restBaseUrl}/programenrollment/${e.uuid}`:`${r.restBaseUrl}/programenrollment`;return(0,r.openmrsFetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:e,signal:t.signal})}function v(e,t){let n;return n=e.uuid?`${r.restBaseUrl}/patient/${t}/identifier/${e.uuid}`:`${r.restBaseUrl}/patient/${t}/identifier`,(0,r.openmrsFetch)(n,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(e)})}function b(e,t){let n;return n=e.uuid?`${r.restBaseUrl}/person/${t}/attribute/${e.uuid}`:`${r.restBaseUrl}/person/${t}/attribute`,(0,r.openmrsFetch)(n,{headers:{"Content-Type":"application/json"},method:"POST",body:e})}function _(e,t,n,i){if(!n)throw Error(e("patientCannotBeMarkedAsDeceasedBecauseNoPayloadSupplied","Patient cannot be marked as deceased because no payload is supplied"));let o=`${r.restBaseUrl}/person/${t}`;return(0,r.openmrsFetch)(o,{method:"POST",headers:{"Content-Type":"application/json"},body:n,signal:i.signal})}},498(e,t,n){"use strict";n.d(t,{FU:()=>l,Mi:()=>i,RA:()=>a,RZ:()=>o,ZA:()=>s,t$:()=>r});let r="cf82933b-3f3f-45e7-a5ab-5d31aaee3da3",i="488b58ff-64f5-4f8a-8979-fa79940b1594",o="custom:(uuid,encounterDatetime,encounterType:(uuid,name,description),location:(uuid,name),patient:(uuid,display),encounterProviders:(uuid,provider:(uuid,name),encounterRole:(uuid,name)),orders:(uuid,display,concept:(uuid,display),voided),diagnoses:(uuid,certainty,condition,formFieldPath,formFieldNamespace,display,rank,voided,diagnosis:(coded:(uuid,display))),obs:(uuid,obsDatetime,comment,voided,groupMembers,formFieldNamespace,formFieldPath,concept:(uuid,name:(uuid,name)),value:(uuid,name:(uuid,name),names:(uuid,conceptNameType,name))))",a="forms-engine-store",l=["radio","checkbox","select","content-switcher"],s="OPTION_NULL"},1807(e,t,n){"use strict";n.d(t,{L:()=>r});let r="@openmrs/esm-form-engine-app"},1343(e,t,n){"use strict";n.d(t,{yh:()=>aq,y6:()=>aY,Im:()=>ej,Tn:()=>lG});var r,i={};n.r(i),n.d(i,{boolean:()=>t1,booleanish:()=>t2,commaOrSpaceSeparated:()=>t9,commaSeparated:()=>t6,number:()=>t3,overloadedBoolean:()=>t4,spaceSeparated:()=>t5});var o={};function a(e,t){let n=e.behaviours?.find(e=>e.intent===t),r=e.behaviours?.find(e=>"*"===e.intent);if(n||r){delete n?.intent,delete r?.intent;let t=Object.assign(r||{},n||{}),i=t.defaultValue;void 0!=i&&(e.questionOptions.defaultValue=i,delete t.defaultValue),e=Object.assign(e,t),delete e.behaviours}}function l(e,t){let n=e.behaviours?.find(e=>e.intent===t),r=e.behaviours?.find(e=>"*"===e.intent);n&&r?(delete n.intent,delete r.intent,e=Object.assign(e,Object.assign(r,n)),delete e.behaviours):!n&&r&&(delete r.intent,e=Object.assign(e,r),delete e.behaviours)}n.r(o),n.d(o,{attentionMarkers:()=>r6,contentInitial:()=>r0,disable:()=>r9,document:()=>rX,flow:()=>r2,flowInitial:()=>r1,insideSpan:()=>r5,string:()=>r4,text:()=>r3}),n(2722);var s=n(2664),u=n(498),c=n(5399),d=n.n(c),f=n(3373),p=n.n(f);let m={flexColumn:"-esm-form-engine__obs-group__flexColumn___Rm5Li",flexFullWidth:"-esm-form-engine__obs-group__flexFullWidth___Zd-wp",groupContainer:"-esm-form-engine__obs-group__groupContainer___DYseT",boldLegend:"-esm-form-engine__obs-group__boldLegend___ycIBQ"};var h=n(7685),g=n(324),y=e=>e instanceof Date,v=e=>null==e,b=e=>!v(e)&&!Array.isArray(e)&&"object"==typeof e&&!y(e),_=e=>b(e)&&e.target?"checkbox"===e.target.type?e.target.checked:e.target.value:e,w=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,x=(e,t)=>e.has(w(t)),E="u">typeof window&&void 0!==window.HTMLElement&&"u">typeof document;function k(e){let t;if(e instanceof Date)return new Date(e);let n="u">typeof FileList&&e instanceof FileList;if(E&&(e instanceof Blob||n))return e;let r=Array.isArray(e);if(!r&&!(b(e)&&b(t=e.constructor&&e.constructor.prototype)&&t.hasOwnProperty("isPrototypeOf")))return e;let i=r?[]:Object.create(Object.getPrototypeOf(e));for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(i[t]=k(e[t]));return i}var S=e=>void 0===e,O=e=>Array.isArray(e)?e.filter(Boolean):[],D=e=>O(e.replace(/["|']|\]/g,"").split(/\.|\[/)),C=(e,t,n)=>{if(!t||!b(e))return n;let r=(/^\w*$/.test(t)?[t]:D(t)).reduce((e,t)=>v(e)?e:e[t],e);return S(r)||r===e?S(e[t])?n:e[t]:r},F=e=>"function"==typeof e,A=(e,t,n)=>{let r=-1,i=/^\w*$/.test(t)?[t]:D(t),o=i.length,a=o-1;for(;++r<o;){let t=i[r],o=n;if(r!==a){let n=e[t];o=b(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if("__proto__"===t||"constructor"===t||"prototype"===t)return;e[t]=o,e=e[t]}};let P="blur",T="trigger",V="onChange",M="onSubmit",j="maxLength",I="minLength",N="pattern",L="required",q="validate",R="form",$="root",B=d().createContext(null);B.displayName="HookFormControlContext";var H=(e,t,n,r=!0)=>{let i={defaultValues:t._defaultValues};for(let o in e)Object.defineProperty(i,o,{get:()=>("all"!==t._proxyFormState[o]&&(t._proxyFormState[o]=!r||"all"),n&&(n[o]=!0),e[o])});return i};let z="u">typeof window?d().useLayoutEffect:d().useEffect;var U=e=>"string"==typeof e,W=(e,t,n,r,i)=>U(e)?(r&&t.watch.add(e),C(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),C(n,e))):(r&&(t.watchAll=!0),n),Y=e=>v(e)||"object"!=typeof e;function J(e,t,n=new WeakSet){if(Y(e)||Y(t))return Object.is(e,t);if(y(e)&&y(t))return Object.is(e.getTime(),t.getTime());let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;if(n.has(e)||n.has(t))return!0;for(let o of(n.add(e),n.add(t),r)){let r=e[o];if(!i.includes(o))return!1;if("ref"!==o){let e=t[o];if(y(r)&&y(e)||b(r)&&b(e)||Array.isArray(r)&&Array.isArray(e)?!J(r,e,n):!Object.is(r,e))return!1}}return!0}function Z(e){let t=d().useContext(B),{control:n=t,name:r,defaultValue:i,disabled:o,exact:a,compute:l}=e||{},s=d().useRef(i),u=d().useRef(l),c=d().useRef(void 0),f=d().useRef(n),p=d().useRef(r);u.current=l;let[m,h]=d().useState(()=>{let e=n._getWatch(r,s.current);return u.current?u.current(e):e}),g=d().useCallback(e=>{let t=W(r,n._names,e||n._formValues,!1,s.current);return u.current?u.current(t):t},[n._formValues,n._names,r]),y=d().useCallback(e=>{if(!o){let t=W(r,n._names,e||n._formValues,!1,s.current);if(u.current){let e=u.current(t);J(e,c.current)||(h(e),c.current=e)}else h(t)}},[n._formValues,n._names,o,r]);z(()=>(f.current===n&&J(p.current,r)||(f.current=n,p.current=r,y()),n._subscribe({name:r,formState:{values:!0},exact:a,callback:e=>{y(e.values)}})),[n,a,r,y]),d().useEffect(()=>n._removeUnmounted());let v=f.current!==n,b=p.current,_=d().useMemo(()=>{if(o)return null;let e=!v&&!J(b,r);return v||e?g():null},[o,v,r,b,g]);return null!==_?_:m}let G=e=>e.render(function(e){let t=d().useContext(B),{name:n,disabled:r,control:i=t,shouldUnregister:o,defaultValue:a,exact:l=!0}=e,s=x(i._names.array,n),u=d().useMemo(()=>C(i._formValues,n,C(i._defaultValues,n,a)),[i,n,a]),c=Z({control:i,name:n,defaultValue:u,exact:l}),f=function(e){let t=d().useContext(B),{control:n=t,disabled:r,name:i,exact:o}=e||{},[a,l]=d().useState(n._formState),s=d().useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return z(()=>n._subscribe({name:i,formState:s.current,exact:o,callback:e=>{r||l({...n._formState,...e})}}),[i,r,o]),d().useEffect(()=>{s.current.isValid&&n._setValid(!0)},[n]),d().useMemo(()=>H(a,n,s.current,!1),[a,n])}({control:i,name:n,exact:l}),p=d().useRef(e),m=d().useRef(void 0),h=d().useRef(i.register(n,{...e.rules,value:c,..."boolean"==typeof e.disabled?{disabled:e.disabled}:{}}));p.current=e;let g=d().useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!C(f.errors,n)},isDirty:{enumerable:!0,get:()=>!!C(f.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!C(f.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!C(f.validatingFields,n)},error:{enumerable:!0,get:()=>C(f.errors,n)}}),[f,n]),y=d().useCallback(e=>h.current.onChange({target:{value:_(e),name:n},type:"change"}),[n]),v=d().useCallback(()=>h.current.onBlur({target:{value:C(i._formValues,n),name:n},type:P}),[n,i._formValues]),b=d().useCallback(e=>{let t=C(i._fields,n);t&&t._f&&e&&(t._f.ref={focus:()=>F(e.focus)&&e.focus(),select:()=>F(e.select)&&e.select(),setCustomValidity:t=>F(e.setCustomValidity)&&e.setCustomValidity(t),reportValidity:()=>F(e.reportValidity)&&e.reportValidity()})},[i._fields,n]),w=d().useMemo(()=>({name:n,value:c,..."boolean"==typeof r||f.disabled?{disabled:f.disabled||r}:{},onChange:y,onBlur:v,ref:b}),[n,r,f.disabled,y,v,b,c]);return d().useEffect(()=>{let e=i._options.shouldUnregister||o,t=m.current;t&&t!==n&&!s&&i.unregister(t),i.register(n,{...p.current.rules,..."boolean"==typeof p.current.disabled?{disabled:p.current.disabled}:{}});let r=(e,t)=>{let n=C(i._fields,e);n&&n._f&&(n._f.mount=t)};if(r(n,!0),e){let e=k(C(i._options.defaultValues,n,p.current.defaultValue));A(i._defaultValues,n,e),S(C(i._formValues,n))&&A(i._formValues,n,e)}return s||i.register(n),m.current=n,()=>{(s?e&&!i._state.action:e)?i.unregister(n):r(n,!1)}},[n,i,s,o]),d().useEffect(()=>{i._setDisabledField({disabled:r,name:n})},[r,n,i]),d().useMemo(()=>({field:w,formState:f,fieldState:g}),[w,f,g])}(e));d().createContext(null).displayName="HookFormContext";var Q=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},K=e=>Array.isArray(e)?e:[e],X=()=>{let e=[];return{get observers(){return e},next:t=>{for(let n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}},ee=e=>b(e)&&!Object.keys(e).length,et=e=>{if(!E)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},en=e=>et(e)&&e.isConnected;function er(e,t){let n=Array.isArray(t)?t:/^\w*$/.test(t)?[t]:D(t),r=1===n.length?e:function(e,t){let n=t.slice(0,-1).length,r=0;for(;r<n;)e=S(e)?r++:e[t[r++]];return e}(e,n),i=n.length-1,o=n[i];return r&&delete r[o],0!==i&&(b(r)&&ee(r)||Array.isArray(r)&&function(e){for(let t in e)if(e.hasOwnProperty(t)&&!S(e[t]))return!1;return!0}(r))&&er(e,n.slice(0,-1)),e}function ei(e){return Array.isArray(e)||b(e)&&!(e=>{for(let t in e)if(F(e[t]))return!0;return!1})(e)}function eo(e,t={}){for(let n in e){let r=e[n];ei(r)?(t[n]=Array.isArray(r)?[]:{},eo(r,t[n])):S(r)||(t[n]=!0)}return t}function ea(e,t,n){for(let r in n||(n=eo(t)),e){let i=e[r];if(ei(i))S(t)||Y(n[r])?n[r]=eo(i,Array.isArray(i)?[]:{}):ea(i,v(t)?{}:t[r],n[r]);else{let e=t[r];n[r]=!J(i,e)}}return n}let el={value:!1,isValid:!1},es={value:!0,isValid:!0};var eu=e=>{if(Array.isArray(e)){if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!S(e[0].attributes.value)?S(e[0].value)||""===e[0].value?es:{value:e[0].value,isValid:!0}:es:el}return el},ec=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>S(e)?e:t?""===e?NaN:e?+e:e:n&&U(e)?new Date(e):r?r(e):e;let ed={isValid:!1,value:null};var ef=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,ed):ed;function ep(e){let t=e.ref;return"file"===t.type?t.files:"radio"===t.type?ef(e.refs).value:"select-multiple"===t.type?[...t.selectedOptions].map(({value:e})=>e):"checkbox"===t.type?eu(e.refs).value:ec(S(t.value)?e.ref.value:t.value,e)}var em=e=>S(e)?e:e instanceof RegExp?e.source:b(e)?e.value instanceof RegExp?e.value.source:e.value:e,eh=e=>({isOnSubmit:!e||e===M,isOnBlur:"onBlur"===e,isOnChange:e===V,isOnAll:"all"===e,isOnTouch:"onTouched"===e});let eg="AsyncFunction";var ey=e=>!!e&&!!e.validate&&!!(F(e.validate)&&e.validate.constructor.name===eg||b(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===eg)),ev=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))));let eb=(e,t,n,r)=>{for(let i of n||Object.keys(e)){let n=C(e,i);if(n){let{_f:e,...o}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r)return!0;else if(e.ref&&t(e.ref,e.name)&&!r)return!0;else if(eb(o,t))break}else if(b(o)&&eb(o,t))break}}};function e_(e,t,n){let r=C(e,n);if(r||/^\w*$/.test(n))return{error:r,name:n};let i=n.split(".");for(;i.length;){let r=i.join("."),o=C(t,r),a=C(e,r);if(o&&!Array.isArray(o)&&n!==r)break;if(a&&a.type)return{name:r,error:a};if(a&&a.root&&a.root.type)return{name:`${r}.root`,error:a.root};i.pop()}return{name:n}}var ew=(e,t,n)=>{let r=K(C(e,n));return A(r,$,t[n]),A(e,n,r),e};function ex(e,t,n="validate"){if(U(e)||Array.isArray(e)&&e.every(U)||"boolean"==typeof e&&!e)return{type:n,message:U(e)?e:"",ref:t}}var eE=e=>!b(e)||e instanceof RegExp?{value:e,message:""}:e,ek=async(e,t,n,r,i,o)=>{let{ref:a,refs:l,required:s,maxLength:u,minLength:c,min:d,max:f,pattern:p,validate:m,name:h,valueAsNumber:g,mount:y}=e._f,_=C(n,h);if(!y||t.has(h))return{};let w=l?l[0]:a,x=e=>{i&&w.reportValidity&&(w.setCustomValidity("boolean"==typeof e?"":e||""),w.reportValidity())},E={},k="radio"===a.type,O="checkbox"===a.type,D=(g||"file"===a.type)&&S(a.value)&&S(_)||et(a)&&""===a.value||""===_||Array.isArray(_)&&!_.length,A=Q.bind(null,h,r,E),P=(e,t,n,r=j,i=I)=>{let o=e?t:n;E[h]={type:e?r:i,message:o,ref:a,...A(e?r:i,o)}};if(o?!Array.isArray(_)||!_.length:s&&(!(k||O)&&(D||v(_))||"boolean"==typeof _&&!_||O&&!eu(l).isValid||k&&!ef(l).isValid)){let{value:e,message:t}=U(s)?{value:!!s,message:s}:eE(s);if(e&&(E[h]={type:L,message:t,ref:w,...A(L,t)},!r))return x(t),E}if(!D&&(!v(d)||!v(f))){let e,t,n=eE(f),i=eE(d);if(v(_)||isNaN(_)){let r=a.valueAsDate||new Date(_),o=e=>new Date(new Date().toDateString()+" "+e),l="time"==a.type,s="week"==a.type;U(n.value)&&_&&(e=l?o(_)>o(n.value):s?_>n.value:r>new Date(n.value)),U(i.value)&&_&&(t=l?o(_)<o(i.value):s?_<i.value:r<new Date(i.value))}else{let r=a.valueAsNumber||(_?+_:_);v(n.value)||(e=r>n.value),v(i.value)||(t=r<i.value)}if((e||t)&&(P(!!e,n.message,i.message,"max","min"),!r))return x(E[h].message),E}if((u||c)&&!D&&(U(_)||o&&Array.isArray(_))){let e=eE(u),t=eE(c),n=!v(e.value)&&_.length>+e.value,i=!v(t.value)&&_.length<+t.value;if((n||i)&&(P(n,e.message,t.message),!r))return x(E[h].message),E}if(p&&!D&&U(_)){let{value:e,message:t}=eE(p);if(e instanceof RegExp&&!_.match(e)&&(E[h]={type:N,message:t,ref:a,...A(N,t)},!r))return x(t),E}if(m){if(F(m)){let e=ex(await m(_,n),w);if(e&&(E[h]={...e,...A(q,e.message)},!r))return x(e.message),E}else if(b(m)){let e={};for(let t in m){if(!ee(e)&&!r)break;let i=ex(await m[t](_,n),w,t);i&&(e={...i,...A(t,i.message)},x(i.message),r&&(E[h]=e))}if(!ee(e)&&(E[h]={ref:w,...e},!r))return E}}return x(!0),E};let eS={mode:M,reValidateMode:V,shouldFocusError:!0};var eO=n(7807);let eD=(0,c.createContext)(null),eC={didCatch:!1,error:null};class eF extends c.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=eC}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){let{error:e}=this.state;if(null!==e){for(var t,n,r=arguments.length,i=Array(r),o=0;o<r;o++)i[o]=arguments[o];null==(t=(n=this.props).onReset)||t.call(n,{args:i,reason:"imperative-api"}),this.setState(eC)}}componentDidCatch(e,t){var n,r;null==(n=(r=this.props).onError)||n.call(r,e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&null!==t.error&&function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}(e.resetKeys,r)){var i,o;null==(i=(o=this.props).onReset)||i.call(o,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(eC)}}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:o}=this.state,a=e;if(i){let e={error:o,resetErrorBoundary:this.resetErrorBoundary};if("function"==typeof t)a=t(e);else if(n)a=(0,c.createElement)(n,e);else if(null===r||(0,c.isValidElement)(r))a=r;else throw o}return(0,c.createElement)(eD.Provider,{value:{didCatch:i,error:o,resetErrorBoundary:this.resetErrorBoundary}},a)}}var eA=n(222),eP=n.n(eA);let eT="field.required",eV="field.outOfBound",eM={validate:(e,t)=>{if(e.meta?.submission?.unspecified)return[];if(ej(t)&&e.isRequired){if("object"==typeof e.required&&"conditionalRequired"===e.required.type&&e.isRequired)return eI(eT,e.required.message??"Field is mandatory");else if(e.isRequired)return eI(eT,"Field is mandatory")}if("text"===e.questionOptions.rendering)return function(e,t,n){let r=Number(e),i=Number(t);if("number"==typeof n&&!Number.isNaN(n)){if(r&&i&&n>=r&&n<=i)return[];if(r&&n<r)return eI(eV,`Length should be at least ${r} characters`);if(i&&n>i)return eI(eV,`Length should not exceed ${i} characters`);if(i&&r&&n<r&&n>i)return eI(eV,`Length should be between ${r} and ${i} characters`)}}(e.questionOptions.minLength,e.questionOptions.maxLength,t?.length)??[];if("number"===e.questionOptions.rendering){let o=Number(e.questionOptions.min),a=Number(e.questionOptions.max),l=e.questionOptions.disallowDecimals||e.meta?.concept?.allowDecimal;if(ej(t))return[];if(l&&!Number.isInteger(t))return eI(eV,"Decimal values are not allowed for this field");if(!Number.isNaN(o)||!Number.isNaN(a)){var n,r,i;return n=o,r=a,i=t,!Number.isNaN(n)&&i<n?eI(eV,`Value must be greater than ${n}`):!Number.isNaN(r)&&i>r?eI(eV,`Value must be lower than ${r}`):[]}}return[]}};function ej(e){return!!(null==e||""===e||"string"==typeof e&&!e?.trim()||Array.isArray(e)&&!e.length)}function eI(e,t){return[{resultType:"error",errCode:e,message:t}]}function eN(e){let t=[];return e.forEach(e=>{!function e(n){t.push(n),n.groupMembers?.length&&n.groupMembers.forEach(t=>{e(t)})}(e)}),t}function eL(e,t){return e.questionOptions.rendering===t}function eq(e){e.meta?.submission||(e.meta={...e.meta||{},submission:{}}),e.meta.submission={...e.meta.submission,voidedValue:null,newValue:null}}function eR(e,t,n){return e.meta?.submission||(e.meta={...e.meta||{},submission:{}}),ej(t)||(e.meta.submission.newValue=t),ej(n)||(e.meta.submission.voidedValue=n),e.meta.submission.newValue}function e$(e){return!!e.meta.submission?.newValue||!!e.meta.submission?.voidedValue}function eB(e){return"view"===e||"embedded-view"===e}function eH(e){let t=eP()(e).toDate();if(isNaN(t.getTime()))return new Date(NaN);try{let n=e.split("T")[1];if(n){let e=n.split(":");t.setHours(parseInt(e[0]),parseInt(e[1]),0)}}catch(e){console.error(e)}return t}function ez(e,t){let n={noToday:!0};return"calendar"===e.datePickerFormat?n.time=!1:n.time=!0,(0,s.formatDate)(t,n)}function eU(e){return e.pages=e.pages.map(e=>(e.sections=Array.from(e.sections),e)),{...e}}var eW=n(5992),eY=n(1630),eJ=n.n(eY),eZ=n(2154),eG=n.n(eZ),eQ=n(7581),eK=n.n(eQ),eX=n(7289),e0=n.n(eX),e1=n(3657),e2=n.n(e1),e4=n(8087),e3=n.n(e4),e5=n(9908);let e6={wflFemaleBelow5:()=>n.e("4926").then(n.t.bind(n,877,19)),wflMaleBelow5:()=>n.e("908").then(n.t.bind(n,4775,19)),hfaFemaleBelow5:()=>n.e("212").then(n.t.bind(n,6095,19)),hfaMaleBelow5:()=>n.e("4958").then(n.t.bind(n,5501,19)),hfaFemale5Above:()=>n.e("1229").then(n.t.bind(n,8844,19)),hfaMale5Above:()=>n.e("383").then(n.t.bind(n,7890,19)),bfaFemale5Above:()=>n.e("9899").then(n.t.bind(n,5878,19)),bfaMale5Above:()=>n.e("8577").then(n.t.bind(n,6008,19))},e9={calcWeightForHeightZscore:["wflFemaleBelow5","wflMaleBelow5"],calcHeightForAgeZscore:["hfaFemaleBelow5","hfaMaleBelow5","hfaFemale5Above","hfaMale5Above"],calcBMIForAgeZscore:["bfaFemale5Above","bfaMale5Above"]},e7=new Map;async function e8(e){let t=JSON.stringify(e??{}),n=Object.entries(e9).filter(([e])=>t.includes(e)).flatMap(([,e])=>e).filter(e=>!e7.has(e)),r=(await Promise.allSettled(n.map(async e=>{let t=await e6[e]();e7.set(e,t.default)}))).find(e=>"rejected"===e.status);if(r)throw r.reason}function te(e){let t=e7.get(e);return t||console.warn(`Z-score calculation: the ${e} reference table hasn't been loaded`),t}function tt(e,t,n){return eK()(e,e=>e[t]===n)}function tn(e,t,n){if(e&&t&&n){let r=eP()(t),i=eP()(e);return r.isValid()&&i.isValid()?r.diff(i,n):null}return null}function tr(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}eP().extend(eJ());class ti{constructor(e,t,n,r){tr(this,"node",null),tr(this,"patient",null),tr(this,"allFields",[]),tr(this,"allFieldValues",{}),tr(this,"api",e5),tr(this,"isEmpty",ej),tr(this,"dayjs",eP()),tr(this,"calculateZScoreFromRef",(e,t)=>{if(!e)return console.warn("Z-score calculation: No reference data object provided"),null;let n=Object.keys(e),r=n.map(t=>e[t]),i=r[1],o=[];t<i?o.push(i):e2()(r,e=>{e<=t&&o.push(e)});let a=e3()(o),l=n[eG()(r,e=>e===a)],s=l?.replace("SD","");return s?.includes("neg")&&(s="-"+s.substring(0,1)),("S"===s||"L"===s||"M"===s||"-5"===s)&&(s="-4"),s??null}),tr(this,"today",()=>new Date),tr(this,"includes",(e,t)=>e?.includes(t)),tr(this,"isDateBefore",(e,t,n)=>{let r=t instanceof Date?t:n?eP()(t,n,!0).toDate():eP()(t,"YYYY-MM-DD",!0).toDate();return e?.getTime()<r.getTime()}),tr(this,"isDateAfter",(e,t,n,r)=>{let i,o=eP()(t);switch(r){case"months":i=o.add(n,"month").toDate();break;case"weeks":i=o.add(n,"week").toDate();break;case"days":i=o.add(n,"day").toDate();break;case"years":i=o.add(n,"year").toDate();break;default:i=new Date(0)}return e.getTime()>=i.getTime()}),tr(this,"addWeeksToDate",(e,t)=>eP()(e).add(t,"week").toDate()),tr(this,"addDaysToDate",(e,t)=>eP()(e).add(t,"day").toDate()),tr(this,"isDateAfterSimple",(e,t,n)=>{let r=t instanceof Date?t:n?eP()(t,n,!0).toDate():eP()(t,"YYYY-MM-DD",!0).toDate();return e?.getTime()>r.getTime()}),tr(this,"useFieldValue",e=>{let t=this.allFields.find(t=>t.id===e);return t&&to(this.node,t),this.allFieldValues[e]??null}),tr(this,"doesNotMatchExpression",(e,t)=>!!(!t||["undefined","null",""].includes(t.toString()))||!new RegExp(e).test(t)),tr(this,"calcBMI",(e,t)=>{if(!e||!t)return null;let n=e/100;return parseFloat((t/(n*n)).toFixed(1))}),tr(this,"calcEDD",e=>e?new Date(e.getTime()+24192e6):null),tr(this,"calcMonthsOnART",e=>{if(null==e)return null;if(!(e instanceof Date))throw Error("DateFormatException: value passed is not a valid date");let t=new Date;return 30>Math.round((t.getTime()-e.getTime())/864e5)?0:eP()(t).diff(e,"month")}),tr(this,"calcViralLoadStatus",e=>{let t;return e&&(t=e>50?"a6768be6-c08e-464d-8f53-5f4229508e54":"5d5e42cc-acc4-4069-b3a8-7163e0db5d96"),t??null}),tr(this,"calcNextVisitDate",(e,t)=>e&&t?new Date(e.getTime()+24*t*36e5):null),tr(this,"calcTreatmentEndDate",(e,t,n)=>e&&t&&"160429AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"===n?new Date(e.getTime()+24*(30+t)*36e5):null),tr(this,"calcAgeBasedOnDate",e=>(e?new Date(e).getFullYear():new Date().getFullYear())-new Date(this.patient.birthDate).getFullYear()),tr(this,"calcBSA",(e,t)=>e&&t?parseFloat(Math.sqrt(e*t/3600).toFixed(2)):null),tr(this,"arrayContains",(e,t)=>{if(!e||!Array.isArray(e))return!1;if(0===e.length)return null==t||Array.isArray(t)&&0===t.length;if(Array.isArray(t)||(t=[t]),0===t.length)return!0;for(let n of t)if(-1===e.indexOf(n))return!1;return!0}),tr(this,"arrayContainsAny",(e,t)=>{if(!e||!Array.isArray(e))return!1;if(0===e.length)return null==t||Array.isArray(t)&&0===t.length;if(Array.isArray(t)||(t=[t]),0===t.length)return!0;for(let n of t)if(-1!==e.indexOf(n))return!0;return!1}),tr(this,"parseDate",e=>(0,s.parseDate)(e)),tr(this,"formatDate",(e,t)=>{if(!(e instanceof Date)&&isNaN((e=new Date(e)).getTime()))throw Error("DateFormatException: value passed is not a valid date");return t?eP()(e).format(t):(0,s.formatDate)(e)}),tr(this,"extractRepeatingGroupValues",(e,t)=>t.map(function(t){return t[e]})),tr(this,"calcGravida",(e,t)=>{let n="number"==typeof e?e:parseInt(e,10),r="number"==typeof t?t:parseInt(t,10);if(!Number.isInteger(n)||!Number.isInteger(r))throw Error("Both inputs must be valid numbers.");return n+r}),tr(this,"calcWeightForHeightZscore",(e,t)=>{var n;let r,i=Number(e);if(!i||!t)return null;let o=new Date(this.patient.birthDate),a=(n=this.patient.sex,r=tn(o,new Date,"years"),"F"===n&&null!==r&&r<5?te("wflFemaleBelow5"):"M"===n&&null!==r&&r<5?te("wflMaleBelow5"):null);if(!a||i<45||i>110)return null;let l=i.toFixed(1),s=eK()(a,e=>parseFloat(e.Length).toFixed(1)===l),u=e0()(s);return this.calculateZScoreFromRef(u,t)}),tr(this,"calcBMIForAgeZscore",(e,t)=>{var n,r;let i,o,a,l;if(!e||!t)return null;let s=new Date(this.patient.birthDate),u=(n=this.patient.sex,i=tn(s,r=new Date,"years"),o=tn(s,r,"months"),a=tn(s,r,"days"),l=Math.max(o,61),"F"===n&&a>1856&&i<18?tt(te("bfaFemale5Above"),"Month",l):"M"===n&&a>1856&&i<18?tt(te("bfaMale5Above"),"Month",l):null),c=e/100,d=parseFloat((t/(c*c)).toFixed(1)),f=e0()(u);return this.calculateZScoreFromRef(f,d)}),tr(this,"calcHeightForAgeZscore",(e,t)=>{if(!e)return null;let n=new Date(this.patient.birthDate),r=function(e,t,n){let r=tn(t,n,"years"),i=tn(t,n,"months"),o=tn(t,n,"days"),a=Math.max(i,61);if("F"===e){if(null!==o&&o<=1856)return tt(te("hfaFemaleBelow5"),"Day",o);if(o>1856&&r<18)return tt(te("hfaFemale5Above"),"Month",a)}if("M"===e){if(null!==o&&o<=1856)return tt(te("hfaMaleBelow5"),"Day",o);if(o>1856&&r<18)return tt(te("hfaMale5Above"),"Month",a)}return null}(this.patient.sex,n,new Date),i=e0()(r);return this.calculateZScoreFromRef(i,e)}),tr(this,"calcTimeDifference",(e,t)=>{if(!e)return 0;let n=eP()();switch(t){case"d":return Math.abs(Math.round(n.diff(e,"day",!0)));case"w":return Math.abs(Math.round(n.diff(e,"week",!0)));case"m":return Math.abs(Math.round(n.diff(e,"month",!0)));case"y":return Math.abs(Math.round(n.diff(e,"year",!0)))}}),tr(this,"resolve",e=>Promise.resolve(e)),this.allFields=n,this.allFieldValues=r,this.node=e,this.patient=t}}function to(e,t){if(e&&t)switch(e.type){case"page":t.pageDependents||(t.pageDependents=new Set),t.pageDependents.add(e.value.label);break;case"section":t.sectionDependents||(t.sectionDependents=new Set),t.sectionDependents.add(e.value.label);break;default:t.fieldDependents||(t.fieldDependents=new Set),t.fieldDependents.add(e.value.id)}}class ta{putObject(e,t){this.dataSourceMap[e]=t}getObject(e){return this.dataSourceMap[e]}constructor(){!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"dataSourceMap",{})}}let tl=new Map;function ts(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||void 0===e||"object"==typeof e||null==e}function tu(e,t,n,r,i){if(!e?.trim())return null;let o=tf(e);tp(o,t,n);try{return(0,s.evaluateAsType)(o,td(t,n,r,i),ts)}catch(t){console.error(`Error: ${t}
1
+ (globalThis.webpackChunk_openmrs_esm_form_engine_app=globalThis.webpackChunk_openmrs_esm_form_engine_app||[]).push([["4388"],{9908(e,t,n){"use strict";n.r(t),n.d(t,{createAttachment:()=>l,fetchClobData:()=>h,fetchOpenMRSForm:()=>m,getAllLocations:()=>c,getConcept:()=>s,getLatestObs:()=>f,getLatestObsForConceptSet:()=>p,getLocationsByTag:()=>u,getPatientEnrolledPrograms:()=>g,getPreviousEncounter:()=>d,markPatientAsDeceased:()=>_,saveEncounter:()=>a,savePatientIdentifier:()=>v,savePersonAttribute:()=>b,saveProgramEnrollment:()=>y});var r=n(2664),i=n(498),o=n(1809);function a(e,t,n){let o=n?`${r.restBaseUrl}/encounter/${n}?v=${i.RZ}`:`${r.restBaseUrl}/encounter?v=${i.RZ}`;return(0,r.openmrsFetch)(o,{headers:{"Content-Type":"application/json"},method:"POST",body:t,signal:e.signal})}async function l(e,t,n){let i=new FormData;return i.append("fileCaption",n.fileDescription),i.append("patient",e),n.file?i.append("file",n.file,n.fileName):(i.append("file",new File([""],n.fileName),n.fileName),i.append("base64Content",n.base64Content)),i.append("encounter",t),i.append("formFieldNamespace",n.formFieldNamespace),i.append("formFieldPath",n.formFieldPath),(0,r.openmrsFetch)(`${r.attachmentUrl}`,{method:"POST",body:i})}function s(e,t){return(0,r.openmrsFetch)(`${r.restBaseUrl}/concept/${e}?v=${t}`).then(({data:e})=>e.results)}function u(e){return(0,r.openmrsFetch)(`${r.restBaseUrl}/location?tag=${e}&v=custom:(uuid,display)`).then(({data:e})=>e.results)}function c(){return(0,r.openmrsFetch)(`${r.restBaseUrl}/location?v=custom:(uuid,display)`).then(({data:e})=>e.results)}async function d(e,t){let n=`patient=${e}&_sort=-date&_count=1&type=${t}`,o=await (0,r.openmrsFetch)(`${r.fhirBaseUrl}/Encounter?${n}`);if(o?.data?.entry?.length){let e=o.data.entry[0].resource.id;return(o=await (0,r.openmrsFetch)(`${r.restBaseUrl}/encounter/${e}?v=${i.RZ}`)).data}return null}async function f(e,t,n){let i=`patient=${e}&code=${t}${n?`&encounter.type=${n}`:""}`;i+="&_sort=-date&_count=1";let{data:o}=await (0,r.openmrsFetch)(`${r.fhirBaseUrl}/Observation?${i}`);return o.entry?.length?o.entry[0].resource:null}async function p(e,t,n){let i=await f(e,t,n);if(!i)return[];let o=i.encounter?.reference?.split("/").pop();if(!o)return[i];let a=`patient=${e}&code=${t}&encounter=${o}`,{data:l}=await (0,r.openmrsFetch)(`${r.fhirBaseUrl}/Observation?${a}`);return l.entry?.map(e=>e.resource)??[]}async function m(e){if(!e)return null;let{url:t,isUUID:n}=(0,o.O)(e)?{url:`${r.restBaseUrl}/form/${e}?v=full`,isUUID:!0}:{url:`${r.restBaseUrl}/form?q=${e}&v=full`,isUUID:!1},{data:i}=await (0,r.openmrsFetch)(t);if(n)return i;if(i.results?.length){let e=i.results.find(e=>!1===e.retired);if(e)return e}throw Error(`Form with ID "${e}" was not found`)}async function h(e){if(!e)return null;let t=e.resources?.find(({name:e})=>"JSON schema"===e);if(!t)return null;let n=`${r.restBaseUrl}/clobdata/${t.valueReference}`,{data:i}=await (0,r.openmrsFetch)(n);return i}function g(e){return(0,r.openmrsFetch)(`${r.restBaseUrl}/programenrollment?patient=${e}&v=custom:(uuid,display,program:(uuid,name,allWorkflows),dateEnrolled,dateCompleted,location:(uuid,display),states:(state:(uuid,name,concept:(uuid),programWorkflow:(uuid)))`).then(({data:e})=>e||null)}function y(e,t){if(!e)throw Error("Program enrollment cannot be created because no payload is supplied");let n=e.uuid?`${r.restBaseUrl}/programenrollment/${e.uuid}`:`${r.restBaseUrl}/programenrollment`;return(0,r.openmrsFetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:e,signal:t.signal})}function v(e,t){let n;return n=e.uuid?`${r.restBaseUrl}/patient/${t}/identifier/${e.uuid}`:`${r.restBaseUrl}/patient/${t}/identifier`,(0,r.openmrsFetch)(n,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify(e)})}function b(e,t){let n;return n=e.uuid?`${r.restBaseUrl}/person/${t}/attribute/${e.uuid}`:`${r.restBaseUrl}/person/${t}/attribute`,(0,r.openmrsFetch)(n,{headers:{"Content-Type":"application/json"},method:"POST",body:e})}function _(e,t,n,i){if(!n)throw Error(e("patientCannotBeMarkedAsDeceasedBecauseNoPayloadSupplied","Patient cannot be marked as deceased because no payload is supplied"));let o=`${r.restBaseUrl}/person/${t}`;return(0,r.openmrsFetch)(o,{method:"POST",headers:{"Content-Type":"application/json"},body:n,signal:i.signal})}},498(e,t,n){"use strict";n.d(t,{FU:()=>l,Mi:()=>i,RA:()=>a,RZ:()=>o,ZA:()=>s,t$:()=>r});let r="cf82933b-3f3f-45e7-a5ab-5d31aaee3da3",i="488b58ff-64f5-4f8a-8979-fa79940b1594",o="custom:(uuid,encounterDatetime,encounterType:(uuid,name,description),location:(uuid,name),patient:(uuid,display),encounterProviders:(uuid,provider:(uuid,name),encounterRole:(uuid,name)),orders:(uuid,display,concept:(uuid,display),voided),diagnoses:(uuid,certainty,condition,formFieldPath,formFieldNamespace,display,rank,voided,diagnosis:(coded:(uuid,display))),obs:(uuid,obsDatetime,comment,voided,groupMembers,formFieldNamespace,formFieldPath,concept:(uuid,name:(uuid,name)),value:(uuid,name:(uuid,name),names:(uuid,conceptNameType,name))))",a="forms-engine-store",l=["radio","checkbox","select","content-switcher"],s="OPTION_NULL"},1807(e,t,n){"use strict";n.d(t,{L:()=>r});let r="@openmrs/esm-form-engine-app"},1343(e,t,n){"use strict";n.d(t,{yh:()=>aR,y6:()=>aJ,Im:()=>eV,Tn:()=>lQ});var r,i={};n.r(i),n.d(i,{boolean:()=>t2,booleanish:()=>t4,commaOrSpaceSeparated:()=>t7,commaSeparated:()=>t9,number:()=>t5,overloadedBoolean:()=>t3,spaceSeparated:()=>t6});var o={};function a(e,t){let n=e.behaviours?.find(e=>e.intent===t),r=e.behaviours?.find(e=>"*"===e.intent);if(n||r){delete n?.intent,delete r?.intent;let t=Object.assign(r||{},n||{}),i=t.defaultValue;void 0!=i&&(e.questionOptions.defaultValue=i,delete t.defaultValue),e=Object.assign(e,t),delete e.behaviours}}function l(e,t){let n=e.behaviours?.find(e=>e.intent===t),r=e.behaviours?.find(e=>"*"===e.intent);n&&r?(delete n.intent,delete r.intent,e=Object.assign(e,Object.assign(r,n)),delete e.behaviours):!n&&r&&(delete r.intent,e=Object.assign(e,r),delete e.behaviours)}n.r(o),n.d(o,{attentionMarkers:()=>r9,contentInitial:()=>r1,disable:()=>r7,document:()=>r0,flow:()=>r4,flowInitial:()=>r2,insideSpan:()=>r6,string:()=>r3,text:()=>r5}),n(2722);var s=n(2664),u=n(498),c=n(5399),d=n.n(c),f=n(3373),p=n.n(f);let m={flexColumn:"-esm-form-engine__obs-group__flexColumn___Rm5Li",flexFullWidth:"-esm-form-engine__obs-group__flexFullWidth___Zd-wp",groupContainer:"-esm-form-engine__obs-group__groupContainer___DYseT",boldLegend:"-esm-form-engine__obs-group__boldLegend___ycIBQ"};var h=n(7685),g=n(324),y=e=>e instanceof Date,v=e=>null==e,b=e=>!v(e)&&!Array.isArray(e)&&"object"==typeof e&&!y(e),_=e=>b(e)&&e.target?"checkbox"===e.target.type?e.target.checked:e.target.value:e,w=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,x=(e,t)=>e.has(w(t)),E="u">typeof window&&void 0!==window.HTMLElement&&"u">typeof document;function k(e){let t;if(e instanceof Date)return new Date(e);let n="u">typeof FileList&&e instanceof FileList;if(E&&(e instanceof Blob||n))return e;let r=Array.isArray(e);if(!r&&!(b(e)&&b(t=e.constructor&&e.constructor.prototype)&&t.hasOwnProperty("isPrototypeOf")))return e;let i=r?[]:Object.create(Object.getPrototypeOf(e));for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(i[t]=k(e[t]));return i}var S=e=>void 0===e,O=e=>Array.isArray(e)?e.filter(Boolean):[],D=e=>O(e.replace(/["|']|\]/g,"").split(/\.|\[/)),C=(e,t,n)=>{if(!t||!b(e))return n;let r=(/^\w*$/.test(t)?[t]:D(t)).reduce((e,t)=>v(e)?e:e[t],e);return S(r)||r===e?S(e[t])?n:e[t]:r},F=e=>"function"==typeof e,A=(e,t,n)=>{let r=-1,i=/^\w*$/.test(t)?[t]:D(t),o=i.length,a=o-1;for(;++r<o;){let t=i[r],o=n;if(r!==a){let n=e[t];o=b(n)||Array.isArray(n)?n:isNaN(+i[r+1])?{}:[]}if("__proto__"===t||"constructor"===t||"prototype"===t)return;e[t]=o,e=e[t]}};let P="blur",T="trigger",V="onChange",M="onSubmit",j="maxLength",I="minLength",N="pattern",L="required",q="validate",R="form",$="root",B=d().createContext(null);B.displayName="HookFormControlContext";var H=(e,t,n,r=!0)=>{let i={defaultValues:t._defaultValues};for(let o in e)Object.defineProperty(i,o,{get:()=>("all"!==t._proxyFormState[o]&&(t._proxyFormState[o]=!r||"all"),n&&(n[o]=!0),e[o])});return i};let z="u">typeof window?d().useLayoutEffect:d().useEffect;var U=e=>"string"==typeof e,W=(e,t,n,r,i)=>U(e)?(r&&t.watch.add(e),C(n,e,i)):Array.isArray(e)?e.map(e=>(r&&t.watch.add(e),C(n,e))):(r&&(t.watchAll=!0),n),Y=e=>v(e)||"object"!=typeof e;function J(e,t,n=new WeakSet){if(Y(e)||Y(t))return Object.is(e,t);if(y(e)&&y(t))return Object.is(e.getTime(),t.getTime());let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return!1;if(n.has(e)||n.has(t))return!0;for(let o of(n.add(e),n.add(t),r)){let r=e[o];if(!i.includes(o))return!1;if("ref"!==o){let e=t[o];if(y(r)&&y(e)||b(r)&&b(e)||Array.isArray(r)&&Array.isArray(e)?!J(r,e,n):!Object.is(r,e))return!1}}return!0}function Z(e){let t=d().useContext(B),{control:n=t,name:r,defaultValue:i,disabled:o,exact:a,compute:l}=e||{},s=d().useRef(i),u=d().useRef(l),c=d().useRef(void 0),f=d().useRef(n),p=d().useRef(r);u.current=l;let[m,h]=d().useState(()=>{let e=n._getWatch(r,s.current);return u.current?u.current(e):e}),g=d().useCallback(e=>{let t=W(r,n._names,e||n._formValues,!1,s.current);return u.current?u.current(t):t},[n._formValues,n._names,r]),y=d().useCallback(e=>{if(!o){let t=W(r,n._names,e||n._formValues,!1,s.current);if(u.current){let e=u.current(t);J(e,c.current)||(h(e),c.current=e)}else h(t)}},[n._formValues,n._names,o,r]);z(()=>(f.current===n&&J(p.current,r)||(f.current=n,p.current=r,y()),n._subscribe({name:r,formState:{values:!0},exact:a,callback:e=>{y(e.values)}})),[n,a,r,y]),d().useEffect(()=>n._removeUnmounted());let v=f.current!==n,b=p.current,_=d().useMemo(()=>{if(o)return null;let e=!v&&!J(b,r);return v||e?g():null},[o,v,r,b,g]);return null!==_?_:m}let G=e=>e.render(function(e){let t=d().useContext(B),{name:n,disabled:r,control:i=t,shouldUnregister:o,defaultValue:a,exact:l=!0}=e,s=x(i._names.array,n),u=d().useMemo(()=>C(i._formValues,n,C(i._defaultValues,n,a)),[i,n,a]),c=Z({control:i,name:n,defaultValue:u,exact:l}),f=function(e){let t=d().useContext(B),{control:n=t,disabled:r,name:i,exact:o}=e||{},[a,l]=d().useState(n._formState),s=d().useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return z(()=>n._subscribe({name:i,formState:s.current,exact:o,callback:e=>{r||l({...n._formState,...e})}}),[i,r,o]),d().useEffect(()=>{s.current.isValid&&n._setValid(!0)},[n]),d().useMemo(()=>H(a,n,s.current,!1),[a,n])}({control:i,name:n,exact:l}),p=d().useRef(e),m=d().useRef(void 0),h=d().useRef(i.register(n,{...e.rules,value:c,..."boolean"==typeof e.disabled?{disabled:e.disabled}:{}}));p.current=e;let g=d().useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!C(f.errors,n)},isDirty:{enumerable:!0,get:()=>!!C(f.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!C(f.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!C(f.validatingFields,n)},error:{enumerable:!0,get:()=>C(f.errors,n)}}),[f,n]),y=d().useCallback(e=>h.current.onChange({target:{value:_(e),name:n},type:"change"}),[n]),v=d().useCallback(()=>h.current.onBlur({target:{value:C(i._formValues,n),name:n},type:P}),[n,i._formValues]),b=d().useCallback(e=>{let t=C(i._fields,n);t&&t._f&&e&&(t._f.ref={focus:()=>F(e.focus)&&e.focus(),select:()=>F(e.select)&&e.select(),setCustomValidity:t=>F(e.setCustomValidity)&&e.setCustomValidity(t),reportValidity:()=>F(e.reportValidity)&&e.reportValidity()})},[i._fields,n]),w=d().useMemo(()=>({name:n,value:c,..."boolean"==typeof r||f.disabled?{disabled:f.disabled||r}:{},onChange:y,onBlur:v,ref:b}),[n,r,f.disabled,y,v,b,c]);return d().useEffect(()=>{let e=i._options.shouldUnregister||o,t=m.current;t&&t!==n&&!s&&i.unregister(t),i.register(n,{...p.current.rules,..."boolean"==typeof p.current.disabled?{disabled:p.current.disabled}:{}});let r=(e,t)=>{let n=C(i._fields,e);n&&n._f&&(n._f.mount=t)};if(r(n,!0),e){let e=k(C(i._options.defaultValues,n,p.current.defaultValue));A(i._defaultValues,n,e),S(C(i._formValues,n))&&A(i._formValues,n,e)}return s||i.register(n),m.current=n,()=>{(s?e&&!i._state.action:e)?i.unregister(n):r(n,!1)}},[n,i,s,o]),d().useEffect(()=>{i._setDisabledField({disabled:r,name:n})},[r,n,i]),d().useMemo(()=>({field:w,formState:f,fieldState:g}),[w,f,g])}(e));d().createContext(null).displayName="HookFormContext";var Q=(e,t,n,r,i)=>t?{...n[e],types:{...n[e]&&n[e].types?n[e].types:{},[r]:i||!0}}:{},K=e=>Array.isArray(e)?e:[e],X=()=>{let e=[];return{get observers(){return e},next:t=>{for(let n of e)n.next&&n.next(t)},subscribe:t=>(e.push(t),{unsubscribe:()=>{e=e.filter(e=>e!==t)}}),unsubscribe:()=>{e=[]}}},ee=e=>b(e)&&!Object.keys(e).length,et=e=>{if(!E)return!1;let t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},en=e=>et(e)&&e.isConnected;function er(e,t){let n=Array.isArray(t)?t:/^\w*$/.test(t)?[t]:D(t),r=1===n.length?e:function(e,t){let n=t.slice(0,-1).length,r=0;for(;r<n;)e=S(e)?r++:e[t[r++]];return e}(e,n),i=n.length-1,o=n[i];return r&&delete r[o],0!==i&&(b(r)&&ee(r)||Array.isArray(r)&&function(e){for(let t in e)if(e.hasOwnProperty(t)&&!S(e[t]))return!1;return!0}(r))&&er(e,n.slice(0,-1)),e}function ei(e){return Array.isArray(e)||b(e)&&!(e=>{for(let t in e)if(F(e[t]))return!0;return!1})(e)}function eo(e,t={}){for(let n in e){let r=e[n];ei(r)?(t[n]=Array.isArray(r)?[]:{},eo(r,t[n])):S(r)||(t[n]=!0)}return t}function ea(e,t,n){for(let r in n||(n=eo(t)),e){let i=e[r];if(ei(i))S(t)||Y(n[r])?n[r]=eo(i,Array.isArray(i)?[]:{}):ea(i,v(t)?{}:t[r],n[r]);else{let e=t[r];n[r]=!J(i,e)}}return n}let el={value:!1,isValid:!1},es={value:!0,isValid:!0};var eu=e=>{if(Array.isArray(e)){if(e.length>1){let t=e.filter(e=>e&&e.checked&&!e.disabled).map(e=>e.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!S(e[0].attributes.value)?S(e[0].value)||""===e[0].value?es:{value:e[0].value,isValid:!0}:es:el}return el},ec=(e,{valueAsNumber:t,valueAsDate:n,setValueAs:r})=>S(e)?e:t?""===e?NaN:e?+e:e:n&&U(e)?new Date(e):r?r(e):e;let ed={isValid:!1,value:null};var ef=e=>Array.isArray(e)?e.reduce((e,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:e,ed):ed;function ep(e){let t=e.ref;return"file"===t.type?t.files:"radio"===t.type?ef(e.refs).value:"select-multiple"===t.type?[...t.selectedOptions].map(({value:e})=>e):"checkbox"===t.type?eu(e.refs).value:ec(S(t.value)?e.ref.value:t.value,e)}var em=e=>S(e)?e:e instanceof RegExp?e.source:b(e)?e.value instanceof RegExp?e.value.source:e.value:e,eh=e=>({isOnSubmit:!e||e===M,isOnBlur:"onBlur"===e,isOnChange:e===V,isOnAll:"all"===e,isOnTouch:"onTouched"===e});let eg="AsyncFunction";var ey=e=>!!e&&!!e.validate&&!!(F(e.validate)&&e.validate.constructor.name===eg||b(e.validate)&&Object.values(e.validate).find(e=>e.constructor.name===eg)),ev=(e,t,n)=>!n&&(t.watchAll||t.watch.has(e)||[...t.watch].some(t=>e.startsWith(t)&&/^\.\w+/.test(e.slice(t.length))));let eb=(e,t,n,r)=>{for(let i of n||Object.keys(e)){let n=C(e,i);if(n){let{_f:e,...o}=n;if(e){if(e.refs&&e.refs[0]&&t(e.refs[0],i)&&!r)return!0;else if(e.ref&&t(e.ref,e.name)&&!r)return!0;else if(eb(o,t))break}else if(b(o)&&eb(o,t))break}}};function e_(e,t,n){let r=C(e,n);if(r||/^\w*$/.test(n))return{error:r,name:n};let i=n.split(".");for(;i.length;){let r=i.join("."),o=C(t,r),a=C(e,r);if(o&&!Array.isArray(o)&&n!==r)break;if(a&&a.type)return{name:r,error:a};if(a&&a.root&&a.root.type)return{name:`${r}.root`,error:a.root};i.pop()}return{name:n}}var ew=(e,t,n)=>{let r=K(C(e,n));return A(r,$,t[n]),A(e,n,r),e};function ex(e,t,n="validate"){if(U(e)||Array.isArray(e)&&e.every(U)||"boolean"==typeof e&&!e)return{type:n,message:U(e)?e:"",ref:t}}var eE=e=>!b(e)||e instanceof RegExp?{value:e,message:""}:e,ek=async(e,t,n,r,i,o)=>{let{ref:a,refs:l,required:s,maxLength:u,minLength:c,min:d,max:f,pattern:p,validate:m,name:h,valueAsNumber:g,mount:y}=e._f,_=C(n,h);if(!y||t.has(h))return{};let w=l?l[0]:a,x=e=>{i&&w.reportValidity&&(w.setCustomValidity("boolean"==typeof e?"":e||""),w.reportValidity())},E={},k="radio"===a.type,O="checkbox"===a.type,D=(g||"file"===a.type)&&S(a.value)&&S(_)||et(a)&&""===a.value||""===_||Array.isArray(_)&&!_.length,A=Q.bind(null,h,r,E),P=(e,t,n,r=j,i=I)=>{let o=e?t:n;E[h]={type:e?r:i,message:o,ref:a,...A(e?r:i,o)}};if(o?!Array.isArray(_)||!_.length:s&&(!(k||O)&&(D||v(_))||"boolean"==typeof _&&!_||O&&!eu(l).isValid||k&&!ef(l).isValid)){let{value:e,message:t}=U(s)?{value:!!s,message:s}:eE(s);if(e&&(E[h]={type:L,message:t,ref:w,...A(L,t)},!r))return x(t),E}if(!D&&(!v(d)||!v(f))){let e,t,n=eE(f),i=eE(d);if(v(_)||isNaN(_)){let r=a.valueAsDate||new Date(_),o=e=>new Date(new Date().toDateString()+" "+e),l="time"==a.type,s="week"==a.type;U(n.value)&&_&&(e=l?o(_)>o(n.value):s?_>n.value:r>new Date(n.value)),U(i.value)&&_&&(t=l?o(_)<o(i.value):s?_<i.value:r<new Date(i.value))}else{let r=a.valueAsNumber||(_?+_:_);v(n.value)||(e=r>n.value),v(i.value)||(t=r<i.value)}if((e||t)&&(P(!!e,n.message,i.message,"max","min"),!r))return x(E[h].message),E}if((u||c)&&!D&&(U(_)||o&&Array.isArray(_))){let e=eE(u),t=eE(c),n=!v(e.value)&&_.length>+e.value,i=!v(t.value)&&_.length<+t.value;if((n||i)&&(P(n,e.message,t.message),!r))return x(E[h].message),E}if(p&&!D&&U(_)){let{value:e,message:t}=eE(p);if(e instanceof RegExp&&!_.match(e)&&(E[h]={type:N,message:t,ref:a,...A(N,t)},!r))return x(t),E}if(m){if(F(m)){let e=ex(await m(_,n),w);if(e&&(E[h]={...e,...A(q,e.message)},!r))return x(e.message),E}else if(b(m)){let e={};for(let t in m){if(!ee(e)&&!r)break;let i=ex(await m[t](_,n),w,t);i&&(e={...i,...A(t,i.message)},x(i.message),r&&(E[h]=e))}if(!ee(e)&&(E[h]={ref:w,...e},!r))return E}}return x(!0),E};let eS={mode:M,reValidateMode:V,shouldFocusError:!0};var eO=n(7807);let eD=(0,c.createContext)(null),eC={didCatch:!1,error:null};class eF extends c.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=eC}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(){let{error:e}=this.state;if(null!==e){for(var t,n,r=arguments.length,i=Array(r),o=0;o<r;o++)i[o]=arguments[o];null==(t=(n=this.props).onReset)||t.call(n,{args:i,reason:"imperative-api"}),this.setState(eC)}}componentDidCatch(e,t){var n,r;null==(n=(r=this.props).onError)||n.call(r,e,t)}componentDidUpdate(e,t){let{didCatch:n}=this.state,{resetKeys:r}=this.props;if(n&&null!==t.error&&function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e.length!==t.length||e.some((e,n)=>!Object.is(e,t[n]))}(e.resetKeys,r)){var i,o;null==(i=(o=this.props).onReset)||i.call(o,{next:r,prev:e.resetKeys,reason:"keys"}),this.setState(eC)}}render(){let{children:e,fallbackRender:t,FallbackComponent:n,fallback:r}=this.props,{didCatch:i,error:o}=this.state,a=e;if(i){let e={error:o,resetErrorBoundary:this.resetErrorBoundary};if("function"==typeof t)a=t(e);else if(n)a=(0,c.createElement)(n,e);else if(null===r||(0,c.isValidElement)(r))a=r;else throw o}return(0,c.createElement)(eD.Provider,{value:{didCatch:i,error:o,resetErrorBoundary:this.resetErrorBoundary}},a)}}let eA="field.required",eP="field.outOfBound",eT={validate:(e,t)=>{if(e.meta?.submission?.unspecified)return[];if(eV(t)&&e.isRequired){if("object"==typeof e.required&&"conditionalRequired"===e.required.type&&e.isRequired)return eM(eA,e.required.message??"Field is mandatory");else if(e.isRequired)return eM(eA,"Field is mandatory")}if("text"===e.questionOptions.rendering)return function(e,t,n){let r=Number(e),i=Number(t);if("number"==typeof n&&!Number.isNaN(n)){if(r&&i&&n>=r&&n<=i)return[];if(r&&n<r)return eM(eP,`Length should be at least ${r} characters`);if(i&&n>i)return eM(eP,`Length should not exceed ${i} characters`);if(i&&r&&n<r&&n>i)return eM(eP,`Length should be between ${r} and ${i} characters`)}}(e.questionOptions.minLength,e.questionOptions.maxLength,t?.length)??[];if("number"===e.questionOptions.rendering){let o=Number(e.questionOptions.min),a=Number(e.questionOptions.max),l=e.questionOptions.disallowDecimals||e.meta?.concept?.allowDecimal;if(eV(t))return[];if(l&&!Number.isInteger(t))return eM(eP,"Decimal values are not allowed for this field");if(!Number.isNaN(o)||!Number.isNaN(a)){var n,r,i;return n=o,r=a,i=t,!Number.isNaN(n)&&i<n?eM(eP,`Value must be greater than ${n}`):!Number.isNaN(r)&&i>r?eM(eP,`Value must be lower than ${r}`):[]}}return[]}};function eV(e){return!!(null==e||""===e||"string"==typeof e&&!e?.trim()||Array.isArray(e)&&!e.length)}function eM(e,t){return[{resultType:"error",errCode:e,message:t}]}function ej(e){let t=[];return e.forEach(e=>{!function e(n){t.push(n),n.groupMembers?.length&&n.groupMembers.forEach(t=>{e(t)})}(e)}),t}function eI(e,t){return e.questionOptions.rendering===t}function eN(e){e.meta?.submission||(e.meta={...e.meta||{},submission:{}}),e.meta.submission={...e.meta.submission,voidedValue:null,newValue:null}}function eL(e,t,n){return e.meta?.submission||(e.meta={...e.meta||{},submission:{}}),eV(t)||(e.meta.submission.newValue=t),eV(n)||(e.meta.submission.voidedValue=n),e.meta.submission.newValue}function eq(e){return!!e.meta.submission?.newValue||!!e.meta.submission?.voidedValue}function eR(e){return"view"===e||"embedded-view"===e}function e$(e){return(0,s.parseDate)(e)}function eB(e){let[,t,n]=/T(\d{2}):(\d{2})/.exec(e)??[];return t?new Date(1970,0,1,Number(t),Number(n)):new Date(NaN)}function eH(e,t){let n={noToday:!0};return"calendar"===e.datePickerFormat?n.time=!1:n.time=!0,(0,s.formatDate)(t,n)}function ez(e){return e.pages=e.pages.map(e=>(e.sections=Array.from(e.sections),e)),{...e}}var eU=n(5992),eW=n(222),eY=n.n(eW),eJ=n(1630),eZ=n.n(eJ),eG=n(2154),eQ=n.n(eG),eK=n(7581),eX=n.n(eK),e0=n(7289),e1=n.n(e0),e2=n(3657),e4=n.n(e2),e3=n(8087),e5=n.n(e3),e6=n(9908);let e9={wflFemaleBelow5:()=>n.e("4926").then(n.t.bind(n,877,19)),wflMaleBelow5:()=>n.e("908").then(n.t.bind(n,4775,19)),hfaFemaleBelow5:()=>n.e("212").then(n.t.bind(n,6095,19)),hfaMaleBelow5:()=>n.e("4958").then(n.t.bind(n,5501,19)),hfaFemale5Above:()=>n.e("1229").then(n.t.bind(n,8844,19)),hfaMale5Above:()=>n.e("383").then(n.t.bind(n,7890,19)),bfaFemale5Above:()=>n.e("9899").then(n.t.bind(n,5878,19)),bfaMale5Above:()=>n.e("8577").then(n.t.bind(n,6008,19))},e7={calcWeightForHeightZscore:["wflFemaleBelow5","wflMaleBelow5"],calcHeightForAgeZscore:["hfaFemaleBelow5","hfaMaleBelow5","hfaFemale5Above","hfaMale5Above"],calcBMIForAgeZscore:["bfaFemale5Above","bfaMale5Above"]},e8=new Map;async function te(e){let t=JSON.stringify(e??{}),n=Object.entries(e7).filter(([e])=>t.includes(e)).flatMap(([,e])=>e).filter(e=>!e8.has(e)),r=(await Promise.allSettled(n.map(async e=>{let t=await e9[e]();e8.set(e,t.default)}))).find(e=>"rejected"===e.status);if(r)throw r.reason}function tt(e){let t=e8.get(e);return t||console.warn(`Z-score calculation: the ${e} reference table hasn't been loaded`),t}function tn(e,t,n){return eX()(e,e=>e[t]===n)}function tr(e,t,n){if(e&&t&&n){let r=eY()(t),i=eY()(e);return r.isValid()&&i.isValid()?r.diff(i,n):null}return null}function ti(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}eY().extend(eZ());class to{constructor(e,t,n,r){ti(this,"node",null),ti(this,"patient",null),ti(this,"allFields",[]),ti(this,"allFieldValues",{}),ti(this,"api",e6),ti(this,"isEmpty",eV),ti(this,"dayjs",eY()),ti(this,"calculateZScoreFromRef",(e,t)=>{if(!e)return console.warn("Z-score calculation: No reference data object provided"),null;let n=Object.keys(e),r=n.map(t=>e[t]),i=r[1],o=[];t<i?o.push(i):e4()(r,e=>{e<=t&&o.push(e)});let a=e5()(o),l=n[eQ()(r,e=>e===a)],s=l?.replace("SD","");return s?.includes("neg")&&(s="-"+s.substring(0,1)),("S"===s||"L"===s||"M"===s||"-5"===s)&&(s="-4"),s??null}),ti(this,"today",()=>new Date),ti(this,"includes",(e,t)=>e?.includes(t)),ti(this,"isDateBefore",(e,t,n)=>{let r=t instanceof Date?t:n?eY()(t,n,!0).toDate():eY()(t,"YYYY-MM-DD",!0).toDate();return e?.getTime()<r.getTime()}),ti(this,"isDateAfter",(e,t,n,r)=>{let i,o=eY()(t);switch(r){case"months":i=o.add(n,"month").toDate();break;case"weeks":i=o.add(n,"week").toDate();break;case"days":i=o.add(n,"day").toDate();break;case"years":i=o.add(n,"year").toDate();break;default:i=new Date(0)}return e.getTime()>=i.getTime()}),ti(this,"addWeeksToDate",(e,t)=>eY()(e).add(t,"week").toDate()),ti(this,"addDaysToDate",(e,t)=>eY()(e).add(t,"day").toDate()),ti(this,"isDateAfterSimple",(e,t,n)=>{let r=t instanceof Date?t:n?eY()(t,n,!0).toDate():eY()(t,"YYYY-MM-DD",!0).toDate();return e?.getTime()>r.getTime()}),ti(this,"useFieldValue",e=>{let t=this.allFields.find(t=>t.id===e);return t&&ta(this.node,t),this.allFieldValues[e]??null}),ti(this,"doesNotMatchExpression",(e,t)=>!!(!t||["undefined","null",""].includes(t.toString()))||!new RegExp(e).test(t)),ti(this,"calcBMI",(e,t)=>{if(!e||!t)return null;let n=e/100;return parseFloat((t/(n*n)).toFixed(1))}),ti(this,"calcEDD",e=>e?new Date(e.getTime()+24192e6):null),ti(this,"calcMonthsOnART",e=>{if(null==e)return null;if(!(e instanceof Date))throw Error("DateFormatException: value passed is not a valid date");let t=new Date;return 30>Math.round((t.getTime()-e.getTime())/864e5)?0:eY()(t).diff(e,"month")}),ti(this,"calcViralLoadStatus",e=>{let t;return e&&(t=e>50?"a6768be6-c08e-464d-8f53-5f4229508e54":"5d5e42cc-acc4-4069-b3a8-7163e0db5d96"),t??null}),ti(this,"calcNextVisitDate",(e,t)=>e&&t?new Date(e.getTime()+24*t*36e5):null),ti(this,"calcTreatmentEndDate",(e,t,n)=>e&&t&&"160429AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"===n?new Date(e.getTime()+24*(30+t)*36e5):null),ti(this,"calcAgeBasedOnDate",e=>(e?new Date(e).getFullYear():new Date().getFullYear())-new Date(this.patient.birthDate).getFullYear()),ti(this,"calcBSA",(e,t)=>e&&t?parseFloat(Math.sqrt(e*t/3600).toFixed(2)):null),ti(this,"arrayContains",(e,t)=>{if(!e||!Array.isArray(e))return!1;if(0===e.length)return null==t||Array.isArray(t)&&0===t.length;if(Array.isArray(t)||(t=[t]),0===t.length)return!0;for(let n of t)if(-1===e.indexOf(n))return!1;return!0}),ti(this,"arrayContainsAny",(e,t)=>{if(!e||!Array.isArray(e))return!1;if(0===e.length)return null==t||Array.isArray(t)&&0===t.length;if(Array.isArray(t)||(t=[t]),0===t.length)return!0;for(let n of t)if(-1!==e.indexOf(n))return!0;return!1}),ti(this,"parseDate",e=>(0,s.parseDate)(e)),ti(this,"formatDate",(e,t)=>{if(!(e instanceof Date)&&isNaN((e=new Date(e)).getTime()))throw Error("DateFormatException: value passed is not a valid date");return t?eY()(e).format(t):(0,s.formatDate)(e)}),ti(this,"extractRepeatingGroupValues",(e,t)=>t.map(function(t){return t[e]})),ti(this,"calcGravida",(e,t)=>{let n="number"==typeof e?e:parseInt(e,10),r="number"==typeof t?t:parseInt(t,10);if(!Number.isInteger(n)||!Number.isInteger(r))throw Error("Both inputs must be valid numbers.");return n+r}),ti(this,"calcWeightForHeightZscore",(e,t)=>{var n;let r,i=Number(e);if(!i||!t)return null;let o=new Date(this.patient.birthDate),a=(n=this.patient.sex,r=tr(o,new Date,"years"),"F"===n&&null!==r&&r<5?tt("wflFemaleBelow5"):"M"===n&&null!==r&&r<5?tt("wflMaleBelow5"):null);if(!a||i<45||i>110)return null;let l=i.toFixed(1),s=eX()(a,e=>parseFloat(e.Length).toFixed(1)===l),u=e1()(s);return this.calculateZScoreFromRef(u,t)}),ti(this,"calcBMIForAgeZscore",(e,t)=>{var n,r;let i,o,a,l;if(!e||!t)return null;let s=new Date(this.patient.birthDate),u=(n=this.patient.sex,i=tr(s,r=new Date,"years"),o=tr(s,r,"months"),a=tr(s,r,"days"),l=Math.max(o,61),"F"===n&&a>1856&&i<18?tn(tt("bfaFemale5Above"),"Month",l):"M"===n&&a>1856&&i<18?tn(tt("bfaMale5Above"),"Month",l):null),c=e/100,d=parseFloat((t/(c*c)).toFixed(1)),f=e1()(u);return this.calculateZScoreFromRef(f,d)}),ti(this,"calcHeightForAgeZscore",(e,t)=>{if(!e)return null;let n=new Date(this.patient.birthDate),r=function(e,t,n){let r=tr(t,n,"years"),i=tr(t,n,"months"),o=tr(t,n,"days"),a=Math.max(i,61);if("F"===e){if(null!==o&&o<=1856)return tn(tt("hfaFemaleBelow5"),"Day",o);if(o>1856&&r<18)return tn(tt("hfaFemale5Above"),"Month",a)}if("M"===e){if(null!==o&&o<=1856)return tn(tt("hfaMaleBelow5"),"Day",o);if(o>1856&&r<18)return tn(tt("hfaMale5Above"),"Month",a)}return null}(this.patient.sex,n,new Date),i=e1()(r);return this.calculateZScoreFromRef(i,e)}),ti(this,"calcTimeDifference",(e,t)=>{if(!e)return 0;let n=eY()();switch(t){case"d":return Math.abs(Math.round(n.diff(e,"day",!0)));case"w":return Math.abs(Math.round(n.diff(e,"week",!0)));case"m":return Math.abs(Math.round(n.diff(e,"month",!0)));case"y":return Math.abs(Math.round(n.diff(e,"year",!0)))}}),ti(this,"resolve",e=>Promise.resolve(e)),this.allFields=n,this.allFieldValues=r,this.node=e,this.patient=t}}function ta(e,t){if(e&&t)switch(e.type){case"page":t.pageDependents||(t.pageDependents=new Set),t.pageDependents.add(e.value.label);break;case"section":t.sectionDependents||(t.sectionDependents=new Set),t.sectionDependents.add(e.value.label);break;default:t.fieldDependents||(t.fieldDependents=new Set),t.fieldDependents.add(e.value.id)}}class tl{putObject(e,t){this.dataSourceMap[e]=t}getObject(e){return this.dataSourceMap[e]}constructor(){!function(e,t,n){t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(this,"dataSourceMap",{})}}let ts=new Map;function tu(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||void 0===e||"object"==typeof e||null==e}function tc(e,t,n,r,i){if(!e?.trim())return null;let o=tp(e);tm(o,t,n);try{return(0,s.evaluateAsType)(o,tf(t,n,r,i),tu)}catch(t){console.error(`Error: ${t}
2
2
 
3
- failing expression: ${e}`)}return null}async function tc(e,t,n,r,i){if(!e?.trim())return null;let o=tf(e);tp(o,t,n);try{return(0,s.evaluateAsTypeAsync)(o,td(t,n,r,i),ts)}catch(t){console.error(`Error: ${t}
3
+ failing expression: ${e}`)}return null}async function td(e,t,n,r,i){if(!e?.trim())return null;let o=tp(e);tm(o,t,n);try{return(0,s.evaluateAsTypeAsync)(o,tf(t,n,r,i),tu)}catch(t){console.error(`Error: ${t}
4
4
 
5
- failing expression: ${e}`)}return null}function td(e,t,n,r){let{myValue:i,patient:o}=r,{sex:a,age:l}=o??{};"field"===e.type&&void 0===i&&e.value&&(i=n[e.value.id]);let s=new ta;s.putObject("prevEnc",{value:r.previousEncounter||{obs:[]},getValue(e){return this.value.obs.find(t=>t.concept.uuid==e)}});let u=r?.visit??{},c=u?.visitType||{uuid:""},d=c.uuid??"",f={isEmpty:eW.A};return{...new ti(e,o,t,n),...aW().expressionHelpers,...r,...n,patient:o,myValue:i,sex:a,age:l,HD:s,visit:u,visitType:c,visitTypeUuid:d,_:f}}function tf(e){let t=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t}(e);if(tl.has(t))return tl.get(t);let n=(0,s.compile)(e);return tl.set(t,n),n}function tp(e,t,n){for(let r of(0,s.extractVariableNames)(e)){let e=n.find(e=>e.id===r);e&&to(t,e)}}function tm(e,t,n,r){return"embedded-view"==r||("automatic"==e?"maximized"==n&&t.endsWith("desktop"):"single-line"==e)}function th(e,t,n){if("object"!=typeof e.required)return!1;let{referenceQuestionAnswers:r,referenceQuestionId:i}=e.required,o=t.find(e=>e.id==i);return!!o&&((o.fieldDependents||(o.fieldDependents=new Set)).add(e.id),r?.includes(n[i]))}function tg(e,t,n,r,i,o,a){let{value:l,type:s}=e,u=o(l.hide?.hideWhenExpression,e,t,n,{mode:r,patient:i});e.value.isHidden=u,"field"==s&&e.value?.questions?.length&&e.value?.questions.forEach(e=>{e.isParentHidden=u}),"page"==s&&l.sections.forEach(e=>{e.isParentHidden=u,ty(u,e,t,a)}),"section"==s&&ty(u,l,t,a)}function ty(e,t,n,r){let i=t.questions.map(e=>e.id);n.filter(e=>i.includes(e.id)).forEach(t=>{t.isParentHidden=e,"group"==t.questionOptions.rendering&&t.questions.forEach(t=>{t.isParentHidden=e}),r?.(t)})}function tv(e,t){if(!e?.includes(":"))return t?.find(t=>t.uuid===e);{let[n,r]=e.split(":");return t?.find(e=>e?.conceptMappings?.find(e=>e?.conceptReferenceTerm?.conceptSource?.name.toUpperCase()===n.toUpperCase()&&e?.conceptReferenceTerm?.code.toUpperCase()===r.toUpperCase()))}}function tb(e,t=!1){let n=document.getElementById(e);n?.scrollIntoView({behavior:"smooth",block:"start",inline:"center"}),t&&n?.focus()}function t_(e){return!e.isHidden&&(e.sections?.some(e=>!e.isHidden&&e.questions?.some(e=>!e.isHidden))??!1)}var tw=n(8059);function tx(e,t,n,r){let i=[],o=[];if(e.meta.submission?.unspecified)return{errors:[],warnings:[]};try{e.validators.forEach(a=>{let l=n[a.type]?.validate?.(e,t,{...a,...r});l&&l.forEach(e=>{"error"===e.resultType?i.push(e):"warning"===e.resultType&&o.push(e)})})}catch(e){console.error(e)}return{errors:i,warnings:o}}var tE=n(1809);let tk=d().createContext(void 0),tS=({methods:e,children:t,...n})=>d().createElement(tk.Provider,{value:{...n,methods:e}},t),tO=()=>{let e=d().useContext(tk);if(!e)throw Error("FormProviderContext must be used within a FormProviderContext");return e},tD=()=>{let{t:e}=(0,eO.useTranslation)();return d().createElement("div",null,d().createElement("span",{className:"-esm-form-engine__value__empty___hEe5L"},"(",e("blank","Blank"),")"))},tC=({value:e})=>Array.isArray(e)?d().createElement(tF,{valueArray:e}):d().createElement("div",{className:"-esm-form-engine__value__value___ltyQT"},e),tF=({valueArray:e})=>d().createElement("ul",null,e.map(e=>d().createElement("li",{className:"-esm-form-engine__value__item___2GHPw"},e))),tA=({previousValue:e,displayText:t,field:n,hideHeader:r,onAfterChange:i})=>{let{t:o}=(0,eO.useTranslation)(),{methods:{setValue:a}}=tO();return d().createElement("div",{className:"-esm-form-engine__previous-value-review__formField___usT6m"},d().createElement("div",{className:"-esm-form-engine__previous-value-review__row___uDsJL"},!r&&d().createElement("div",null,o("previousValue","Previous value:")),d().createElement("div",{className:"-esm-form-engine__previous-value-review__value___ySFyl"},d().createElement(tC,{value:t}))),d().createElement("div",{className:"-esm-form-engine__previous-value-review__reuseButton___n4XbJ",role:"button",tabIndex:0,onClick:t=>{t.preventDefault(),a(n.id,e),i(e)}},o("reuseValue","Reuse value")))},tP=({field:e,fieldValue:t,setFieldValue:n,onAfterChange:r})=>{let{t:i}=(0,eO.useTranslation)(),[o,a]=(0,c.useState)(!1),{sessionMode:l,updateFormField:s}=tO();(0,c.useEffect)(()=>{ej(t)&&"edit"===l&&(a(!0),e.meta.submission||(e.meta.submission={}),e.meta.submission.unspecified=!0)},[]),(0,c.useEffect)(()=>{e.meta.submission?.unspecified&&(e.meta.submission.newValue||!ej(t))&&(e.meta.submission.unspecified=!1,s(e)),a(!!e.meta.submission?.unspecified)},[e.meta?.submission,e.meta.submission?.unspecified,t]);let u=(0,c.useCallback)(t=>{let i=e.questionOptions.rendering;if(t.target.checked){a(!0);let t="checkbox"===i?[]:"";eq(e),e.meta.submission.unspecified=!0,e.meta.submission.errors=[],e.meta.submission.warnings=[],s(e),n(t),r(t)}else a(!1),e.meta.submission.unspecified=!1,s(e)},[e.questionOptions.rendering]);return!e.isHidden&&!(0,tE.H)(e.readonly)&&!eB(l)&&d().createElement("div",{className:"-esm-form-engine__unspecified__unspecified___kJgif"},d().createElement(g.Checkbox,{id:`${e.id}-unspecified`,labelText:i("unspecified","Unspecified"),value:i("unspecified","Unspecified"),onChange:u,checked:o,disabled:e.isDisabled}))},tT=({fieldId:e,valueAdapter:t,repeatOptions:n})=>{var r,i,o;let[a,l]=(0,c.useState)(null),[f,p]=(0,c.useState)([]),[m,g]=(0,c.useState)([]),[y,v]=(0,c.useState)(null),b=tO(),_=!1;try{let e=(0,s.useConfig)({externalModuleName:"@openmrs/esm-form-engine-app"});_=e?.hideUnansweredQuestionsInReadonlyForms??!1}catch(e){console.warn("Failed to load @openmrs/esm-form engine-app config - using hideUnansweredQuestionsInReadonlyForms=false (empty fields will be visible in readonly mode): ",e)}let{methods:{control:w,getValues:x,getFieldState:E},patient:k,sessionMode:S,formFields:O,formFieldValidators:D,addInvalidField:C,removeInvalidField:F,updateFormField:A}=b,P=(0,c.useRef)(null),T=Z({control:w,name:e,exact:!0}),V=(0,c.useMemo)(()=>O.find(t=>t.id===e),[e,O]);(0,c.useEffect)(()=>{var e,t;if(eL(V,"repeating")&&n?.targetRendering?aR(n.targetRendering).then(e=>{e&&l({value:e})}):("obs"==(t=e=V).type&&!t.questionOptions.concept&&"fixed-value"!==t.questionOptions.rendering&&!eL(e,"file")?(e.disabled=!0,e.isDisabled=!0,aR("text")):aR(e.questionOptions.rendering)).then(e=>{e&&l({value:e})}),"enter"===S&&(V.historicalExpression||b.previousDomainObjectValue))try{b.processor.getHistoricalValue(V,b).then(e=>{v(e)})}catch(e){console.error(e)}},[]),(0,c.useEffect)(()=>{let{isDirty:e,isTouched:n}=E(V.id),{submission:r,unspecified:i}=V.meta,{calculate:o,defaultValue:a}=V.questionOptions;!ej(T)&&!r?.newValue&&!e&&!i&&(o?.calculateExpression||a)&&t.transformFieldValue(V,T,b);let l=P.current;P.current=null,(e||n)&&(!l||!(0,h.A)(l.value,T))&&M(T)},[T]),(0,c.useEffect)(()=>{V.meta.submission?.errors&&p(V.meta.submission.errors),V.meta.submission?.warnings&&g(V.meta.submission.warnings),V.meta.submission?.unspecified&&(p([]),F(V.id))},[V.meta.submission]);let M=e=>{V.meta.submission?.unspecified&&!ej(e)&&(V.meta.submission.unspecified=!1);let{errors:n,warnings:r}=tx(V,e,D,{formFields:O,values:x(),expressionContext:{patient:k,mode:S}});if(V.meta.submission&&(V.meta.submission.errors=void 0,V.meta.submission.warnings=void 0),f.length&&!n.length?(F(V.id),p([])):n.length&&(p(n),C(V)),n.length||t.transformFieldValue(V,e,b),g(r),!function(e,t){let{methods:{getValues:n}}=t,r=n();u.FU.includes(e.questionOptions.rendering)&&function(e,t,n){let{sessionMode:r,formFields:i,patient:o,visit:a}=n;e.questionOptions.answers.forEach(n=>{let l=n.disable?.disableWhenExpression;l&&l.includes("myValue")&&(n.disable.isDisabled=tu(n.disable?.disableWhenExpression,{value:e,type:"field"},i,t,{mode:r,patient:o,visit:a}))})}(e,r,t),function(e,t,n){let{sessionMode:r,formFields:i,patient:o,formFieldValidators:a,formJson:l,methods:{setValue:s},updateFormField:u,setForm:c,visit:d}=n,f=!1;e.fieldDependents&&e.fieldDependents.forEach(e=>{let c=i.find(t=>t.id==e);if(c){if(c.questionOptions.calculate?.calculateExpression&&tc(c.questionOptions.calculate.calculateExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d}).then(e=>{s(c.id,e);let{errors:a,warnings:l}=tx(c,e,n.formFieldValidators,{formFields:i,values:t,expressionContext:{patient:o,mode:r}});c.meta.submission||(c.meta.submission={}),c.meta.submission.errors=a,c.meta.submission.warnings=l,a.length||n.formFieldAdapters[c.type].transformFieldValue(c,e,n),u(c)}).catch(e=>{(0,tw.N)(e,"Error evaluating calculate expression")}),c.hide){let e,n=(e=l.pages.find(e=>c.meta.pageId===e.id),e?.sections.find(e=>e.questions.find(e=>e.id===c.id))),a=n?.questions.some(e=>!e.isHidden);if(tg({value:c,type:"field"},i,t,r,o,tu,u),n){n.questions=n?.questions.map(e=>e.id===c.id?c:e);let e=c.isHidden,t=[...n.questions,c].some(e=>!e.isHidden);a||e?a&&!t&&(n.isHidden=!0,f=!0):(n.isHidden=!1,f=!0)}}if("object"==typeof c.disabled&&c.disabled.disableWhenExpression&&(c.isDisabled=function(e,t,n,r,i,o){let{value:a}=e;return o(a.disabled?.disableWhenExpression,e,t,n,{mode:r,patient:i})}({value:c,type:"field"},i,t,r,o,tu)),"object"==typeof c.required&&c.required?.type==="conditionalRequired"&&(c.isRequired=th(c,i,t)),c.validators?.some(e=>"conditionalAnswered"===e.type)){let e=c.validators?.find(e=>"conditionalAnswered"===e.type),n=a.conditionalAnswered.validate(c,c.meta.submission?.newValue,{...e,expressionContext:{patient:o,mode:r},values:t,formFields:i});c.meta.submission={...c.meta.submission,errors:n}}c?.questionOptions.answers?.filter(e=>!ej(e.hide?.hideWhenExpression)).forEach(e=>{e.isHidden=tu(e.hide?.hideWhenExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})}),c?.questionOptions.answers?.filter(e=>!ej(e.disable?.isDisabled)).forEach(e=>{e.disable.isDisabled=tu(e.disable?.disableWhenExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})}),!c.isHidden&&c.meta.readonlyExpression&&(c.readonly=tu(c.meta.readonlyExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})),eL(c,"repeating")&&!ej(c.questionOptions.repeatOptions?.limitExpression)&&(c.questionOptions.repeatOptions.limit=tu(c.questionOptions.repeatOptions?.limitExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})),u(c)}}),e.sectionDependents&&e.sectionDependents.forEach(e=>{for(let n=0;n<l.pages.length;n++){let a=l.pages[n].sections.find(t=>t.label==e);if(a){tg({value:a,type:"section"},i,t,r,o,tu,u),f=!0;break}}}),e.pageDependents&&e.pageDependents?.forEach(e=>{tg({value:l.pages.find(t=>t.label==e),type:"page"},i,t,r,o,tu,u),f=!0}),f&&c(l)}(e,r,t)}(V,b),V.meta.groupId){let e=O.find(e=>e.id===V.meta.groupId);e&&(e.questions=e.questions.map(e=>e.id===V.id?V:e),A(e))}},j=e=>{P.current={value:e},M(e)};if(!a)return null;let I=a.value;return!n?.targetRendering&&tM(V.questionOptions.rendering)?d().createElement(I,{key:V.id,field:V,value:null,errors:f,warnings:m,setFieldValue:null}):(r=!!V.questionOptions.isTransient,i=ej(T),o=_,"embedded-view"===S&&i&&(r||o))?null:d().createElement(eF,{FallbackComponent:tV,onReset:()=>{}},d().createElement(G,{control:w,name:V.id,render:({field:{value:e,onChange:t,onBlur:n}})=>d().createElement("div",null,d().createElement(I,{key:`${V.id}-input-component`,field:V,value:e,errors:f,warnings:m,setFieldValue:e=>{t(e),j(e),n()}}),function(e){let{rendering:t}=e.questionOptions;return(0,tE.H)(e.unspecified)&&"toggle"!=t&&"group"!=t&&"repeating"!=t&&"markdown"!=t&&"extension-widget"!=t&&"workspace-launcher"!=t}(V)&&d().createElement("div",{className:"-esm-form-engine__form-field-renderer__unspecifiedContainer___MoH57"},V.unspecified&&d().createElement(tP,{key:`${V.id}-unspecified`,field:V,setFieldValue:t,onAfterChange:j,fieldValue:e})),y?.value&&d().createElement("div",null,d().createElement(tA,{key:`${V.id}-previous-value-review`,previousValue:y.value,displayText:y.display,onAfterChange:j,field:V})))}))};function tV({error:e}){let{t}=(0,eO.useTranslation)();return d().createElement(g.ToastNotification,{"aria-label":t("closesNotification","Closes notification"),caption:"",hideCloseButton:!0,lowContrast:!0,onClose:function(){},onCloseButtonClick:function(){},statusIconDescription:t("notification","Notification"),subtitle:e.message,title:t("errorRenderingField","Error rendering field")})}function tM(e){return"group"===e||"repeating"===e}let tj=({field:e,...t})=>{let{t:n}=(0,eO.useTranslation)(),{formFieldAdapters:r,formFields:i}=tO(),o=(0,c.useMemo)(()=>e.questions.map(e=>i.find(t=>t.id===e.id)).filter(e=>!e.isHidden).map((n,i)=>{let o=`${n.id}_${i}`;return n.id===e.id?d().createElement(tV,{error:Error("ObsGroup child has same id as parent question")}):"obsGroup"===n.type&&tM(n.questionOptions.rendering)?d().createElement("div",{key:o,className:m.nestedGroupContainer},d().createElement(tj,{field:n,...t})):r[n.type]?d().createElement("div",{className:p()(m.flexColumn),key:o},d().createElement("div",{className:m.groupContainer},d().createElement(tT,{fieldId:n.id,valueAdapter:r[n.type]}))):void 0}),[e,i]);return d().createElement("div",{className:m.groupContainer},o.length>1?d().createElement(g.FormGroup,{legendText:n(e.label),className:m.boldLegend},o):o)},tI=({value:e,tooltipText:t})=>d().createElement("div",{className:"-esm-form-engine__label__label___d9pB3"},d().createElement(g.DefinitionTooltip,{autoAlign:!0,tabIndex:0,definition:t??""},d().createElement("span",{className:"cds--label"},`${e}:`))),tN="-esm-form-engine__field-value-view__inlineFlexColumn___Yd9Fp",tL=({label:e,conceptName:t,value:n,isInline:r})=>d().createElement(d().Fragment,null,r?d().createElement("div",{className:"-esm-form-engine__field-value-view__inlineFlexRow___Rk2F-"},d().createElement("div",{className:tN},d().createElement(tI,{value:e,tooltipText:t})),d().createElement("div",{className:tN},ej(n)?d().createElement(tD,null):d().createElement(tC,{value:n}))):d().createElement("div",{className:"-esm-form-engine__field-value-view__readonly___4EhBN"},d().createElement("div",{className:"-esm-form-engine__field-value-view__formField___aiANn"},d().createElement(tI,{value:e,tooltipText:t}),d().createElement("div",{className:"-esm-form-engine__field-value-view__value___cgPr1"},ej(n)?d().createElement(tD,null):d().createElement(tC,{value:n}))))),tq="-esm-form-engine__content-switcher__boldedLegend___DEeyj";var tR=n(4807);let t$=({field:e,children:t})=>{let{t:n}=(0,eO.useTranslation)();return e.questionInfo?d().createElement(g.Tooltip,{autoAlign:!0,label:n(e.questionInfo)},d().createElement("div",null,t)):d().createElement(d().Fragment,null,t)},tB=({field:e,customLabel:t})=>{let{t:n}=(0,eO.useTranslation)(),r=!!e.questionInfo,i=t||n(e.label);return d().createElement(t$,{field:e},d().createElement("div",{className:"-esm-form-engine__field-label__questionLabel___mFOqM","data-testid":`${e.id}-label`},d().createElement("span",null,i),e.isRequired&&d().createElement("span",{title:n("required","Required"),className:"-esm-form-engine__field-label__required___QIc-5"},"*"),r&&d().createElement(tR.$$,{size:16,"aria-hidden":"true",className:"-esm-form-engine__field-label__tooltipIcon___vCSZl","data-testid":`${e.id}-information-icon`})))},tH=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),[a,l]=(0,c.useState)(""),{layoutType:u,sessionMode:f,workspaceLayout:m}=tO(),h=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(f)||(0,tE.H)(e.readonly))&&tm(e.inlineRendering,u,m,f),[f,e.readonly,e.inlineRendering,u,m]),y=(0,c.useCallback)(e=>{v(e,a),i(e)},[i,a]),v=(0,c.useCallback)((e,t)=>{if(!ej(t)){let[n,r]=t.split(":").map(Number);e.setHours(n??0,r??0)}},[]),b=(0,c.useCallback)(n=>{let r=n.target.value;l(r);let o="timer"===e.datePickerFormat?new Date:new Date(t);v(o,r),i(o)},[i,v,t]);(0,c.useEffect)(()=>{t&&t instanceof Date&&l([10>t.getHours()?`0${t.getHours()}`:`${t.getHours()}`,10>t.getMinutes()?`0${t.getMinutes()}`:`${t.getMinutes()}`].join(":"))},[t]);let _=(0,c.useMemo)(()=>"timer"===e.datePickerFormat?d().createElement(tB,{field:e}):d().createElement(tB,{field:e,customLabel:o("time","Time")}),[e.datePickerFormat,e.label,o]);return"view"==f||"embedded-view"==f||(0,tE.H)(e.readonly)?d().createElement(tL,{label:o(e.label),value:t instanceof Date?ez(e,t):t,conceptName:e.meta?.concept?.display,isInline:h}):!e.isHidden&&d().createElement("div",{className:"-esm-form-engine__date__datetime___z+i2e"},("calendar"===e.datePickerFormat||"both"===e.datePickerFormat)&&d().createElement("div",{className:"-esm-form-engine__date__datePickerSpacing___Lprw3"},d().createElement(g.Layer,null,d().createElement(s.OpenmrsDatePicker,{id:e.id,onChange:y,labelText:d().createElement("span",{className:"-esm-form-engine__date__datePickerLabel___gCHIg"},d().createElement(tB,{field:e})),isDisabled:e.isDisabled,isReadOnly:(0,tE.H)(e.readonly),isRequired:e.isRequired??!1,isInvalid:n.length>0,invalidText:n[0]?.message,value:t})),r.length>0?d().createElement("div",{className:"-esm-form-engine__date__datePickerWarn___GDUCO"},r[0]?.message):null),"both"===e.datePickerFormat||"timer"===e.datePickerFormat?d().createElement("div",null,d().createElement(g.Layer,null,d().createElement(g.TimePicker,{className:p()("-esm-form-engine__date__boldedLabel___cGCdn","-esm-form-engine__date__timeInput___E1vhw"),id:e.id,labelText:_,placeholder:"HH:MM",pattern:"(1[012]|[1-9]):[0-5][0-9]$",type:"time",disabled:"timer"===e.datePickerFormat?e.isDisabled:!t,invalid:n.length>0,invalidText:n[0]?.message,readOnly:(0,tE.H)(e.readonly),warning:r.length>0,warningText:r[0]?.message,value:a||(t instanceof Date?t.toLocaleDateString(window.navigator.language):t),onChange:b}))):null)},tz=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tU=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tW={};function tY(e,t){return((t||tW).jsx?tU:tz).test(e)}let tJ=/[ \t\n\f\r]/g;function tZ(e){return""===e.replace(tJ,"")}class tG{constructor(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}}function tQ(e,t){let n={},r={},i=-1;for(;++i<e.length;)Object.assign(n,e[i].property),Object.assign(r,e[i].normal);return new tG(n,r,t)}function tK(e){return e.toLowerCase()}tG.prototype.property={},tG.prototype.normal={},tG.prototype.space=null;class tX{constructor(e,t){this.property=e,this.attribute=t}}tX.prototype.space=null,tX.prototype.boolean=!1,tX.prototype.booleanish=!1,tX.prototype.overloadedBoolean=!1,tX.prototype.number=!1,tX.prototype.commaSeparated=!1,tX.prototype.spaceSeparated=!1,tX.prototype.commaOrSpaceSeparated=!1,tX.prototype.mustUseProperty=!1,tX.prototype.defined=!1;let t0=0,t1=t7(),t2=t7(),t4=t7(),t3=t7(),t5=t7(),t6=t7(),t9=t7();function t7(){return 2**++t0}let t8=Object.keys(i);class ne extends tX{constructor(e,t,n,r){let o=-1;if(super(e,t),function(e,t,n){n&&(e[t]=n)}(this,"space",r),"number"==typeof n)for(;++o<t8.length;){const e=t8[o];!function(e,t,n){n&&(e[t]=n)}(this,t8[o],(n&i[e])===i[e])}}}ne.prototype.defined=!0;let nt={}.hasOwnProperty;function nn(e){let t,n={},r={};for(t in e.properties)if(nt.call(e.properties,t)){let i=e.properties[t],o=new ne(t,e.transform(e.attributes||{},t),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(t)&&(o.mustUseProperty=!0),n[t]=o,r[tK(t)]=t,r[tK(o.attribute)]=t}return new tG(n,r,e.space)}let nr=nn({space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase(),properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}}),ni=nn({space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase(),properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function no(e,t){return t in e?e[t]:t}function na(e,t){return no(e,t.toLowerCase())}let nl=nn({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:na,properties:{xmlns:null,xmlnsXLink:null}}),ns=nn({transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase(),properties:{ariaActiveDescendant:null,ariaAtomic:t2,ariaAutoComplete:null,ariaBusy:t2,ariaChecked:t2,ariaColCount:t3,ariaColIndex:t3,ariaColSpan:t3,ariaControls:t5,ariaCurrent:null,ariaDescribedBy:t5,ariaDetails:null,ariaDisabled:t2,ariaDropEffect:t5,ariaErrorMessage:null,ariaExpanded:t2,ariaFlowTo:t5,ariaGrabbed:t2,ariaHasPopup:null,ariaHidden:t2,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:t5,ariaLevel:t3,ariaLive:null,ariaModal:t2,ariaMultiLine:t2,ariaMultiSelectable:t2,ariaOrientation:null,ariaOwns:t5,ariaPlaceholder:null,ariaPosInSet:t3,ariaPressed:t2,ariaReadOnly:t2,ariaRelevant:null,ariaRequired:t2,ariaRoleDescription:t5,ariaRowCount:t3,ariaRowIndex:t3,ariaRowSpan:t3,ariaSelected:t2,ariaSetSize:t3,ariaSort:null,ariaValueMax:t3,ariaValueMin:t3,ariaValueNow:t3,ariaValueText:null,role:null}}),nu=nn({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:na,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:t6,acceptCharset:t5,accessKey:t5,action:null,allow:null,allowFullScreen:t1,allowPaymentRequest:t1,allowUserMedia:t1,alt:null,as:null,async:t1,autoCapitalize:null,autoComplete:t5,autoFocus:t1,autoPlay:t1,capture:t1,charSet:null,checked:t1,cite:null,className:t5,cols:t3,colSpan:null,content:null,contentEditable:t2,controls:t1,controlsList:t5,coords:t3|t6,crossOrigin:null,data:null,dateTime:null,decoding:null,default:t1,defer:t1,dir:null,dirName:null,disabled:t1,download:t4,draggable:t2,encType:null,enterKeyHint:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:t1,formTarget:null,headers:t5,height:t3,hidden:t1,high:t3,href:null,hrefLang:null,htmlFor:t5,httpEquiv:t5,id:null,imageSizes:null,imageSrcSet:null,inputMode:null,integrity:null,is:null,isMap:t1,itemId:null,itemProp:t5,itemRef:t5,itemScope:t1,itemType:t5,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:t1,low:t3,manifest:null,max:null,maxLength:t3,media:null,method:null,min:null,minLength:t3,multiple:t1,muted:t1,name:null,nonce:null,noModule:t1,noValidate:t1,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:t1,optimum:t3,pattern:null,ping:t5,placeholder:null,playsInline:t1,poster:null,preload:null,readOnly:t1,referrerPolicy:null,rel:t5,required:t1,reversed:t1,rows:t3,rowSpan:t3,sandbox:t5,scope:null,scoped:t1,seamless:t1,selected:t1,shape:null,size:t3,sizes:null,slot:null,span:t3,spellCheck:t2,src:null,srcDoc:null,srcLang:null,srcSet:null,start:t3,step:null,style:null,tabIndex:t3,target:null,title:null,translate:null,type:null,typeMustMatch:t1,useMap:null,value:t2,width:t3,wrap:null,align:null,aLink:null,archive:t5,axis:null,background:null,bgColor:null,border:t3,borderColor:null,bottomMargin:t3,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:t1,declare:t1,event:null,face:null,frame:null,frameBorder:null,hSpace:t3,leftMargin:t3,link:null,longDesc:null,lowSrc:null,marginHeight:t3,marginWidth:t3,noResize:t1,noHref:t1,noShade:t1,noWrap:t1,object:null,profile:null,prompt:null,rev:null,rightMargin:t3,rules:null,scheme:null,scrolling:t2,standby:null,summary:null,text:null,topMargin:t3,valueType:null,version:null,vAlign:null,vLink:null,vSpace:t3,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:t1,disableRemotePlayback:t1,prefix:null,property:null,results:t3,security:null,unselectable:null}}),nc=nn({space:"svg",attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},transform:no,properties:{about:t9,accentHeight:t3,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:t3,amplitude:t3,arabicForm:null,ascent:t3,attributeName:null,attributeType:null,azimuth:t3,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:t3,by:null,calcMode:null,capHeight:t3,className:t5,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:t3,diffuseConstant:t3,direction:null,display:null,dur:null,divisor:t3,dominantBaseline:null,download:t1,dx:null,dy:null,edgeMode:null,editable:null,elevation:t3,enableBackground:null,end:null,event:null,exponent:t3,externalResourcesRequired:null,fill:null,fillOpacity:t3,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:t6,g2:t6,glyphName:t6,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:t3,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:t3,horizOriginX:t3,horizOriginY:t3,id:null,ideographic:t3,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:t3,k:t3,k1:t3,k2:t3,k3:t3,k4:t3,kernelMatrix:t9,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:t3,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:t3,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:t3,overlineThickness:t3,paintOrder:null,panose1:null,path:null,pathLength:t3,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:t5,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:t3,pointsAtY:t3,pointsAtZ:t3,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:t9,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:t9,rev:t9,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:t9,requiredFeatures:t9,requiredFonts:t9,requiredFormats:t9,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:t3,specularExponent:t3,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:t3,strikethroughThickness:t3,string:null,stroke:null,strokeDashArray:t9,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:t3,strokeOpacity:t3,strokeWidth:null,style:null,surfaceScale:t3,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:t9,tabIndex:t3,tableValues:null,target:null,targetX:t3,targetY:t3,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:t9,to:null,transform:null,u1:null,u2:null,underlinePosition:t3,underlineThickness:t3,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:t3,values:null,vAlphabetic:t3,vMathematical:t3,vectorEffect:null,vHanging:t3,vIdeographic:t3,version:null,vertAdvY:t3,vertOriginX:t3,vertOriginY:t3,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:t3,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}}),nd=tQ([ni,nr,nl,ns,nu],"html"),nf=tQ([ni,nr,nl,ns,nc],"svg"),np=/^data[-\w.:]+$/i,nm=/-[a-z]/g,nh=/[A-Z]/g;function ng(e){return"-"+e.toLowerCase()}function ny(e){return e.charAt(1).toUpperCase()}let nv={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};var nb=n(8052);let n_=nb.default||nb,nw=nE("end"),nx=nE("start");function nE(e){return function(t){let n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function nk(e){return e&&"object"==typeof e?"position"in e||"type"in e?nO(e.position):"start"in e||"end"in e?nO(e):"line"in e||"column"in e?nS(e):"":""}function nS(e){return nD(e&&e.line)+":"+nD(e&&e.column)}function nO(e){return nS(e&&e.start)+"-"+nS(e&&e.end)}function nD(e){return e&&"number"==typeof e?e:1}class nC extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",i={},o=!1;if(t&&(i="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!i.cause&&e&&(o=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){const e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}const a=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file,this.message=r,this.line=a?a.line:void 0,this.name=nk(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=o&&i.cause&&"string"==typeof i.cause.stack?i.cause.stack:"",this.actual,this.expected,this.note,this.url}}nC.prototype.file="",nC.prototype.name="",nC.prototype.reason="",nC.prototype.message="",nC.prototype.stack="",nC.prototype.column=void 0,nC.prototype.line=void 0,nC.prototype.ancestors=void 0,nC.prototype.cause=void 0,nC.prototype.fatal=void 0,nC.prototype.place=void 0,nC.prototype.ruleId=void 0,nC.prototype.source=void 0;let nF={}.hasOwnProperty,nA=new Map,nP=/[A-Z]/g,nT=/-([a-z])/g,nV=new Set(["table","tbody","thead","tfoot","tr"]),nM=new Set(["td","th"]),nj="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function nI(e,t,n){var r,i,o,a,l,s,u,c,d;let f,p,m,h,g,y,v,b,_,w,x;return"element"===t.type?(r=e,i=t,o=n,p=f=r.schema,"svg"===i.tagName.toLowerCase()&&"html"===f.space&&(r.schema=nf),r.ancestors.push(i),m=nR(r,i.tagName,!1),h=function(e,t){let n,r,i={};for(r in t.properties)if("children"!==r&&nF.call(t.properties,r)){let o=function(e,t,n){let r=function(e,t){let n=tK(t),r=t,i=tX;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&np.test(t)){if("-"===t.charAt(4)){let e=t.slice(5).replace(nm,ny);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!nm.test(e)){let n=e.replace(nh,ng);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}i=ne}return new i(r,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){var i;let t;if(Array.isArray(n)&&(n=r.commaSeparated?(t={},(""===(i=n)[i.length-1]?[...i,""]:i).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()):n.join(" ").trim()),"style"===r.property){let t="object"==typeof n?n:function(e,t){let n={};try{n_(t,function(e,t){let r=e;"--"!==r.slice(0,2)&&("-ms-"===r.slice(0,4)&&(r="ms-"+r.slice(4)),r=r.replace(nT,nB)),n[r]=t})}catch(t){if(!e.ignoreInvalidStyle){let n=new nC("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:t,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=nj+"#cannot-parse-style-attribute",n}}return n}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){let t,n={};for(t in e)nF.call(e,t)&&(n[function(e){let t=e.replace(nP,nH);return"ms-"===t.slice(0,3)&&(t="-"+t),t}(t)]=e[t]);return n}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?nv[r.property]||r.property:r.attribute,n]}}(e,r,t.properties[r]);if(o){let[r,a]=o;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof a&&nM.has(t.tagName)?n=a:i[r]=a}}return n&&((i.style||(i.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),i}(r,i),g=nq(r,i),nV.has(i.tagName)&&(g=g.filter(function(e){return"string"!=typeof e||!("object"==typeof e?"text"===e.type&&tZ(e.value):tZ(e))})),nN(r,h,m,i),nL(h,g),r.ancestors.pop(),r.schema=f,r.create(i,m,h,o)):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}n$(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?(a=e,l=t,s=n,v=y=a.schema,"svg"===l.name&&"html"===y.space&&(a.schema=nf),a.ancestors.push(l),b=null===l.name?a.Fragment:nR(a,l.name,!0),_=function(e,t){let n={};for(let r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let o=i.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else n$(e,t.position);else{let i,o=r.name;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,i=e.evaluater.evaluateExpression(t.expression)}else n$(e,t.position);else i=null===r.value||r.value;n[o]=i}return n}(a,l),w=nq(a,l),nN(a,_,b,l),nL(_,w),a.ancestors.pop(),a.schema=y,a.create(l,b,_,s)):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);n$(e,t.position)}(e,t):"root"===t.type?(u=e,c=t,d=n,nL(x={},nq(u,c)),u.create(c,u.Fragment,x,d)):"text"===t.type?t.value:void 0}function nN(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function nL(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function nq(e,t){let n=[],r=-1,i=e.passKeys?new Map:nA;for(;++r<t.children.length;){let o,a=t.children[r];if(e.passKeys){let e="element"===a.type?a.tagName:"mdxJsxFlowElement"===a.type||"mdxJsxTextElement"===a.type?a.name:void 0;if(e){let t=i.get(e)||0;o=e+"-"+t,i.set(e,t+1)}}let l=nI(e,a,o);void 0!==l&&n.push(l)}return n}function nR(e,t,n){let r;if(n)if(t.includes(".")){let e,n=t.split("."),i=-1;for(;++i<n.length;){let t=tY(n[i])?{type:"Identifier",name:n[i]}:{type:"Literal",value:n[i]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(i&&"Literal"===t.type),optional:!1}:t}r=e}else r=tY(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){let t=r.value;return nF.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);n$(e)}function n$(e,t){let n=new nC("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=nj+"#cannot-handle-mdx-estrees-without-createevaluater",n}function nB(e,t){return t.toUpperCase()}function nH(e){return"-"+e.toLowerCase()}let nz={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]};var nU=n(1085);let nW={};function nY(e,t,n){var r;if((r=e)&&"object"==typeof r){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return nJ(e.children,t,n)}return Array.isArray(e)?nJ(e,t,n):""}function nJ(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=nY(e[i],t,n);return r.join("")}function nZ(e,t,n,r){let i,o=e.length,a=0;if(t=t<0?-t>o?0:o+t:t>o?o:t,n=n>0?n:0,r.length<1e4)(i=Array.from(r)).unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);a<r.length;)(i=r.slice(a,a+1e4)).unshift(t,0),e.splice(...i),a+=1e4,t+=1e4}function nG(e,t){return e.length>0?(nZ(e,e.length,0,t),e):t}class nQ{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=null==t?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){this.setCursor(Math.trunc(e));let r=this.right.splice(this.right.length-(t||0),1/0);return n&&nK(this.left,n),r.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),nK(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),nK(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let t=this.left.splice(e,1/0);nK(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);nK(this.left,t.reverse())}}}function nK(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function nX(e){let t,n,r,i,o,a,l,s={},u=-1,c=new nQ(e);for(;++u<c.length;){for(;u in s;)u=s[u];if(t=c.get(u),u&&"chunkFlow"===t[1].type&&"listItemPrefix"===c.get(u-1)[1].type&&((r=0)<(a=t[1]._tokenizer.events).length&&"lineEndingBlank"===a[r][1].type&&(r+=2),r<a.length&&"content"===a[r][1].type))for(;++r<a.length&&"content"!==a[r][1].type;)"chunkText"===a[r][1].type&&(a[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===t[0])t[1].contentType&&(Object.assign(s,function(e,t){let n,r,i=e.get(t)[1],o=e.get(t)[2],a=t-1,l=[],s=i._tokenizer||o.parser[i.contentType](i.start),u=s.events,c=[],d={},f=-1,p=i,m=0,h=0,g=[0];for(;p;){for(;e.get(++a)[1]!==p;);l.push(a),!p._tokenizer&&(n=o.sliceStream(p),p.next||n.push(null),r&&s.defineSkip(p.start),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(n),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),r=p,p=p.next}for(p=i;++f<u.length;)"exit"===u[f][0]&&"enter"===u[f-1][0]&&u[f][1].type===u[f-1][1].type&&u[f][1].start.line!==u[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(s.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=u.slice(g[f],g[f+1]),n=l.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)d[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return d}(c,u)),u=s[u],l=!0);else if(t[1]._container){for(r=u,n=void 0;r--;)if("lineEnding"===(i=c.get(r))[1].type||"lineEndingBlank"===i[1].type)"enter"===i[0]&&(n&&(c.get(n)[1].type="lineEndingBlank"),i[1].type="lineEnding",n=r);else break;n&&(t[1].end={...c.get(n)[1].start},(o=c.slice(n,u)).unshift(t),c.splice(n,u-n+1,o))}}return nZ(e,0,1/0,c.slice(0)),!l}let n0={}.hasOwnProperty,n1=rr(/[A-Za-z]/),n2=rr(/[\dA-Za-z]/),n4=rr(/[#-'*+\--9=?A-Z^-~]/);function n3(e){return null!==e&&(e<32||127===e)}let n5=rr(/\d/),n6=rr(/[\dA-Fa-f]/),n9=rr(/[!-/:-@[-`{-~]/);function n7(e){return null!==e&&e<-2}function n8(e){return null!==e&&(e<0||32===e)}function re(e){return -2===e||-1===e||32===e}let rt=rr(/\p{P}|\p{S}/u),rn=rr(/\s/);function rr(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function ri(e,t,n,r){let i=r?r-1:1/0,o=0;return function(r){return re(r)?(e.enter(n),function r(a){return re(a)&&o++<i?(e.consume(a),r):(e.exit(n),t(a))}(r)):t(r)}}let ro={tokenize:function(e){let t,n=e.attempt(this.parser.constructs.contentInitial,function(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),ri(e,n,"linePrefix"))},function(n){return e.enter("paragraph"),function n(r){let i=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=i),t=i,function t(r){if(null===r){e.exit("chunkText"),e.exit("paragraph"),e.consume(r);return}return n7(r)?(e.consume(r),e.exit("chunkText"),n):(e.consume(r),t)}(r)}(n)});return n}},ra={tokenize:function(e){let t,n,r,i=this,o=[],a=0;return l;function l(t){if(a<o.length){let n=o[a];return i.containerState=n[1],e.attempt(n[0].continuation,s,u)(t)}return u(t)}function s(e){if(a++,i.containerState._closeFlow){let n;i.containerState._closeFlow=void 0,t&&y();let r=i.events.length,o=r;for(;o--;)if("exit"===i.events[o][0]&&"chunkFlow"===i.events[o][1].type){n=i.events[o][1].end;break}g(a);let l=r;for(;l<i.events.length;)i.events[l][1].end={...n},l++;return nZ(i.events,o+1,0,i.events.slice(r)),i.events.length=l,u(e)}return l(e)}function u(n){if(a===o.length){if(!t)return f(n);if(t.currentConstruct&&t.currentConstruct.concrete)return m(n);i.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return i.containerState={},e.check(rl,c,d)(n)}function c(e){return t&&y(),g(a),f(e)}function d(e){return i.parser.lazy[i.now().line]=a!==o.length,r=i.now().offset,m(e)}function f(t){return i.containerState={},e.attempt(rl,p,m)(t)}function p(e){return a++,o.push([i.currentConstruct,i.containerState]),f(e)}function m(r){if(null===r){t&&y(),g(0),e.consume(r);return}return t=t||i.parser.flow(i.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:n}),function t(n){if(null===n){h(e.exit("chunkFlow"),!0),g(0),e.consume(n);return}return n7(n)?(e.consume(n),h(e.exit("chunkFlow")),a=0,i.interrupt=void 0,l):(e.consume(n),t)}(r)}function h(e,o){let l=i.sliceStream(e);if(o&&l.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(l),i.parser.lazy[e.start.line]){let e,n,o=t.events.length;for(;o--;)if(t.events[o][1].start.offset<r&&(!t.events[o][1].end||t.events[o][1].end.offset>r))return;let l=i.events.length,s=l;for(;s--;)if("exit"===i.events[s][0]&&"chunkFlow"===i.events[s][1].type){if(e){n=i.events[s][1].end;break}e=!0}for(g(a),o=l;o<i.events.length;)i.events[o][1].end={...n},o++;nZ(i.events,s+1,0,i.events.slice(l)),i.events.length=o}}function g(t){let n=o.length;for(;n-- >t;){let t=o[n];i.containerState=t[1],t[0].exit.call(i,e)}o.length=t}function y(){t.write([null]),n=void 0,t=void 0,i.containerState._closeFlow=void 0}}},rl={tokenize:function(e,t,n){return ri(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},rs={partial:!0,tokenize:function(e,t,n){return function(t){return re(t)?ri(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||n7(e)?t(e):n(e)}}},ru={resolve:function(e){return nX(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?i(t):n7(t)?e.check(rc,o,i)(t):(e.consume(t),r)}function i(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function o(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},rc={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),ri(e,i,"linePrefix")};function i(i){if(null===i||n7(i))return n(i);let o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}},rd={tokenize:function(e){let t=this,n=e.attempt(rs,function(r){return null===r?void e.consume(r):(e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)},e.attempt(this.parser.constructs.flowInitial,r,ri(e,e.attempt(this.parser.constructs.flow,r,e.attempt(ru,r)),"linePrefix")));return n;function r(r){return null===r?void e.consume(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}},rf={resolveAll:rg()},rp=rh("string"),rm=rh("text");function rh(e){return{resolveAll:rg("text"===e?ry:void 0),tokenize:function(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,o,a);return o;function o(e){return s(e)?i(e):a(e)}function a(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),l)}function l(e){return s(e)?(t.exit("data"),i(e)):(t.consume(e),l)}function s(e){if(null===e)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function rg(e){return function(t,n){let r,i=-1;for(;++i<=t.length;)void 0===r?t[i]&&"data"===t[i][1].type&&(r=i,i++):t[i]&&"data"===t[i][1].type||(i!==r+2&&(t[r][1].end=t[i-1][1].end,t.splice(r+2,i-r-2),i=r+2),r=void 0);return e?e(t,n):t}}function ry(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let r,i=e[n-1][1],o=t.sliceStream(i),a=o.length,l=-1,s=0;for(;a--;){let e=o[a];if("string"==typeof e){for(l=e.length;32===e.charCodeAt(l-1);)s++,l--;if(l)break;l=-1}else if(-2===e)r=!0,s++;else if(-1===e);else{a++;break}}if(s){let o={type:n===e.length||r||s<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?l:i.start._bufferIndex+l,_index:i.start._index+a,line:i.end.line,column:i.end.column-s,offset:i.end.offset-s},end:{...i.end}};i.end={...o.start},i.start.offset===i.end.offset?Object.assign(i,o):(e.splice(n,0,["enter",o,t],["exit",o,t]),n+=2)}n++}return e}let rv={name:"thematicBreak",tokenize:function(e,t,n){let r,i=0;return function(o){var a;return e.enter("thematicBreak"),r=a=o,function o(a){return a===r?(e.enter("thematicBreakSequence"),function t(n){return n===r?(e.consume(n),i++,t):(e.exit("thematicBreakSequence"),re(n)?ri(e,o,"whitespace")(n):o(n))}(a)):i>=3&&(null===a||n7(a))?(e.exit("thematicBreak"),t(a)):n(a)}(a)}}},rb={continuation:{tokenize:function(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(rs,function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ri(e,t,"listItemIndent",r.containerState.size+1)(n)},function(n){return r.containerState.furtherBlankLines||!re(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(rw,t,i)(n))});function i(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,ri(e,e.attempt(rb,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){let r=this,i=r.events[r.events.length-1],o=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,a=0;return function(t){let i=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===i?!r.containerState.marker||t===r.containerState.marker:n5(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),"listUnordered"===i)return e.enter("listItemPrefix"),42===t||45===t?e.check(rv,n,l)(t):l(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),function t(i){return n5(i)&&++a<10?(e.consume(i),t):(!r.interrupt||a<2)&&(r.containerState.marker?i===r.containerState.marker:41===i||46===i)?(e.exit("listItemValue"),l(i)):n(i)}(t)}return n(t)};function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(rs,r.interrupt?n:s,e.attempt(r_,c,u))}function s(e){return r.containerState.initialBlankLine=!0,o++,c(e)}function u(t){return re(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),c):n(t)}function c(n){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},r_={partial:!0,tokenize:function(e,t,n){let r=this;return ri(e,function(e){let i=r.events[r.events.length-1];return!re(e)&&i&&"listItemPrefixWhitespace"===i[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},rw={partial:!0,tokenize:function(e,t,n){let r=this;return ri(e,function(e){let i=r.events[r.events.length-1];return i&&"listItemIndent"===i[1].type&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)}},rx={continuation:{tokenize:function(e,t,n){let r=this;return function(t){return re(t)?ri(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):i(t)};function i(r){return e.attempt(rx,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){let r=this;return function(t){if(62===t){let n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),i}return n(t)};function i(n){return re(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};function rE(e,t,n,r,i,o,a,l,s){let u=s||1/0,c=0;return function(t){return 60===t?(e.enter(r),e.enter(i),e.enter(o),e.consume(t),e.exit(o),d):null===t||32===t||41===t||n3(t)?n(t):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),m(t))};function d(n){return 62===n?(e.enter(o),e.consume(n),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),f(n))}function f(t){return 62===t?(e.exit("chunkString"),e.exit(l),d(t)):null===t||60===t||n7(t)?n(t):(e.consume(t),92===t?p:f)}function p(t){return 60===t||62===t||92===t?(e.consume(t),f):f(t)}function m(i){return!c&&(null===i||41===i||n8(i))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(i)):c<u&&40===i?(e.consume(i),c++,m):41===i?(e.consume(i),c--,m):null===i||32===i||40===i||n3(i)?n(i):(e.consume(i),92===i?h:m)}function h(t){return 40===t||41===t||92===t?(e.consume(t),m):m(t)}}function rk(e,t,n,r,i,o){let a,l=this,s=0;return function(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(o),u};function u(d){return s>999||null===d||91===d||93===d&&!a||94===d&&!s&&"_hiddenFootnoteSupport"in l.parser.constructs?n(d):93===d?(e.exit(o),e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):n7(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),c(d))}function c(t){return null===t||91===t||93===t||n7(t)||s++>999?(e.exit("chunkString"),u(t)):(e.consume(t),a||(a=!re(t)),92===t?d:c)}function d(t){return 91===t||92===t||93===t?(e.consume(t),s++,c):c(t)}}function rS(e,t,n,r,i,o){let a;return function(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),a=40===t?41:t,l):n(t)};function l(n){return n===a?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(o),s(n))}function s(t){return t===a?(e.exit(o),l(a)):null===t?n(t):n7(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),ri(e,s,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(t))}function u(t){return t===a||null===t||n7(t)?(e.exit("chunkString"),s(t)):(e.consume(t),92===t?c:u)}function c(t){return t===a||92===t?(e.consume(t),u):u(t)}}function rO(e,t){let n;return function r(i){return n7(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):re(i)?ri(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}function rD(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let rC={partial:!0,tokenize:function(e,t,n){return function(t){return n8(t)?rO(e,r)(t):n(t)};function r(t){return rS(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function i(t){return re(t)?ri(e,o,"whitespace")(t):o(t)}function o(e){return null===e||n7(e)?t(e):n(e)}}},rF={name:"codeIndented",tokenize:function(e,t,n){let r=this;return function(t){return e.enter("codeIndented"),ri(e,i,"linePrefix",5)(t)};function i(t){let i=r.events[r.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?function t(n){return null===n?o(n):n7(n)?e.attempt(rA,t,o)(n):(e.enter("codeFlowValue"),function n(r){return null===r||n7(r)?(e.exit("codeFlowValue"),t(r)):(e.consume(r),n)}(n))}(t):n(t)}function o(n){return e.exit("codeIndented"),t(n)}}},rA={partial:!0,tokenize:function(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):n7(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):ri(e,o,"linePrefix",5)(t)}function o(e){let o=r.events[r.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(e):n7(e)?i(e):n(e)}}},rP={name:"setextUnderline",resolveTo:function(e,t){let n,r,i,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){n=o;break}"paragraph"===e[o][1].type&&(r=o)}else"content"===e[o][1].type&&e.splice(o,1),i||"definition"!==e[o][1].type||(i=o);let a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",i?(e.splice(r,0,["enter",a,t]),e.splice(i+1,0,["exit",e[n][1],t]),e[n][1].end={...e[i][1].end}):e[n][1]=a,e.push(["exit",a,t]),e},tokenize:function(e,t,n){let r,i=this;return function(t){var a;let l,s=i.events.length;for(;s--;)if("lineEnding"!==i.events[s][1].type&&"linePrefix"!==i.events[s][1].type&&"content"!==i.events[s][1].type){l="paragraph"===i.events[s][1].type;break}return!i.parser.lazy[i.now().line]&&(i.interrupt||l)?(e.enter("setextHeadingLine"),r=t,a=t,e.enter("setextHeadingLineSequence"),function t(n){return n===r?(e.consume(n),t):(e.exit("setextHeadingLineSequence"),re(n)?ri(e,o,"lineSuffix")(n):o(n))}(a)):n(t)};function o(r){return null===r||n7(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}},rT=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],rV=["pre","script","style","textarea"],rM={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(rs,t,n)}}},rj={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return n7(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):n(t)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},rI={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},rN={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){let r,i=this,o={partial:!0,tokenize:function(e,t,n){let o=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a};function a(t){return e.enter("codeFencedFence"),re(t)?ri(e,s,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):s(t)}function s(t){return t===r?(e.enter("codeFencedFenceSequence"),function t(i){return i===r?(o++,e.consume(i),t):o>=l?(e.exit("codeFencedFenceSequence"),re(i)?ri(e,u,"whitespace")(i):u(i)):n(i)}(t)):n(t)}function u(r){return null===r||n7(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}},a=0,l=0;return function(t){var o;let u;return o=t,a=(u=i.events[i.events.length-1])&&"linePrefix"===u[1].type?u[2].sliceSerialize(u[1],!0).length:0,r=o,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function t(i){return i===r?(l++,e.consume(i),t):l<3?n(i):(e.exit("codeFencedFenceSequence"),re(i)?ri(e,s,"whitespace")(i):s(i))}(o)};function s(o){return null===o||n7(o)?(e.exit("codeFencedFence"),i.interrupt?t(o):e.check(rI,c,m)(o)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||n7(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),s(i)):re(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ri(e,u,"whitespace")(i)):96===i&&i===r?n(i):(e.consume(i),t)}(o))}function u(t){return null===t||n7(t)?s(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||n7(i)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),s(i)):96===i&&i===r?n(i):(e.consume(i),t)}(t))}function c(t){return e.attempt(o,m,d)(t)}function d(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),f}function f(t){return a>0&&re(t)?ri(e,p,"linePrefix",a+1)(t):p(t)}function p(t){return null===t||n7(t)?e.check(rI,c,m)(t):(e.enter("codeFlowValue"),function t(n){return null===n||n7(n)?(e.exit("codeFlowValue"),p(n)):(e.consume(n),t)}(t))}function m(n){return e.exit("codeFenced"),t(n)}}},rL=document.createElement("i");function rq(e){let t="&"+e+";";rL.innerHTML=t;let n=rL.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}let rR={name:"characterReference",tokenize:function(e,t,n){let r,i,o=this,a=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),l};function l(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),s):(e.enter("characterReferenceValue"),r=31,i=n2,u(t))}function s(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,i=n6,u):(e.enter("characterReferenceValue"),r=7,i=n5,u(t))}function u(l){if(59===l&&a){let r=e.exit("characterReferenceValue");return i!==n2||rq(o.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(l),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(l)}return i(l)&&a++<r?(e.consume(l),u):n(l)}}},r$={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return n9(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}},rB={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),ri(e,t,"linePrefix")}}};function rH(e,t,n){let r=[],i=-1;for(;++i<e.length;){let o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}let rz={name:"labelEnd",resolveAll:function(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){let e="labelImage"===r.type?4:2;r.type="data",t+=e}}return e.length!==n.length&&nZ(e,0,e.length,n),e},resolveTo:function(e,t){let n,r,i,o,a=e.length,l=0;for(;a--;)if(n=e[a][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[a][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(i){if("enter"===e[a][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=a,"labelLink"!==n.type)){l=2;break}}else"labelEnd"===n.type&&(i=a);let s={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[r][1].start},end:{...e[i][1].end}},c={type:"labelText",start:{...e[r+l+2][1].end},end:{...e[i-2][1].start}};return o=nG(o=[["enter",s,t],["enter",u,t]],e.slice(r+1,r+l+3)),o=nG(o,[["enter",c,t]]),o=nG(o,rH(t.parser.constructs.insideSpan.null,e.slice(r+l+4,i-3),t)),o=nG(o,[["exit",c,t],e[i-2],e[i-1],["exit",u,t]]),o=nG(o,e.slice(i+1)),o=nG(o,[["exit",s,t]]),nZ(e,r,e.length,o),e},tokenize:function(e,t,n){let r,i,o=this,a=o.events.length;for(;a--;)if(("labelImage"===o.events[a][1].type||"labelLink"===o.events[a][1].type)&&!o.events[a][1]._balanced){r=o.events[a][1];break}return function(t){return r?r._inactive?c(t):(i=o.parser.defined.includes(rD(o.sliceSerialize({start:r.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),l):n(t)};function l(t){return 40===t?e.attempt(rU,u,i?u:c)(t):91===t?e.attempt(rW,u,i?s:c)(t):i?u(t):c(t)}function s(t){return e.attempt(rY,u,c)(t)}function u(e){return t(e)}function c(e){return r._balanced=!0,n(e)}}},rU={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return n8(t)?rO(e,i)(t):i(t)}function i(t){return 41===t?u(t):rE(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function o(t){return n8(t)?rO(e,l)(t):u(t)}function a(e){return n(e)}function l(t){return 34===t||39===t||40===t?rS(e,s,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):u(t)}function s(t){return n8(t)?rO(e,u)(t):u(t)}function u(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},rW={tokenize:function(e,t,n){let r=this;return function(t){return rk.call(r,e,i,o,"reference","referenceMarker","referenceString")(t)};function i(e){return r.parser.defined.includes(rD(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}},rY={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}},rJ={name:"labelStartImage",resolveAll:rz.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),i};function i(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),o):n(t)}function o(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};function rZ(e){return null===e||n8(e)||rn(e)?1:rt(e)?2:void 0}let rG={name:"attention",resolveAll:function(e,t){let n,r,i,o,a,l,s,u,c=-1;for(;++c<e.length;)if("enter"===e[c][0]&&"attentionSequence"===e[c][1].type&&e[c][1]._close){for(n=c;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[c][1]).charCodeAt(0)){if((e[n][1]._close||e[c][1]._open)&&(e[c][1].end.offset-e[c][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[c][1].end.offset-e[c][1].start.offset)%3))continue;l=e[n][1].end.offset-e[n][1].start.offset>1&&e[c][1].end.offset-e[c][1].start.offset>1?2:1;let d={...e[n][1].end},f={...e[c][1].start};rQ(d,-l),rQ(f,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[c][1].start},end:f},i={type:l>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[c][1].start}},r={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[n][1].end={...o.start},e[c][1].start={...a.end},s=[],e[n][1].end.offset-e[n][1].start.offset&&(s=nG(s,[["enter",e[n][1],t],["exit",e[n][1],t]])),s=nG(s,[["enter",r,t],["enter",o,t],["exit",o,t],["enter",i,t]]),s=nG(s,rH(t.parser.constructs.insideSpan.null,e.slice(n+1,c),t)),s=nG(s,[["exit",i,t],["enter",a,t],["exit",a,t],["exit",r,t]]),e[c][1].end.offset-e[c][1].start.offset?(u=2,s=nG(s,[["enter",e[c][1],t],["exit",e[c][1],t]])):u=0,nZ(e,n-1,c-n+3,s),c=n+s.length-u-2;break}}for(c=-1;++c<e.length;)"attentionSequence"===e[c][1].type&&(e[c][1].type="data");return e},tokenize:function(e,t){let n,r=this.parser.constructs.attentionMarkers.null,i=this.previous,o=rZ(i);return function(a){return n=a,e.enter("attentionSequence"),function a(l){if(l===n)return e.consume(l),a;let s=e.exit("attentionSequence"),u=rZ(l),c=!u||2===u&&o||r.includes(l),d=!o||2===o&&u||r.includes(i);return s._open=!!(42===n?c:c&&(o||!d)),s._close=!!(42===n?d:d&&(u||!c)),t(l)}(a)}}};function rQ(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let rK={name:"labelStartLink",resolveAll:rz.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),i};function i(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},rX={42:rb,43:rb,45:rb,48:rb,49:rb,50:rb,51:rb,52:rb,53:rb,54:rb,55:rb,56:rb,57:rb,62:rx},r0={91:{name:"definition",tokenize:function(e,t,n){let r,i=this;return function(t){var r;return e.enter("definition"),r=t,rk.call(i,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(r)};function o(t){return(r=rD(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),a):n(t)}function a(t){return n8(t)?rO(e,l)(t):l(t)}function l(t){return rE(e,s,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function s(t){return e.attempt(rC,u,u)(t)}function u(t){return re(t)?ri(e,c,"whitespace")(t):c(t)}function c(o){return null===o||n7(o)?(e.exit("definition"),i.parser.defined.push(r),t(o)):n(o)}}}},r1={[-2]:rF,[-1]:rF,32:rF},r2={35:{name:"headingAtx",resolve:function(e,t){let n,r,i=e.length-2,o=3;return"whitespace"===e[3][1].type&&(o+=2),i-2>o&&"whitespace"===e[i][1].type&&(i-=2),"atxHeadingSequence"===e[i][1].type&&(o===i-1||i-4>o&&"whitespace"===e[i-2][1].type)&&(i-=o+1===i?2:4),i>o&&(n={type:"atxHeadingText",start:e[o][1].start,end:e[i][1].end},r={type:"chunkText",start:e[o][1].start,end:e[i][1].end,contentType:"text"},nZ(e,o,i-o+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e},tokenize:function(e,t,n){let r=0;return function(i){var o;return e.enter("atxHeading"),o=i,e.enter("atxHeadingSequence"),function i(o){return 35===o&&r++<6?(e.consume(o),i):null===o||n8(o)?(e.exit("atxHeadingSequence"),function n(r){return 35===r?(e.enter("atxHeadingSequence"),function t(r){return 35===r?(e.consume(r),t):(e.exit("atxHeadingSequence"),n(r))}(r)):null===r||n7(r)?(e.exit("atxHeading"),t(r)):re(r)?ri(e,n,"whitespace")(r):(e.enter("atxHeadingText"),function t(r){return null===r||35===r||n8(r)?(e.exit("atxHeadingText"),n(r)):(e.consume(r),t)}(r))}(o)):n(o)}(o)}}},42:rv,45:[rP,rv],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,n){let r,i,o,a,l,s=this;return function(t){var n;return n=t,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(n),u};function u(a){return 33===a?(e.consume(a),c):47===a?(e.consume(a),i=!0,p):63===a?(e.consume(a),r=3,s.interrupt?t:T):n1(a)?(e.consume(a),o=String.fromCharCode(a),m):n(a)}function c(i){return 45===i?(e.consume(i),r=2,d):91===i?(e.consume(i),r=5,a=0,f):n1(i)?(e.consume(i),r=4,s.interrupt?t:T):n(i)}function d(r){return 45===r?(e.consume(r),s.interrupt?t:T):n(r)}function f(r){let i="CDATA[";return r===i.charCodeAt(a++)?(e.consume(r),a===i.length)?s.interrupt?t:k:f:n(r)}function p(t){return n1(t)?(e.consume(t),o=String.fromCharCode(t),m):n(t)}function m(a){if(null===a||47===a||62===a||n8(a)){let l=47===a,u=o.toLowerCase();return!l&&!i&&rV.includes(u)?(r=1,s.interrupt?t(a):k(a)):rT.includes(o.toLowerCase())?(r=6,l)?(e.consume(a),h):s.interrupt?t(a):k(a):(r=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(a):i?function t(n){return re(n)?(e.consume(n),t):x(n)}(a):g(a))}return 45===a||n2(a)?(e.consume(a),o+=String.fromCharCode(a),m):n(a)}function h(r){return 62===r?(e.consume(r),s.interrupt?t:k):n(r)}function g(t){return 47===t?(e.consume(t),x):58===t||95===t||n1(t)?(e.consume(t),y):re(t)?(e.consume(t),g):x(t)}function y(t){return 45===t||46===t||58===t||95===t||n2(t)?(e.consume(t),y):v(t)}function v(t){return 61===t?(e.consume(t),b):re(t)?(e.consume(t),v):g(t)}function b(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,_):re(t)?(e.consume(t),b):function t(n){return null===n||34===n||39===n||47===n||60===n||61===n||62===n||96===n||n8(n)?v(n):(e.consume(n),t)}(t)}function _(t){return t===l?(e.consume(t),l=null,w):null===t||n7(t)?n(t):(e.consume(t),_)}function w(e){return 47===e||62===e||re(e)?g(e):n(e)}function x(t){return 62===t?(e.consume(t),E):n(t)}function E(t){return null===t||n7(t)?k(t):re(t)?(e.consume(t),E):n(t)}function k(t){return 45===t&&2===r?(e.consume(t),C):60===t&&1===r?(e.consume(t),F):62===t&&4===r?(e.consume(t),V):63===t&&3===r?(e.consume(t),T):93===t&&5===r?(e.consume(t),P):n7(t)&&(6===r||7===r)?(e.exit("htmlFlowData"),e.check(rM,M,S)(t)):null===t||n7(t)?(e.exit("htmlFlowData"),S(t)):(e.consume(t),k)}function S(t){return e.check(rj,O,M)(t)}function O(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),D}function D(t){return null===t||n7(t)?S(t):(e.enter("htmlFlowData"),k(t))}function C(t){return 45===t?(e.consume(t),T):k(t)}function F(t){return 47===t?(e.consume(t),o="",A):k(t)}function A(t){if(62===t){let n=o.toLowerCase();return rV.includes(n)?(e.consume(t),V):k(t)}return n1(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),A):k(t)}function P(t){return 93===t?(e.consume(t),T):k(t)}function T(t){return 62===t?(e.consume(t),V):45===t&&2===r?(e.consume(t),T):k(t)}function V(t){return null===t||n7(t)?(e.exit("htmlFlowData"),M(t)):(e.consume(t),V)}function M(n){return e.exit("htmlFlow"),t(n)}}},61:rP,95:rv,96:rN,126:rN},r4={38:rR,92:r$},r3={[-5]:rB,[-4]:rB,[-3]:rB,33:rJ,38:rR,42:rG,60:[{name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i};function i(t){return n1(t)?(e.consume(t),o):64===t?n(t):l(t)}function o(t){return 43===t||45===t||46===t||n2(t)?(r=1,function t(n){return 58===n?(e.consume(n),r=0,a):(43===n||45===n||46===n||n2(n))&&r++<32?(e.consume(n),t):(r=0,l(n))}(t)):l(t)}function a(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||n3(r)?n(r):(e.consume(r),a)}function l(t){return 64===t?(e.consume(t),s):n4(t)?(e.consume(t),l):n(t)}function s(i){return n2(i)?function i(o){return 46===o?(e.consume(o),r=0,s):62===o?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(o),e.exit("autolinkMarker"),e.exit("autolink"),t):function t(o){if((45===o||n2(o))&&r++<63){let n=45===o?t:i;return e.consume(o),n}return n(o)}(o)}(i):n(i)}}},{name:"htmlText",tokenize:function(e,t,n){let r,i,o,a=this;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),l};function l(t){return 33===t?(e.consume(t),s):47===t?(e.consume(t),_):63===t?(e.consume(t),v):n1(t)?(e.consume(t),x):n(t)}function s(t){return 45===t?(e.consume(t),u):91===t?(e.consume(t),i=0,p):n1(t)?(e.consume(t),y):n(t)}function u(t){return 45===t?(e.consume(t),f):n(t)}function c(t){return null===t?n(t):45===t?(e.consume(t),d):n7(t)?(o=c,A(t)):(e.consume(t),c)}function d(t){return 45===t?(e.consume(t),f):c(t)}function f(e){return 62===e?F(e):45===e?d(e):c(e)}function p(t){let r="CDATA[";return t===r.charCodeAt(i++)?(e.consume(t),i===r.length?m:p):n(t)}function m(t){return null===t?n(t):93===t?(e.consume(t),h):n7(t)?(o=m,A(t)):(e.consume(t),m)}function h(t){return 93===t?(e.consume(t),g):m(t)}function g(t){return 62===t?F(t):93===t?(e.consume(t),g):m(t)}function y(t){return null===t||62===t?F(t):n7(t)?(o=y,A(t)):(e.consume(t),y)}function v(t){return null===t?n(t):63===t?(e.consume(t),b):n7(t)?(o=v,A(t)):(e.consume(t),v)}function b(e){return 62===e?F(e):v(e)}function _(t){return n1(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||n2(t)?(e.consume(t),w):function t(n){return n7(n)?(o=t,A(n)):re(n)?(e.consume(n),t):F(n)}(t)}function x(t){return 45===t||n2(t)?(e.consume(t),x):47===t||62===t||n8(t)?E(t):n(t)}function E(t){return 47===t?(e.consume(t),F):58===t||95===t||n1(t)?(e.consume(t),k):n7(t)?(o=E,A(t)):re(t)?(e.consume(t),E):F(t)}function k(t){return 45===t||46===t||58===t||95===t||n2(t)?(e.consume(t),k):function t(n){return 61===n?(e.consume(n),S):n7(n)?(o=t,A(n)):re(n)?(e.consume(n),t):E(n)}(t)}function S(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,O):n7(t)?(o=S,A(t)):re(t)?(e.consume(t),S):(e.consume(t),D)}function O(t){return t===r?(e.consume(t),r=void 0,C):null===t?n(t):n7(t)?(o=O,A(t)):(e.consume(t),O)}function D(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||n8(t)?E(t):(e.consume(t),D)}function C(e){return 47===e||62===e||n8(e)?E(e):n(e)}function F(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function A(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),P}function P(t){return re(t)?ri(e,T,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):T(t)}function T(t){return e.enter("htmlTextData"),o(t)}}}],91:rK,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return n7(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},r$],93:rz,95:rG,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,i=3;if(("lineEnding"===e[3][1].type||"space"===e[i][1].type)&&("lineEnding"===e[r][1].type||"space"===e[r][1].type)){for(t=i;++t<r;)if("codeTextData"===e[t][1].type){e[i][1].type="codeTextPadding",e[r][1].type="codeTextPadding",i+=2,r-=2;break}}for(t=i-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):(t===r||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,i,o=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),function t(n){return 96===n?(e.consume(n),o++,t):(e.exit("codeTextSequence"),a(n))}(t)};function a(s){return null===s?n(s):32===s?(e.enter("space"),e.consume(s),e.exit("space"),a):96===s?(i=e.enter("codeTextSequence"),r=0,function n(a){return 96===a?(e.consume(a),r++,n):r===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(a)):(i.type="codeTextData",l(a))}(s)):n7(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),a):(e.enter("codeTextData"),l(s))}function l(t){return null===t||32===t||96===t||n7(t)?(e.exit("codeTextData"),a(t)):(e.consume(t),l)}}}},r5={null:[rG,rf]},r6={null:[42,95]},r9={null:[]},r7=/[\0\t\n\r]/g;function r8(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let ie=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function it(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return r8(n.slice(t?2:1),t?16:10)}return rq(n)||e}let ir={}.hasOwnProperty;function ii(e){return{line:e.line,column:e.column,offset:e.offset}}function io(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+nk({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+nk({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+nk({start:t.start,end:t.end})+") is still open")}function ia(e){let t=this;t.parser=function(n){var r,i;let a,l,s,u;return"string"!=typeof(r={...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})&&(i=r,r=void 0),(function(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(y),autolinkProtocol:u,autolinkEmail:u,atxHeading:r(m),blockQuote:r(function(){return{type:"blockquote",children:[]}}),characterEscape:u,characterReference:u,codeFenced:r(p),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:r(p,i),codeText:r(function(){return{type:"inlineCode",value:""}},i),codeTextData:u,data:u,codeFlowValue:u,definition:r(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:r(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:r(h),hardBreakTrailing:r(h),htmlFlow:r(g,i),htmlFlowData:u,htmlText:r(g,i),htmlTextData:u,image:r(function(){return{type:"image",title:null,url:"",alt:null}}),label:i,link:r(y),listItem:r(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:r(v,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:r(v),paragraph:r(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:r(m),strong:r(function(){return{type:"strong",children:[]}}),thematicBreak:r(function(){return{type:"thematicBreak"}})},exit:{atxHeading:a(),atxHeadingSequence:function(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)},autolink:a(),autolinkEmail:function(e){c.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){c.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:a(),characterEscapeValue:c,characterReferenceMarkerHexadecimal:f,characterReferenceMarkerNumeric:f,characterReferenceValue:function(e){let t,n=this.sliceSerialize(e),r=this.data.characterReferenceType;r?(t=r8(n,"characterReferenceMarkerNumeric"===r?10:16),this.data.characterReferenceType=void 0):t=rq(n);let i=this.stack[this.stack.length-1];i.value+=t},characterReference:function(e){this.stack.pop().position.end=ii(e.end)},codeFenced:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:c,codeIndented:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:c,data:c,definition:a(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=rD(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:a(),hardBreakEscape:a(d),hardBreakTrailing:a(d),htmlFlow:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:c,htmlText:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:c,image:a(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=t},labelText:function(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=t.replace(ie,it),n.identifier=rD(t).toLowerCase()},lineEnding:function(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=ii(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(u.call(this,e),c.call(this,e))},link:a(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=rD(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:a(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:a(),thematicBreak:a()}};!function e(t,n){let r=-1;for(;++r<n.length;){let i=n[r];Array.isArray(i)?e(t,i):function(e,t){let n;for(n in t)if(ir.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r)}}}(t,i)}}(t,(e||{}).mdastExtensions||[]);let n={};return function(e){let r={type:"root",children:[]},a={stack:[r],tokenStack:[],config:t,enter:o,exit:l,buffer:i,resume:s,data:n},u=[],c=-1;for(;++c<e.length;)("listOrdered"===e[c][1].type||"listUnordered"===e[c][1].type)&&("enter"===e[c][0]?u.push(c):c=function(e,t,n){let r,i,o,a,l=t-1,s=-1,u=!1;for(;++l<=n;){let t=e[l];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?s++:s--,a=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||a||s||o||(o=l),a=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:a=void 0}if(!s&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===s&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let a=l;for(i=void 0;a--;){let t=e[a];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;i&&(e[i][1].type="lineEndingBlank",u=!0),t[1].type="lineEnding",i=a}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}o&&(!i||o<i)&&(r._spread=!0),r.end=Object.assign({},i?e[i][1].start:t[1].end),e.splice(i||l,0,["exit",r,t[2]]),l++,n++}if("listItemPrefix"===t[1].type){let i={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=i,e.splice(l,0,["enter",i,t[2]]),l++,n++,o=void 0,a=!0}}}return e[t][1]._spread=u,n}(e,u.pop(),c));for(c=-1;++c<e.length;){let n=t[e[c][0]];ir.call(n,e[c][1].type)&&n[e[c][1].type].call(Object.assign({sliceSerialize:e[c][2].sliceSerialize},a),e[c][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||io).call(a,void 0,e[0])}for(r.position={start:ii(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:ii(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},c=-1;++c<t.transforms.length;)r=t.transforms[c](r)||r;return r};function r(e,t){return function(n){o.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function o(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:ii(t.start),end:void 0}}function a(e){return function(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||io).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+nk({start:e.start,end:e.end})+"): it’s not open");n.position.end=ii(e.end)}function s(){var e;return e=this.stack.pop(),nY(e,"boolean"!=typeof nW.includeImageAlt||nW.includeImageAlt,"boolean"!=typeof nW.includeHtml||nW.includeHtml)}function u(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&"text"===n.type||((n={type:"text",value:""}).position={start:ii(e.start),end:void 0},t.push(n)),this.stack.push(n)}function c(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=ii(e.end)}function d(){this.data.atHardBreak=!0}function f(e){this.data.characterReferenceType=e.type}function p(){return{type:"code",lang:null,meta:null,value:""}}function m(){return{type:"heading",depth:0,children:[]}}function h(){return{type:"break"}}function g(){return{type:"html",value:""}}function y(){return{type:"link",title:null,url:"",children:[]}}function v(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(i)(function(e){for(;!nX(e););return e}((function(e){let t={constructs:function(e){let t={},n=-1;for(;++n<e.length;)!function(e,t){let n;for(n in t){let r,i=(n0.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];if(o)for(r in o){n0.call(i,r)||(i[r]=[]);let e=o[r];!function(e,t){let n=-1,r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);nZ(e,0,0,r)}(i[r],Array.isArray(e)?e:e?[e]:[])}}}(t,e[n]);return t}([o,...(e||{}).extensions||[]]),content:n(ro),defined:[],document:n(ra),flow:n(rd),lazy:{},string:n(rp),text:n(rm)};return t;function n(e){return function(n){return function(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},o=[],a=[],l=[],s={attempt:m(function(e,t){h(e,t.from)}),check:m(p),consume:function(e){n7(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,g()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=e},enter:function(e,t){let n=t||{};return n.type=e,n.start=f(),u.events.push(["enter",n,u]),l.push(n),n},exit:function(e){let t=l.pop();return t.end=f(),u.events.push(["exit",t,u]),t},interrupt:m(p,{interrupt:!0})},u={code:null,containerState:{},defineSkip:function(e){i[e.line]=e.column,g()},events:[],now:f,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n,r=-1,i=[];for(;++r<e.length;){let o,a=e[r];if("string"==typeof a)o=a;else switch(a){case -5:o="\r";break;case -4:o="\n";break;case -3:o="\r\n";break;case -2:o=t?" ":" ";break;case -1:if(!t&&n)continue;o=" ";break;default:o=String.fromCharCode(a)}n=-2===a,i.push(o)}return i.join("")}(d(e),t)},sliceStream:d,write:function(e){return(a=nG(a,e),function(){let e;for(;r._index<a.length;){let n=a[r._index];if("string"==typeof n)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<n.length;){var t;t=n.charCodeAt(r._bufferIndex),c=c(t)}else c=c(n)}}(),null!==a[a.length-1])?[]:(h(t,0),u.events=rH(o,u.events,u),u.events)}},c=t.tokenize.call(u,s);return t.resolveAll&&o.push(t),u;function d(e){return function(e,t){let n,r=t.start._index,i=t.start._bufferIndex,o=t.end._index,a=t.end._bufferIndex;if(r===o)n=[e[r].slice(i,a)];else{if(n=e.slice(r,o),i>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(i):n.shift()}a>0&&n.push(e[o].slice(0,a))}return n}(a,e)}function f(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:o}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:o}}function p(e,t){t.restore()}function m(e,t){return function(n,i,o){var a;let c,d,p,m;return Array.isArray(n)?h(n):"tokenize"in n?h([n]):(a=n,function(e){let t=null!==e&&a[e],n=null!==e&&a.null;return h([...Array.isArray(t)?t:t?[t]:[],...Array.isArray(n)?n:n?[n]:[]])(e)});function h(e){return(c=e,d=0,0===e.length)?o:y(e[d])}function y(e){return function(n){let i,o,a,c,d;return(i=f(),o=u.previous,a=u.currentConstruct,c=u.events.length,d=Array.from(l),m={from:c,restore:function(){r=i,u.previous=o,u.currentConstruct=a,u.events.length=c,l=d,g()}},p=e,e.partial||(u.currentConstruct=e),e.name&&u.parser.constructs.disable.null.includes(e.name))?b(n):e.tokenize.call(t?Object.assign(Object.create(u),t):u,s,v,b)(n)}}function v(t){return e(p,m),i}function b(e){return(m.restore(),++d<c.length)?y(c[d]):o}}}function h(e,t){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&nZ(u.events,t,u.events.length-t,e.resolve(u.events.slice(t),u)),e.resolveTo&&(u.events=e.resolveTo(u.events,u))}function g(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}(t,e,n)}}})(i).document().write((l=1,s="",u=!0,function(e,t,n){let r,i,o,c,d,f=[];for(e=s+("string"==typeof e?e.toString():new TextDecoder(t||void 0).decode(e)),o=0,s="",u&&(65279===e.charCodeAt(0)&&o++,u=void 0);o<e.length;){if(r7.lastIndex=o,c=(r=r7.exec(e))&&void 0!==r.index?r.index:e.length,d=e.charCodeAt(c),!r){s=e.slice(o);break}if(10===d&&o===c&&a)f.push(-3),a=void 0;else switch(a&&(f.push(-5),a=void 0),o<c&&(f.push(e.slice(o,c)),l+=c-o),d){case 0:f.push(65533),l++;break;case 9:for(i=4*Math.ceil(l/4),f.push(-2);l++<i;)f.push(-1);break;case 10:f.push(-4),l=1;break;default:a=!0,l=1}o=c+1}return n&&(a&&f.push(-5),s&&f.push(s),f.push(null)),f})(n,r,!0))))}}let il="object"==typeof self?self:globalThis,is=e=>{var t;let n,r;return(t=new Map,n=(e,n)=>(t.set(n,e),e),r=i=>{if(t.has(i))return t.get(i);let[o,a]=e[i];switch(o){case 0:case -1:return n(a,i);case 1:{let e=n([],i);for(let t of a)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of a)e[r(t)]=r(n);return e}case 3:return n(new Date(a),i);case 4:{let{source:e,flags:t}=a;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of a)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of a)e.add(r(t));return e}case 7:{let{name:e,message:t}=a;return n(new il[e](t),i)}case 8:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i)}return n(new il[o](a),i)})(0)},{toString:iu}={},{keys:ic}=Object,id=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let n=iu.call(e).slice(8,-1);switch(n){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},ip=([e,t])=>0===e&&("function"===t||"symbol"===t),im=(e,{json:t,lossy:n}={})=>{var r,i,o;let a,l,s=[];return(r=!(t||n),i=!!t,o=new Map,a=(e,t)=>{let n=s.push(e)-1;return o.set(t,n),n},l=e=>{if(o.has(e))return o.get(e);let[t,n]=id(e);switch(t){case 0:{let i=e;switch(n){case"bigint":t=8,i=e.toString();break;case"function":case"symbol":if(r)throw TypeError("unable to serialize "+n);i=null;break;case"undefined":return a([-1],e)}return a([t,i],e)}case 1:{if(n)return a([n,[...e]],e);let r=[],i=a([t,r],e);for(let t of e)r.push(l(t));return i}case 2:{if(n)switch(n){case"BigInt":return a([n,e.toString()],e);case"Boolean":case"Number":case"String":return a([n,e.valueOf()],e)}if(i&&"toJSON"in e)return l(e.toJSON());let o=[],s=a([t,o],e);for(let t of ic(e))(r||!ip(id(e[t])))&&o.push([l(t),l(e[t])]);return s}case 3:return a([t,e.toISOString()],e);case 4:{let{source:n,flags:r}=e;return a([t,{source:n,flags:r}],e)}case 5:{let n=[],i=a([t,n],e);for(let[t,i]of e)(r||!(ip(id(t))||ip(id(i))))&&n.push([l(t),l(i)]);return i}case 6:{let n=[],i=a([t,n],e);for(let t of e)(r||!ip(id(t)))&&n.push(l(t));return i}}let{message:s}=e;return a([t,{name:n,message:s}],e)})(e),s},ih="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?is(im(e,t)):structuredClone(e):(e,t)=>is(im(e,t));function ig(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let o=e.charCodeAt(n),a="";if(37===o&&n2(e.charCodeAt(n+1))&&n2(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){let t=e.charCodeAt(n+1);o<56320&&t>56319&&t<57344?(a=String.fromCharCode(o,t),i=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function iy(e,t){let n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function iv(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}let ib=function(e){var t,n;if(null==e)return iw;if("function"==typeof e)return i_(e);if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],n=-1;for(;++n<e.length;)t[n]=ib(e[n]);return i_(function(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1})}(e):(t=e,i_(function(e){let n;for(n in t)if(e[n]!==t[n])return!1;return!0}))}if("string"==typeof e){return n=e,i_(function(e){return e&&e.type===n})}throw Error("Expected function, string, or object as test")};function i_(e){return function(t,n,r){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function iw(){return!0}let ix=[];function iE(e,t,n,r){var i,o,a;let l,s,u,c,d,f;"function"==typeof t&&"function"!=typeof n?(s=void 0,u=t,l=n):(s=t,u=n,l=r),i=s,o=function(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return u(e,r,n)},a=l,"function"==typeof i&&"function"!=typeof o?(a=o,o=i):c=i,d=ib(c),f=a?-1:1,(function e(t,n,r){let l=t&&"object"==typeof t?t:{};if("string"==typeof l.type){let e="string"==typeof l.tagName?l.tagName:"string"==typeof l.name?l.name:void 0;Object.defineProperty(s,"name",{value:"node ("+t.type+(e?"<"+e+">":"")+")"})}return s;function s(){var l;let s,u,c,p=ix;if((!i||d(t,n,r[r.length-1]||void 0))&&!1===(p=Array.isArray(l=o(t,r))?l:"number"==typeof l?[!0,l]:null==l?ix:[l])[0])return p;if("children"in t&&t.children&&t.children&&"skip"!==p[0])for(u=(a?t.children.length:-1)+f,c=r.concat(t);u>-1&&u<t.children.length;){if(!1===(s=e(t.children[u],u,c)())[0])return s;u="number"==typeof s[1]?s[1]:u+f}return p}})(e,void 0,[])()}function ik(e,t){let n=t.referenceType,r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];let i=e.all(t),o=i[0];o&&"text"===o.type?o.value="["+o.value:i.unshift({type:"text",value:"["});let a=i[i.length-1];return a&&"text"===a.type?a.value+=r:i.push({type:"text",value:r}),i}function iS(e){let t=e.spread;return null==t?e.children.length>1:t}function iO(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;9===t||32===t;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}let iD={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o={type:"element",tagName:"pre",properties:{},children:[o=e.applyData(t,o)]},e.patch(t,o),o},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){let n,r="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),o=ig(i.toLowerCase()),a=e.footnoteOrder.indexOf(i),l=e.footnoteCounts.get(i);void 0===l?(l=0,e.footnoteOrder.push(i),n=e.footnoteOrder.length):n=a+1,l+=1,e.footnoteCounts.set(i,l);let s={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+o,id:r+"fnref-"+o+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,s);let u={type:"element",tagName:"sup",properties:{},children:[s]};return e.patch(t,u),e.applyData(t,u)},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ik(e,t);let i={src:ig(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(i.title=r.title);let o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)},image:function(e,t){let n={src:ig(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return ik(e,t);let i={href:ig(r.url||"")};null!==r.title&&void 0!==r.title&&(i.title=r.title);let o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)},link:function(e,t){let n={href:ig(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){let r=e.all(t),i=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=iS(n[r])}return t}(n):iS(t),o={},a=[];if("boolean"==typeof t.checked){let e,n=r[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},r.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<r.length;){let e=r[l];(i||0!==l||"element"!==e.type||"p"!==e.tagName)&&a.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||i?a.push(e):a.push(...e.children)}let s=r[r.length-1];s&&(i||"element"!==s.type||"p"!==s.tagName)&&a.push({type:"text",value:"\n"});let u={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,u),e.applyData(t,u)},list:function(e,t){let n={},r=e.all(t),i=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++i<r.length;){let e=r[i];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=nx(t.children[1]),a=nw(t.children[t.children.length-1]);o&&a&&(r.position={start:o,end:a}),i.push(r)}let o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let r=n?n.children:void 0,i=0===(r?r.indexOf(t):1)?"th":"td",o=n&&"table"===n.type?n.align:void 0,a=o?o.length:t.children.length,l=-1,s=[];for(;++l<a;){let n=t.children[l],r={},a=o?o[l]:void 0;a&&(r.align=a);let u={type:"element",tagName:i,properties:r,children:[]};n&&(u.children=e.all(n),e.patch(n,u),u=e.applyData(n,u)),s.push(u)}let u={type:"element",tagName:"tr",properties:{},children:e.wrap(s,!0)};return e.patch(t,u),e.applyData(t,u)},text:function(e,t){let n={type:"text",value:function(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,o=[];for(;r;)o.push(iO(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(iO(t.slice(i),i>0,!1)),o.join("")}(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:iC,yaml:iC,definition:iC,footnoteDefinition:iC};function iC(){}let iF={}.hasOwnProperty,iA={};function iP(e,t){e.position&&(t.position=function(e){let t=nx(e),n=nw(e);if(t&&n)return{start:t,end:n}}(e))}function iT(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&i&&Object.assign(n.properties,ih(i)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function iV(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function iM(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function ij(e,t){let n,r,i,o,a=(n=t||iA,r=new Map,i=new Map,o={all:function(e){let t=[];if("children"in e){let n=e.children,r=-1;for(;++r<n.length;){let i=o.one(n[r],e);if(i){if(r&&"break"===n[r-1].type&&(Array.isArray(i)||"text"!==i.type||(i.value=iM(i.value)),!Array.isArray(i)&&"element"===i.type)){let e=i.children[0];e&&"text"===e.type&&(e.value=iM(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t},applyData:iT,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...iD,...n.handlers},one:function(e,t){let n=e.type,r=o.handlers[n];if(iF.call(o.handlers,n)&&r)return r(o,e,t);if(o.options.passThrough&&o.options.passThrough.includes(n)){if("children"in e){let{children:t,...n}=e,r=ih(n);return r.children=o.all(e),r}return ih(e)}return(o.options.unknownHandler||function(e,t){let n=t.data||{},r="value"in t&&!(iF.call(n,"hProperties")||iF.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)})(o,e,t)},options:n,patch:iP,wrap:iV},iE(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),o),l=a.one(e,void 0),s=function(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||iy,r=e.options.footnoteBackLabel||iv,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[],s=-1;for(;++s<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[s]);if(!i)continue;let o=e.all(i),a=String(i.identifier).toUpperCase(),u=ig(a.toLowerCase()),c=0,d=[],f=e.footnoteCounts.get(a);for(;void 0!==f&&++c<=f;){d.length>0&&d.push({type:"text",value:" "});let e="string"==typeof n?n:n(s,c);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+u+(c>1?"-"+c:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(s,c),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let p=o[o.length-1];if(p&&"element"===p.type&&"p"===p.tagName){let e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...d)}else o.push(...d);let m={type:"element",tagName:"li",properties:{id:t+"fn-"+u},children:e.wrap(o,!0)};e.patch(i,m),l.push(m)}if(0!==l.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...ih(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:"\n"}]}}(a),u=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return s&&u.children.push({type:"text",value:"\n"},s),u}function iI(e,t){return e&&"run"in e?async function(n,r){let i=ij(n,{file:r,...t});await e.run(i,r)}:function(n,r){return ij(n,{file:r,...e||t})}}function iN(e){if(e)throw e}var iL=n(9710);function iq(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let iR=function(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');iz(e);let r=0,i=-1,o=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else i<0&&(n=!0,i=o+1);return i<0?"":e.slice(r,i)}if(t===e)return"";let a=-1,l=t.length-1;for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else a<0&&(n=!0,a=o+1),l>-1&&(e.codePointAt(o)===t.codePointAt(l--)?l<0&&(i=o):(l=-1,i=a));return r===i?i=a:i<0&&(i=e.length),e.slice(r,i)},i$=function(e){let t;if(iz(e),0===e.length)return".";let n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},iB=function(e){let t;iz(e);let n=e.length,r=-1,i=0,o=-1,a=0;for(;n--;){let l=e.codePointAt(n);if(47===l){if(t){i=n+1;break}continue}r<0&&(t=!0,r=n+1),46===l?o<0?o=n:1!==a&&(a=1):o>-1&&(a=-1)}return o<0||r<0||0===a||1===a&&o===r-1&&o===i+1?"":e.slice(o,r)},iH=function(...e){var t;let n,r,i,o=-1;for(;++o<e.length;)iz(e[o]),e[o]&&(i=void 0===i?e[o]:i+"/"+e[o]);return void 0===i?".":(iz(t=i),n=47===t.codePointAt(0),0!==(r=function(e,t){let n,r,i="",o=0,a=-1,l=0,s=-1;for(;++s<=e.length;){if(s<e.length)n=e.codePointAt(s);else if(47===n)break;else n=47;if(47===n){if(a===s-1||1===l);else if(a!==s-1&&2===l){if(i.length<2||2!==o||46!==i.codePointAt(i.length-1)||46!==i.codePointAt(i.length-2)){if(i.length>2){if((r=i.lastIndexOf("/"))!==i.length-1){r<0?(i="",o=0):o=(i=i.slice(0,r)).length-1-i.lastIndexOf("/"),a=s,l=0;continue}}else if(i.length>0){i="",o=0,a=s,l=0;continue}}t&&(i=i.length>0?i+"/..":"..",o=2)}else i.length>0?i+="/"+e.slice(a+1,s):i=e.slice(a+1,s),o=s-a-1;a=s,l=0}else 46===n&&l>-1?l++:l=-1}return i}(t,!n)).length||n||(r="."),r.length>0&&47===t.codePointAt(t.length-1)&&(r+="/"),n?"/"+r:r)};function iz(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function iU(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let iW=["history","path","basename","stem","extname","dirname"];class iY{constructor(e){let t,n;t=e?iU(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<iW.length;){const e=iW[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)iW.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?iR(this.path):void 0}set basename(e){iZ(e,"basename"),iJ(e,"basename"),this.path=iH(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?i$(this.path):void 0}set dirname(e){iG(this.basename,"dirname"),this.path=iH(e||"",this.basename)}get extname(){return"string"==typeof this.path?iB(this.path):void 0}set extname(e){if(iJ(e,"extname"),iG(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=iH(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){iU(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!iU(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){let e=t.codePointAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),iZ(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?iR(this.path,this.extname):void 0}set stem(e){iZ(e,"stem"),iJ(e,"stem"),this.path=iH(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new nC(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function iJ(e,t){if(e&&e.includes("/"))throw Error("`"+t+"` cannot be a path: did not expect `/`")}function iZ(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function iG(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}let iQ=function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},iK={}.hasOwnProperty;class iX extends iQ{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let e=[],t={run:function(...t){let n=-1,r=t.pop();if("function"!=typeof r)throw TypeError("Expected function as last argument, not "+r);!function i(o,...a){let l=e[++n],s=-1;if(o)return void r(o);for(;++s<t.length;)(null===a[s]||void 0===a[s])&&(a[s]=t[s]);t=a,l?(function(e,t){let n;return function(...t){let o,a=e.length>t.length;a&&t.push(r);try{o=e.apply(this,t)}catch(e){if(a&&n)throw e;return r(e)}a||(o instanceof Promise?o.then(i,r):o instanceof Error?r(o):i(o))};function r(e,...i){n||(n=!0,t(e,...i))}function i(e){r(null,e)}})(l,i)(...a):r(null,...a)}(null,...t)},use:function(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}()}copy(){let e=new iX,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data(iL(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(i4("data",this.frozen),this.namespace[e]=t,this):iK.call(this.namespace,e)&&this.namespace[e]||void 0:e?(i4("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...t]=this.attachers[this.freezeIndex];if(!1===t[0])continue;!0===t[0]&&(t[0]=void 0);let n=e.call(this,...t);"function"==typeof n&&this.transformers.use(n)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=i6(e),n=this.parser||this.Parser;return i1("parse",n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),i1("process",this.parser||this.Parser),i2("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let o=i6(e),a=n.parse(o);function l(e,n){e||!n?i(e):r?r(n):t(void 0,n)}n.run(a,o,function(e,t,r){var i,o;if(e||!t||!r)return l(e);let a=n.stringify(t,r);"string"==typeof(i=a)||(o=i)&&"object"==typeof o&&"byteLength"in o&&"byteOffset"in o?r.value=a:r.result=a,l(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),i1("processSync",this.parser||this.Parser),i2("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,iN(e),t=r}),i5("processSync","process",n),t}run(e,t,n){i3(e),this.freeze();let r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,o){let a=i6(t);r.run(e,a,function(t,r,a){let l=r||e;t?o(t):i?i(l):n(void 0,l,a)})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){iN(e),n=t,r=!0}),i5("runSync","run",r),n}stringify(e,t){this.freeze();let n=i6(t),r=this.compiler||this.Compiler;return i2("stringify",r),i3(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(i4("use",this.frozen),null==e);else if("function"==typeof e)a(e,t);else if("object"==typeof e)Array.isArray(e)?o(e):i(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=iL(!0,r.settings,e.settings))}function o(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)!function(e){if("function"==typeof e)a(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;a(t,n)}else i(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function a(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(-1===i)n.push([e,...t]);else if(t.length>0){let[r,...o]=t,a=n[i][1];iq(a)&&iq(r)&&(r=iL(!0,a,r)),n[i]=[e,r,...o]}}}}let i0=new iX().freeze();function i1(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function i2(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function i4(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function i3(e){if(!iq(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function i5(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function i6(e){var t;return(t=e)&&"object"==typeof t&&"message"in t&&"messages"in t?e:new iY(e)}let i9=[],i7={allowDangerousHtml:!0},i8=/^(https?|ircs?|mailto|xmpp)$/i,oe=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function ot(e){let t=e.allowedElements,n=e.allowElement,r=e.children||"",i=e.className,o=e.components,a=e.disallowedElements,l=e.rehypePlugins||i9,s=e.remarkPlugins||i9,u=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...i7}:i7,c=e.skipHtml,d=e.unwrapDisallowed,f=e.urlTransform||on,p=i0().use(ia).use(s).use(iI,u).use(l),m=new iY;for(let t of("string"==typeof r&&(m.value=r),oe))Object.hasOwn(e,t.from)&&(t.from,t.to&&t.to,t.id);let h=p.parse(m),g=p.runSync(h,m);return i&&(g={type:"element",tagName:"div",properties:{className:i},children:"root"===g.type?g.children:[g]}),iE(g,function(e,r,i){if("raw"===e.type&&i&&"number"==typeof r)return c?i.children.splice(r,1):i.children[r]={type:"text",value:e.value},r;if("element"===e.type){let t;for(t in nz)if(Object.hasOwn(nz,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=nz[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=f(String(n||""),t,e))}}if("element"===e.type){let o=t?!t.includes(e.tagName):!!a&&a.includes(e.tagName);if(!o&&n&&"number"==typeof r&&(o=!n(e,r,i)),o&&i&&"number"==typeof r)return d&&e.children?i.children.splice(r,1,...e.children):i.children.splice(r,1),r}}),function(e,t){var n,r,i,o;let a;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let l=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=l,r=t.jsxDEV,a=function(e,t,i,o){let a=Array.isArray(i.children),l=nx(e);return r(t,i,o,a,{columnNumber:l?l.column-1:void 0,fileName:n,lineNumber:l?l.line:void 0},void 0)}}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");i=t.jsx,o=t.jsxs,a=function(e,t,n,r){let a=Array.isArray(n.children)?o:i;return r?a(t,n,r):a(t,n)}}let s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:a,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:l,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?nf:nd,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},u=nI(s,e,void 0);return u&&"string"!=typeof u?u:s.create(e,s.Fragment,{children:u||void 0},void 0)}(g,{Fragment:nU.Fragment,components:o,ignoreInvalidStyle:!0,jsx:nU.jsx,jsxs:nU.jsxs,passKeys:!0,passNode:!0})}function on(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t<0||i>-1&&t>i||n>-1&&t>n||r>-1&&t>r||i8.test(e.slice(0,t))?e:""}let or={a:({node:e,...t})=>d().createElement("a",{...t,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer"})},oi=({markdown:e})=>d().createElement("div",{className:"-esm-form-engine__markdown-wrapper__markdownWrapper___N6Orn"},d().createElement(ot,{children:e,unwrapDisallowed:!0,allowedElements:["h1","h2","h3","h4","h5","h6","p","strong","em","code","pre","ul","ol","li","a","blockquote","hr","br"],components:or})),oo={boldedLabel:"-esm-form-engine__multi-select__boldedLabel___-TJAY",errorLabel:"-esm-form-engine__multi-select__errorLabel___Cx0K1",selectionDisplay:"-esm-form-engine__multi-select__selectionDisplay___KJIF4",tagContainer:"-esm-form-engine__multi-select__tagContainer___jtOs2",checkbox:"-esm-form-engine__multi-select__checkbox___m66zk"},oa={boldedLabel:"-esm-form-engine__number__boldedLabel___baNvc",errorLabel:"-esm-form-engine__number__errorLabel___vJnNs",controlWidthConstrained:"-esm-form-engine__number__controlWidthConstrained___wjS56"},ol="-esm-form-engine__toggle__boldedLabel___IF1zX";var os=n(7942),ou=n(9600);let oc=function(){return ou.A.Date.now()};var od=/\s/;let of=function(e){for(var t=e.length;t--&&od.test(e.charAt(t)););return t};var op=/^\s+/,om=n(4089),oh=0/0,og=/^[-+]0x[0-9a-f]+$/i,oy=/^0b[01]+$/i,ov=/^0o[0-7]+$/i,ob=parseInt;let o_=function(e){if("number"==typeof e)return e;if((0,om.A)(e))return oh;if((0,os.A)(e)){var t,n="function"==typeof e.valueOf?e.valueOf():e;e=(0,os.A)(n)?n+"":n}if("string"!=typeof e)return 0===e?e:+e;e=(t=e)?t.slice(0,of(t)+1).replace(op,""):t;var r=oy.test(e);return r||ov.test(e)?ob(e.slice(2),r?2:8):og.test(e)?oh:+e};var ow=Math.max,ox=Math.min;let oE=function(e,t,n){var r,i,o,a,l,s,u=0,c=!1,d=!1,f=!0;if("function"!=typeof e)throw TypeError("Expected a function");function p(t){var n=r,o=i;return r=i=void 0,u=t,a=e.apply(o,n)}function m(e){var n=e-s,r=e-u;return void 0===s||n>=t||n<0||d&&r>=o}function h(){var e,n,r,i=oc();if(m(i))return g(i);l=setTimeout(h,(e=i-s,n=i-u,r=t-e,d?ox(r,o-n):r))}function g(e){return(l=void 0,f&&r)?p(e):(r=i=void 0,a)}function y(){var e,n=oc(),o=m(n);if(r=arguments,i=this,s=n,o){if(void 0===l)return u=e=s,l=setTimeout(h,t),c?p(e):a;if(d)return clearTimeout(l),l=setTimeout(h,t),p(s)}return void 0===l&&(l=setTimeout(h,t)),a}return t=o_(t)||0,(0,os.A)(n)&&(c=!!n.leading,o=(d="maxWait"in n)?ow(o_(n.maxWait)||0,t):o,f="trailing"in n?!!n.trailing:f),y.cancel=function(){void 0!==l&&clearTimeout(l),u=0,r=s=i=l=void 0},y.flush=function(){return void 0===l?a:g(oc())},y},ok=[{name:"drug",datasource:{name:"drug_datasource",config:{class:"8d490dfc-c2cc-11de-8d13-0010c6dffd0f"}}},{name:"select-concept-answers",datasource:{name:"select_concept_answers_datasource",config:{concept:""}}},{name:"encounter-provider",datasource:{name:"provider_datasource"}},{name:"encounter-role",datasource:{name:"encounter_role_datasource"}},{name:"encounter-location",datasource:{name:"location_datasource"}},{name:"problem",datasource:{name:"problem_datasource",config:{class:["8d4918b0-c2cc-11de-8d13-0010c6dffd0f","8d492954-c2cc-11de-8d13-0010c6dffd0f","8d492b2a-c2cc-11de-8d13-0010c6dffd0f"]}}}],oS=e=>ok.find(t=>t.name===e),oO=({field:e,errors:t,warnings:n,setFieldValue:r})=>{let{t:i}=(0,eO.useTranslation)(),[o,a]=(0,c.useState)([]),[l,s]=(0,c.useState)(!1),[u,f]=(0,c.useState)(!1),[p,m]=(0,c.useState)(""),h=(0,c.useRef)(!1),[y,v]=(0,c.useState)(null),[b,_]=(0,c.useState)({}),w=(e=>{let t=e.questionOptions.config?.referencedField,{methods:{control:n}}=tO();return Z({control:n,name:t,exact:!0,disabled:!t})})(e),x=(0,tE.H)(e.questionOptions.isSearchable),{layoutType:E,sessionMode:k,workspaceLayout:S,methods:{control:O,getFieldState:D,getValues:C}}=tO(),F=Z({control:O,name:e.id,exact:!0}),{isDirty:A}=D(e.id),P=(0,c.useMemo)(()=>!!(eB(k)||(0,tE.H)(e.readonly))&&tm(e.inlineRendering,E,S,k),[k,e.readonly,e.inlineRendering,E,S]),T=(0,c.useMemo)(()=>o.find(e=>e.uuid==F)||null,[o,F]),V=(0,c.useRef)(0),M=(0,c.useMemo)(()=>oE((t,n)=>{let r=V.current;f(!0),n.fetchData(t,b).then(t=>{r===V.current&&(t.length&&a(r=>{let i=C(e.id),o=r.find(e=>e.uuid==i),a=t.map(e=>n.toUuidAndDisplay(e,b));return o&&!a.some(e=>e.uuid==o.uuid)&&a.unshift(o),a}),f(!1))}).catch(e=>{r===V.current&&(console.error(e),f(!1))})},300),[b,e.id,C]),j=(0,c.useCallback)(e=>o.some(t=>t.display?.toLowerCase().includes(e.toLowerCase())),[o]);return((0,c.useEffect)(()=>{let t=e.questionOptions?.datasource?.name;_(t?e.questionOptions.datasource?.config:oS(e.questionOptions.rendering)?.datasource?.config),aU(t||e.questionOptions.rendering).then(e=>v(e))},[e.questionOptions?.datasource]),(0,c.useEffect)(()=>{let t=!1;return y&&!(0,tE.H)(e.questionOptions.isSearchable)&&(a([]),s(!0),y.fetchData(null,{...b,referencedValue:w}).then(e=>{t||(a(e.map(e=>y.toUuidAndDisplay(e,b))),s(!1))}).catch(e=>{t||(console.error(e),s(!1),a([]))})),()=>{t=!0}},[y,b,w]),(0,c.useEffect)(()=>(y&&x&&!ej(p)&&!j(p)?M(p,y):f(!1),()=>{M.cancel(),V.current++}),[y,p,x,M]),(0,c.useEffect)(()=>{let e=!1;return F&&!A&&y&&x&&!o.length&&(s(!0),y.fetchSingleItem(F,b).then(t=>{e||(a([y.toUuidAndDisplay(t,b)]),s(!1))}).catch(t=>{e||(console.error(t),s(!1))})),()=>{e=!0}},[F,A,y,x,o,b]),l)?d().createElement(g.DropdownSkeleton,null):eB(k)||(0,tE.H)(e.readonly)?d().createElement(tL,{label:i(e.label),value:F?oD(o.find(e=>e.uuid==F)):F,conceptName:e.meta?.concept?.display,isInline:P}):!e.isHidden&&d().createElement("div",{className:"-esm-form-engine__ui-select-extended__boldedLabel___MlmB3"},d().createElement(g.Layer,null,d().createElement(g.ComboBox,{id:e.id,titleText:d().createElement(tB,{field:e}),items:o,itemToElement:e=>d().createElement("span",{className:"-esm-form-engine__ui-select-extended__item___+jYTi"},e?.code&&d().createElement("span",{className:"-esm-form-engine__ui-select-extended__code___Sg-vJ"},e.code),d().createElement("span",{className:"-esm-form-engine__ui-select-extended__label___tsm2B"},e?.display)),itemToString:oD,selectedItem:T,placeholder:x?i("search","Search")+"...":null,onChange:({selectedItem:e})=>{M.cancel(),V.current++,f(!1),h.current=!0,r(e?.uuid)},disabled:e.isDisabled,readOnly:(0,tE.H)(e.readonly),invalid:t.length>0,invalidText:t.length&&t[0].message,onInputChange:t=>{if(h.current){h.current=!1;return}e.questionOptions.isSearchable&&m(t)},onBlur:e=>{e.target.value||r(null)}}),u&&d().createElement(g.InlineLoading,{className:"-esm-form-engine__ui-select-extended__loader___-txFf",description:i("searching","Searching")+"..."})))};function oD(e){return e?.code?`${e.code} ${e.display}`:e?.display??""}var oC=n(3322);function oF(e,t,n){let r=[],i=(0,oC.A)(e);return i.questionOptions.repeatOptions={...i.questionOptions.repeatOptions??{}},i.meta={repeat:{...i.meta??{},isClone:!0},initialValue:{omrsObject:t}},i.id=`${i.id}_${n}`,i.questions?.forEach(e=>{r.push(e.id),e.id=`${e.id}_${n}`,e.meta.groupId=i.id,e.meta.initialValue={omrsObject:null,refinedValue:null},e.fieldDependents=new Set,eq(e),e.hide&&e.hide.hideWhenExpression&&(e.hide.hideWhenExpression=oA(e.hide.hideWhenExpression,n,r)),e.validators?.length&&e.validators.forEach(e=>{"js_expression"===e.type&&(e.failsWhenExpression=oA(e.failsWhenExpression,n,r))}),e.questionOptions.calculate?.calculateExpression&&(e.questionOptions.calculate.calculateExpression=oA(e.questionOptions.calculate?.calculateExpression,n,r))}),i}function oA(e,t,n){let r=[...new Set(n)];if(!r.length)return e;let i=r.slice().sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return e.replace(RegExp(`\\b(?:${i})\\b`,"g"),e=>`${e}_${t}`)}let oP=[],oT={async getInitialValue(e,t,n){let r=oq(eN((t??n.domainObjectValue).obs),oP,e);return eL(e,"file")&&r?.length?oR(e,r):oV(e,r,!0)},async getPreviousValue(e,t,n){let r=t??n.previousDomainObjectValue;if(r){let t=oV(e,oq(eN(r.obs),oP,e),!0);if(!ej(t))return{value:t,display:this.getDisplayValue(e,t)}}return null},getDisplayValue:(e,t)=>{let n=e.questionOptions.rendering;return ej(t)?t:t instanceof Date?ez(e,t):"checkbox"===n?t.map(t=>e.questionOptions.answers?.find(e=>e.concept==t)?.label):"toggle"===n?t?e.questionOptions.toggleOptions.labelTrue:e.questionOptions.toggleOptions.labelFalse:u.FU.includes(n)?e.questionOptions.answers?.find(e=>e.concept==t)?.label:t},transformFieldValue:(e,t,n)=>(eq(e),!e.meta.initialValue?.omrsObject&&ej(t))?null:eL(e,"checkbox")?function(e,t=[]){let n=e.meta.initialValue?.omrsObject;if(n?.length&&ej(t))return eR(e,null,n.map(e=>oj(e)));if(n?.length&&!ej(t)){let r=n.filter(e=>!t.includes(e.value.uuid));return eR(e,t.filter(e=>!n.some(t=>t.value.uuid===e)).map(t=>oM(e,t)),r.map(e=>oj(e)))}return eR(e,t.map(t=>oM(e,t)),void 0)}(e,Array.isArray(t)?t:[t]):eL(e,"file")?function(e,t=[]){let n=t.filter(e=>e.uuid&&e.voided).map(e=>({uuid:e.uuid,voided:!0})),r=e.meta.submission.newValue=t.filter(e=>!e.uuid).map(t=>({formFieldNamespace:"rfe-forms",formFieldPath:`rfe-forms-${e.id}`,...t}));return eR(e,r,n)}(e,t):!ej(t)&&oL(e,t)?eR(e,oI(e,t),void 0):e.meta.initialValue?.omrsObject&&ej(t)?eR(e,void 0,oj(e.meta.initialValue.omrsObject)):ej(t)?null:eR(e,oM(e,t),void 0),tearDown:function(){oP=[]}};function oV(e,t=[],n=!1){let r=e.questionOptions.rendering;if(e.meta||(e.meta={initialValue:{omrsObject:null,refinedValue:null}}),t.length){if("checkbox"==r)return oP.push(...t.map(e=>e.uuid)),e.meta.initialValue.omrsObject=n?t:null,t.map(e=>e.value.uuid);let i=t[0];if(n&&(e.meta.initialValue.omrsObject={...i}),oP.push(i.uuid),"string"==typeof i.value||"number"==typeof i.value){if(r.startsWith("date")){let t=eH(i.value);return n&&(e.meta.initialValue.omrsObject.value=eP()(t).format("YYYY-MM-DD HH:mm")),t}return i.value}return"toggle"==r?i.value.uuid===u.t$:"fixed-value"==r?e.fixedValue:i.value?.uuid}return""}function oM(e,t){return ej(t)&&"obsGroup"!==e.type?null:{..."obsGroup"===e.type?{groupMembers:[]}:{value:e.questionOptions.rendering.startsWith("date")?oN(e,t):t},concept:e.questionOptions.concept,formFieldNamespace:"rfe-forms",formFieldPath:`rfe-forms-${e.id}`}}function oj(e){return{uuid:e.uuid,voided:!0}}function oI(e,t){let n=e.meta.initialValue?.omrsObject,r=e.questionOptions.rendering.startsWith("date")?oN(e,t):t;return{uuid:n.uuid,value:r,formFieldNamespace:"rfe-forms",formFieldPath:`rfe-forms-${e.id}`}}function oN(e,t){if(e.datePickerFormat)switch(e.datePickerFormat){case"calendar":default:return eP()(t).format("YYYY-MM-DD");case"timer":return eP()(t).format("HH:mm");case"both":return eP()(t).format("YYYY-MM-DD HH:mm")}return t}function oL(e,t){let n=e.meta.initialValue?.omrsObject;return!ej(n)&&(u.FU.includes(e.questionOptions.rendering)?n.value.uuid!==t:eL(e,"date")?0!==eP()(t).diff(eP()(n.value),"D"):eL(e,"datetime")||"both"===e.datePickerFormat?0!==eP()(t).diff(eP()(n.value),"minute"):eL(e,"toggle")?n.value.uuid===u.t$!==t:n.value!==t)}function oq(e,t,n){let r=e.filter(e=>!!eL(n,"file")&&e.formFieldPath==`rfe-forms-${n.id}`||e.formFieldPath==`rfe-forms-${n.id}`&&e.concept.uuid==n.questionOptions.concept);if(!r?.length){let r=e.filter(e=>e.concept.uuid==n.questionOptions.concept);return t?.length?r.filter(e=>!t.includes(e.uuid)):r}return r}async function oR(e,t){let n=new AbortController,r=await Promise.all(t.map(e=>(0,s.getAttachmentByUuid)(e.uuid,n).then(e=>e.data).catch(t=>(console.error(`Failed to fetch attachment ${e.uuid}:`,t),null))));return e.meta.initialValue={omrsObject:t},r.filter(Boolean).map(e=>({uuid:e.uuid,base64Content:`${window.openmrsBase}${s.attachmentUrl}/${e.uuid}/bytes`,fileName:e.filename,fileDescription:e.comment,fileType:e.bytesContentFamily?.toLowerCase()}))}let o$={validate:(e,t)=>!ej(t)&&u.FU.includes(e.questionOptions.rendering)&&!(Array.isArray(t)?t:[t]).every(t=>e.questionOptions.answers?.find(e=>e.concept===t||e.value===t))?[{resultType:"error",errCode:"invalid.defaultValue",message:"Value not found in coded answers list"}]:ej(t)||"date"!=e.questionOptions.rendering||eP()(t).isValid()?!ej(t)&&"number"==e.questionOptions.rendering&&isNaN(t)?[{resultType:"error",errCode:"invalid.defaultValue",message:`Invalid numerical value: '${t}'`}]:[]:[{resultType:"error",errCode:"invalid.defaultValue",message:`Invalid date value: '${t}'`}]},oB=[];function oH(e,t,n){return e?{action:"NEW",concept:e,type:t?.questionOptions?.orderType||"testorder",careSetting:t?.questionOptions?.orderSettingUuid||"6f0c9a92-6f24-11e3-af88-005056821db0",orderer:n}:null}let oz=[];function oU(e,t){let n=t.meta.initialValue?.omrsObject;n&&oW(e,(Array.isArray(n)?n:[n]).map(e=>oj(e)))}function oW(e,t){t&&(Array.isArray(t)?e.push(...t):e.push(t))}function oY(e){return!!(e.isHidden||e.isParentHidden)}function oJ(e){if("toggle"==e.questionOptions.rendering&&"boolean"!=typeof e.questionOptions.defaultValue)return e.questionOptions.defaultValue==u.t$;let t=o$.validate(e,e.questionOptions.defaultValue);return t.length?(console.error(`Default value validation errors for field "${e.id}" with value "${e.questionOptions.defaultValue}":`,t),null):e.questionOptions.defaultValue}async function oZ(e,t,n,r){let i=1,{formFieldAdapters:o}=r,a=t.obs.filter(t=>t.concept.uuid===e.questionOptions.concept&&t.uuid!=e.meta.initialValue?.omrsObject?.uuid&&!oP.includes(t.uuid)),l=t.orders.filter(t=>(e.questionOptions.answers?.map(e=>e.concept)||[]).includes(t.concept?.uuid)&&!oB.includes(t.uuid));if("testOrder"===e.type)return Promise.all(l.filter(e=>!e.voided).map(async t=>{let a=oF(e,t,i++);return n[a.id]=await o[e.type].getInitialValue(a,{orders:[t]},r),a}));let s=t.diagnoses.filter(t=>!t.voided&&!oz.includes(t?.diagnosis?.coded.uuid)&&t.formFieldPath.startsWith(`rfe-forms-${e.id}_`));return"diagnosis"===e.type?Promise.all(s.map(async t=>{let i=parseInt(t.formFieldPath.split("_")[1]),a=oF(e,t,i);return n[a.id]=await o[e.type].getInitialValue(a,{diagnoses:[t]},r),oz.includes(t.diagnosis.coded.uuid)||oz.push(t.diagnosis.coded.uuid),a})):Promise.all(a.map(async t=>{let a=oF(e,t,i++);return await Promise.all(a.questions.map(async i=>{n[i.id]=await o[e.type].getInitialValue(i,{obs:[t]},r)})),oP.push(t.uuid),[a,...a.questions]})).then(e=>e.flat())}function oG(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class oQ{getDomainObject(){return this.domainObjectValue}async loadDependencies(e,t,n){return Promise.resolve({})}constructor(e){oG(this,"formJson",void 0),oG(this,"domainObjectValue",void 0),this.formJson=e}}var oK=n(1807),oX=n(7361),o0=n(6956),o1=n(7313),o2=n(3660),o4=n.n(o2),o3=n(1619),o5=n.n(o3);function o6(e){let[t,n]=(0,c.useState)(!0),{encounter:r,isLoading:i}=function(e){let[t,n]=(0,c.useState)(null),[r,i]=(0,c.useState)(!0),[o,a]=(0,c.useState)(null);return(0,c.useEffect)(()=>{var t;let r=new AbortController;return!ej(e.encounter)&&("string"==typeof(t=e.encounter)||!(0,o0.A)(t)&&(0,o1.A)(t)&&"[object String]"==(0,oX.A)(t))?(0,s.openmrsFetch)(`${s.restBaseUrl}/encounter/${e.encounter}?v=${u.RZ}`,{signal:r.signal}).then(e=>{n(e.data),i(!1)}).catch(e=>{a(e)}):(ej(e.encounter)||n(e.encounter),i(!1)),()=>{r.abort()}},[e.encounter]),{encounter:t,error:o,isLoading:r}}(e.formJson),{encounterRole:o,isLoading:a}=function(){let{data:e,error:t,isLoading:n}=o4()(`${s.restBaseUrl}/encounterrole?v=custom:(uuid,display,name)`,s.openmrsFetch),r=e?.data.results.find(e=>"Clinician"===e.name);return r?{encounterRole:r,error:t,isLoading:n}:{encounterRole:e?.data.results[0],error:t,isLoading:n}}(),{isLoadingPatientPrograms:l,patientPrograms:d}=((e,t)=>{let{activePrograms:n,error:r,isLoading:i}=(e=>{let t=`${s.restBaseUrl}/programenrollment?patient=${e}&v=custom:(uuid,display,program:(uuid,name,allWorkflows),dateEnrolled,dateCompleted,location:(uuid,display),states:(startDate,endDate,state:(uuid,name,retired,concept:(uuid),programWorkflow:(uuid)))`,{data:n,error:r,isLoading:i}=o5()(e?t:null,s.openmrsFetch),o=n?.data?.results.length>0?n?.data.results.sort((e,t)=>t.dateEnrolled>e.dateEnrolled?1:-1):null;return{activePrograms:o?.filter(e=>!e.dateCompleted),error:r,isLoading:i}})(t.meta?.programs?.hasProgramFields?e:null);return{patientPrograms:n,errorFetchingPatientPrograms:r,isLoadingPatientPrograms:i}})(e.patient?.id,e.formJson);return(0,c.useEffect)(()=>{n(l||i||a)},[l,i,a]),{data:{encounter:r,patientPrograms:d,encounterRole:o},isLoading:t,error:null,updateContext:(t,{setDomainObjectValue:n,setCustomDependencies:i})=>{e.processor.domainObjectValue=r,n(r),i(e=>({...e,patientPrograms:d,defaultEncounterRole:o}))}}}let o9={checkbox:[],toggle:!1,text:""},o7=["encounterProvider","encounterDatetime","encounterLocation","patientIdentifier","encounterRole","programState","personAttribute"];class o8 extends oQ{prepareFormSchema(e){let t=new Set;return e.pages.forEach(n=>{n.sections.forEach(r=>{r.questions.forEach(i=>{!function e(n,r,i,o){n.id&&t.add(n.id),n.inlineRendering=n.inlineRendering??r.inlineRendering??i.inlineRendering??o.inlineRendering,n.readonly=n.readonly??r.readonly??i.readonly??o.readonly,n.questionOptions?.rendering!="fixed-value"||n.meta.fixedValue||(n.meta.fixedValue=n.value,delete n.value),(n.questionOptions?.rendering=="group"||"obsGroup"===n.type)&&n.questions?.forEach(t=>(t.readonly=t.readonly??n.readonly,e(t,r,i,o)))}(i,r,n,e)})})}),function(e,t){let n=/(['"])([a-zA-Z_][a-zA-Z0-9_]*)\1/g;function r(e){e.questionOptions?.calculate?.calculateExpression&&function(e,r){for(let i of e.matchAll(n)){let e=i[2];t.has(e)&&console.error(`The calculateExpression for the field '${r}' incorrectly quotes the field ID '${e}' as a string. Field IDs must be referenced as variables without quotes to access their values. Remove the quotes: use ${e} instead of '${e}'.`)}}(e.questionOptions.calculate.calculateExpression,e.id),e.questions&&e.questions.forEach(r)}e.pages.forEach(e=>{e.sections.forEach(e=>{e.questions.forEach(r)})})}(e,t),e}async processSubmission(e,t){var n,r,i,o,a,l;let{encounterRole:u,encounterProvider:c,encounterDate:d,encounterLocation:f}=function(e){let{formFields:t,location:n,currentProvider:r,customDependencies:i,sessionDate:o,domainObjectValue:a,visit:l}=e,{defaultEncounterRole:s}=i,u=t.find(e=>"encounterRole"===e.type)?.meta.submission?.newValue||s?.uuid,c=t.find(e=>"encounterProvider"===e.type)?.meta.submission?.newValue||r.uuid,d=t.find(e=>"encounterDatetime"===e.type)?.meta.submission?.newValue,f=l?.stopDatetime?o:void 0;return{encounterRole:u,encounterProvider:c,encounterDate:d??(a?.encounterDatetime?new Date(a.encounterDatetime):f),encounterLocation:t.find(e=>"encounterLocation"===e.type)?.meta.submission?.newValue||a?.location?.uuid||n.uuid}}(e),p=(e,t,n)=>(0,s.translateFrom)(oK.L,e,t,n),m=e.formFields.filter(e=>"patientIdentifier"===e.type&&e$(e)).map(e=>e.meta.submission.newValue),h=function(e,t,n,r,i){var o,a;let{patient:l,formJson:s,domainObjectValue:u,formFields:c,visit:d,deletedFields:f}=e,p=[...c,...f],m=[];o=m,(a=p).filter(e=>(function(e){let{questionOptions:{isTransient:t},type:n}=e;return!t&&!!["obs","obsGroup"].includes(n)&&!e.meta.groupId&&(!!(oY(e)&&e.meta.initialValue?.omrsObject)||!oY(e)&&("obsGroup"===n||e$(e)))})(e)).forEach(e=>{var t,n,r;return t=o,n=e,r=a,void(oY(n)&&n.meta.initialValue.omrsObject?oU(t,n):"obsGroup"===n.type?function e(t,n,r){if(n.meta.submission?.voidedValue)return void oW(t,n.meta.submission.voidedValue);let i=oM(n,null);n.meta.initialValue?.omrsObject&&(i.uuid=n.meta.initialValue.omrsObject.uuid),n.questions.forEach(t=>{let n=r.find(e=>e.id===t.id)??t;if(oY(n))oU(i.groupMembers,n);else if("obsGroup"===n.type){let t=[];e(t,n,r),oW(i.groupMembers,t)}else e$(n)&&(oW(i.groupMembers,n.meta.submission.newValue),oW(i.groupMembers,n.meta.submission.voidedValue))}),(i.groupMembers?.length||i.voided)&&oW(t,i)}(t,n,r):(eL(n,"file")||oW(t,n.meta.submission.newValue),oW(t,n.meta.submission.voidedValue)))});let h=p.filter(e=>"testOrder"===e.type&&e$(e)).flatMap(e=>oY(e)?[e.meta.submission.newValue?void 0:e.meta.submission.voidedValue]:[e.meta.submission.newValue,e.meta.submission.voidedValue]).filter(e=>e),g=p.filter(e=>"diagnosis"===e.type&&e$(e)).map(e=>oY(e)?e.meta.submission.newValue?void 0:e.meta.submission.voidedValue:e.meta.submission.newValue||e.meta.submission.voidedValue).filter(e=>e),y={};return u?(Object.assign(y,u),-1===y.encounterProviders.findIndex(e=>e.provider.uuid==r)&&(y.encounterProviders=[...y.encounterProviders,{provider:r,encounterRole:n}]),t&&(y.encounterDatetime=t),y.location=i,y.form={uuid:s.uuid},d&&(y.visit=d.uuid),y.obs=m,y.orders=h,y.diagnoses=g):(y={patient:l.id,location:i,encounterType:s.encounterType,encounterProviders:[{provider:r,encounterRole:n}],obs:m,form:{uuid:s.uuid},visit:d?.uuid,orders:h,diagnoses:g},t&&(y.encounterDatetime=t)),y}(e,d,u,c,f);try{await Promise.all((n=e.patient,m.map(e=>(0,e5.savePatientIdentifier)(e,n.id)))),m?.length&&(0,s.showSnackbar)({title:p("patientIdentifiersSaved","Patient identifier(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){let e=(0,tw.j)(t);return Promise.reject({title:p("errorSavingPatientIdentifiers","Error saving patient identifiers"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}try{let t=e.formFields.filter(e=>"personAttribute"===e.type&&e$(e)).map(e=>e.meta.submission.newValue);await Promise.all((r=e.patient,t.map(e=>(0,e5.savePersonAttribute)(e,r.id)))),t?.length&&(0,s.showSnackbar)({title:p("personAttributesSaved","Person attribute(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){let e=(0,tw.j)(t);return Promise.reject({title:p("errorSavingPersonAttributes","Error saving person attributes"),description:e.join(", "),kind:"error",critical:!0})}try{let t,n,r,l=(i=e.formFields,o=e.patient,a=e.customDependencies.patientPrograms,t=i.filter(e=>"programState"===e.type&&e$(e)),n=new Map,t.forEach(e=>{let t=e.questionOptions.programUuid,r=e.meta.submission.newValue,i=a.find(e=>e.program.uuid===t);i?n.has(t)?n.get(t).states.push(r):n.set(t,{uuid:i.uuid,states:[r]}):n.has(t)?n.get(t).states.push(r):n.set(t,{patient:o.id,program:t,states:[r],dateEnrolled:eP()().format()})}),Array.from(n.values())),u=await await (r=new AbortController,Promise.all(l.map(e=>(0,e5.saveProgramEnrollment)(e,r))));u?.length&&(0,s.showSnackbar)({title:p("patientProgramsSaved","Patient program(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){let e=(0,tw.j)(t);return Promise.reject({title:p("errorSavingPatientPrograms","Error saving patient program(s)"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}try{let{data:n}=await (0,e5.saveEncounter)(t,h,h.uuid),r=n.orders.map(e=>e.orderNumber),i=n.diagnoses.map(e=>e.display);r.length&&(0,s.showSnackbar)({title:p("ordersSaved","Order(s) saved successfully"),subtitle:r.join(", "),kind:"success",isLowContrast:!0}),i.length&&(0,s.showSnackbar)({title:p("diagnosisSaved","Diagnosis(es) saved successfully"),subtitle:i.join(", "),kind:"success",isLowContrast:!0});try{let t,r=await (l=e.formFields,t=l?.filter(e=>e?.questionOptions.rendering==="file"&&e$(e)),!t?.length?[]:Promise.all(t.flatMap(e=>{let t="string"==typeof n?.patient?n?.patient:n?.patient?.uuid;return(e.meta.submission.newValue??[]).map(e=>(0,e5.createAttachment)(t,n.uuid,e))})));r?.length&&(0,s.showSnackbar)({title:p("attachmentsSaved","Attachment(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){console.error("Error saving attachments",t);let e=(0,tw.j)(t);return Promise.reject({title:p("errorSavingAttachments","Error saving attachment(s)"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}return n}catch(t){console.error("Error saving encounter",t);let e=(0,tw.j)(t);return Promise.reject({title:p("errorSavingEncounter","Error saving encounter"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}}getCustomHooks(){return{useCustomHooks:o6}}async getInitialValues(e){let{domainObjectValue:t,formFields:n,formFieldAdapters:r}=e,i={},o=[];if(t){await Promise.all(n.map(async n=>{let a=r[n.type];if(n.meta.initialValue?.omrsObject&&!ej(n.meta.initialValue.refinedValue)){i[n.id]=n.meta.initialValue.refinedValue;return}if(a){eL(n,"repeating")&&!n.meta?.repeat?.isClone&&o.push(n);let r=null;try{r=await a.getInitialValue(n,t,e),n.meta.initialValue.refinedValue=r}catch(e){console.error(e)}if("obsGroup"===n.type)return;if(ej(r)?ej(n.questionOptions.defaultValue)?i[n.id]=o9[n.questionOptions.rendering]??"":i[n.id]=oJ(n):i[n.id]=r,n.questionOptions.calculate?.calculateExpression)try{await ae(n,i,e)}catch(e){console.error(e)}}else console.warn(`No adapter found for field type ${n.type}`)}));let a=await Promise.all(o.flatMap(n=>oZ(n,t,i,e))).then(e=>e.flat());n.push(...a)}else{let t=n.filter(e=>"group"!==e.questionOptions.rendering&&"obsGroup"!==e.type),o=[];await Promise.all(t.map(async t=>{let n=r[t.type];if(i[t.id]=o9[t.questionOptions.rendering]??null,ej(i[t.id])&&o7.includes(t.type))try{i[t.id]=await n.getInitialValue(t,null,e)}catch(e){console.error(e)}t.questionOptions.defaultValue&&(i[t.id]=oJ(t)),t.questionOptions.calculate?.calculateExpression&&o.push(t)})),await Promise.all(o.map(async t=>{try{await ae(t,i,e)}catch(e){console.error(e)}}))}return i}async loadDependencies(e,t,{setPreviousDomainObjectValue:n}){let{patient:r,formJson:i}=e;return n(await (0,e5.getPreviousEncounter)(r?.id,i.encounterType)),e}async getHistoricalValue(e,t){let{formFields:n,sessionMode:r,patient:i,methods:{getValues:o},formFieldAdapters:a,previousDomainObjectValue:l,visit:s}=t,c=a[e.type];if(e.historicalExpression){let t=await tc(e.historicalExpression,{value:e,type:"field"},n,o(),{mode:r,patient:i,previousEncounter:l,visit:s});return t?((e,t)=>{let n=e.questionOptions.rendering;if("object"!=typeof t)return{value:t,display:t};let r="Observation"===t.resourceType?function(e,t){try{return{obsDatetime:e.effectiveDateTime,uuid:e.id,concept:{uuid:e.code.coding[0]?.code,display:e.code.coding[0]?.display},value:function(e,t){switch(t){case"toggle":return e.valueBoolean?{uuid:u.t$}:{uuid:u.Mi};case"date":case"datetime":return e.valueDateTime;case"number":return e.valueQuantity?.value??null;case"radio":case"checkbox":case"select":case"content-switcher":return e.valueCodeableConcept?.coding[0]?{uuid:e.valueCodeableConcept?.coding[0].code,name:{name:e.valueCodeableConcept?.coding[0].display}}:null;default:return e.valueString}}(e,t)}}catch(e){return console.error("Error converting FHIR Obs to OpenMRS modelling",e),null}}(t,n):t;if(!r)return{value:null,display:null};if("string"==typeof r.value||"number"==typeof r.value){if("date"===n||"datetime"===n){let e=eH(`${r.value}`);return{value:e,display:eP()(e).format("YYYY-MM-DD HH:mm")}}return{value:r.value,display:r.value}}return["toggle","checkbox"].includes(n)?{value:r.value?.uuid,display:r.value?.name?.name}:{value:r.value?.uuid,display:e.questionOptions.answers?.find(e=>e.concept===r.value?.uuid)?.label}})(e,t):null}return l&&e.questionOptions.enablePreviousValue?await c.getPreviousValue(e,l,t):null}}async function ae(e,t,n){let{formFields:r,sessionMode:i,patient:o,visit:a}=n,l=e.questionOptions.calculate.calculateExpression,s=await tc(l,{value:e,type:"field"},r,t,{mode:i,patient:o,visit:a});ej(s)||(t[e.id]=s)}function at(e,t){let n=t.obs?.find(t=>t.formFieldPath.includes(e))?.value;return("object"==typeof n?n?.uuid:n)??null}async function an(e,t,n,r,i){return Promise.all(e.map(async({postAction:e,config:o,actionId:a,enabled:l})=>{try{let i=[];if(t)if(t.forEach(e=>{e?.data&&i.push(e.data),e?.uuid&&i.push(e)}),i.length)(!l||function(e,t){let n=t[0];try{let t=(0,s.compile)(e),r={};for(let e of(0,s.extractVariableNames)(t))r[e]=at(e,n);return r.useFieldValue=e=>at(e,n),r.undefined=null,!!(0,s.evaluate)(t,r)}catch(e){throw Error("Error evaluating expression",{cause:e})}}(l,i))&&await e.applyAction({patient:n,sessionMode:r,encounters:i},o);else throw Error("No encounter data to process post submission action");else throw Error("No handlers available to process post submission action")}catch(t){let e=(0,tw.j)(t);(0,s.showSnackbar)({title:String(i("errorDescriptionTitle",a?a.replace(/([a-z])([A-Z])/g,"$1 $2"):"Post Submission Error")),subtitle:String(i("errorDescription","{{errors}}",{errors:e.join(", ")})),kind:"error",isLowContrast:!1})}}))}let ar=(0,c.createContext)(void 0),ai=({patient:e,patientUUID:t,sessionMode:n,sessionDate:r,formJson:i,workspaceLayout:o,location:a,provider:l,visit:u,isFormExpanded:f=!0,children:p,isLoadingDependencies:m=!1,formSubmissionProps:h,hideFormCollapseToggle:g,handleConfirmQuestionDeletion:y,setIsFormDirty:v})=>{let{t:b}=(0,eO.useTranslation)(),_=(0,c.useRef)(void 0),w=(0,c.useRef)({}),x=(0,s.useLayoutType)(),{isSubmitting:E,setIsSubmitting:k,onSubmit:S,onError:O,handleClose:D}=h,[C,F]=(0,c.useState)(!1),A=function(e){let[t,n]=(0,c.useState)([]);return(0,c.useEffect)(()=>{let t=[];e?.length&&e.map(e=>{let n="string"==typeof e?e:e.actionId;aH(n)?.then(r=>t.push({postAction:r,config:e.config,actionId:n,enabled:e.enabled}))}),n(t)},[e]),t}(i.postSubmissionActions),P=new AbortController,T=(0,c.useCallback)((e,t,n)=>{t?w.current[e]=n:_.current=n},[]),V=(0,c.useRef)({EncounterFormProcessor:o8}),M=(0,c.useCallback)(()=>{let e=[_.current,...Object.values(w.current)],t=e.every(e=>(function(e){let{formFields:t,formFieldValidators:n,patient:r,sessionMode:i,addInvalidField:o,updateFormField:a,methods:{getValues:l,trigger:s}}=e,u=l();return 0===t.filter(e=>!e.isHidden&&!e.isParentHidden&&!e.isDisabled&&!e.meta.submission?.unspecified).flatMap(e=>e.validators?.flatMap(l=>{let s=n[l.type];if(s){let n=s.validate(e,u[e.id],{formFields:t,values:u,expressionContext:{patient:r,mode:i},...l}).filter(e=>"error"===e.resultType);return n.length&&(e.meta.submission={...e.meta.submission,errors:n},a(e),o(e)),n}})).filter(e=>!!e).length})(e));return{forms:e,isValid:t}},[]);return!function({patientUuid:e,formUuid:t,setIsSubmitting:n,setIsValidating:r}){let{t:i}=(0,eO.useTranslation)();(0,c.useEffect)(()=>{let o=o=>{let{formUuid:a,patientUuid:l,action:s}=o.detail;if(!s||!a||!l)return void(0,tw.N)(Error("The form action event is missing required details (formUuid, patientUuid, or action)."),i("formActionFailed","Form action failed"));if(a===t&&l===e)switch(s){case"onSubmit":n(!0);break;case"validateForm":r(!0);break;default:(0,tw.N)(Error(`Unsupported form action: "${s}"`),i("formActionFailed","Form action failed"))}};return window.addEventListener("ampath-form-action",o),()=>{window.removeEventListener("ampath-form-action",o)}},[n,r,t,e])}({patientUuid:t,formUuid:i?.uuid,setIsSubmitting:k,setIsValidating:F}),(0,c.useEffect)(()=>{C&&(m||M(),F(!1))},[C,M,m]),(0,c.useEffect)(()=>{if(E){if(m)return void k(!1);let{forms:t,isValid:r}=M();r?Promise.all(t.map(e=>e.processor.processSubmission(e,P))).then(async t=>{h.setIsSubmitting(!1),"edit"===n?(0,s.showSnackbar)({title:b("updatedRecord","Record updated"),subtitle:b("updatedRecordDescription","The patient encounter was updated"),kind:"success",isLowContrast:!0}):(0,s.showSnackbar)({title:b("submittedForm","Form submitted"),subtitle:b("submittedFormDescription","Form submitted successfully"),kind:"success",isLowContrast:!0}),A&&await an(A,t,e,n,b),g(),S?S(t):D()}).catch(e=>{k(!1),e instanceof Error?(0,s.showSnackbar)({title:b("errorProcessingFormSubmission","Error processing form submission"),kind:"error",subtitle:e.message,isLowContrast:!1}):(0,s.showSnackbar)(e)}):k(!1)}return()=>{P.abort()}},[E,M,m]),d().createElement(ar.Provider,{value:{patient:e,sessionMode:n,sessionDate:r,formJson:i,formProcessors:V.current,layoutType:x,workspaceLayout:o,visit:u,location:a,provider:l,isFormExpanded:f,registerForm:T,handleConfirmQuestionDeletion:y,setIsFormDirty:v}},V.current&&p)},ao=()=>{let e=(0,c.useContext)(ar);if(!e)throw Error("useFormFactoryContext must be used within a FormFactoryProvider");return e},aa={actionButtons:"-esm-form-engine__repeat-controls__actionButtons___RPDJa"},al=function({question:e,rows:t,handleDelete:n,handleAdd:r,questionIndex:i}){var o,a;let l,{t:s}=(0,eO.useTranslation)();return d().createElement("div",{className:aa.actionButtons},i>0&&d().createElement(g.Button,{className:aa.button,kind:"danger",onClick:n},d().createElement("span",null,s("remove","Remove"))),i===t.length-1&&d().createElement(g.Button,{className:aa.button,iconDescription:s("add","Add"),kind:"primary",disabled:(o=e.questionOptions.repeatOptions?.limit,a=t.length,l=Number(o),!(ej(o)||isNaN(l))&&a>=l),onClick:r},d().createElement("span",null,e.questionOptions.repeatOptions?.addText||s("add","Add"))))},as={obsGroup:"group",testOrder:"select",diagnosis:"ui-select-extended"};var au=n(5848);let ac={label:"-esm-form-engine__file__label___rUrrs",thumbnailGrid:"-esm-form-engine__file__thumbnailGrid___FRMXX",thumbnailContainer:"-esm-form-engine__file__thumbnailContainer___4S7Rq"},ad="-esm-form-engine__file-thumbnail__pdfThumbnail___CfkjD";var af=n(529),ap=n(1899);function am({bytesContentFamily:e,removeFileCb:t,...n}){let r=(0,c.useMemo)(()=>{switch(e){case"image":return ah;case"pdf":return ag;default:return ay}},[]);return d().createElement("div",{className:"-esm-form-engine__file-thumbnail__thumbnail___AGjAZ"},d().createElement(r,n),d().createElement(g.Button,{kind:"ghost",className:"-esm-form-engine__file-thumbnail__removeButton___DhEu3",onClick:t},d().createElement(af.bm,{size:16,className:"-esm-form-engine__file-thumbnail__closeIcon___zKRmf"})))}function ah(e){return d().createElement("img",{className:"-esm-form-engine__file-thumbnail__imageThumbnail___nKfAe",src:e.src,alt:e.title})}function ag(e){return d().createElement("div",{className:ad,role:"button",tabIndex:0},d().createElement(ap.aD,{size:24}))}function ay(e){return d().createElement("div",{className:ad,role:"button",tabIndex:0},d().createElement(ap.WZ,{size:24}))}let av=[{name:"drug",baseControlComponent:oO},{name:"problem",baseControlComponent:oO},{name:"encounter-provider",baseControlComponent:oO},{name:"encounter-location",baseControlComponent:oO},{name:"select-concept-answers",baseControlComponent:oO},{name:"encounter-role",baseControlComponent:oO}],ab=[{name:"text",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s}=tO(),[u,f]=(0,c.useState)(null),p=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,tE.H)(e.readonly))&&tm(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l?d().createElement(tL,{label:o(e.label),value:t,conceptName:e.meta?.concept?.display,isInline:p}):!e.isHidden&&d().createElement("div",{className:"-esm-form-engine__text__boldedLabel___WRIlW"},d().createElement(g.Layer,null,d().createElement(g.TextInput,{disabled:e.isDisabled,enableCounter:!!(e.questionOptions.max||e.questionOptions.maxLength),id:e.id,invalid:n.length>0,invalidText:n[0]?.message,labelText:d().createElement(tB,{field:e}),maxCount:e.questionOptions.max?Number(e.questionOptions.max):Number(e.questionOptions.maxLength),name:e.id,onBlur:e=>{e.preventDefault(),u!==t&&f(t)},onChange:e=>{i(e.target.value)},readOnly:(0,tE.H)(e.readonly),value:t??"",warn:r.length>0,warnText:r.length>0?r[0].message:void 0})))}},{name:"textarea",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),[a,l]=(0,c.useState)(t),{layoutType:s,sessionMode:u,workspaceLayout:f}=tO(),p=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(u)||(0,tE.H)(e.readonly))&&tm(e.inlineRendering,s,f,u),[u,e.readonly,e.inlineRendering,s,f]);return"view"==u||"embedded-view"==u?d().createElement(tL,{label:o(e.label),value:t,conceptName:e.meta?.concept?.display,isInline:p}):!e.isHidden&&d().createElement("div",{className:"-esm-form-engine__text-area__boldedLabel___VdRnE"},d().createElement(g.Layer,null,d().createElement(g.TextArea,{id:e.id,labelText:d().createElement(tB,{field:e}),name:e.id,onChange:i,onBlur:e=>{e.preventDefault(),a!==t&&l(t)},value:t||"",rows:e.questionOptions.rows||4,disabled:e.isDisabled,readOnly:(0,tE.H)(e.readonly),invalid:n.length>0,invalidText:n[0]?.message,warn:r.length>0,warnText:r[0]?.message,enableCounter:!!(e.questionOptions.max||e.questionOptions.maxLength),maxCount:e.questionOptions.max?Number(e.questionOptions.max):Number(e.questionOptions.maxLength)})))}},{name:"select",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:f}=tO(),p=(0,c.useCallback)(({selectedItem:e})=>{i(e===u.ZA?null:e)},[i]),m=(0,c.useCallback)(t=>{let n=e.questionOptions.answers.find(e=>e.value?e.value==t:e.concept==t);return n?o(n.label):""},[e.questionOptions.answers,o]),h=(0,c.useMemo)(()=>{let t=e.questionOptions.answers;return t.some(e=>e.value===u.ZA)||t.unshift({value:u.ZA,label:o("chooseAnOption","Choose an option")}),t.filter(e=>!e.isHidden).map(e=>e.value||e.concept)},[e.questionOptions.answers]),y=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,tE.H)(e.readonly))&&tm(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l?d().createElement(tL,{label:o(e.label),value:t?f[e.type].getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:y}):!e.isHidden&&d().createElement("div",{className:"-esm-form-engine__dropdown__boldedLabel___jRkpD"},d().createElement(g.Layer,null,d().createElement(g.Dropdown,{"aria-label":o(e.label),disabled:e.isDisabled,id:e.id,invalid:n.length>0,invalidText:n[0]?.message,items:h,itemToString:m,label:"",onChange:p,readOnly:(0,tE.H)(e.readonly),selectedItem:ej(t)?u.ZA:t,titleText:d().createElement(tB,{field:e}),warn:r.length>0,warnText:r[0]?.message})))}},{name:"checkbox",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:u}=tO(),[f,p]=(0,c.useState)(0),[m,h]=(0,c.useState)([]),y=(0,c.useRef)(!0),v=e.questionOptions.answers.filter(e=>!e.isHidden).map((t,n)=>({id:`${e.id}-${t.concept}`,concept:t.concept,label:o(t.label),key:n,disabled:t.disable?.isDisabled,readonly:(0,tE.H)(e.readonly)})),b=(0,c.useMemo)(()=>t?.length&&f<1?(p(f+1),v.filter(e=>t?.includes(e.concept))):[],[t]),_=(0,c.useMemo)(()=>(0,tE.H)(e.questionOptions.isCheckboxSearchable),[e.questionOptions.isCheckboxSearchable]);(0,c.useEffect)(()=>{y.current&&1===f&&(h(b.map(e=>e.concept)),y.current=!1)},[b,y]);let w=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,tE.H)(e.readonly))&&tm(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l?d().createElement("div",{className:oo.formField},d().createElement(tL,{label:o(e.label),value:t?u[e.type]?.getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:w})):!e.isHidden&&d().createElement(d().Fragment,null,d().createElement("div",{className:oo.boldedLabel},d().createElement(g.Layer,null,_?d().createElement(g.FilterableMultiSelect,{disabled:e.isDisabled,id:e.id,initialSelectedItems:b,invalid:n.length>0,invalidText:n[0]?.message,items:v,itemToString:e=>e?o(e.label):" ",key:e.id,onChange:({selectedItems:e})=>{i(e.map(e=>e.concept))},placeholder:o("search","Search")+"...",readOnly:(0,tE.H)(e.readonly),titleText:d().createElement(tB,{field:e}),warn:r.length>0,warnText:r[0]?.message}):d().createElement(g.CheckboxGroup,{legendText:d().createElement(tB,{field:e}),readOnly:(0,tE.H)(e.readonly)},v?.map((t,n)=>d().createElement(g.Checkbox,{className:oo.checkbox,checked:m.some(e=>e===t.concept),disabled:t.disabled,id:`${e.id}-${t.concept}`,key:`${e.id}-${t.concept}-${n}`,labelText:o(t.label),name:t.concept,onChange:()=>{let e,n;return n=t.concept,void(h(e=m.some(e=>e===n)?m.filter(e=>e!==n):m.some(e=>e===n)?m.filter(e=>e!==n):[...m,n]),i(e))},readOnly:(0,tE.H)(e.readonly)}))))),_&&d().createElement("div",{className:oo.selectionDisplay},t?.length?d().createElement("div",{className:oo.tagContainer},u[e.type]?.getDisplayValue(e,t)?.map((e,t)=>d().createElement(g.Tag,{key:t,type:"cool-gray"},o(e)))):d().createElement(tD,null)))}},{name:"radio",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:u}=tO(),f=e=>{i(e)},p=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,tE.H)(e.readonly))&&tm(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l||(0,tE.H)(e.readonly)?d().createElement(tL,{label:o(e.label),value:t?u[e.type].getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:p}):!e.isHidden&&d().createElement(g.FormGroup,{legendText:d().createElement(tB,{field:e}),className:"-esm-form-engine__radio__boldedLegend___YisTw",disabled:e.isDisabled,invalid:n?.length>0},d().createElement(g.RadioButtonGroup,{name:e.id,valueSelected:t,onChange:f,readOnly:(0,tE.H)(e.readonly),orientation:e.questionOptions?.orientation||"vertical"},e.questionOptions.answers.filter(e=>!e.isHidden).map((n,r)=>d().createElement(g.RadioButton,{id:`${e.id}-${n.label}`,labelText:o(n.label)??"",value:n.concept,key:r,onClick:e=>{t&&e.target.checked?(e.target.checked=!1,e.preventDefault(),f(null)):f(n.concept)}}))),(n?.length>0||r?.length>0)&&d().createElement("div",null,d().createElement("div",{className:"-esm-form-engine__radio__errorMessage___fmThI"},n.length>0?n[0].message:r.length>0?r[0].message:null)))}},{name:"date",component:tH},{name:"datetime",component:tH},{name:"number",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s}=tO(),u=(0,c.useMemo)(()=>isNaN(t)?"":t??"",[t]),f=(0,c.useCallback)(e=>void 0===e||isNaN(Number(e))?void 0:Number(e),[]),m=(0,c.useCallback)((e,{value:t})=>{let n=f(t);i(isNaN(n)?void 0:n)},[i,f]),h=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,tE.H)(e.readonly))&&tm(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]),y=f(e.questionOptions.max),v=f(e.questionOptions.min);return"view"==l||"embedded-view"==l?d().createElement("div",{className:oa.formField},d().createElement(tL,{label:o(e.label),value:t,conceptName:e.meta?.concept?.display,isInline:h})):!e.isHidden&&d().createElement(g.Layer,null,d().createElement(g.NumberInput,{id:e.id,invalid:n.length>0,invalidText:n[0]?.message,label:d().createElement(tB,{field:e}),max:y,min:v,name:e.id,value:u,onChange:m,allowEmpty:!0,size:"lg",hideSteppers:e.hideSteppers??!1,disabled:e.isDisabled,readOnly:(0,tE.H)(e.readonly),className:p()(oa.controlWidthConstrained,oa.boldedLabel),warn:r.length>0,warnText:r[0]?.message,step:e.questionOptions.step??.01}))}},{name:"content-switcher",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:u}=tO(),f=(0,c.useCallback)(e=>{i(e.name)},[i]),m=(0,c.useMemo)(()=>e.questionOptions.answers.filter(e=>!e.isHidden),[e.questionOptions.answers]),h=(0,c.useMemo)(()=>m.findIndex(e=>e.concept==t),[t,m]),y=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,tE.H)(e.readonly))&&tm(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l||(0,tE.H)(e.readonly)?d().createElement("div",{className:"-esm-form-engine__content-switcher__formField___vZnsA"},d().createElement(tL,{label:o(e.label),value:t?u[e.type].getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:y})):!e.isHidden&&d().createElement(g.FormGroup,{legendText:d().createElement("div",{className:tq},d().createElement(tB,{field:e})),className:p()({"-esm-form-engine__content-switcher__errorLegend___JGh37":n.length>0,[tq]:0===n.length})},d().createElement(g.ContentSwitcher,{onChange:f,selectedIndex:h,className:"-esm-form-engine__content-switcher__selectedOption___KMGst",size:"md"},m.map((t,n)=>d().createElement(g.Switch,{name:t.concept||t.value,text:o(t.label),key:n,disabled:e.isDisabled}))))}},{name:"toggle",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),a=tO();(0,c.useEffect)(()=>{e.meta?.initialValue?.omrsObject||"enter"!=a.sessionMode||a.formFieldAdapters[e.type].transformFieldValue(e,t??!1,a)},[]);let l=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(a.sessionMode)||(0,tE.H)(e.readonly))&&tm(e.inlineRendering,a.layoutType,a.workspaceLayout,a.sessionMode),[a.sessionMode,e.readonly,e.inlineRendering,a.layoutType,a.workspaceLayout]);return"view"==a.sessionMode||"embedded-view"==a.sessionMode?d().createElement(tL,{label:o(e.label),value:ej(t)?t:a.formFieldAdapters[e.type].getDisplayValue(e,t),conceptName:e.meta?.concept?.display,isInline:l}):!e.isHidden&&d().createElement("div",{className:ol},d().createElement(g.Toggle,{labelText:o(e.label),className:ol,id:e.id,labelA:e.questionOptions.toggleOptions.labelFalse,labelB:e.questionOptions.toggleOptions.labelTrue,onToggle:e=>{i(e)},toggled:!!t,disabled:e.isDisabled,readOnly:(0,tE.H)(e.readonly)}))}},{name:"workspace-launcher",component:({field:e})=>{let{t}=(0,eO.useTranslation)(),{sessionMode:n,patient:r,visit:i}=tO(),o=async()=>{let n=e.questionOptions?.workspaceName;if(!n)return void(0,s.showSnackbar)({title:t("invalidWorkspaceName","Invalid workspace name."),subtitle:t("invalidWorkspaceNameSubtitle","Please provide a valid workspace name."),kind:"error",isLowContrast:!0});let o=e.questionOptions?.workspaceProps??{},a={patient:r,patientUuid:r?.id,visitContext:i};try{await (0,s.launchWorkspace2)(n,o,a)}catch(e){(0,s.showSnackbar)({title:t("errorLaunchingWorkspace","Error launching workspace"),subtitle:e?.message??t("errorLaunchingWorkspaceSubtitle","An unexpected error occurred while launching the workspace."),kind:"error",isLowContrast:!0})}};return e.isHidden||eB(n)?null:d().createElement("div",null,d().createElement("div",{className:"-esm-form-engine__workspace-launcher__label___vIWfO"},d().createElement(tB,{field:e})),d().createElement("div",{className:"-esm-form-engine__workspace-launcher__workspaceButton___cmGUN"},d().createElement(g.Button,{disabled:(0,tE.H)(e.readonly??!1)||!r,onClick:o},e.questionOptions.buttonLabel?t(e.questionOptions.buttonLabel):t("launchWorkspace","Launch Workspace")),!r&&d().createElement(g.InlineNotification,{className:"-esm-form-engine__workspace-launcher__noPatientNotification___hhJs2",kind:"info",lowContrast:!0,hideCloseButton:!0,title:t("noPatientContext","No patient selected"),subtitle:t("noPatientContextSubtitle","This button is only active when a patient chart is open.")})))}},{name:"group",component:tj},{name:"repeating",component:({field:e})=>{var t;let[n,r]=(0,c.useState)([]),i=tO(),{handleConfirmQuestionDeletion:o}=ao(),{patient:a,sessionMode:l,formFieldAdapters:u,formFields:f,methods:{getValues:p,setValue:m,unregister:h},addFormField:g,removeFormField:y,deletedFields:v,setDeletedFields:b,visit:_}=i;(0,c.useEffect)(()=>{r(f.filter(t=>t.questionOptions.concept===e.questionOptions.concept&&t.id.startsWith(e.id)&&!t.meta?.repeat?.wasDeleted))},[f,e]);let w=(0,c.useCallback)(t=>{let o=[],s=oF(e,null,t);o.push(s),"obsGroup"===s.type&&s.questions?.forEach(e=>{o.push(e)}),o.forEach(e=>{e.hide?.hideWhenExpression&&(e.isHidden=tu(e.hide.hideWhenExpression,{value:e,type:"field"},[...f,...o],p(),{mode:l,patient:a,visit:_})),e.questionOptions.calculate?.calculateExpression&&tc(e.questionOptions.calculate?.calculateExpression,{value:e,type:"field"},[...f,...o],p(),{mode:l,patient:a,visit:_}).then(t=>{ej(t)||(m(e.id,t),u[e.type]?.transformFieldValue(e,t,i))}),g(e)}),r([...n,s])},[f,e,n,i]),x=e=>{e.meta.initialValue?.omrsObject?(u[e.type]?.transformFieldValue(e,null,i),e.meta.repeat={...e.meta.repeat||{},wasDeleted:!0},"obsGroup"===e.type&&e.questions.forEach(t=>{t.meta.repeat={...e.meta.repeat||{},wasDeleted:!0},u[t.type]?.transformFieldValue(t,null,i)})):(eq(e),h(e.id),e.questions?.forEach(e=>h(e.id))),r(n.filter(t=>t.id!==e.id)),b([...v,e]),y(e.id)},E=(0,c.useMemo)(()=>n.map((t,r)=>{var i;let a=d().createElement(tT,{fieldId:t.id,valueAdapter:u[t.type],repeatOptions:{targetRendering:{...i=t,questionOptions:{...i.questionOptions,rendering:as[i.type]||null}}.questionOptions.rendering}});return d().createElement("div",{key:t.id+"_wrapper"},0!==r&&d().createElement("div",null,d().createElement("hr",{className:"-esm-form-engine__repeat__divider___m-qDa"})),d().createElement("div",{className:"-esm-form-engine__repeat__nodeContainer___WpV+2"},a),!eB(l)&&d().createElement(al,{question:t,rows:n,questionIndex:r,handleDelete:()=>{if(o&&"function"==typeof o){let e=o(t);e&&"function"==typeof e.then&&"function"==typeof e.catch?e.then(()=>x(t)).catch(()=>(0,s.createErrorHandler)()):"boolean"==typeof e?e&&x(t):x(t)}else x(t)},handleAdd:()=>{w(n.reduce((t,n)=>{let r=Number(n.id.slice(e.id.length+1));return Number.isFinite(r)?Math.max(t,r):t},0)+1)}}))}),[n]);return!e.isHidden&&E&&(t=e,t.questions?.length?t.questions?.some(e=>!e.isHidden):!t.isHidden)?d().createElement(d().Fragment,null,d().createElement("div",null,E)):null}},{name:"markdown",component:({field:e})=>{var t;let{t:n}=(0,eO.useTranslation)();return!e.isHidden&&d().createElement(oi,{markdown:Array.isArray(t=e.value)?t.map(e=>n(e,{defaultValue:e,interpolation:{escapeValue:!1}})).join("\n\n"):"string"==typeof t?n(t,{defaultValue:t,interpolation:{escapeValue:!1}}):t})}},{name:"fixed-value",component:({field:e,setFieldValue:t})=>{let n=tO();return(0,c.useEffect)(()=>{e.meta?.initialValue?.omrsObject||ej(e.meta.fixedValue)||(t(e.meta.fixedValue),n.formFieldAdapters[e.type].transformFieldValue(e,e.meta.fixedValue,n))},[]),d().createElement(d().Fragment,null)}},{name:"ui-select-extended",component:oO},{name:"file",component:({field:e,value:t,setFieldValue:n})=>{let{t:r}=(0,eO.useTranslation)(),{sessionMode:i}=tO(),o="tablet"===(0,s.useLayoutType)(),a=(0,c.useCallback)(()=>{let r=(0,s.showModal)("capture-photo-modal",{saveFile:e=>(e.capturedFromWebcam&&!e.fileName.includes(".")&&(e.fileName=`${e.fileName}.png`),n([...t||[],e]),r(),Promise.resolve()),closeModal:()=>{r()},allowedExtensions:e.questionOptions.allowedFileTypes,multipleFiles:e.questionOptions.allowMultiple,collectDescription:!0})},[t,e]),l=(0,c.useCallback)(e=>{let r=[...t],i=r[e];i.uuid?r[e]={...i,voided:!0}:r.splice(e,1),n(r)},[t]);return eB(i)&&!t?d().createElement(tL,{label:r(e.label),value:null,conceptName:e.meta.concept?.display,isInline:!1}):d().createElement("div",null,d().createElement("div",{className:p()(ac.label,"cds--label")},d().createElement(tB,{field:e})),!eB(i)&&d().createElement("div",null,d().createElement(g.Button,{className:ac.uploadButton,kind:o?"ghost":"tertiary",onClick:a,renderIcon:e=>d().createElement(au.OM,{size:16,...e})},e.questionOptions.buttonLabel?r(e.questionOptions.buttonLabel):r("addFile","Add file"))),d().createElement("div",{className:ac.thumbnailGrid},t&&t.filter(e=>!e.voided).map((e,t)=>d().createElement("div",{className:ac.thumbnailContainer},d().createElement(am,{title:e.fileName,src:e.base64Content,bytesContentFamily:e.fileType,removeFileCb:()=>l(t)})))))}},...ok.map(e=>({name:e.name,component:av.find(t=>t.name===e.name).baseControlComponent}))],a_=[{name:"default_value",component:o$},{name:"form_field",component:eM},{name:"date",component:{validate:(e,t,n)=>{let r=new Date,i=t?[]:eM.validate(e,t);return i.length?i:t&&!(0,tE.H)(n?.allowFutureDates)&&t.getTime&&t.getTime()>r.getTime()?[{resultType:"error",errCode:"value.invalid",message:"Future dates not allowed"}]:[]}}},{name:"js_expression",component:{validate:function(e,t,n){return n.expressionContext.myValue=t,Object.keys(n).filter(e=>"failsWhenExpression"===e||"warnsWhenExpression"===e).flatMap(r=>{let i="failsWhenExpression"===r;return tu(n[r],{value:e,type:"field"},n.formFields,{...n.values,[e.id]:t},n.expressionContext)?[{resultType:i?"error":"warning",errCode:i?"value.invalid":null,message:n.message?n.message:i?"Invalid value":"Field has warnings"}]:[]})}}},{name:"conditionalAnswered",component:{validate:function(e,t,n){let{referenceQuestionId:r,referenceQuestionAnswers:i,values:o,formFields:a,message:l}=n,s=o[a.find(e=>e.id===r).id];return ej(t)||i.includes(s)?[]:[{resultType:"error",errCode:"invalid.valueSelected",message:l}]}}}];class aw{fetchData(e){return(0,s.openmrsFetch)(e?`${this.url}&q=${e}`:this.url).then(({data:e})=>e.results)}fetchSingleItem(e){let t=this.url;if(t.includes("?")){let n=t.split("?");t=`${n[0]}/${e}?${n[1]}`}else t=`${t}/${e}`;return(0,s.openmrsFetch)(t).then(({data:e})=>e)}toUuidAndDisplay(e){if(void 0===e.uuid||void 0===e.display)throw Error("'uuid' or 'display' not found in the OpenMRS object.");return e}constructor(e){!function(e,t){"url"in e?Object.defineProperty(e,"url",{value:t,enumerable:!0,configurable:!0,writable:!0}):e.url=t}(this,void 0),this.url=e}}let ax="custom:(uuid,display,conceptClass:(uuid,display))",aE="custom:(uuid,display,conceptClass:(uuid,display),mappings:(conceptMapType:(uuid,display),conceptReferenceTerm:(code,conceptSource:(uuid))))";class ak extends aw{fetchData(e,t){if(ej(t?.class)&&ej(t?.concept)&&!t?.useSetMembersByConcept&&ej(e))return Promise.resolve([]);let n=t?.conceptSourceUuid?aE:ax,r=`${s.restBaseUrl}/concept?name=&searchType=fuzzy&v=${n}`;if(t?.class)if("string"!=typeof t.class)return(0,s.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.results.filter(e=>e.conceptClass&&t.class.includes(e.conceptClass.uuid)));else{let e=r.split("searchType=fuzzy");r=`${e[0]}searchType=fuzzy&class=${t.class}&${e[1]}`}if(t?.concept&&t?.useSetMembersByConcept){let n=r.split("?name=&searchType=fuzzy&v="),i=t?.conceptSourceUuid?"custom:(uuid,setMembers:(uuid,display,mappings:(conceptMapType:(uuid,display),conceptReferenceTerm:(code,conceptSource:(uuid)))))":"custom:(uuid,setMembers:(uuid,display))";return r=`${n[0]}/${t.concept}?v=${i}`,(0,s.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.setMembers)}return(0,s.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.results)}fetchSingleItem(e,t){let n=t?.conceptSourceUuid?aE:ax;return(0,s.openmrsFetch)(`${s.restBaseUrl}/concept/${e}?v=${n}`).then(({data:e})=>e)}toUuidAndDisplay(e,t){let n=super.toUuidAndDisplay(e),r=this.getConceptSourceMapping(e,t?.conceptSourceUuid)?.conceptReferenceTerm?.code;return r?{...n,code:r}:n}getConceptSourceMapping(e,t){if(!t)return;let n=e.mappings?.filter(e=>e.conceptReferenceTerm?.conceptSource?.uuid===t)??[];return n.find(e=>e.conceptMapType?.uuid==="35543629-7d8c-11e1-909d-c80aa9edcf4e"||e.conceptMapType?.display?.toUpperCase()==="SAME-AS")??n[0]}constructor(){super(`${s.restBaseUrl}/concept?v=${ax}`)}}let aS=[{name:"location_datasource",component:new class extends aw{fetchData(e,t,n){let r=this.url,i=r.split("?");return t?.tag&&(r=`${i[0]}?tag=${t.tag}&${i[1]}`),n&&(r=`${i[0]}/${n}?${i[1]}`),(0,s.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.results?e.results:e)}constructor(){super(`${s.restBaseUrl}/location?v=custom:(uuid,display)`)}}},{name:"drug_datasource",component:new ak},{name:"problem_datasource",component:new ak},{name:"select_concept_answers_datasource",component:new class extends aw{fetchSingleItem(e){return(0,s.openmrsFetch)(this.buildUrl(e)).then(({data:e})=>e)}fetchData(e,t){let n=this.buildUrl(t.referencedValue||t.concept);return(0,s.openmrsFetch)(n).then(({data:e})=>e.setMembers.length?e.setMembers:e.answers)}buildUrl(e){return this.url.replace(":conceptUuid",e)}constructor(){super(`${s.restBaseUrl}/concept/:conceptUuid?v=custom:(uuid,display,setMembers:(uuid,display),answers:(uuid,display))`)}}},{name:"provider_datasource",component:new class extends aw{async fetchData(e,t){let n=`${s.restBaseUrl}/provider?v=custom:(uuid,display)`,{data:r}=await (0,s.openmrsFetch)(e?`${n}&q=${e}`:n);return r?.results}async fetchSingleItem(e){let{data:t}=await (0,s.openmrsFetch)(`${s.restBaseUrl}/provider/${e}?v=custom:(uuid,display)`);return t}constructor(){super(null)}}},{name:"encounter_role_datasource",component:new class extends aw{async fetchData(e,t){let n=`${s.restBaseUrl}/encounterrole?v=custom:(uuid,display,name)`,{data:r}=await (0,s.openmrsFetch)(e?`${n}&q=${e}`:n);return r?.results}constructor(){super(null)}}}],aO=[{name:"ProgramEnrollmentSubmissionAction",load:()=>n.e("8720").then(n.bind(n,3696))},{name:"MarkPatientAsDeceasedAction",load:()=>n.e("5897").then(n.bind(n,8128))}];function aD(e,t){if(e&&"string"==typeof e[t]){let n=e[t].trim().toLowerCase();("true"===n||"false"===n)&&(e[t]="true"===n)}return e}let aC=[{name:"DefaultFormSchemaTransformer",component:{transform:(e,t)=>{var n;return aD(e,"readonly"),e.pages.forEach((t,n)=>{let r=t.label??"";t.id=`page-${r.replace(/\s/g,"")}-${n}`,aD(t,"readonly"),t.sections&&t.sections.forEach(n=>{var r,i;let o,a;r=n.questions,o=[],r?.forEach(e=>{if(o.push(e),"inlineDate"!==e.type&&(0,tE.H)(e.questionOptions?.showDate)){let t={id:`${e.id}_inline_date`,label:`Date for ${e.label}`,type:"inlineDate",questionOptions:{rendering:"date",isTransient:!0},validators:e.questionOptions.shownDateOptions?.validators,disabled:{disableWhenExpression:`isEmpty(${e.id})`},hide:e.questionOptions.shownDateOptions?.hide||e.hide,meta:{targetField:e.id,initialValue:{omrsObject:e.meta?.initialValue?.omrsObject?.obsDatetime}}};o.push(t)}}),n.questions=o,i=n.questions,a=[],i?.forEach(e=>{if(a.push(e),"obsComment"!==e.type&&(0,tE.H)(e.questionOptions?.showComment)){let t={id:`${e.id}_obs_comment`,label:`Comment for ${e.label}`,type:"obsComment",questionOptions:{rendering:"text",isTransient:!0},validators:e.questionOptions.shownCommentOptions?.validators,disabled:{disableWhenExpression:`isEmpty(${e.id})`},hide:e.questionOptions.shownCommentOptions?.hide||e.hide,meta:{targetField:e.id,initialValue:{omrsObject:e.meta?.initialValue?.omrsObject?.comment}}};a.push(t)}}),n.questions=a,aD(n,"readonly"),aD(n,"isExpanded"),n?.questions?.forEach((n,r)=>(function e(t,n,r){if("programState"===t.type){let e=r.meta??{};e.programs=e.programs?{...e.programs,hasProgramFields:!0}:{hasProgramFields:!0},r.meta=e}try{var i,o;i=t,aD(i,"readonly"),aD(i,"required"),aD(i,"unspecified"),aD(i.questionOptions,"disallowDecimals"),aD(i.questionOptions,"isSearchable"),aD(i.questionOptions,"isTransient"),aD(i.questionOptions,"enablePreviousValue"),aD(i.questionOptions,"allowMultiple"),i.meta||(i.meta={submission:null,initialValue:{omrsObject:null,refinedValue:null}}),o=t,!eL(o,"group")&&(o.validators=o.validators||[],0>o.validators.findIndex(e=>"form_field"===e.type)&&o.validators.push({type:"form_field"}),0>o.validators.findIndex(e=>"default_value"===e.type)&&o.validators.push({type:"default_value"})),function(e){switch(e.type){case"encounterProvider":e.questionOptions.rendering="encounter-provider";break;case"encounterLocation":e.questionOptions.rendering="encounter-location";break;case"encounterRole":e.questionOptions.rendering="encounter-role";break;case"encounterDatetime":e.questionOptions.rendering=eL(e,"ui-select-extended")?"date":e.questionOptions.rendering;break;case"diagnosis":var t=e;if("dataSource"in t.questionOptions&&"diagnoses"===t.questionOptions.dataSource||"diagnosis"===t.type){let e=t.questionOptions.datasource?.config;t.questionOptions.datasource={name:"problem_datasource",config:{...e,class:t.questionOptions.diagnosis?.conceptClasses??e?.class}},t.questionOptions.diagnosis?.conceptSet&&(t.questionOptions={...t.questionOptions,concept:t.questionOptions.diagnosis?.conceptSet,datasource:{name:"problem_datasource",config:{...e,concept:t.questionOptions.diagnosis.conceptSet,useSetMembersByConcept:!0}}}),t.questionOptions.isSearchable=!0,delete t.questionOptions.dataSource}}}(t),function(e){var t,n;switch(e.questionOptions.rendering){case"checkbox-searchable":case"multiCheckbox":t=e,"multiCheckbox"===t.questionOptions.rendering&&(t.questionOptions.rendering="checkbox-searchable",(0,tE.H)(t.inlineMultiCheckbox)&&(t.questionOptions.rendering="checkbox")),eL(t,"checkbox-searchable")&&(t.questionOptions.rendering="checkbox",t.questionOptions.isCheckboxSearchable=!0);break;case"numeric":e.questionOptions.rendering="number";break;case"select-concept-answers":(n=e).questionOptions.isSearchable=!0,n.questionOptions.datasource?.config||(n.questionOptions.datasource={name:"select_concept_answers_datasource",config:{concept:n.questionOptions.concept}});break;case"repeating":case"group":!function e(t){eL(t,"group")&&t.questions?.length&&t.questions.forEach(e),"testOrder"===t.type&&t.questionOptions.selectableOrders?.length&&(t.questionOptions.answers=t.questionOptions.selectableOrders||[],delete t.questionOptions.selectableOrders)}(e);break;case"date":e.datePickerFormat=e.datePickerFormat??"calendar";break;case"datetime":e.datePickerFormat=e.datePickerFormat??"both";break;case"workspace-launcher":case"markdown":e.type="control";break;case"drug":case"problem":e.questionOptions.isSearchable=!0}}(t),t.questions?.length&&("obsGroup"===t.type&&t.questions.length?t.questions.forEach(t=>e(t,n,r)):t.questions.forEach(t=>e(t,n,r))),t.meta.pageId=n.id}catch(e){console.error(e)}})(n,t,e))})}),t&&"object"==typeof t&&(n=e,Object.entries(t).forEach(([e,t])=>{n?.pages.forEach(n=>{n.sections.forEach(n=>{n.questions.forEach(n=>{n.id===e?n.questionOptions.defaultValue=t:Array.isArray(n?.questions)&&n.questions.length>0&&n.questions.forEach(n=>{n.id===e&&(n.questionOptions.defaultValue=t)})})})})})),e.meta?.programs&&function(e){if(e.meta.programs.isEnrollment||e.meta.programs.discontinuationDateQuestionId){let t={programUuid:e.meta.programs.uuid};e.meta.programs.isEnrollment?t.enrollmentDate="":t.completionDate=e.meta.programs.discontinuationDateQuestionId,e.postSubmissionActions=[{actionId:"ProgramEnrollmentSubmissionAction",enabled:"true",config:t}]}}(e),e}}}];function aF(e){if(e&&e.encounterProviders?.length){let t=e.encounterProviders.length-1;return e.encounterProviders[t].provider}return null}function aA(e){if(e&&e.encounterProviders?.length){let t=e.encounterProviders.length-1;return e.encounterProviders[t].encounterRole}return null}function aP(e,t){return oL(e,t)||!ej(e.meta.submission.newValue.obsDatetime)}let aT=[{type:"obs",component:oT},{type:"control",component:{getDisplayValue:(e,t)=>t,transformFieldValue:function(e,t,n){return null},getInitialValue:function(e,t,n){return null},getPreviousValue:function(e,t,n){return null},tearDown:function(){}}},{type:"obsGroup",component:oT},{type:"testOrder",component:{transformFieldValue:function(e,t,n){if(eq(e),"edit"===n.sessionMode&&e.meta.initialValue?.omrsObject){var r=t,i=e,o=n.currentProvider.uuid;let a=i.meta.initialValue?.omrsObject;if(r===a?.concept?.uuid)return null;let l={uuid:a?.uuid,voided:!0};return eR(i,oH(r,i,o),l),i.meta.submission.newValue||null}let a=oH(t,e,n.currentProvider.uuid);return eR(e,a,null),a},getInitialValue:function(e,t,n){let r=e.questionOptions.answers?.map(e=>e.concept)||[],i=t?.orders.filter(e=>!oB.includes(e.uuid)&&!e.voided).find(e=>r.includes(e.concept.uuid));return i?(e.meta={...e.meta||{},initialValue:{omrsObject:i,refinedValue:i.concept.uuid}},oB.push(i.uuid),i.concept.uuid):null},getPreviousValue:function(e,t,n){return null},getDisplayValue:(e,t)=>e.questionOptions.answers?.find(e=>e.concept==t)?.label||t,tearDown:function(){oB=[]}}},{type:"programState",component:{transformFieldValue:function(e,t,n){if(eq(e),e.meta?.initialValue?.omrsObject?.uuid===t||ej(t))return null;e.meta.submission.newValue={state:t,startDate:eP()().format()}},getInitialValue:function(e,t,n){let r=n.customDependencies.patientPrograms?.find(t=>t.program.uuid===e.questionOptions.programUuid);if(r?.states?.length>0){let t=r.states.filter(e=>!e.endDate).find(t=>t.state.programWorkflow?.uuid===e.questionOptions.workflowUuid)?.state;return e.meta={...e.meta||{},initialValue:{omrsObject:t}},t?.uuid}return null},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"encounterLocation",component:{transformFieldValue:function(e,t,n){eR(e,t,null)},getInitialValue:function(e,t,n){return t&&t.location?.uuid?t.location.uuid:n.location.uuid},getPreviousValue:function(e,t,n){let r=t??n.previousDomainObjectValue;return{value:r?.location?.uuid,display:r?.location?.name}},getDisplayValue:function(e,t){return t},tearDown:function(){}}},{type:"encounterProvider",component:{transformFieldValue:function(e,t,n){eR(e,t,null)},getInitialValue:function(e,t,n){let r=aF(t);return r?.uuid?r.uuid:n.currentProvider?.uuid},getPreviousValue:function(e,t,n){let r=aF(t??n.previousDomainObjectValue);return{value:r?.uuid,display:r?.name}},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"encounterRole",component:{transformFieldValue:function(e,t,n){eR(e,t,null)},getInitialValue:function(e,t,n){let r=t??n.domainObjectValue;return r?aA(r)?.uuid:n.customDependencies.defaultEncounterRole.uuid},getPreviousValue:function(e,t,n){let r=t??n.previousDomainObjectValue;if(r){let e=aA(r);return{value:e?.uuid,display:e?.name}}return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"obsComment",component:{transformFieldValue:function(e,t,n){let r=n.getFormField(e.meta.targetField),i=n.methods.getValues(r.id),o=r.meta.initialValue?.omrsObject;if(r.meta.submission?.newValue)ej(t)&&!aP(r,i)?r.meta.submission.newValue=null:r.meta.submission.newValue.comment=t;else if(!e$(r)&&o){if(ej(t)&&ej(o.comment))return null;let e=oI(r,i);r.meta.submission={newValue:{...e,comment:t}}}return null},getInitialValue:function(e,t,n){if(t??n.domainObjectValue){let t=e.id.split("_obs_comment")[0],r=n.formFields.find(e=>e.id===t);return r?.meta.initialValue.omrsObject?.comment}return null},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t},tearDown:function(){}}},{type:"encounterDatetime",component:{transformFieldValue:function(e,t,n){eR(e,t,null)},getInitialValue:function(e,t,n){return t?.encounterDatetime?new Date(t.encounterDatetime):n.sessionDate},getPreviousValue:function(e,t,n){if(t?.encounterDatetime){let n=new Date(t.encounterDatetime);return{value:n,display:this.getDisplayValue(e,n)}}return null},getDisplayValue:function(e,t){return(0,s.formatDate)(t)},tearDown:function(){}}},{type:"inlineDate",component:{transformFieldValue:function(e,t,n){let r=n.getFormField(e.meta.targetField),i=n.methods.getValues(r.id),o=t instanceof Date?(0,s.toOmrsIsoString)(t):t;if(r.meta.submission?.newValue)ej(o)&&!aP(r,i)?r.meta.submission.newValue=null:r.meta.submission.newValue.obsDatetime=o;else if(!e$(r)&&r.meta.initialValue?.omrsObject){if(ej(t)&&ej(r.meta.initialValue.omrsObject?.obsDatetime))return null;let e=oI(r,i);r.meta.submission={newValue:{...e,obsDatetime:o}}}},getInitialValue:function(e,t,n){if(t??n.domainObjectValue){let t=e.id.split("_inline_date")[0],r=n.formFields.find(e=>e.id===t),i=r?.meta.initialValue?.omrsObject;if(i?.obsDatetime)return(0,s.parseDate)(i.obsDatetime)}return null},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?(0,s.formatDate)(t):null},tearDown:function(){}}},{type:"patientIdentifier",component:{transformFieldValue:function(e,t,n){return(eq(e),e.meta.initialValue?.refinedValue===t||ej(t))?null:(e.meta.submission.newValue={identifier:t,identifierType:e.questionOptions.identifierType,uuid:e.meta.initialValue?.omrsObject?.id,location:n.location},e.meta.submission.newValue)},getInitialValue:function(e,t,n){let r=n.patient?.identifier?.find(t=>t.type?.coding[0]?.code===e.questionOptions.identifierType);return e.meta={...e.meta||{},initialValue:{omrsObject:r,refinedValue:r?.value}},r?.value},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"personAttribute",component:{transformFieldValue:function(e,t,n){return(eq(e),e.meta.initialValue?.refinedValue===t||ej(t))?null:(e.meta.submission.newValue={value:t,attributeType:e.questionOptions.attributeType,uuid:e.meta.initialValue?.omrsObject?.uuid},e.meta.submission.newValue)},getInitialValue:function(e,t,n){let r=n.patient?.extension?.find(t=>t.url===`http://fhir.openmrs.org/ext/person-attribute/${e.questionOptions.attributeType}`);return e.meta={...e.meta,initialValue:{omrsObject:r,refinedValue:r?.valueString||r?.valueReference?.reference}},e.meta.initialValue.refinedValue},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"diagnosis",component:{transformFieldValue:function(e,t,n){let r,i,o;if(eq(e),e.meta.initialValue?.omrsObject&&ej(t))return eR(e,void 0,{uuid:e.meta.initialValue.omrsObject.uuid,voided:!0});if(!ej(t)){var a,l,s,u,c;let r=e.meta.initialValue?.omrsObject;if(a=r,l=t,!ej(a)&&a.value!==l){return eR(e,(s=t,u=e,c=r,{patient:n.patient.id,condition:null,diagnosis:{coded:s},certainty:(0,tE.H)(u.questionOptions?.diagnosis?.isConfirmed)?"CONFIRMED":"PROVISIONAL",rank:u.questionOptions.diagnosis?.rank??1,formFieldPath:`rfe-forms-${u.id}`,formFieldNamespace:"rfe-forms",uuid:c.uuid}),void 0)}}let d=(r=t,i=e,o=n.patient.id,r?{patient:o,condition:null,diagnosis:{coded:r},certainty:(0,tE.H)(i.questionOptions?.diagnosis?.isConfirmed)?"CONFIRMED":"PROVISIONAL",rank:i.questionOptions.diagnosis?.rank??1,formFieldPath:`rfe-forms-${i.id}`,formFieldNamespace:"rfe-forms"}:null);return eR(e,d,null),d},getInitialValue:function(e,t,n){let r=(t??n.domainObjectValue).diagnoses.find(t=>t.formFieldPath===`rfe-forms-${e.id}`);return r?(e.meta={...e.meta||{},initialValue:{omrsObject:r,refinedValue:r.diagnosis?.coded.uuid}},oz.includes(r.diagnosis?.coded?.uuid)||oz.push(r.diagnosis?.coded?.uuid),r.diagnosis?.coded.uuid):null},getPreviousValue:function(e,t,n){return null},getDisplayValue:(e,t)=>e.questionOptions.answers?.find(e=>e.concept==t)?.label||t,tearDown:function(){oz=[]}}}],aV={},aM={},aj={},aI={},aN={},aL={};function aq(e,t){aW().expressionHelpers[e]=t}async function aR(e){if(aM[e])return aM[e];let t=ab.find(t=>t.name===e||t?.alias===e)?.component;if(!t){let n=await aW().controls.find(t=>t.name===e||t?.alias===e)?.load?.();t=n?.default}return aM[e]=t,t}async function a$(e){if(aj[e])return aj[e];let t=aT.find(t=>t.type===e)?.component;if(!t){let n=await aW().fieldValueAdapters.find(t=>t.type===e)?.load?.();t=n?.default}return aj[e]=t,t}async function aB(){let e=[];if(Object.keys(aL).length)return Object.values(aL);let t=aW().formSchemaTransformers||[];return e.push(...(await Promise.all(t.map(async e=>{let t=await e.load?.();return t?.default}))).filter(e=>void 0!==e)),e.push(...aC.map(e=>e.component)),e.forEach(e=>{aL[aC.find(t=>t.component===e).name]=e}),e}async function aH(e){let t=aI[e];if(t)return t;let n=aO.find(t=>t.name===e);if(n){let t=n.load,r=await t();return aI[e]=r.default,r.default}let r=aW().postSubmissionActions.find(t=>t.name===e);if(r){let t=r.load,n=await t();return aI[e]=n.default,n.default}return console.error(`No loader found for PostSubmissionAction registration of id: ${e}`),null}async function az(e){if(aV[e])return aV[e];let t=a_.find(t=>t.name===e)?.component;if(!t){let n=await aW().fieldValidators.find(t=>t.name===e)?.load?.();t=n?.default}return aV[e]=t,t}async function aU(e){if(aN[e])return aN[e];let t=aS.find(t=>t.name===e)?.component;if(!t){let n=oS(e);if(n)t=aS.find(e=>e.name===n.datasource.name)?.component;else{let n=await aW().dataSources.find(t=>t.name===e)?.load?.();if(!n)throw Error("Datasource not found");t=n.default}}return aN[e]=t,t}function aW(){return(0,s.getGlobalStore)(u.RA,{controls:[],postSubmissionActions:[],expressionHelpers:{},fieldValidators:[],fieldValueAdapters:[],dataSources:[],formSchemaTransformers:[]}).getState()}function aY(e,t,n,r,i){var o,a;let[l,s]=(0,c.useState)(null),[u,d]=(0,c.useState)((o=e,a=t,o||a?o&&a?Error("InvalidArgumentsErr: Both formUuid and formJson cannot be provided at the same time."):void 0:Error("InvalidArgumentsErr: Neither formUuid nor formJson was provided")));return(0,c.useEffect)(()=>{let o=new AbortController;return aJ(e,t,r,i).then(e=>{var t={...e,encounter:n};if(t?.translations){let e=window.i18next.language;window.i18next.addResourceBundle(e,oK.L,t.translations,!0,!0)}s(t)}).catch(e=>{"AbortError"!==e.name&&(console.error(e),d(Error("Error loading form JSON: "+e.message)))}),()=>{o.abort()}},[r,e,t,n]),{formJson:l,isLoading:!l&&!u,formError:u}}async function aJ(e,t,n,r){var i,o,s,u,c,d,f;let p,m,h=await (0,e5.fetchOpenMRSForm)(e),g=await (0,e5.fetchClobData)(h),y=await aB(),v=g?{...g,uuid:h.uuid}:"string"==typeof(i=t)?JSON.parse(i):JSON.parse(JSON.stringify(i)),b=v.pages.filter(e=>e.isSubform&&!e.subform.form&&e.subform?.name).map(e=>e.subform?.name);o=v,(await aZ(b,n)).forEach(e=>{let t=o.pages.find(t=>t.subform?.name===e.name);t&&(t.subform.form=e)});let _=(s=v,(p=s?.referencedForms)||[]),w=await aG(_),x=_.reduce((e,t)=>(e[t.formName]=t.alias,e),{});return c=v,d=(u=w,m=new Map,u.forEach(e=>{m.set(e.name,e)}),m),f=x,d.forEach((e,t)=>{c.pages.forEach(n=>{n.sections&&n.sections.forEach(n=>{if(n.reference&&(n.reference.form===t||n.reference.form===f[t])){let t=function(e,t){let n,r=t.pages.filter(t=>t.label===e.reference.page);if(r.length>0){let t=r[0].sections.filter(t=>t.label===e.reference.section);t.length>0&&(n=t[0])}var i=n,o=e.reference;if(o?.excludeQuestions){let e=o.excludeQuestions;i.questions=i.questions.filter(t=>!e.includes(t.id))}return i}(n,e);Object.assign(n,t)}})})}),function e(t,n=[],r,i){var o;return function(t,n){for(let r=t.pages.length-1;r>=0;r--){let i=t.pages[r];(0,tE.H)(i.isSubform)&&!(0,tE.H)(i.isHidden)&&i.subform?.form?.encounterType===t.encounterType&&(i.subform.form.pages.filter(e=>!(0,tE.H)(e.isSubform)),t.pages.splice(r,1,...e(i.subform.form,[],n).pages))}}(t,r),n.reduce((e,t)=>t.transform(e,i),t),(o=t).encounter&&"string"==typeof o.encounter&&!o.encounterType&&(o.encounterType=o.encounter,delete o.encounter),function e(t,n,r){if(!t)return n;let i=JSON.parse(JSON.stringify(n));return i.defaultPage=i.availableIntents?.find(e=>e.intent===(t?.intent||t))?.defaultPage,i.markdown&&l(i.markdown,t),i.pages=i.pages||[],i.pages.forEach(n=>{if(n.isSubform&&n.subform?.form){let r=[],i=n.subform.behaviours?.find(e=>e.intent==t?.intent||t);(i?.readonly!==void 0||i?.readonly!=null)&&r.push({name:"readonly",type:"field",value:i?.readonly}),n.subform.form=e(i?.subform_intent||"*",n.subform?.form,r)}let i=n.behaviours?.find(e=>e.intent===(t?.intent||t));if(i)n.hide=i.hide??n.hide,n.readonly=i.readonly??n.readonly;else{let e=n.behaviours?.find(e=>"*"===e.intent);e&&(n.hide=e.hide??n.hide,n.readonly=e.readonly??n.readonly)}n.markdown&&l(n.markdown,t),n.sections=n.sections||[],n.sections.forEach(e=>{let n=e.behaviours?.find(e=>e.intent===t?.intent||t);if(n)e.hide=n.hide??e.hide;else{let t=e.behaviours?.find(e=>"*"===e.intent);e.hide=t?.hide??e.hide}e.markdown&&l(e.markdown,t),e.questions=e.questions||[],e.questions.forEach(e=>{e.behaviours&&(a(e,t?.intent||t),r?.filter(e=>"all"==e.type||"field"==e.type)?.forEach(t=>{e[t.name]=t.value})),e.questions&&e.questions.length&&e.questions.forEach(e=>{a(e,t?.intent||t),r?.filter(e=>"all"==e.type||"field"==e.type)?.forEach(t=>{e[t.name]=t.value})})})})}),i}(r,t)}(v,y,n,r)}async function aZ(e,t){return Promise.all(e.map(e=>aJ(e,null,t)))}async function aG(e){return Promise.all(e.map(e=>aJ(e.formName,null,null)))}var aQ=function(e,t){return(aQ=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function aK(e,t){function n(){this.constructor=e}aQ(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function aX(e){return"function"==typeof e}var a0=!1,a1={Promise:void 0,set useDeprecatedSynchronousErrorHandling(value){value&&Error().stack,a0=value},get useDeprecatedSynchronousErrorHandling(){return a0}};function a2(e){setTimeout(function(){throw e},0)}var a4={closed:!0,next:function(e){},error:function(e){if(a1.useDeprecatedSynchronousErrorHandling)throw e;a2(e)},complete:function(){}},a3=Array.isArray||function(e){return e&&"number"==typeof e.length},a5=function(){function e(e){return Error.call(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=e,this}return e.prototype=Object.create(Error.prototype),e}(),a6=function(){var e;function t(e){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,e&&(this._ctorUnsubscribe=!0,this._unsubscribe=e)}return t.prototype.unsubscribe=function(){if(!this.closed){var e,n=this._parentOrParents,r=this._ctorUnsubscribe,i=this._unsubscribe,o=this._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,n instanceof t)n.remove(this);else if(null!==n)for(var a=0;a<n.length;++a)n[a].remove(this);if(aX(i)){r&&(this._unsubscribe=void 0);try{i.call(this)}catch(t){e=t instanceof a5?a9(t.errors):[t]}}if(a3(o))for(var a=-1,l=o.length;++a<l;){var s=o[a];if(null!==s&&"object"==typeof s)try{s.unsubscribe()}catch(t){e=e||[],t instanceof a5?e=e.concat(a9(t.errors)):e.push(t)}}if(e)throw new a5(e)}},t.prototype.add=function(e){var n=e;if(!e)return t.EMPTY;switch(typeof e){case"function":n=new t(e);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof t)){var r=n;(n=new t)._subscriptions=[r]}break;default:throw Error("unrecognized teardown "+e+" added to Subscription.")}var i=n._parentOrParents;if(null===i)n._parentOrParents=this;else if(i instanceof t){if(i===this)return n;n._parentOrParents=[i,this]}else{if(-1!==i.indexOf(this))return n;i.push(this)}var o=this._subscriptions;return null===o?this._subscriptions=[n]:o.push(n),n},t.prototype.remove=function(e){var t=this._subscriptions;if(t){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}},(e=new t).closed=!0,t.EMPTY=e,t}();function a9(e){return e.reduce(function(e,t){return e.concat(t instanceof a5?t.errors:t)},[])}var a7="function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random(),a8=function(e){function t(n,r,i){var o=e.call(this)||this;switch(o.syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=a4;break;case 1:if(!n){o.destination=a4;break}if("object"==typeof n){n instanceof t?(o.syncErrorThrowable=n.syncErrorThrowable,o.destination=n,n.add(o)):(o.syncErrorThrowable=!0,o.destination=new le(o,n));break}default:o.syncErrorThrowable=!0,o.destination=new le(o,n,r,i)}return o}return aK(t,e),t.prototype[a7]=function(){return this},t.create=function(e,n,r){var i=new t(e,n,r);return i.syncErrorThrowable=!1,i},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this))},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){this.destination.error(e),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var e=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=e,this},t}(a6),le=function(e){function t(t,n,r,i){var o,a=e.call(this)||this;a._parentSubscriber=t;var l=a;return aX(n)?o=n:n&&(o=n.next,r=n.error,i=n.complete,n!==a4&&(aX((l=Object.create(n)).unsubscribe)&&a.add(l.unsubscribe.bind(l)),l.unsubscribe=a.unsubscribe.bind(a))),a._context=l,a._next=o,a._error=r,a._complete=i,a}return aK(t,e),t.prototype.next=function(e){if(!this.isStopped&&this._next){var t=this._parentSubscriber;a1.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,e)&&this.unsubscribe():this.__tryOrUnsub(this._next,e)}},t.prototype.error=function(e){if(!this.isStopped){var t=this._parentSubscriber,n=a1.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?this.__tryOrSetError(t,this._error,e):this.__tryOrUnsub(this._error,e),this.unsubscribe();else if(t.syncErrorThrowable)n?(t.syncErrorValue=e,t.syncErrorThrown=!0):a2(e),this.unsubscribe();else{if(this.unsubscribe(),n)throw e;a2(e)}}},t.prototype.complete=function(){var e=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return e._complete.call(e._context)};a1.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,n):this.__tryOrUnsub(n),this.unsubscribe()}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(e,t){try{e.call(this._context,t)}catch(e){if(this.unsubscribe(),a1.useDeprecatedSynchronousErrorHandling)throw e;a2(e)}},t.prototype.__tryOrSetError=function(e,t,n){if(!a1.useDeprecatedSynchronousErrorHandling)throw Error("bad call");try{t.call(this._context,n)}catch(t){if(a1.useDeprecatedSynchronousErrorHandling)return e.syncErrorValue=t,e.syncErrorThrown=!0,!0;return a2(t),!0}return!1},t.prototype._unsubscribe=function(){var e=this._parentSubscriber;this._context=null,this._parentSubscriber=null,e.unsubscribe()},t}(a8),lt="function"==typeof Symbol&&Symbol.observable||"@@observable",ln=function(){function e(e){this._isScalar=!1,e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this.operator,i=function(e,t,n){if(e){if(e instanceof a8)return e;if(e[a7])return e[a7]()}return e||t||n?new a8(e,t,n):new a8(a4)}(e,t,n);if(r?i.add(r.call(i,this.source)):i.add(this.source||a1.useDeprecatedSynchronousErrorHandling&&!i.syncErrorThrowable?this._subscribe(i):this._trySubscribe(i)),a1.useDeprecatedSynchronousErrorHandling&&i.syncErrorThrowable&&(i.syncErrorThrowable=!1,i.syncErrorThrown))throw i.syncErrorValue;return i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){a1.useDeprecatedSynchronousErrorHandling&&(e.syncErrorThrown=!0,e.syncErrorValue=t),function(e){for(;e;){var t=e,n=t.closed,r=t.destination,i=t.isStopped;if(n||i)return!1;e=r&&r instanceof a8?r:null}return!0}(e)?e.error(t):console.warn(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=lr(t))(function(t,r){var i;i=n.subscribe(function(t){try{e(t)}catch(e){r(e),i&&i.unsubscribe()}},r,t)})},e.prototype._subscribe=function(e){var t=this.source;return t&&t.subscribe(e)},e.prototype[lt]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 0===e.length?this:(0===e.length?function(e){return e}:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=lr(e))(function(e,n){var r;t.subscribe(function(e){return r=e},function(e){return n(e)},function(){return e(r)})})},e.create=function(t){return new e(t)},e}();function lr(e){if(e||(e=a1.Promise||Promise),!e)throw Error("no Promise impl found");return e}var li=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),lo=function(e){function t(t,n){var r=e.call(this)||this;return r.subject=t,r.subscriber=n,r.closed=!1,r}return aK(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var n=t.indexOf(this.subscriber);-1!==n&&t.splice(n,1)}}},t}(a6),la=function(e){function t(t){var n=e.call(this,t)||this;return n.destination=t,n}return aK(t,e),t}(a8),ll=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return aK(t,e),t.prototype[a7]=function(){return new la(this)},t.prototype.lift=function(e){var t=new ls(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new li;if(!this.isStopped)for(var t=this.observers,n=t.length,r=t.slice(),i=0;i<n;i++)r[i].next(e)},t.prototype.error=function(e){if(this.closed)throw new li;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,n=t.length,r=t.slice(),i=0;i<n;i++)r[i].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new li;this.isStopped=!0;for(var e=this.observers,t=e.length,n=e.slice(),r=0;r<t;r++)n[r].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(!this.closed)return e.prototype._trySubscribe.call(this,t);throw new li},t.prototype._subscribe=function(e){if(this.closed)throw new li;return this.hasError?(e.error(this.thrownError),a6.EMPTY):this.isStopped?(e.complete(),a6.EMPTY):(this.observers.push(e),new lo(this,e))},t.prototype.asObservable=function(){var e=new ln;return e.source=this,e},t.create=function(e,t){return new ls(e,t)},t}(ln),ls=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return aK(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):a6.EMPTY},t}(ll),lu=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return aK(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return n&&!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(!this.closed)return this._value;throw new li},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(ll);function lc(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let ld=new class{setEvaluatedPagesVisibility(e){this.evaluatedPagesVisibilitySubject.next(e)}updateScrollablePages(e){this.scrollablePagesSubject.next(e)}updatePagesWithErrors(e){this.pagesWithErrorsSubject.next(new Set(e))}addActivePage(e){let t=this.activePagesSubject.value;t.add(e),this.activePagesSubject.next(t)}removeInactivePage(e){let t=this.activePagesSubject.value;t.delete(e),this.activePagesSubject.next(t)}getActivePagesObservable(){return this.activePagesSubject.asObservable()}getScrollablePagesObservable(){return this.scrollablePagesSubject.asObservable()}getPagesWithErrorsObservable(){return this.pagesWithErrorsSubject.asObservable()}getEvaluatedPagesVisibilityObservable(){return this.evaluatedPagesVisibilitySubject.asObservable()}clear(){this.scrollablePagesSubject.next([]),this.pagesWithErrorsSubject.next(new Set),this.activePagesSubject.next(new Set),this.evaluatedPagesVisibilitySubject.next(!1)}constructor(){lc(this,"scrollablePagesSubject",new lu([])),lc(this,"pagesWithErrorsSubject",new lu(new Set)),lc(this,"activePagesSubject",new lu(new Set)),lc(this,"evaluatedPagesVisibilitySubject",new lu(null))}},lf=new Set,lp=()=>{let[e,t]=(0,c.useState)({pages:[],pagesWithErrors:[],activePages:[],evaluatedPagesVisibility:!1,hasMultiplePages:null});return(0,c.useEffect)(()=>{let e=[ld.getScrollablePagesObservable().subscribe(e=>{t(t=>({...t,pages:e,hasMultiplePages:e.length>1}))}),ld.getPagesWithErrorsObservable().subscribe(e=>{t(t=>({...t,pagesWithErrors:Array.from(e)}))}),ld.getActivePagesObservable().subscribe(e=>{t(t=>({...t,activePages:Array.from(e)}))}),ld.getEvaluatedPagesVisibilityObservable().subscribe(e=>{t(t=>({...t,evaluatedPagesVisibility:e}))})];return()=>e.forEach(e=>e.unsubscribe())},[]),e},lm={female:"F",male:"M",other:"O",unknown:"U"},lh=({section:e})=>{let{formFieldAdapters:t}=tO(),n=(0,c.useMemo)(()=>e.label.replace(/\s/g,""),[e.label]);return d().createElement("div",{className:"-esm-form-engine__section-renderer__section___OpnOG"},e.questions.map(e=>t[e.type]?d().createElement("div",{key:`${n}-${e.id}`,className:"-esm-form-engine__section-renderer__sectionBody___lI63X"},d().createElement(tT,{key:e.id,fieldId:e.id,valueAdapter:t[e.type]})):null))};var lg=n(9086),ly=!!("u">typeof window&&window.document&&window.document.createElement),lv=void 0;function lb(e){e.handlers===e.nextHandlers&&(e.nextHandlers=e.handlers.slice())}function l_(e){this.target=e,this.events={}}l_.prototype.getEventHandlers=function(e,t){var n=String(e)+" "+String(t?!0===t?100:(0|t.capture)+(t.passive<<1)+(t.once<<2):0);return this.events[n]||(this.events[n]={handlers:[],handleEvent:void 0},this.events[n].nextHandlers=this.events[n].handlers),this.events[n]},l_.prototype.handleEvent=function(e,t,n){var r=this.getEventHandlers(e,t);r.handlers=r.nextHandlers,r.handlers.forEach(function(e){e&&e(n)})},l_.prototype.add=function(e,t,n){var r=this,i=this.getEventHandlers(e,n);lb(i),0===i.nextHandlers.length&&(i.handleEvent=this.handleEvent.bind(this,e,n),this.target.addEventListener(e,i.handleEvent,n)),i.nextHandlers.push(t);var o=!0;return function(){if(o){o=!1,lb(i);var a=i.nextHandlers.indexOf(t);i.nextHandlers.splice(a,1),0===i.nextHandlers.length&&(r.target&&r.target.removeEventListener(e,i.handleEvent,n),i.handleEvent=void 0)}}};var lw="__consolidated_events_handlers__";function lx(e,t,n,r){e[lw]||(e[lw]=new l_(e));var i=function(e){if(e)return(void 0===lv&&(lv=function(){if(!ly||!window.addEventListener||!window.removeEventListener||!Object.defineProperty)return!1;var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}}),n=function(){};window.addEventListener("testPassiveEventSupport",n,t),window.removeEventListener("testPassiveEventSupport",n,t)}catch(e){}return e}()),lv)?e:!!e.capture}(r);return e[lw].add(t,n,i)}var lE=n(524);function lk(e,t){var n=!isNaN(parseFloat(e))&&isFinite(e)?parseFloat(e):"px"===e.slice(-2)?parseFloat(e.slice(0,-2)):void 0;if("number"==typeof n)return n;var r=function(e){if("%"===e.slice(-1))return parseFloat(e.slice(0,-1))/100}(e);if("number"==typeof r)return r*t}var lS="above",lO="inside",lD="below",lC="invisible";function lF(e){return"string"==typeof e.type}var lA=[];function lP(e){lA.push(e),r||(r=setTimeout(function(){var e;for(r=null;e=lA.shift();)e()},0));var t=!0;return function(){if(t){t=!1;var n=lA.indexOf(e);-1!==n&&(lA.splice(n,1),!lA.length&&r&&(clearTimeout(r),r=null))}}}var lT="u">typeof window,lV=function(e){function t(t){var n;return(n=e.call(this,t)||this).refElement=function(e){n._ref=e},n}(0,lg.A)(t,e);var r=t.prototype;return r.componentDidMount=function(){var e=this;lT&&(this.cancelOnNextTick=lP(function(){e.cancelOnNextTick=null;var t=e.props,n=t.children;t.debug;var r=e._ref;if(n&&!lF(n)&&!r)throw Error("<Waypoint> needs a DOM element to compute boundaries. The child you passed is neither a DOM element (e.g. <div>) nor does it use the innerRef prop.\n\nSee https://goo.gl/LrBNgw for more info.");e._handleScroll=e._handleScroll.bind(e),e.scrollableAncestor=e._findScrollableAncestor(),e.scrollEventListenerUnsubscribe=lx(e.scrollableAncestor,"scroll",e._handleScroll,{passive:!0}),e.resizeEventListenerUnsubscribe=lx(window,"resize",e._handleScroll,{passive:!0}),e._handleScroll(null)}))},r.componentDidUpdate=function(){var e=this;lT&&this.scrollableAncestor&&(this.cancelOnNextTick||(this.cancelOnNextTick=lP(function(){e.cancelOnNextTick=null,e._handleScroll(null)})))},r.componentWillUnmount=function(){lT&&(this.scrollEventListenerUnsubscribe&&this.scrollEventListenerUnsubscribe(),this.resizeEventListenerUnsubscribe&&this.resizeEventListenerUnsubscribe(),this.cancelOnNextTick&&this.cancelOnNextTick())},r._findScrollableAncestor=function(){var e=this.props,t=e.horizontal,r=e.scrollableAncestor;if(r)return"window"===r?n.g.window:r;for(var i=this._ref;i.parentNode&&(i=i.parentNode)!==document.body;){var o=window.getComputedStyle(i),a=(t?o.getPropertyValue("overflow-x"):o.getPropertyValue("overflow-y"))||o.getPropertyValue("overflow");if("auto"===a||"scroll"===a||"overlay"===a)return i}return window},r._handleScroll=function(e){if(this._ref){var t=this._getBounds(),n=t.viewportBottom-t.viewportTop==0?lC:t.viewportTop<=t.waypointTop&&t.waypointTop<=t.viewportBottom||t.viewportTop<=t.waypointBottom&&t.waypointBottom<=t.viewportBottom||t.waypointTop<=t.viewportTop&&t.viewportBottom<=t.waypointBottom?lO:t.viewportBottom<t.waypointTop?lD:t.waypointTop<t.viewportTop?lS:lC,r=this._previousPosition,i=this.props,o=(i.debug,i.onPositionChange),a=i.onEnter,l=i.onLeave,s=i.fireOnRapidScroll;if(this._previousPosition=n,r!==n){var u={currentPosition:n,previousPosition:r,event:e,waypointTop:t.waypointTop,waypointBottom:t.waypointBottom,viewportTop:t.viewportTop,viewportBottom:t.viewportBottom};o.call(this,u),n===lO?a.call(this,u):r===lO&&l.call(this,u);var c=r===lD&&n===lS,d=r===lS&&n===lD;s&&(c||d)&&(a.call(this,{currentPosition:lO,previousPosition:r,event:e,waypointTop:t.waypointTop,waypointBottom:t.waypointBottom,viewportTop:t.viewportTop,viewportBottom:t.viewportBottom}),l.call(this,{currentPosition:n,previousPosition:lO,event:e,waypointTop:t.waypointTop,waypointBottom:t.waypointBottom,viewportTop:t.viewportTop,viewportBottom:t.viewportBottom}))}}},r._getBounds=function(){var e,t,n=this.props,r=n.horizontal;n.debug;var i=this._ref.getBoundingClientRect(),o=i.left,a=i.top,l=i.right,s=i.bottom;this.scrollableAncestor===window?(e=r?window.innerWidth:window.innerHeight,t=0):(e=r?this.scrollableAncestor.offsetWidth:this.scrollableAncestor.offsetHeight,t=r?this.scrollableAncestor.getBoundingClientRect().left:this.scrollableAncestor.getBoundingClientRect().top);var u=this.props,c=u.bottomOffset,d=lk(u.topOffset,e),f=lk(c,e),p=t+e;return{waypointTop:r?o:a,waypointBottom:r?l:s,viewportTop:t+d,viewportBottom:p-f}},r.render=function(){var e=this,t=this.props.children;return t?lF(t)||(0,lE.isForwardRef)(t)?d().cloneElement(t,{ref:function(n){e.refElement(n),t.ref&&("function"==typeof t.ref?t.ref(n):t.ref.current=n)}}):d().cloneElement(t,{innerRef:this.refElement}):d().createElement("span",{ref:this.refElement,style:{fontSize:0}})},t}(d().PureComponent);lV.above=lS,lV.below=lD,lV.inside=lO,lV.invisible=lC,lV.defaultProps={debug:!1,scrollableAncestor:void 0,children:void 0,topOffset:"0px",bottomOffset:"0px",horizontal:!1,onEnter:function(){},onLeave:function(){},onPositionChange:function(){},fireOnRapidScroll:!0},lV.displayName="Waypoint";let lM={pageContent:"-esm-form-engine__page-renderer__pageContent___ZYB9J",pageHeader:"-esm-form-engine__page-renderer__pageHeader___XuC5+",pageTitle:"-esm-form-engine__page-renderer__pageTitle___AbChc",collapseIcon:"-esm-form-engine__page-renderer__collapseIcon___eEY4D",sectionContainer:"-esm-form-engine__page-renderer__sectionContainer___nfi1A",accordionContainer:"-esm-form-engine__page-renderer__accordionContainer___M2pxs",firstSection:"-esm-form-engine__page-renderer__firstSection___IQTsd",lastSection:"-esm-form-engine__page-renderer__lastSection___sooKZ",formSection:"-esm-form-engine__page-renderer__formSection___PGg8p",hiddenAccordion:"-esm-form-engine__page-renderer__hiddenAccordion___-29II"};function lj({section:e,sectionIndex:t,visibleSections:n,isFormExpanded:r}){let{t:i}=(0,eO.useTranslation)(),[o,a]=(0,c.useState)(r);return(0,c.useEffect)(()=>{a(r)},[r]),d().createElement(g.AccordionItem,{title:i(e.label),open:o,className:p()(lM.sectionContainer,{[lM.firstSection]:0===t,[lM.lastSection]:t===n.length-1})},d().createElement("div",{className:lM.formSection},d().createElement(lh,{section:e})))}let lI=function({page:e,isFormExpanded:t}){let{t:n}=(0,eO.useTranslation)(),[r,i]=(0,c.useState)(!1),o=(0,c.useMemo)(()=>e.sections.filter(e=>{let t=e.questions.some(e=>!(0,tE.H)(e.isHidden));return!(0,tE.H)(e.isHidden)&&t}),[e.sections]);return(0,c.useEffect)(()=>(i(!t),()=>{ld.removeInactivePage(e.id)}),[t]),d().createElement("div",null,d().createElement(lV,{key:e.id,onEnter:()=>ld.addActivePage(e.id),onLeave:()=>ld.removeInactivePage(e.id),topOffset:"40%",bottomOffset:"40%"},d().createElement("div",{id:e.id,className:lM.pageContent},d().createElement("div",{className:lM.pageHeader,onClick:()=>i(!r)},d().createElement("p",{className:lM.pageTitle},n(e.label),d().createElement("span",{className:lM.collapseIconWrapper},r?d().createElement(s.ChevronDownIcon,{className:lM.collapseIcon,"aria-label":"Expand"}):d().createElement(s.ChevronUpIcon,{className:lM.collapseIcon,"aria-label":"Collapse"})))),d().createElement("div",{className:p()({[lM.hiddenAccordion]:r,[lM.accordionContainer]:!r})},d().createElement(g.Accordion,null,o.map((e,n)=>d().createElement(lj,{key:`section-${e.label}`,section:e,sectionIndex:n,visibleSections:o,isFormExpanded:t})))))))},lN={formFields:[],invalidFields:[],formJson:null,deletedFields:[]},lL=(e,t)=>{switch(t.type){case"SET_FORM_FIELDS":return{...e,formFields:t.value};case"ADD_FORM_FIELD":return{...e,formFields:[...e.formFields,t.value]};case"UPDATE_FORM_FIELD":return{...e,formFields:e.formFields.map(e=>e.id===t.value.id?t.value:e)};case"REMOVE_FORM_FIELD":return{...e,formFields:e.formFields.filter(e=>e.id!==t.value)};case"SET_INVALID_FIELDS":return{...e,invalidFields:t.value};case"ADD_INVALID_FIELD":return{...e,invalidFields:[...e.invalidFields,t.value]};case"REMOVE_INVALID_FIELD":return{...e,invalidFields:e.invalidFields.filter(e=>e.id!==t.value)};case"CLEAR_INVALID_FIELDS":return{...e,invalidFields:[]};case"SET_FORM_JSON":return{...e,formJson:t.value};case"SET_DELETED_FIELDS":return{...e,deletedFields:t.value};default:return e}},lq=({processorContext:e,initialValues:t,isSubForm:n,setIsLoadingFormDependencies:r})=>{let i,o,a,l,s,u,f,p,{evaluatedFields:m,evaluatedFormJson:h,evaluatedPagesVisibility:g}=((e,t)=>{let{formFields:n,patient:r,sessionMode:i,visit:o}=t,[a,l]=(0,c.useState)(t.formJson),[s,u]=(0,c.useState)(!1),d=(0,c.useMemo)(()=>n?.map(t=>{var a;let l,s,u={value:t,type:"field"},c={patient:r,mode:i,visit:o};if(t.hide?.hideWhenExpression){let r=tu(t.hide.hideWhenExpression,u,n,e,c);t.isHidden=r,Array.isArray(t.questions)&&t.questions.forEach(e=>{e.isHidden=r})}else t.isHidden=!1;"object"==typeof t.required&&"conditionalRequired"===t.required.type?t.isRequired=th(t,n,e):t.isRequired=(0,tE.H)(t.required),"object"==typeof t.disabled&&t.disabled.disableWhenExpression?t.isDisabled=tu(t.disabled.disableWhenExpression,u,n,e,c):t.isDisabled=(0,tE.H)(t.disabled),t.validators?.some(e=>"conditionalAnswered"===e.type)&&(l=t.validators.find(e=>"conditionalAnswered"===e.type).referenceQuestionId,(s=n.find(e=>e.id==l))&&(s.fieldDependents||(s.fieldDependents=new Set)).add(t.id)),t.questionOptions.answers?.filter(e=>!ej(e.hide?.hideWhenExpression)).forEach(t=>{t.isHidden=tu(t.hide.hideWhenExpression,u,n,e,c)}),t.questionOptions.answers?.filter(e=>!ej(e.disable?.disableWhenExpression)).forEach(t=>{t.disable.isDisabled=tu(t.disable?.disableWhenExpression,u,n,e,c)}),"string"==typeof t.readonly&&"true"!==(a=t.readonly)&&"false"!==a&&(t.meta.readonlyExpression=t.readonly,t.readonly=tu(t.readonly,u,n,e,c));let d=t.questionOptions.repeatOptions?.limitExpression;return"repeating"!==t.questionOptions.rendering||ej(d)||(t.questionOptions.repeatOptions.limit=tu(d,u,n,e,c)),t}),[e,n,r,i]);return(0,c.useEffect)(()=>{t.formJson?.pages?.forEach(t=>{t.hide?tg({value:t,type:"page"},n,e,i,r,tu,null):t.isHidden=!1,t?.sections?.forEach(t=>{t.hide?tg({value:t,type:"section"},n,e,i,r,tu,null):t.isHidden=!1})}),l(eU(t.formJson)),u(!0)},[t.formJson,n]),{evaluatedFormJson:a,evaluatedFields:d,evaluatedPagesVisibility:s}})(t,e),{registerForm:D,setIsFormDirty:V,workspaceLayout:M,isFormExpanded:j}=ao(),I=function(e={}){let t=d().useRef(void 0),n=d().useRef(void 0),[r,i]=d().useState({isDirty:!1,isValidating:!1,isLoading:F(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:F(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!F(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{let{formControl:n,...i}=function(e={}){let t,n={...eS,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:F(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1},i={},o=(b(n.defaultValues)||b(n.values))&&k(n.defaultValues||n.values)||{},a=n.shouldUnregister?{}:k(o),l={action:!1,mount:!1,watch:!1,keepIsValid:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u=0,c={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={...c},f={...d},p={array:X(),state:X()},m="all"===n.criteriaMode,h=async e=>{if(!l.keepIsValid&&!n.disabled&&(d.isValid||f.isValid||e)){let e;n.resolver?(e=ee((await M()).errors),g()):e=await N({fields:i,onlyCheckValid:!0,eventType:"valid"}),e!==r.isValid&&p.state.next({isValid:e})}},g=(e,t)=>{!n.disabled&&(d.isValidating||d.validatingFields||f.isValidating||f.validatingFields)&&((e||Array.from(s.mount)).forEach(e=>{e&&(t?A(r.validatingFields,e,t):er(r.validatingFields,e))}),p.state.next({validatingFields:r.validatingFields,isValidating:!ee(r.validatingFields)}))},D=(e,t,n,r)=>{let s=C(i,e);if(s){let i=C(a,e,S(n)?C(o,e):n);S(i)||r&&r.defaultChecked||t?A(a,e,t?i:ep(s._f)):H(e,i),l.mount&&!l.action&&h()}},V=(e,t,i,a,l)=>{let s=!1,u=!1,c={name:e};if(!n.disabled){if(!i||a){(d.isDirty||f.isDirty)&&(u=r.isDirty,r.isDirty=c.isDirty=L(),s=u!==c.isDirty);let n=J(C(o,e),t);u=!!C(r.dirtyFields,e),n?er(r.dirtyFields,e):A(r.dirtyFields,e,!0),c.dirtyFields=r.dirtyFields,s=s||(d.dirtyFields||f.dirtyFields)&&!n!==u}if(i){let t=C(r.touchedFields,e);t||(A(r.touchedFields,e,i),c.touchedFields=r.touchedFields,s=s||(d.touchedFields||f.touchedFields)&&t!==i)}s&&l&&p.state.next(c)}return s?c:{}},M=async e=>(g(e,!0),await n.resolver(a,n.context,((e,t,n,r)=>{let i={};for(let n of e){let e=C(t,n);e&&A(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}})(e||s.mount,i,n.criteriaMode,n.shouldUseNativeValidation))),j=async e=>{let{errors:t}=await M(e);if(g(e),e)for(let n of e){let e=C(t,n);e?A(r.errors,n,e):er(r.errors,n)}else r.errors=t;return t},I=async({name:t,eventType:n})=>{if(e.validate){let i=await e.validate({formValues:a,formState:r,name:t,eventType:n});if(b(i))for(let e in i)i[e]&&es(`${R}.${e}`,{message:U(i.message)?i.message:"",type:q});else U(i)||!i?es(R,{message:i||"",type:q}):el(R);return i}return!0},N=async({fields:t,onlyCheckValid:i,name:o,eventType:l,context:u={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(u.runRootValidation=!0,!await I({name:o,eventType:l}))&&(u.valid=!1,i))return u.valid;for(let o in t){let c=t[o];if(c){let{_f:t,...f}=c;if(t){let o=s.array.has(t.name),l=c._f&&ey(c._f);l&&d.validatingFields&&g([t.name],!0);let f=await ek(c,s.disabled,a,m,n.shouldUseNativeValidation&&!i,o);if(l&&d.validatingFields&&g([t.name]),f[t.name]&&(u.valid=!1,i)||(i||(C(f,t.name)?o?ew(r.errors,f,t.name):A(r.errors,t.name,f[t.name]):er(r.errors,t.name)),e.shouldUseNativeValidation&&f[t.name]))break}ee(f)||await N({context:u,onlyCheckValid:i,fields:f,name:o,eventType:l})}}return u.valid},L=(e,t)=>!n.disabled&&(e&&t&&A(a,e,t),!J(ei(),o)),B=(e,t,n)=>W(e,s,{...l.mount?a:S(t)?o:U(e)?{[e]:t}:t},n,t),H=(e,t,n={})=>{let r=C(i,e),o=t;if(r){let n=r._f;n&&(n.disabled||A(a,e,ec(t,n)),o=et(n.ref)&&v(t)?"":t,"select-multiple"===n.ref.type?[...n.ref.options].forEach(e=>e.selected=o.includes(e.value)):n.refs?"checkbox"===n.ref.type?n.refs.forEach(e=>{e.defaultChecked&&e.disabled||(Array.isArray(o)?e.checked=!!o.find(t=>t===e.value):e.checked=o===e.value||!!o)}):n.refs.forEach(e=>e.checked=e.value===o):"file"===n.ref.type?n.ref.value="":(n.ref.value=o,n.ref.type||p.state.next({name:e,values:k(a)})))}(n.shouldDirty||n.shouldTouch)&&V(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&Q(e)},z=(e,t,n)=>{for(let r in t){if(!t.hasOwnProperty(r))return;let o=t[r],a=e+"."+r,l=C(i,a);(s.array.has(e)||b(o)||l&&!l._f)&&!y(o)?z(a,o,n):H(a,o,n)}},Y=(e,t,n={})=>{let u=C(i,e),c=s.array.has(e),m=k(t);A(a,e,m),c?(p.array.next({name:e,values:k(a)}),(d.isDirty||d.dirtyFields||f.isDirty||f.dirtyFields)&&n.shouldDirty&&p.state.next({name:e,dirtyFields:ea(o,a),isDirty:L(e,m)})):!u||u._f||v(m)?H(e,m,n):z(e,m,n),ev(e,s)?p.state.next({...r,name:e,values:k(a)}):p.state.next({name:l.mount?e:void 0,values:k(a)})},Z=async o=>{l.mount=!0;let c=o.target,v=c.name,b=!0,w=C(i,v),x=e=>{b=Number.isNaN(e)||y(e)&&isNaN(e.getTime())||J(e,C(a,v,e))},E=eh(n.mode),S=eh(n.reValidateMode);if(w){var O,D,F,T,j;let l,y,$,B=c.type?ep(w._f):_(o),H=o.type===P||"focusout"===o.type,z=!(($=w._f).mount&&($.required||$.min||$.max||$.maxLength||$.minLength||$.pattern||$.validate))&&!e.validate&&!n.resolver&&!C(r.errors,v)&&!w._f.deps||(O=H,D=C(r.touchedFields,v),F=r.isSubmitted,T=S,!(j=E).isOnAll&&(!F&&j.isOnTouch?!(D||O):(F?T.isOnBlur:j.isOnBlur)?!O:(F?!T.isOnChange:!j.isOnChange)||O)),U=ev(v,s,H);A(a,v,B),H?c&&c.readOnly||(w._f.onBlur&&w._f.onBlur(o),t&&t(0)):w._f.onChange&&w._f.onChange(o);let W=V(v,B,H),Y=!ee(W)||U;if(H||p.state.next({name:v,type:o.type,values:k(a)}),z)return(d.isValid||f.isValid)&&("onBlur"===n.mode?H&&h():H||h()),Y&&p.state.next({name:v,...U?{}:W});if(!n.resolver&&e.validate&&await I({name:v,eventType:o.type}),!H&&U&&p.state.next({...r}),n.resolver){let{errors:e}=await M([v]);if(g([v]),x(B),b){let t=e_(r.errors,i,v),n=e_(e,i,t.name||v);l=n.error,v=n.name,y=ee(e)}}else g([v],!0),l=(await ek(w,s.disabled,a,m,n.shouldUseNativeValidation))[v],g([v]),x(B),b&&(l?y=!1:(d.isValid||f.isValid)&&(y=await N({fields:i,onlyCheckValid:!0,name:v,eventType:o.type})));if(b){w._f.deps&&(!Array.isArray(w._f.deps)||w._f.deps.length>0)&&Q(w._f.deps);var L=v,q=y,R=l;let e=C(r.errors,L),i=(d.isValid||f.isValid)&&"boolean"==typeof q&&r.isValid!==q;if(n.delayError&&R){let e;e=()=>{A(r.errors,L,R),p.state.next({errors:r.errors})},(t=t=>{clearTimeout(u),u=setTimeout(e,t)})(n.delayError)}else clearTimeout(u),t=null,R?A(r.errors,L,R):er(r.errors,L);if((R?!J(e,R):e)||!ee(W)||i){let e={...W,...i&&"boolean"==typeof q?{isValid:q}:{},errors:r.errors,name:L};r={...r,...e},p.state.next(e)}}}},G=(e,t)=>{if(C(r.errors,t)&&e.focus)return e.focus(),1},Q=async(e,t={})=>{let o,a,l=K(e);if(n.resolver){let t=await j(S(e)?e:l);o=ee(t),a=e?!l.some(e=>C(t,e)):o}else e?((a=(await Promise.all(l.map(async e=>{let t=C(i,e);return await N({fields:t&&t._f?{[e]:t}:t,eventType:T})}))).every(Boolean))||r.isValid)&&h():a=o=await N({fields:i,name:e,eventType:T});return p.state.next({...!U(e)||(d.isValid||f.isValid)&&o!==r.isValid?{}:{name:e},...n.resolver||!e?{isValid:o}:{},errors:r.errors}),t.shouldFocus&&!a&&eb(i,G,e?l:s.mount),a},ei=(e,t)=>{let n={...l.mount?a:o};return t&&(n=function e(t,n){let r={};for(let i in t)if(t.hasOwnProperty(i)){let o=t[i],a=n[i];if(o&&b(o)&&a){let t=e(o,a);b(t)&&(r[i]=t)}else t[i]&&(r[i]=a)}return r}(t.dirtyFields?r.dirtyFields:r.touchedFields,n)),S(e)?n:U(e)?C(n,e):e.map(e=>C(n,e))},eo=(e,t)=>({invalid:!!C((t||r).errors,e),isDirty:!!C((t||r).dirtyFields,e),error:C((t||r).errors,e),isValidating:!!C(r.validatingFields,e),isTouched:!!C((t||r).touchedFields,e)}),el=e=>{let t=e?K(e):void 0;null==t||t.forEach(e=>er(r.errors,e)),t?t.forEach(e=>{p.state.next({name:e,errors:r.errors})}):p.state.next({errors:{}})},es=(e,t,n)=>{let o=(C(i,e,{_f:{}})._f||{}).ref,{ref:a,message:l,type:s,...u}=C(r.errors,e)||{};A(r.errors,e,{...u,...t,ref:o}),p.state.next({name:e,errors:r.errors,isValid:!1}),n&&n.shouldFocus&&o&&o.focus&&o.focus()},eu=e=>p.state.subscribe({next:t=>{let n,i,l;n=e.name,i=t.name,l=e.exact,(!n||!i||n===i||K(n).some(e=>e&&(l?e===i:e.startsWith(i)||i.startsWith(e))))&&((e,t,n,r)=>{n(e);let{name:i,...o}=e;return ee(o)||Object.keys(o).length>=Object.keys(t).length||Object.keys(o).find(e=>t[e]===(!r||"all"))})(t,e.formState||d,eC,e.reRenderRoot)&&e.callback({values:{...a},...r,...t,defaultValues:o})}}).unsubscribe,ed=(e,t={})=>{for(let l of e?K(e):s.mount)s.mount.delete(l),s.array.delete(l),t.keepValue||(er(i,l),er(a,l)),t.keepError||er(r.errors,l),t.keepDirty||er(r.dirtyFields,l),t.keepTouched||er(r.touchedFields,l),t.keepIsValidating||er(r.validatingFields,l),n.shouldUnregister||t.keepDefaultValue||er(o,l);p.state.next({values:k(a)}),p.state.next({...r,...!t.keepDirty?{}:{isDirty:L()}}),t.keepIsValid||h()},ef=({disabled:e,name:t})=>{if("boolean"==typeof e&&l.mount||e||s.disabled.has(t)){let n=s.disabled.has(t);e?s.disabled.add(t):s.disabled.delete(t),!!e!==n&&l.mount&&!l.action&&h()}},eg=(e,t={})=>{let r=C(i,e),a="boolean"==typeof t.disabled||"boolean"==typeof n.disabled;return(A(i,e,{...r||{},_f:{...r&&r._f?r._f:{ref:{name:e}},name:e,mount:!0,...t}}),s.mount.add(e),r)?ef({disabled:"boolean"==typeof t.disabled?t.disabled:n.disabled,name:e}):D(e,!0,t.value),{...a?{disabled:t.disabled||n.disabled}:{},...n.progressive?{required:!!t.required,min:em(t.min),max:em(t.max),minLength:em(t.minLength),maxLength:em(t.maxLength),pattern:em(t.pattern)}:{},name:e,onChange:Z,onBlur:Z,ref:a=>{if(a){let n;eg(e,t),r=C(i,e);let l=S(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,s="radio"===(n=l).type||"checkbox"===n.type,u=r._f.refs||[];(s?u.find(e=>e===l):l===r._f.ref)||(A(i,e,{_f:{...r._f,...s?{refs:[...u.filter(en),l,...Array.isArray(C(o,e))?[{}]:[]],ref:{type:l.type,name:e}}:{ref:l}}}),D(e,!1,void 0,l))}else(r=C(i,e,{}))._f&&(r._f.mount=!1),(n.shouldUnregister||t.shouldUnregister)&&!(x(s.array,e)&&l.action)&&s.unMount.add(e)}}},ex=()=>n.shouldFocusError&&eb(i,G,s.mount),eE=(e,t)=>async o=>{let l;o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let u=k(a);if(p.state.next({isSubmitting:!0}),n.resolver){let{errors:e,values:t}=await M();g(),r.errors=e,u=k(t)}else await N({fields:i,eventType:"submit"});if(s.disabled.size)for(let e of s.disabled)er(u,e);if(er(r.errors,$),ee(r.errors)){p.state.next({errors:{}});try{await e(u,o)}catch(e){l=e}}else t&&await t({...r.errors},o),ex(),setTimeout(ex);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ee(r.errors)&&!l,submitCount:r.submitCount+1,errors:r.errors}),l)throw l},eO=(e,t={})=>{let u=e?k(e):o,c=k(u),f=ee(e),m=f?o:c;if(t.keepDefaultValues||(o=u),!t.keepValues){if(t.keepDirtyValues)for(let e of Array.from(new Set([...s.mount,...Object.keys(ea(o,a))]))){let t=C(r.dirtyFields,e),n=C(a,e),i=C(m,e);t&&!S(n)?A(m,e,n):t||S(i)||Y(e,i)}else{if(E&&S(e))for(let e of s.mount){let t=C(i,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(et(e)){let t=e.closest("form");if(t){t.reset();break}}}}if(t.keepFieldsRef)for(let e of s.mount)Y(e,C(m,e));else i={}}a=n.shouldUnregister?t.keepDefaultValues?k(o):{}:k(m),p.array.next({values:{...m}}),p.state.next({values:{...m}})}s={mount:t.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!d.isValid||!!t.keepIsValid||!!t.keepDirtyValues||!n.shouldUnregister&&!ee(m),l.watch=!!n.shouldUnregister,l.keepIsValid=!!t.keepIsValid,l.action=!1,t.keepErrors||(r.errors={}),p.state.next({submitCount:t.keepSubmitCount?r.submitCount:0,isDirty:!f&&(t.keepDirty?r.isDirty:!!(t.keepDefaultValues&&!J(e,o))),isSubmitted:!!t.keepIsSubmitted&&r.isSubmitted,dirtyFields:f?{}:t.keepDirtyValues?t.keepDefaultValues&&a?ea(o,a):r.dirtyFields:t.keepDefaultValues&&e?ea(o,e):t.keepDirty?r.dirtyFields:{},touchedFields:t.keepTouched?r.touchedFields:{},errors:t.keepErrors?r.errors:{},isSubmitSuccessful:!!t.keepIsSubmitSuccessful&&r.isSubmitSuccessful,isSubmitting:!1,defaultValues:o})},eD=(e,t)=>eO(F(e)?e(a):e,{...n.resetOptions,...t}),eC=e=>{r={...r,...e}},eF={control:{register:eg,unregister:ed,getFieldState:eo,handleSubmit:eE,setError:es,_subscribe:eu,_runSchema:M,_updateIsValidating:g,_focusError:ex,_getWatch:B,_getDirty:L,_setValid:h,_setFieldArray:(e,t=[],s,u,c=!0,m=!0)=>{if(u&&s&&!n.disabled){if(l.action=!0,m&&Array.isArray(C(i,e))){let t=s(C(i,e),u.argA,u.argB);c&&A(i,e,t)}if(m&&Array.isArray(C(r.errors,e))){let t,n=s(C(r.errors,e),u.argA,u.argB);c&&A(r.errors,e,n),O(C(t=r.errors,e)).length||er(t,e)}if((d.touchedFields||f.touchedFields)&&m&&Array.isArray(C(r.touchedFields,e))){let t=s(C(r.touchedFields,e),u.argA,u.argB);c&&A(r.touchedFields,e,t)}if(d.dirtyFields||f.dirtyFields){let t=ea(o,a),n=w(e);A(r.dirtyFields,n,C(t,n))}p.state.next({name:e,isDirty:L(e,t),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else A(a,e,t)},_setDisabledField:ef,_setErrors:e=>{r.errors=e,p.state.next({errors:r.errors,isValid:!1})},_getFieldArray:e=>O(C(l.mount?a:o,e,n.shouldUnregister?C(o,e,[]):[])),_reset:eO,_resetDefaultValues:()=>F(n.defaultValues)&&n.defaultValues().then(e=>{eD(e,n.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:()=>{for(let e of s.unMount){let t=C(i,e);t&&(t._f.refs?t._f.refs.every(e=>!en(e)):!en(t._f.ref))&&ed(e)}s.unMount=new Set},_disableForm:e=>{"boolean"==typeof e&&(p.state.next({disabled:e}),eb(i,(t,n)=>{let r=C(i,n);r&&(t.disabled=r._f.disabled||e,Array.isArray(r._f.refs)&&r._f.refs.forEach(t=>{t.disabled=r._f.disabled||e}))},0,!1))},_subjects:p,_proxyFormState:d,get _fields(){return i},get _formValues(){return a},get _state(){return l},set _state(value){l=value},get _defaultValues(){return o},get _names(){return s},set _names(value){s=value},get _formState(){return r},get _options(){return n},set _options(value){n={...n,...value}}},subscribe:e=>(l.mount=!0,f={...f,...e.formState},eu({...e,formState:{...c,...e.formState}})),trigger:Q,register:eg,handleSubmit:eE,watch:(e,t)=>F(e)?p.state.subscribe({next:n=>"values"in n&&e(B(void 0,t),n)}):B(e,t,!0),setValue:Y,getValues:ei,reset:eD,resetField:(e,t={})=>{C(i,e)&&(S(t.defaultValue)?Y(e,k(C(o,e))):(Y(e,t.defaultValue),A(o,e,k(t.defaultValue))),t.keepTouched||er(r.touchedFields,e),t.keepDirty||(er(r.dirtyFields,e),r.isDirty=t.defaultValue?L(e,k(C(o,e))):L()),!t.keepError&&(er(r.errors,e),d.isValid&&h()),p.state.next({...r}))},clearErrors:el,unregister:ed,setError:es,setFocus:(e,t={})=>{let n=C(i,e),r=n&&n._f;if(r){let e=r.refs?r.refs[0]:r.ref;e.focus&&setTimeout(()=>{e.focus(),t.shouldSelect&&F(e.select)&&e.select()})}},getFieldState:eo};return{...eF,formControl:eF}}(e);t.current={...i,formState:r}}let o=t.current.control;return o._options=e,z(()=>{let e=o._subscribe({formState:o._proxyFormState,callback:()=>i({...o._formState}),reRenderRoot:!0});return i(e=>({...e,isReady:!0})),o._formState.isReady=!0,e},[o]),d().useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),d().useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),d().useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),d().useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),d().useEffect(()=>{if(o._proxyFormState.isDirty){let e=o._getDirty();e!==r.isDirty&&o._subjects.state.next({isDirty:e})}},[o,r.isDirty]),d().useEffect(()=>{var t;e.values&&!J(e.values,n.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),(null==(t=o._options.resetOptions)?void 0:t.keepIsValid)||o._setValid(),n.current=e.values,i(e=>({...e}))):o._resetDefaultValues()},[o,e.values]),d().useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=d().useMemo(()=>H(r,o),[o,r]),t.current}({defaultValues:t,mode:"onChange",reValidateMode:"onChange",criteriaMode:"all"}),{formState:{isDirty:N}}=I,[{formFields:L,invalidFields:B,formJson:Y,deletedFields:Z},G]=(0,c.useReducer)(lL,{...lN,formFields:m,formJson:h}),{addFormField:Q,updateFormField:ei,getFormField:eo,removeFormField:el,setInvalidFields:es,addInvalidField:eu,removeInvalidField:ed,setForm:ef,setDeletedFields:eg}=(i=(0,c.useCallback)(e=>{G({type:"ADD_FORM_FIELD",value:e})},[]),o=(0,c.useCallback)(e=>{if(e.meta.groupId){let t=L.find(t=>t.id===e.meta.groupId);t&&(t.questions=t.questions.map(t=>t.id===e.id?e:t),o(t))}G({type:"UPDATE_FORM_FIELD",value:(0,oC.A)(e)})},[L]),a=(0,c.useCallback)(e=>L.find(t=>t.id===e),[L]),l=(0,c.useCallback)(e=>{G({type:"REMOVE_FORM_FIELD",value:e})},[]),s=(0,c.useCallback)(e=>{G({type:"SET_INVALID_FIELDS",value:e})},[]),u=(0,c.useCallback)(e=>{G({type:"ADD_INVALID_FIELD",value:e})},[]),f=(0,c.useCallback)(e=>{G({type:"REMOVE_INVALID_FIELD",value:e})},[]),p=(0,c.useCallback)(e=>{G({type:"SET_FORM_JSON",value:eU(e)})},[]),{addFormField:i,updateFormField:o,getFormField:a,removeFormField:l,setInvalidFields:s,addInvalidField:u,removeInvalidField:f,setForm:p,setDeletedFields:(0,c.useCallback)(e=>{G({type:"SET_DELETED_FIELDS",value:e})},[])});(0,c.useEffect)(()=>{let e=Y.pages.filter(e=>!e.isSubform).map(e=>e);ld.updateScrollablePages(e)},[Y.pages]),(0,c.useEffect)(()=>{ld.setEvaluatedPagesVisibility(g)},[g]),(0,c.useEffect)(()=>{ld.updatePagesWithErrors(B.map(e=>e.meta.pageId))},[B]);let ex=(0,c.useMemo)(()=>({...e,workspaceLayout:M,methods:I,formFields:L,formJson:Y,invalidFields:B,deletedFields:Z,addFormField:Q,updateFormField:ei,getFormField:eo,removeFormField:el,setInvalidFields:es,addInvalidField:eu,removeInvalidField:ed,setForm:ef,setDeletedFields:eg}),[e,M,I,L,Y,B,Z]);return(0,c.useEffect)(()=>{D(Y.name,n,ex)},[Y.name,n,ex]),(0,c.useEffect)(()=>{V(N)},[N]),d().createElement(tS,ex,Y.pages.map(e=>e.isSubform||t_(e)?e.isSubform&&e.subform?.form?d().createElement(lU,{key:e.subform.form.uuid,formJson:e.subform.form,isSubForm:!0,setIsLoadingFormDependencies:r}):d().createElement(lI,{key:e.label,page:e,isFormExpanded:j}):null))},lR=({context:e,setContext:t,setters:n,useCustomHooks:r,setIsLoadingCustomHooks:i})=>{let{isLoading:o=!1,error:a=null,data:l,updateContext:s}=r(e);return(0,c.useEffect)(()=>{!o&&s&&(s(t,n),i(!1))},[o]),null},l$={},lB={},lH=()=>{let{t:e}=(0,eO.useTranslation)();return d().createElement("div",{className:"-esm-form-engine__loader__loaderContainer___78hu3"},d().createElement(g.InlineLoading,{className:"-esm-form-engine__loader__loader___dnvKS",description:`${e("loading","Loading")} ...`}))},lz=["patient","formJson","visit","sessionMode","sessionDate","location","currentProvider","layoutType","processor","formFields","formFieldAdapters","formFieldValidators"],lU=({formJson:e,isSubForm:t=!1,setIsLoadingFormDependencies:n})=>{let{patient:r,sessionMode:i,formProcessors:o,layoutType:a,location:l,provider:f,sessionDate:p,visit:m}=ao(),{t:h}=(0,eO.useTranslation)(),y=(0,c.useId)(),v=(0,c.useMemo)(()=>{let t,n=o[e.processor];return n?t=new n(e):(console.error(`Form processor ${e.processor} not found, defaulting to EncounterFormProcessor`),t=new o8(e)),t.prepareFormSchema(e),t},[o,e.processor]),{formFields:b,conceptReferences:_}=function(e){let[t,n]=(0,c.useMemo)(()=>{let t=[],n=new Set,r=(e,i)=>{let o=i?{...e,meta:{...e.meta,groupId:i}}:e;t.push(o),o.questionOptions?.concept&&n.add(o.questionOptions.concept),o.questionOptions?.answers?.forEach(e=>{e.concept&&n.add(e.concept)}),"obsGroup"===o.type&&o.questions&&o.questions.forEach(e=>{r(e,o.id)})};return e.pages?.forEach(e=>e.sections?.forEach(e=>{e.questions?.forEach(e=>r(e))})),[t,JSON.stringify(Array.from(n).sort())]},[e]);return{formFields:t,conceptReferences:(0,c.useMemo)(()=>new Set(JSON.parse(n)),[n])}}(e),{concepts:w,isLoading:x}=function(e){let{data:t,error:n,isLoading:r}=o5()([`${s.restBaseUrl}/conceptreferences?v=custom:(uuid,display,conceptClass:(uuid,display),answers:(uuid,display),conceptMappings:(conceptReferenceTerm:(conceptSource:(name),code)))`,e],([e,t])=>(0,s.openmrsFetch)(e,{headers:{"Content-Type":"application/json"},body:{references:t},method:"POST"}),{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1,shouldRetryOnError:!1});return{concepts:(0,c.useMemo)(()=>t?.data?Object.values(t.data):void 0,[t]),isLoading:r,error:n}}(Array.from(_)),E=(0,c.useMemo)(()=>b.length&&w?.length?b.map(e=>{let t=tv(e.questionOptions.concept,w);return e.questionOptions.concept=t?t.uuid:e.questionOptions.concept,e.label=e.label?e.label:t?.display,u.FU.includes(e.questionOptions.rendering)&&!e.questionOptions.answers?.length&&t?.conceptClass?.display==="Question"&&t?.answers?.length&&(e.questionOptions.answers=t.answers.map(e=>({concept:e?.uuid,label:e?.display}))),e.meta={...e.meta||{},concept:t},e.questionOptions.answers&&(e.questionOptions.answers=e.questionOptions.answers.map(e=>{let t=tv(e.concept,w);return{...e,concept:t?t.uuid:e.concept,label:e.label?e.label:t?.display}})),e}):b??[],[w,b]),k=(e=>{let t=(0,c.useMemo)(()=>{let t=new Set;return e.forEach(e=>t.add(e.type)),Array.from(t).sort().join(",")},[e]),{data:n}=o4()(t?["formFieldValueAdapters",t]:null,async([,e])=>{let t=e.split(","),n=await Promise.all(t.map(e=>a$(e))),r={};return t.forEach((e,t)=>{r[e]=n[t]}),r},{keepPreviousData:!0});return n??lB})(b),S=function(e){let t=(0,c.useMemo)(()=>{let t=new Set;return e.forEach(e=>{e.validators?.forEach(e=>t.add(e.type))}),Array.from(t).sort().join(",")},[e]),{data:n}=o4()(t?["formFieldValidators",t]:null,async([,e])=>{let t=e.split(","),n=await Promise.all(t.map(e=>az(e))),r={};return t.forEach((e,t)=>{r[e]=n[t]}),r},{keepPreviousData:!0});return n??l$}(b),O=(0,c.useMemo)(()=>E?.length?E:b??[],[E,b]),[D,C]=(0,c.useState)({}),F=(0,c.useMemo)(()=>({patient:r,formJson:e,sessionMode:i,layoutType:a,location:l,currentProvider:f,processor:v,sessionDate:p,visit:m,formFields:O,formFieldAdapters:k??{},formFieldValidators:S??{}}),[r,e,i,a,l,f,v,p,m,O,k,S]),A=(0,c.useMemo)(()=>({...F,...D}),[F,D]),P=(0,c.useCallback)(e=>{C(t=>{let n,r={...F,...t},i="function"==typeof e?e(r):e;return"function"==typeof e&&(n=lz.filter(e=>e in i&&i[e]!==r[e])).length&&console.warn(`A form processor tried to set the context propert${1===n.length?"y":"ies"} ${n.join(", ")}, which the form engine derives itself. ${1===n.length?"It was":"They were"} ignored. Use the setters passed alongside setContext to update the domain object or custom dependencies.`),{domainObjectValue:i.domainObjectValue,previousDomainObjectValue:i.previousDomainObjectValue,customDependencies:i.customDependencies}})},[F]),T=(0,c.useMemo)(()=>({setDomainObjectValue:e=>C(t=>({...t,domainObjectValue:e})),setPreviousDomainObjectValue:e=>C(t=>({...t,previousDomainObjectValue:e})),setCustomDependencies:e=>C(t=>({...t,customDependencies:"function"==typeof e?e(t.customDependencies??{}):e}))}),[]),{isLoading:V,error:M,retry:j}=((e,t,n,r)=>{let{loadDependencies:i}=e,{formJson:o}=t,[a,l]=(0,c.useState)(0),[s,u]=(0,c.useState)(null),d=(0,c.useCallback)(()=>l(e=>e+1),[]),f=s?.loadDependencies===i&&s?.attempt===a?s:null;return(0,c.useEffect)(()=>{let e=!1;return async function(){let l=await Promise.allSettled([Promise.resolve().then(()=>i?.(t,n,r)),e8(o)]);if(!e){let e=l.find(e=>"rejected"===e.status);u({loadDependencies:i,attempt:a,error:e?Error(e.reason?.message??String(e.reason)):null})}}(),()=>{e=!0}},[i,a]),{isLoading:!f||!!f.error,error:f?.error,retry:d}})(v,A,P,T),I=v.getCustomHooks().useCustomHooks,[N,L]=(0,c.useState)(!!I),{isLoadingInitialValues:q,initialValues:R,error:$}=((e,t,n)=>{let[r,i]=(0,c.useState)(!0),[o,a]=(0,c.useState)({}),[l,s]=(0,c.useState)(null),u=(0,c.useRef)(n);u.current=n;let d=(0,c.useRef)(!1),f=n.formFields?.length>0,p=Object.keys(n.formFieldAdapters??{}).length>0;return(0,c.useEffect)(()=>{if(e&&!t&&f&&p&&!d.current){d.current=!0;let t=u.current;e.getInitialValues(t).then(e=>{a(e),i(!1)}).catch(e=>{console.error(e),s(e),i(!1)})}},[e,t,f,p]),{isLoadingInitialValues:r,initialValues:o,error:l}})(v,V||N||x,A),B=(0,c.useMemo)(()=>V||N||x||q,[V,N,x,q]);return(0,c.useEffect)(()=>{n(y,B)},[y,B,n]),(0,c.useEffect)(()=>()=>n(y,!1),[y,n]),(0,c.useEffect)(()=>{(0,tw.N)($,h("errorLoadingInitialValues","Error loading initial values"))},[$,h]),(0,c.useEffect)(()=>{k&&k&&Object.values(k).forEach(e=>{lf.add(e)})},[k]),d().createElement(d().Fragment,null,I&&d().createElement(lR,{context:A,setContext:P,setters:T,useCustomHooks:I,setIsLoadingCustomHooks:L}),M?d().createElement("div",null,d().createElement(g.InlineNotification,{kind:"error",hideCloseButton:!0,title:h("errorLoadingFormDependencies","Unable to load form data"),subtitle:h("retryLoadingFormDependencies","Required form data could not be loaded. Retry to complete and save this form.")}),d().createElement(g.Button,{kind:"tertiary",onClick:j},h("retry","Retry"))):B?d().createElement(lH,null):d().createElement(lq,{processorContext:A,initialValues:R,isSubForm:t,setIsLoadingFormDependencies:n}))},lW=({patient:e,hideActionsOverflow:t})=>d().createElement("div",{className:"-esm-form-engine__patient-banner__patientBannerContainer___w28t3"},d().createElement(s.ExtensionSlot,{name:"patient-header-slot",state:{patient:e,patientUuid:e.id,hideActionsOverflow:t}}));function lY({page:e,currentActivePage:t,pagesWithErrors:n,requestPage:r}){let{t:i}=(0,eO.useTranslation)(),o=e.id===t,a=n.includes(e.id),l="tablet"===(0,s.useLayoutType)();return d().createElement("div",{className:p()("-esm-form-engine__sidebar__pageLink___ivjRs",{"-esm-form-engine__sidebar__activePage___PtOKZ":o&&!a,"-esm-form-engine__sidebar__errorPage___56UzK":a&&!o,"-esm-form-engine__sidebar__activeErrorPage___FRrGU":a&&o,"-esm-form-engine__sidebar__pageLinkTablet___DzG-5":l})},d().createElement("button",{onClick:t=>{t.preventDefault(),r(e.id)}},d().createElement("span",null,i(e.label))))}let lJ=({defaultPage:e,isFormSubmitting:t,sessionMode:n,onCancel:r,handleClose:i,hideFormCollapseToggle:o,hideControls:a})=>{let{t:l}=(0,eO.useTranslation)(),{pages:u,pagesWithErrors:f,activePages:m,evaluatedPagesVisibility:h}=lp(),{currentActivePage:y,requestPage:v}=(({pages:e,defaultPage:t,activePages:n,evaluatedPagesVisibility:r})=>{let[i,o]=(0,c.useState)(null),[a,l]=(0,c.useState)(!1),[s,u]=(0,c.useState)(null),d=(0,c.useRef)(!0);return(0,c.useEffect)(()=>{if(a||!r)return;let n=e.find(({label:e})=>e===t);if(n&&!n.isHidden)o(n.id),tb(n.id);else{let t=e.find(e=>!e.isHidden);t&&o(t.id)}l(!0)},[e,t,r,a]),(0,c.useEffect)(()=>{let e=null;return a&&(e=setTimeout(()=>{d.current=!1},200)),()=>{e&&clearTimeout(e)}},[a]),(0,c.useEffect)(()=>{if(d.current)return;let t=null;if(s&&n.includes(s)){o(s),t=setTimeout(()=>{u(null)},100);return}return!s&&n.length>0&&o(n.reduce((t,n)=>e.findIndex(e=>e.id===t)<e.findIndex(e=>e.id===n)?t:n)),()=>{t&&clearTimeout(t)}},[n,s,e]),{currentActivePage:i,requestPage:(0,c.useCallback)(e=>{d.current=!1,u(e),o(e),tb(e)},[])}})({pages:u,defaultPage:e,activePages:m,evaluatedPagesVisibility:h}),b=(0,s.useLayoutType)(),_=(0,c.useMemo)(()=>"tablet"===b?"lg":"sm",[b]);return d().createElement("div",{className:"-esm-form-engine__sidebar__sidebar___oko66"},u.filter(e=>t_(e)).map(e=>d().createElement(lY,{key:e.id,page:e,currentActivePage:y,pagesWithErrors:f,requestPage:v})),"view"!==n&&!a&&d().createElement("hr",{className:"-esm-form-engine__sidebar__divider___qNrzq"}),!a&&d().createElement("div",{className:"-esm-form-engine__sidebar__sideNavActions___hQ7Cj"},"view"!==n&&d().createElement(g.Button,{className:"-esm-form-engine__sidebar__saveButton___1qxAl",disabled:t,type:"submit",size:_},t?d().createElement(g.InlineLoading,{description:l("submitting","Submitting")+"..."}):d().createElement("span",null,`${l("save","Save")}`)),d().createElement(g.Button,{className:p()("-esm-form-engine__sidebar__closeButton___X671g",{"-esm-form-engine__sidebar__topMargin___XINCj":"view"===n}),kind:"tertiary",onClick:()=>{r?.(),i?.(),o()},size:_},"view"===n?l("close","Close"):l("cancel","Cancel"))))},lZ=({formJson:e,patientUUID:t,formUUID:n,encounterUUID:r,visit:i,formSessionIntent:o,mode:a,onSubmit:l,onCancel:u,handleClose:f,handleConfirmQuestionDeletion:m,markFormAsDirty:h,hideControls:y=!1,hidePatientBanner:v=!1,preFilledQuestions:b})=>{let{t:_}=(0,eO.useTranslation)(),w=(0,s.useSession)(),x=(0,c.useRef)(null),E=(0,c.useRef)(new Date),k=(0,c.useMemo)(()=>(function(e,t){if(!t)return e;let n=t.startDatetime?new Date(t.startDatetime):null,r=t.stopDatetime?new Date(t.stopDatetime):null;return n&&e<n||r&&e>r?n??r:e})(E.current,i),[i?.startDatetime,i?.stopDatetime]),S=function(e){let[t,n]=(0,c.useState)(0),r=(0,c.useMemo)(()=>t<=26.25?"narrow":t<=32.25?"wider":t<=48.25?"extra-wide":"ultra-wide",[t]);return(0,c.useLayoutEffect)(()=>{let t=()=>{let t=e.current?.parentElement?.offsetWidth,r=parseInt(getComputedStyle(document.documentElement).fontSize);t&&n(function(e,t=16){return e/t}(t,r))};t();let r=new ResizeObserver(e=>{t()});return e.current?.parentElement&&r.observe(e.current?.parentElement),()=>{r.disconnect()}},[e]),r}(x),{patient:O,isLoadingPatient:D}=(e=>{let{patient:t,isLoading:n,error:r}=(0,s.usePatient)(e);if(t&&!n){var i;let e,n;i=new Date(t?.birthDate),n=(e=new Date).getFullYear()-i.getFullYear(),t.age=e.getMonth()<i.getMonth()||e.getMonth()===i.getMonth()&&e.getDate()<i.getDate()?n-1:n,t.sex=lm[t.gender]??"U"}return{patient:t,isLoadingPatient:n,patientError:r}})(t),[C,F]=(0,c.useState)(!0),A=(0,c.useRef)(new Set),P=(0,c.useCallback)((e,t)=>{t?A.current.add(e):A.current.delete(e),F(A.current.size>0)},[]),[T,V]=(0,c.useState)(!1),[M,j]=(0,c.useState)(!1),I=ej(a)?ej(r)?"enter":"edit":a,{isFormExpanded:N,hideFormCollapseToggle:L}=function(e){let[t,n]=(0,c.useState)(void 0),r=(0,c.useCallback)(()=>{let e=new CustomEvent("openmrs:form-view-embedded",{detail:{value:!1}});window.dispatchEvent(e)},[]),i=(0,c.useCallback)(e=>{n(e.detail.value)},[]);return(0,c.useEffect)(()=>{let t=new CustomEvent("openmrs:form-view-embedded",{detail:{value:"embedded-view"!=e}});window.dispatchEvent(t)},[e]),(0,c.useEffect)(()=>(window.addEventListener("openmrs:form-collapse-toggle",i),()=>{window.removeEventListener("openmrs:form-collapse-toggle",i)}),[]),{isFormExpanded:t,hideFormCollapseToggle:r}}(I),{hasMultiplePages:q}=lp(),{formJson:R,isLoading:$,formError:B}=aY(n,e,r,o,b),H=(0,c.useMemo)(()=>!v&&O&&"ultra-wide"===S&&"embedded-view"!==a,[O,a,S,v]),z=(0,c.useMemo)(()=>["narrow"].includes(S),[S]),U=(0,c.useMemo)(()=>"embedded-view"!==a&&!C&&null!==q&&(z||!q),[a,z,C,q]),W=(0,c.useMemo)(()=>"embedded-view"!==a&&!C&&null!==q&&!z&&q,[z,C,q]);(0,c.useEffect)(()=>{(0,tw.N)(B,_("errorLoadingFormSchema","Error loading form schema"))},[B]),(0,c.useEffect)(()=>()=>{lf.forEach(e=>{try{e.tearDown()}catch(e){}}),lf.clear(),ld.clear()},[]),(0,c.useEffect)(()=>{h?.(M)},[M]);let Y=(0,c.useCallback)(e=>{e.preventDefault(),V(!0)},[]);return d().createElement("form",{ref:x,noValidate:!0,className:p()("cds--form","-esm-form-engine__form-engine__form___G3zJ0"),onSubmit:Y},D||$?d().createElement(lH,null):d().createElement(ai,{patient:O,isLoadingDependencies:C,patientUUID:t,sessionMode:I,sessionDate:k,formJson:R,workspaceLayout:"ultra-wide"===S?"maximized":"minimized",location:w?.sessionLocation,provider:w?.currentProvider,visit:i,handleConfirmQuestionDeletion:m,isFormExpanded:N,formSubmissionProps:{isSubmitting:T,setIsSubmitting:V,onSubmit:l,onError:()=>{},handleClose:()=>{}},hideFormCollapseToggle:L,setIsFormDirty:j},d().createElement("div",{className:"-esm-form-engine__form-engine__formContainer___SqLcw"},C&&d().createElement("div",{className:"-esm-form-engine__form-engine__linearActivity___boIRq"},d().createElement("div",{className:"-esm-form-engine__form-engine__indeterminate___nUedJ"})),d().createElement("div",{className:"-esm-form-engine__form-engine__formContent___wWrk8"},W&&d().createElement(lJ,{isFormSubmitting:T,sessionMode:a,defaultPage:R.defaultPage,onCancel:u,handleClose:f,hideFormCollapseToggle:L,hideControls:y}),d().createElement("div",{className:"-esm-form-engine__form-engine__formContentInner___z1h1C"},H&&d().createElement(lW,{patient:O,hideActionsOverflow:!0}),R.markdown&&d().createElement("div",{className:"-esm-form-engine__form-engine__markdownContainer___A3eX9"},d().createElement(oi,{markdown:R.markdown})),d().createElement("div",{className:"-esm-form-engine__form-engine__formBody___Fb2k2"},d().createElement(lU,{formJson:R,setIsLoadingFormDependencies:P})),U&&!y&&d().createElement(g.ButtonSet,{className:"-esm-form-engine__form-engine__minifiedButtons___SnmW7"},d().createElement(g.Button,{kind:"secondary",onClick:()=>{u&&u(),f&&f(),L()}},"view"===a?_("close","Close"):_("cancel","Cancel")),d().createElement(g.Button,{className:"-esm-form-engine__form-engine__saveButton___T0Txa",disabled:C||T||"view"===a,kind:"primary",type:"submit"},T?d().createElement(g.InlineLoading,{description:_("submitting","Submitting")+"..."}):d().createElement("span",null,`${_("save","Save")}`))))))))},lG=function(e){return d().createElement(c.Suspense,{fallback:d().createElement(lH,null)},d().createElement(eO.I18nextProvider,{i18n:window.i18next,defaultNS:oK.L},d().createElement(lZ,e)))}},1809(e,t,n){"use strict";function r(e){return"boolean"==typeof e?e:"string"==typeof e?"true"==e:!!e}function i(e){return/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(e)}n.d(t,{H:()=>r,O:()=>i})},8059(e,t,n){"use strict";n.d(t,{N:()=>i,j:()=>o});var r=n(2664);function i(e,t){if(e){let n=o(e).join(", ");console.error(e),(0,r.showSnackbar)({subtitle:n,title:t,kind:"error",isLowContrast:!1})}}function o(e){let t=e?.responseBody?.error?.fieldErrors,n=e?.responseBody?.error?.globalErrors;return t&&0!==Object.keys(t).length||n?n?.length?n.flatMap(e=>e.message):Object.values(t).flatMap(e=>e.map(e=>e.message)):[e?.responseBody?.error?.message??e?.message]}},1630(e){e.exports=function(){"use strict";var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d/,r=/\d\d/,i=/\d\d?/,o=/\d*[^-_:/,()\s\d]+/,a={},l=function(e){return(e*=1)+(e>68?1900:2e3)},s=function(e){return function(t){this[e]=+t}},u=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e||"Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e)}],c=function(e){var t=a[e];return t&&(t.indexOf?t:t.s.concat(t.f))},d=function(e,t){var n,r=a.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},f={A:[o,function(e){this.afternoon=d(e,!1)}],a:[o,function(e){this.afternoon=d(e,!0)}],Q:[n,function(e){this.month=3*(e-1)+1}],S:[n,function(e){this.milliseconds=100*e}],SS:[r,function(e){this.milliseconds=10*e}],SSS:[/\d{3}/,function(e){this.milliseconds=+e}],s:[i,s("seconds")],ss:[i,s("seconds")],m:[i,s("minutes")],mm:[i,s("minutes")],H:[i,s("hours")],h:[i,s("hours")],HH:[i,s("hours")],hh:[i,s("hours")],D:[i,s("day")],DD:[r,s("day")],Do:[o,function(e){var t=a.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r)}],w:[i,s("week")],ww:[r,s("week")],M:[i,s("month")],MM:[r,s("month")],MMM:[o,function(e){var t=c("months"),n=(c("monthsShort")||t.map(function(e){return e.slice(0,3)})).indexOf(e)+1;if(n<1)throw Error();this.month=n%12||n}],MMMM:[o,function(e){var t=c("months").indexOf(e)+1;if(t<1)throw Error();this.month=t%12||t}],Y:[/[+-]?\d+/,s("year")],YY:[r,function(e){this.year=l(e)}],YYYY:[/\d{4}/,s("year")],Z:u,ZZ:u};return function(n,r,i){i.p.customParseFormat=!0,n&&n.parseTwoDigitYear&&(l=n.parseTwoDigitYear);var o=r.prototype,s=o.parse;o.parse=function(n){var r=n.date,o=n.utc,l=n.args;this.$u=o;var u=l[1];if("string"==typeof u){var c=!0===l[2],d=!0===l[3],p=l[2];d&&(p=l[2]),a=this.$locale(),!c&&p&&(a=i.Ls[p]),this.$d=function(n,r,i,o){try{if(["x","X"].indexOf(r)>-1)return new Date(("X"===r?1e3:1)*n);var l=(function(n){var r,i;r=n,i=a&&a.formats;for(var o=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(e,t,n){return t||n.slice(1)})})).match(t),l=o.length,s=0;s<l;s+=1){var u=o[s],c=f[u],d=c&&c[0],p=c&&c[1];o[s]=p?{regex:d,parser:p}:u.replace(/^\[|\]$/g,"")}return function(e){for(var t={},n=0,r=0;n<l;n+=1){var i=o[n];if("string"==typeof i)r+=i.length;else{var a=i.regex,s=i.parser,u=e.slice(r),c=a.exec(u)[0];s.call(t,c),e=e.replace(c,"")}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon}}(t),t}})(r)(n),s=l.year,u=l.month,c=l.day,d=l.hours,p=l.minutes,m=l.seconds,h=l.milliseconds,g=l.zone,y=l.week,v=new Date,b=c||(s||u?1:v.getDate()),_=s||v.getFullYear(),w=0;s&&!u||(w=u>0?u-1:v.getMonth());var x,E=d||0,k=p||0,S=m||0,O=h||0;return g?new Date(Date.UTC(_,w,b,E,k,S,O+60*g.offset*1e3)):i?new Date(Date.UTC(_,w,b,E,k,S,O)):(x=new Date(_,w,b,E,k,S,O),y&&(x=o(x).week(y).toDate()),x)}catch(e){return new Date("")}}(r,u,o,i),this.init(),p&&!0!==p&&(this.$L=this.locale(p).$L),(c||d)&&r!=this.format(u)&&(this.$d=new Date("")),a={}}else if(u instanceof Array)for(var m=u.length,h=1;h<=m;h+=1){l[1]=u[h-1];var g=i.apply(this,l);if(g.isValid()){this.$d=g.$d,this.$L=g.$L,this.init();break}h===m&&(this.$d=new Date(""))}else s.call(this,n)}}}()},9710(e){"use strict";var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===n.call(e)},a=function(e){if(!e||"[object Object]"!==n.call(e))return!1;var r,i=t.call(e,"constructor"),o=e.constructor&&e.constructor.prototype&&t.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!i&&!o)return!1;for(r in e);return void 0===r||t.call(e,r)},l=function(e,t){r&&"__proto__"===t.name?r(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},s=function(e,n){if("__proto__"===n){if(!t.call(e,n))return;else if(i)return i(e,n).value}return e[n]};e.exports=function e(){var t,n,r,i,u,c,d=arguments[0],f=1,p=arguments.length,m=!1;for("boolean"==typeof d&&(m=d,d=arguments[1]||{},f=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});f<p;++f)if(t=arguments[f],null!=t)for(n in t)r=s(d,n),d!==(i=s(t,n))&&(m&&i&&(a(i)||(u=o(i)))?(u?(u=!1,c=r&&o(r)?r:[]):c=r&&a(r)?r:{},l(d,{name:n,newValue:e(m,c,i)})):void 0!==i&&l(d,{name:n,newValue:i}));return d}},5937(e){var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,r=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,s=/^\s+|\s+$/g;function u(e){return e?e.replace(s,""):""}e.exports=function(e,s){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];s=s||{};var c=1,d=1;function f(e){var t=e.match(n);t&&(c+=t.length);var r=e.lastIndexOf("\n");d=~r?e.length-r:d+e.length}function p(){var e={line:c,column:d};return function(t){return t.position=new m(e),y(r),t}}function m(e){this.start=e,this.end={line:c,column:d},this.source=s.source}m.prototype.content=e;var h=[];function g(t){var n=Error(s.source+":"+c+":"+d+": "+t);if(n.reason=t,n.filename=s.source,n.line=c,n.column=d,n.source=e,s.silent)h.push(n);else throw n}function y(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function v(e){var t;for(e=e||[];t=b();)!1!==t&&e.push(t);return e}function b(){var t=p();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var n=2;""!=e.charAt(n)&&("*"!=e.charAt(n)||"/"!=e.charAt(n+1));)++n;if(n+=2,""===e.charAt(n-1))return g("End of comment missing");var r=e.slice(2,n-2);return d+=2,f(r),e=e.slice(n),d+=2,t({type:"comment",comment:r})}}y(r);var _,w=[];for(v(w);_=function(){var e=p(),n=y(i);if(n){if(b(),!y(o))return g("property missing ':'");var r=y(a),s=e({type:"declaration",property:u(n[0].replace(t,"")),value:r?u(r[0].replace(t,"")):""});return y(l),s}}();)!1!==_&&(w.push(_),v(w));return w}},3103(e,t,n){e.exports=n(4715)(n(8942),"DataView")},5098(e,t,n){var r=n(3305),i=n(9361),o=n(1112),a=n(5276),l=n(5071);function s(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=i,s.prototype.get=o,s.prototype.has=a,s.prototype.set=l,e.exports=s},1386(e,t,n){var r=n(2393),i=n(2049),o=n(7144),a=n(7452),l=n(3964);function s(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=i,s.prototype.get=o,s.prototype.has=a,s.prototype.set=l,e.exports=s},9770(e,t,n){e.exports=n(4715)(n(8942),"Map")},8250(e,t,n){var r=n(9753),i=n(5681),o=n(88),a=n(4732),l=n(9068);function s(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=i,s.prototype.get=o,s.prototype.has=a,s.prototype.set=l,e.exports=s},9413(e,t,n){e.exports=n(4715)(n(8942),"Promise")},4512(e,t,n){e.exports=n(4715)(n(8942),"Set")},3212(e,t,n){var r=n(8250),i=n(1877),o=n(8006);function a(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new r;++t<n;)this.add(e[t])}a.prototype.add=a.prototype.push=i,a.prototype.has=o,e.exports=a},1340(e,t,n){var r=n(1386),i=n(4103),o=n(1779),a=n(4162),l=n(7462),s=n(6638);function u(e){var t=this.__data__=new r(e);this.size=t.size}u.prototype.clear=i,u.prototype.delete=o,u.prototype.get=a,u.prototype.has=l,u.prototype.set=s,e.exports=u},5650(e,t,n){e.exports=n(8942).Symbol},1623(e,t,n){e.exports=n(8942).Uint8Array},9270(e,t,n){e.exports=n(4715)(n(8942),"WeakMap")},9968(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}},9847(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var a=e[n];t(a,n,e)&&(o[i++]=a)}return o}},358(e,t,n){var r=n(6137),i=n(3283),o=n(3142),a=n(5853),l=n(9632),s=n(8666),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=o(e),c=!n&&i(e),d=!n&&!c&&a(e),f=!n&&!c&&!d&&s(e),p=n||c||d||f,m=p?r(e.length,String):[],h=m.length;for(var g in e)(t||u.call(e,g))&&!(p&&("length"==g||d&&("offset"==g||"parent"==g)||f&&("buffer"==g||"byteLength"==g||"byteOffset"==g)||l(g,h)))&&m.push(g);return m}},5111(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}},1129(e){e.exports=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}},6465(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}},7034(e,t,n){var r=n(6285);e.exports=function(e,t){for(var n=e.length;n--;)if(r(e[n][0],t))return n;return -1}},4570(e,t,n){var r=n(7170);e.exports=n(5770)(r)},4661(e,t,n){var r=n(4570);e.exports=function(e,t){var n=[];return r(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}},7250(e){e.exports=function(e,t,n,r){for(var i=e.length,o=n+(r?1:-1);r?o--:++o<i;)if(t(e[o],o,e))return o;return -1}},5636(e,t,n){e.exports=n(6596)()},7170(e,t,n){var r=n(5636),i=n(1211);e.exports=function(e,t){return e&&r(e,t,i)}},7923(e,t,n){var r=n(3526),i=n(6040);e.exports=function(e,t){t=r(t,e);for(var n=0,o=t.length;null!=e&&n<o;)e=e[i(t[n++])];return n&&n==o?e:void 0}},8244(e,t,n){var r=n(1129),i=n(3142);e.exports=function(e,t,n){var o=t(e);return i(e)?o:r(o,n(e))}},7379(e,t,n){var r=n(5650),i=n(8870),o=n(9005),a=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":a&&a in Object(e)?i(e):o(e)}},3636(e){e.exports=function(e,t){return null!=e&&t in Object(e)}},6027(e,t,n){var r=n(7379),i=n(547);e.exports=function(e){return i(e)&&"[object Arguments]"==r(e)}},4687(e,t,n){var r=n(353),i=n(547);e.exports=function e(t,n,o,a,l){return t===n||(null!=t&&null!=n&&(i(t)||i(n))?r(t,n,o,a,e,l):t!=t&&n!=n)}},353(e,t,n){var r=n(1340),i=n(3934),o=n(8861),a=n(1182),l=n(8486),s=n(3142),u=n(5853),c=n(8666),d="[object Arguments]",f="[object Array]",p="[object Object]",m=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,h,g,y){var v=s(e),b=s(t),_=v?f:l(e),w=b?f:l(t);_=_==d?p:_,w=w==d?p:w;var x=_==p,E=w==p,k=_==w;if(k&&u(e)){if(!u(t))return!1;v=!0,x=!1}if(k&&!x)return y||(y=new r),v||c(e)?i(e,t,n,h,g,y):o(e,t,_,n,h,g,y);if(!(1&n)){var S=x&&m.call(e,"__wrapped__"),O=E&&m.call(t,"__wrapped__");if(S||O){var D=S?e.value():e,C=O?t.value():t;return y||(y=new r),g(D,C,n,h,y)}}return!!k&&(y||(y=new r),a(e,t,n,h,g,y))}},8330(e,t,n){var r=n(1340),i=n(4687);e.exports=function(e,t,n,o){var a=n.length,l=a,s=!o;if(null==e)return!l;for(e=Object(e);a--;){var u=n[a];if(s&&u[2]?u[1]!==e[u[0]]:!(u[0]in e))return!1}for(;++a<l;){var c=(u=n[a])[0],d=e[c],f=u[1];if(s&&u[2]){if(void 0===d&&!(c in e))return!1}else{var p=new r;if(o)var m=o(d,f,c,e,t,p);if(!(void 0===m?i(f,d,3,o,p):m))return!1}}return!0}},9624(e,t,n){var r=n(3655),i=n(4759),o=n(1580),a=n(4066),l=/^\[object .+?Constructor\]$/,s=Object.prototype,u=Function.prototype.toString,c=s.hasOwnProperty,d=RegExp("^"+u.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!o(e)||i(e))&&(r(e)?d:l).test(a(e))}},674(e,t,n){var r=n(7379),i=n(5387),o=n(547),a={};a["[object Float32Array]"]=a["[object Float64Array]"]=a["[object Int8Array]"]=a["[object Int16Array]"]=a["[object Int32Array]"]=a["[object Uint8Array]"]=a["[object Uint8ClampedArray]"]=a["[object Uint16Array]"]=a["[object Uint32Array]"]=!0,a["[object Arguments]"]=a["[object Array]"]=a["[object ArrayBuffer]"]=a["[object Boolean]"]=a["[object DataView]"]=a["[object Date]"]=a["[object Error]"]=a["[object Function]"]=a["[object Map]"]=a["[object Number]"]=a["[object Object]"]=a["[object RegExp]"]=a["[object Set]"]=a["[object String]"]=a["[object WeakMap]"]=!1,e.exports=function(e){return o(e)&&i(e.length)&&!!a[r(e)]}},3334(e,t,n){var r=n(6526),i=n(2343),o=n(2053),a=n(3142),l=n(3282);e.exports=function(e){return"function"==typeof e?e:null==e?o:"object"==typeof e?a(e)?i(e[0],e[1]):r(e):l(e)}},195(e,t,n){var r=n(4882),i=n(8121),o=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=[];for(var n in Object(e))o.call(e,n)&&"constructor"!=n&&t.push(n);return t}},6526(e,t,n){var r=n(8330),i=n(4367),o=n(3904);e.exports=function(e){var t=i(e);return 1==t.length&&t[0][2]?o(t[0][0],t[0][1]):function(n){return n===e||r(n,e,t)}}},2343(e,t,n){var r=n(4687),i=n(6123),o=n(7276),a=n(5187),l=n(7267),s=n(3904),u=n(6040);e.exports=function(e,t){return a(e)&&l(t)?s(u(e),t):function(n){var a=i(n,e);return void 0===a&&a===t?o(n,e):r(t,a,3)}}},2762(e){e.exports=function(e){return function(t){return null==t?void 0:t[e]}}},8880(e,t,n){var r=n(7923);e.exports=function(e){return function(t){return r(t,e)}}},6137(e){e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},2291(e,t,n){var r=n(5650),i=n(5111),o=n(3142),a=n(1187),l=1/0,s=r?r.prototype:void 0,u=s?s.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(o(t))return i(t,e)+"";if(a(t))return u?u.call(t):"";var n=t+"";return"0"==n&&1/t==-l?"-0":n}},6403(e,t,n){var r=n(2945),i=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(i,""):e}},9460(e){e.exports=function(e){return function(t){return e(t)}}},5568(e){e.exports=function(e,t){return e.has(t)}},3997(e,t,n){var r=n(2053);e.exports=function(e){return"function"==typeof e?e:r}},3526(e,t,n){var r=n(3142),i=n(5187),o=n(6493),a=n(5243);e.exports=function(e,t){return r(e)?e:i(e,t)?[e]:o(a(e))}},1950(e,t,n){e.exports=n(8942)["__core-js_shared__"]},5770(e,t,n){var r=n(6529);e.exports=function(e,t){return function(n,i){if(null==n)return n;if(!r(n))return e(n,i);for(var o=n.length,a=t?o:-1,l=Object(n);(t?a--:++a<o)&&!1!==i(l[a],a,l););return n}}},6596(e){e.exports=function(e){return function(t,n,r){for(var i=-1,o=Object(t),a=r(t),l=a.length;l--;){var s=a[e?l:++i];if(!1===n(o[s],s,o))break}return t}}},3934(e,t,n){var r=n(3212),i=n(6465),o=n(5568);e.exports=function(e,t,n,a,l,s){var u=1&n,c=e.length,d=t.length;if(c!=d&&!(u&&d>c))return!1;var f=s.get(e),p=s.get(t);if(f&&p)return f==t&&p==e;var m=-1,h=!0,g=2&n?new r:void 0;for(s.set(e,t),s.set(t,e);++m<c;){var y=e[m],v=t[m];if(a)var b=u?a(v,y,m,t,e,s):a(y,v,m,e,t,s);if(void 0!==b){if(b)continue;h=!1;break}if(g){if(!i(t,function(e,t){if(!o(g,t)&&(y===e||l(y,e,n,a,s)))return g.push(t)})){h=!1;break}}else if(!(y===v||l(y,v,n,a,s))){h=!1;break}}return s.delete(e),s.delete(t),h}},8861(e,t,n){var r=n(5650),i=n(1623),o=n(6285),a=n(3934),l=n(5894),s=n(9828),u=r?r.prototype:void 0,c=u?u.valueOf:void 0;e.exports=function(e,t,n,r,u,d,f){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)break;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":if(e.byteLength!=t.byteLength||!d(new i(e),new i(t)))break;return!0;case"[object Boolean]":case"[object Date]":case"[object Number]":return o(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var p=l;case"[object Set]":var m=1&r;if(p||(p=s),e.size!=t.size&&!m)break;var h=f.get(e);if(h)return h==t;r|=2,f.set(e,t);var g=a(p(e),p(t),r,u,d,f);return f.delete(e),g;case"[object Symbol]":if(c)return c.call(e)==c.call(t)}return!1}},1182(e,t,n){var r=n(393),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,o,a,l){var s=1&n,u=r(e),c=u.length;if(c!=r(t).length&&!s)return!1;for(var d=c;d--;){var f=u[d];if(!(s?f in t:i.call(t,f)))return!1}var p=l.get(e),m=l.get(t);if(p&&m)return p==t&&m==e;var h=!0;l.set(e,t),l.set(t,e);for(var g=s;++d<c;){var y=e[f=u[d]],v=t[f];if(o)var b=s?o(v,y,f,t,e,l):o(y,v,f,e,t,l);if(!(void 0===b?y===v||a(y,v,n,o,l):b)){h=!1;break}g||(g="constructor"==f)}if(h&&!g){var _=e.constructor,w=t.constructor;_!=w&&"constructor"in e&&"constructor"in t&&!("function"==typeof _&&_ instanceof _&&"function"==typeof w&&w instanceof w)&&(h=!1)}return l.delete(e),l.delete(t),h}},4967(e,t,n){e.exports="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g},393(e,t,n){var r=n(8244),i=n(7979),o=n(1211);e.exports=function(e){return r(e,o,i)}},4700(e,t,n){var r=n(9067);e.exports=function(e,t){var n=e.__data__;return r(t)?n["string"==typeof t?"string":"hash"]:n.map}},4367(e,t,n){var r=n(7267),i=n(1211);e.exports=function(e){for(var t=i(e),n=t.length;n--;){var o=t[n],a=e[o];t[n]=[o,a,r(a)]}return t}},4715(e,t,n){var r=n(9624),i=n(155);e.exports=function(e,t){var n=i(e,t);return r(n)?n:void 0}},8870(e,t,n){var r=n(5650),i=Object.prototype,o=i.hasOwnProperty,a=i.toString,l=r?r.toStringTag:void 0;e.exports=function(e){var t=o.call(e,l),n=e[l];try{e[l]=void 0;var r=!0}catch(e){}var i=a.call(e);return r&&(t?e[l]=n:delete e[l]),i}},7979(e,t,n){var r=n(9847),i=n(9306),o=Object.prototype.propertyIsEnumerable,a=Object.getOwnPropertySymbols;e.exports=a?function(e){return null==e?[]:r(a(e=Object(e)),function(t){return o.call(e,t)})}:i},8486(e,t,n){var r=n(3103),i=n(9770),o=n(9413),a=n(4512),l=n(9270),s=n(7379),u=n(4066),c="[object Map]",d="[object Promise]",f="[object Set]",p="[object WeakMap]",m="[object DataView]",h=u(r),g=u(i),y=u(o),v=u(a),b=u(l),_=s;(r&&_(new r(new ArrayBuffer(1)))!=m||i&&_(new i)!=c||o&&_(o.resolve())!=d||a&&_(new a)!=f||l&&_(new l)!=p)&&(_=function(e){var t=s(e),n="[object Object]"==t?e.constructor:void 0,r=n?u(n):"";if(r)switch(r){case h:return m;case g:return c;case y:return d;case v:return f;case b:return p}return t}),e.exports=_},155(e){e.exports=function(e,t){return null==e?void 0:e[t]}},5899(e,t,n){var r=n(3526),i=n(3283),o=n(3142),a=n(9632),l=n(5387),s=n(6040);e.exports=function(e,t,n){t=r(t,e);for(var u=-1,c=t.length,d=!1;++u<c;){var f=s(t[u]);if(!(d=null!=e&&n(e,f)))break;e=e[f]}return d||++u!=c?d:!!(c=null==e?0:e.length)&&l(c)&&a(f,c)&&(o(e)||i(e))}},3305(e,t,n){var r=n(4497);e.exports=function(){this.__data__=r?r(null):{},this.size=0}},9361(e){e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=!!t,t}},1112(e,t,n){var r=n(4497),i=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(r){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return i.call(t,e)?t[e]:void 0}},5276(e,t,n){var r=n(4497),i=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return r?void 0!==t[e]:i.call(t,e)}},5071(e,t,n){var r=n(4497);e.exports=function(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=r&&void 0===t?"__lodash_hash_undefined__":t,this}},9632(e){var t=/^(?:0|[1-9]\d*)$/;e.exports=function(e,n){var r=typeof e;return!!(n=null==n?0x1fffffffffffff:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n}},5187(e,t,n){var r=n(3142),i=n(1187),o=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!!("number"==n||"symbol"==n||"boolean"==n||null==e||i(e))||a.test(e)||!o.test(e)||null!=t&&e in Object(t)}},9067(e){e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},4759(e,t,n){var r,i=n(1950),o=(r=/[^.]+$/.exec(i&&i.keys&&i.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";e.exports=function(e){return!!o&&o in e}},4882(e){var t=Object.prototype;e.exports=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}},7267(e,t,n){var r=n(1580);e.exports=function(e){return e==e&&!r(e)}},2393(e){e.exports=function(){this.__data__=[],this.size=0}},2049(e,t,n){var r=n(7034),i=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0)&&(n==t.length-1?t.pop():i.call(t,n,1),--this.size,!0)}},7144(e,t,n){var r=n(7034);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},7452(e,t,n){var r=n(7034);e.exports=function(e){return r(this.__data__,e)>-1}},3964(e,t,n){var r=n(7034);e.exports=function(e,t){var n=this.__data__,i=r(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}},9753(e,t,n){var r=n(5098),i=n(1386),o=n(9770);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(o||i),string:new r}}},5681(e,t,n){var r=n(4700);e.exports=function(e){var t=r(this,e).delete(e);return this.size-=!!t,t}},88(e,t,n){var r=n(4700);e.exports=function(e){return r(this,e).get(e)}},4732(e,t,n){var r=n(4700);e.exports=function(e){return r(this,e).has(e)}},9068(e,t,n){var r=n(4700);e.exports=function(e,t){var n=r(this,e),i=n.size;return n.set(e,t),this.size+=+(n.size!=i),this}},5894(e){e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}},3904(e){e.exports=function(e,t){return function(n){return null!=n&&n[e]===t&&(void 0!==t||e in Object(n))}}},6853(e,t,n){var r=n(9011);e.exports=function(e){var t=r(e,function(e){return 500===n.size&&n.clear(),e}),n=t.cache;return t}},4497(e,t,n){e.exports=n(4715)(Object,"create")},8121(e,t,n){e.exports=n(3766)(Object.keys,Object)},2306(e,t,n){e=n.nmd(e);var r=n(4967),i=t&&!t.nodeType&&t,o=i&&e&&!e.nodeType&&e,a=o&&o.exports===i&&r.process,l=function(){try{var e=o&&o.require&&o.require("util").types;if(e)return e;return a&&a.binding&&a.binding("util")}catch(e){}}();e.exports=l},9005(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},3766(e){e.exports=function(e,t){return function(n){return e(t(n))}}},8942(e,t,n){var r=n(4967),i="object"==typeof self&&self&&self.Object===Object&&self;e.exports=r||i||Function("return this")()},1877(e){e.exports=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this}},8006(e){e.exports=function(e){return this.__data__.has(e)}},9828(e){e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}},4103(e,t,n){var r=n(1386);e.exports=function(){this.__data__=new r,this.size=0}},1779(e){e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},4162(e){e.exports=function(e){return this.__data__.get(e)}},7462(e){e.exports=function(e){return this.__data__.has(e)}},6638(e,t,n){var r=n(1386),i=n(9770),o=n(8250);e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var a=n.__data__;if(!i||a.length<199)return a.push([e,t]),this.size=++n.size,this;n=this.__data__=new o(a)}return n.set(e,t),this.size=n.size,this}},6493(e,t,n){var r=n(6853),i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,o=/\\(\\)?/g;e.exports=r(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(i,function(e,n,r,i){t.push(r?i.replace(o,"$1"):n||e)}),t})},6040(e,t,n){var r=n(1187),i=1/0;e.exports=function(e){if("string"==typeof e||r(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}},4066(e){var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},2945(e){var t=/\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},6285(e){e.exports=function(e,t){return e===t||e!=e&&t!=t}},7581(e,t,n){var r=n(9847),i=n(4661),o=n(3334),a=n(3142);e.exports=function(e,t){return(a(e)?r:i)(e,o(t,3))}},2154(e,t,n){var r=n(7250),i=n(3334),o=n(7642),a=Math.max;e.exports=function(e,t,n){var l=null==e?0:e.length;if(!l)return -1;var s=null==n?0:o(n);return s<0&&(s=a(l+s,0)),r(e,i(t,3),s)}},7289(e,t,n){e.exports=n(3981)},3657(e,t,n){var r=n(9968),i=n(4570),o=n(3997),a=n(3142);e.exports=function(e,t){return(a(e)?r:i)(e,o(t))}},6123(e,t,n){var r=n(7923);e.exports=function(e,t,n){var i=null==e?void 0:r(e,t);return void 0===i?n:i}},7276(e,t,n){var r=n(3636),i=n(5899);e.exports=function(e,t){return null!=e&&i(e,t,r)}},3981(e){e.exports=function(e){return e&&e.length?e[0]:void 0}},2053(e){e.exports=function(e){return e}},3283(e,t,n){var r=n(6027),i=n(547),o=Object.prototype,a=o.hasOwnProperty,l=o.propertyIsEnumerable;e.exports=r(function(){return arguments}())?r:function(e){return i(e)&&a.call(e,"callee")&&!l.call(e,"callee")}},3142(e){e.exports=Array.isArray},6529(e,t,n){var r=n(3655),i=n(5387);e.exports=function(e){return null!=e&&i(e.length)&&!r(e)}},5853(e,t,n){e=n.nmd(e);var r=n(8942),i=n(4772),o=t&&!t.nodeType&&t,a=o&&e&&!e.nodeType&&e,l=a&&a.exports===o?r.Buffer:void 0,s=l?l.isBuffer:void 0;e.exports=s||i},3655(e,t,n){var r=n(7379),i=n(1580);e.exports=function(e){if(!i(e))return!1;var t=r(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},5387(e){e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=0x1fffffffffffff}},1580(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},547(e){e.exports=function(e){return null!=e&&"object"==typeof e}},1187(e,t,n){var r=n(7379),i=n(547);e.exports=function(e){return"symbol"==typeof e||i(e)&&"[object Symbol]"==r(e)}},8666(e,t,n){var r=n(674),i=n(9460),o=n(2306),a=o&&o.isTypedArray;e.exports=a?i(a):r},1211(e,t,n){var r=n(358),i=n(195),o=n(6529);e.exports=function(e){return o(e)?r(e):i(e)}},8087(e){e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},9011(e,t,n){var r=n(8250);function i(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw TypeError("Expected a function");var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(i.Cache||r),n}i.Cache=r,e.exports=i},3282(e,t,n){var r=n(2762),i=n(8880),o=n(5187),a=n(6040);e.exports=function(e){return o(e)?r(a(e)):i(e)}},9306(e){e.exports=function(){return[]}},4772(e){e.exports=function(){return!1}},3301(e,t,n){var r=n(6131),i=1/0;e.exports=function(e){return e?(e=r(e))===i||e===-i?(e<0?-1:1)*17976931348623157e292:e==e?e:0:0===e?e:0}},7642(e,t,n){var r=n(3301);e.exports=function(e){var t=r(e),n=t%1;return t==t?n?t-n:t:0}},6131(e,t,n){var r=n(6403),i=n(1580),o=n(1187),a=0/0,l=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(o(e))return a;if(i(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=i(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=s.test(e);return n||u.test(e)?c(e.slice(2),n?2:8):l.test(e)?a:+e}},5243(e,t,n){var r=n(2291);e.exports=function(e){return null==e?"":r(e)}},2281(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null}},6783(e,t,n){"use strict";let r=n(4517),i=n(3955),{safeRe:o,t:a}=n(2841);e.exports=(e,t)=>{if(e instanceof r)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let n=null;if((t=t||{}).rtl){let r,i=t.includePrerelease?o[a.COERCERTLFULL]:o[a.COERCERTL];for(;(r=i.exec(e))&&(!n||n.index+n[0].length!==e.length);)n&&r.index+r[0].length===n.index+n[0].length||(n=r),i.lastIndex=r.index+r[1].length+r[2].length;i.lastIndex=-1}else n=e.match(t.includePrerelease?o[a.COERCEFULL]:o[a.COERCE]);if(null===n)return null;let l=n[2],s=n[3]||"0",u=n[4]||"0",c=t.includePrerelease&&n[5]?`-${n[5]}`:"",d=t.includePrerelease&&n[6]?`+${n[6]}`:"";return i(`${l}.${s}.${u}${c}${d}`,t)}},6106(e,t,n){"use strict";let r=n(4517);e.exports=(e,t,n)=>{let i=new r(e,n),o=new r(t,n);return i.compare(o)||i.compareBuild(o)}},2132(e,t,n){"use strict";let r=n(7851);e.exports=(e,t)=>r(e,t,!0)},3269(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e,null,!0),i=r(t,null,!0),o=n.compare(i);if(0===o)return null;let a=o>0,l=a?n:i,s=a?i:n,u=!!l.prerelease.length;if(s.prerelease.length&&!u){if(!s.patch&&!s.minor)return"major";if(0===s.compareMain(l))return s.minor&&!s.patch?"minor":"patch"}let c=u?"pre":"";return n.major!==i.major?c+"major":n.minor!==i.minor?c+"minor":n.patch!==i.patch?c+"patch":"prerelease"}},8868(e,t,n){"use strict";let r=n(4517);e.exports=(e,t,n,i,o)=>{"string"==typeof n&&(o=i,i=n,n=void 0);try{return new r(e instanceof r?e.version:e,n).inc(t,i,o).version}catch(e){return null}}},6381(e,t,n){"use strict";let r=n(4517);e.exports=(e,t)=>new r(e,t).major},1353(e,t,n){"use strict";let r=n(4517);e.exports=(e,t)=>new r(e,t).minor},3955(e,t,n){"use strict";let r=n(4517);e.exports=(e,t,n=!1)=>{if(e instanceof r)return e;try{return new r(e,t)}catch(e){if(!n)return null;throw e}}},6082(e,t,n){"use strict";let r=n(4517);e.exports=(e,t)=>new r(e,t).patch},9428(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e,t);return n&&n.prerelease.length?n.prerelease:null}},7555(e,t,n){"use strict";let r=n(7851);e.exports=(e,t,n)=>r(t,e,n)},3810(e,t,n){"use strict";let r=n(6106);e.exports=(e,t)=>e.sort((e,n)=>r(n,e,t))},4042(e,t,n){"use strict";let r=n(6106);e.exports=(e,t)=>e.sort((e,n)=>r(e,n,t))},8474(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e,t);return n?n.version:null}},2722(e,t,n){"use strict";let r=n(2841),i=n(9543),o=n(4517),a=n(3806),l=n(3955),s=n(8474),u=n(2281),c=n(8868),d=n(3269),f=n(6381),p=n(1353),m=n(6082),h=n(9428),g=n(7851),y=n(7555),v=n(2132),b=n(6106),_=n(4042),w=n(3810),x=n(9761),E=n(1262),k=n(8848),S=n(8220),O=n(2386),D=n(9639),C=n(4004),F=n(6783),A=n(1565),P=n(7476),T=n(7229),V=n(6364),M=n(5039),j=n(5357),I=n(1280),N=n(7403),L=n(8854),q=n(7226),R=n(7183),$=n(8623);e.exports={parse:l,valid:s,clean:u,inc:c,diff:d,major:f,minor:p,patch:m,prerelease:h,compare:g,rcompare:y,compareLoose:v,compareBuild:b,sort:_,rsort:w,gt:x,lt:E,eq:k,neq:S,gte:O,lte:D,cmp:C,coerce:F,Comparator:A,Range:P,satisfies:T,toComparators:V,maxSatisfying:M,minSatisfying:j,minVersion:I,validRange:N,outside:L,gtr:q,ltr:R,intersects:$,simplifyRange:n(6486),subset:n(583),SemVer:o,re:r.re,src:r.src,tokens:r.t,SEMVER_SPEC_VERSION:i.SEMVER_SPEC_VERSION,RELEASE_TYPES:i.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}},7226(e,t,n){"use strict";let r=n(8854);e.exports=(e,t,n)=>r(e,t,">",n)},8623(e,t,n){"use strict";let r=n(7476);e.exports=(e,t,n)=>(e=new r(e,n),t=new r(t,n),e.intersects(t,n))},7183(e,t,n){"use strict";let r=n(8854);e.exports=(e,t,n)=>r(e,t,"<",n)},5039(e,t,n){"use strict";let r=n(4517),i=n(7476);e.exports=(e,t,n)=>{let o=null,a=null,l=null;try{l=new i(t,n)}catch(e){return null}return e.forEach(e=>{l.test(e)&&(!o||-1===a.compare(e))&&(a=new r(o=e,n))}),o}},5357(e,t,n){"use strict";let r=n(4517),i=n(7476);e.exports=(e,t,n)=>{let o=null,a=null,l=null;try{l=new i(t,n)}catch(e){return null}return e.forEach(e=>{l.test(e)&&(!o||1===a.compare(e))&&(a=new r(o=e,n))}),o}},1280(e,t,n){"use strict";let r=n(4517),i=n(7476),o=n(9761);e.exports=(e,t)=>{e=new i(e,t);let n=new r("0.0.0");if(e.test(n)||(n=new r("0.0.0-0"),e.test(n)))return n;n=null;for(let t=0;t<e.set.length;++t){let i=e.set[t],a=null;i.forEach(e=>{let t=new r(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":(!a||o(t,a))&&(a=t);break;case"<":case"<=":break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),a&&(!n||o(n,a))&&(n=a)}return n&&e.test(n)?n:null}},8854(e,t,n){"use strict";let r=n(4517),i=n(1565),{ANY:o}=i,a=n(7476),l=n(7229),s=n(9761),u=n(1262),c=n(9639),d=n(2386);e.exports=(e,t,n,f)=>{let p,m,h,g,y;switch(e=new r(e,f),t=new a(t,f),n){case">":p=s,m=c,h=u,g=">",y=">=";break;case"<":p=u,m=d,h=s,g="<",y="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(l(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let r=t.set[n],a=null,l=null;if(r.forEach(e=>{e.semver===o&&(e=new i(">=0.0.0")),a=a||e,l=l||e,p(e.semver,a.semver,f)?a=e:h(e.semver,l.semver,f)&&(l=e)}),a.operator===g||a.operator===y||(!l.operator||l.operator===g)&&m(e,l.semver)||l.operator===y&&h(e,l.semver))return!1}return!0}},6486(e,t,n){"use strict";let r=n(7229),i=n(7851);e.exports=(e,t,n)=>{let o=[],a=null,l=null,s=e.sort((e,t)=>i(e,t,n));for(let e of s)r(e,t,n)?(l=e,a||(a=e)):(l&&o.push([a,l]),l=null,a=null);a&&o.push([a,null]);let u=[];for(let[e,t]of o)e===t?u.push(e):t||e!==s[0]?t?e===s[0]?u.push(`<=${t}`):u.push(`${e} - ${t}`):u.push(`>=${e}`):u.push("*");let c=u.join(" || "),d="string"==typeof t.raw?t.raw:String(t);return c.length<d.length?c:t}},583(e,t,n){"use strict";let r=n(7476),i=n(1565),{ANY:o}=i,a=n(7229),l=n(7851),s=[new i(">=0.0.0-0")],u=[new i(">=0.0.0")],c=(e,t,n)=>{let r,i,c,p,m,h,g;if(e===t)return!0;if(1===e.length&&e[0].semver===o)if(1===t.length&&t[0].semver===o)return!0;else e=n.includePrerelease?s:u;if(1===t.length&&t[0].semver===o)if(n.includePrerelease)return!0;else t=u;let y=new Set;for(let t of e)">"===t.operator||">="===t.operator?r=d(r,t,n):"<"===t.operator||"<="===t.operator?i=f(i,t,n):y.add(t.semver);if(y.size>1)return null;if(r&&i&&((c=l(r.semver,i.semver,n))>0||0===c&&(">="!==r.operator||"<="!==i.operator)))return null;for(let e of y){if(r&&!a(e,String(r),n)||i&&!a(e,String(i),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let v=!!i&&!n.includePrerelease&&!!i.semver.prerelease.length&&i.semver,b=!!r&&!n.includePrerelease&&!!r.semver.prerelease.length&&r.semver;for(let e of(v&&1===v.prerelease.length&&"<"===i.operator&&0===v.prerelease[0]&&(v=!1),t)){if(g=g||">"===e.operator||">="===e.operator,h=h||"<"===e.operator||"<="===e.operator,r){if(b&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===b.major&&e.semver.minor===b.minor&&e.semver.patch===b.patch&&(b=!1),">"===e.operator||">="===e.operator){if((p=d(r,e,n))===e&&p!==r)return!1}else if(">="===r.operator&&!a(r.semver,String(e),n))return!1}if(i){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),"<"===e.operator||"<="===e.operator){if((m=f(i,e,n))===e&&m!==i)return!1}else if("<="===i.operator&&!a(i.semver,String(e),n))return!1}if(!e.operator&&(i||r)&&0!==c)return!1}return(!r||!h||!!i||0===c)&&(!i||!g||!!r||0===c)&&!b&&!v&&!0},d=(e,t,n)=>{if(!e)return t;let r=l(e.semver,t.semver,n);return r>0?e:r<0||">"===t.operator&&">="===e.operator?t:e},f=(e,t,n)=>{if(!e)return t;let r=l(e.semver,t.semver,n);return r<0?e:r>0||"<"===t.operator&&"<="===e.operator?t:e};e.exports=(e,t,n={})=>{if(e===t)return!0;e=new r(e,n),t=new r(t,n);let i=!1;e:for(let r of e.set){for(let e of t.set){let t=c(r,e,n);if(i=i||null!==t,t)continue e}if(i)return!1}return!0}},6364(e,t,n){"use strict";let r=n(7476);e.exports=(e,t)=>new r(e,t).set.map(e=>e.map(e=>e.value).join(" ").trim().split(" "))},7403(e,t,n){"use strict";let r=n(7476);e.exports=(e,t)=>{try{return new r(e,t).range||"*"}catch(e){return null}}},8052(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var n=null;if(!e||"string"!=typeof e)return n;var r=(0,i.default)(e),o="function"==typeof t;return r.forEach(function(e){if("declaration"===e.type){var r=e.property,i=e.value;o?t(r,i,e):i&&((n=n||{})[r]=i)}}),n};var i=r(n(5937))}}]);
5
+ failing expression: ${e}`)}return null}function tf(e,t,n,r){let{myValue:i,patient:o}=r,{sex:a,age:l}=o??{};"field"===e.type&&void 0===i&&e.value&&(i=n[e.value.id]);let s=new tl;s.putObject("prevEnc",{value:r.previousEncounter||{obs:[]},getValue(e){return this.value.obs.find(t=>t.concept.uuid==e)}});let u=r?.visit??{},c=u?.visitType||{uuid:""},d=c.uuid??"",f={isEmpty:eU.A};return{...new to(e,o,t,n),...aY().expressionHelpers,...r,...n,patient:o,myValue:i,sex:a,age:l,HD:s,visit:u,visitType:c,visitTypeUuid:d,_:f}}function tp(e){let t=function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t}(e);if(ts.has(t))return ts.get(t);let n=(0,s.compile)(e);return ts.set(t,n),n}function tm(e,t,n){for(let r of(0,s.extractVariableNames)(e)){let e=n.find(e=>e.id===r);e&&ta(t,e)}}function th(e,t,n,r){return"embedded-view"==r||("automatic"==e?"maximized"==n&&t.endsWith("desktop"):"single-line"==e)}function tg(e,t,n){if("object"!=typeof e.required)return!1;let{referenceQuestionAnswers:r,referenceQuestionId:i}=e.required,o=t.find(e=>e.id==i);return!!o&&((o.fieldDependents||(o.fieldDependents=new Set)).add(e.id),r?.includes(n[i]))}function ty(e,t,n,r,i,o,a){let{value:l,type:s}=e,u=o(l.hide?.hideWhenExpression,e,t,n,{mode:r,patient:i});e.value.isHidden=u,"field"==s&&e.value?.questions?.length&&e.value?.questions.forEach(e=>{e.isParentHidden=u}),"page"==s&&l.sections.forEach(e=>{e.isParentHidden=u,tv(u,e,t,a)}),"section"==s&&tv(u,l,t,a)}function tv(e,t,n,r){let i=t.questions.map(e=>e.id);n.filter(e=>i.includes(e.id)).forEach(t=>{t.isParentHidden=e,"group"==t.questionOptions.rendering&&t.questions.forEach(t=>{t.isParentHidden=e}),r?.(t)})}function tb(e,t){if(!e?.includes(":"))return t?.find(t=>t.uuid===e);{let[n,r]=e.split(":");return t?.find(e=>e?.conceptMappings?.find(e=>e?.conceptReferenceTerm?.conceptSource?.name.toUpperCase()===n.toUpperCase()&&e?.conceptReferenceTerm?.code.toUpperCase()===r.toUpperCase()))}}function t_(e,t=!1){let n=document.getElementById(e);n?.scrollIntoView({behavior:"smooth",block:"start",inline:"center"}),t&&n?.focus()}function tw(e){return!e.isHidden&&(e.sections?.some(e=>!e.isHidden&&e.questions?.some(e=>!e.isHidden))??!1)}var tx=n(8059);function tE(e,t,n,r){let i=[],o=[];if(e.meta.submission?.unspecified)return{errors:[],warnings:[]};try{e.validators.forEach(a=>{let l=n[a.type]?.validate?.(e,t,{...a,...r});l&&l.forEach(e=>{"error"===e.resultType?i.push(e):"warning"===e.resultType&&o.push(e)})})}catch(e){console.error(e)}return{errors:i,warnings:o}}var tk=n(1809);let tS=d().createContext(void 0),tO=({methods:e,children:t,...n})=>d().createElement(tS.Provider,{value:{...n,methods:e}},t),tD=()=>{let e=d().useContext(tS);if(!e)throw Error("FormProviderContext must be used within a FormProviderContext");return e},tC=()=>{let{t:e}=(0,eO.useTranslation)();return d().createElement("div",null,d().createElement("span",{className:"-esm-form-engine__value__empty___hEe5L"},"(",e("blank","Blank"),")"))},tF=({value:e})=>Array.isArray(e)?d().createElement(tA,{valueArray:e}):d().createElement("div",{className:"-esm-form-engine__value__value___ltyQT"},e),tA=({valueArray:e})=>d().createElement("ul",null,e.map(e=>d().createElement("li",{className:"-esm-form-engine__value__item___2GHPw"},e))),tP=({previousValue:e,displayText:t,field:n,hideHeader:r,onAfterChange:i})=>{let{t:o}=(0,eO.useTranslation)(),{methods:{setValue:a}}=tD();return d().createElement("div",{className:"-esm-form-engine__previous-value-review__formField___usT6m"},d().createElement("div",{className:"-esm-form-engine__previous-value-review__row___uDsJL"},!r&&d().createElement("div",null,o("previousValue","Previous value:")),d().createElement("div",{className:"-esm-form-engine__previous-value-review__value___ySFyl"},d().createElement(tF,{value:t}))),d().createElement("div",{className:"-esm-form-engine__previous-value-review__reuseButton___n4XbJ",role:"button",tabIndex:0,onClick:t=>{t.preventDefault(),a(n.id,e),i(e)}},o("reuseValue","Reuse value")))},tT=({field:e,fieldValue:t,setFieldValue:n,onAfterChange:r})=>{let{t:i}=(0,eO.useTranslation)(),[o,a]=(0,c.useState)(!1),{sessionMode:l,updateFormField:s}=tD();(0,c.useEffect)(()=>{eV(t)&&"edit"===l&&(a(!0),e.meta.submission||(e.meta.submission={}),e.meta.submission.unspecified=!0)},[]),(0,c.useEffect)(()=>{e.meta.submission?.unspecified&&(e.meta.submission.newValue||!eV(t))&&(e.meta.submission.unspecified=!1,s(e)),a(!!e.meta.submission?.unspecified)},[e.meta?.submission,e.meta.submission?.unspecified,t]);let u=(0,c.useCallback)(t=>{let i=e.questionOptions.rendering;if(t.target.checked){a(!0);let t="checkbox"===i?[]:"";eN(e),e.meta.submission.unspecified=!0,e.meta.submission.errors=[],e.meta.submission.warnings=[],s(e),n(t),r(t)}else a(!1),e.meta.submission.unspecified=!1,s(e)},[e.questionOptions.rendering]);return!e.isHidden&&!(0,tk.H)(e.readonly)&&!eR(l)&&d().createElement("div",{className:"-esm-form-engine__unspecified__unspecified___kJgif"},d().createElement(g.Checkbox,{id:`${e.id}-unspecified`,labelText:i("unspecified","Unspecified"),value:i("unspecified","Unspecified"),onChange:u,checked:o,disabled:e.isDisabled}))},tV=({fieldId:e,valueAdapter:t,repeatOptions:n})=>{var r,i,o;let[a,l]=(0,c.useState)(null),[f,p]=(0,c.useState)([]),[m,g]=(0,c.useState)([]),[y,v]=(0,c.useState)(null),b=tD(),_=!1;try{let e=(0,s.useConfig)({externalModuleName:"@openmrs/esm-form-engine-app"});_=e?.hideUnansweredQuestionsInReadonlyForms??!1}catch(e){console.warn("Failed to load @openmrs/esm-form engine-app config - using hideUnansweredQuestionsInReadonlyForms=false (empty fields will be visible in readonly mode): ",e)}let{methods:{control:w,getValues:x,getFieldState:E},patient:k,sessionMode:S,formFields:O,formFieldValidators:D,addInvalidField:C,removeInvalidField:F,updateFormField:A}=b,P=(0,c.useRef)(null),T=Z({control:w,name:e,exact:!0}),V=(0,c.useMemo)(()=>O.find(t=>t.id===e),[e,O]);(0,c.useEffect)(()=>{var e,t;if(eI(V,"repeating")&&n?.targetRendering?a$(n.targetRendering).then(e=>{e&&l({value:e})}):("obs"==(t=e=V).type&&!t.questionOptions.concept&&"fixed-value"!==t.questionOptions.rendering&&!eI(e,"file")?(e.disabled=!0,e.isDisabled=!0,a$("text")):a$(e.questionOptions.rendering)).then(e=>{e&&l({value:e})}),"enter"===S&&(V.historicalExpression||b.previousDomainObjectValue))try{b.processor.getHistoricalValue(V,b).then(e=>{v(e)})}catch(e){console.error(e)}},[]),(0,c.useEffect)(()=>{let{isDirty:e,isTouched:n}=E(V.id),{submission:r,unspecified:i}=V.meta,{calculate:o,defaultValue:a}=V.questionOptions;!eV(T)&&!r?.newValue&&!e&&!i&&(o?.calculateExpression||a)&&t.transformFieldValue(V,T,b);let l=P.current;P.current=null,(e||n)&&(!l||!(0,h.A)(l.value,T))&&M(T)},[T]),(0,c.useEffect)(()=>{V.meta.submission?.errors&&p(V.meta.submission.errors),V.meta.submission?.warnings&&g(V.meta.submission.warnings),V.meta.submission?.unspecified&&(p([]),F(V.id))},[V.meta.submission]);let M=e=>{V.meta.submission?.unspecified&&!eV(e)&&(V.meta.submission.unspecified=!1);let{errors:n,warnings:r}=tE(V,e,D,{formFields:O,values:x(),expressionContext:{patient:k,mode:S}});if(V.meta.submission&&(V.meta.submission.errors=void 0,V.meta.submission.warnings=void 0),f.length&&!n.length?(F(V.id),p([])):n.length&&(p(n),C(V)),n.length||t.transformFieldValue(V,e,b),g(r),!function(e,t){let{methods:{getValues:n}}=t,r=n();u.FU.includes(e.questionOptions.rendering)&&function(e,t,n){let{sessionMode:r,formFields:i,patient:o,visit:a}=n;e.questionOptions.answers.forEach(n=>{let l=n.disable?.disableWhenExpression;l&&l.includes("myValue")&&(n.disable.isDisabled=tc(n.disable?.disableWhenExpression,{value:e,type:"field"},i,t,{mode:r,patient:o,visit:a}))})}(e,r,t),function(e,t,n){let{sessionMode:r,formFields:i,patient:o,formFieldValidators:a,formJson:l,methods:{setValue:s},updateFormField:u,setForm:c,visit:d}=n,f=!1;e.fieldDependents&&e.fieldDependents.forEach(e=>{let c=i.find(t=>t.id==e);if(c){if(c.questionOptions.calculate?.calculateExpression&&td(c.questionOptions.calculate.calculateExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d}).then(e=>{s(c.id,e);let{errors:a,warnings:l}=tE(c,e,n.formFieldValidators,{formFields:i,values:t,expressionContext:{patient:o,mode:r}});c.meta.submission||(c.meta.submission={}),c.meta.submission.errors=a,c.meta.submission.warnings=l,a.length||n.formFieldAdapters[c.type].transformFieldValue(c,e,n),u(c)}).catch(e=>{(0,tx.N)(e,"Error evaluating calculate expression")}),c.hide){let e,n=(e=l.pages.find(e=>c.meta.pageId===e.id),e?.sections.find(e=>e.questions.find(e=>e.id===c.id))),a=n?.questions.some(e=>!e.isHidden);if(ty({value:c,type:"field"},i,t,r,o,tc,u),n){n.questions=n?.questions.map(e=>e.id===c.id?c:e);let e=c.isHidden,t=[...n.questions,c].some(e=>!e.isHidden);a||e?a&&!t&&(n.isHidden=!0,f=!0):(n.isHidden=!1,f=!0)}}if("object"==typeof c.disabled&&c.disabled.disableWhenExpression&&(c.isDisabled=function(e,t,n,r,i,o){let{value:a}=e;return o(a.disabled?.disableWhenExpression,e,t,n,{mode:r,patient:i})}({value:c,type:"field"},i,t,r,o,tc)),"object"==typeof c.required&&c.required?.type==="conditionalRequired"&&(c.isRequired=tg(c,i,t)),c.validators?.some(e=>"conditionalAnswered"===e.type)){let e=c.validators?.find(e=>"conditionalAnswered"===e.type),n=a.conditionalAnswered.validate(c,c.meta.submission?.newValue,{...e,expressionContext:{patient:o,mode:r},values:t,formFields:i});c.meta.submission={...c.meta.submission,errors:n}}c?.questionOptions.answers?.filter(e=>!eV(e.hide?.hideWhenExpression)).forEach(e=>{e.isHidden=tc(e.hide?.hideWhenExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})}),c?.questionOptions.answers?.filter(e=>!eV(e.disable?.isDisabled)).forEach(e=>{e.disable.isDisabled=tc(e.disable?.disableWhenExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})}),!c.isHidden&&c.meta.readonlyExpression&&(c.readonly=tc(c.meta.readonlyExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})),eI(c,"repeating")&&!eV(c.questionOptions.repeatOptions?.limitExpression)&&(c.questionOptions.repeatOptions.limit=tc(c.questionOptions.repeatOptions?.limitExpression,{value:c,type:"field"},i,t,{mode:r,patient:o,visit:d})),u(c)}}),e.sectionDependents&&e.sectionDependents.forEach(e=>{for(let n=0;n<l.pages.length;n++){let a=l.pages[n].sections.find(t=>t.label==e);if(a){ty({value:a,type:"section"},i,t,r,o,tc,u),f=!0;break}}}),e.pageDependents&&e.pageDependents?.forEach(e=>{ty({value:l.pages.find(t=>t.label==e),type:"page"},i,t,r,o,tc,u),f=!0}),f&&c(l)}(e,r,t)}(V,b),V.meta.groupId){let e=O.find(e=>e.id===V.meta.groupId);e&&(e.questions=e.questions.map(e=>e.id===V.id?V:e),A(e))}},j=e=>{P.current={value:e},M(e)};if(!a)return null;let I=a.value;return!n?.targetRendering&&tj(V.questionOptions.rendering)?d().createElement(I,{key:V.id,field:V,value:null,errors:f,warnings:m,setFieldValue:null}):(r=!!V.questionOptions.isTransient,i=eV(T),o=_,"embedded-view"===S&&i&&(r||o))?null:d().createElement(eF,{FallbackComponent:tM,onReset:()=>{}},d().createElement(G,{control:w,name:V.id,render:({field:{value:e,onChange:t,onBlur:n}})=>d().createElement("div",null,d().createElement(I,{key:`${V.id}-input-component`,field:V,value:e,errors:f,warnings:m,setFieldValue:e=>{t(e),j(e),n()}}),function(e){let{rendering:t}=e.questionOptions;return(0,tk.H)(e.unspecified)&&"toggle"!=t&&"group"!=t&&"repeating"!=t&&"markdown"!=t&&"extension-widget"!=t&&"workspace-launcher"!=t}(V)&&d().createElement("div",{className:"-esm-form-engine__form-field-renderer__unspecifiedContainer___MoH57"},V.unspecified&&d().createElement(tT,{key:`${V.id}-unspecified`,field:V,setFieldValue:t,onAfterChange:j,fieldValue:e})),y?.value&&d().createElement("div",null,d().createElement(tP,{key:`${V.id}-previous-value-review`,previousValue:y.value,displayText:y.display,onAfterChange:j,field:V})))}))};function tM({error:e}){let{t}=(0,eO.useTranslation)();return d().createElement(g.ToastNotification,{"aria-label":t("closesNotification","Closes notification"),caption:"",hideCloseButton:!0,lowContrast:!0,onClose:function(){},onCloseButtonClick:function(){},statusIconDescription:t("notification","Notification"),subtitle:e.message,title:t("errorRenderingField","Error rendering field")})}function tj(e){return"group"===e||"repeating"===e}let tI=({field:e,...t})=>{let{t:n}=(0,eO.useTranslation)(),{formFieldAdapters:r,formFields:i}=tD(),o=(0,c.useMemo)(()=>e.questions.map(e=>i.find(t=>t.id===e.id)).filter(e=>!e.isHidden).map((n,i)=>{let o=`${n.id}_${i}`;return n.id===e.id?d().createElement(tM,{error:Error("ObsGroup child has same id as parent question")}):"obsGroup"===n.type&&tj(n.questionOptions.rendering)?d().createElement("div",{key:o,className:m.nestedGroupContainer},d().createElement(tI,{field:n,...t})):r[n.type]?d().createElement("div",{className:p()(m.flexColumn),key:o},d().createElement("div",{className:m.groupContainer},d().createElement(tV,{fieldId:n.id,valueAdapter:r[n.type]}))):void 0}),[e,i]);return d().createElement("div",{className:m.groupContainer},o.length>1?d().createElement(g.FormGroup,{legendText:n(e.label),className:m.boldLegend},o):o)},tN=({value:e,tooltipText:t})=>d().createElement("div",{className:"-esm-form-engine__label__label___d9pB3"},d().createElement(g.DefinitionTooltip,{autoAlign:!0,tabIndex:0,definition:t??""},d().createElement("span",{className:"cds--label"},`${e}:`))),tL="-esm-form-engine__field-value-view__inlineFlexColumn___Yd9Fp",tq=({label:e,conceptName:t,value:n,isInline:r})=>d().createElement(d().Fragment,null,r?d().createElement("div",{className:"-esm-form-engine__field-value-view__inlineFlexRow___Rk2F-"},d().createElement("div",{className:tL},d().createElement(tN,{value:e,tooltipText:t})),d().createElement("div",{className:tL},eV(n)?d().createElement(tC,null):d().createElement(tF,{value:n}))):d().createElement("div",{className:"-esm-form-engine__field-value-view__readonly___4EhBN"},d().createElement("div",{className:"-esm-form-engine__field-value-view__formField___aiANn"},d().createElement(tN,{value:e,tooltipText:t}),d().createElement("div",{className:"-esm-form-engine__field-value-view__value___cgPr1"},eV(n)?d().createElement(tC,null):d().createElement(tF,{value:n}))))),tR="-esm-form-engine__content-switcher__boldedLegend___DEeyj";var t$=n(4807);let tB=({field:e,children:t})=>{let{t:n}=(0,eO.useTranslation)();return e.questionInfo?d().createElement(g.Tooltip,{autoAlign:!0,label:n(e.questionInfo)},d().createElement("div",null,t)):d().createElement(d().Fragment,null,t)},tH=({field:e,customLabel:t})=>{let{t:n}=(0,eO.useTranslation)(),r=!!e.questionInfo,i=t||n(e.label);return d().createElement(tB,{field:e},d().createElement("div",{className:"-esm-form-engine__field-label__questionLabel___mFOqM","data-testid":`${e.id}-label`},d().createElement("span",null,i),e.isRequired&&d().createElement("span",{title:n("required","Required"),className:"-esm-form-engine__field-label__required___QIc-5"},"*"),r&&d().createElement(t$.$$,{size:16,"aria-hidden":"true",className:"-esm-form-engine__field-label__tooltipIcon___vCSZl","data-testid":`${e.id}-information-icon`})))},tz=({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),[a,l]=(0,c.useState)(""),{layoutType:u,sessionMode:f,workspaceLayout:m}=tD(),h=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(f)||(0,tk.H)(e.readonly))&&th(e.inlineRendering,u,m,f),[f,e.readonly,e.inlineRendering,u,m]),y=(0,c.useCallback)(e=>{v(e,a),i(e)},[i,a]),v=(0,c.useCallback)((e,t)=>{if(!eV(t)){let[n,r]=t.split(":").map(Number);e.setHours(n??0,r??0)}},[]),b=(0,c.useCallback)(n=>{let r=n.target.value;l(r);let o="timer"===e.datePickerFormat?new Date:new Date(t);v(o,r),i(o)},[i,v,t]);(0,c.useEffect)(()=>{t&&t instanceof Date&&l([10>t.getHours()?`0${t.getHours()}`:`${t.getHours()}`,10>t.getMinutes()?`0${t.getMinutes()}`:`${t.getMinutes()}`].join(":"))},[t]);let _=(0,c.useMemo)(()=>"timer"===e.datePickerFormat?d().createElement(tH,{field:e}):d().createElement(tH,{field:e,customLabel:o("time","Time")}),[e.datePickerFormat,e.label,o]);return"view"==f||"embedded-view"==f||(0,tk.H)(e.readonly)?d().createElement(tq,{label:o(e.label),value:t instanceof Date?eH(e,t):t,conceptName:e.meta?.concept?.display,isInline:h}):!e.isHidden&&d().createElement("div",{className:"-esm-form-engine__date__datetime___z+i2e"},("calendar"===e.datePickerFormat||"both"===e.datePickerFormat)&&d().createElement("div",{className:"-esm-form-engine__date__datePickerSpacing___Lprw3"},d().createElement(g.Layer,null,d().createElement(s.OpenmrsDatePicker,{id:e.id,onChange:y,labelText:d().createElement("span",{className:"-esm-form-engine__date__datePickerLabel___gCHIg"},d().createElement(tH,{field:e})),isDisabled:e.isDisabled,isReadOnly:(0,tk.H)(e.readonly),isRequired:e.isRequired??!1,isInvalid:n.length>0,invalidText:n[0]?.message,value:t})),r.length>0?d().createElement("div",{className:"-esm-form-engine__date__datePickerWarn___GDUCO"},r[0]?.message):null),"both"===e.datePickerFormat||"timer"===e.datePickerFormat?d().createElement("div",null,d().createElement(g.Layer,null,d().createElement(g.TimePicker,{className:p()("-esm-form-engine__date__boldedLabel___cGCdn","-esm-form-engine__date__timeInput___E1vhw"),id:e.id,labelText:_,placeholder:"HH:MM",pattern:"(1[012]|[1-9]):[0-5][0-9]$",type:"time",disabled:"timer"===e.datePickerFormat?e.isDisabled:!t,invalid:n.length>0,invalidText:n[0]?.message,readOnly:(0,tk.H)(e.readonly),warning:r.length>0,warningText:r[0]?.message,value:a||(t instanceof Date?t.toLocaleDateString(window.navigator.language):t),onChange:b}))):null)},tU=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tW=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tY={};function tJ(e,t){return((t||tY).jsx?tW:tU).test(e)}let tZ=/[ \t\n\f\r]/g;function tG(e){return""===e.replace(tZ,"")}class tQ{constructor(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}}function tK(e,t){let n={},r={},i=-1;for(;++i<e.length;)Object.assign(n,e[i].property),Object.assign(r,e[i].normal);return new tQ(n,r,t)}function tX(e){return e.toLowerCase()}tQ.prototype.property={},tQ.prototype.normal={},tQ.prototype.space=null;class t0{constructor(e,t){this.property=e,this.attribute=t}}t0.prototype.space=null,t0.prototype.boolean=!1,t0.prototype.booleanish=!1,t0.prototype.overloadedBoolean=!1,t0.prototype.number=!1,t0.prototype.commaSeparated=!1,t0.prototype.spaceSeparated=!1,t0.prototype.commaOrSpaceSeparated=!1,t0.prototype.mustUseProperty=!1,t0.prototype.defined=!1;let t1=0,t2=t8(),t4=t8(),t3=t8(),t5=t8(),t6=t8(),t9=t8(),t7=t8();function t8(){return 2**++t1}let ne=Object.keys(i);class nt extends t0{constructor(e,t,n,r){let o=-1;if(super(e,t),function(e,t,n){n&&(e[t]=n)}(this,"space",r),"number"==typeof n)for(;++o<ne.length;){const e=ne[o];!function(e,t,n){n&&(e[t]=n)}(this,ne[o],(n&i[e])===i[e])}}}nt.prototype.defined=!0;let nn={}.hasOwnProperty;function nr(e){let t,n={},r={};for(t in e.properties)if(nn.call(e.properties,t)){let i=e.properties[t],o=new nt(t,e.transform(e.attributes||{},t),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(t)&&(o.mustUseProperty=!0),n[t]=o,r[tX(t)]=t,r[tX(o.attribute)]=t}return new tQ(n,r,e.space)}let ni=nr({space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase(),properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}}),no=nr({space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase(),properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function na(e,t){return t in e?e[t]:t}function nl(e,t){return na(e,t.toLowerCase())}let ns=nr({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:nl,properties:{xmlns:null,xmlnsXLink:null}}),nu=nr({transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase(),properties:{ariaActiveDescendant:null,ariaAtomic:t4,ariaAutoComplete:null,ariaBusy:t4,ariaChecked:t4,ariaColCount:t5,ariaColIndex:t5,ariaColSpan:t5,ariaControls:t6,ariaCurrent:null,ariaDescribedBy:t6,ariaDetails:null,ariaDisabled:t4,ariaDropEffect:t6,ariaErrorMessage:null,ariaExpanded:t4,ariaFlowTo:t6,ariaGrabbed:t4,ariaHasPopup:null,ariaHidden:t4,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:t6,ariaLevel:t5,ariaLive:null,ariaModal:t4,ariaMultiLine:t4,ariaMultiSelectable:t4,ariaOrientation:null,ariaOwns:t6,ariaPlaceholder:null,ariaPosInSet:t5,ariaPressed:t4,ariaReadOnly:t4,ariaRelevant:null,ariaRequired:t4,ariaRoleDescription:t6,ariaRowCount:t5,ariaRowIndex:t5,ariaRowSpan:t5,ariaSelected:t4,ariaSetSize:t5,ariaSort:null,ariaValueMax:t5,ariaValueMin:t5,ariaValueNow:t5,ariaValueText:null,role:null}}),nc=nr({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:nl,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:t9,acceptCharset:t6,accessKey:t6,action:null,allow:null,allowFullScreen:t2,allowPaymentRequest:t2,allowUserMedia:t2,alt:null,as:null,async:t2,autoCapitalize:null,autoComplete:t6,autoFocus:t2,autoPlay:t2,capture:t2,charSet:null,checked:t2,cite:null,className:t6,cols:t5,colSpan:null,content:null,contentEditable:t4,controls:t2,controlsList:t6,coords:t5|t9,crossOrigin:null,data:null,dateTime:null,decoding:null,default:t2,defer:t2,dir:null,dirName:null,disabled:t2,download:t3,draggable:t4,encType:null,enterKeyHint:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:t2,formTarget:null,headers:t6,height:t5,hidden:t2,high:t5,href:null,hrefLang:null,htmlFor:t6,httpEquiv:t6,id:null,imageSizes:null,imageSrcSet:null,inputMode:null,integrity:null,is:null,isMap:t2,itemId:null,itemProp:t6,itemRef:t6,itemScope:t2,itemType:t6,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:t2,low:t5,manifest:null,max:null,maxLength:t5,media:null,method:null,min:null,minLength:t5,multiple:t2,muted:t2,name:null,nonce:null,noModule:t2,noValidate:t2,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:t2,optimum:t5,pattern:null,ping:t6,placeholder:null,playsInline:t2,poster:null,preload:null,readOnly:t2,referrerPolicy:null,rel:t6,required:t2,reversed:t2,rows:t5,rowSpan:t5,sandbox:t6,scope:null,scoped:t2,seamless:t2,selected:t2,shape:null,size:t5,sizes:null,slot:null,span:t5,spellCheck:t4,src:null,srcDoc:null,srcLang:null,srcSet:null,start:t5,step:null,style:null,tabIndex:t5,target:null,title:null,translate:null,type:null,typeMustMatch:t2,useMap:null,value:t4,width:t5,wrap:null,align:null,aLink:null,archive:t6,axis:null,background:null,bgColor:null,border:t5,borderColor:null,bottomMargin:t5,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:t2,declare:t2,event:null,face:null,frame:null,frameBorder:null,hSpace:t5,leftMargin:t5,link:null,longDesc:null,lowSrc:null,marginHeight:t5,marginWidth:t5,noResize:t2,noHref:t2,noShade:t2,noWrap:t2,object:null,profile:null,prompt:null,rev:null,rightMargin:t5,rules:null,scheme:null,scrolling:t4,standby:null,summary:null,text:null,topMargin:t5,valueType:null,version:null,vAlign:null,vLink:null,vSpace:t5,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:t2,disableRemotePlayback:t2,prefix:null,property:null,results:t5,security:null,unselectable:null}}),nd=nr({space:"svg",attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},transform:na,properties:{about:t7,accentHeight:t5,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:t5,amplitude:t5,arabicForm:null,ascent:t5,attributeName:null,attributeType:null,azimuth:t5,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:t5,by:null,calcMode:null,capHeight:t5,className:t6,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:t5,diffuseConstant:t5,direction:null,display:null,dur:null,divisor:t5,dominantBaseline:null,download:t2,dx:null,dy:null,edgeMode:null,editable:null,elevation:t5,enableBackground:null,end:null,event:null,exponent:t5,externalResourcesRequired:null,fill:null,fillOpacity:t5,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:t9,g2:t9,glyphName:t9,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:t5,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:t5,horizOriginX:t5,horizOriginY:t5,id:null,ideographic:t5,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:t5,k:t5,k1:t5,k2:t5,k3:t5,k4:t5,kernelMatrix:t7,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:t5,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:t5,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:t5,overlineThickness:t5,paintOrder:null,panose1:null,path:null,pathLength:t5,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:t6,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:t5,pointsAtY:t5,pointsAtZ:t5,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:t7,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:t7,rev:t7,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:t7,requiredFeatures:t7,requiredFonts:t7,requiredFormats:t7,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:t5,specularExponent:t5,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:t5,strikethroughThickness:t5,string:null,stroke:null,strokeDashArray:t7,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:t5,strokeOpacity:t5,strokeWidth:null,style:null,surfaceScale:t5,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:t7,tabIndex:t5,tableValues:null,target:null,targetX:t5,targetY:t5,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:t7,to:null,transform:null,u1:null,u2:null,underlinePosition:t5,underlineThickness:t5,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:t5,values:null,vAlphabetic:t5,vMathematical:t5,vectorEffect:null,vHanging:t5,vIdeographic:t5,version:null,vertAdvY:t5,vertOriginX:t5,vertOriginY:t5,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:t5,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}}),nf=tK([no,ni,ns,nu,nc],"html"),np=tK([no,ni,ns,nu,nd],"svg"),nm=/^data[-\w.:]+$/i,nh=/-[a-z]/g,ng=/[A-Z]/g;function ny(e){return"-"+e.toLowerCase()}function nv(e){return e.charAt(1).toUpperCase()}let nb={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"};var n_=n(8052);let nw=n_.default||n_,nx=nk("end"),nE=nk("start");function nk(e){return function(t){let n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function nS(e){return e&&"object"==typeof e?"position"in e||"type"in e?nD(e.position):"start"in e||"end"in e?nD(e):"line"in e||"column"in e?nO(e):"":""}function nO(e){return nC(e&&e.line)+":"+nC(e&&e.column)}function nD(e){return nO(e&&e.start)+"-"+nO(e&&e.end)}function nC(e){return e&&"number"==typeof e?e:1}class nF extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",i={},o=!1;if(t&&(i="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?r=e:!i.cause&&e&&(o=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){const e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}const a=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file,this.message=r,this.line=a?a.line:void 0,this.name=nS(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=o&&i.cause&&"string"==typeof i.cause.stack?i.cause.stack:"",this.actual,this.expected,this.note,this.url}}nF.prototype.file="",nF.prototype.name="",nF.prototype.reason="",nF.prototype.message="",nF.prototype.stack="",nF.prototype.column=void 0,nF.prototype.line=void 0,nF.prototype.ancestors=void 0,nF.prototype.cause=void 0,nF.prototype.fatal=void 0,nF.prototype.place=void 0,nF.prototype.ruleId=void 0,nF.prototype.source=void 0;let nA={}.hasOwnProperty,nP=new Map,nT=/[A-Z]/g,nV=/-([a-z])/g,nM=new Set(["table","tbody","thead","tfoot","tr"]),nj=new Set(["td","th"]),nI="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function nN(e,t,n){var r,i,o,a,l,s,u,c,d;let f,p,m,h,g,y,v,b,_,w,x;return"element"===t.type?(r=e,i=t,o=n,p=f=r.schema,"svg"===i.tagName.toLowerCase()&&"html"===f.space&&(r.schema=np),r.ancestors.push(i),m=n$(r,i.tagName,!1),h=function(e,t){let n,r,i={};for(r in t.properties)if("children"!==r&&nA.call(t.properties,r)){let o=function(e,t,n){let r=function(e,t){let n=tX(t),r=t,i=t0;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&nm.test(t)){if("-"===t.charAt(4)){let e=t.slice(5).replace(nh,nv);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!nh.test(e)){let n=e.replace(ng,ny);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}i=nt}return new i(r,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){var i;let t;if(Array.isArray(n)&&(n=r.commaSeparated?(t={},(""===(i=n)[i.length-1]?[...i,""]:i).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()):n.join(" ").trim()),"style"===r.property){let t="object"==typeof n?n:function(e,t){let n={};try{nw(t,function(e,t){let r=e;"--"!==r.slice(0,2)&&("-ms-"===r.slice(0,4)&&(r="ms-"+r.slice(4)),r=r.replace(nV,nH)),n[r]=t})}catch(t){if(!e.ignoreInvalidStyle){let n=new nF("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:t,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=nI+"#cannot-parse-style-attribute",n}}return n}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){let t,n={};for(t in e)nA.call(e,t)&&(n[function(e){let t=e.replace(nT,nz);return"ms-"===t.slice(0,3)&&(t="-"+t),t}(t)]=e[t]);return n}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?nb[r.property]||r.property:r.attribute,n]}}(e,r,t.properties[r]);if(o){let[r,a]=o;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof a&&nj.has(t.tagName)?n=a:i[r]=a}}return n&&((i.style||(i.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=n),i}(r,i),g=nR(r,i),nM.has(i.tagName)&&(g=g.filter(function(e){return"string"!=typeof e||!("object"==typeof e?"text"===e.type&&tG(e.value):tG(e))})),nL(r,h,m,i),nq(h,g),r.ancestors.pop(),r.schema=f,r.create(i,m,h,o)):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}nB(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?(a=e,l=t,s=n,v=y=a.schema,"svg"===l.name&&"html"===y.space&&(a.schema=np),a.ancestors.push(l),b=null===l.name?a.Fragment:n$(a,l.name,!0),_=function(e,t){let n={};for(let r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let o=i.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else nB(e,t.position);else{let i,o=r.name;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,i=e.evaluater.evaluateExpression(t.expression)}else nB(e,t.position);else i=null===r.value||r.value;n[o]=i}return n}(a,l),w=nR(a,l),nL(a,_,b,l),nq(_,w),a.ancestors.pop(),a.schema=y,a.create(l,b,_,s)):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);nB(e,t.position)}(e,t):"root"===t.type?(u=e,c=t,d=n,nq(x={},nR(u,c)),u.create(c,u.Fragment,x,d)):"text"===t.type?t.value:void 0}function nL(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function nq(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function nR(e,t){let n=[],r=-1,i=e.passKeys?new Map:nP;for(;++r<t.children.length;){let o,a=t.children[r];if(e.passKeys){let e="element"===a.type?a.tagName:"mdxJsxFlowElement"===a.type||"mdxJsxTextElement"===a.type?a.name:void 0;if(e){let t=i.get(e)||0;o=e+"-"+t,i.set(e,t+1)}}let l=nN(e,a,o);void 0!==l&&n.push(l)}return n}function n$(e,t,n){let r;if(n)if(t.includes(".")){let e,n=t.split("."),i=-1;for(;++i<n.length;){let t=tJ(n[i])?{type:"Identifier",name:n[i]}:{type:"Literal",value:n[i]};e=e?{type:"MemberExpression",object:e,property:t,computed:!!(i&&"Literal"===t.type),optional:!1}:t}r=e}else r=tJ(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){let t=r.value;return nA.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);nB(e)}function nB(e,t){let n=new nF("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=nI+"#cannot-handle-mdx-estrees-without-createevaluater",n}function nH(e,t){return t.toUpperCase()}function nz(e){return"-"+e.toLowerCase()}let nU={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]};var nW=n(1085);let nY={};function nJ(e,t,n){var r;if((r=e)&&"object"==typeof r){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return nZ(e.children,t,n)}return Array.isArray(e)?nZ(e,t,n):""}function nZ(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=nJ(e[i],t,n);return r.join("")}function nG(e,t,n,r){let i,o=e.length,a=0;if(t=t<0?-t>o?0:o+t:t>o?o:t,n=n>0?n:0,r.length<1e4)(i=Array.from(r)).unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);a<r.length;)(i=r.slice(a,a+1e4)).unshift(t,0),e.splice(...i),a+=1e4,t+=1e4}function nQ(e,t){return e.length>0?(nG(e,e.length,0,t),e):t}class nK{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=null==t?1/0:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){this.setCursor(Math.trunc(e));let r=this.right.splice(this.right.length-(t||0),1/0);return n&&nX(this.left,n),r.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),nX(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),nX(this.right,e.reverse())}setCursor(e){if(e!==this.left.length&&(!(e>this.left.length)||0!==this.right.length)&&(!(e<0)||0!==this.left.length))if(e<this.left.length){let t=this.left.splice(e,1/0);nX(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);nX(this.left,t.reverse())}}}function nX(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function n0(e){let t,n,r,i,o,a,l,s={},u=-1,c=new nK(e);for(;++u<c.length;){for(;u in s;)u=s[u];if(t=c.get(u),u&&"chunkFlow"===t[1].type&&"listItemPrefix"===c.get(u-1)[1].type&&((r=0)<(a=t[1]._tokenizer.events).length&&"lineEndingBlank"===a[r][1].type&&(r+=2),r<a.length&&"content"===a[r][1].type))for(;++r<a.length&&"content"!==a[r][1].type;)"chunkText"===a[r][1].type&&(a[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===t[0])t[1].contentType&&(Object.assign(s,function(e,t){let n,r,i=e.get(t)[1],o=e.get(t)[2],a=t-1,l=[],s=i._tokenizer||o.parser[i.contentType](i.start),u=s.events,c=[],d={},f=-1,p=i,m=0,h=0,g=[0];for(;p;){for(;e.get(++a)[1]!==p;);l.push(a),!p._tokenizer&&(n=o.sliceStream(p),p.next||n.push(null),r&&s.defineSkip(p.start),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(n),p._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),r=p,p=p.next}for(p=i;++f<u.length;)"exit"===u[f][0]&&"enter"===u[f-1][0]&&u[f][1].type===u[f-1][1].type&&u[f][1].start.line!==u[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(s.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=u.slice(g[f],g[f+1]),n=l.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)d[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return d}(c,u)),u=s[u],l=!0);else if(t[1]._container){for(r=u,n=void 0;r--;)if("lineEnding"===(i=c.get(r))[1].type||"lineEndingBlank"===i[1].type)"enter"===i[0]&&(n&&(c.get(n)[1].type="lineEndingBlank"),i[1].type="lineEnding",n=r);else break;n&&(t[1].end={...c.get(n)[1].start},(o=c.slice(n,u)).unshift(t),c.splice(n,u-n+1,o))}}return nG(e,0,1/0,c.slice(0)),!l}let n1={}.hasOwnProperty,n2=ri(/[A-Za-z]/),n4=ri(/[\dA-Za-z]/),n3=ri(/[#-'*+\--9=?A-Z^-~]/);function n5(e){return null!==e&&(e<32||127===e)}let n6=ri(/\d/),n9=ri(/[\dA-Fa-f]/),n7=ri(/[!-/:-@[-`{-~]/);function n8(e){return null!==e&&e<-2}function re(e){return null!==e&&(e<0||32===e)}function rt(e){return -2===e||-1===e||32===e}let rn=ri(/\p{P}|\p{S}/u),rr=ri(/\s/);function ri(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function ro(e,t,n,r){let i=r?r-1:1/0,o=0;return function(r){return rt(r)?(e.enter(n),function r(a){return rt(a)&&o++<i?(e.consume(a),r):(e.exit(n),t(a))}(r)):t(r)}}let ra={tokenize:function(e){let t,n=e.attempt(this.parser.constructs.contentInitial,function(t){return null===t?void e.consume(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),ro(e,n,"linePrefix"))},function(n){return e.enter("paragraph"),function n(r){let i=e.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=i),t=i,function t(r){if(null===r){e.exit("chunkText"),e.exit("paragraph"),e.consume(r);return}return n8(r)?(e.consume(r),e.exit("chunkText"),n):(e.consume(r),t)}(r)}(n)});return n}},rl={tokenize:function(e){let t,n,r,i=this,o=[],a=0;return l;function l(t){if(a<o.length){let n=o[a];return i.containerState=n[1],e.attempt(n[0].continuation,s,u)(t)}return u(t)}function s(e){if(a++,i.containerState._closeFlow){let n;i.containerState._closeFlow=void 0,t&&y();let r=i.events.length,o=r;for(;o--;)if("exit"===i.events[o][0]&&"chunkFlow"===i.events[o][1].type){n=i.events[o][1].end;break}g(a);let l=r;for(;l<i.events.length;)i.events[l][1].end={...n},l++;return nG(i.events,o+1,0,i.events.slice(r)),i.events.length=l,u(e)}return l(e)}function u(n){if(a===o.length){if(!t)return f(n);if(t.currentConstruct&&t.currentConstruct.concrete)return m(n);i.interrupt=!!(t.currentConstruct&&!t._gfmTableDynamicInterruptHack)}return i.containerState={},e.check(rs,c,d)(n)}function c(e){return t&&y(),g(a),f(e)}function d(e){return i.parser.lazy[i.now().line]=a!==o.length,r=i.now().offset,m(e)}function f(t){return i.containerState={},e.attempt(rs,p,m)(t)}function p(e){return a++,o.push([i.currentConstruct,i.containerState]),f(e)}function m(r){if(null===r){t&&y(),g(0),e.consume(r);return}return t=t||i.parser.flow(i.now()),e.enter("chunkFlow",{_tokenizer:t,contentType:"flow",previous:n}),function t(n){if(null===n){h(e.exit("chunkFlow"),!0),g(0),e.consume(n);return}return n8(n)?(e.consume(n),h(e.exit("chunkFlow")),a=0,i.interrupt=void 0,l):(e.consume(n),t)}(r)}function h(e,o){let l=i.sliceStream(e);if(o&&l.push(null),e.previous=n,n&&(n.next=e),n=e,t.defineSkip(e.start),t.write(l),i.parser.lazy[e.start.line]){let e,n,o=t.events.length;for(;o--;)if(t.events[o][1].start.offset<r&&(!t.events[o][1].end||t.events[o][1].end.offset>r))return;let l=i.events.length,s=l;for(;s--;)if("exit"===i.events[s][0]&&"chunkFlow"===i.events[s][1].type){if(e){n=i.events[s][1].end;break}e=!0}for(g(a),o=l;o<i.events.length;)i.events[o][1].end={...n},o++;nG(i.events,s+1,0,i.events.slice(l)),i.events.length=o}}function g(t){let n=o.length;for(;n-- >t;){let t=o[n];i.containerState=t[1],t[0].exit.call(i,e)}o.length=t}function y(){t.write([null]),n=void 0,t=void 0,i.containerState._closeFlow=void 0}}},rs={tokenize:function(e,t,n){return ro(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}},ru={partial:!0,tokenize:function(e,t,n){return function(t){return rt(t)?ro(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||n8(e)?t(e):n(e)}}},rc={resolve:function(e){return n0(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?i(t):n8(t)?e.check(rd,o,i)(t):(e.consume(t),r)}function i(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function o(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},rd={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),ro(e,i,"linePrefix")};function i(i){if(null===i||n8(i))return n(i);let o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}},rf={tokenize:function(e){let t=this,n=e.attempt(ru,function(r){return null===r?void e.consume(r):(e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n)},e.attempt(this.parser.constructs.flowInitial,r,ro(e,e.attempt(this.parser.constructs.flow,r,e.attempt(rc,r)),"linePrefix")));return n;function r(r){return null===r?void e.consume(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n)}}},rp={resolveAll:ry()},rm=rg("string"),rh=rg("text");function rg(e){return{resolveAll:ry("text"===e?rv:void 0),tokenize:function(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,o,a);return o;function o(e){return s(e)?i(e):a(e)}function a(e){return null===e?void t.consume(e):(t.enter("data"),t.consume(e),l)}function l(e){return s(e)?(t.exit("data"),i(e)):(t.consume(e),l)}function s(e){if(null===e)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function ry(e){return function(t,n){let r,i=-1;for(;++i<=t.length;)void 0===r?t[i]&&"data"===t[i][1].type&&(r=i,i++):t[i]&&"data"===t[i][1].type||(i!==r+2&&(t[r][1].end=t[i-1][1].end,t.splice(r+2,i-r-2),i=r+2),r=void 0);return e?e(t,n):t}}function rv(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){let r,i=e[n-1][1],o=t.sliceStream(i),a=o.length,l=-1,s=0;for(;a--;){let e=o[a];if("string"==typeof e){for(l=e.length;32===e.charCodeAt(l-1);)s++,l--;if(l)break;l=-1}else if(-2===e)r=!0,s++;else if(-1===e);else{a++;break}}if(s){let o={type:n===e.length||r||s<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?l:i.start._bufferIndex+l,_index:i.start._index+a,line:i.end.line,column:i.end.column-s,offset:i.end.offset-s},end:{...i.end}};i.end={...o.start},i.start.offset===i.end.offset?Object.assign(i,o):(e.splice(n,0,["enter",o,t],["exit",o,t]),n+=2)}n++}return e}let rb={name:"thematicBreak",tokenize:function(e,t,n){let r,i=0;return function(o){var a;return e.enter("thematicBreak"),r=a=o,function o(a){return a===r?(e.enter("thematicBreakSequence"),function t(n){return n===r?(e.consume(n),i++,t):(e.exit("thematicBreakSequence"),rt(n)?ro(e,o,"whitespace")(n):o(n))}(a)):i>=3&&(null===a||n8(a))?(e.exit("thematicBreak"),t(a)):n(a)}(a)}}},r_={continuation:{tokenize:function(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(ru,function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ro(e,t,"listItemIndent",r.containerState.size+1)(n)},function(n){return r.containerState.furtherBlankLines||!rt(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(rx,t,i)(n))});function i(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,ro(e,e.attempt(r_,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){let r=this,i=r.events[r.events.length-1],o=i&&"linePrefix"===i[1].type?i[2].sliceSerialize(i[1],!0).length:0,a=0;return function(t){let i=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===i?!r.containerState.marker||t===r.containerState.marker:n6(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),"listUnordered"===i)return e.enter("listItemPrefix"),42===t||45===t?e.check(rb,n,l)(t):l(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),function t(i){return n6(i)&&++a<10?(e.consume(i),t):(!r.interrupt||a<2)&&(r.containerState.marker?i===r.containerState.marker:41===i||46===i)?(e.exit("listItemValue"),l(i)):n(i)}(t)}return n(t)};function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||t,e.check(ru,r.interrupt?n:s,e.attempt(rw,c,u))}function s(e){return r.containerState.initialBlankLine=!0,o++,c(e)}function u(t){return rt(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),c):n(t)}function c(n){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},rw={partial:!0,tokenize:function(e,t,n){let r=this;return ro(e,function(e){let i=r.events[r.events.length-1];return!rt(e)&&i&&"listItemPrefixWhitespace"===i[1].type?t(e):n(e)},"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},rx={partial:!0,tokenize:function(e,t,n){let r=this;return ro(e,function(e){let i=r.events[r.events.length-1];return i&&"listItemIndent"===i[1].type&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)},"listItemIndent",r.containerState.size+1)}},rE={continuation:{tokenize:function(e,t,n){let r=this;return function(t){return rt(t)?ro(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):i(t)};function i(r){return e.attempt(rE,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){let r=this;return function(t){if(62===t){let n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),i}return n(t)};function i(n){return rt(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};function rk(e,t,n,r,i,o,a,l,s){let u=s||1/0,c=0;return function(t){return 60===t?(e.enter(r),e.enter(i),e.enter(o),e.consume(t),e.exit(o),d):null===t||32===t||41===t||n5(t)?n(t):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),m(t))};function d(n){return 62===n?(e.enter(o),e.consume(n),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),f(n))}function f(t){return 62===t?(e.exit("chunkString"),e.exit(l),d(t)):null===t||60===t||n8(t)?n(t):(e.consume(t),92===t?p:f)}function p(t){return 60===t||62===t||92===t?(e.consume(t),f):f(t)}function m(i){return!c&&(null===i||41===i||re(i))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(i)):c<u&&40===i?(e.consume(i),c++,m):41===i?(e.consume(i),c--,m):null===i||32===i||40===i||n5(i)?n(i):(e.consume(i),92===i?h:m)}function h(t){return 40===t||41===t||92===t?(e.consume(t),m):m(t)}}function rS(e,t,n,r,i,o){let a,l=this,s=0;return function(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(o),u};function u(d){return s>999||null===d||91===d||93===d&&!a||94===d&&!s&&"_hiddenFootnoteSupport"in l.parser.constructs?n(d):93===d?(e.exit(o),e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):n8(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),c(d))}function c(t){return null===t||91===t||93===t||n8(t)||s++>999?(e.exit("chunkString"),u(t)):(e.consume(t),a||(a=!rt(t)),92===t?d:c)}function d(t){return 91===t||92===t||93===t?(e.consume(t),s++,c):c(t)}}function rO(e,t,n,r,i,o){let a;return function(t){return 34===t||39===t||40===t?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),a=40===t?41:t,l):n(t)};function l(n){return n===a?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(o),s(n))}function s(t){return t===a?(e.exit(o),l(a)):null===t?n(t):n8(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),ro(e,s,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(t))}function u(t){return t===a||null===t||n8(t)?(e.exit("chunkString"),s(t)):(e.consume(t),92===t?c:u)}function c(t){return t===a||92===t?(e.consume(t),u):u(t)}}function rD(e,t){let n;return function r(i){return n8(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):rt(i)?ro(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}function rC(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}let rF={partial:!0,tokenize:function(e,t,n){return function(t){return re(t)?rD(e,r)(t):n(t)};function r(t){return rO(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function i(t){return rt(t)?ro(e,o,"whitespace")(t):o(t)}function o(e){return null===e||n8(e)?t(e):n(e)}}},rA={name:"codeIndented",tokenize:function(e,t,n){let r=this;return function(t){return e.enter("codeIndented"),ro(e,i,"linePrefix",5)(t)};function i(t){let i=r.events[r.events.length-1];return i&&"linePrefix"===i[1].type&&i[2].sliceSerialize(i[1],!0).length>=4?function t(n){return null===n?o(n):n8(n)?e.attempt(rP,t,o)(n):(e.enter("codeFlowValue"),function n(r){return null===r||n8(r)?(e.exit("codeFlowValue"),t(r)):(e.consume(r),n)}(n))}(t):n(t)}function o(n){return e.exit("codeIndented"),t(n)}}},rP={partial:!0,tokenize:function(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):n8(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):ro(e,o,"linePrefix",5)(t)}function o(e){let o=r.events[r.events.length-1];return o&&"linePrefix"===o[1].type&&o[2].sliceSerialize(o[1],!0).length>=4?t(e):n8(e)?i(e):n(e)}}},rT={name:"setextUnderline",resolveTo:function(e,t){let n,r,i,o=e.length;for(;o--;)if("enter"===e[o][0]){if("content"===e[o][1].type){n=o;break}"paragraph"===e[o][1].type&&(r=o)}else"content"===e[o][1].type&&e.splice(o,1),i||"definition"!==e[o][1].type||(i=o);let a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[r][1].type="setextHeadingText",i?(e.splice(r,0,["enter",a,t]),e.splice(i+1,0,["exit",e[n][1],t]),e[n][1].end={...e[i][1].end}):e[n][1]=a,e.push(["exit",a,t]),e},tokenize:function(e,t,n){let r,i=this;return function(t){var a;let l,s=i.events.length;for(;s--;)if("lineEnding"!==i.events[s][1].type&&"linePrefix"!==i.events[s][1].type&&"content"!==i.events[s][1].type){l="paragraph"===i.events[s][1].type;break}return!i.parser.lazy[i.now().line]&&(i.interrupt||l)?(e.enter("setextHeadingLine"),r=t,a=t,e.enter("setextHeadingLineSequence"),function t(n){return n===r?(e.consume(n),t):(e.exit("setextHeadingLineSequence"),rt(n)?ro(e,o,"lineSuffix")(n):o(n))}(a)):n(t)};function o(r){return null===r||n8(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}},rV=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],rM=["pre","script","style","textarea"],rj={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(ru,t,n)}}},rI={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return n8(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i):n(t)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},rN={partial:!0,tokenize:function(e,t,n){let r=this;return function(t){return null===t?n(t):(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),i)};function i(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},rL={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){let r,i=this,o={partial:!0,tokenize:function(e,t,n){let o=0;return function(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a};function a(t){return e.enter("codeFencedFence"),rt(t)?ro(e,s,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):s(t)}function s(t){return t===r?(e.enter("codeFencedFenceSequence"),function t(i){return i===r?(o++,e.consume(i),t):o>=l?(e.exit("codeFencedFenceSequence"),rt(i)?ro(e,u,"whitespace")(i):u(i)):n(i)}(t)):n(t)}function u(r){return null===r||n8(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}},a=0,l=0;return function(t){var o;let u;return o=t,a=(u=i.events[i.events.length-1])&&"linePrefix"===u[1].type?u[2].sliceSerialize(u[1],!0).length:0,r=o,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),function t(i){return i===r?(l++,e.consume(i),t):l<3?n(i):(e.exit("codeFencedFenceSequence"),rt(i)?ro(e,s,"whitespace")(i):s(i))}(o)};function s(o){return null===o||n8(o)?(e.exit("codeFencedFence"),i.interrupt?t(o):e.check(rN,c,m)(o)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||n8(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),s(i)):rt(i)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ro(e,u,"whitespace")(i)):96===i&&i===r?n(i):(e.consume(i),t)}(o))}function u(t){return null===t||n8(t)?s(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),function t(i){return null===i||n8(i)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),s(i)):96===i&&i===r?n(i):(e.consume(i),t)}(t))}function c(t){return e.attempt(o,m,d)(t)}function d(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),f}function f(t){return a>0&&rt(t)?ro(e,p,"linePrefix",a+1)(t):p(t)}function p(t){return null===t||n8(t)?e.check(rN,c,m)(t):(e.enter("codeFlowValue"),function t(n){return null===n||n8(n)?(e.exit("codeFlowValue"),p(n)):(e.consume(n),t)}(t))}function m(n){return e.exit("codeFenced"),t(n)}}},rq=document.createElement("i");function rR(e){let t="&"+e+";";rq.innerHTML=t;let n=rq.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&n!==t&&n}let r$={name:"characterReference",tokenize:function(e,t,n){let r,i,o=this,a=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),l};function l(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),s):(e.enter("characterReferenceValue"),r=31,i=n4,u(t))}function s(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,i=n9,u):(e.enter("characterReferenceValue"),r=7,i=n6,u(t))}function u(l){if(59===l&&a){let r=e.exit("characterReferenceValue");return i!==n4||rR(o.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(l),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(l)}return i(l)&&a++<r?(e.consume(l),u):n(l)}}},rB={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return n7(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}},rH={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),ro(e,t,"linePrefix")}}};function rz(e,t,n){let r=[],i=-1;for(;++i<e.length;){let o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}let rU={name:"labelEnd",resolveAll:function(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){let e="labelImage"===r.type?4:2;r.type="data",t+=e}}return e.length!==n.length&&nG(e,0,e.length,n),e},resolveTo:function(e,t){let n,r,i,o,a=e.length,l=0;for(;a--;)if(n=e[a][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[a][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(i){if("enter"===e[a][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=a,"labelLink"!==n.type)){l=2;break}}else"labelEnd"===n.type&&(i=a);let s={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[r][1].start},end:{...e[i][1].end}},c={type:"labelText",start:{...e[r+l+2][1].end},end:{...e[i-2][1].start}};return o=nQ(o=[["enter",s,t],["enter",u,t]],e.slice(r+1,r+l+3)),o=nQ(o,[["enter",c,t]]),o=nQ(o,rz(t.parser.constructs.insideSpan.null,e.slice(r+l+4,i-3),t)),o=nQ(o,[["exit",c,t],e[i-2],e[i-1],["exit",u,t]]),o=nQ(o,e.slice(i+1)),o=nQ(o,[["exit",s,t]]),nG(e,r,e.length,o),e},tokenize:function(e,t,n){let r,i,o=this,a=o.events.length;for(;a--;)if(("labelImage"===o.events[a][1].type||"labelLink"===o.events[a][1].type)&&!o.events[a][1]._balanced){r=o.events[a][1];break}return function(t){return r?r._inactive?c(t):(i=o.parser.defined.includes(rC(o.sliceSerialize({start:r.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),l):n(t)};function l(t){return 40===t?e.attempt(rW,u,i?u:c)(t):91===t?e.attempt(rY,u,i?s:c)(t):i?u(t):c(t)}function s(t){return e.attempt(rJ,u,c)(t)}function u(e){return t(e)}function c(e){return r._balanced=!0,n(e)}}},rW={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return re(t)?rD(e,i)(t):i(t)}function i(t){return 41===t?u(t):rk(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function o(t){return re(t)?rD(e,l)(t):u(t)}function a(e){return n(e)}function l(t){return 34===t||39===t||40===t?rO(e,s,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):u(t)}function s(t){return re(t)?rD(e,u)(t):u(t)}function u(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},rY={tokenize:function(e,t,n){let r=this;return function(t){return rS.call(r,e,i,o,"reference","referenceMarker","referenceString")(t)};function i(e){return r.parser.defined.includes(rC(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}},rJ={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}},rZ={name:"labelStartImage",resolveAll:rU.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),i};function i(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),o):n(t)}function o(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};function rG(e){return null===e||re(e)||rr(e)?1:rn(e)?2:void 0}let rQ={name:"attention",resolveAll:function(e,t){let n,r,i,o,a,l,s,u,c=-1;for(;++c<e.length;)if("enter"===e[c][0]&&"attentionSequence"===e[c][1].type&&e[c][1]._close){for(n=c;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[c][1]).charCodeAt(0)){if((e[n][1]._close||e[c][1]._open)&&(e[c][1].end.offset-e[c][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[c][1].end.offset-e[c][1].start.offset)%3))continue;l=e[n][1].end.offset-e[n][1].start.offset>1&&e[c][1].end.offset-e[c][1].start.offset>1?2:1;let d={...e[n][1].end},f={...e[c][1].start};rK(d,-l),rK(f,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[n][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[c][1].start},end:f},i={type:l>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[c][1].start}},r={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[n][1].end={...o.start},e[c][1].start={...a.end},s=[],e[n][1].end.offset-e[n][1].start.offset&&(s=nQ(s,[["enter",e[n][1],t],["exit",e[n][1],t]])),s=nQ(s,[["enter",r,t],["enter",o,t],["exit",o,t],["enter",i,t]]),s=nQ(s,rz(t.parser.constructs.insideSpan.null,e.slice(n+1,c),t)),s=nQ(s,[["exit",i,t],["enter",a,t],["exit",a,t],["exit",r,t]]),e[c][1].end.offset-e[c][1].start.offset?(u=2,s=nQ(s,[["enter",e[c][1],t],["exit",e[c][1],t]])):u=0,nG(e,n-1,c-n+3,s),c=n+s.length-u-2;break}}for(c=-1;++c<e.length;)"attentionSequence"===e[c][1].type&&(e[c][1].type="data");return e},tokenize:function(e,t){let n,r=this.parser.constructs.attentionMarkers.null,i=this.previous,o=rG(i);return function(a){return n=a,e.enter("attentionSequence"),function a(l){if(l===n)return e.consume(l),a;let s=e.exit("attentionSequence"),u=rG(l),c=!u||2===u&&o||r.includes(l),d=!o||2===o&&u||r.includes(i);return s._open=!!(42===n?c:c&&(o||!d)),s._close=!!(42===n?d:d&&(u||!c)),t(l)}(a)}}};function rK(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}let rX={name:"labelStartLink",resolveAll:rU.resolveAll,tokenize:function(e,t,n){let r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),i};function i(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}},r0={42:r_,43:r_,45:r_,48:r_,49:r_,50:r_,51:r_,52:r_,53:r_,54:r_,55:r_,56:r_,57:r_,62:rE},r1={91:{name:"definition",tokenize:function(e,t,n){let r,i=this;return function(t){var r;return e.enter("definition"),r=t,rS.call(i,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(r)};function o(t){return(r=rC(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),58===t)?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),a):n(t)}function a(t){return re(t)?rD(e,l)(t):l(t)}function l(t){return rk(e,s,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function s(t){return e.attempt(rF,u,u)(t)}function u(t){return rt(t)?ro(e,c,"whitespace")(t):c(t)}function c(o){return null===o||n8(o)?(e.exit("definition"),i.parser.defined.push(r),t(o)):n(o)}}}},r2={[-2]:rA,[-1]:rA,32:rA},r4={35:{name:"headingAtx",resolve:function(e,t){let n,r,i=e.length-2,o=3;return"whitespace"===e[3][1].type&&(o+=2),i-2>o&&"whitespace"===e[i][1].type&&(i-=2),"atxHeadingSequence"===e[i][1].type&&(o===i-1||i-4>o&&"whitespace"===e[i-2][1].type)&&(i-=o+1===i?2:4),i>o&&(n={type:"atxHeadingText",start:e[o][1].start,end:e[i][1].end},r={type:"chunkText",start:e[o][1].start,end:e[i][1].end,contentType:"text"},nG(e,o,i-o+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]])),e},tokenize:function(e,t,n){let r=0;return function(i){var o;return e.enter("atxHeading"),o=i,e.enter("atxHeadingSequence"),function i(o){return 35===o&&r++<6?(e.consume(o),i):null===o||re(o)?(e.exit("atxHeadingSequence"),function n(r){return 35===r?(e.enter("atxHeadingSequence"),function t(r){return 35===r?(e.consume(r),t):(e.exit("atxHeadingSequence"),n(r))}(r)):null===r||n8(r)?(e.exit("atxHeading"),t(r)):rt(r)?ro(e,n,"whitespace")(r):(e.enter("atxHeadingText"),function t(r){return null===r||35===r||re(r)?(e.exit("atxHeadingText"),n(r)):(e.consume(r),t)}(r))}(o)):n(o)}(o)}}},42:rb,45:[rT,rb],60:{concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););return t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e},tokenize:function(e,t,n){let r,i,o,a,l,s=this;return function(t){var n;return n=t,e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(n),u};function u(a){return 33===a?(e.consume(a),c):47===a?(e.consume(a),i=!0,p):63===a?(e.consume(a),r=3,s.interrupt?t:T):n2(a)?(e.consume(a),o=String.fromCharCode(a),m):n(a)}function c(i){return 45===i?(e.consume(i),r=2,d):91===i?(e.consume(i),r=5,a=0,f):n2(i)?(e.consume(i),r=4,s.interrupt?t:T):n(i)}function d(r){return 45===r?(e.consume(r),s.interrupt?t:T):n(r)}function f(r){let i="CDATA[";return r===i.charCodeAt(a++)?(e.consume(r),a===i.length)?s.interrupt?t:k:f:n(r)}function p(t){return n2(t)?(e.consume(t),o=String.fromCharCode(t),m):n(t)}function m(a){if(null===a||47===a||62===a||re(a)){let l=47===a,u=o.toLowerCase();return!l&&!i&&rM.includes(u)?(r=1,s.interrupt?t(a):k(a)):rV.includes(o.toLowerCase())?(r=6,l)?(e.consume(a),h):s.interrupt?t(a):k(a):(r=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(a):i?function t(n){return rt(n)?(e.consume(n),t):x(n)}(a):g(a))}return 45===a||n4(a)?(e.consume(a),o+=String.fromCharCode(a),m):n(a)}function h(r){return 62===r?(e.consume(r),s.interrupt?t:k):n(r)}function g(t){return 47===t?(e.consume(t),x):58===t||95===t||n2(t)?(e.consume(t),y):rt(t)?(e.consume(t),g):x(t)}function y(t){return 45===t||46===t||58===t||95===t||n4(t)?(e.consume(t),y):v(t)}function v(t){return 61===t?(e.consume(t),b):rt(t)?(e.consume(t),v):g(t)}function b(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,_):rt(t)?(e.consume(t),b):function t(n){return null===n||34===n||39===n||47===n||60===n||61===n||62===n||96===n||re(n)?v(n):(e.consume(n),t)}(t)}function _(t){return t===l?(e.consume(t),l=null,w):null===t||n8(t)?n(t):(e.consume(t),_)}function w(e){return 47===e||62===e||rt(e)?g(e):n(e)}function x(t){return 62===t?(e.consume(t),E):n(t)}function E(t){return null===t||n8(t)?k(t):rt(t)?(e.consume(t),E):n(t)}function k(t){return 45===t&&2===r?(e.consume(t),C):60===t&&1===r?(e.consume(t),F):62===t&&4===r?(e.consume(t),V):63===t&&3===r?(e.consume(t),T):93===t&&5===r?(e.consume(t),P):n8(t)&&(6===r||7===r)?(e.exit("htmlFlowData"),e.check(rj,M,S)(t)):null===t||n8(t)?(e.exit("htmlFlowData"),S(t)):(e.consume(t),k)}function S(t){return e.check(rI,O,M)(t)}function O(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),D}function D(t){return null===t||n8(t)?S(t):(e.enter("htmlFlowData"),k(t))}function C(t){return 45===t?(e.consume(t),T):k(t)}function F(t){return 47===t?(e.consume(t),o="",A):k(t)}function A(t){if(62===t){let n=o.toLowerCase();return rM.includes(n)?(e.consume(t),V):k(t)}return n2(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),A):k(t)}function P(t){return 93===t?(e.consume(t),T):k(t)}function T(t){return 62===t?(e.consume(t),V):45===t&&2===r?(e.consume(t),T):k(t)}function V(t){return null===t||n8(t)?(e.exit("htmlFlowData"),M(t)):(e.consume(t),V)}function M(n){return e.exit("htmlFlow"),t(n)}}},61:rT,95:rb,96:rL,126:rL},r3={38:r$,92:rB},r5={[-5]:rH,[-4]:rH,[-3]:rH,33:rZ,38:r$,42:rQ,60:[{name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i};function i(t){return n2(t)?(e.consume(t),o):64===t?n(t):l(t)}function o(t){return 43===t||45===t||46===t||n4(t)?(r=1,function t(n){return 58===n?(e.consume(n),r=0,a):(43===n||45===n||46===n||n4(n))&&r++<32?(e.consume(n),t):(r=0,l(n))}(t)):l(t)}function a(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||n5(r)?n(r):(e.consume(r),a)}function l(t){return 64===t?(e.consume(t),s):n3(t)?(e.consume(t),l):n(t)}function s(i){return n4(i)?function i(o){return 46===o?(e.consume(o),r=0,s):62===o?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(o),e.exit("autolinkMarker"),e.exit("autolink"),t):function t(o){if((45===o||n4(o))&&r++<63){let n=45===o?t:i;return e.consume(o),n}return n(o)}(o)}(i):n(i)}}},{name:"htmlText",tokenize:function(e,t,n){let r,i,o,a=this;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),l};function l(t){return 33===t?(e.consume(t),s):47===t?(e.consume(t),_):63===t?(e.consume(t),v):n2(t)?(e.consume(t),x):n(t)}function s(t){return 45===t?(e.consume(t),u):91===t?(e.consume(t),i=0,p):n2(t)?(e.consume(t),y):n(t)}function u(t){return 45===t?(e.consume(t),f):n(t)}function c(t){return null===t?n(t):45===t?(e.consume(t),d):n8(t)?(o=c,A(t)):(e.consume(t),c)}function d(t){return 45===t?(e.consume(t),f):c(t)}function f(e){return 62===e?F(e):45===e?d(e):c(e)}function p(t){let r="CDATA[";return t===r.charCodeAt(i++)?(e.consume(t),i===r.length?m:p):n(t)}function m(t){return null===t?n(t):93===t?(e.consume(t),h):n8(t)?(o=m,A(t)):(e.consume(t),m)}function h(t){return 93===t?(e.consume(t),g):m(t)}function g(t){return 62===t?F(t):93===t?(e.consume(t),g):m(t)}function y(t){return null===t||62===t?F(t):n8(t)?(o=y,A(t)):(e.consume(t),y)}function v(t){return null===t?n(t):63===t?(e.consume(t),b):n8(t)?(o=v,A(t)):(e.consume(t),v)}function b(e){return 62===e?F(e):v(e)}function _(t){return n2(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||n4(t)?(e.consume(t),w):function t(n){return n8(n)?(o=t,A(n)):rt(n)?(e.consume(n),t):F(n)}(t)}function x(t){return 45===t||n4(t)?(e.consume(t),x):47===t||62===t||re(t)?E(t):n(t)}function E(t){return 47===t?(e.consume(t),F):58===t||95===t||n2(t)?(e.consume(t),k):n8(t)?(o=E,A(t)):rt(t)?(e.consume(t),E):F(t)}function k(t){return 45===t||46===t||58===t||95===t||n4(t)?(e.consume(t),k):function t(n){return 61===n?(e.consume(n),S):n8(n)?(o=t,A(n)):rt(n)?(e.consume(n),t):E(n)}(t)}function S(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,O):n8(t)?(o=S,A(t)):rt(t)?(e.consume(t),S):(e.consume(t),D)}function O(t){return t===r?(e.consume(t),r=void 0,C):null===t?n(t):n8(t)?(o=O,A(t)):(e.consume(t),O)}function D(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||re(t)?E(t):(e.consume(t),D)}function C(e){return 47===e||62===e||re(e)?E(e):n(e)}function F(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function A(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),P}function P(t){return rt(t)?ro(e,T,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):T(t)}function T(t){return e.enter("htmlTextData"),o(t)}}}],91:rX,92:[{name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return n8(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}},rB],93:rU,95:rQ,96:{name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,i=3;if(("lineEnding"===e[3][1].type||"space"===e[i][1].type)&&("lineEnding"===e[r][1].type||"space"===e[r][1].type)){for(t=i;++t<r;)if("codeTextData"===e[t][1].type){e[i][1].type="codeTextPadding",e[r][1].type="codeTextPadding",i+=2,r-=2;break}}for(t=i-1,r++;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):(t===r||"lineEnding"===e[t][1].type)&&(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,i,o=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),function t(n){return 96===n?(e.consume(n),o++,t):(e.exit("codeTextSequence"),a(n))}(t)};function a(s){return null===s?n(s):32===s?(e.enter("space"),e.consume(s),e.exit("space"),a):96===s?(i=e.enter("codeTextSequence"),r=0,function n(a){return 96===a?(e.consume(a),r++,n):r===o?(e.exit("codeTextSequence"),e.exit("codeText"),t(a)):(i.type="codeTextData",l(a))}(s)):n8(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),a):(e.enter("codeTextData"),l(s))}function l(t){return null===t||32===t||96===t||n8(t)?(e.exit("codeTextData"),a(t)):(e.consume(t),l)}}}},r6={null:[rQ,rp]},r9={null:[42,95]},r7={null:[]},r8=/[\0\t\n\r]/g;function ie(e,t){let n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(65535&n)==65535||(65535&n)==65534||n>1114111?"�":String.fromCodePoint(n)}let it=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ir(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){let e=n.charCodeAt(1),t=120===e||88===e;return ie(n.slice(t?2:1),t?16:10)}return rR(n)||e}let ii={}.hasOwnProperty;function io(e){return{line:e.line,column:e.column,offset:e.offset}}function ia(e,t){if(e)throw Error("Cannot close `"+e.type+"` ("+nS({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+nS({start:t.start,end:t.end})+") is open");throw Error("Cannot close document, a token (`"+t.type+"`, "+nS({start:t.start,end:t.end})+") is still open")}function il(e){let t=this;t.parser=function(n){var r,i;let a,l,s,u;return"string"!=typeof(r={...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})&&(i=r,r=void 0),(function(e){let t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:r(y),autolinkProtocol:u,autolinkEmail:u,atxHeading:r(m),blockQuote:r(function(){return{type:"blockquote",children:[]}}),characterEscape:u,characterReference:u,codeFenced:r(p),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:r(p,i),codeText:r(function(){return{type:"inlineCode",value:""}},i),codeTextData:u,data:u,codeFlowValue:u,definition:r(function(){return{type:"definition",identifier:"",label:null,title:null,url:""}}),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:r(function(){return{type:"emphasis",children:[]}}),hardBreakEscape:r(h),hardBreakTrailing:r(h),htmlFlow:r(g,i),htmlFlowData:u,htmlText:r(g,i),htmlTextData:u,image:r(function(){return{type:"image",title:null,url:"",alt:null}}),label:i,link:r(y),listItem:r(function(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}),listItemValue:function(e){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0)},listOrdered:r(v,function(){this.data.expectingFirstListItemValue=!0}),listUnordered:r(v),paragraph:r(function(){return{type:"paragraph",children:[]}}),reference:function(){this.data.referenceType="collapsed"},referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:r(m),strong:r(function(){return{type:"strong",children:[]}}),thematicBreak:r(function(){return{type:"thematicBreak"}})},exit:{atxHeading:a(),atxHeadingSequence:function(e){let t=this.stack[this.stack.length-1];t.depth||(t.depth=this.sliceSerialize(e).length)},autolink:a(),autolinkEmail:function(e){c.call(this,e),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)},autolinkProtocol:function(e){c.call(this,e),this.stack[this.stack.length-1].url=this.sliceSerialize(e)},blockQuote:a(),characterEscapeValue:c,characterReferenceMarkerHexadecimal:f,characterReferenceMarkerNumeric:f,characterReferenceValue:function(e){let t,n=this.sliceSerialize(e),r=this.data.characterReferenceType;r?(t=ie(n,"characterReferenceMarkerNumeric"===r?10:16),this.data.characterReferenceType=void 0):t=rR(n);let i=this.stack[this.stack.length-1];i.value+=t},characterReference:function(e){this.stack.pop().position.end=io(e.end)},codeFenced:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}),codeFencedFence:function(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)},codeFencedFenceInfo:function(){let e=this.resume();this.stack[this.stack.length-1].lang=e},codeFencedFenceMeta:function(){let e=this.resume();this.stack[this.stack.length-1].meta=e},codeFlowValue:c,codeIndented:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}),codeText:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),codeTextData:c,data:c,definition:a(),definitionDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},definitionLabelString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=rC(this.sliceSerialize(e)).toLowerCase()},definitionTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},emphasis:a(),hardBreakEscape:a(d),hardBreakTrailing:a(d),htmlFlow:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlFlowData:c,htmlText:a(function(){let e=this.resume();this.stack[this.stack.length-1].value=e}),htmlTextData:c,image:a(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),label:function(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,"link"===n.type?n.children=e.children:n.alt=t},labelText:function(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=t.replace(it,ir),n.identifier=rC(t).toLowerCase()},lineEnding:function(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){n.children[n.children.length-1].position.end=io(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(u.call(this,e),c.call(this,e))},link:a(function(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}),listItem:a(),listOrdered:a(),listUnordered:a(),paragraph:a(),referenceString:function(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=rC(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"},resourceDestinationString:function(){let e=this.resume();this.stack[this.stack.length-1].url=e},resourceTitleString:function(){let e=this.resume();this.stack[this.stack.length-1].title=e},resource:function(){this.data.inReference=void 0},setextHeading:a(function(){this.data.setextHeadingSlurpLineEnding=void 0}),setextHeadingLineSequence:function(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2},setextHeadingText:function(){this.data.setextHeadingSlurpLineEnding=!0},strong:a(),thematicBreak:a()}};!function e(t,n){let r=-1;for(;++r<n.length;){let i=n[r];Array.isArray(i)?e(t,i):function(e,t){let n;for(n in t)if(ii.call(t,n))switch(n){case"canContainEols":{let r=t[n];r&&e[n].push(...r);break}case"transforms":{let r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{let r=t[n];r&&Object.assign(e[n],r)}}}(t,i)}}(t,(e||{}).mdastExtensions||[]);let n={};return function(e){let r={type:"root",children:[]},a={stack:[r],tokenStack:[],config:t,enter:o,exit:l,buffer:i,resume:s,data:n},u=[],c=-1;for(;++c<e.length;)("listOrdered"===e[c][1].type||"listUnordered"===e[c][1].type)&&("enter"===e[c][0]?u.push(c):c=function(e,t,n){let r,i,o,a,l=t-1,s=-1,u=!1;for(;++l<=n;){let t=e[l];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?s++:s--,a=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||a||s||o||(o=l),a=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:a=void 0}if(!s&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===s&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(r){let a=l;for(i=void 0;a--;){let t=e[a];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;i&&(e[i][1].type="lineEndingBlank",u=!0),t[1].type="lineEnding",i=a}else if("linePrefix"===t[1].type||"blockQuotePrefix"===t[1].type||"blockQuotePrefixWhitespace"===t[1].type||"blockQuoteMarker"===t[1].type||"listItemIndent"===t[1].type);else break}o&&(!i||o<i)&&(r._spread=!0),r.end=Object.assign({},i?e[i][1].start:t[1].end),e.splice(i||l,0,["exit",r,t[2]]),l++,n++}if("listItemPrefix"===t[1].type){let i={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=i,e.splice(l,0,["enter",i,t[2]]),l++,n++,o=void 0,a=!0}}}return e[t][1]._spread=u,n}(e,u.pop(),c));for(c=-1;++c<e.length;){let n=t[e[c][0]];ii.call(n,e[c][1].type)&&n[e[c][1].type].call(Object.assign({sliceSerialize:e[c][2].sliceSerialize},a),e[c][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||ia).call(a,void 0,e[0])}for(r.position={start:io(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:io(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},c=-1;++c<t.transforms.length;)r=t.transforms[c](r)||r;return r};function r(e,t){return function(n){o.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function o(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:io(t.start),end:void 0}}function a(e){return function(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||ia).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+nS({start:e.start,end:e.end})+"): it’s not open");n.position.end=io(e.end)}function s(){var e;return e=this.stack.pop(),nJ(e,"boolean"!=typeof nY.includeImageAlt||nY.includeImageAlt,"boolean"!=typeof nY.includeHtml||nY.includeHtml)}function u(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];n&&"text"===n.type||((n={type:"text",value:""}).position={start:io(e.start),end:void 0},t.push(n)),this.stack.push(n)}function c(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=io(e.end)}function d(){this.data.atHardBreak=!0}function f(e){this.data.characterReferenceType=e.type}function p(){return{type:"code",lang:null,meta:null,value:""}}function m(){return{type:"heading",depth:0,children:[]}}function h(){return{type:"break"}}function g(){return{type:"html",value:""}}function y(){return{type:"link",title:null,url:"",children:[]}}function v(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}})(i)(function(e){for(;!n0(e););return e}((function(e){let t={constructs:function(e){let t={},n=-1;for(;++n<e.length;)!function(e,t){let n;for(n in t){let r,i=(n1.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];if(o)for(r in o){n1.call(i,r)||(i[r]=[]);let e=o[r];!function(e,t){let n=-1,r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);nG(e,0,0,r)}(i[r],Array.isArray(e)?e:e?[e]:[])}}}(t,e[n]);return t}([o,...(e||{}).extensions||[]]),content:n(ra),defined:[],document:n(rl),flow:n(rf),lazy:{},string:n(rm),text:n(rh)};return t;function n(e){return function(n){return function(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},o=[],a=[],l=[],s={attempt:m(function(e,t){h(e,t.from)}),check:m(p),consume:function(e){n8(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,g()):-1!==e&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=e},enter:function(e,t){let n=t||{};return n.type=e,n.start=f(),u.events.push(["enter",n,u]),l.push(n),n},exit:function(e){let t=l.pop();return t.end=f(),u.events.push(["exit",t,u]),t},interrupt:m(p,{interrupt:!0})},u={code:null,containerState:{},defineSkip:function(e){i[e.line]=e.column,g()},events:[],now:f,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n,r=-1,i=[];for(;++r<e.length;){let o,a=e[r];if("string"==typeof a)o=a;else switch(a){case -5:o="\r";break;case -4:o="\n";break;case -3:o="\r\n";break;case -2:o=t?" ":" ";break;case -1:if(!t&&n)continue;o=" ";break;default:o=String.fromCharCode(a)}n=-2===a,i.push(o)}return i.join("")}(d(e),t)},sliceStream:d,write:function(e){return(a=nQ(a,e),function(){let e;for(;r._index<a.length;){let n=a[r._index];if("string"==typeof n)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<n.length;){var t;t=n.charCodeAt(r._bufferIndex),c=c(t)}else c=c(n)}}(),null!==a[a.length-1])?[]:(h(t,0),u.events=rz(o,u.events,u),u.events)}},c=t.tokenize.call(u,s);return t.resolveAll&&o.push(t),u;function d(e){return function(e,t){let n,r=t.start._index,i=t.start._bufferIndex,o=t.end._index,a=t.end._bufferIndex;if(r===o)n=[e[r].slice(i,a)];else{if(n=e.slice(r,o),i>-1){let e=n[0];"string"==typeof e?n[0]=e.slice(i):n.shift()}a>0&&n.push(e[o].slice(0,a))}return n}(a,e)}function f(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:o}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:o}}function p(e,t){t.restore()}function m(e,t){return function(n,i,o){var a;let c,d,p,m;return Array.isArray(n)?h(n):"tokenize"in n?h([n]):(a=n,function(e){let t=null!==e&&a[e],n=null!==e&&a.null;return h([...Array.isArray(t)?t:t?[t]:[],...Array.isArray(n)?n:n?[n]:[]])(e)});function h(e){return(c=e,d=0,0===e.length)?o:y(e[d])}function y(e){return function(n){let i,o,a,c,d;return(i=f(),o=u.previous,a=u.currentConstruct,c=u.events.length,d=Array.from(l),m={from:c,restore:function(){r=i,u.previous=o,u.currentConstruct=a,u.events.length=c,l=d,g()}},p=e,e.partial||(u.currentConstruct=e),e.name&&u.parser.constructs.disable.null.includes(e.name))?b(n):e.tokenize.call(t?Object.assign(Object.create(u),t):u,s,v,b)(n)}}function v(t){return e(p,m),i}function b(e){return(m.restore(),++d<c.length)?y(c[d]):o}}}function h(e,t){e.resolveAll&&!o.includes(e)&&o.push(e),e.resolve&&nG(u.events,t,u.events.length-t,e.resolve(u.events.slice(t),u)),e.resolveTo&&(u.events=e.resolveTo(u.events,u))}function g(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}(t,e,n)}}})(i).document().write((l=1,s="",u=!0,function(e,t,n){let r,i,o,c,d,f=[];for(e=s+("string"==typeof e?e.toString():new TextDecoder(t||void 0).decode(e)),o=0,s="",u&&(65279===e.charCodeAt(0)&&o++,u=void 0);o<e.length;){if(r8.lastIndex=o,c=(r=r8.exec(e))&&void 0!==r.index?r.index:e.length,d=e.charCodeAt(c),!r){s=e.slice(o);break}if(10===d&&o===c&&a)f.push(-3),a=void 0;else switch(a&&(f.push(-5),a=void 0),o<c&&(f.push(e.slice(o,c)),l+=c-o),d){case 0:f.push(65533),l++;break;case 9:for(i=4*Math.ceil(l/4),f.push(-2);l++<i;)f.push(-1);break;case 10:f.push(-4),l=1;break;default:a=!0,l=1}o=c+1}return n&&(a&&f.push(-5),s&&f.push(s),f.push(null)),f})(n,r,!0))))}}let is="object"==typeof self?self:globalThis,iu=e=>{var t;let n,r;return(t=new Map,n=(e,n)=>(t.set(n,e),e),r=i=>{if(t.has(i))return t.get(i);let[o,a]=e[i];switch(o){case 0:case -1:return n(a,i);case 1:{let e=n([],i);for(let t of a)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of a)e[r(t)]=r(n);return e}case 3:return n(new Date(a),i);case 4:{let{source:e,flags:t}=a;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of a)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of a)e.add(r(t));return e}case 7:{let{name:e,message:t}=a;return n(new is[e](t),i)}case 8:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i)}return n(new is[o](a),i)})(0)},{toString:ic}={},{keys:id}=Object,ip=e=>{let t=typeof e;if("object"!==t||!e)return[0,t];let n=ic.call(e).slice(8,-1);switch(n){case"Array":return[1,""];case"Object":return[2,""];case"Date":return[3,""];case"RegExp":return[4,""];case"Map":return[5,""];case"Set":return[6,""]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},im=([e,t])=>0===e&&("function"===t||"symbol"===t),ih=(e,{json:t,lossy:n}={})=>{var r,i,o;let a,l,s=[];return(r=!(t||n),i=!!t,o=new Map,a=(e,t)=>{let n=s.push(e)-1;return o.set(t,n),n},l=e=>{if(o.has(e))return o.get(e);let[t,n]=ip(e);switch(t){case 0:{let i=e;switch(n){case"bigint":t=8,i=e.toString();break;case"function":case"symbol":if(r)throw TypeError("unable to serialize "+n);i=null;break;case"undefined":return a([-1],e)}return a([t,i],e)}case 1:{if(n)return a([n,[...e]],e);let r=[],i=a([t,r],e);for(let t of e)r.push(l(t));return i}case 2:{if(n)switch(n){case"BigInt":return a([n,e.toString()],e);case"Boolean":case"Number":case"String":return a([n,e.valueOf()],e)}if(i&&"toJSON"in e)return l(e.toJSON());let o=[],s=a([t,o],e);for(let t of id(e))(r||!im(ip(e[t])))&&o.push([l(t),l(e[t])]);return s}case 3:return a([t,e.toISOString()],e);case 4:{let{source:n,flags:r}=e;return a([t,{source:n,flags:r}],e)}case 5:{let n=[],i=a([t,n],e);for(let[t,i]of e)(r||!(im(ip(t))||im(ip(i))))&&n.push([l(t),l(i)]);return i}case 6:{let n=[],i=a([t,n],e);for(let t of e)(r||!im(ip(t)))&&n.push(l(t));return i}}let{message:s}=e;return a([t,{name:n,message:s}],e)})(e),s},ig="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?iu(ih(e,t)):structuredClone(e):(e,t)=>iu(ih(e,t));function iy(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let o=e.charCodeAt(n),a="";if(37===o&&n4(e.charCodeAt(n+1))&&n4(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){let t=e.charCodeAt(n+1);o<56320&&t>56319&&t<57344?(a=String.fromCharCode(o,t),i=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function iv(e,t){let n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function ib(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}let i_=function(e){var t,n;if(null==e)return ix;if("function"==typeof e)return iw(e);if("object"==typeof e){return Array.isArray(e)?function(e){let t=[],n=-1;for(;++n<e.length;)t[n]=i_(e[n]);return iw(function(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1})}(e):(t=e,iw(function(e){let n;for(n in t)if(e[n]!==t[n])return!1;return!0}))}if("string"==typeof e){return n=e,iw(function(e){return e&&e.type===n})}throw Error("Expected function, string, or object as test")};function iw(e){return function(t,n,r){return!!(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function ix(){return!0}let iE=[];function ik(e,t,n,r){var i,o,a;let l,s,u,c,d,f;"function"==typeof t&&"function"!=typeof n?(s=void 0,u=t,l=n):(s=t,u=n,l=r),i=s,o=function(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return u(e,r,n)},a=l,"function"==typeof i&&"function"!=typeof o?(a=o,o=i):c=i,d=i_(c),f=a?-1:1,(function e(t,n,r){let l=t&&"object"==typeof t?t:{};if("string"==typeof l.type){let e="string"==typeof l.tagName?l.tagName:"string"==typeof l.name?l.name:void 0;Object.defineProperty(s,"name",{value:"node ("+t.type+(e?"<"+e+">":"")+")"})}return s;function s(){var l;let s,u,c,p=iE;if((!i||d(t,n,r[r.length-1]||void 0))&&!1===(p=Array.isArray(l=o(t,r))?l:"number"==typeof l?[!0,l]:null==l?iE:[l])[0])return p;if("children"in t&&t.children&&t.children&&"skip"!==p[0])for(u=(a?t.children.length:-1)+f,c=r.concat(t);u>-1&&u<t.children.length;){if(!1===(s=e(t.children[u],u,c)())[0])return s;u="number"==typeof s[1]?s[1]:u+f}return p}})(e,void 0,[])()}function iS(e,t){let n=t.referenceType,r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];let i=e.all(t),o=i[0];o&&"text"===o.type?o.value="["+o.value:i.unshift({type:"text",value:"["});let a=i[i.length-1];return a&&"text"===a.type?a.value+=r:i.push({type:"text",value:r}),i}function iO(e){let t=e.spread;return null==t?e.children.length>1:t}function iD(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;9===t||32===t;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}let iC={blockquote:function(e,t){let n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){let n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){let n=t.value?t.value+"\n":"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o={type:"element",tagName:"pre",properties:{},children:[o=e.applyData(t,o)]},e.patch(t,o),o},delete:function(e,t){let n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){let n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){let n,r="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",i=String(t.identifier).toUpperCase(),o=iy(i.toLowerCase()),a=e.footnoteOrder.indexOf(i),l=e.footnoteCounts.get(i);void 0===l?(l=0,e.footnoteOrder.push(i),n=e.footnoteOrder.length):n=a+1,l+=1,e.footnoteCounts.set(i,l);let s={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+o,id:r+"fnref-"+o+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(n)}]};e.patch(t,s);let u={type:"element",tagName:"sup",properties:{},children:[s]};return e.patch(t,u),e.applyData(t,u)},heading:function(e,t){let n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){let n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return iS(e,t);let i={src:iy(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(i.title=r.title);let o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)},image:function(e,t){let n={src:iy(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){let n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);let r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return iS(e,t);let i={href:iy(r.url||"")};null!==r.title&&void 0!==r.title&&(i.title=r.title);let o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)},link:function(e,t){let n={href:iy(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);let r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){let r=e.all(t),i=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=iO(n[r])}return t}(n):iO(t),o={},a=[];if("boolean"==typeof t.checked){let e,n=r[0];n&&"element"===n.type&&"p"===n.tagName?e=n:(e={type:"element",tagName:"p",properties:{},children:[]},r.unshift(e)),e.children.length>0&&e.children.unshift({type:"text",value:" "}),e.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<r.length;){let e=r[l];(i||0!==l||"element"!==e.type||"p"!==e.tagName)&&a.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||i?a.push(e):a.push(...e.children)}let s=r[r.length-1];s&&(i||"element"!==s.type||"p"!==s.tagName)&&a.push({type:"text",value:"\n"});let u={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,u),e.applyData(t,u)},list:function(e,t){let n={},r=e.all(t),i=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++i<r.length;){let e=r[i];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}let o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)},paragraph:function(e,t){let n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){let n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){let n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},o=nE(t.children[1]),a=nx(t.children[t.children.length-1]);o&&a&&(r.position={start:o,end:a}),i.push(r)}let o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)},tableCell:function(e,t){let n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){let r=n?n.children:void 0,i=0===(r?r.indexOf(t):1)?"th":"td",o=n&&"table"===n.type?n.align:void 0,a=o?o.length:t.children.length,l=-1,s=[];for(;++l<a;){let n=t.children[l],r={},a=o?o[l]:void 0;a&&(r.align=a);let u={type:"element",tagName:i,properties:r,children:[]};n&&(u.children=e.all(n),e.patch(n,u),u=e.applyData(n,u)),s.push(u)}let u={type:"element",tagName:"tr",properties:{},children:e.wrap(s,!0)};return e.patch(t,u),e.applyData(t,u)},text:function(e,t){let n={type:"text",value:function(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,o=[];for(;r;)o.push(iD(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(iD(t.slice(i),i>0,!1)),o.join("")}(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){let n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:iF,yaml:iF,definition:iF,footnoteDefinition:iF};function iF(){}let iA={}.hasOwnProperty,iP={};function iT(e,t){e.position&&(t.position=function(e){let t=nE(e),n=nx(e);if(t&&n)return{start:t,end:n}}(e))}function iV(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;"string"==typeof t&&("element"===n.type?n.tagName=t:n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}),"element"===n.type&&i&&Object.assign(n.properties,ig(i)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function iM(e,t){let n=[],r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function ij(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function iI(e,t){let n,r,i,o,a=(n=t||iP,r=new Map,i=new Map,o={all:function(e){let t=[];if("children"in e){let n=e.children,r=-1;for(;++r<n.length;){let i=o.one(n[r],e);if(i){if(r&&"break"===n[r-1].type&&(Array.isArray(i)||"text"!==i.type||(i.value=ij(i.value)),!Array.isArray(i)&&"element"===i.type)){let e=i.children[0];e&&"text"===e.type&&(e.value=ij(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t},applyData:iV,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...iC,...n.handlers},one:function(e,t){let n=e.type,r=o.handlers[n];if(iA.call(o.handlers,n)&&r)return r(o,e,t);if(o.options.passThrough&&o.options.passThrough.includes(n)){if("children"in e){let{children:t,...n}=e,r=ig(n);return r.children=o.all(e),r}return ig(e)}return(o.options.unknownHandler||function(e,t){let n=t.data||{},r="value"in t&&!(iA.call(n,"hProperties")||iA.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)})(o,e,t)},options:n,patch:iT,wrap:iM},ik(e,function(e){if("definition"===e.type||"footnoteDefinition"===e.type){let t="definition"===e.type?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),o),l=a.one(e,void 0),s=function(e){let t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||iv,r=e.options.footnoteBackLabel||ib,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[],s=-1;for(;++s<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[s]);if(!i)continue;let o=e.all(i),a=String(i.identifier).toUpperCase(),u=iy(a.toLowerCase()),c=0,d=[],f=e.footnoteCounts.get(a);for(;void 0!==f&&++c<=f;){d.length>0&&d.push({type:"text",value:" "});let e="string"==typeof n?n:n(s,c);"string"==typeof e&&(e={type:"text",value:e}),d.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+u+(c>1?"-"+c:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof r?r:r(s,c),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}let p=o[o.length-1];if(p&&"element"===p.type&&"p"===p.tagName){let e=p.children[p.children.length-1];e&&"text"===e.type?e.value+=" ":p.children.push({type:"text",value:" "}),p.children.push(...d)}else o.push(...d);let m={type:"element",tagName:"li",properties:{id:t+"fn-"+u},children:e.wrap(o,!0)};e.patch(i,m),l.push(m)}if(0!==l.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...ig(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:"\n"}]}}(a),u=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return s&&u.children.push({type:"text",value:"\n"},s),u}function iN(e,t){return e&&"run"in e?async function(n,r){let i=iI(n,{file:r,...t});await e.run(i,r)}:function(n,r){return iI(n,{file:r,...e||t})}}function iL(e){if(e)throw e}var iq=n(9710);function iR(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}let i$=function(e,t){let n;if(void 0!==t&&"string"!=typeof t)throw TypeError('"ext" argument must be a string');iU(e);let r=0,i=-1,o=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else i<0&&(n=!0,i=o+1);return i<0?"":e.slice(r,i)}if(t===e)return"";let a=-1,l=t.length-1;for(;o--;)if(47===e.codePointAt(o)){if(n){r=o+1;break}}else a<0&&(n=!0,a=o+1),l>-1&&(e.codePointAt(o)===t.codePointAt(l--)?l<0&&(i=o):(l=-1,i=a));return r===i?i=a:i<0&&(i=e.length),e.slice(r,i)},iB=function(e){let t;if(iU(e),0===e.length)return".";let n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},iH=function(e){let t;iU(e);let n=e.length,r=-1,i=0,o=-1,a=0;for(;n--;){let l=e.codePointAt(n);if(47===l){if(t){i=n+1;break}continue}r<0&&(t=!0,r=n+1),46===l?o<0?o=n:1!==a&&(a=1):o>-1&&(a=-1)}return o<0||r<0||0===a||1===a&&o===r-1&&o===i+1?"":e.slice(o,r)},iz=function(...e){var t;let n,r,i,o=-1;for(;++o<e.length;)iU(e[o]),e[o]&&(i=void 0===i?e[o]:i+"/"+e[o]);return void 0===i?".":(iU(t=i),n=47===t.codePointAt(0),0!==(r=function(e,t){let n,r,i="",o=0,a=-1,l=0,s=-1;for(;++s<=e.length;){if(s<e.length)n=e.codePointAt(s);else if(47===n)break;else n=47;if(47===n){if(a===s-1||1===l);else if(a!==s-1&&2===l){if(i.length<2||2!==o||46!==i.codePointAt(i.length-1)||46!==i.codePointAt(i.length-2)){if(i.length>2){if((r=i.lastIndexOf("/"))!==i.length-1){r<0?(i="",o=0):o=(i=i.slice(0,r)).length-1-i.lastIndexOf("/"),a=s,l=0;continue}}else if(i.length>0){i="",o=0,a=s,l=0;continue}}t&&(i=i.length>0?i+"/..":"..",o=2)}else i.length>0?i+="/"+e.slice(a+1,s):i=e.slice(a+1,s),o=s-a-1;a=s,l=0}else 46===n&&l>-1?l++:l=-1}return i}(t,!n)).length||n||(r="."),r.length>0&&47===t.codePointAt(t.length-1)&&(r+="/"),n?"/"+r:r)};function iU(e){if("string"!=typeof e)throw TypeError("Path must be a string. Received "+JSON.stringify(e))}function iW(e){return!!(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}let iY=["history","path","basename","stem","extname","dirname"];class iJ{constructor(e){let t,n;t=e?iW(e)?{path:e}:"string"==typeof e||function(e){return!!(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":"/",this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<iY.length;){const e=iY[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)iY.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?i$(this.path):void 0}set basename(e){iG(e,"basename"),iZ(e,"basename"),this.path=iz(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?iB(this.path):void 0}set dirname(e){iQ(this.basename,"dirname"),this.path=iz(e||"",this.basename)}get extname(){return"string"==typeof this.path?iH(this.path):void 0}set extname(e){if(iZ(e,"extname"),iQ(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw Error("`extname` must start with `.`");if(e.includes(".",1))throw Error("`extname` cannot contain multiple dots")}this.path=iz(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){iW(e)&&(e=function(e){if("string"==typeof e)e=new URL(e);else if(!iW(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){let e=TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){let e=TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}let t=e.pathname,n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){let e=t.codePointAt(n+2);if(70===e||102===e){let e=TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}(e)),iG(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?i$(this.path,this.extname):void 0}set stem(e){iG(e,"stem"),iZ(e,"stem"),this.path=iz(this.dirname||"",e+(this.extname||""))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new nF(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return void 0===this.value?"":"string"==typeof this.value?this.value:new TextDecoder(e||void 0).decode(this.value)}}function iZ(e,t){if(e&&e.includes("/"))throw Error("`"+t+"` cannot be a path: did not expect `/`")}function iG(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function iQ(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}let iK=function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},iX={}.hasOwnProperty;class i0 extends iK{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=function(){let e=[],t={run:function(...t){let n=-1,r=t.pop();if("function"!=typeof r)throw TypeError("Expected function as last argument, not "+r);!function i(o,...a){let l=e[++n],s=-1;if(o)return void r(o);for(;++s<t.length;)(null===a[s]||void 0===a[s])&&(a[s]=t[s]);t=a,l?(function(e,t){let n;return function(...t){let o,a=e.length>t.length;a&&t.push(r);try{o=e.apply(this,t)}catch(e){if(a&&n)throw e;return r(e)}a||(o instanceof Promise?o.then(i,r):o instanceof Error?r(o):i(o))};function r(e,...i){n||(n=!0,t(e,...i))}function i(e){r(null,e)}})(l,i)(...a):r(null,...a)}(null,...t)},use:function(n){if("function"!=typeof n)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}()}copy(){let e=new i0,t=-1;for(;++t<this.attachers.length;){let n=this.attachers[t];e.use(...n)}return e.data(iq(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2==arguments.length?(i3("data",this.frozen),this.namespace[e]=t,this):iX.call(this.namespace,e)&&this.namespace[e]||void 0:e?(i3("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;for(;++this.freezeIndex<this.attachers.length;){let[e,...t]=this.attachers[this.freezeIndex];if(!1===t[0])continue;!0===t[0]&&(t[0]=void 0);let n=e.call(this,...t);"function"==typeof n&&this.transformers.use(n)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=i9(e),n=this.parser||this.Parser;return i2("parse",n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),i2("process",this.parser||this.Parser),i4("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let o=i9(e),a=n.parse(o);function l(e,n){e||!n?i(e):r?r(n):t(void 0,n)}n.run(a,o,function(e,t,r){var i,o;if(e||!t||!r)return l(e);let a=n.stringify(t,r);"string"==typeof(i=a)||(o=i)&&"object"==typeof o&&"byteLength"in o&&"byteOffset"in o?r.value=a:r.result=a,l(e,r)})}}processSync(e){let t,n=!1;return this.freeze(),i2("processSync",this.parser||this.Parser),i4("processSync",this.compiler||this.Compiler),this.process(e,function(e,r){n=!0,iL(e),t=r}),i6("processSync","process",n),t}run(e,t,n){i5(e),this.freeze();let r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,o){let a=i9(t);r.run(e,a,function(t,r,a){let l=r||e;t?o(t):i?i(l):n(void 0,l,a)})}}runSync(e,t){let n,r=!1;return this.run(e,t,function(e,t){iL(e),n=t,r=!0}),i6("runSync","run",r),n}stringify(e,t){this.freeze();let n=i9(t),r=this.compiler||this.Compiler;return i4("stringify",r),i5(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(i3("use",this.frozen),null==e);else if("function"==typeof e)a(e,t);else if("object"==typeof e)Array.isArray(e)?o(e):i(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(!("plugins"in e)&&!("settings"in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=iq(!0,r.settings,e.settings))}function o(e){let t=-1;if(null==e);else if(Array.isArray(e))for(;++t<e.length;)!function(e){if("function"==typeof e)a(e,[]);else if("object"==typeof e)if(Array.isArray(e)){let[t,...n]=e;a(t,n)}else i(e);else throw TypeError("Expected usable value, not `"+e+"`")}(e[t]);else throw TypeError("Expected a list of plugins, not `"+e+"`")}function a(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(-1===i)n.push([e,...t]);else if(t.length>0){let[r,...o]=t,a=n[i][1];iR(a)&&iR(r)&&(r=iq(!0,a,r)),n[i]=[e,r,...o]}}}}let i1=new i0().freeze();function i2(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `parser`")}function i4(e,t){if("function"!=typeof t)throw TypeError("Cannot `"+e+"` without `compiler`")}function i3(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function i5(e){if(!iR(e)||"string"!=typeof e.type)throw TypeError("Expected node, got `"+e+"`")}function i6(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function i9(e){var t;return(t=e)&&"object"==typeof t&&"message"in t&&"messages"in t?e:new iJ(e)}let i7=[],i8={allowDangerousHtml:!0},oe=/^(https?|ircs?|mailto|xmpp)$/i,ot=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function on(e){let t=e.allowedElements,n=e.allowElement,r=e.children||"",i=e.className,o=e.components,a=e.disallowedElements,l=e.rehypePlugins||i7,s=e.remarkPlugins||i7,u=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...i8}:i8,c=e.skipHtml,d=e.unwrapDisallowed,f=e.urlTransform||or,p=i1().use(il).use(s).use(iN,u).use(l),m=new iJ;for(let t of("string"==typeof r&&(m.value=r),ot))Object.hasOwn(e,t.from)&&(t.from,t.to&&t.to,t.id);let h=p.parse(m),g=p.runSync(h,m);return i&&(g={type:"element",tagName:"div",properties:{className:i},children:"root"===g.type?g.children:[g]}),ik(g,function(e,r,i){if("raw"===e.type&&i&&"number"==typeof r)return c?i.children.splice(r,1):i.children[r]={type:"text",value:e.value},r;if("element"===e.type){let t;for(t in nU)if(Object.hasOwn(nU,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=nU[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=f(String(n||""),t,e))}}if("element"===e.type){let o=t?!t.includes(e.tagName):!!a&&a.includes(e.tagName);if(!o&&n&&"number"==typeof r&&(o=!n(e,r,i)),o&&i&&"number"==typeof r)return d&&e.children?i.children.splice(r,1,...e.children):i.children.splice(r,1),r}}),function(e,t){var n,r,i,o;let a;if(!t||void 0===t.Fragment)throw TypeError("Expected `Fragment` in options");let l=t.filePath||void 0;if(t.development){if("function"!=typeof t.jsxDEV)throw TypeError("Expected `jsxDEV` in options when `development: true`");n=l,r=t.jsxDEV,a=function(e,t,i,o){let a=Array.isArray(i.children),l=nE(e);return r(t,i,o,a,{columnNumber:l?l.column-1:void 0,fileName:n,lineNumber:l?l.line:void 0},void 0)}}else{if("function"!=typeof t.jsx)throw TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw TypeError("Expected `jsxs` in production options");i=t.jsx,o=t.jsxs,a=function(e,t,n,r){let a=Array.isArray(n.children)?o:i;return r?a(t,n,r):a(t,n)}}let s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:a,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:l,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?np:nf,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},u=nN(s,e,void 0);return u&&"string"!=typeof u?u:s.create(e,s.Fragment,{children:u||void 0},void 0)}(g,{Fragment:nW.Fragment,components:o,ignoreInvalidStyle:!0,jsx:nW.jsx,jsxs:nW.jsxs,passKeys:!0,passNode:!0})}function or(e){let t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t<0||i>-1&&t>i||n>-1&&t>n||r>-1&&t>r||oe.test(e.slice(0,t))?e:""}let oi={a:({node:e,...t})=>d().createElement("a",{...t,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer"})},oo=({markdown:e})=>d().createElement("div",{className:"-esm-form-engine__markdown-wrapper__markdownWrapper___N6Orn"},d().createElement(on,{children:e,unwrapDisallowed:!0,allowedElements:["h1","h2","h3","h4","h5","h6","p","strong","em","code","pre","ul","ol","li","a","blockquote","hr","br"],components:oi})),oa={boldedLabel:"-esm-form-engine__multi-select__boldedLabel___-TJAY",errorLabel:"-esm-form-engine__multi-select__errorLabel___Cx0K1",selectionDisplay:"-esm-form-engine__multi-select__selectionDisplay___KJIF4",tagContainer:"-esm-form-engine__multi-select__tagContainer___jtOs2",checkbox:"-esm-form-engine__multi-select__checkbox___m66zk"},ol={boldedLabel:"-esm-form-engine__number__boldedLabel___baNvc",errorLabel:"-esm-form-engine__number__errorLabel___vJnNs",controlWidthConstrained:"-esm-form-engine__number__controlWidthConstrained___wjS56"},os="-esm-form-engine__toggle__boldedLabel___IF1zX";var ou=n(7942),oc=n(9600);let od=function(){return oc.A.Date.now()};var of=/\s/;let op=function(e){for(var t=e.length;t--&&of.test(e.charAt(t)););return t};var om=/^\s+/,oh=n(4089),og=0/0,oy=/^[-+]0x[0-9a-f]+$/i,ov=/^0b[01]+$/i,ob=/^0o[0-7]+$/i,o_=parseInt;let ow=function(e){if("number"==typeof e)return e;if((0,oh.A)(e))return og;if((0,ou.A)(e)){var t,n="function"==typeof e.valueOf?e.valueOf():e;e=(0,ou.A)(n)?n+"":n}if("string"!=typeof e)return 0===e?e:+e;e=(t=e)?t.slice(0,op(t)+1).replace(om,""):t;var r=ov.test(e);return r||ob.test(e)?o_(e.slice(2),r?2:8):oy.test(e)?og:+e};var ox=Math.max,oE=Math.min;let ok=function(e,t,n){var r,i,o,a,l,s,u=0,c=!1,d=!1,f=!0;if("function"!=typeof e)throw TypeError("Expected a function");function p(t){var n=r,o=i;return r=i=void 0,u=t,a=e.apply(o,n)}function m(e){var n=e-s,r=e-u;return void 0===s||n>=t||n<0||d&&r>=o}function h(){var e,n,r,i=od();if(m(i))return g(i);l=setTimeout(h,(e=i-s,n=i-u,r=t-e,d?oE(r,o-n):r))}function g(e){return(l=void 0,f&&r)?p(e):(r=i=void 0,a)}function y(){var e,n=od(),o=m(n);if(r=arguments,i=this,s=n,o){if(void 0===l)return u=e=s,l=setTimeout(h,t),c?p(e):a;if(d)return clearTimeout(l),l=setTimeout(h,t),p(s)}return void 0===l&&(l=setTimeout(h,t)),a}return t=ow(t)||0,(0,ou.A)(n)&&(c=!!n.leading,o=(d="maxWait"in n)?ox(ow(n.maxWait)||0,t):o,f="trailing"in n?!!n.trailing:f),y.cancel=function(){void 0!==l&&clearTimeout(l),u=0,r=s=i=l=void 0},y.flush=function(){return void 0===l?a:g(od())},y},oS=[{name:"drug",datasource:{name:"drug_datasource",config:{class:"8d490dfc-c2cc-11de-8d13-0010c6dffd0f"}}},{name:"select-concept-answers",datasource:{name:"select_concept_answers_datasource",config:{concept:""}}},{name:"encounter-provider",datasource:{name:"provider_datasource"}},{name:"encounter-role",datasource:{name:"encounter_role_datasource"}},{name:"encounter-location",datasource:{name:"location_datasource"}},{name:"problem",datasource:{name:"problem_datasource",config:{class:["8d4918b0-c2cc-11de-8d13-0010c6dffd0f","8d492954-c2cc-11de-8d13-0010c6dffd0f","8d492b2a-c2cc-11de-8d13-0010c6dffd0f"]}}}],oO=e=>oS.find(t=>t.name===e),oD=({field:e,errors:t,warnings:n,setFieldValue:r})=>{let{t:i}=(0,eO.useTranslation)(),[o,a]=(0,c.useState)([]),[l,s]=(0,c.useState)(!1),[u,f]=(0,c.useState)(!1),[p,m]=(0,c.useState)(""),h=(0,c.useRef)(!1),[y,v]=(0,c.useState)(null),[b,_]=(0,c.useState)({}),w=(e=>{let t=e.questionOptions.config?.referencedField,{methods:{control:n}}=tD();return Z({control:n,name:t,exact:!0,disabled:!t})})(e),x=(0,tk.H)(e.questionOptions.isSearchable),{layoutType:E,sessionMode:k,workspaceLayout:S,methods:{control:O,getFieldState:D,getValues:C}}=tD(),F=Z({control:O,name:e.id,exact:!0}),{isDirty:A}=D(e.id),P=(0,c.useMemo)(()=>!!(eR(k)||(0,tk.H)(e.readonly))&&th(e.inlineRendering,E,S,k),[k,e.readonly,e.inlineRendering,E,S]),T=(0,c.useMemo)(()=>o.find(e=>e.uuid==F)||null,[o,F]),V=(0,c.useRef)(0),M=(0,c.useMemo)(()=>ok((t,n)=>{let r=V.current;f(!0),n.fetchData(t,b).then(t=>{r===V.current&&(t.length&&a(r=>{let i=C(e.id),o=r.find(e=>e.uuid==i),a=t.map(e=>n.toUuidAndDisplay(e,b));return o&&!a.some(e=>e.uuid==o.uuid)&&a.unshift(o),a}),f(!1))}).catch(e=>{r===V.current&&(console.error(e),f(!1))})},300),[b,e.id,C]),j=(0,c.useCallback)(e=>o.some(t=>t.display?.toLowerCase().includes(e.toLowerCase())),[o]);return((0,c.useEffect)(()=>{let t=e.questionOptions?.datasource?.name;_(t?e.questionOptions.datasource?.config:oO(e.questionOptions.rendering)?.datasource?.config),aW(t||e.questionOptions.rendering).then(e=>v(e))},[e.questionOptions?.datasource]),(0,c.useEffect)(()=>{let t=!1;return y&&!(0,tk.H)(e.questionOptions.isSearchable)&&(a([]),s(!0),y.fetchData(null,{...b,referencedValue:w}).then(e=>{t||(a(e.map(e=>y.toUuidAndDisplay(e,b))),s(!1))}).catch(e=>{t||(console.error(e),s(!1),a([]))})),()=>{t=!0}},[y,b,w]),(0,c.useEffect)(()=>(y&&x&&!eV(p)&&!j(p)?M(p,y):f(!1),()=>{M.cancel(),V.current++}),[y,p,x,M]),(0,c.useEffect)(()=>{let e=!1;return F&&!A&&y&&x&&!o.length&&(s(!0),y.fetchSingleItem(F,b).then(t=>{e||(a([y.toUuidAndDisplay(t,b)]),s(!1))}).catch(t=>{e||(console.error(t),s(!1))})),()=>{e=!0}},[F,A,y,x,o,b]),l)?d().createElement(g.DropdownSkeleton,null):eR(k)||(0,tk.H)(e.readonly)?d().createElement(tq,{label:i(e.label),value:F?oC(o.find(e=>e.uuid==F)):F,conceptName:e.meta?.concept?.display,isInline:P}):!e.isHidden&&d().createElement("div",{className:"-esm-form-engine__ui-select-extended__boldedLabel___MlmB3"},d().createElement(g.Layer,null,d().createElement(g.ComboBox,{id:e.id,titleText:d().createElement(tH,{field:e}),items:o,itemToElement:e=>d().createElement("span",{className:"-esm-form-engine__ui-select-extended__item___+jYTi"},e?.code&&d().createElement("span",{className:"-esm-form-engine__ui-select-extended__code___Sg-vJ"},e.code),d().createElement("span",{className:"-esm-form-engine__ui-select-extended__label___tsm2B"},e?.display)),itemToString:oC,selectedItem:T,placeholder:x?i("search","Search")+"...":null,onChange:({selectedItem:e})=>{M.cancel(),V.current++,f(!1),h.current=!0,r(e?.uuid)},disabled:e.isDisabled,readOnly:(0,tk.H)(e.readonly),invalid:t.length>0,invalidText:t.length&&t[0].message,onInputChange:t=>{if(h.current){h.current=!1;return}e.questionOptions.isSearchable&&m(t)},onBlur:e=>{e.target.value||r(null)}}),u&&d().createElement(g.InlineLoading,{className:"-esm-form-engine__ui-select-extended__loader___-txFf",description:i("searching","Searching")+"..."})))};function oC(e){return e?.code?`${e.code} ${e.display}`:e?.display??""}var oF=n(3322);function oA(e,t,n){let r=[],i=(0,oF.A)(e);return i.questionOptions.repeatOptions={...i.questionOptions.repeatOptions??{}},i.meta={repeat:{...i.meta??{},isClone:!0},initialValue:{omrsObject:t}},i.id=`${i.id}_${n}`,i.questions?.forEach(e=>{r.push(e.id),e.id=`${e.id}_${n}`,e.meta.groupId=i.id,e.meta.initialValue={omrsObject:null,refinedValue:null},e.fieldDependents=new Set,eN(e),e.hide&&e.hide.hideWhenExpression&&(e.hide.hideWhenExpression=oP(e.hide.hideWhenExpression,n,r)),e.validators?.length&&e.validators.forEach(e=>{"js_expression"===e.type&&(e.failsWhenExpression=oP(e.failsWhenExpression,n,r))}),e.questionOptions.calculate?.calculateExpression&&(e.questionOptions.calculate.calculateExpression=oP(e.questionOptions.calculate?.calculateExpression,n,r))}),i}function oP(e,t,n){let r=[...new Set(n)];if(!r.length)return e;let i=r.slice().sort((e,t)=>t.length-e.length).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return e.replace(RegExp(`\\b(?:${i})\\b`,"g"),e=>`${e}_${t}`)}let oT=[],oV={async getInitialValue(e,t,n){let r=oR(ej((t??n.domainObjectValue).obs),oT,e);return eI(e,"file")&&r?.length?o$(e,r):oM(e,r,!0)},async getPreviousValue(e,t,n){let r=t??n.previousDomainObjectValue;if(r){let t=oM(e,oR(ej(r.obs),oT,e),!1);if(!eV(t))return{value:t,display:this.getDisplayValue(e,t)}}return null},getDisplayValue:(e,t)=>{let n=e.questionOptions.rendering;return eV(t)?t:t instanceof Date?eH(e,t):"checkbox"===n?t.map(t=>e.questionOptions.answers?.find(e=>e.concept==t)?.label):"toggle"===n?t?e.questionOptions.toggleOptions.labelTrue:e.questionOptions.toggleOptions.labelFalse:u.FU.includes(n)?e.questionOptions.answers?.find(e=>e.concept==t)?.label:t},transformFieldValue:(e,t,n)=>(eN(e),!e.meta.initialValue?.omrsObject&&eV(t))?null:eI(e,"checkbox")?function(e,t=[]){let n=e.meta.initialValue?.omrsObject;if(n?.length&&eV(t))return eL(e,null,n.map(e=>oI(e)));if(n?.length&&!eV(t)){let r=n.filter(e=>!t.includes(e.value.uuid));return eL(e,t.filter(e=>!n.some(t=>t.value.uuid===e)).map(t=>oj(e,t)),r.map(e=>oI(e)))}return eL(e,t.map(t=>oj(e,t)),void 0)}(e,Array.isArray(t)?t:[t]):eI(e,"file")?function(e,t=[]){let n=t.filter(e=>e.uuid&&e.voided).map(e=>({uuid:e.uuid,voided:!0})),r=e.meta.submission.newValue=t.filter(e=>!e.uuid).map(t=>({formFieldNamespace:"rfe-forms",formFieldPath:`rfe-forms-${e.id}`,...t}));return eL(e,r,n)}(e,t):!eV(t)&&oq(e,t)?eL(e,oN(e,t),void 0):!eV(t)&&e.meta.initialValue?.omrsObject?null:e.meta.initialValue?.omrsObject&&eV(t)?eL(e,void 0,oI(e.meta.initialValue.omrsObject)):eV(t)?null:eL(e,oj(e,t),void 0),tearDown:function(){oT=[]}};function oM(e,t=[],n=!1){let r=e.questionOptions.rendering;if(e.meta||(e.meta={initialValue:{omrsObject:null,refinedValue:null}}),t.length){if("checkbox"==r)return oT.push(...t.map(e=>e.uuid)),n&&(e.meta.initialValue.omrsObject=t),t.map(e=>e.value.uuid);let i=t[0];if(n&&(e.meta.initialValue.omrsObject={...i}),oT.push(i.uuid),"string"==typeof i.value||"number"==typeof i.value){if(r.startsWith("date")){let t="timer"===e.datePickerFormat?eB(i.value):e$(i.value);return n&&(e.meta.initialValue.omrsObject.value=eY()(t).format("YYYY-MM-DD HH:mm")),t}return i.value}return"toggle"==r?i.value.uuid===u.t$:"fixed-value"==r?e.fixedValue:i.value?.uuid}return""}function oj(e,t){return eV(t)&&"obsGroup"!==e.type?null:{..."obsGroup"===e.type?{groupMembers:[]}:{value:e.questionOptions.rendering.startsWith("date")?oL(e,t):t},concept:e.questionOptions.concept,formFieldNamespace:"rfe-forms",formFieldPath:`rfe-forms-${e.id}`}}function oI(e){return{uuid:e.uuid,voided:!0}}function oN(e,t){let n=e.meta.initialValue?.omrsObject,r=e.questionOptions.rendering.startsWith("date")?oL(e,t):t;return{uuid:n.uuid,value:r,formFieldNamespace:"rfe-forms",formFieldPath:`rfe-forms-${e.id}`}}function oL(e,t){switch(e.datePickerFormat??(eI(e,"datetime")?"both":"calendar")){case"timer":return eY()(t).format("HH:mm");case"both":return eY()(t).format("YYYY-MM-DDTHH:mmZ");default:return eY()(t).format("YYYY-MM-DD")}}function oq(e,t){let n=e.meta.initialValue?.omrsObject;return!eV(n)&&(u.FU.includes(e.questionOptions.rendering)?n.value.uuid!==t:e.questionOptions.rendering.startsWith("date")?oL(e,n.value)!==oL(e,t):eI(e,"toggle")?n.value.uuid===u.t$!==t:n.value!==t)}function oR(e,t,n){let r=e.filter(e=>!!eI(n,"file")&&e.formFieldPath==`rfe-forms-${n.id}`||e.formFieldPath==`rfe-forms-${n.id}`&&e.concept.uuid==n.questionOptions.concept);if(!r?.length){let r=e.filter(e=>e.concept.uuid==n.questionOptions.concept);return t?.length?r.filter(e=>!t.includes(e.uuid)):r}return r}async function o$(e,t){let n=new AbortController,r=await Promise.all(t.map(e=>(0,s.getAttachmentByUuid)(e.uuid,n).then(e=>e.data).catch(t=>(console.error(`Failed to fetch attachment ${e.uuid}:`,t),null))));return e.meta.initialValue={omrsObject:t},r.filter(Boolean).map(e=>({uuid:e.uuid,base64Content:`${window.openmrsBase}${s.attachmentUrl}/${e.uuid}/bytes`,fileName:e.filename,fileDescription:e.comment,fileType:e.bytesContentFamily?.toLowerCase()}))}let oB={validate:(e,t)=>!eV(t)&&u.FU.includes(e.questionOptions.rendering)&&!(Array.isArray(t)?t:[t]).every(t=>e.questionOptions.answers?.find(e=>e.concept===t||e.value===t))?[{resultType:"error",errCode:"invalid.defaultValue",message:"Value not found in coded answers list"}]:eV(t)||"date"!=e.questionOptions.rendering||eY()(t).isValid()?!eV(t)&&"number"==e.questionOptions.rendering&&isNaN(t)?[{resultType:"error",errCode:"invalid.defaultValue",message:`Invalid numerical value: '${t}'`}]:[]:[{resultType:"error",errCode:"invalid.defaultValue",message:`Invalid date value: '${t}'`}]},oH=[];function oz(e,t,n){return e?{action:"NEW",concept:e,type:t?.questionOptions?.orderType||"testorder",careSetting:t?.questionOptions?.orderSettingUuid||"6f0c9a92-6f24-11e3-af88-005056821db0",orderer:n}:null}let oU=[];function oW(e,t){let n=t.meta.initialValue?.omrsObject;n&&oY(e,(Array.isArray(n)?n:[n]).map(e=>oI(e)))}function oY(e,t){t&&(Array.isArray(t)?e.push(...t):e.push(t))}function oJ(e){return!!(e.isHidden||e.isParentHidden)}function oZ(e){if("toggle"==e.questionOptions.rendering&&"boolean"!=typeof e.questionOptions.defaultValue)return e.questionOptions.defaultValue==u.t$;let t=oB.validate(e,e.questionOptions.defaultValue);return t.length?(console.error(`Default value validation errors for field "${e.id}" with value "${e.questionOptions.defaultValue}":`,t),null):e.questionOptions.defaultValue}async function oG(e,t,n,r){let i=1,{formFieldAdapters:o}=r,a=t.obs.filter(t=>t.concept.uuid===e.questionOptions.concept&&t.uuid!=e.meta.initialValue?.omrsObject?.uuid&&!oT.includes(t.uuid)),l=t.orders.filter(t=>(e.questionOptions.answers?.map(e=>e.concept)||[]).includes(t.concept?.uuid)&&!oH.includes(t.uuid));if("testOrder"===e.type)return Promise.all(l.filter(e=>!e.voided).map(async t=>{let a=oA(e,t,i++);return n[a.id]=await o[e.type].getInitialValue(a,{orders:[t]},r),a}));let s=t.diagnoses.filter(t=>!t.voided&&!oU.includes(t?.diagnosis?.coded.uuid)&&t.formFieldPath.startsWith(`rfe-forms-${e.id}_`));return"diagnosis"===e.type?Promise.all(s.map(async t=>{let i=parseInt(t.formFieldPath.split("_")[1]),a=oA(e,t,i);return n[a.id]=await o[e.type].getInitialValue(a,{diagnoses:[t]},r),oU.includes(t.diagnosis.coded.uuid)||oU.push(t.diagnosis.coded.uuid),a})):Promise.all(a.map(async t=>{let a=oA(e,t,i++);return await Promise.all(a.questions.map(async i=>{n[i.id]=await o[e.type].getInitialValue(i,{obs:[t]},r)})),oT.push(t.uuid),[a,...a.questions]})).then(e=>e.flat())}function oQ(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class oK{getDomainObject(){return this.domainObjectValue}async loadDependencies(e,t,n){return Promise.resolve({})}constructor(e){oQ(this,"formJson",void 0),oQ(this,"domainObjectValue",void 0),this.formJson=e}}var oX=n(1807),o0=n(7361),o1=n(6956),o2=n(7313),o4=n(3660),o3=n.n(o4),o5=n(1619),o6=n.n(o5);function o9(e){let[t,n]=(0,c.useState)(!0),{encounter:r,isLoading:i}=function(e){let[t,n]=(0,c.useState)(null),[r,i]=(0,c.useState)(!0),[o,a]=(0,c.useState)(null);return(0,c.useEffect)(()=>{var t;let r=new AbortController;return!eV(e.encounter)&&("string"==typeof(t=e.encounter)||!(0,o1.A)(t)&&(0,o2.A)(t)&&"[object String]"==(0,o0.A)(t))?(0,s.openmrsFetch)(`${s.restBaseUrl}/encounter/${e.encounter}?v=${u.RZ}`,{signal:r.signal}).then(e=>{n(e.data),i(!1)}).catch(e=>{a(e)}):(eV(e.encounter)||n(e.encounter),i(!1)),()=>{r.abort()}},[e.encounter]),{encounter:t,error:o,isLoading:r}}(e.formJson),{encounterRole:o,isLoading:a}=function(){let{data:e,error:t,isLoading:n}=o3()(`${s.restBaseUrl}/encounterrole?v=custom:(uuid,display,name)`,s.openmrsFetch),r=e?.data.results.find(e=>"Clinician"===e.name);return r?{encounterRole:r,error:t,isLoading:n}:{encounterRole:e?.data.results[0],error:t,isLoading:n}}(),{isLoadingPatientPrograms:l,patientPrograms:d}=((e,t)=>{let{activePrograms:n,error:r,isLoading:i}=(e=>{let t=`${s.restBaseUrl}/programenrollment?patient=${e}&v=custom:(uuid,display,program:(uuid,name,allWorkflows),dateEnrolled,dateCompleted,location:(uuid,display),states:(startDate,endDate,state:(uuid,name,retired,concept:(uuid),programWorkflow:(uuid)))`,{data:n,error:r,isLoading:i}=o6()(e?t:null,s.openmrsFetch),o=n?.data?.results.length>0?n?.data.results.sort((e,t)=>t.dateEnrolled>e.dateEnrolled?1:-1):null;return{activePrograms:o?.filter(e=>!e.dateCompleted),error:r,isLoading:i}})(t.meta?.programs?.hasProgramFields?e:null);return{patientPrograms:n,errorFetchingPatientPrograms:r,isLoadingPatientPrograms:i}})(e.patient?.id,e.formJson);return(0,c.useEffect)(()=>{n(l||i||a)},[l,i,a]),{data:{encounter:r,patientPrograms:d,encounterRole:o},isLoading:t,error:null,updateContext:(t,{setDomainObjectValue:n,setCustomDependencies:i})=>{e.processor.domainObjectValue=r,n(r),i(e=>({...e,patientPrograms:d,defaultEncounterRole:o}))}}}let o7={checkbox:[],toggle:!1,text:""},o8=["encounterProvider","encounterDatetime","encounterLocation","patientIdentifier","encounterRole","programState","personAttribute"];class ae extends oK{prepareFormSchema(e){let t=new Set;return e.pages.forEach(n=>{n.sections.forEach(r=>{r.questions.forEach(i=>{!function e(n,r,i,o){n.id&&t.add(n.id),n.inlineRendering=n.inlineRendering??r.inlineRendering??i.inlineRendering??o.inlineRendering,n.readonly=n.readonly??r.readonly??i.readonly??o.readonly,n.questionOptions?.rendering!="fixed-value"||n.meta.fixedValue||(n.meta.fixedValue=n.value,delete n.value),(n.questionOptions?.rendering=="group"||"obsGroup"===n.type)&&n.questions?.forEach(t=>(t.readonly=t.readonly??n.readonly,e(t,r,i,o)))}(i,r,n,e)})})}),function(e,t){let n=/(['"])([a-zA-Z_][a-zA-Z0-9_]*)\1/g;function r(e){e.questionOptions?.calculate?.calculateExpression&&function(e,r){for(let i of e.matchAll(n)){let e=i[2];t.has(e)&&console.error(`The calculateExpression for the field '${r}' incorrectly quotes the field ID '${e}' as a string. Field IDs must be referenced as variables without quotes to access their values. Remove the quotes: use ${e} instead of '${e}'.`)}}(e.questionOptions.calculate.calculateExpression,e.id),e.questions&&e.questions.forEach(r)}e.pages.forEach(e=>{e.sections.forEach(e=>{e.questions.forEach(r)})})}(e,t),e}async processSubmission(e,t){var n,r,i,o,a,l;let{encounterRole:u,encounterProvider:c,encounterDate:d,encounterLocation:f}=function(e){let{formFields:t,location:n,currentProvider:r,customDependencies:i,sessionDate:o,domainObjectValue:a,visit:l}=e,{defaultEncounterRole:s}=i,u=t.find(e=>"encounterRole"===e.type)?.meta.submission?.newValue||s?.uuid,c=t.find(e=>"encounterProvider"===e.type)?.meta.submission?.newValue||r.uuid,d=t.find(e=>"encounterDatetime"===e.type)?.meta.submission?.newValue,f=l?.stopDatetime?o:void 0;return{encounterRole:u,encounterProvider:c,encounterDate:d??(a?.encounterDatetime?new Date(a.encounterDatetime):f),encounterLocation:t.find(e=>"encounterLocation"===e.type)?.meta.submission?.newValue||a?.location?.uuid||n.uuid}}(e),p=(e,t,n)=>(0,s.translateFrom)(oX.L,e,t,n),m=e.formFields.filter(e=>"patientIdentifier"===e.type&&eq(e)).map(e=>e.meta.submission.newValue),h=function(e,t,n,r,i){var o,a;let{patient:l,formJson:s,domainObjectValue:u,formFields:c,visit:d,deletedFields:f}=e,p=[...c,...f],m=[];o=m,(a=p).filter(e=>(function(e){let{questionOptions:{isTransient:t},type:n}=e;return!t&&!!["obs","obsGroup"].includes(n)&&!e.meta.groupId&&(!!(oJ(e)&&e.meta.initialValue?.omrsObject)||!oJ(e)&&("obsGroup"===n||eq(e)))})(e)).forEach(e=>{var t,n,r;return t=o,n=e,r=a,void(oJ(n)&&n.meta.initialValue.omrsObject?oW(t,n):"obsGroup"===n.type?function e(t,n,r){if(n.meta.submission?.voidedValue)return void oY(t,n.meta.submission.voidedValue);let i=oj(n,null);n.meta.initialValue?.omrsObject&&(i.uuid=n.meta.initialValue.omrsObject.uuid),n.questions.forEach(t=>{let n=r.find(e=>e.id===t.id)??t;if(oJ(n))oW(i.groupMembers,n);else if("obsGroup"===n.type){let t=[];e(t,n,r),oY(i.groupMembers,t)}else eq(n)&&(oY(i.groupMembers,n.meta.submission.newValue),oY(i.groupMembers,n.meta.submission.voidedValue))}),(i.groupMembers?.length||i.voided)&&oY(t,i)}(t,n,r):(eI(n,"file")||oY(t,n.meta.submission.newValue),oY(t,n.meta.submission.voidedValue)))});let h=p.filter(e=>"testOrder"===e.type&&eq(e)).flatMap(e=>oJ(e)?[e.meta.submission.newValue?void 0:e.meta.submission.voidedValue]:[e.meta.submission.newValue,e.meta.submission.voidedValue]).filter(e=>e),g=p.filter(e=>"diagnosis"===e.type&&eq(e)).map(e=>oJ(e)?e.meta.submission.newValue?void 0:e.meta.submission.voidedValue:e.meta.submission.newValue||e.meta.submission.voidedValue).filter(e=>e),y={};return u?(Object.assign(y,u),-1===y.encounterProviders.findIndex(e=>e.provider.uuid==r)&&(y.encounterProviders=[...y.encounterProviders,{provider:r,encounterRole:n}]),t&&(y.encounterDatetime=t),y.location=i,y.form={uuid:s.uuid},d&&(y.visit=d.uuid),y.obs=m,y.orders=h,y.diagnoses=g):(y={patient:l.id,location:i,encounterType:s.encounterType,encounterProviders:[{provider:r,encounterRole:n}],obs:m,form:{uuid:s.uuid},visit:d?.uuid,orders:h,diagnoses:g},t&&(y.encounterDatetime=t)),y}(e,d,u,c,f);try{await Promise.all((n=e.patient,m.map(e=>(0,e6.savePatientIdentifier)(e,n.id)))),m?.length&&(0,s.showSnackbar)({title:p("patientIdentifiersSaved","Patient identifier(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){let e=(0,tx.j)(t);return Promise.reject({title:p("errorSavingPatientIdentifiers","Error saving patient identifiers"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}try{let t=e.formFields.filter(e=>"personAttribute"===e.type&&eq(e)).map(e=>e.meta.submission.newValue);await Promise.all((r=e.patient,t.map(e=>(0,e6.savePersonAttribute)(e,r.id)))),t?.length&&(0,s.showSnackbar)({title:p("personAttributesSaved","Person attribute(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){let e=(0,tx.j)(t);return Promise.reject({title:p("errorSavingPersonAttributes","Error saving person attributes"),description:e.join(", "),kind:"error",critical:!0})}try{let t,n,r,l=(i=e.formFields,o=e.patient,a=e.customDependencies.patientPrograms,t=i.filter(e=>"programState"===e.type&&eq(e)),n=new Map,t.forEach(e=>{let t=e.questionOptions.programUuid,r=e.meta.submission.newValue,i=a.find(e=>e.program.uuid===t);i?n.has(t)?n.get(t).states.push(r):n.set(t,{uuid:i.uuid,states:[r]}):n.has(t)?n.get(t).states.push(r):n.set(t,{patient:o.id,program:t,states:[r],dateEnrolled:eY()().format()})}),Array.from(n.values())),u=await await (r=new AbortController,Promise.all(l.map(e=>(0,e6.saveProgramEnrollment)(e,r))));u?.length&&(0,s.showSnackbar)({title:p("patientProgramsSaved","Patient program(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){let e=(0,tx.j)(t);return Promise.reject({title:p("errorSavingPatientPrograms","Error saving patient program(s)"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}try{let{data:n}=await (0,e6.saveEncounter)(t,h,h.uuid),r=n.orders.map(e=>e.orderNumber),i=n.diagnoses.map(e=>e.display);r.length&&(0,s.showSnackbar)({title:p("ordersSaved","Order(s) saved successfully"),subtitle:r.join(", "),kind:"success",isLowContrast:!0}),i.length&&(0,s.showSnackbar)({title:p("diagnosisSaved","Diagnosis(es) saved successfully"),subtitle:i.join(", "),kind:"success",isLowContrast:!0});try{let t,r=await (l=e.formFields,t=l?.filter(e=>e?.questionOptions.rendering==="file"&&eq(e)),!t?.length?[]:Promise.all(t.flatMap(e=>{let t="string"==typeof n?.patient?n?.patient:n?.patient?.uuid;return(e.meta.submission.newValue??[]).map(e=>(0,e6.createAttachment)(t,n.uuid,e))})));r?.length&&(0,s.showSnackbar)({title:p("attachmentsSaved","Attachment(s) saved successfully"),kind:"success",isLowContrast:!0})}catch(t){console.error("Error saving attachments",t);let e=(0,tx.j)(t);return Promise.reject({title:p("errorSavingAttachments","Error saving attachment(s)"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}return n}catch(t){console.error("Error saving encounter",t);let e=(0,tx.j)(t);return Promise.reject({title:p("errorSavingEncounter","Error saving encounter"),subtitle:e.join(", "),kind:"error",isLowContrast:!1})}}getCustomHooks(){return{useCustomHooks:o9}}async getInitialValues(e){let{domainObjectValue:t,formFields:n,formFieldAdapters:r}=e,i={},o=[];if(t){await Promise.all(n.map(async n=>{let a=r[n.type];if(n.meta.initialValue?.omrsObject&&!eV(n.meta.initialValue.refinedValue)){i[n.id]=n.meta.initialValue.refinedValue;return}if(a){eI(n,"repeating")&&!n.meta?.repeat?.isClone&&o.push(n);let r=null;try{r=await a.getInitialValue(n,t,e),n.meta.initialValue.refinedValue=r}catch(e){console.error(e)}if("obsGroup"===n.type)return;if(eV(r)?eV(n.questionOptions.defaultValue)?i[n.id]=o7[n.questionOptions.rendering]??"":i[n.id]=oZ(n):i[n.id]=r,n.questionOptions.calculate?.calculateExpression)try{await at(n,i,e)}catch(e){console.error(e)}}else console.warn(`No adapter found for field type ${n.type}`)}));let a=await Promise.all(o.flatMap(n=>oG(n,t,i,e))).then(e=>e.flat());n.push(...a)}else{let t=n.filter(e=>"group"!==e.questionOptions.rendering&&"obsGroup"!==e.type),o=[];await Promise.all(t.map(async t=>{let n=r[t.type];if(i[t.id]=o7[t.questionOptions.rendering]??null,eV(i[t.id])&&o8.includes(t.type))try{i[t.id]=await n.getInitialValue(t,null,e)}catch(e){console.error(e)}t.questionOptions.defaultValue&&(i[t.id]=oZ(t)),t.questionOptions.calculate?.calculateExpression&&o.push(t)})),await Promise.all(o.map(async t=>{try{await at(t,i,e)}catch(e){console.error(e)}}))}return i}async loadDependencies(e,t,{setPreviousDomainObjectValue:n}){let{patient:r,formJson:i}=e;return n(await (0,e6.getPreviousEncounter)(r?.id,i.encounterType)),e}async getHistoricalValue(e,t){let{formFields:n,sessionMode:r,patient:i,methods:{getValues:o},formFieldAdapters:a,previousDomainObjectValue:l,visit:s}=t,c=a[e.type];if(e.historicalExpression){let t=await td(e.historicalExpression,{value:e,type:"field"},n,o(),{mode:r,patient:i,previousEncounter:l,visit:s});return t?((e,t)=>{let n=e.questionOptions.rendering;if("object"!=typeof t)return{value:t,display:t};let r="Observation"===t.resourceType?function(e,t){try{return{obsDatetime:e.effectiveDateTime,uuid:e.id,concept:{uuid:e.code.coding[0]?.code,display:e.code.coding[0]?.display},value:function(e,t){switch(t){case"toggle":return e.valueBoolean?{uuid:u.t$}:{uuid:u.Mi};case"date":case"datetime":return e.valueDateTime;case"number":return e.valueQuantity?.value??null;case"radio":case"checkbox":case"select":case"content-switcher":return e.valueCodeableConcept?.coding[0]?{uuid:e.valueCodeableConcept?.coding[0].code,name:{name:e.valueCodeableConcept?.coding[0].display}}:null;default:return e.valueString}}(e,t)}}catch(e){return console.error("Error converting FHIR Obs to OpenMRS modelling",e),null}}(t,n):t;if(!r)return{value:null,display:null};if("string"==typeof r.value||"number"==typeof r.value){if("date"===n||"datetime"===n){let t="timer"===e.datePickerFormat?eB(`${r.value}`):e$(`${r.value}`);return{value:t,display:eY()(t).format("YYYY-MM-DD HH:mm")}}return{value:r.value,display:r.value}}return["toggle","checkbox"].includes(n)?{value:r.value?.uuid,display:r.value?.name?.name}:{value:r.value?.uuid,display:e.questionOptions.answers?.find(e=>e.concept===r.value?.uuid)?.label}})(e,t):null}return l&&e.questionOptions.enablePreviousValue?await c.getPreviousValue(e,l,t):null}}async function at(e,t,n){let{formFields:r,sessionMode:i,patient:o,visit:a}=n,l=e.questionOptions.calculate.calculateExpression,s=await td(l,{value:e,type:"field"},r,t,{mode:i,patient:o,visit:a});eV(s)||(t[e.id]=s)}function an(e,t){let n=t.obs?.find(t=>t.formFieldPath.includes(e))?.value;return("object"==typeof n?n?.uuid:n)??null}async function ar(e,t,n,r,i){return Promise.all(e.map(async({postAction:e,config:o,actionId:a,enabled:l})=>{try{let i=[];if(t)if(t.forEach(e=>{e?.data&&i.push(e.data),e?.uuid&&i.push(e)}),i.length)(!l||function(e,t){let n=t[0];try{let t=(0,s.compile)(e),r={};for(let e of(0,s.extractVariableNames)(t))r[e]=an(e,n);return r.useFieldValue=e=>an(e,n),r.undefined=null,!!(0,s.evaluate)(t,r)}catch(e){throw Error("Error evaluating expression",{cause:e})}}(l,i))&&await e.applyAction({patient:n,sessionMode:r,encounters:i},o);else throw Error("No encounter data to process post submission action");else throw Error("No handlers available to process post submission action")}catch(t){let e=(0,tx.j)(t);(0,s.showSnackbar)({title:String(i("errorDescriptionTitle",a?a.replace(/([a-z])([A-Z])/g,"$1 $2"):"Post Submission Error")),subtitle:String(i("errorDescription","{{errors}}",{errors:e.join(", ")})),kind:"error",isLowContrast:!1})}}))}let ai=(0,c.createContext)(void 0),ao=({patient:e,patientUUID:t,sessionMode:n,sessionDate:r,formJson:i,workspaceLayout:o,location:a,provider:l,visit:u,isFormExpanded:f=!0,children:p,isLoadingDependencies:m=!1,formSubmissionProps:h,hideFormCollapseToggle:g,handleConfirmQuestionDeletion:y,setIsFormDirty:v})=>{let{t:b}=(0,eO.useTranslation)(),_=(0,c.useRef)(void 0),w=(0,c.useRef)({}),x=(0,s.useLayoutType)(),{isSubmitting:E,setIsSubmitting:k,onSubmit:S,onError:O,handleClose:D}=h,[C,F]=(0,c.useState)(!1),A=function(e){let[t,n]=(0,c.useState)([]);return(0,c.useEffect)(()=>{let t=[];e?.length&&e.map(e=>{let n="string"==typeof e?e:e.actionId;az(n)?.then(r=>t.push({postAction:r,config:e.config,actionId:n,enabled:e.enabled}))}),n(t)},[e]),t}(i.postSubmissionActions),P=new AbortController,T=(0,c.useCallback)((e,t,n)=>{t?w.current[e]=n:_.current=n},[]),V=(0,c.useRef)({EncounterFormProcessor:ae}),M=(0,c.useCallback)(()=>{let e=[_.current,...Object.values(w.current)],t=e.every(e=>(function(e){let{formFields:t,formFieldValidators:n,patient:r,sessionMode:i,addInvalidField:o,updateFormField:a,methods:{getValues:l,trigger:s}}=e,u=l();return 0===t.filter(e=>!e.isHidden&&!e.isParentHidden&&!e.isDisabled&&!e.meta.submission?.unspecified).flatMap(e=>e.validators?.flatMap(l=>{let s=n[l.type];if(s){let n=s.validate(e,u[e.id],{formFields:t,values:u,expressionContext:{patient:r,mode:i},...l}).filter(e=>"error"===e.resultType);return n.length&&(e.meta.submission={...e.meta.submission,errors:n},a(e),o(e)),n}})).filter(e=>!!e).length})(e));return{forms:e,isValid:t}},[]);return!function({patientUuid:e,formUuid:t,setIsSubmitting:n,setIsValidating:r}){let{t:i}=(0,eO.useTranslation)();(0,c.useEffect)(()=>{let o=o=>{let{formUuid:a,patientUuid:l,action:s}=o.detail;if(!s||!a||!l)return void(0,tx.N)(Error("The form action event is missing required details (formUuid, patientUuid, or action)."),i("formActionFailed","Form action failed"));if(a===t&&l===e)switch(s){case"onSubmit":n(!0);break;case"validateForm":r(!0);break;default:(0,tx.N)(Error(`Unsupported form action: "${s}"`),i("formActionFailed","Form action failed"))}};return window.addEventListener("ampath-form-action",o),()=>{window.removeEventListener("ampath-form-action",o)}},[n,r,t,e])}({patientUuid:t,formUuid:i?.uuid,setIsSubmitting:k,setIsValidating:F}),(0,c.useEffect)(()=>{C&&(m||M(),F(!1))},[C,M,m]),(0,c.useEffect)(()=>{if(E){if(m)return void k(!1);let{forms:t,isValid:r}=M();r?Promise.all(t.map(e=>e.processor.processSubmission(e,P))).then(async t=>{h.setIsSubmitting(!1),"edit"===n?(0,s.showSnackbar)({title:b("updatedRecord","Record updated"),subtitle:b("updatedRecordDescription","The patient encounter was updated"),kind:"success",isLowContrast:!0}):(0,s.showSnackbar)({title:b("submittedForm","Form submitted"),subtitle:b("submittedFormDescription","Form submitted successfully"),kind:"success",isLowContrast:!0}),A&&await ar(A,t,e,n,b),g(),S?S(t):D()}).catch(e=>{k(!1),e instanceof Error?(0,s.showSnackbar)({title:b("errorProcessingFormSubmission","Error processing form submission"),kind:"error",subtitle:e.message,isLowContrast:!1}):(0,s.showSnackbar)(e)}):k(!1)}return()=>{P.abort()}},[E,M,m]),d().createElement(ai.Provider,{value:{patient:e,sessionMode:n,sessionDate:r,formJson:i,formProcessors:V.current,layoutType:x,workspaceLayout:o,visit:u,location:a,provider:l,isFormExpanded:f,registerForm:T,handleConfirmQuestionDeletion:y,setIsFormDirty:v}},V.current&&p)},aa=()=>{let e=(0,c.useContext)(ai);if(!e)throw Error("useFormFactoryContext must be used within a FormFactoryProvider");return e},al={actionButtons:"-esm-form-engine__repeat-controls__actionButtons___RPDJa"},as=function({question:e,rows:t,handleDelete:n,handleAdd:r,questionIndex:i}){var o,a;let l,{t:s}=(0,eO.useTranslation)();return d().createElement("div",{className:al.actionButtons},i>0&&d().createElement(g.Button,{className:al.button,kind:"danger",onClick:n},d().createElement("span",null,s("remove","Remove"))),i===t.length-1&&d().createElement(g.Button,{className:al.button,iconDescription:s("add","Add"),kind:"primary",disabled:(o=e.questionOptions.repeatOptions?.limit,a=t.length,l=Number(o),!(eV(o)||isNaN(l))&&a>=l),onClick:r},d().createElement("span",null,e.questionOptions.repeatOptions?.addText||s("add","Add"))))},au={obsGroup:"group",testOrder:"select",diagnosis:"ui-select-extended"};var ac=n(5848);let ad={label:"-esm-form-engine__file__label___rUrrs",thumbnailGrid:"-esm-form-engine__file__thumbnailGrid___FRMXX",thumbnailContainer:"-esm-form-engine__file__thumbnailContainer___4S7Rq"},af="-esm-form-engine__file-thumbnail__pdfThumbnail___CfkjD";var ap=n(529),am=n(1899);function ah({bytesContentFamily:e,removeFileCb:t,...n}){let r=(0,c.useMemo)(()=>{switch(e){case"image":return ag;case"pdf":return ay;default:return av}},[]);return d().createElement("div",{className:"-esm-form-engine__file-thumbnail__thumbnail___AGjAZ"},d().createElement(r,n),d().createElement(g.Button,{kind:"ghost",className:"-esm-form-engine__file-thumbnail__removeButton___DhEu3",onClick:t},d().createElement(ap.bm,{size:16,className:"-esm-form-engine__file-thumbnail__closeIcon___zKRmf"})))}function ag(e){return d().createElement("img",{className:"-esm-form-engine__file-thumbnail__imageThumbnail___nKfAe",src:e.src,alt:e.title})}function ay(e){return d().createElement("div",{className:af,role:"button",tabIndex:0},d().createElement(am.aD,{size:24}))}function av(e){return d().createElement("div",{className:af,role:"button",tabIndex:0},d().createElement(am.WZ,{size:24}))}let ab=[{name:"drug",baseControlComponent:oD},{name:"problem",baseControlComponent:oD},{name:"encounter-provider",baseControlComponent:oD},{name:"encounter-location",baseControlComponent:oD},{name:"select-concept-answers",baseControlComponent:oD},{name:"encounter-role",baseControlComponent:oD}],a_=[{name:"text",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s}=tD(),[u,f]=(0,c.useState)(null),p=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,tk.H)(e.readonly))&&th(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l?d().createElement(tq,{label:o(e.label),value:t,conceptName:e.meta?.concept?.display,isInline:p}):!e.isHidden&&d().createElement("div",{className:"-esm-form-engine__text__boldedLabel___WRIlW"},d().createElement(g.Layer,null,d().createElement(g.TextInput,{disabled:e.isDisabled,enableCounter:!!(e.questionOptions.max||e.questionOptions.maxLength),id:e.id,invalid:n.length>0,invalidText:n[0]?.message,labelText:d().createElement(tH,{field:e}),maxCount:e.questionOptions.max?Number(e.questionOptions.max):Number(e.questionOptions.maxLength),name:e.id,onBlur:e=>{e.preventDefault(),u!==t&&f(t)},onChange:e=>{i(e.target.value)},readOnly:(0,tk.H)(e.readonly),value:t??"",warn:r.length>0,warnText:r.length>0?r[0].message:void 0})))}},{name:"textarea",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),[a,l]=(0,c.useState)(t),{layoutType:s,sessionMode:u,workspaceLayout:f}=tD(),p=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(u)||(0,tk.H)(e.readonly))&&th(e.inlineRendering,s,f,u),[u,e.readonly,e.inlineRendering,s,f]);return"view"==u||"embedded-view"==u?d().createElement(tq,{label:o(e.label),value:t,conceptName:e.meta?.concept?.display,isInline:p}):!e.isHidden&&d().createElement("div",{className:"-esm-form-engine__text-area__boldedLabel___VdRnE"},d().createElement(g.Layer,null,d().createElement(g.TextArea,{id:e.id,labelText:d().createElement(tH,{field:e}),name:e.id,onChange:i,onBlur:e=>{e.preventDefault(),a!==t&&l(t)},value:t||"",rows:e.questionOptions.rows||4,disabled:e.isDisabled,readOnly:(0,tk.H)(e.readonly),invalid:n.length>0,invalidText:n[0]?.message,warn:r.length>0,warnText:r[0]?.message,enableCounter:!!(e.questionOptions.max||e.questionOptions.maxLength),maxCount:e.questionOptions.max?Number(e.questionOptions.max):Number(e.questionOptions.maxLength)})))}},{name:"select",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:f}=tD(),p=(0,c.useCallback)(({selectedItem:e})=>{i(e===u.ZA?null:e)},[i]),m=(0,c.useCallback)(t=>{let n=e.questionOptions.answers.find(e=>e.value?e.value==t:e.concept==t);return n?o(n.label):""},[e.questionOptions.answers,o]),h=(0,c.useMemo)(()=>{let t=e.questionOptions.answers;return t.some(e=>e.value===u.ZA)||t.unshift({value:u.ZA,label:o("chooseAnOption","Choose an option")}),t.filter(e=>!e.isHidden).map(e=>e.value||e.concept)},[e.questionOptions.answers]),y=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,tk.H)(e.readonly))&&th(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l?d().createElement(tq,{label:o(e.label),value:t?f[e.type].getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:y}):!e.isHidden&&d().createElement("div",{className:"-esm-form-engine__dropdown__boldedLabel___jRkpD"},d().createElement(g.Layer,null,d().createElement(g.Dropdown,{"aria-label":o(e.label),disabled:e.isDisabled,id:e.id,invalid:n.length>0,invalidText:n[0]?.message,items:h,itemToString:m,label:"",onChange:p,readOnly:(0,tk.H)(e.readonly),selectedItem:eV(t)?u.ZA:t,titleText:d().createElement(tH,{field:e}),warn:r.length>0,warnText:r[0]?.message})))}},{name:"checkbox",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:u}=tD(),[f,p]=(0,c.useState)(0),[m,h]=(0,c.useState)([]),y=(0,c.useRef)(!0),v=e.questionOptions.answers.filter(e=>!e.isHidden).map((t,n)=>({id:`${e.id}-${t.concept}`,concept:t.concept,label:o(t.label),key:n,disabled:t.disable?.isDisabled,readonly:(0,tk.H)(e.readonly)})),b=(0,c.useMemo)(()=>t?.length&&f<1?(p(f+1),v.filter(e=>t?.includes(e.concept))):[],[t]),_=(0,c.useMemo)(()=>(0,tk.H)(e.questionOptions.isCheckboxSearchable),[e.questionOptions.isCheckboxSearchable]);(0,c.useEffect)(()=>{y.current&&1===f&&(h(b.map(e=>e.concept)),y.current=!1)},[b,y]);let w=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,tk.H)(e.readonly))&&th(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l?d().createElement("div",{className:oa.formField},d().createElement(tq,{label:o(e.label),value:t?u[e.type]?.getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:w})):!e.isHidden&&d().createElement(d().Fragment,null,d().createElement("div",{className:oa.boldedLabel},d().createElement(g.Layer,null,_?d().createElement(g.FilterableMultiSelect,{disabled:e.isDisabled,id:e.id,initialSelectedItems:b,invalid:n.length>0,invalidText:n[0]?.message,items:v,itemToString:e=>e?o(e.label):" ",key:e.id,onChange:({selectedItems:e})=>{i(e.map(e=>e.concept))},placeholder:o("search","Search")+"...",readOnly:(0,tk.H)(e.readonly),titleText:d().createElement(tH,{field:e}),warn:r.length>0,warnText:r[0]?.message}):d().createElement(g.CheckboxGroup,{invalid:n.length>0,invalidText:n[0]?.message,legendText:d().createElement(tH,{field:e}),readOnly:(0,tk.H)(e.readonly),warn:r.length>0,warnText:r[0]?.message},v?.map((t,n)=>d().createElement(g.Checkbox,{className:oa.checkbox,checked:m.some(e=>e===t.concept),disabled:t.disabled,id:`${e.id}-${t.concept}`,key:`${e.id}-${t.concept}-${n}`,labelText:o(t.label),name:t.concept,onChange:()=>{let e,n;return n=t.concept,void(h(e=m.some(e=>e===n)?m.filter(e=>e!==n):m.some(e=>e===n)?m.filter(e=>e!==n):[...m,n]),i(e))},readOnly:(0,tk.H)(e.readonly)}))))),_&&d().createElement("div",{className:oa.selectionDisplay},t?.length?d().createElement("div",{className:oa.tagContainer},u[e.type]?.getDisplayValue(e,t)?.map((e,t)=>d().createElement(g.Tag,{key:t,type:"cool-gray"},o(e)))):d().createElement(tC,null)))}},{name:"radio",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:u}=tD(),f=e=>{i(e)},p=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,tk.H)(e.readonly))&&th(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l||(0,tk.H)(e.readonly)?d().createElement(tq,{label:o(e.label),value:t?u[e.type].getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:p}):!e.isHidden&&d().createElement(g.FormGroup,{legendText:d().createElement(tH,{field:e}),className:"-esm-form-engine__radio__boldedLegend___YisTw",disabled:e.isDisabled,invalid:n?.length>0},d().createElement(g.RadioButtonGroup,{name:e.id,valueSelected:t,onChange:f,readOnly:(0,tk.H)(e.readonly),orientation:e.questionOptions?.orientation||"vertical"},e.questionOptions.answers.filter(e=>!e.isHidden).map((n,r)=>d().createElement(g.RadioButton,{id:`${e.id}-${n.label}`,labelText:o(n.label)??"",value:n.concept,key:r,onClick:e=>{t&&e.target.checked?(e.target.checked=!1,e.preventDefault(),f(null)):f(n.concept)}}))),(n?.length>0||r?.length>0)&&d().createElement("div",null,d().createElement("div",{className:"-esm-form-engine__radio__errorMessage___fmThI"},n.length>0?n[0].message:r.length>0?r[0].message:null)))}},{name:"date",component:tz},{name:"datetime",component:tz},{name:"number",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s}=tD(),u=(0,c.useMemo)(()=>isNaN(t)?"":t??"",[t]),f=(0,c.useCallback)(e=>void 0===e||isNaN(Number(e))?void 0:Number(e),[]),m=(0,c.useCallback)((e,{value:t})=>{let n=f(t);i(isNaN(n)?void 0:n)},[i,f]),h=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,tk.H)(e.readonly))&&th(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]),y=f(e.questionOptions.max),v=f(e.questionOptions.min);return"view"==l||"embedded-view"==l?d().createElement("div",{className:ol.formField},d().createElement(tq,{label:o(e.label),value:t,conceptName:e.meta?.concept?.display,isInline:h})):!e.isHidden&&d().createElement(g.Layer,null,d().createElement(g.NumberInput,{id:e.id,invalid:n.length>0,invalidText:n[0]?.message,label:d().createElement(tH,{field:e}),max:y,min:v,name:e.id,value:u,onChange:m,allowEmpty:!0,size:"lg",hideSteppers:e.hideSteppers??!1,disabled:e.isDisabled,readOnly:(0,tk.H)(e.readonly),className:p()(ol.controlWidthConstrained,ol.boldedLabel),warn:r.length>0,warnText:r[0]?.message,step:e.questionOptions.step??.01}))}},{name:"content-switcher",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),{layoutType:a,sessionMode:l,workspaceLayout:s,formFieldAdapters:u}=tD(),f=(0,c.useCallback)(e=>{i(e.name)},[i]),m=(0,c.useMemo)(()=>e.questionOptions.answers.filter(e=>!e.isHidden),[e.questionOptions.answers]),h=(0,c.useMemo)(()=>m.findIndex(e=>e.concept==t),[t,m]),y=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(l)||(0,tk.H)(e.readonly))&&th(e.inlineRendering,a,s,l),[l,e.readonly,e.inlineRendering,a,s]);return"view"==l||"embedded-view"==l||(0,tk.H)(e.readonly)?d().createElement("div",{className:"-esm-form-engine__content-switcher__formField___vZnsA"},d().createElement(tq,{label:o(e.label),value:t?u[e.type].getDisplayValue(e,t):t,conceptName:e.meta?.concept?.display,isInline:y})):!e.isHidden&&d().createElement(g.FormGroup,{legendText:d().createElement("div",{className:tR},d().createElement(tH,{field:e})),className:p()({"-esm-form-engine__content-switcher__errorLegend___JGh37":n.length>0,[tR]:0===n.length})},d().createElement(g.ContentSwitcher,{onChange:f,selectedIndex:h,className:"-esm-form-engine__content-switcher__selectedOption___KMGst",size:"md"},m.map((t,n)=>d().createElement(g.Switch,{name:t.concept||t.value,text:o(t.label),key:n,disabled:e.isDisabled}))))}},{name:"toggle",component:({field:e,value:t,errors:n,warnings:r,setFieldValue:i})=>{let{t:o}=(0,eO.useTranslation)(),a=tD();(0,c.useEffect)(()=>{e.meta?.initialValue?.omrsObject||"enter"!=a.sessionMode||a.formFieldAdapters[e.type].transformFieldValue(e,t??!1,a)},[]);let l=(0,c.useMemo)(()=>!!(["view","embedded-view"].includes(a.sessionMode)||(0,tk.H)(e.readonly))&&th(e.inlineRendering,a.layoutType,a.workspaceLayout,a.sessionMode),[a.sessionMode,e.readonly,e.inlineRendering,a.layoutType,a.workspaceLayout]);return"view"==a.sessionMode||"embedded-view"==a.sessionMode?d().createElement(tq,{label:o(e.label),value:eV(t)?t:a.formFieldAdapters[e.type].getDisplayValue(e,t),conceptName:e.meta?.concept?.display,isInline:l}):!e.isHidden&&d().createElement("div",{className:os},d().createElement(g.Toggle,{labelText:o(e.label),className:os,id:e.id,labelA:e.questionOptions.toggleOptions.labelFalse,labelB:e.questionOptions.toggleOptions.labelTrue,onToggle:e=>{i(e)},toggled:!!t,disabled:e.isDisabled,readOnly:(0,tk.H)(e.readonly)}))}},{name:"workspace-launcher",component:({field:e})=>{let{t}=(0,eO.useTranslation)(),{sessionMode:n,patient:r,visit:i}=tD(),o=async()=>{let n=e.questionOptions?.workspaceName;if(!n)return void(0,s.showSnackbar)({title:t("invalidWorkspaceName","Invalid workspace name."),subtitle:t("invalidWorkspaceNameSubtitle","Please provide a valid workspace name."),kind:"error",isLowContrast:!0});let o=e.questionOptions?.workspaceProps??{},a={patient:r,patientUuid:r?.id,visitContext:i};try{await (0,s.launchWorkspace2)(n,o,a)}catch(e){(0,s.showSnackbar)({title:t("errorLaunchingWorkspace","Error launching workspace"),subtitle:e?.message??t("errorLaunchingWorkspaceSubtitle","An unexpected error occurred while launching the workspace."),kind:"error",isLowContrast:!0})}};return e.isHidden||eR(n)?null:d().createElement("div",null,d().createElement("div",{className:"-esm-form-engine__workspace-launcher__label___vIWfO"},d().createElement(tH,{field:e})),d().createElement("div",{className:"-esm-form-engine__workspace-launcher__workspaceButton___cmGUN"},d().createElement(g.Button,{disabled:(0,tk.H)(e.readonly??!1)||!r,onClick:o},e.questionOptions.buttonLabel?t(e.questionOptions.buttonLabel):t("launchWorkspace","Launch Workspace")),!r&&d().createElement(g.InlineNotification,{className:"-esm-form-engine__workspace-launcher__noPatientNotification___hhJs2",kind:"info",lowContrast:!0,hideCloseButton:!0,title:t("noPatientContext","No patient selected"),subtitle:t("noPatientContextSubtitle","This button is only active when a patient chart is open.")})))}},{name:"group",component:tI},{name:"repeating",component:({field:e})=>{var t;let[n,r]=(0,c.useState)([]),i=tD(),{handleConfirmQuestionDeletion:o}=aa(),{patient:a,sessionMode:l,formFieldAdapters:u,formFields:f,methods:{getValues:p,setValue:m,unregister:h},addFormField:g,removeFormField:y,deletedFields:v,setDeletedFields:b,visit:_}=i;(0,c.useEffect)(()=>{r(f.filter(t=>t.questionOptions.concept===e.questionOptions.concept&&t.id.startsWith(e.id)&&!t.meta?.repeat?.wasDeleted))},[f,e]);let w=(0,c.useCallback)(t=>{let o=[],s=oA(e,null,t);o.push(s),"obsGroup"===s.type&&s.questions?.forEach(e=>{o.push(e)}),o.forEach(e=>{e.hide?.hideWhenExpression&&(e.isHidden=tc(e.hide.hideWhenExpression,{value:e,type:"field"},[...f,...o],p(),{mode:l,patient:a,visit:_})),e.questionOptions.calculate?.calculateExpression&&td(e.questionOptions.calculate?.calculateExpression,{value:e,type:"field"},[...f,...o],p(),{mode:l,patient:a,visit:_}).then(t=>{eV(t)||(m(e.id,t),u[e.type]?.transformFieldValue(e,t,i))}),g(e)}),r([...n,s])},[f,e,n,i]),x=e=>{e.meta.initialValue?.omrsObject?(u[e.type]?.transformFieldValue(e,null,i),e.meta.repeat={...e.meta.repeat||{},wasDeleted:!0},"obsGroup"===e.type&&e.questions.forEach(t=>{t.meta.repeat={...e.meta.repeat||{},wasDeleted:!0},u[t.type]?.transformFieldValue(t,null,i)})):(eN(e),h(e.id),e.questions?.forEach(e=>h(e.id))),r(n.filter(t=>t.id!==e.id)),b([...v,e]),y(e.id)},E=(0,c.useMemo)(()=>n.map((t,r)=>{var i;let a=d().createElement(tV,{fieldId:t.id,valueAdapter:u[t.type],repeatOptions:{targetRendering:{...i=t,questionOptions:{...i.questionOptions,rendering:au[i.type]||null}}.questionOptions.rendering}});return d().createElement("div",{key:t.id+"_wrapper"},0!==r&&d().createElement("div",null,d().createElement("hr",{className:"-esm-form-engine__repeat__divider___m-qDa"})),d().createElement("div",{className:"-esm-form-engine__repeat__nodeContainer___WpV+2"},a),!eR(l)&&d().createElement(as,{question:t,rows:n,questionIndex:r,handleDelete:()=>{if(o&&"function"==typeof o){let e=o(t);e&&"function"==typeof e.then&&"function"==typeof e.catch?e.then(()=>x(t)).catch(()=>(0,s.createErrorHandler)()):"boolean"==typeof e?e&&x(t):x(t)}else x(t)},handleAdd:()=>{w(n.reduce((t,n)=>{let r=Number(n.id.slice(e.id.length+1));return Number.isFinite(r)?Math.max(t,r):t},0)+1)}}))}),[n]);return!e.isHidden&&E&&(t=e,t.questions?.length?t.questions?.some(e=>!e.isHidden):!t.isHidden)?d().createElement(d().Fragment,null,d().createElement("div",null,E)):null}},{name:"markdown",component:({field:e})=>{var t;let{t:n}=(0,eO.useTranslation)();return!e.isHidden&&d().createElement(oo,{markdown:Array.isArray(t=e.value)?t.map(e=>n(e,{defaultValue:e,interpolation:{escapeValue:!1}})).join("\n\n"):"string"==typeof t?n(t,{defaultValue:t,interpolation:{escapeValue:!1}}):t})}},{name:"fixed-value",component:({field:e,setFieldValue:t})=>{let n=tD();return(0,c.useEffect)(()=>{e.meta?.initialValue?.omrsObject||eV(e.meta.fixedValue)||(t(e.meta.fixedValue),n.formFieldAdapters[e.type].transformFieldValue(e,e.meta.fixedValue,n))},[]),d().createElement(d().Fragment,null)}},{name:"ui-select-extended",component:oD},{name:"file",component:({field:e,value:t,setFieldValue:n})=>{let{t:r}=(0,eO.useTranslation)(),{sessionMode:i}=tD(),o="tablet"===(0,s.useLayoutType)(),a=(0,c.useCallback)(()=>{let r=(0,s.showModal)("capture-photo-modal",{saveFile:e=>(e.capturedFromWebcam&&!e.fileName.includes(".")&&(e.fileName=`${e.fileName}.png`),n([...t||[],e]),r(),Promise.resolve()),closeModal:()=>{r()},allowedExtensions:e.questionOptions.allowedFileTypes,multipleFiles:e.questionOptions.allowMultiple,collectDescription:!0})},[t,e]),l=(0,c.useCallback)(e=>{let r=[...t],i=r[e];i.uuid?r[e]={...i,voided:!0}:r.splice(e,1),n(r)},[t]);return eR(i)&&!t?d().createElement(tq,{label:r(e.label),value:null,conceptName:e.meta.concept?.display,isInline:!1}):d().createElement("div",null,d().createElement("div",{className:p()(ad.label,"cds--label")},d().createElement(tH,{field:e})),!eR(i)&&d().createElement("div",null,d().createElement(g.Button,{className:ad.uploadButton,kind:o?"ghost":"tertiary",onClick:a,renderIcon:e=>d().createElement(ac.OM,{size:16,...e})},e.questionOptions.buttonLabel?r(e.questionOptions.buttonLabel):r("addFile","Add file"))),d().createElement("div",{className:ad.thumbnailGrid},t&&t.filter(e=>!e.voided).map((e,t)=>d().createElement("div",{className:ad.thumbnailContainer},d().createElement(ah,{title:e.fileName,src:e.base64Content,bytesContentFamily:e.fileType,removeFileCb:()=>l(t)})))))}},...oS.map(e=>({name:e.name,component:ab.find(t=>t.name===e.name).baseControlComponent}))],aw=[{name:"default_value",component:oB},{name:"form_field",component:eT},{name:"date",component:{validate:(e,t,n)=>{let r=new Date,i=t?[]:eT.validate(e,t);return i.length?i:t&&!(0,tk.H)(n?.allowFutureDates)&&t.getTime&&t.getTime()>r.getTime()?[{resultType:"error",errCode:"value.invalid",message:"Future dates not allowed"}]:[]}}},{name:"js_expression",component:{validate:function(e,t,n){return n.expressionContext.myValue=t,Object.keys(n).filter(e=>"failsWhenExpression"===e||"warnsWhenExpression"===e).flatMap(r=>{let i="failsWhenExpression"===r;return tc(n[r],{value:e,type:"field"},n.formFields,{...n.values,[e.id]:t},n.expressionContext)?[{resultType:i?"error":"warning",errCode:i?"value.invalid":null,message:n.message?n.message:i?"Invalid value":"Field has warnings"}]:[]})}}},{name:"conditionalAnswered",component:{validate:function(e,t,n){let{referenceQuestionId:r,referenceQuestionAnswers:i,values:o,formFields:a,message:l}=n,s=o[a.find(e=>e.id===r).id];return eV(t)||i.includes(s)?[]:[{resultType:"error",errCode:"invalid.valueSelected",message:l}]}}}];class ax{fetchData(e){return(0,s.openmrsFetch)(e?`${this.url}&q=${e}`:this.url).then(({data:e})=>e.results)}fetchSingleItem(e){let t=this.url;if(t.includes("?")){let n=t.split("?");t=`${n[0]}/${e}?${n[1]}`}else t=`${t}/${e}`;return(0,s.openmrsFetch)(t).then(({data:e})=>e)}toUuidAndDisplay(e){if(void 0===e.uuid||void 0===e.display)throw Error("'uuid' or 'display' not found in the OpenMRS object.");return e}constructor(e){!function(e,t){"url"in e?Object.defineProperty(e,"url",{value:t,enumerable:!0,configurable:!0,writable:!0}):e.url=t}(this,void 0),this.url=e}}let aE="custom:(uuid,display,conceptClass:(uuid,display))",ak="custom:(uuid,display,conceptClass:(uuid,display),mappings:(conceptMapType:(uuid,display),conceptReferenceTerm:(code,conceptSource:(uuid))))";class aS extends ax{fetchData(e,t){if(eV(t?.class)&&eV(t?.concept)&&!t?.useSetMembersByConcept&&eV(e))return Promise.resolve([]);let n=t?.conceptSourceUuid?ak:aE,r=`${s.restBaseUrl}/concept?name=&searchType=fuzzy&v=${n}`;if(t?.class)if("string"!=typeof t.class)return(0,s.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.results.filter(e=>e.conceptClass&&t.class.includes(e.conceptClass.uuid)));else{let e=r.split("searchType=fuzzy");r=`${e[0]}searchType=fuzzy&class=${t.class}&${e[1]}`}if(t?.concept&&t?.useSetMembersByConcept){let n=r.split("?name=&searchType=fuzzy&v="),i=t?.conceptSourceUuid?"custom:(uuid,setMembers:(uuid,display,mappings:(conceptMapType:(uuid,display),conceptReferenceTerm:(code,conceptSource:(uuid)))))":"custom:(uuid,setMembers:(uuid,display))";return r=`${n[0]}/${t.concept}?v=${i}`,(0,s.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.setMembers)}return(0,s.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.results)}fetchSingleItem(e,t){let n=t?.conceptSourceUuid?ak:aE;return(0,s.openmrsFetch)(`${s.restBaseUrl}/concept/${e}?v=${n}`).then(({data:e})=>e)}toUuidAndDisplay(e,t){let n=super.toUuidAndDisplay(e),r=this.getConceptSourceMapping(e,t?.conceptSourceUuid)?.conceptReferenceTerm?.code;return r?{...n,code:r}:n}getConceptSourceMapping(e,t){if(!t)return;let n=e.mappings?.filter(e=>e.conceptReferenceTerm?.conceptSource?.uuid===t)??[];return n.find(e=>e.conceptMapType?.uuid==="35543629-7d8c-11e1-909d-c80aa9edcf4e"||e.conceptMapType?.display?.toUpperCase()==="SAME-AS")??n[0]}constructor(){super(`${s.restBaseUrl}/concept?v=${aE}`)}}let aO=[{name:"location_datasource",component:new class extends ax{fetchData(e,t,n){let r=this.url,i=r.split("?");return t?.tag&&(r=`${i[0]}?tag=${t.tag}&${i[1]}`),n&&(r=`${i[0]}/${n}?${i[1]}`),(0,s.openmrsFetch)(e?`${r}&q=${e}`:r).then(({data:e})=>e.results?e.results:e)}constructor(){super(`${s.restBaseUrl}/location?v=custom:(uuid,display)`)}}},{name:"drug_datasource",component:new aS},{name:"problem_datasource",component:new aS},{name:"select_concept_answers_datasource",component:new class extends ax{fetchSingleItem(e){return(0,s.openmrsFetch)(this.buildUrl(e)).then(({data:e})=>e)}fetchData(e,t){let n=this.buildUrl(t.referencedValue||t.concept);return(0,s.openmrsFetch)(n).then(({data:e})=>e.setMembers.length?e.setMembers:e.answers)}buildUrl(e){return this.url.replace(":conceptUuid",e)}constructor(){super(`${s.restBaseUrl}/concept/:conceptUuid?v=custom:(uuid,display,setMembers:(uuid,display),answers:(uuid,display))`)}}},{name:"provider_datasource",component:new class extends ax{async fetchData(e,t){let n=`${s.restBaseUrl}/provider?v=custom:(uuid,display)`,{data:r}=await (0,s.openmrsFetch)(e?`${n}&q=${e}`:n);return r?.results}async fetchSingleItem(e){let{data:t}=await (0,s.openmrsFetch)(`${s.restBaseUrl}/provider/${e}?v=custom:(uuid,display)`);return t}constructor(){super(null)}}},{name:"encounter_role_datasource",component:new class extends ax{async fetchData(e,t){let n=`${s.restBaseUrl}/encounterrole?v=custom:(uuid,display,name)`,{data:r}=await (0,s.openmrsFetch)(e?`${n}&q=${e}`:n);return r?.results}constructor(){super(null)}}}],aD=[{name:"ProgramEnrollmentSubmissionAction",load:()=>n.e("8720").then(n.bind(n,3696))},{name:"MarkPatientAsDeceasedAction",load:()=>n.e("5897").then(n.bind(n,8128))}];function aC(e,t){if(e&&"string"==typeof e[t]){let n=e[t].trim().toLowerCase();("true"===n||"false"===n)&&(e[t]="true"===n)}return e}let aF=[{name:"DefaultFormSchemaTransformer",component:{transform:(e,t)=>{var n;return aC(e,"readonly"),e.pages.forEach((t,n)=>{let r=t.label??"";t.id=`page-${r.replace(/\s/g,"")}-${n}`,aC(t,"readonly"),t.sections&&t.sections.forEach(n=>{var r,i;let o,a;r=n.questions,o=[],r?.forEach(e=>{if(o.push(e),"inlineDate"!==e.type&&(0,tk.H)(e.questionOptions?.showDate)){let t={id:`${e.id}_inline_date`,label:`Date for ${e.label}`,type:"inlineDate",questionOptions:{rendering:"date",isTransient:!0},validators:e.questionOptions.shownDateOptions?.validators,disabled:{disableWhenExpression:`isEmpty(${e.id})`},hide:e.questionOptions.shownDateOptions?.hide||e.hide,meta:{targetField:e.id,initialValue:{omrsObject:e.meta?.initialValue?.omrsObject?.obsDatetime}}};o.push(t)}}),n.questions=o,i=n.questions,a=[],i?.forEach(e=>{if(a.push(e),"obsComment"!==e.type&&(0,tk.H)(e.questionOptions?.showComment)){let t={id:`${e.id}_obs_comment`,label:`Comment for ${e.label}`,type:"obsComment",questionOptions:{rendering:"text",isTransient:!0},validators:e.questionOptions.shownCommentOptions?.validators,disabled:{disableWhenExpression:`isEmpty(${e.id})`},hide:e.questionOptions.shownCommentOptions?.hide||e.hide,meta:{targetField:e.id,initialValue:{omrsObject:e.meta?.initialValue?.omrsObject?.comment}}};a.push(t)}}),n.questions=a,aC(n,"readonly"),aC(n,"isExpanded"),n?.questions?.forEach((n,r)=>(function e(t,n,r){if("programState"===t.type){let e=r.meta??{};e.programs=e.programs?{...e.programs,hasProgramFields:!0}:{hasProgramFields:!0},r.meta=e}try{var i,o;i=t,aC(i,"readonly"),aC(i,"required"),aC(i,"unspecified"),aC(i.questionOptions,"disallowDecimals"),aC(i.questionOptions,"isSearchable"),aC(i.questionOptions,"isTransient"),aC(i.questionOptions,"enablePreviousValue"),aC(i.questionOptions,"allowMultiple"),i.meta||(i.meta={submission:null,initialValue:{omrsObject:null,refinedValue:null}}),o=t,!eI(o,"group")&&(o.validators=o.validators||[],0>o.validators.findIndex(e=>"form_field"===e.type)&&o.validators.push({type:"form_field"}),0>o.validators.findIndex(e=>"default_value"===e.type)&&o.validators.push({type:"default_value"})),function(e){switch(e.type){case"encounterProvider":e.questionOptions.rendering="encounter-provider";break;case"encounterLocation":e.questionOptions.rendering="encounter-location";break;case"encounterRole":e.questionOptions.rendering="encounter-role";break;case"encounterDatetime":e.questionOptions.rendering=eI(e,"ui-select-extended")?"date":e.questionOptions.rendering;break;case"diagnosis":var t=e;if("dataSource"in t.questionOptions&&"diagnoses"===t.questionOptions.dataSource||"diagnosis"===t.type){let e=t.questionOptions.datasource?.config;t.questionOptions.datasource={name:"problem_datasource",config:{...e,class:t.questionOptions.diagnosis?.conceptClasses??e?.class}},t.questionOptions.diagnosis?.conceptSet&&(t.questionOptions={...t.questionOptions,concept:t.questionOptions.diagnosis?.conceptSet,datasource:{name:"problem_datasource",config:{...e,concept:t.questionOptions.diagnosis.conceptSet,useSetMembersByConcept:!0}}}),t.questionOptions.isSearchable=!0,delete t.questionOptions.dataSource}}}(t),function(e){var t,n;switch(e.questionOptions.rendering){case"checkbox-searchable":case"multiCheckbox":t=e,"multiCheckbox"===t.questionOptions.rendering&&(t.questionOptions.rendering="checkbox-searchable",(0,tk.H)(t.inlineMultiCheckbox)&&(t.questionOptions.rendering="checkbox")),eI(t,"checkbox-searchable")&&(t.questionOptions.rendering="checkbox",t.questionOptions.isCheckboxSearchable=!0);break;case"numeric":e.questionOptions.rendering="number";break;case"select-concept-answers":(n=e).questionOptions.isSearchable=!0,n.questionOptions.datasource?.config||(n.questionOptions.datasource={name:"select_concept_answers_datasource",config:{concept:n.questionOptions.concept}});break;case"repeating":case"group":!function e(t){eI(t,"group")&&t.questions?.length&&t.questions.forEach(e),"testOrder"===t.type&&t.questionOptions.selectableOrders?.length&&(t.questionOptions.answers=t.questionOptions.selectableOrders||[],delete t.questionOptions.selectableOrders)}(e);break;case"date":e.datePickerFormat=e.datePickerFormat??"calendar";break;case"datetime":e.datePickerFormat=e.datePickerFormat??"both";break;case"workspace-launcher":case"markdown":e.type="control";break;case"drug":case"problem":e.questionOptions.isSearchable=!0}}(t),t.questions?.length&&("obsGroup"===t.type&&t.questions.length?t.questions.forEach(t=>e(t,n,r)):t.questions.forEach(t=>e(t,n,r))),t.meta.pageId=n.id}catch(e){console.error(e)}})(n,t,e))})}),t&&"object"==typeof t&&(n=e,Object.entries(t).forEach(([e,t])=>{n?.pages.forEach(n=>{n.sections.forEach(n=>{n.questions.forEach(n=>{n.id===e?n.questionOptions.defaultValue=t:Array.isArray(n?.questions)&&n.questions.length>0&&n.questions.forEach(n=>{n.id===e&&(n.questionOptions.defaultValue=t)})})})})})),e.meta?.programs&&function(e){if(e.meta.programs.isEnrollment||e.meta.programs.discontinuationDateQuestionId){let t={programUuid:e.meta.programs.uuid};e.meta.programs.isEnrollment?t.enrollmentDate="":t.completionDate=e.meta.programs.discontinuationDateQuestionId,e.postSubmissionActions=[{actionId:"ProgramEnrollmentSubmissionAction",enabled:"true",config:t}]}}(e),e}}}];function aA(e){if(e&&e.encounterProviders?.length){let t=e.encounterProviders.length-1;return e.encounterProviders[t].provider}return null}function aP(e){if(e&&e.encounterProviders?.length){let t=e.encounterProviders.length-1;return e.encounterProviders[t].encounterRole}return null}function aT(e,t){return oq(e,t)||!eV(e.meta.submission.newValue.obsDatetime)}let aV=[{type:"obs",component:oV},{type:"control",component:{getDisplayValue:(e,t)=>t,transformFieldValue:function(e,t,n){return null},getInitialValue:function(e,t,n){return null},getPreviousValue:function(e,t,n){return null},tearDown:function(){}}},{type:"obsGroup",component:oV},{type:"testOrder",component:{transformFieldValue:function(e,t,n){if(eN(e),"edit"===n.sessionMode&&e.meta.initialValue?.omrsObject){var r=t,i=e,o=n.currentProvider.uuid;let a=i.meta.initialValue?.omrsObject;if(r===a?.concept?.uuid)return null;let l={uuid:a?.uuid,voided:!0};return eL(i,oz(r,i,o),l),i.meta.submission.newValue||null}let a=oz(t,e,n.currentProvider.uuid);return eL(e,a,null),a},getInitialValue:function(e,t,n){let r=e.questionOptions.answers?.map(e=>e.concept)||[],i=t?.orders.filter(e=>!oH.includes(e.uuid)&&!e.voided).find(e=>r.includes(e.concept.uuid));return i?(e.meta={...e.meta||{},initialValue:{omrsObject:i,refinedValue:i.concept.uuid}},oH.push(i.uuid),i.concept.uuid):null},getPreviousValue:function(e,t,n){return null},getDisplayValue:(e,t)=>e.questionOptions.answers?.find(e=>e.concept==t)?.label||t,tearDown:function(){oH=[]}}},{type:"programState",component:{transformFieldValue:function(e,t,n){if(eN(e),e.meta?.initialValue?.omrsObject?.uuid===t||eV(t))return null;e.meta.submission.newValue={state:t,startDate:eY()().format()}},getInitialValue:function(e,t,n){let r=n.customDependencies.patientPrograms?.find(t=>t.program.uuid===e.questionOptions.programUuid);if(r?.states?.length>0){let t=r.states.filter(e=>!e.endDate).find(t=>t.state.programWorkflow?.uuid===e.questionOptions.workflowUuid)?.state;return e.meta={...e.meta||{},initialValue:{omrsObject:t}},t?.uuid}return null},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"encounterLocation",component:{transformFieldValue:function(e,t,n){eL(e,t,null)},getInitialValue:function(e,t,n){return t&&t.location?.uuid?t.location.uuid:n.location.uuid},getPreviousValue:function(e,t,n){let r=t??n.previousDomainObjectValue;return{value:r?.location?.uuid,display:r?.location?.name}},getDisplayValue:function(e,t){return t},tearDown:function(){}}},{type:"encounterProvider",component:{transformFieldValue:function(e,t,n){eL(e,t,null)},getInitialValue:function(e,t,n){let r=aA(t);return r?.uuid?r.uuid:n.currentProvider?.uuid},getPreviousValue:function(e,t,n){let r=aA(t??n.previousDomainObjectValue);return{value:r?.uuid,display:r?.name}},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"encounterRole",component:{transformFieldValue:function(e,t,n){eL(e,t,null)},getInitialValue:function(e,t,n){let r=t??n.domainObjectValue;return r?aP(r)?.uuid:n.customDependencies.defaultEncounterRole.uuid},getPreviousValue:function(e,t,n){let r=t??n.previousDomainObjectValue;if(r){let e=aP(r);return{value:e?.uuid,display:e?.name}}return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"obsComment",component:{transformFieldValue:function(e,t,n){let r=n.getFormField(e.meta.targetField),i=n.methods.getValues(r.id),o=r.meta.initialValue?.omrsObject;if(r.meta.submission?.newValue)eV(t)&&!aT(r,i)?r.meta.submission.newValue=null:r.meta.submission.newValue.comment=t;else if(!eq(r)&&o){if(eV(t)&&eV(o.comment))return null;let e=oN(r,i);r.meta.submission={newValue:{...e,comment:t}}}return null},getInitialValue:function(e,t,n){if(t??n.domainObjectValue){let t=e.id.split("_obs_comment")[0],r=n.formFields.find(e=>e.id===t);return r?.meta.initialValue.omrsObject?.comment}return null},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t},tearDown:function(){}}},{type:"encounterDatetime",component:{transformFieldValue:function(e,t,n){eL(e,t,null)},getInitialValue:function(e,t,n){return t?.encounterDatetime?new Date(t.encounterDatetime):n.sessionDate},getPreviousValue:function(e,t,n){if(t?.encounterDatetime){let n=new Date(t.encounterDatetime);return{value:n,display:this.getDisplayValue(e,n)}}return null},getDisplayValue:function(e,t){return(0,s.formatDate)(t)},tearDown:function(){}}},{type:"inlineDate",component:{transformFieldValue:function(e,t,n){let r=n.getFormField(e.meta.targetField),i=n.methods.getValues(r.id),o=t instanceof Date?(0,s.toOmrsIsoString)(t):t;if(r.meta.submission?.newValue)eV(o)&&!aT(r,i)?r.meta.submission.newValue=null:r.meta.submission.newValue.obsDatetime=o;else if(!eq(r)&&r.meta.initialValue?.omrsObject){if(eV(t)&&eV(r.meta.initialValue.omrsObject?.obsDatetime))return null;let e=oN(r,i);r.meta.submission={newValue:{...e,obsDatetime:o}}}},getInitialValue:function(e,t,n){if(t??n.domainObjectValue){let t=e.id.split("_inline_date")[0],r=n.formFields.find(e=>e.id===t),i=r?.meta.initialValue?.omrsObject;if(i?.obsDatetime)return(0,s.parseDate)(i.obsDatetime)}return null},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?(0,s.formatDate)(t):null},tearDown:function(){}}},{type:"patientIdentifier",component:{transformFieldValue:function(e,t,n){return(eN(e),e.meta.initialValue?.refinedValue===t||eV(t))?null:(e.meta.submission.newValue={identifier:t,identifierType:e.questionOptions.identifierType,uuid:e.meta.initialValue?.omrsObject?.id,location:n.location},e.meta.submission.newValue)},getInitialValue:function(e,t,n){let r=n.patient?.identifier?.find(t=>t.type?.coding[0]?.code===e.questionOptions.identifierType);return e.meta={...e.meta||{},initialValue:{omrsObject:r,refinedValue:r?.value}},r?.value},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"personAttribute",component:{transformFieldValue:function(e,t,n){return(eN(e),e.meta.initialValue?.refinedValue===t||eV(t))?null:(e.meta.submission.newValue={value:t,attributeType:e.questionOptions.attributeType,uuid:e.meta.initialValue?.omrsObject?.uuid},e.meta.submission.newValue)},getInitialValue:function(e,t,n){let r=n.patient?.extension?.find(t=>t.url===`http://fhir.openmrs.org/ext/person-attribute/${e.questionOptions.attributeType}`);return e.meta={...e.meta,initialValue:{omrsObject:r,refinedValue:r?.valueString||r?.valueReference?.reference}},e.meta.initialValue.refinedValue},getPreviousValue:function(e,t,n){return null},getDisplayValue:function(e,t){return t?.display?t.display:t},tearDown:function(){}}},{type:"diagnosis",component:{transformFieldValue:function(e,t,n){let r,i,o;if(eN(e),e.meta.initialValue?.omrsObject&&eV(t))return eL(e,void 0,{uuid:e.meta.initialValue.omrsObject.uuid,voided:!0});if(!eV(t)){var a,l,s,u,c;let r=e.meta.initialValue?.omrsObject;if(a=r,l=t,!eV(a)&&a.value!==l){return eL(e,(s=t,u=e,c=r,{patient:n.patient.id,condition:null,diagnosis:{coded:s},certainty:(0,tk.H)(u.questionOptions?.diagnosis?.isConfirmed)?"CONFIRMED":"PROVISIONAL",rank:u.questionOptions.diagnosis?.rank??1,formFieldPath:`rfe-forms-${u.id}`,formFieldNamespace:"rfe-forms",uuid:c.uuid}),void 0)}}let d=(r=t,i=e,o=n.patient.id,r?{patient:o,condition:null,diagnosis:{coded:r},certainty:(0,tk.H)(i.questionOptions?.diagnosis?.isConfirmed)?"CONFIRMED":"PROVISIONAL",rank:i.questionOptions.diagnosis?.rank??1,formFieldPath:`rfe-forms-${i.id}`,formFieldNamespace:"rfe-forms"}:null);return eL(e,d,null),d},getInitialValue:function(e,t,n){let r=(t??n.domainObjectValue).diagnoses.find(t=>t.formFieldPath===`rfe-forms-${e.id}`);return r?(e.meta={...e.meta||{},initialValue:{omrsObject:r,refinedValue:r.diagnosis?.coded.uuid}},oU.includes(r.diagnosis?.coded?.uuid)||oU.push(r.diagnosis?.coded?.uuid),r.diagnosis?.coded.uuid):null},getPreviousValue:function(e,t,n){return null},getDisplayValue:(e,t)=>e.questionOptions.answers?.find(e=>e.concept==t)?.label||t,tearDown:function(){oU=[]}}}],aM={},aj={},aI={},aN={},aL={},aq={};function aR(e,t){aY().expressionHelpers[e]=t}async function a$(e){if(aj[e])return aj[e];let t=a_.find(t=>t.name===e||t?.alias===e)?.component;if(!t){let n=await aY().controls.find(t=>t.name===e||t?.alias===e)?.load?.();t=n?.default}return aj[e]=t,t}async function aB(e){if(aI[e])return aI[e];let t=aV.find(t=>t.type===e)?.component;if(!t){let n=await aY().fieldValueAdapters.find(t=>t.type===e)?.load?.();t=n?.default}return aI[e]=t,t}async function aH(){let e=[];if(Object.keys(aq).length)return Object.values(aq);let t=aY().formSchemaTransformers||[];return e.push(...(await Promise.all(t.map(async e=>{let t=await e.load?.();return t?.default}))).filter(e=>void 0!==e)),e.push(...aF.map(e=>e.component)),e.forEach(e=>{aq[aF.find(t=>t.component===e).name]=e}),e}async function az(e){let t=aN[e];if(t)return t;let n=aD.find(t=>t.name===e);if(n){let t=n.load,r=await t();return aN[e]=r.default,r.default}let r=aY().postSubmissionActions.find(t=>t.name===e);if(r){let t=r.load,n=await t();return aN[e]=n.default,n.default}return console.error(`No loader found for PostSubmissionAction registration of id: ${e}`),null}async function aU(e){if(aM[e])return aM[e];let t=aw.find(t=>t.name===e)?.component;if(!t){let n=await aY().fieldValidators.find(t=>t.name===e)?.load?.();t=n?.default}return aM[e]=t,t}async function aW(e){if(aL[e])return aL[e];let t=aO.find(t=>t.name===e)?.component;if(!t){let n=oO(e);if(n)t=aO.find(e=>e.name===n.datasource.name)?.component;else{let n=await aY().dataSources.find(t=>t.name===e)?.load?.();if(!n)throw Error("Datasource not found");t=n.default}}return aL[e]=t,t}function aY(){return(0,s.getGlobalStore)(u.RA,{controls:[],postSubmissionActions:[],expressionHelpers:{},fieldValidators:[],fieldValueAdapters:[],dataSources:[],formSchemaTransformers:[]}).getState()}function aJ(e,t,n,r,i){var o,a;let[l,s]=(0,c.useState)(null),[u,d]=(0,c.useState)((o=e,a=t,o||a?o&&a?Error("InvalidArgumentsErr: Both formUuid and formJson cannot be provided at the same time."):void 0:Error("InvalidArgumentsErr: Neither formUuid nor formJson was provided")));return(0,c.useEffect)(()=>{let o=new AbortController;return aZ(e,t,r,i).then(e=>{var t={...e,encounter:n};if(t?.translations){let e=window.i18next.language;window.i18next.addResourceBundle(e,oX.L,t.translations,!0,!0)}s(t)}).catch(e=>{"AbortError"!==e.name&&(console.error(e),d(Error("Error loading form JSON: "+e.message)))}),()=>{o.abort()}},[r,e,t,n]),{formJson:l,isLoading:!l&&!u,formError:u}}async function aZ(e,t,n,r){var i,o,s,u,c,d,f;let p,m,h=await (0,e6.fetchOpenMRSForm)(e),g=await (0,e6.fetchClobData)(h),y=await aH(),v=g?{...g,uuid:h.uuid}:"string"==typeof(i=t)?JSON.parse(i):JSON.parse(JSON.stringify(i)),b=v.pages.filter(e=>e.isSubform&&!e.subform.form&&e.subform?.name).map(e=>e.subform?.name);o=v,(await aG(b,n)).forEach(e=>{let t=o.pages.find(t=>t.subform?.name===e.name);t&&(t.subform.form=e)});let _=(s=v,(p=s?.referencedForms)||[]),w=await aQ(_),x=_.reduce((e,t)=>(e[t.formName]=t.alias,e),{});return c=v,d=(u=w,m=new Map,u.forEach(e=>{m.set(e.name,e)}),m),f=x,d.forEach((e,t)=>{c.pages.forEach(n=>{n.sections&&n.sections.forEach(n=>{if(n.reference&&(n.reference.form===t||n.reference.form===f[t])){let t=function(e,t){let n,r=t.pages.filter(t=>t.label===e.reference.page);if(r.length>0){let t=r[0].sections.filter(t=>t.label===e.reference.section);t.length>0&&(n=t[0])}var i=n,o=e.reference;if(o?.excludeQuestions){let e=o.excludeQuestions;i.questions=i.questions.filter(t=>!e.includes(t.id))}return i}(n,e);Object.assign(n,t)}})})}),function e(t,n=[],r,i){var o;return function(t,n){for(let r=t.pages.length-1;r>=0;r--){let i=t.pages[r];(0,tk.H)(i.isSubform)&&!(0,tk.H)(i.isHidden)&&i.subform?.form?.encounterType===t.encounterType&&(i.subform.form.pages.filter(e=>!(0,tk.H)(e.isSubform)),t.pages.splice(r,1,...e(i.subform.form,[],n).pages))}}(t,r),n.reduce((e,t)=>t.transform(e,i),t),(o=t).encounter&&"string"==typeof o.encounter&&!o.encounterType&&(o.encounterType=o.encounter,delete o.encounter),function e(t,n,r){if(!t)return n;let i=JSON.parse(JSON.stringify(n));return i.defaultPage=i.availableIntents?.find(e=>e.intent===(t?.intent||t))?.defaultPage,i.markdown&&l(i.markdown,t),i.pages=i.pages||[],i.pages.forEach(n=>{if(n.isSubform&&n.subform?.form){let r=[],i=n.subform.behaviours?.find(e=>e.intent==t?.intent||t);(i?.readonly!==void 0||i?.readonly!=null)&&r.push({name:"readonly",type:"field",value:i?.readonly}),n.subform.form=e(i?.subform_intent||"*",n.subform?.form,r)}let i=n.behaviours?.find(e=>e.intent===(t?.intent||t));if(i)n.hide=i.hide??n.hide,n.readonly=i.readonly??n.readonly;else{let e=n.behaviours?.find(e=>"*"===e.intent);e&&(n.hide=e.hide??n.hide,n.readonly=e.readonly??n.readonly)}n.markdown&&l(n.markdown,t),n.sections=n.sections||[],n.sections.forEach(e=>{let n=e.behaviours?.find(e=>e.intent===t?.intent||t);if(n)e.hide=n.hide??e.hide;else{let t=e.behaviours?.find(e=>"*"===e.intent);e.hide=t?.hide??e.hide}e.markdown&&l(e.markdown,t),e.questions=e.questions||[],e.questions.forEach(e=>{e.behaviours&&(a(e,t?.intent||t),r?.filter(e=>"all"==e.type||"field"==e.type)?.forEach(t=>{e[t.name]=t.value})),e.questions&&e.questions.length&&e.questions.forEach(e=>{a(e,t?.intent||t),r?.filter(e=>"all"==e.type||"field"==e.type)?.forEach(t=>{e[t.name]=t.value})})})})}),i}(r,t)}(v,y,n,r)}async function aG(e,t){return Promise.all(e.map(e=>aZ(e,null,t)))}async function aQ(e){return Promise.all(e.map(e=>aZ(e.formName,null,null)))}var aK=function(e,t){return(aK=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function aX(e,t){function n(){this.constructor=e}aK(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function a0(e){return"function"==typeof e}var a1=!1,a2={Promise:void 0,set useDeprecatedSynchronousErrorHandling(value){value&&Error().stack,a1=value},get useDeprecatedSynchronousErrorHandling(){return a1}};function a4(e){setTimeout(function(){throw e},0)}var a3={closed:!0,next:function(e){},error:function(e){if(a2.useDeprecatedSynchronousErrorHandling)throw e;a4(e)},complete:function(){}},a5=Array.isArray||function(e){return e&&"number"==typeof e.length},a6=function(){function e(e){return Error.call(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map(function(e,t){return t+1+") "+e.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=e,this}return e.prototype=Object.create(Error.prototype),e}(),a9=function(){var e;function t(e){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,e&&(this._ctorUnsubscribe=!0,this._unsubscribe=e)}return t.prototype.unsubscribe=function(){if(!this.closed){var e,n=this._parentOrParents,r=this._ctorUnsubscribe,i=this._unsubscribe,o=this._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,n instanceof t)n.remove(this);else if(null!==n)for(var a=0;a<n.length;++a)n[a].remove(this);if(a0(i)){r&&(this._unsubscribe=void 0);try{i.call(this)}catch(t){e=t instanceof a6?a7(t.errors):[t]}}if(a5(o))for(var a=-1,l=o.length;++a<l;){var s=o[a];if(null!==s&&"object"==typeof s)try{s.unsubscribe()}catch(t){e=e||[],t instanceof a6?e=e.concat(a7(t.errors)):e.push(t)}}if(e)throw new a6(e)}},t.prototype.add=function(e){var n=e;if(!e)return t.EMPTY;switch(typeof e){case"function":n=new t(e);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof t)){var r=n;(n=new t)._subscriptions=[r]}break;default:throw Error("unrecognized teardown "+e+" added to Subscription.")}var i=n._parentOrParents;if(null===i)n._parentOrParents=this;else if(i instanceof t){if(i===this)return n;n._parentOrParents=[i,this]}else{if(-1!==i.indexOf(this))return n;i.push(this)}var o=this._subscriptions;return null===o?this._subscriptions=[n]:o.push(n),n},t.prototype.remove=function(e){var t=this._subscriptions;if(t){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}},(e=new t).closed=!0,t.EMPTY=e,t}();function a7(e){return e.reduce(function(e,t){return e.concat(t instanceof a6?t.errors:t)},[])}var a8="function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random(),le=function(e){function t(n,r,i){var o=e.call(this)||this;switch(o.syncErrorValue=null,o.syncErrorThrown=!1,o.syncErrorThrowable=!1,o.isStopped=!1,arguments.length){case 0:o.destination=a3;break;case 1:if(!n){o.destination=a3;break}if("object"==typeof n){n instanceof t?(o.syncErrorThrowable=n.syncErrorThrowable,o.destination=n,n.add(o)):(o.syncErrorThrowable=!0,o.destination=new lt(o,n));break}default:o.syncErrorThrowable=!0,o.destination=new lt(o,n,r,i)}return o}return aX(t,e),t.prototype[a8]=function(){return this},t.create=function(e,n,r){var i=new t(e,n,r);return i.syncErrorThrowable=!1,i},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this))},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){this.destination.error(e),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var e=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=e,this},t}(a9),lt=function(e){function t(t,n,r,i){var o,a=e.call(this)||this;a._parentSubscriber=t;var l=a;return a0(n)?o=n:n&&(o=n.next,r=n.error,i=n.complete,n!==a3&&(a0((l=Object.create(n)).unsubscribe)&&a.add(l.unsubscribe.bind(l)),l.unsubscribe=a.unsubscribe.bind(a))),a._context=l,a._next=o,a._error=r,a._complete=i,a}return aX(t,e),t.prototype.next=function(e){if(!this.isStopped&&this._next){var t=this._parentSubscriber;a2.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,e)&&this.unsubscribe():this.__tryOrUnsub(this._next,e)}},t.prototype.error=function(e){if(!this.isStopped){var t=this._parentSubscriber,n=a2.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?this.__tryOrSetError(t,this._error,e):this.__tryOrUnsub(this._error,e),this.unsubscribe();else if(t.syncErrorThrowable)n?(t.syncErrorValue=e,t.syncErrorThrown=!0):a4(e),this.unsubscribe();else{if(this.unsubscribe(),n)throw e;a4(e)}}},t.prototype.complete=function(){var e=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return e._complete.call(e._context)};a2.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,n):this.__tryOrUnsub(n),this.unsubscribe()}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(e,t){try{e.call(this._context,t)}catch(e){if(this.unsubscribe(),a2.useDeprecatedSynchronousErrorHandling)throw e;a4(e)}},t.prototype.__tryOrSetError=function(e,t,n){if(!a2.useDeprecatedSynchronousErrorHandling)throw Error("bad call");try{t.call(this._context,n)}catch(t){if(a2.useDeprecatedSynchronousErrorHandling)return e.syncErrorValue=t,e.syncErrorThrown=!0,!0;return a4(t),!0}return!1},t.prototype._unsubscribe=function(){var e=this._parentSubscriber;this._context=null,this._parentSubscriber=null,e.unsubscribe()},t}(le),ln="function"==typeof Symbol&&Symbol.observable||"@@observable",lr=function(){function e(e){this._isScalar=!1,e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this.operator,i=function(e,t,n){if(e){if(e instanceof le)return e;if(e[a8])return e[a8]()}return e||t||n?new le(e,t,n):new le(a3)}(e,t,n);if(r?i.add(r.call(i,this.source)):i.add(this.source||a2.useDeprecatedSynchronousErrorHandling&&!i.syncErrorThrowable?this._subscribe(i):this._trySubscribe(i)),a2.useDeprecatedSynchronousErrorHandling&&i.syncErrorThrowable&&(i.syncErrorThrowable=!1,i.syncErrorThrown))throw i.syncErrorValue;return i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){a2.useDeprecatedSynchronousErrorHandling&&(e.syncErrorThrown=!0,e.syncErrorValue=t),function(e){for(;e;){var t=e,n=t.closed,r=t.destination,i=t.isStopped;if(n||i)return!1;e=r&&r instanceof le?r:null}return!0}(e)?e.error(t):console.warn(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=li(t))(function(t,r){var i;i=n.subscribe(function(t){try{e(t)}catch(e){r(e),i&&i.unsubscribe()}},r,t)})},e.prototype._subscribe=function(e){var t=this.source;return t&&t.subscribe(e)},e.prototype[ln]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 0===e.length?this:(0===e.length?function(e){return e}:1===e.length?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=li(e))(function(e,n){var r;t.subscribe(function(e){return r=e},function(e){return n(e)},function(){return e(r)})})},e.create=function(t){return new e(t)},e}();function li(e){if(e||(e=a2.Promise||Promise),!e)throw Error("no Promise impl found");return e}var lo=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),la=function(e){function t(t,n){var r=e.call(this)||this;return r.subject=t,r.subscriber=n,r.closed=!1,r}return aX(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var n=t.indexOf(this.subscriber);-1!==n&&t.splice(n,1)}}},t}(a9),ll=function(e){function t(t){var n=e.call(this,t)||this;return n.destination=t,n}return aX(t,e),t}(le),ls=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return aX(t,e),t.prototype[a8]=function(){return new ll(this)},t.prototype.lift=function(e){var t=new lu(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new lo;if(!this.isStopped)for(var t=this.observers,n=t.length,r=t.slice(),i=0;i<n;i++)r[i].next(e)},t.prototype.error=function(e){if(this.closed)throw new lo;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,n=t.length,r=t.slice(),i=0;i<n;i++)r[i].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new lo;this.isStopped=!0;for(var e=this.observers,t=e.length,n=e.slice(),r=0;r<t;r++)n[r].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(!this.closed)return e.prototype._trySubscribe.call(this,t);throw new lo},t.prototype._subscribe=function(e){if(this.closed)throw new lo;return this.hasError?(e.error(this.thrownError),a9.EMPTY):this.isStopped?(e.complete(),a9.EMPTY):(this.observers.push(e),new la(this,e))},t.prototype.asObservable=function(){var e=new lr;return e.source=this,e},t.create=function(e,t){return new lu(e,t)},t}(lr),lu=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return aX(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):a9.EMPTY},t}(ls),lc=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return aX(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return n&&!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(!this.closed)return this._value;throw new lo},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(ls);function ld(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let lf=new class{setEvaluatedPagesVisibility(e){this.evaluatedPagesVisibilitySubject.next(e)}updateScrollablePages(e){this.scrollablePagesSubject.next(e)}updatePagesWithErrors(e){this.pagesWithErrorsSubject.next(new Set(e))}addActivePage(e){let t=this.activePagesSubject.value;t.add(e),this.activePagesSubject.next(t)}removeInactivePage(e){let t=this.activePagesSubject.value;t.delete(e),this.activePagesSubject.next(t)}getActivePagesObservable(){return this.activePagesSubject.asObservable()}getScrollablePagesObservable(){return this.scrollablePagesSubject.asObservable()}getPagesWithErrorsObservable(){return this.pagesWithErrorsSubject.asObservable()}getEvaluatedPagesVisibilityObservable(){return this.evaluatedPagesVisibilitySubject.asObservable()}clear(){this.scrollablePagesSubject.next([]),this.pagesWithErrorsSubject.next(new Set),this.activePagesSubject.next(new Set),this.evaluatedPagesVisibilitySubject.next(!1)}constructor(){ld(this,"scrollablePagesSubject",new lc([])),ld(this,"pagesWithErrorsSubject",new lc(new Set)),ld(this,"activePagesSubject",new lc(new Set)),ld(this,"evaluatedPagesVisibilitySubject",new lc(null))}},lp=new Set,lm=()=>{let[e,t]=(0,c.useState)({pages:[],pagesWithErrors:[],activePages:[],evaluatedPagesVisibility:!1,hasMultiplePages:null});return(0,c.useEffect)(()=>{let e=[lf.getScrollablePagesObservable().subscribe(e=>{t(t=>({...t,pages:e,hasMultiplePages:e.length>1}))}),lf.getPagesWithErrorsObservable().subscribe(e=>{t(t=>({...t,pagesWithErrors:Array.from(e)}))}),lf.getActivePagesObservable().subscribe(e=>{t(t=>({...t,activePages:Array.from(e)}))}),lf.getEvaluatedPagesVisibilityObservable().subscribe(e=>{t(t=>({...t,evaluatedPagesVisibility:e}))})];return()=>e.forEach(e=>e.unsubscribe())},[]),e},lh={female:"F",male:"M",other:"O",unknown:"U"},lg=({section:e})=>{let{formFieldAdapters:t}=tD(),n=(0,c.useMemo)(()=>e.label.replace(/\s/g,""),[e.label]);return d().createElement("div",{className:"-esm-form-engine__section-renderer__section___OpnOG"},e.questions.map(e=>t[e.type]?d().createElement("div",{key:`${n}-${e.id}`,className:"-esm-form-engine__section-renderer__sectionBody___lI63X"},d().createElement(tV,{key:e.id,fieldId:e.id,valueAdapter:t[e.type]})):null))};var ly=n(9086),lv=!!("u">typeof window&&window.document&&window.document.createElement),lb=void 0;function l_(e){e.handlers===e.nextHandlers&&(e.nextHandlers=e.handlers.slice())}function lw(e){this.target=e,this.events={}}lw.prototype.getEventHandlers=function(e,t){var n=String(e)+" "+String(t?!0===t?100:(0|t.capture)+(t.passive<<1)+(t.once<<2):0);return this.events[n]||(this.events[n]={handlers:[],handleEvent:void 0},this.events[n].nextHandlers=this.events[n].handlers),this.events[n]},lw.prototype.handleEvent=function(e,t,n){var r=this.getEventHandlers(e,t);r.handlers=r.nextHandlers,r.handlers.forEach(function(e){e&&e(n)})},lw.prototype.add=function(e,t,n){var r=this,i=this.getEventHandlers(e,n);l_(i),0===i.nextHandlers.length&&(i.handleEvent=this.handleEvent.bind(this,e,n),this.target.addEventListener(e,i.handleEvent,n)),i.nextHandlers.push(t);var o=!0;return function(){if(o){o=!1,l_(i);var a=i.nextHandlers.indexOf(t);i.nextHandlers.splice(a,1),0===i.nextHandlers.length&&(r.target&&r.target.removeEventListener(e,i.handleEvent,n),i.handleEvent=void 0)}}};var lx="__consolidated_events_handlers__";function lE(e,t,n,r){e[lx]||(e[lx]=new lw(e));var i=function(e){if(e)return(void 0===lb&&(lb=function(){if(!lv||!window.addEventListener||!window.removeEventListener||!Object.defineProperty)return!1;var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}}),n=function(){};window.addEventListener("testPassiveEventSupport",n,t),window.removeEventListener("testPassiveEventSupport",n,t)}catch(e){}return e}()),lb)?e:!!e.capture}(r);return e[lx].add(t,n,i)}var lk=n(524);function lS(e,t){var n=!isNaN(parseFloat(e))&&isFinite(e)?parseFloat(e):"px"===e.slice(-2)?parseFloat(e.slice(0,-2)):void 0;if("number"==typeof n)return n;var r=function(e){if("%"===e.slice(-1))return parseFloat(e.slice(0,-1))/100}(e);if("number"==typeof r)return r*t}var lO="above",lD="inside",lC="below",lF="invisible";function lA(e){return"string"==typeof e.type}var lP=[];function lT(e){lP.push(e),r||(r=setTimeout(function(){var e;for(r=null;e=lP.shift();)e()},0));var t=!0;return function(){if(t){t=!1;var n=lP.indexOf(e);-1!==n&&(lP.splice(n,1),!lP.length&&r&&(clearTimeout(r),r=null))}}}var lV="u">typeof window,lM=function(e){function t(t){var n;return(n=e.call(this,t)||this).refElement=function(e){n._ref=e},n}(0,ly.A)(t,e);var r=t.prototype;return r.componentDidMount=function(){var e=this;lV&&(this.cancelOnNextTick=lT(function(){e.cancelOnNextTick=null;var t=e.props,n=t.children;t.debug;var r=e._ref;if(n&&!lA(n)&&!r)throw Error("<Waypoint> needs a DOM element to compute boundaries. The child you passed is neither a DOM element (e.g. <div>) nor does it use the innerRef prop.\n\nSee https://goo.gl/LrBNgw for more info.");e._handleScroll=e._handleScroll.bind(e),e.scrollableAncestor=e._findScrollableAncestor(),e.scrollEventListenerUnsubscribe=lE(e.scrollableAncestor,"scroll",e._handleScroll,{passive:!0}),e.resizeEventListenerUnsubscribe=lE(window,"resize",e._handleScroll,{passive:!0}),e._handleScroll(null)}))},r.componentDidUpdate=function(){var e=this;lV&&this.scrollableAncestor&&(this.cancelOnNextTick||(this.cancelOnNextTick=lT(function(){e.cancelOnNextTick=null,e._handleScroll(null)})))},r.componentWillUnmount=function(){lV&&(this.scrollEventListenerUnsubscribe&&this.scrollEventListenerUnsubscribe(),this.resizeEventListenerUnsubscribe&&this.resizeEventListenerUnsubscribe(),this.cancelOnNextTick&&this.cancelOnNextTick())},r._findScrollableAncestor=function(){var e=this.props,t=e.horizontal,r=e.scrollableAncestor;if(r)return"window"===r?n.g.window:r;for(var i=this._ref;i.parentNode&&(i=i.parentNode)!==document.body;){var o=window.getComputedStyle(i),a=(t?o.getPropertyValue("overflow-x"):o.getPropertyValue("overflow-y"))||o.getPropertyValue("overflow");if("auto"===a||"scroll"===a||"overlay"===a)return i}return window},r._handleScroll=function(e){if(this._ref){var t=this._getBounds(),n=t.viewportBottom-t.viewportTop==0?lF:t.viewportTop<=t.waypointTop&&t.waypointTop<=t.viewportBottom||t.viewportTop<=t.waypointBottom&&t.waypointBottom<=t.viewportBottom||t.waypointTop<=t.viewportTop&&t.viewportBottom<=t.waypointBottom?lD:t.viewportBottom<t.waypointTop?lC:t.waypointTop<t.viewportTop?lO:lF,r=this._previousPosition,i=this.props,o=(i.debug,i.onPositionChange),a=i.onEnter,l=i.onLeave,s=i.fireOnRapidScroll;if(this._previousPosition=n,r!==n){var u={currentPosition:n,previousPosition:r,event:e,waypointTop:t.waypointTop,waypointBottom:t.waypointBottom,viewportTop:t.viewportTop,viewportBottom:t.viewportBottom};o.call(this,u),n===lD?a.call(this,u):r===lD&&l.call(this,u);var c=r===lC&&n===lO,d=r===lO&&n===lC;s&&(c||d)&&(a.call(this,{currentPosition:lD,previousPosition:r,event:e,waypointTop:t.waypointTop,waypointBottom:t.waypointBottom,viewportTop:t.viewportTop,viewportBottom:t.viewportBottom}),l.call(this,{currentPosition:n,previousPosition:lD,event:e,waypointTop:t.waypointTop,waypointBottom:t.waypointBottom,viewportTop:t.viewportTop,viewportBottom:t.viewportBottom}))}}},r._getBounds=function(){var e,t,n=this.props,r=n.horizontal;n.debug;var i=this._ref.getBoundingClientRect(),o=i.left,a=i.top,l=i.right,s=i.bottom;this.scrollableAncestor===window?(e=r?window.innerWidth:window.innerHeight,t=0):(e=r?this.scrollableAncestor.offsetWidth:this.scrollableAncestor.offsetHeight,t=r?this.scrollableAncestor.getBoundingClientRect().left:this.scrollableAncestor.getBoundingClientRect().top);var u=this.props,c=u.bottomOffset,d=lS(u.topOffset,e),f=lS(c,e),p=t+e;return{waypointTop:r?o:a,waypointBottom:r?l:s,viewportTop:t+d,viewportBottom:p-f}},r.render=function(){var e=this,t=this.props.children;return t?lA(t)||(0,lk.isForwardRef)(t)?d().cloneElement(t,{ref:function(n){e.refElement(n),t.ref&&("function"==typeof t.ref?t.ref(n):t.ref.current=n)}}):d().cloneElement(t,{innerRef:this.refElement}):d().createElement("span",{ref:this.refElement,style:{fontSize:0}})},t}(d().PureComponent);lM.above=lO,lM.below=lC,lM.inside=lD,lM.invisible=lF,lM.defaultProps={debug:!1,scrollableAncestor:void 0,children:void 0,topOffset:"0px",bottomOffset:"0px",horizontal:!1,onEnter:function(){},onLeave:function(){},onPositionChange:function(){},fireOnRapidScroll:!0},lM.displayName="Waypoint";let lj={pageContent:"-esm-form-engine__page-renderer__pageContent___ZYB9J",pageHeader:"-esm-form-engine__page-renderer__pageHeader___XuC5+",pageTitle:"-esm-form-engine__page-renderer__pageTitle___AbChc",collapseIcon:"-esm-form-engine__page-renderer__collapseIcon___eEY4D",sectionContainer:"-esm-form-engine__page-renderer__sectionContainer___nfi1A",accordionContainer:"-esm-form-engine__page-renderer__accordionContainer___M2pxs",firstSection:"-esm-form-engine__page-renderer__firstSection___IQTsd",lastSection:"-esm-form-engine__page-renderer__lastSection___sooKZ",formSection:"-esm-form-engine__page-renderer__formSection___PGg8p",hiddenAccordion:"-esm-form-engine__page-renderer__hiddenAccordion___-29II"};function lI({section:e,sectionIndex:t,visibleSections:n,isFormExpanded:r}){let{t:i}=(0,eO.useTranslation)(),[o,a]=(0,c.useState)(r);return(0,c.useEffect)(()=>{a(r)},[r]),d().createElement(g.AccordionItem,{title:i(e.label),open:o,className:p()(lj.sectionContainer,{[lj.firstSection]:0===t,[lj.lastSection]:t===n.length-1})},d().createElement("div",{className:lj.formSection},d().createElement(lg,{section:e})))}let lN=function({page:e,isFormExpanded:t}){let{t:n}=(0,eO.useTranslation)(),[r,i]=(0,c.useState)(!1),o=(0,c.useMemo)(()=>e.sections.filter(e=>{let t=e.questions.some(e=>!(0,tk.H)(e.isHidden));return!(0,tk.H)(e.isHidden)&&t}),[e.sections]);return(0,c.useEffect)(()=>(i(!t),()=>{lf.removeInactivePage(e.id)}),[t]),d().createElement("div",null,d().createElement(lM,{key:e.id,onEnter:()=>lf.addActivePage(e.id),onLeave:()=>lf.removeInactivePage(e.id),topOffset:"40%",bottomOffset:"40%"},d().createElement("div",{id:e.id,className:lj.pageContent},d().createElement("div",{className:lj.pageHeader,onClick:()=>i(!r)},d().createElement("p",{className:lj.pageTitle},n(e.label),d().createElement("span",{className:lj.collapseIconWrapper},r?d().createElement(s.ChevronDownIcon,{className:lj.collapseIcon,"aria-label":"Expand"}):d().createElement(s.ChevronUpIcon,{className:lj.collapseIcon,"aria-label":"Collapse"})))),d().createElement("div",{className:p()({[lj.hiddenAccordion]:r,[lj.accordionContainer]:!r})},d().createElement(g.Accordion,null,o.map((e,n)=>d().createElement(lI,{key:`section-${e.label}`,section:e,sectionIndex:n,visibleSections:o,isFormExpanded:t})))))))},lL={formFields:[],invalidFields:[],formJson:null,deletedFields:[]},lq=(e,t)=>{switch(t.type){case"SET_FORM_FIELDS":return{...e,formFields:t.value};case"ADD_FORM_FIELD":return{...e,formFields:[...e.formFields,t.value]};case"UPDATE_FORM_FIELD":return{...e,formFields:e.formFields.map(e=>e.id===t.value.id?t.value:e)};case"REMOVE_FORM_FIELD":return{...e,formFields:e.formFields.filter(e=>e.id!==t.value)};case"SET_INVALID_FIELDS":return{...e,invalidFields:t.value};case"ADD_INVALID_FIELD":return{...e,invalidFields:[...e.invalidFields,t.value]};case"REMOVE_INVALID_FIELD":return{...e,invalidFields:e.invalidFields.filter(e=>e.id!==t.value)};case"CLEAR_INVALID_FIELDS":return{...e,invalidFields:[]};case"SET_FORM_JSON":return{...e,formJson:t.value};case"SET_DELETED_FIELDS":return{...e,deletedFields:t.value};default:return e}},lR=({processorContext:e,initialValues:t,isSubForm:n,setIsLoadingFormDependencies:r})=>{let i,o,a,l,s,u,f,p,{evaluatedFields:m,evaluatedFormJson:h,evaluatedPagesVisibility:g}=((e,t)=>{let{formFields:n,patient:r,sessionMode:i,visit:o}=t,[a,l]=(0,c.useState)(t.formJson),[s,u]=(0,c.useState)(!1),d=(0,c.useMemo)(()=>n?.map(t=>{var a;let l,s,u={value:t,type:"field"},c={patient:r,mode:i,visit:o};if(t.hide?.hideWhenExpression){let r=tc(t.hide.hideWhenExpression,u,n,e,c);t.isHidden=r,Array.isArray(t.questions)&&t.questions.forEach(e=>{e.isHidden=r})}else t.isHidden=!1;"object"==typeof t.required&&"conditionalRequired"===t.required.type?t.isRequired=tg(t,n,e):t.isRequired=(0,tk.H)(t.required),"object"==typeof t.disabled&&t.disabled.disableWhenExpression?t.isDisabled=tc(t.disabled.disableWhenExpression,u,n,e,c):t.isDisabled=(0,tk.H)(t.disabled),t.validators?.some(e=>"conditionalAnswered"===e.type)&&(l=t.validators.find(e=>"conditionalAnswered"===e.type).referenceQuestionId,(s=n.find(e=>e.id==l))&&(s.fieldDependents||(s.fieldDependents=new Set)).add(t.id)),t.questionOptions.answers?.filter(e=>!eV(e.hide?.hideWhenExpression)).forEach(t=>{t.isHidden=tc(t.hide.hideWhenExpression,u,n,e,c)}),t.questionOptions.answers?.filter(e=>!eV(e.disable?.disableWhenExpression)).forEach(t=>{t.disable.isDisabled=tc(t.disable?.disableWhenExpression,u,n,e,c)}),"string"==typeof t.readonly&&"true"!==(a=t.readonly)&&"false"!==a&&(t.meta.readonlyExpression=t.readonly,t.readonly=tc(t.readonly,u,n,e,c));let d=t.questionOptions.repeatOptions?.limitExpression;return"repeating"!==t.questionOptions.rendering||eV(d)||(t.questionOptions.repeatOptions.limit=tc(d,u,n,e,c)),t}),[e,n,r,i]);return(0,c.useEffect)(()=>{t.formJson?.pages?.forEach(t=>{t.hide?ty({value:t,type:"page"},n,e,i,r,tc,null):t.isHidden=!1,t?.sections?.forEach(t=>{t.hide?ty({value:t,type:"section"},n,e,i,r,tc,null):t.isHidden=!1})}),l(ez(t.formJson)),u(!0)},[t.formJson,n]),{evaluatedFormJson:a,evaluatedFields:d,evaluatedPagesVisibility:s}})(t,e),{registerForm:D,setIsFormDirty:V,workspaceLayout:M,isFormExpanded:j}=aa(),I=function(e={}){let t=d().useRef(void 0),n=d().useRef(void 0),[r,i]=d().useState({isDirty:!1,isValidating:!1,isLoading:F(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:F(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:r},e.defaultValues&&!F(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{let{formControl:n,...i}=function(e={}){let t,n={...eS,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:F(n.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:n.errors||{},disabled:n.disabled||!1},i={},o=(b(n.defaultValues)||b(n.values))&&k(n.defaultValues||n.values)||{},a=n.shouldUnregister?{}:k(o),l={action:!1,mount:!1,watch:!1,keepIsValid:!1},s={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},u=0,c={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},d={...c},f={...d},p={array:X(),state:X()},m="all"===n.criteriaMode,h=async e=>{if(!l.keepIsValid&&!n.disabled&&(d.isValid||f.isValid||e)){let e;n.resolver?(e=ee((await M()).errors),g()):e=await N({fields:i,onlyCheckValid:!0,eventType:"valid"}),e!==r.isValid&&p.state.next({isValid:e})}},g=(e,t)=>{!n.disabled&&(d.isValidating||d.validatingFields||f.isValidating||f.validatingFields)&&((e||Array.from(s.mount)).forEach(e=>{e&&(t?A(r.validatingFields,e,t):er(r.validatingFields,e))}),p.state.next({validatingFields:r.validatingFields,isValidating:!ee(r.validatingFields)}))},D=(e,t,n,r)=>{let s=C(i,e);if(s){let i=C(a,e,S(n)?C(o,e):n);S(i)||r&&r.defaultChecked||t?A(a,e,t?i:ep(s._f)):H(e,i),l.mount&&!l.action&&h()}},V=(e,t,i,a,l)=>{let s=!1,u=!1,c={name:e};if(!n.disabled){if(!i||a){(d.isDirty||f.isDirty)&&(u=r.isDirty,r.isDirty=c.isDirty=L(),s=u!==c.isDirty);let n=J(C(o,e),t);u=!!C(r.dirtyFields,e),n?er(r.dirtyFields,e):A(r.dirtyFields,e,!0),c.dirtyFields=r.dirtyFields,s=s||(d.dirtyFields||f.dirtyFields)&&!n!==u}if(i){let t=C(r.touchedFields,e);t||(A(r.touchedFields,e,i),c.touchedFields=r.touchedFields,s=s||(d.touchedFields||f.touchedFields)&&t!==i)}s&&l&&p.state.next(c)}return s?c:{}},M=async e=>(g(e,!0),await n.resolver(a,n.context,((e,t,n,r)=>{let i={};for(let n of e){let e=C(t,n);e&&A(i,n,e._f)}return{criteriaMode:n,names:[...e],fields:i,shouldUseNativeValidation:r}})(e||s.mount,i,n.criteriaMode,n.shouldUseNativeValidation))),j=async e=>{let{errors:t}=await M(e);if(g(e),e)for(let n of e){let e=C(t,n);e?A(r.errors,n,e):er(r.errors,n)}else r.errors=t;return t},I=async({name:t,eventType:n})=>{if(e.validate){let i=await e.validate({formValues:a,formState:r,name:t,eventType:n});if(b(i))for(let e in i)i[e]&&es(`${R}.${e}`,{message:U(i.message)?i.message:"",type:q});else U(i)||!i?es(R,{message:i||"",type:q}):el(R);return i}return!0},N=async({fields:t,onlyCheckValid:i,name:o,eventType:l,context:u={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(u.runRootValidation=!0,!await I({name:o,eventType:l}))&&(u.valid=!1,i))return u.valid;for(let o in t){let c=t[o];if(c){let{_f:t,...f}=c;if(t){let o=s.array.has(t.name),l=c._f&&ey(c._f);l&&d.validatingFields&&g([t.name],!0);let f=await ek(c,s.disabled,a,m,n.shouldUseNativeValidation&&!i,o);if(l&&d.validatingFields&&g([t.name]),f[t.name]&&(u.valid=!1,i)||(i||(C(f,t.name)?o?ew(r.errors,f,t.name):A(r.errors,t.name,f[t.name]):er(r.errors,t.name)),e.shouldUseNativeValidation&&f[t.name]))break}ee(f)||await N({context:u,onlyCheckValid:i,fields:f,name:o,eventType:l})}}return u.valid},L=(e,t)=>!n.disabled&&(e&&t&&A(a,e,t),!J(ei(),o)),B=(e,t,n)=>W(e,s,{...l.mount?a:S(t)?o:U(e)?{[e]:t}:t},n,t),H=(e,t,n={})=>{let r=C(i,e),o=t;if(r){let n=r._f;n&&(n.disabled||A(a,e,ec(t,n)),o=et(n.ref)&&v(t)?"":t,"select-multiple"===n.ref.type?[...n.ref.options].forEach(e=>e.selected=o.includes(e.value)):n.refs?"checkbox"===n.ref.type?n.refs.forEach(e=>{e.defaultChecked&&e.disabled||(Array.isArray(o)?e.checked=!!o.find(t=>t===e.value):e.checked=o===e.value||!!o)}):n.refs.forEach(e=>e.checked=e.value===o):"file"===n.ref.type?n.ref.value="":(n.ref.value=o,n.ref.type||p.state.next({name:e,values:k(a)})))}(n.shouldDirty||n.shouldTouch)&&V(e,o,n.shouldTouch,n.shouldDirty,!0),n.shouldValidate&&Q(e)},z=(e,t,n)=>{for(let r in t){if(!t.hasOwnProperty(r))return;let o=t[r],a=e+"."+r,l=C(i,a);(s.array.has(e)||b(o)||l&&!l._f)&&!y(o)?z(a,o,n):H(a,o,n)}},Y=(e,t,n={})=>{let u=C(i,e),c=s.array.has(e),m=k(t);A(a,e,m),c?(p.array.next({name:e,values:k(a)}),(d.isDirty||d.dirtyFields||f.isDirty||f.dirtyFields)&&n.shouldDirty&&p.state.next({name:e,dirtyFields:ea(o,a),isDirty:L(e,m)})):!u||u._f||v(m)?H(e,m,n):z(e,m,n),ev(e,s)?p.state.next({...r,name:e,values:k(a)}):p.state.next({name:l.mount?e:void 0,values:k(a)})},Z=async o=>{l.mount=!0;let c=o.target,v=c.name,b=!0,w=C(i,v),x=e=>{b=Number.isNaN(e)||y(e)&&isNaN(e.getTime())||J(e,C(a,v,e))},E=eh(n.mode),S=eh(n.reValidateMode);if(w){var O,D,F,T,j;let l,y,$,B=c.type?ep(w._f):_(o),H=o.type===P||"focusout"===o.type,z=!(($=w._f).mount&&($.required||$.min||$.max||$.maxLength||$.minLength||$.pattern||$.validate))&&!e.validate&&!n.resolver&&!C(r.errors,v)&&!w._f.deps||(O=H,D=C(r.touchedFields,v),F=r.isSubmitted,T=S,!(j=E).isOnAll&&(!F&&j.isOnTouch?!(D||O):(F?T.isOnBlur:j.isOnBlur)?!O:(F?!T.isOnChange:!j.isOnChange)||O)),U=ev(v,s,H);A(a,v,B),H?c&&c.readOnly||(w._f.onBlur&&w._f.onBlur(o),t&&t(0)):w._f.onChange&&w._f.onChange(o);let W=V(v,B,H),Y=!ee(W)||U;if(H||p.state.next({name:v,type:o.type,values:k(a)}),z)return(d.isValid||f.isValid)&&("onBlur"===n.mode?H&&h():H||h()),Y&&p.state.next({name:v,...U?{}:W});if(!n.resolver&&e.validate&&await I({name:v,eventType:o.type}),!H&&U&&p.state.next({...r}),n.resolver){let{errors:e}=await M([v]);if(g([v]),x(B),b){let t=e_(r.errors,i,v),n=e_(e,i,t.name||v);l=n.error,v=n.name,y=ee(e)}}else g([v],!0),l=(await ek(w,s.disabled,a,m,n.shouldUseNativeValidation))[v],g([v]),x(B),b&&(l?y=!1:(d.isValid||f.isValid)&&(y=await N({fields:i,onlyCheckValid:!0,name:v,eventType:o.type})));if(b){w._f.deps&&(!Array.isArray(w._f.deps)||w._f.deps.length>0)&&Q(w._f.deps);var L=v,q=y,R=l;let e=C(r.errors,L),i=(d.isValid||f.isValid)&&"boolean"==typeof q&&r.isValid!==q;if(n.delayError&&R){let e;e=()=>{A(r.errors,L,R),p.state.next({errors:r.errors})},(t=t=>{clearTimeout(u),u=setTimeout(e,t)})(n.delayError)}else clearTimeout(u),t=null,R?A(r.errors,L,R):er(r.errors,L);if((R?!J(e,R):e)||!ee(W)||i){let e={...W,...i&&"boolean"==typeof q?{isValid:q}:{},errors:r.errors,name:L};r={...r,...e},p.state.next(e)}}}},G=(e,t)=>{if(C(r.errors,t)&&e.focus)return e.focus(),1},Q=async(e,t={})=>{let o,a,l=K(e);if(n.resolver){let t=await j(S(e)?e:l);o=ee(t),a=e?!l.some(e=>C(t,e)):o}else e?((a=(await Promise.all(l.map(async e=>{let t=C(i,e);return await N({fields:t&&t._f?{[e]:t}:t,eventType:T})}))).every(Boolean))||r.isValid)&&h():a=o=await N({fields:i,name:e,eventType:T});return p.state.next({...!U(e)||(d.isValid||f.isValid)&&o!==r.isValid?{}:{name:e},...n.resolver||!e?{isValid:o}:{},errors:r.errors}),t.shouldFocus&&!a&&eb(i,G,e?l:s.mount),a},ei=(e,t)=>{let n={...l.mount?a:o};return t&&(n=function e(t,n){let r={};for(let i in t)if(t.hasOwnProperty(i)){let o=t[i],a=n[i];if(o&&b(o)&&a){let t=e(o,a);b(t)&&(r[i]=t)}else t[i]&&(r[i]=a)}return r}(t.dirtyFields?r.dirtyFields:r.touchedFields,n)),S(e)?n:U(e)?C(n,e):e.map(e=>C(n,e))},eo=(e,t)=>({invalid:!!C((t||r).errors,e),isDirty:!!C((t||r).dirtyFields,e),error:C((t||r).errors,e),isValidating:!!C(r.validatingFields,e),isTouched:!!C((t||r).touchedFields,e)}),el=e=>{let t=e?K(e):void 0;null==t||t.forEach(e=>er(r.errors,e)),t?t.forEach(e=>{p.state.next({name:e,errors:r.errors})}):p.state.next({errors:{}})},es=(e,t,n)=>{let o=(C(i,e,{_f:{}})._f||{}).ref,{ref:a,message:l,type:s,...u}=C(r.errors,e)||{};A(r.errors,e,{...u,...t,ref:o}),p.state.next({name:e,errors:r.errors,isValid:!1}),n&&n.shouldFocus&&o&&o.focus&&o.focus()},eu=e=>p.state.subscribe({next:t=>{let n,i,l;n=e.name,i=t.name,l=e.exact,(!n||!i||n===i||K(n).some(e=>e&&(l?e===i:e.startsWith(i)||i.startsWith(e))))&&((e,t,n,r)=>{n(e);let{name:i,...o}=e;return ee(o)||Object.keys(o).length>=Object.keys(t).length||Object.keys(o).find(e=>t[e]===(!r||"all"))})(t,e.formState||d,eC,e.reRenderRoot)&&e.callback({values:{...a},...r,...t,defaultValues:o})}}).unsubscribe,ed=(e,t={})=>{for(let l of e?K(e):s.mount)s.mount.delete(l),s.array.delete(l),t.keepValue||(er(i,l),er(a,l)),t.keepError||er(r.errors,l),t.keepDirty||er(r.dirtyFields,l),t.keepTouched||er(r.touchedFields,l),t.keepIsValidating||er(r.validatingFields,l),n.shouldUnregister||t.keepDefaultValue||er(o,l);p.state.next({values:k(a)}),p.state.next({...r,...!t.keepDirty?{}:{isDirty:L()}}),t.keepIsValid||h()},ef=({disabled:e,name:t})=>{if("boolean"==typeof e&&l.mount||e||s.disabled.has(t)){let n=s.disabled.has(t);e?s.disabled.add(t):s.disabled.delete(t),!!e!==n&&l.mount&&!l.action&&h()}},eg=(e,t={})=>{let r=C(i,e),a="boolean"==typeof t.disabled||"boolean"==typeof n.disabled;return(A(i,e,{...r||{},_f:{...r&&r._f?r._f:{ref:{name:e}},name:e,mount:!0,...t}}),s.mount.add(e),r)?ef({disabled:"boolean"==typeof t.disabled?t.disabled:n.disabled,name:e}):D(e,!0,t.value),{...a?{disabled:t.disabled||n.disabled}:{},...n.progressive?{required:!!t.required,min:em(t.min),max:em(t.max),minLength:em(t.minLength),maxLength:em(t.maxLength),pattern:em(t.pattern)}:{},name:e,onChange:Z,onBlur:Z,ref:a=>{if(a){let n;eg(e,t),r=C(i,e);let l=S(a.value)&&a.querySelectorAll&&a.querySelectorAll("input,select,textarea")[0]||a,s="radio"===(n=l).type||"checkbox"===n.type,u=r._f.refs||[];(s?u.find(e=>e===l):l===r._f.ref)||(A(i,e,{_f:{...r._f,...s?{refs:[...u.filter(en),l,...Array.isArray(C(o,e))?[{}]:[]],ref:{type:l.type,name:e}}:{ref:l}}}),D(e,!1,void 0,l))}else(r=C(i,e,{}))._f&&(r._f.mount=!1),(n.shouldUnregister||t.shouldUnregister)&&!(x(s.array,e)&&l.action)&&s.unMount.add(e)}}},ex=()=>n.shouldFocusError&&eb(i,G,s.mount),eE=(e,t)=>async o=>{let l;o&&(o.preventDefault&&o.preventDefault(),o.persist&&o.persist());let u=k(a);if(p.state.next({isSubmitting:!0}),n.resolver){let{errors:e,values:t}=await M();g(),r.errors=e,u=k(t)}else await N({fields:i,eventType:"submit"});if(s.disabled.size)for(let e of s.disabled)er(u,e);if(er(r.errors,$),ee(r.errors)){p.state.next({errors:{}});try{await e(u,o)}catch(e){l=e}}else t&&await t({...r.errors},o),ex(),setTimeout(ex);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ee(r.errors)&&!l,submitCount:r.submitCount+1,errors:r.errors}),l)throw l},eO=(e,t={})=>{let u=e?k(e):o,c=k(u),f=ee(e),m=f?o:c;if(t.keepDefaultValues||(o=u),!t.keepValues){if(t.keepDirtyValues)for(let e of Array.from(new Set([...s.mount,...Object.keys(ea(o,a))]))){let t=C(r.dirtyFields,e),n=C(a,e),i=C(m,e);t&&!S(n)?A(m,e,n):t||S(i)||Y(e,i)}else{if(E&&S(e))for(let e of s.mount){let t=C(i,e);if(t&&t._f){let e=Array.isArray(t._f.refs)?t._f.refs[0]:t._f.ref;if(et(e)){let t=e.closest("form");if(t){t.reset();break}}}}if(t.keepFieldsRef)for(let e of s.mount)Y(e,C(m,e));else i={}}a=n.shouldUnregister?t.keepDefaultValues?k(o):{}:k(m),p.array.next({values:{...m}}),p.state.next({values:{...m}})}s={mount:t.keepDirtyValues?s.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!d.isValid||!!t.keepIsValid||!!t.keepDirtyValues||!n.shouldUnregister&&!ee(m),l.watch=!!n.shouldUnregister,l.keepIsValid=!!t.keepIsValid,l.action=!1,t.keepErrors||(r.errors={}),p.state.next({submitCount:t.keepSubmitCount?r.submitCount:0,isDirty:!f&&(t.keepDirty?r.isDirty:!!(t.keepDefaultValues&&!J(e,o))),isSubmitted:!!t.keepIsSubmitted&&r.isSubmitted,dirtyFields:f?{}:t.keepDirtyValues?t.keepDefaultValues&&a?ea(o,a):r.dirtyFields:t.keepDefaultValues&&e?ea(o,e):t.keepDirty?r.dirtyFields:{},touchedFields:t.keepTouched?r.touchedFields:{},errors:t.keepErrors?r.errors:{},isSubmitSuccessful:!!t.keepIsSubmitSuccessful&&r.isSubmitSuccessful,isSubmitting:!1,defaultValues:o})},eD=(e,t)=>eO(F(e)?e(a):e,{...n.resetOptions,...t}),eC=e=>{r={...r,...e}},eF={control:{register:eg,unregister:ed,getFieldState:eo,handleSubmit:eE,setError:es,_subscribe:eu,_runSchema:M,_updateIsValidating:g,_focusError:ex,_getWatch:B,_getDirty:L,_setValid:h,_setFieldArray:(e,t=[],s,u,c=!0,m=!0)=>{if(u&&s&&!n.disabled){if(l.action=!0,m&&Array.isArray(C(i,e))){let t=s(C(i,e),u.argA,u.argB);c&&A(i,e,t)}if(m&&Array.isArray(C(r.errors,e))){let t,n=s(C(r.errors,e),u.argA,u.argB);c&&A(r.errors,e,n),O(C(t=r.errors,e)).length||er(t,e)}if((d.touchedFields||f.touchedFields)&&m&&Array.isArray(C(r.touchedFields,e))){let t=s(C(r.touchedFields,e),u.argA,u.argB);c&&A(r.touchedFields,e,t)}if(d.dirtyFields||f.dirtyFields){let t=ea(o,a),n=w(e);A(r.dirtyFields,n,C(t,n))}p.state.next({name:e,isDirty:L(e,t),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else A(a,e,t)},_setDisabledField:ef,_setErrors:e=>{r.errors=e,p.state.next({errors:r.errors,isValid:!1})},_getFieldArray:e=>O(C(l.mount?a:o,e,n.shouldUnregister?C(o,e,[]):[])),_reset:eO,_resetDefaultValues:()=>F(n.defaultValues)&&n.defaultValues().then(e=>{eD(e,n.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:()=>{for(let e of s.unMount){let t=C(i,e);t&&(t._f.refs?t._f.refs.every(e=>!en(e)):!en(t._f.ref))&&ed(e)}s.unMount=new Set},_disableForm:e=>{"boolean"==typeof e&&(p.state.next({disabled:e}),eb(i,(t,n)=>{let r=C(i,n);r&&(t.disabled=r._f.disabled||e,Array.isArray(r._f.refs)&&r._f.refs.forEach(t=>{t.disabled=r._f.disabled||e}))},0,!1))},_subjects:p,_proxyFormState:d,get _fields(){return i},get _formValues(){return a},get _state(){return l},set _state(value){l=value},get _defaultValues(){return o},get _names(){return s},set _names(value){s=value},get _formState(){return r},get _options(){return n},set _options(value){n={...n,...value}}},subscribe:e=>(l.mount=!0,f={...f,...e.formState},eu({...e,formState:{...c,...e.formState}})),trigger:Q,register:eg,handleSubmit:eE,watch:(e,t)=>F(e)?p.state.subscribe({next:n=>"values"in n&&e(B(void 0,t),n)}):B(e,t,!0),setValue:Y,getValues:ei,reset:eD,resetField:(e,t={})=>{C(i,e)&&(S(t.defaultValue)?Y(e,k(C(o,e))):(Y(e,t.defaultValue),A(o,e,k(t.defaultValue))),t.keepTouched||er(r.touchedFields,e),t.keepDirty||(er(r.dirtyFields,e),r.isDirty=t.defaultValue?L(e,k(C(o,e))):L()),!t.keepError&&(er(r.errors,e),d.isValid&&h()),p.state.next({...r}))},clearErrors:el,unregister:ed,setError:es,setFocus:(e,t={})=>{let n=C(i,e),r=n&&n._f;if(r){let e=r.refs?r.refs[0]:r.ref;e.focus&&setTimeout(()=>{e.focus(),t.shouldSelect&&F(e.select)&&e.select()})}},getFieldState:eo};return{...eF,formControl:eF}}(e);t.current={...i,formState:r}}let o=t.current.control;return o._options=e,z(()=>{let e=o._subscribe({formState:o._proxyFormState,callback:()=>i({...o._formState}),reRenderRoot:!0});return i(e=>({...e,isReady:!0})),o._formState.isReady=!0,e},[o]),d().useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),d().useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),d().useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),d().useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),d().useEffect(()=>{if(o._proxyFormState.isDirty){let e=o._getDirty();e!==r.isDirty&&o._subjects.state.next({isDirty:e})}},[o,r.isDirty]),d().useEffect(()=>{var t;e.values&&!J(e.values,n.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),(null==(t=o._options.resetOptions)?void 0:t.keepIsValid)||o._setValid(),n.current=e.values,i(e=>({...e}))):o._resetDefaultValues()},[o,e.values]),d().useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=d().useMemo(()=>H(r,o),[o,r]),t.current}({defaultValues:t,mode:"onChange",reValidateMode:"onChange",criteriaMode:"all"}),{formState:{isDirty:N}}=I,[{formFields:L,invalidFields:B,formJson:Y,deletedFields:Z},G]=(0,c.useReducer)(lq,{...lL,formFields:m,formJson:h}),{addFormField:Q,updateFormField:ei,getFormField:eo,removeFormField:el,setInvalidFields:es,addInvalidField:eu,removeInvalidField:ed,setForm:ef,setDeletedFields:eg}=(i=(0,c.useCallback)(e=>{G({type:"ADD_FORM_FIELD",value:e})},[]),o=(0,c.useCallback)(e=>{if(e.meta.groupId){let t=L.find(t=>t.id===e.meta.groupId);t&&(t.questions=t.questions.map(t=>t.id===e.id?e:t),o(t))}G({type:"UPDATE_FORM_FIELD",value:(0,oF.A)(e)})},[L]),a=(0,c.useCallback)(e=>L.find(t=>t.id===e),[L]),l=(0,c.useCallback)(e=>{G({type:"REMOVE_FORM_FIELD",value:e})},[]),s=(0,c.useCallback)(e=>{G({type:"SET_INVALID_FIELDS",value:e})},[]),u=(0,c.useCallback)(e=>{G({type:"ADD_INVALID_FIELD",value:e})},[]),f=(0,c.useCallback)(e=>{G({type:"REMOVE_INVALID_FIELD",value:e})},[]),p=(0,c.useCallback)(e=>{G({type:"SET_FORM_JSON",value:ez(e)})},[]),{addFormField:i,updateFormField:o,getFormField:a,removeFormField:l,setInvalidFields:s,addInvalidField:u,removeInvalidField:f,setForm:p,setDeletedFields:(0,c.useCallback)(e=>{G({type:"SET_DELETED_FIELDS",value:e})},[])});(0,c.useEffect)(()=>{let e=Y.pages.filter(e=>!e.isSubform).map(e=>e);lf.updateScrollablePages(e)},[Y.pages]),(0,c.useEffect)(()=>{lf.setEvaluatedPagesVisibility(g)},[g]),(0,c.useEffect)(()=>{lf.updatePagesWithErrors(B.map(e=>e.meta.pageId))},[B]);let ex=(0,c.useMemo)(()=>({...e,workspaceLayout:M,methods:I,formFields:L,formJson:Y,invalidFields:B,deletedFields:Z,addFormField:Q,updateFormField:ei,getFormField:eo,removeFormField:el,setInvalidFields:es,addInvalidField:eu,removeInvalidField:ed,setForm:ef,setDeletedFields:eg}),[e,M,I,L,Y,B,Z]);return(0,c.useEffect)(()=>{D(Y.name,n,ex)},[Y.name,n,ex]),(0,c.useEffect)(()=>{V(N)},[N]),d().createElement(tO,ex,Y.pages.map(e=>e.isSubform||tw(e)?e.isSubform&&e.subform?.form?d().createElement(lW,{key:e.subform.form.uuid,formJson:e.subform.form,isSubForm:!0,setIsLoadingFormDependencies:r}):d().createElement(lN,{key:e.label,page:e,isFormExpanded:j}):null))},l$=({context:e,setContext:t,setters:n,useCustomHooks:r,setIsLoadingCustomHooks:i})=>{let{isLoading:o=!1,error:a=null,data:l,updateContext:s}=r(e);return(0,c.useEffect)(()=>{!o&&s&&(s(t,n),i(!1))},[o]),null},lB={},lH={},lz=()=>{let{t:e}=(0,eO.useTranslation)();return d().createElement("div",{className:"-esm-form-engine__loader__loaderContainer___78hu3"},d().createElement(g.InlineLoading,{className:"-esm-form-engine__loader__loader___dnvKS",description:`${e("loading","Loading")} ...`}))},lU=["patient","formJson","visit","sessionMode","sessionDate","location","currentProvider","layoutType","processor","formFields","formFieldAdapters","formFieldValidators"],lW=({formJson:e,isSubForm:t=!1,setIsLoadingFormDependencies:n})=>{let{patient:r,sessionMode:i,formProcessors:o,layoutType:a,location:l,provider:f,sessionDate:p,visit:m}=aa(),{t:h}=(0,eO.useTranslation)(),y=(0,c.useId)(),v=(0,c.useMemo)(()=>{let t,n=o[e.processor];return n?t=new n(e):(console.error(`Form processor ${e.processor} not found, defaulting to EncounterFormProcessor`),t=new ae(e)),t.prepareFormSchema(e),t},[o,e.processor]),{formFields:b,conceptReferences:_}=function(e){let[t,n]=(0,c.useMemo)(()=>{let t=[],n=new Set,r=(e,i)=>{let o=i?{...e,meta:{...e.meta,groupId:i}}:e;t.push(o),o.questionOptions?.concept&&n.add(o.questionOptions.concept),o.questionOptions?.answers?.forEach(e=>{e.concept&&n.add(e.concept)}),"obsGroup"===o.type&&o.questions&&o.questions.forEach(e=>{r(e,o.id)})};return e.pages?.forEach(e=>e.sections?.forEach(e=>{e.questions?.forEach(e=>r(e))})),[t,JSON.stringify(Array.from(n).sort())]},[e]);return{formFields:t,conceptReferences:(0,c.useMemo)(()=>new Set(JSON.parse(n)),[n])}}(e),{concepts:w,isLoading:x}=function(e){let{data:t,error:n,isLoading:r}=o6()([`${s.restBaseUrl}/conceptreferences?v=custom:(uuid,display,conceptClass:(uuid,display),answers:(uuid,display),conceptMappings:(conceptReferenceTerm:(conceptSource:(name),code)))`,e],([e,t])=>(0,s.openmrsFetch)(e,{headers:{"Content-Type":"application/json"},body:{references:t},method:"POST"}),{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1,shouldRetryOnError:!1});return{concepts:(0,c.useMemo)(()=>t?.data?Object.values(t.data):void 0,[t]),isLoading:r,error:n}}(Array.from(_)),E=(0,c.useMemo)(()=>b.length&&w?.length?b.map(e=>{let t=tb(e.questionOptions.concept,w);return e.questionOptions.concept=t?t.uuid:e.questionOptions.concept,e.label=e.label?e.label:t?.display,u.FU.includes(e.questionOptions.rendering)&&!e.questionOptions.answers?.length&&t?.conceptClass?.display==="Question"&&t?.answers?.length&&(e.questionOptions.answers=t.answers.map(e=>({concept:e?.uuid,label:e?.display}))),e.meta={...e.meta||{},concept:t},e.questionOptions.answers&&(e.questionOptions.answers=e.questionOptions.answers.map(e=>{let t=tb(e.concept,w);return{...e,concept:t?t.uuid:e.concept,label:e.label?e.label:t?.display}})),e}):b??[],[w,b]),k=(e=>{let t=(0,c.useMemo)(()=>{let t=new Set;return e.forEach(e=>t.add(e.type)),Array.from(t).sort().join(",")},[e]),{data:n}=o3()(t?["formFieldValueAdapters",t]:null,async([,e])=>{let t=e.split(","),n=await Promise.all(t.map(e=>aB(e))),r={};return t.forEach((e,t)=>{r[e]=n[t]}),r},{keepPreviousData:!0});return n??lH})(b),S=function(e){let t=(0,c.useMemo)(()=>{let t=new Set;return e.forEach(e=>{e.validators?.forEach(e=>t.add(e.type))}),Array.from(t).sort().join(",")},[e]),{data:n}=o3()(t?["formFieldValidators",t]:null,async([,e])=>{let t=e.split(","),n=await Promise.all(t.map(e=>aU(e))),r={};return t.forEach((e,t)=>{r[e]=n[t]}),r},{keepPreviousData:!0});return n??lB}(b),O=(0,c.useMemo)(()=>E?.length?E:b??[],[E,b]),[D,C]=(0,c.useState)({}),F=(0,c.useMemo)(()=>({patient:r,formJson:e,sessionMode:i,layoutType:a,location:l,currentProvider:f,processor:v,sessionDate:p,visit:m,formFields:O,formFieldAdapters:k??{},formFieldValidators:S??{}}),[r,e,i,a,l,f,v,p,m,O,k,S]),A=(0,c.useMemo)(()=>({...F,...D}),[F,D]),P=(0,c.useCallback)(e=>{C(t=>{let n,r={...F,...t},i="function"==typeof e?e(r):e;return"function"==typeof e&&(n=lU.filter(e=>e in i&&i[e]!==r[e])).length&&console.warn(`A form processor tried to set the context propert${1===n.length?"y":"ies"} ${n.join(", ")}, which the form engine derives itself. ${1===n.length?"It was":"They were"} ignored. Use the setters passed alongside setContext to update the domain object or custom dependencies.`),{domainObjectValue:i.domainObjectValue,previousDomainObjectValue:i.previousDomainObjectValue,customDependencies:i.customDependencies}})},[F]),T=(0,c.useMemo)(()=>({setDomainObjectValue:e=>C(t=>({...t,domainObjectValue:e})),setPreviousDomainObjectValue:e=>C(t=>({...t,previousDomainObjectValue:e})),setCustomDependencies:e=>C(t=>({...t,customDependencies:"function"==typeof e?e(t.customDependencies??{}):e}))}),[]),{isLoading:V,error:M,retry:j}=((e,t,n,r)=>{let{loadDependencies:i}=e,{formJson:o}=t,[a,l]=(0,c.useState)(0),[s,u]=(0,c.useState)(null),d=(0,c.useCallback)(()=>l(e=>e+1),[]),f=s?.loadDependencies===i&&s?.attempt===a?s:null;return(0,c.useEffect)(()=>{let e=!1;return async function(){let l=await Promise.allSettled([Promise.resolve().then(()=>i?.(t,n,r)),te(o)]);if(!e){let e=l.find(e=>"rejected"===e.status);u({loadDependencies:i,attempt:a,error:e?Error(e.reason?.message??String(e.reason)):null})}}(),()=>{e=!0}},[i,a]),{isLoading:!f||!!f.error,error:f?.error,retry:d}})(v,A,P,T),I=v.getCustomHooks().useCustomHooks,[N,L]=(0,c.useState)(!!I),{isLoadingInitialValues:q,initialValues:R,error:$}=((e,t,n)=>{let[r,i]=(0,c.useState)(!0),[o,a]=(0,c.useState)({}),[l,s]=(0,c.useState)(null),u=(0,c.useRef)(n);u.current=n;let d=(0,c.useRef)(!1),f=n.formFields?.length>0,p=Object.keys(n.formFieldAdapters??{}).length>0;return(0,c.useEffect)(()=>{if(e&&!t&&f&&p&&!d.current){d.current=!0;let t=u.current;e.getInitialValues(t).then(e=>{a(e),i(!1)}).catch(e=>{console.error(e),s(e),i(!1)})}},[e,t,f,p]),{isLoadingInitialValues:r,initialValues:o,error:l}})(v,V||N||x,A),B=(0,c.useMemo)(()=>V||N||x||q,[V,N,x,q]);return(0,c.useEffect)(()=>{n(y,B)},[y,B,n]),(0,c.useEffect)(()=>()=>n(y,!1),[y,n]),(0,c.useEffect)(()=>{(0,tx.N)($,h("errorLoadingInitialValues","Error loading initial values"))},[$,h]),(0,c.useEffect)(()=>{k&&k&&Object.values(k).forEach(e=>{lp.add(e)})},[k]),d().createElement(d().Fragment,null,I&&d().createElement(l$,{context:A,setContext:P,setters:T,useCustomHooks:I,setIsLoadingCustomHooks:L}),M?d().createElement("div",null,d().createElement(g.InlineNotification,{kind:"error",hideCloseButton:!0,title:h("errorLoadingFormDependencies","Unable to load form data"),subtitle:h("retryLoadingFormDependencies","Required form data could not be loaded. Retry to complete and save this form.")}),d().createElement(g.Button,{kind:"tertiary",onClick:j},h("retry","Retry"))):B?d().createElement(lz,null):d().createElement(lR,{processorContext:A,initialValues:R,isSubForm:t,setIsLoadingFormDependencies:n}))},lY=({patient:e,hideActionsOverflow:t})=>d().createElement("div",{className:"-esm-form-engine__patient-banner__patientBannerContainer___w28t3"},d().createElement(s.ExtensionSlot,{name:"patient-header-slot",state:{patient:e,patientUuid:e.id,hideActionsOverflow:t}}));function lJ({page:e,currentActivePage:t,pagesWithErrors:n,requestPage:r}){let{t:i}=(0,eO.useTranslation)(),o=e.id===t,a=n.includes(e.id),l="tablet"===(0,s.useLayoutType)();return d().createElement("div",{className:p()("-esm-form-engine__sidebar__pageLink___ivjRs",{"-esm-form-engine__sidebar__activePage___PtOKZ":o&&!a,"-esm-form-engine__sidebar__errorPage___56UzK":a&&!o,"-esm-form-engine__sidebar__activeErrorPage___FRrGU":a&&o,"-esm-form-engine__sidebar__pageLinkTablet___DzG-5":l})},d().createElement("button",{onClick:t=>{t.preventDefault(),r(e.id)}},d().createElement("span",null,i(e.label))))}let lZ=({defaultPage:e,isFormSubmitting:t,sessionMode:n,onCancel:r,handleClose:i,hideFormCollapseToggle:o,hideControls:a})=>{let{t:l}=(0,eO.useTranslation)(),{pages:u,pagesWithErrors:f,activePages:m,evaluatedPagesVisibility:h}=lm(),{currentActivePage:y,requestPage:v}=(({pages:e,defaultPage:t,activePages:n,evaluatedPagesVisibility:r})=>{let[i,o]=(0,c.useState)(null),[a,l]=(0,c.useState)(!1),[s,u]=(0,c.useState)(null),d=(0,c.useRef)(!0);return(0,c.useEffect)(()=>{if(a||!r)return;let n=e.find(({label:e})=>e===t);if(n&&!n.isHidden)o(n.id),t_(n.id);else{let t=e.find(e=>!e.isHidden);t&&o(t.id)}l(!0)},[e,t,r,a]),(0,c.useEffect)(()=>{let e=null;return a&&(e=setTimeout(()=>{d.current=!1},200)),()=>{e&&clearTimeout(e)}},[a]),(0,c.useEffect)(()=>{if(d.current)return;let t=null;if(s&&n.includes(s)){o(s),t=setTimeout(()=>{u(null)},100);return}return!s&&n.length>0&&o(n.reduce((t,n)=>e.findIndex(e=>e.id===t)<e.findIndex(e=>e.id===n)?t:n)),()=>{t&&clearTimeout(t)}},[n,s,e]),{currentActivePage:i,requestPage:(0,c.useCallback)(e=>{d.current=!1,u(e),o(e),t_(e)},[])}})({pages:u,defaultPage:e,activePages:m,evaluatedPagesVisibility:h}),b=(0,s.useLayoutType)(),_=(0,c.useMemo)(()=>"tablet"===b?"lg":"sm",[b]);return d().createElement("div",{className:"-esm-form-engine__sidebar__sidebar___oko66"},u.filter(e=>tw(e)).map(e=>d().createElement(lJ,{key:e.id,page:e,currentActivePage:y,pagesWithErrors:f,requestPage:v})),"view"!==n&&!a&&d().createElement("hr",{className:"-esm-form-engine__sidebar__divider___qNrzq"}),!a&&d().createElement("div",{className:"-esm-form-engine__sidebar__sideNavActions___hQ7Cj"},"view"!==n&&d().createElement(g.Button,{className:"-esm-form-engine__sidebar__saveButton___1qxAl",disabled:t,type:"submit",size:_},t?d().createElement(g.InlineLoading,{description:l("submitting","Submitting")+"..."}):d().createElement("span",null,`${l("save","Save")}`)),d().createElement(g.Button,{className:p()("-esm-form-engine__sidebar__closeButton___X671g",{"-esm-form-engine__sidebar__topMargin___XINCj":"view"===n}),kind:"tertiary",onClick:()=>{r?.(),i?.(),o()},size:_},"view"===n?l("close","Close"):l("cancel","Cancel"))))},lG=({formJson:e,patientUUID:t,formUUID:n,encounterUUID:r,visit:i,formSessionIntent:o,mode:a,onSubmit:l,onCancel:u,handleClose:f,handleConfirmQuestionDeletion:m,markFormAsDirty:h,hideControls:y=!1,hidePatientBanner:v=!1,preFilledQuestions:b})=>{let{t:_}=(0,eO.useTranslation)(),w=(0,s.useSession)(),x=(0,c.useRef)(null),E=(0,c.useRef)(new Date),k=(0,c.useMemo)(()=>(function(e,t){if(!t)return e;let n=t.startDatetime?new Date(t.startDatetime):null,r=t.stopDatetime?new Date(t.stopDatetime):null;return n&&e<n||r&&e>r?n??r:e})(E.current,i),[i?.startDatetime,i?.stopDatetime]),S=function(e){let[t,n]=(0,c.useState)(0),r=(0,c.useMemo)(()=>t<=26.25?"narrow":t<=32.25?"wider":t<=48.25?"extra-wide":"ultra-wide",[t]);return(0,c.useLayoutEffect)(()=>{let t=()=>{let t=e.current?.parentElement?.offsetWidth,r=parseInt(getComputedStyle(document.documentElement).fontSize);t&&n(function(e,t=16){return e/t}(t,r))};t();let r=new ResizeObserver(e=>{t()});return e.current?.parentElement&&r.observe(e.current?.parentElement),()=>{r.disconnect()}},[e]),r}(x),{patient:O,isLoadingPatient:D}=(e=>{let{patient:t,isLoading:n,error:r}=(0,s.usePatient)(e);if(t&&!n){var i;let e,n;i=new Date(t?.birthDate),n=(e=new Date).getFullYear()-i.getFullYear(),t.age=e.getMonth()<i.getMonth()||e.getMonth()===i.getMonth()&&e.getDate()<i.getDate()?n-1:n,t.sex=lh[t.gender]??"U"}return{patient:t,isLoadingPatient:n,patientError:r}})(t),[C,F]=(0,c.useState)(!0),A=(0,c.useRef)(new Set),P=(0,c.useCallback)((e,t)=>{t?A.current.add(e):A.current.delete(e),F(A.current.size>0)},[]),[T,V]=(0,c.useState)(!1),[M,j]=(0,c.useState)(!1),I=eV(a)?eV(r)?"enter":"edit":a,{isFormExpanded:N,hideFormCollapseToggle:L}=function(e){let[t,n]=(0,c.useState)(void 0),r=(0,c.useCallback)(()=>{let e=new CustomEvent("openmrs:form-view-embedded",{detail:{value:!1}});window.dispatchEvent(e)},[]),i=(0,c.useCallback)(e=>{n(e.detail.value)},[]);return(0,c.useEffect)(()=>{let t=new CustomEvent("openmrs:form-view-embedded",{detail:{value:"embedded-view"!=e}});window.dispatchEvent(t)},[e]),(0,c.useEffect)(()=>(window.addEventListener("openmrs:form-collapse-toggle",i),()=>{window.removeEventListener("openmrs:form-collapse-toggle",i)}),[]),{isFormExpanded:t,hideFormCollapseToggle:r}}(I),{hasMultiplePages:q}=lm(),{formJson:R,isLoading:$,formError:B}=aJ(n,e,r,o,b),H=(0,c.useMemo)(()=>!v&&O&&"ultra-wide"===S&&"embedded-view"!==a,[O,a,S,v]),z=(0,c.useMemo)(()=>["narrow"].includes(S),[S]),U=(0,c.useMemo)(()=>"embedded-view"!==a&&!C&&null!==q&&(z||!q),[a,z,C,q]),W=(0,c.useMemo)(()=>"embedded-view"!==a&&!C&&null!==q&&!z&&q,[z,C,q]);(0,c.useEffect)(()=>{(0,tx.N)(B,_("errorLoadingFormSchema","Error loading form schema"))},[B]),(0,c.useEffect)(()=>()=>{lp.forEach(e=>{try{e.tearDown()}catch(e){}}),lp.clear(),lf.clear()},[]),(0,c.useEffect)(()=>{h?.(M)},[M]);let Y=(0,c.useCallback)(e=>{e.preventDefault(),V(!0)},[]);return d().createElement("form",{ref:x,noValidate:!0,className:p()("cds--form","-esm-form-engine__form-engine__form___G3zJ0"),onSubmit:Y},D||$?d().createElement(lz,null):d().createElement(ao,{patient:O,isLoadingDependencies:C,patientUUID:t,sessionMode:I,sessionDate:k,formJson:R,workspaceLayout:"ultra-wide"===S?"maximized":"minimized",location:w?.sessionLocation,provider:w?.currentProvider,visit:i,handleConfirmQuestionDeletion:m,isFormExpanded:N,formSubmissionProps:{isSubmitting:T,setIsSubmitting:V,onSubmit:l,onError:()=>{},handleClose:()=>{}},hideFormCollapseToggle:L,setIsFormDirty:j},d().createElement("div",{className:"-esm-form-engine__form-engine__formContainer___SqLcw"},C&&d().createElement("div",{className:"-esm-form-engine__form-engine__linearActivity___boIRq"},d().createElement("div",{className:"-esm-form-engine__form-engine__indeterminate___nUedJ"})),d().createElement("div",{className:"-esm-form-engine__form-engine__formContent___wWrk8"},W&&d().createElement(lZ,{isFormSubmitting:T,sessionMode:a,defaultPage:R.defaultPage,onCancel:u,handleClose:f,hideFormCollapseToggle:L,hideControls:y}),d().createElement("div",{className:"-esm-form-engine__form-engine__formContentInner___z1h1C"},H&&d().createElement(lY,{patient:O,hideActionsOverflow:!0}),R.markdown&&d().createElement("div",{className:"-esm-form-engine__form-engine__markdownContainer___A3eX9"},d().createElement(oo,{markdown:R.markdown})),d().createElement("div",{className:"-esm-form-engine__form-engine__formBody___Fb2k2"},d().createElement(lW,{formJson:R,setIsLoadingFormDependencies:P})),U&&!y&&d().createElement(g.ButtonSet,{className:"-esm-form-engine__form-engine__minifiedButtons___SnmW7"},d().createElement(g.Button,{kind:"secondary",onClick:()=>{u&&u(),f&&f(),L()}},"view"===a?_("close","Close"):_("cancel","Cancel")),d().createElement(g.Button,{className:"-esm-form-engine__form-engine__saveButton___T0Txa",disabled:C||T||"view"===a,kind:"primary",type:"submit"},T?d().createElement(g.InlineLoading,{description:_("submitting","Submitting")+"..."}):d().createElement("span",null,`${_("save","Save")}`))))))))},lQ=function(e){return d().createElement(c.Suspense,{fallback:d().createElement(lz,null)},d().createElement(eO.I18nextProvider,{i18n:window.i18next,defaultNS:oX.L},d().createElement(lG,e)))}},1809(e,t,n){"use strict";function r(e){return"boolean"==typeof e?e:"string"==typeof e?"true"==e:!!e}function i(e){return/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(e)}n.d(t,{H:()=>r,O:()=>i})},8059(e,t,n){"use strict";n.d(t,{N:()=>i,j:()=>o});var r=n(2664);function i(e,t){if(e){let n=o(e).join(", ");console.error(e),(0,r.showSnackbar)({subtitle:n,title:t,kind:"error",isLowContrast:!1})}}function o(e){let t=e?.responseBody?.error?.fieldErrors,n=e?.responseBody?.error?.globalErrors;return t&&0!==Object.keys(t).length||n?n?.length?n.flatMap(e=>e.message):Object.values(t).flatMap(e=>e.map(e=>e.message)):[e?.responseBody?.error?.message??e?.message]}},1630(e){e.exports=function(){"use strict";var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d/,r=/\d\d/,i=/\d\d?/,o=/\d*[^-_:/,()\s\d]+/,a={},l=function(e){return(e*=1)+(e>68?1900:2e3)},s=function(e){return function(t){this[e]=+t}},u=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e||"Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e)}],c=function(e){var t=a[e];return t&&(t.indexOf?t:t.s.concat(t.f))},d=function(e,t){var n,r=a.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},f={A:[o,function(e){this.afternoon=d(e,!1)}],a:[o,function(e){this.afternoon=d(e,!0)}],Q:[n,function(e){this.month=3*(e-1)+1}],S:[n,function(e){this.milliseconds=100*e}],SS:[r,function(e){this.milliseconds=10*e}],SSS:[/\d{3}/,function(e){this.milliseconds=+e}],s:[i,s("seconds")],ss:[i,s("seconds")],m:[i,s("minutes")],mm:[i,s("minutes")],H:[i,s("hours")],h:[i,s("hours")],HH:[i,s("hours")],hh:[i,s("hours")],D:[i,s("day")],DD:[r,s("day")],Do:[o,function(e){var t=a.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r)}],w:[i,s("week")],ww:[r,s("week")],M:[i,s("month")],MM:[r,s("month")],MMM:[o,function(e){var t=c("months"),n=(c("monthsShort")||t.map(function(e){return e.slice(0,3)})).indexOf(e)+1;if(n<1)throw Error();this.month=n%12||n}],MMMM:[o,function(e){var t=c("months").indexOf(e)+1;if(t<1)throw Error();this.month=t%12||t}],Y:[/[+-]?\d+/,s("year")],YY:[r,function(e){this.year=l(e)}],YYYY:[/\d{4}/,s("year")],Z:u,ZZ:u};return function(n,r,i){i.p.customParseFormat=!0,n&&n.parseTwoDigitYear&&(l=n.parseTwoDigitYear);var o=r.prototype,s=o.parse;o.parse=function(n){var r=n.date,o=n.utc,l=n.args;this.$u=o;var u=l[1];if("string"==typeof u){var c=!0===l[2],d=!0===l[3],p=l[2];d&&(p=l[2]),a=this.$locale(),!c&&p&&(a=i.Ls[p]),this.$d=function(n,r,i,o){try{if(["x","X"].indexOf(r)>-1)return new Date(("X"===r?1e3:1)*n);var l=(function(n){var r,i;r=n,i=a&&a.formats;for(var o=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(e,t,n){return t||n.slice(1)})})).match(t),l=o.length,s=0;s<l;s+=1){var u=o[s],c=f[u],d=c&&c[0],p=c&&c[1];o[s]=p?{regex:d,parser:p}:u.replace(/^\[|\]$/g,"")}return function(e){for(var t={},n=0,r=0;n<l;n+=1){var i=o[n];if("string"==typeof i)r+=i.length;else{var a=i.regex,s=i.parser,u=e.slice(r),c=a.exec(u)[0];s.call(t,c),e=e.replace(c,"")}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon}}(t),t}})(r)(n),s=l.year,u=l.month,c=l.day,d=l.hours,p=l.minutes,m=l.seconds,h=l.milliseconds,g=l.zone,y=l.week,v=new Date,b=c||(s||u?1:v.getDate()),_=s||v.getFullYear(),w=0;s&&!u||(w=u>0?u-1:v.getMonth());var x,E=d||0,k=p||0,S=m||0,O=h||0;return g?new Date(Date.UTC(_,w,b,E,k,S,O+60*g.offset*1e3)):i?new Date(Date.UTC(_,w,b,E,k,S,O)):(x=new Date(_,w,b,E,k,S,O),y&&(x=o(x).week(y).toDate()),x)}catch(e){return new Date("")}}(r,u,o,i),this.init(),p&&!0!==p&&(this.$L=this.locale(p).$L),(c||d)&&r!=this.format(u)&&(this.$d=new Date("")),a={}}else if(u instanceof Array)for(var m=u.length,h=1;h<=m;h+=1){l[1]=u[h-1];var g=i.apply(this,l);if(g.isValid()){this.$d=g.$d,this.$L=g.$L,this.init();break}h===m&&(this.$d=new Date(""))}else s.call(this,n)}}}()},9710(e){"use strict";var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,o=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===n.call(e)},a=function(e){if(!e||"[object Object]"!==n.call(e))return!1;var r,i=t.call(e,"constructor"),o=e.constructor&&e.constructor.prototype&&t.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!i&&!o)return!1;for(r in e);return void 0===r||t.call(e,r)},l=function(e,t){r&&"__proto__"===t.name?r(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},s=function(e,n){if("__proto__"===n){if(!t.call(e,n))return;else if(i)return i(e,n).value}return e[n]};e.exports=function e(){var t,n,r,i,u,c,d=arguments[0],f=1,p=arguments.length,m=!1;for("boolean"==typeof d&&(m=d,d=arguments[1]||{},f=2),(null==d||"object"!=typeof d&&"function"!=typeof d)&&(d={});f<p;++f)if(t=arguments[f],null!=t)for(n in t)r=s(d,n),d!==(i=s(t,n))&&(m&&i&&(a(i)||(u=o(i)))?(u?(u=!1,c=r&&o(r)?r:[]):c=r&&a(r)?r:{},l(d,{name:n,newValue:e(m,c,i)})):void 0!==i&&l(d,{name:n,newValue:i}));return d}},5937(e){var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,r=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,a=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,l=/^[;\s]*/,s=/^\s+|\s+$/g;function u(e){return e?e.replace(s,""):""}e.exports=function(e,s){if("string"!=typeof e)throw TypeError("First argument must be a string");if(!e)return[];s=s||{};var c=1,d=1;function f(e){var t=e.match(n);t&&(c+=t.length);var r=e.lastIndexOf("\n");d=~r?e.length-r:d+e.length}function p(){var e={line:c,column:d};return function(t){return t.position=new m(e),y(r),t}}function m(e){this.start=e,this.end={line:c,column:d},this.source=s.source}m.prototype.content=e;var h=[];function g(t){var n=Error(s.source+":"+c+":"+d+": "+t);if(n.reason=t,n.filename=s.source,n.line=c,n.column=d,n.source=e,s.silent)h.push(n);else throw n}function y(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function v(e){var t;for(e=e||[];t=b();)!1!==t&&e.push(t);return e}function b(){var t=p();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var n=2;""!=e.charAt(n)&&("*"!=e.charAt(n)||"/"!=e.charAt(n+1));)++n;if(n+=2,""===e.charAt(n-1))return g("End of comment missing");var r=e.slice(2,n-2);return d+=2,f(r),e=e.slice(n),d+=2,t({type:"comment",comment:r})}}y(r);var _,w=[];for(v(w);_=function(){var e=p(),n=y(i);if(n){if(b(),!y(o))return g("property missing ':'");var r=y(a),s=e({type:"declaration",property:u(n[0].replace(t,"")),value:r?u(r[0].replace(t,"")):""});return y(l),s}}();)!1!==_&&(w.push(_),v(w));return w}},3103(e,t,n){e.exports=n(4715)(n(8942),"DataView")},5098(e,t,n){var r=n(3305),i=n(9361),o=n(1112),a=n(5276),l=n(5071);function s(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=i,s.prototype.get=o,s.prototype.has=a,s.prototype.set=l,e.exports=s},1386(e,t,n){var r=n(2393),i=n(2049),o=n(7144),a=n(7452),l=n(3964);function s(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=i,s.prototype.get=o,s.prototype.has=a,s.prototype.set=l,e.exports=s},9770(e,t,n){e.exports=n(4715)(n(8942),"Map")},8250(e,t,n){var r=n(9753),i=n(5681),o=n(88),a=n(4732),l=n(9068);function s(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=i,s.prototype.get=o,s.prototype.has=a,s.prototype.set=l,e.exports=s},9413(e,t,n){e.exports=n(4715)(n(8942),"Promise")},4512(e,t,n){e.exports=n(4715)(n(8942),"Set")},3212(e,t,n){var r=n(8250),i=n(1877),o=n(8006);function a(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new r;++t<n;)this.add(e[t])}a.prototype.add=a.prototype.push=i,a.prototype.has=o,e.exports=a},1340(e,t,n){var r=n(1386),i=n(4103),o=n(1779),a=n(4162),l=n(7462),s=n(6638);function u(e){var t=this.__data__=new r(e);this.size=t.size}u.prototype.clear=i,u.prototype.delete=o,u.prototype.get=a,u.prototype.has=l,u.prototype.set=s,e.exports=u},5650(e,t,n){e.exports=n(8942).Symbol},1623(e,t,n){e.exports=n(8942).Uint8Array},9270(e,t,n){e.exports=n(4715)(n(8942),"WeakMap")},9968(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}},9847(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var a=e[n];t(a,n,e)&&(o[i++]=a)}return o}},358(e,t,n){var r=n(6137),i=n(3283),o=n(3142),a=n(5853),l=n(9632),s=n(8666),u=Object.prototype.hasOwnProperty;e.exports=function(e,t){var n=o(e),c=!n&&i(e),d=!n&&!c&&a(e),f=!n&&!c&&!d&&s(e),p=n||c||d||f,m=p?r(e.length,String):[],h=m.length;for(var g in e)(t||u.call(e,g))&&!(p&&("length"==g||d&&("offset"==g||"parent"==g)||f&&("buffer"==g||"byteLength"==g||"byteOffset"==g)||l(g,h)))&&m.push(g);return m}},5111(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}},1129(e){e.exports=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}},6465(e){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}},7034(e,t,n){var r=n(6285);e.exports=function(e,t){for(var n=e.length;n--;)if(r(e[n][0],t))return n;return -1}},4570(e,t,n){var r=n(7170);e.exports=n(5770)(r)},4661(e,t,n){var r=n(4570);e.exports=function(e,t){var n=[];return r(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}},7250(e){e.exports=function(e,t,n,r){for(var i=e.length,o=n+(r?1:-1);r?o--:++o<i;)if(t(e[o],o,e))return o;return -1}},5636(e,t,n){e.exports=n(6596)()},7170(e,t,n){var r=n(5636),i=n(1211);e.exports=function(e,t){return e&&r(e,t,i)}},7923(e,t,n){var r=n(3526),i=n(6040);e.exports=function(e,t){t=r(t,e);for(var n=0,o=t.length;null!=e&&n<o;)e=e[i(t[n++])];return n&&n==o?e:void 0}},8244(e,t,n){var r=n(1129),i=n(3142);e.exports=function(e,t,n){var o=t(e);return i(e)?o:r(o,n(e))}},7379(e,t,n){var r=n(5650),i=n(8870),o=n(9005),a=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":a&&a in Object(e)?i(e):o(e)}},3636(e){e.exports=function(e,t){return null!=e&&t in Object(e)}},6027(e,t,n){var r=n(7379),i=n(547);e.exports=function(e){return i(e)&&"[object Arguments]"==r(e)}},4687(e,t,n){var r=n(353),i=n(547);e.exports=function e(t,n,o,a,l){return t===n||(null!=t&&null!=n&&(i(t)||i(n))?r(t,n,o,a,e,l):t!=t&&n!=n)}},353(e,t,n){var r=n(1340),i=n(3934),o=n(8861),a=n(1182),l=n(8486),s=n(3142),u=n(5853),c=n(8666),d="[object Arguments]",f="[object Array]",p="[object Object]",m=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,h,g,y){var v=s(e),b=s(t),_=v?f:l(e),w=b?f:l(t);_=_==d?p:_,w=w==d?p:w;var x=_==p,E=w==p,k=_==w;if(k&&u(e)){if(!u(t))return!1;v=!0,x=!1}if(k&&!x)return y||(y=new r),v||c(e)?i(e,t,n,h,g,y):o(e,t,_,n,h,g,y);if(!(1&n)){var S=x&&m.call(e,"__wrapped__"),O=E&&m.call(t,"__wrapped__");if(S||O){var D=S?e.value():e,C=O?t.value():t;return y||(y=new r),g(D,C,n,h,y)}}return!!k&&(y||(y=new r),a(e,t,n,h,g,y))}},8330(e,t,n){var r=n(1340),i=n(4687);e.exports=function(e,t,n,o){var a=n.length,l=a,s=!o;if(null==e)return!l;for(e=Object(e);a--;){var u=n[a];if(s&&u[2]?u[1]!==e[u[0]]:!(u[0]in e))return!1}for(;++a<l;){var c=(u=n[a])[0],d=e[c],f=u[1];if(s&&u[2]){if(void 0===d&&!(c in e))return!1}else{var p=new r;if(o)var m=o(d,f,c,e,t,p);if(!(void 0===m?i(f,d,3,o,p):m))return!1}}return!0}},9624(e,t,n){var r=n(3655),i=n(4759),o=n(1580),a=n(4066),l=/^\[object .+?Constructor\]$/,s=Object.prototype,u=Function.prototype.toString,c=s.hasOwnProperty,d=RegExp("^"+u.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!o(e)||i(e))&&(r(e)?d:l).test(a(e))}},674(e,t,n){var r=n(7379),i=n(5387),o=n(547),a={};a["[object Float32Array]"]=a["[object Float64Array]"]=a["[object Int8Array]"]=a["[object Int16Array]"]=a["[object Int32Array]"]=a["[object Uint8Array]"]=a["[object Uint8ClampedArray]"]=a["[object Uint16Array]"]=a["[object Uint32Array]"]=!0,a["[object Arguments]"]=a["[object Array]"]=a["[object ArrayBuffer]"]=a["[object Boolean]"]=a["[object DataView]"]=a["[object Date]"]=a["[object Error]"]=a["[object Function]"]=a["[object Map]"]=a["[object Number]"]=a["[object Object]"]=a["[object RegExp]"]=a["[object Set]"]=a["[object String]"]=a["[object WeakMap]"]=!1,e.exports=function(e){return o(e)&&i(e.length)&&!!a[r(e)]}},3334(e,t,n){var r=n(6526),i=n(2343),o=n(2053),a=n(3142),l=n(3282);e.exports=function(e){return"function"==typeof e?e:null==e?o:"object"==typeof e?a(e)?i(e[0],e[1]):r(e):l(e)}},195(e,t,n){var r=n(4882),i=n(8121),o=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return i(e);var t=[];for(var n in Object(e))o.call(e,n)&&"constructor"!=n&&t.push(n);return t}},6526(e,t,n){var r=n(8330),i=n(4367),o=n(3904);e.exports=function(e){var t=i(e);return 1==t.length&&t[0][2]?o(t[0][0],t[0][1]):function(n){return n===e||r(n,e,t)}}},2343(e,t,n){var r=n(4687),i=n(6123),o=n(7276),a=n(5187),l=n(7267),s=n(3904),u=n(6040);e.exports=function(e,t){return a(e)&&l(t)?s(u(e),t):function(n){var a=i(n,e);return void 0===a&&a===t?o(n,e):r(t,a,3)}}},2762(e){e.exports=function(e){return function(t){return null==t?void 0:t[e]}}},8880(e,t,n){var r=n(7923);e.exports=function(e){return function(t){return r(t,e)}}},6137(e){e.exports=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}},2291(e,t,n){var r=n(5650),i=n(5111),o=n(3142),a=n(1187),l=1/0,s=r?r.prototype:void 0,u=s?s.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(o(t))return i(t,e)+"";if(a(t))return u?u.call(t):"";var n=t+"";return"0"==n&&1/t==-l?"-0":n}},6403(e,t,n){var r=n(2945),i=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(i,""):e}},9460(e){e.exports=function(e){return function(t){return e(t)}}},5568(e){e.exports=function(e,t){return e.has(t)}},3997(e,t,n){var r=n(2053);e.exports=function(e){return"function"==typeof e?e:r}},3526(e,t,n){var r=n(3142),i=n(5187),o=n(6493),a=n(5243);e.exports=function(e,t){return r(e)?e:i(e,t)?[e]:o(a(e))}},1950(e,t,n){e.exports=n(8942)["__core-js_shared__"]},5770(e,t,n){var r=n(6529);e.exports=function(e,t){return function(n,i){if(null==n)return n;if(!r(n))return e(n,i);for(var o=n.length,a=t?o:-1,l=Object(n);(t?a--:++a<o)&&!1!==i(l[a],a,l););return n}}},6596(e){e.exports=function(e){return function(t,n,r){for(var i=-1,o=Object(t),a=r(t),l=a.length;l--;){var s=a[e?l:++i];if(!1===n(o[s],s,o))break}return t}}},3934(e,t,n){var r=n(3212),i=n(6465),o=n(5568);e.exports=function(e,t,n,a,l,s){var u=1&n,c=e.length,d=t.length;if(c!=d&&!(u&&d>c))return!1;var f=s.get(e),p=s.get(t);if(f&&p)return f==t&&p==e;var m=-1,h=!0,g=2&n?new r:void 0;for(s.set(e,t),s.set(t,e);++m<c;){var y=e[m],v=t[m];if(a)var b=u?a(v,y,m,t,e,s):a(y,v,m,e,t,s);if(void 0!==b){if(b)continue;h=!1;break}if(g){if(!i(t,function(e,t){if(!o(g,t)&&(y===e||l(y,e,n,a,s)))return g.push(t)})){h=!1;break}}else if(!(y===v||l(y,v,n,a,s))){h=!1;break}}return s.delete(e),s.delete(t),h}},8861(e,t,n){var r=n(5650),i=n(1623),o=n(6285),a=n(3934),l=n(5894),s=n(9828),u=r?r.prototype:void 0,c=u?u.valueOf:void 0;e.exports=function(e,t,n,r,u,d,f){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)break;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":if(e.byteLength!=t.byteLength||!d(new i(e),new i(t)))break;return!0;case"[object Boolean]":case"[object Date]":case"[object Number]":return o(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var p=l;case"[object Set]":var m=1&r;if(p||(p=s),e.size!=t.size&&!m)break;var h=f.get(e);if(h)return h==t;r|=2,f.set(e,t);var g=a(p(e),p(t),r,u,d,f);return f.delete(e),g;case"[object Symbol]":if(c)return c.call(e)==c.call(t)}return!1}},1182(e,t,n){var r=n(393),i=Object.prototype.hasOwnProperty;e.exports=function(e,t,n,o,a,l){var s=1&n,u=r(e),c=u.length;if(c!=r(t).length&&!s)return!1;for(var d=c;d--;){var f=u[d];if(!(s?f in t:i.call(t,f)))return!1}var p=l.get(e),m=l.get(t);if(p&&m)return p==t&&m==e;var h=!0;l.set(e,t),l.set(t,e);for(var g=s;++d<c;){var y=e[f=u[d]],v=t[f];if(o)var b=s?o(v,y,f,t,e,l):o(y,v,f,e,t,l);if(!(void 0===b?y===v||a(y,v,n,o,l):b)){h=!1;break}g||(g="constructor"==f)}if(h&&!g){var _=e.constructor,w=t.constructor;_!=w&&"constructor"in e&&"constructor"in t&&!("function"==typeof _&&_ instanceof _&&"function"==typeof w&&w instanceof w)&&(h=!1)}return l.delete(e),l.delete(t),h}},4967(e,t,n){e.exports="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g},393(e,t,n){var r=n(8244),i=n(7979),o=n(1211);e.exports=function(e){return r(e,o,i)}},4700(e,t,n){var r=n(9067);e.exports=function(e,t){var n=e.__data__;return r(t)?n["string"==typeof t?"string":"hash"]:n.map}},4367(e,t,n){var r=n(7267),i=n(1211);e.exports=function(e){for(var t=i(e),n=t.length;n--;){var o=t[n],a=e[o];t[n]=[o,a,r(a)]}return t}},4715(e,t,n){var r=n(9624),i=n(155);e.exports=function(e,t){var n=i(e,t);return r(n)?n:void 0}},8870(e,t,n){var r=n(5650),i=Object.prototype,o=i.hasOwnProperty,a=i.toString,l=r?r.toStringTag:void 0;e.exports=function(e){var t=o.call(e,l),n=e[l];try{e[l]=void 0;var r=!0}catch(e){}var i=a.call(e);return r&&(t?e[l]=n:delete e[l]),i}},7979(e,t,n){var r=n(9847),i=n(9306),o=Object.prototype.propertyIsEnumerable,a=Object.getOwnPropertySymbols;e.exports=a?function(e){return null==e?[]:r(a(e=Object(e)),function(t){return o.call(e,t)})}:i},8486(e,t,n){var r=n(3103),i=n(9770),o=n(9413),a=n(4512),l=n(9270),s=n(7379),u=n(4066),c="[object Map]",d="[object Promise]",f="[object Set]",p="[object WeakMap]",m="[object DataView]",h=u(r),g=u(i),y=u(o),v=u(a),b=u(l),_=s;(r&&_(new r(new ArrayBuffer(1)))!=m||i&&_(new i)!=c||o&&_(o.resolve())!=d||a&&_(new a)!=f||l&&_(new l)!=p)&&(_=function(e){var t=s(e),n="[object Object]"==t?e.constructor:void 0,r=n?u(n):"";if(r)switch(r){case h:return m;case g:return c;case y:return d;case v:return f;case b:return p}return t}),e.exports=_},155(e){e.exports=function(e,t){return null==e?void 0:e[t]}},5899(e,t,n){var r=n(3526),i=n(3283),o=n(3142),a=n(9632),l=n(5387),s=n(6040);e.exports=function(e,t,n){t=r(t,e);for(var u=-1,c=t.length,d=!1;++u<c;){var f=s(t[u]);if(!(d=null!=e&&n(e,f)))break;e=e[f]}return d||++u!=c?d:!!(c=null==e?0:e.length)&&l(c)&&a(f,c)&&(o(e)||i(e))}},3305(e,t,n){var r=n(4497);e.exports=function(){this.__data__=r?r(null):{},this.size=0}},9361(e){e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=!!t,t}},1112(e,t,n){var r=n(4497),i=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(r){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return i.call(t,e)?t[e]:void 0}},5276(e,t,n){var r=n(4497),i=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return r?void 0!==t[e]:i.call(t,e)}},5071(e,t,n){var r=n(4497);e.exports=function(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=r&&void 0===t?"__lodash_hash_undefined__":t,this}},9632(e){var t=/^(?:0|[1-9]\d*)$/;e.exports=function(e,n){var r=typeof e;return!!(n=null==n?0x1fffffffffffff:n)&&("number"==r||"symbol"!=r&&t.test(e))&&e>-1&&e%1==0&&e<n}},5187(e,t,n){var r=n(3142),i=n(1187),o=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!!("number"==n||"symbol"==n||"boolean"==n||null==e||i(e))||a.test(e)||!o.test(e)||null!=t&&e in Object(t)}},9067(e){e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},4759(e,t,n){var r,i=n(1950),o=(r=/[^.]+$/.exec(i&&i.keys&&i.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"";e.exports=function(e){return!!o&&o in e}},4882(e){var t=Object.prototype;e.exports=function(e){var n=e&&e.constructor;return e===("function"==typeof n&&n.prototype||t)}},7267(e,t,n){var r=n(1580);e.exports=function(e){return e==e&&!r(e)}},2393(e){e.exports=function(){this.__data__=[],this.size=0}},2049(e,t,n){var r=n(7034),i=Array.prototype.splice;e.exports=function(e){var t=this.__data__,n=r(t,e);return!(n<0)&&(n==t.length-1?t.pop():i.call(t,n,1),--this.size,!0)}},7144(e,t,n){var r=n(7034);e.exports=function(e){var t=this.__data__,n=r(t,e);return n<0?void 0:t[n][1]}},7452(e,t,n){var r=n(7034);e.exports=function(e){return r(this.__data__,e)>-1}},3964(e,t,n){var r=n(7034);e.exports=function(e,t){var n=this.__data__,i=r(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this}},9753(e,t,n){var r=n(5098),i=n(1386),o=n(9770);e.exports=function(){this.size=0,this.__data__={hash:new r,map:new(o||i),string:new r}}},5681(e,t,n){var r=n(4700);e.exports=function(e){var t=r(this,e).delete(e);return this.size-=!!t,t}},88(e,t,n){var r=n(4700);e.exports=function(e){return r(this,e).get(e)}},4732(e,t,n){var r=n(4700);e.exports=function(e){return r(this,e).has(e)}},9068(e,t,n){var r=n(4700);e.exports=function(e,t){var n=r(this,e),i=n.size;return n.set(e,t),this.size+=+(n.size!=i),this}},5894(e){e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}},3904(e){e.exports=function(e,t){return function(n){return null!=n&&n[e]===t&&(void 0!==t||e in Object(n))}}},6853(e,t,n){var r=n(9011);e.exports=function(e){var t=r(e,function(e){return 500===n.size&&n.clear(),e}),n=t.cache;return t}},4497(e,t,n){e.exports=n(4715)(Object,"create")},8121(e,t,n){e.exports=n(3766)(Object.keys,Object)},2306(e,t,n){e=n.nmd(e);var r=n(4967),i=t&&!t.nodeType&&t,o=i&&e&&!e.nodeType&&e,a=o&&o.exports===i&&r.process,l=function(){try{var e=o&&o.require&&o.require("util").types;if(e)return e;return a&&a.binding&&a.binding("util")}catch(e){}}();e.exports=l},9005(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},3766(e){e.exports=function(e,t){return function(n){return e(t(n))}}},8942(e,t,n){var r=n(4967),i="object"==typeof self&&self&&self.Object===Object&&self;e.exports=r||i||Function("return this")()},1877(e){e.exports=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this}},8006(e){e.exports=function(e){return this.__data__.has(e)}},9828(e){e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}},4103(e,t,n){var r=n(1386);e.exports=function(){this.__data__=new r,this.size=0}},1779(e){e.exports=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}},4162(e){e.exports=function(e){return this.__data__.get(e)}},7462(e){e.exports=function(e){return this.__data__.has(e)}},6638(e,t,n){var r=n(1386),i=n(9770),o=n(8250);e.exports=function(e,t){var n=this.__data__;if(n instanceof r){var a=n.__data__;if(!i||a.length<199)return a.push([e,t]),this.size=++n.size,this;n=this.__data__=new o(a)}return n.set(e,t),this.size=n.size,this}},6493(e,t,n){var r=n(6853),i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,o=/\\(\\)?/g;e.exports=r(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(i,function(e,n,r,i){t.push(r?i.replace(o,"$1"):n||e)}),t})},6040(e,t,n){var r=n(1187),i=1/0;e.exports=function(e){if("string"==typeof e||r(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}},4066(e){var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},2945(e){var t=/\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},6285(e){e.exports=function(e,t){return e===t||e!=e&&t!=t}},7581(e,t,n){var r=n(9847),i=n(4661),o=n(3334),a=n(3142);e.exports=function(e,t){return(a(e)?r:i)(e,o(t,3))}},2154(e,t,n){var r=n(7250),i=n(3334),o=n(7642),a=Math.max;e.exports=function(e,t,n){var l=null==e?0:e.length;if(!l)return -1;var s=null==n?0:o(n);return s<0&&(s=a(l+s,0)),r(e,i(t,3),s)}},7289(e,t,n){e.exports=n(3981)},3657(e,t,n){var r=n(9968),i=n(4570),o=n(3997),a=n(3142);e.exports=function(e,t){return(a(e)?r:i)(e,o(t))}},6123(e,t,n){var r=n(7923);e.exports=function(e,t,n){var i=null==e?void 0:r(e,t);return void 0===i?n:i}},7276(e,t,n){var r=n(3636),i=n(5899);e.exports=function(e,t){return null!=e&&i(e,t,r)}},3981(e){e.exports=function(e){return e&&e.length?e[0]:void 0}},2053(e){e.exports=function(e){return e}},3283(e,t,n){var r=n(6027),i=n(547),o=Object.prototype,a=o.hasOwnProperty,l=o.propertyIsEnumerable;e.exports=r(function(){return arguments}())?r:function(e){return i(e)&&a.call(e,"callee")&&!l.call(e,"callee")}},3142(e){e.exports=Array.isArray},6529(e,t,n){var r=n(3655),i=n(5387);e.exports=function(e){return null!=e&&i(e.length)&&!r(e)}},5853(e,t,n){e=n.nmd(e);var r=n(8942),i=n(4772),o=t&&!t.nodeType&&t,a=o&&e&&!e.nodeType&&e,l=a&&a.exports===o?r.Buffer:void 0,s=l?l.isBuffer:void 0;e.exports=s||i},3655(e,t,n){var r=n(7379),i=n(1580);e.exports=function(e){if(!i(e))return!1;var t=r(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},5387(e){e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=0x1fffffffffffff}},1580(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},547(e){e.exports=function(e){return null!=e&&"object"==typeof e}},1187(e,t,n){var r=n(7379),i=n(547);e.exports=function(e){return"symbol"==typeof e||i(e)&&"[object Symbol]"==r(e)}},8666(e,t,n){var r=n(674),i=n(9460),o=n(2306),a=o&&o.isTypedArray;e.exports=a?i(a):r},1211(e,t,n){var r=n(358),i=n(195),o=n(6529);e.exports=function(e){return o(e)?r(e):i(e)}},8087(e){e.exports=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}},9011(e,t,n){var r=n(8250);function i(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw TypeError("Expected a function");var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(i.Cache||r),n}i.Cache=r,e.exports=i},3282(e,t,n){var r=n(2762),i=n(8880),o=n(5187),a=n(6040);e.exports=function(e){return o(e)?r(a(e)):i(e)}},9306(e){e.exports=function(){return[]}},4772(e){e.exports=function(){return!1}},3301(e,t,n){var r=n(6131),i=1/0;e.exports=function(e){return e?(e=r(e))===i||e===-i?(e<0?-1:1)*17976931348623157e292:e==e?e:0:0===e?e:0}},7642(e,t,n){var r=n(3301);e.exports=function(e){var t=r(e),n=t%1;return t==t?n?t-n:t:0}},6131(e,t,n){var r=n(6403),i=n(1580),o=n(1187),a=0/0,l=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(o(e))return a;if(i(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=i(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=s.test(e);return n||u.test(e)?c(e.slice(2),n?2:8):l.test(e)?a:+e}},5243(e,t,n){var r=n(2291);e.exports=function(e){return null==e?"":r(e)}},2281(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e.trim().replace(/^[=v]+/,""),t);return n?n.version:null}},6783(e,t,n){"use strict";let r=n(4517),i=n(3955),{safeRe:o,t:a}=n(2841);e.exports=(e,t)=>{if(e instanceof r)return e;if("number"==typeof e&&(e=String(e)),"string"!=typeof e)return null;let n=null;if((t=t||{}).rtl){let r,i=t.includePrerelease?o[a.COERCERTLFULL]:o[a.COERCERTL];for(;(r=i.exec(e))&&(!n||n.index+n[0].length!==e.length);)n&&r.index+r[0].length===n.index+n[0].length||(n=r),i.lastIndex=r.index+r[1].length+r[2].length;i.lastIndex=-1}else n=e.match(t.includePrerelease?o[a.COERCEFULL]:o[a.COERCE]);if(null===n)return null;let l=n[2],s=n[3]||"0",u=n[4]||"0",c=t.includePrerelease&&n[5]?`-${n[5]}`:"",d=t.includePrerelease&&n[6]?`+${n[6]}`:"";return i(`${l}.${s}.${u}${c}${d}`,t)}},6106(e,t,n){"use strict";let r=n(4517);e.exports=(e,t,n)=>{let i=new r(e,n),o=new r(t,n);return i.compare(o)||i.compareBuild(o)}},2132(e,t,n){"use strict";let r=n(7851);e.exports=(e,t)=>r(e,t,!0)},3269(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e,null,!0),i=r(t,null,!0),o=n.compare(i);if(0===o)return null;let a=o>0,l=a?n:i,s=a?i:n,u=!!l.prerelease.length;if(s.prerelease.length&&!u){if(!s.patch&&!s.minor)return"major";if(0===s.compareMain(l))return s.minor&&!s.patch?"minor":"patch"}let c=u?"pre":"";return n.major!==i.major?c+"major":n.minor!==i.minor?c+"minor":n.patch!==i.patch?c+"patch":"prerelease"}},8868(e,t,n){"use strict";let r=n(4517);e.exports=(e,t,n,i,o)=>{"string"==typeof n&&(o=i,i=n,n=void 0);try{return new r(e instanceof r?e.version:e,n).inc(t,i,o).version}catch(e){return null}}},6381(e,t,n){"use strict";let r=n(4517);e.exports=(e,t)=>new r(e,t).major},1353(e,t,n){"use strict";let r=n(4517);e.exports=(e,t)=>new r(e,t).minor},3955(e,t,n){"use strict";let r=n(4517);e.exports=(e,t,n=!1)=>{if(e instanceof r)return e;try{return new r(e,t)}catch(e){if(!n)return null;throw e}}},6082(e,t,n){"use strict";let r=n(4517);e.exports=(e,t)=>new r(e,t).patch},9428(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e,t);return n&&n.prerelease.length?n.prerelease:null}},7555(e,t,n){"use strict";let r=n(7851);e.exports=(e,t,n)=>r(t,e,n)},3810(e,t,n){"use strict";let r=n(6106);e.exports=(e,t)=>e.sort((e,n)=>r(n,e,t))},4042(e,t,n){"use strict";let r=n(6106);e.exports=(e,t)=>e.sort((e,n)=>r(e,n,t))},8474(e,t,n){"use strict";let r=n(3955);e.exports=(e,t)=>{let n=r(e,t);return n?n.version:null}},2722(e,t,n){"use strict";let r=n(2841),i=n(9543),o=n(4517),a=n(3806),l=n(3955),s=n(8474),u=n(2281),c=n(8868),d=n(3269),f=n(6381),p=n(1353),m=n(6082),h=n(9428),g=n(7851),y=n(7555),v=n(2132),b=n(6106),_=n(4042),w=n(3810),x=n(9761),E=n(1262),k=n(8848),S=n(8220),O=n(2386),D=n(9639),C=n(4004),F=n(6783),A=n(1565),P=n(7476),T=n(7229),V=n(6364),M=n(5039),j=n(5357),I=n(1280),N=n(7403),L=n(8854),q=n(7226),R=n(7183),$=n(8623);e.exports={parse:l,valid:s,clean:u,inc:c,diff:d,major:f,minor:p,patch:m,prerelease:h,compare:g,rcompare:y,compareLoose:v,compareBuild:b,sort:_,rsort:w,gt:x,lt:E,eq:k,neq:S,gte:O,lte:D,cmp:C,coerce:F,Comparator:A,Range:P,satisfies:T,toComparators:V,maxSatisfying:M,minSatisfying:j,minVersion:I,validRange:N,outside:L,gtr:q,ltr:R,intersects:$,simplifyRange:n(6486),subset:n(583),SemVer:o,re:r.re,src:r.src,tokens:r.t,SEMVER_SPEC_VERSION:i.SEMVER_SPEC_VERSION,RELEASE_TYPES:i.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}},7226(e,t,n){"use strict";let r=n(8854);e.exports=(e,t,n)=>r(e,t,">",n)},8623(e,t,n){"use strict";let r=n(7476);e.exports=(e,t,n)=>(e=new r(e,n),t=new r(t,n),e.intersects(t,n))},7183(e,t,n){"use strict";let r=n(8854);e.exports=(e,t,n)=>r(e,t,"<",n)},5039(e,t,n){"use strict";let r=n(4517),i=n(7476);e.exports=(e,t,n)=>{let o=null,a=null,l=null;try{l=new i(t,n)}catch(e){return null}return e.forEach(e=>{l.test(e)&&(!o||-1===a.compare(e))&&(a=new r(o=e,n))}),o}},5357(e,t,n){"use strict";let r=n(4517),i=n(7476);e.exports=(e,t,n)=>{let o=null,a=null,l=null;try{l=new i(t,n)}catch(e){return null}return e.forEach(e=>{l.test(e)&&(!o||1===a.compare(e))&&(a=new r(o=e,n))}),o}},1280(e,t,n){"use strict";let r=n(4517),i=n(7476),o=n(9761);e.exports=(e,t)=>{e=new i(e,t);let n=new r("0.0.0");if(e.test(n)||(n=new r("0.0.0-0"),e.test(n)))return n;n=null;for(let t=0;t<e.set.length;++t){let i=e.set[t],a=null;i.forEach(e=>{let t=new r(e.semver.version);switch(e.operator){case">":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":(!a||o(t,a))&&(a=t);break;case"<":case"<=":break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),a&&(!n||o(n,a))&&(n=a)}return n&&e.test(n)?n:null}},8854(e,t,n){"use strict";let r=n(4517),i=n(1565),{ANY:o}=i,a=n(7476),l=n(7229),s=n(9761),u=n(1262),c=n(9639),d=n(2386);e.exports=(e,t,n,f)=>{let p,m,h,g,y;switch(e=new r(e,f),t=new a(t,f),n){case">":p=s,m=c,h=u,g=">",y=">=";break;case"<":p=u,m=d,h=s,g="<",y="<=";break;default:throw TypeError('Must provide a hilo val of "<" or ">"')}if(l(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let r=t.set[n],a=null,l=null;if(r.forEach(e=>{e.semver===o&&(e=new i(">=0.0.0")),a=a||e,l=l||e,p(e.semver,a.semver,f)?a=e:h(e.semver,l.semver,f)&&(l=e)}),a.operator===g||a.operator===y||(!l.operator||l.operator===g)&&m(e,l.semver)||l.operator===y&&h(e,l.semver))return!1}return!0}},6486(e,t,n){"use strict";let r=n(7229),i=n(7851);e.exports=(e,t,n)=>{let o=[],a=null,l=null,s=e.sort((e,t)=>i(e,t,n));for(let e of s)r(e,t,n)?(l=e,a||(a=e)):(l&&o.push([a,l]),l=null,a=null);a&&o.push([a,null]);let u=[];for(let[e,t]of o)e===t?u.push(e):t||e!==s[0]?t?e===s[0]?u.push(`<=${t}`):u.push(`${e} - ${t}`):u.push(`>=${e}`):u.push("*");let c=u.join(" || "),d="string"==typeof t.raw?t.raw:String(t);return c.length<d.length?c:t}},583(e,t,n){"use strict";let r=n(7476),i=n(1565),{ANY:o}=i,a=n(7229),l=n(7851),s=[new i(">=0.0.0-0")],u=[new i(">=0.0.0")],c=(e,t,n)=>{let r,i,c,p,m,h,g;if(e===t)return!0;if(1===e.length&&e[0].semver===o)if(1===t.length&&t[0].semver===o)return!0;else e=n.includePrerelease?s:u;if(1===t.length&&t[0].semver===o)if(n.includePrerelease)return!0;else t=u;let y=new Set;for(let t of e)">"===t.operator||">="===t.operator?r=d(r,t,n):"<"===t.operator||"<="===t.operator?i=f(i,t,n):y.add(t.semver);if(y.size>1)return null;if(r&&i&&((c=l(r.semver,i.semver,n))>0||0===c&&(">="!==r.operator||"<="!==i.operator)))return null;for(let e of y){if(r&&!a(e,String(r),n)||i&&!a(e,String(i),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let v=!!i&&!n.includePrerelease&&!!i.semver.prerelease.length&&i.semver,b=!!r&&!n.includePrerelease&&!!r.semver.prerelease.length&&r.semver;for(let e of(v&&1===v.prerelease.length&&"<"===i.operator&&0===v.prerelease[0]&&(v=!1),t)){if(g=g||">"===e.operator||">="===e.operator,h=h||"<"===e.operator||"<="===e.operator,r){if(b&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===b.major&&e.semver.minor===b.minor&&e.semver.patch===b.patch&&(b=!1),">"===e.operator||">="===e.operator){if((p=d(r,e,n))===e&&p!==r)return!1}else if(">="===r.operator&&!a(r.semver,String(e),n))return!1}if(i){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),"<"===e.operator||"<="===e.operator){if((m=f(i,e,n))===e&&m!==i)return!1}else if("<="===i.operator&&!a(i.semver,String(e),n))return!1}if(!e.operator&&(i||r)&&0!==c)return!1}return(!r||!h||!!i||0===c)&&(!i||!g||!!r||0===c)&&!b&&!v&&!0},d=(e,t,n)=>{if(!e)return t;let r=l(e.semver,t.semver,n);return r>0?e:r<0||">"===t.operator&&">="===e.operator?t:e},f=(e,t,n)=>{if(!e)return t;let r=l(e.semver,t.semver,n);return r<0?e:r>0||"<"===t.operator&&"<="===e.operator?t:e};e.exports=(e,t,n={})=>{if(e===t)return!0;e=new r(e,n),t=new r(t,n);let i=!1;e:for(let r of e.set){for(let e of t.set){let t=c(r,e,n);if(i=i||null!==t,t)continue e}if(i)return!1}return!0}},6364(e,t,n){"use strict";let r=n(7476);e.exports=(e,t)=>new r(e,t).set.map(e=>e.map(e=>e.value).join(" ").trim().split(" "))},7403(e,t,n){"use strict";let r=n(7476);e.exports=(e,t)=>{try{return new r(e,t).range||"*"}catch(e){return null}}},8052(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var n=null;if(!e||"string"!=typeof e)return n;var r=(0,i.default)(e),o="function"==typeof t;return r.forEach(function(e){if("declaration"===e.type){var r=e.property,i=e.value;o?t(r,i,e):i&&((n=n||{})[r]=i)}}),n};var i=r(n(5937))}}]);