@medplum/app 4.5.1 → 4.5.2
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.
|
@@ -73,7 +73,7 @@ function F3(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&
|
|
|
73
73
|
Prefix can't start with '-' when allowNegative is true.
|
|
74
74
|
prefix: `+o+`
|
|
75
75
|
allowNegative: `+l+`
|
|
76
|
-
`),l=!1),Object.assign(Object.assign({},e),{allowNegative:l})}function D6(e){e=_6(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,n=e.allowNegative,r=e.allowLeadingZeros,o=e.onKeyDown;o===void 0&&(o=es);var l=e.onBlur;l===void 0&&(l=es);var c=e.thousandSeparator,d=e.decimalScale,f=e.fixedDecimalScale,p=e.prefix;p===void 0&&(p="");var m=e.defaultValue,g=e.value,x=e.valueIsNumericString,b=e.onValueChange,w=W_(e,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),j=tm(e),C=j.decimalSeparator,T=j.allowedDecimalSeparators,E=function(O){return jE(O,e)},R=function(O,I){return T6(O,I,e)},D=Cc(g)?m:g,P=x??E6(D,p,t);Cc(g)?Cc(m)||(P=P||typeof m=="number"):P=P||typeof g=="number";var A=function(O){return Y_(O)?O:(typeof O=="number"&&(O=Z_(O)),P&&typeof d=="number"?SE(O,d,!!f):O)},k=eD(A(g),A(m),!!P,E,R,b),M=k[0],$=M.numAsString,U=M.formattedValue,J=k[1],Z=function(O){var I=O.target,z=O.key,F=I.selectionStart,K=I.selectionEnd,L=I.value;if(L===void 0&&(L=""),(z==="Backspace"||z==="Delete")&&K<p.length){O.preventDefault();return}if(F!==K){o(O);return}z==="Backspace"&&L[0]==="-"&&F===p.length+1&&n&&Hs(I,1),d&&f&&(z==="Backspace"&&L[F-1]===C?(Hs(I,F-1),O.preventDefault()):z==="Delete"&&L[F]===C&&O.preventDefault()),T?.includes(z)&&L[F]===C&&Hs(I,F+1);var q=c===!0?",":c;z==="Backspace"&&L[F-1]===q&&Hs(I,F-1),z==="Delete"&&L[F]===q&&Hs(I,F+1),o(O)},Y=function(O){var I=$;if(I.match(/\d/g)||(I=""),r||(I=f6(I)),f&&d&&(I=SE(I,d,f)),I!==$){var z=jE(I,e);J({formattedValue:z,value:I,floatValue:parseFloat(I)},{event:O,source:dd.event})}l(O)},H=function(O){return O===C?!0:fd(O)},Q=function(O){var I=O.currentValue,z=O.lastValue,F=O.formattedValue,K=O.currentValueIndex,L=O.formattedValueIndex,q=I[K],ie=F[L],xe=J_(z,I),ve=xe.to,Ce=function(Oe){return R(Oe).indexOf(".")+p.length};return g===0&&f&&d&&I[ve.start]===C&&Ce(I)<K&&Ce(F)>L?!1:K>=ve.start&&K<ve.end&&T&&T.includes(q)&&ie===C?!0:q===ie};return Object.assign(Object.assign({},w),{value:U,valueIsNumericString:!1,isValidInputCharacter:H,isCharacterSame:Q,onValueChange:J,format:E,removeFormatting:R,getCaretBoundary:function(O){return R6(O,e)},onKeyDown:Z,onBlur:Y})}function A6(e){var t=D6(e);return Tn.createElement(w6,Object.assign({},t))}function CE({direction:e,style:t,...n}){return a.jsx("svg",{style:{width:"var(--ni-chevron-size)",height:"var(--ni-chevron-size)",transform:e==="up"?"rotate(180deg)":void 0,...t},viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:a.jsx("path",{d:"M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})}var nx={root:"m_e2f5cd4e",controls:"m_95e17d22",control:"m_80b4b171"};const P6=/^(0\.0*|-0(\.0*)?)$/,k6=/^-?0\d+(\.\d+)?\.?$/;function rx(e){return typeof e=="string"&&e!==""&&!Number.isNaN(Number(e))}function fy(e){return typeof e=="number"?e<Number.MAX_SAFE_INTEGER:e===""||rx(e)&&Number(e)<Number.MAX_SAFE_INTEGER}function N6(e){return e.toString().replace(".","").length}function O6(e,t){return(typeof e=="number"?e<Number.MAX_SAFE_INTEGER:!Number.isNaN(Number(e)))&&!Number.isNaN(e)&&N6(t)<14&&t!==""}function EE(e,t,n){if(e===void 0)return!0;const r=t===void 0||e>=t,o=n===void 0||e<=n;return r&&o}const M6={step:1,clampBehavior:"blur",allowDecimal:!0,allowNegative:!0,withKeyboardEvents:!0,allowLeadingZeros:!0,trimLeadingZeroesOnBlur:!0,startValue:0},L6=(e,{size:t})=>({controls:{"--ni-chevron-size":at(t,"ni-chevron-size")}});function I6(e,t,n){const r=e.toString().replace(/^0+/,""),o=parseFloat(r);return Number.isNaN(o)?r:o>Number.MAX_SAFE_INTEGER?t!==void 0?String(t):r:Nh(o,n,t)}const Oc=be((e,t)=>{const n=ae("NumberInput",M6,e),{className:r,classNames:o,styles:l,unstyled:c,vars:d,onChange:f,onValueChange:p,value:m,defaultValue:g,max:x,min:b,step:w,hideControls:j,rightSection:C,isAllowed:T,clampBehavior:E,onBlur:R,allowDecimal:D,decimalScale:P,onKeyDown:A,onKeyDownCapture:k,handlersRef:M,startValue:$,disabled:U,rightSectionPointerEvents:J,allowNegative:Z,readOnly:Y,size:H,rightSectionWidth:Q,stepHoldInterval:O,stepHoldDelay:I,allowLeadingZeros:z,withKeyboardEvents:F,trimLeadingZeroesOnBlur:K,...L}=n,q=$e({name:"NumberInput",classes:nx,props:n,classNames:o,styles:l,unstyled:c,vars:d,varsResolver:L6}),{resolvedClassNames:ie,resolvedStyles:xe}=fl({classNames:o,styles:l,props:n}),[ve,Ce]=Zn({value:m,defaultValue:g,finalValue:"",onChange:f}),Oe=I!==void 0&&O!==void 0,Ee=v.useRef(null),Ge=v.useRef(null),it=v.useRef(0),St=(me,ze)=>{ze.source==="event"&&Ce(O6(me.floatValue,me.value)&&!P6.test(me.value)&&!(z&&k6.test(me.value))?me.floatValue:me.value),p?.(me,ze)},kt=me=>{const ze=String(me).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return ze?Math.max(0,(ze[1]?ze[1].length:0)-(ze[2]?+ze[2]:0)):0},Mt=me=>{Ee.current&&typeof me<"u"&&Ee.current.setSelectionRange(me,me)},ct=v.useRef(Gh);ct.current=()=>{if(!fy(ve))return;let me;const ze=kt(ve),Nt=kt(w),Wt=Math.max(ze,Nt),jn=10**Wt;if(!rx(ve)&&(typeof ve!="number"||Number.isNaN(ve)))me=Nh($,b,x);else if(x!==void 0){const Cn=(Math.round(Number(ve)*jn)+Math.round(w*jn))/jn;me=Cn<=x?Cn:x}else me=(Math.round(Number(ve)*jn)+Math.round(w*jn))/jn;const Qn=me.toFixed(Wt);Ce(parseFloat(Qn)),p?.({floatValue:parseFloat(Qn),formattedValue:Qn,value:Qn},{source:"increment"}),setTimeout(()=>Mt(Ee.current?.value.length),0)};const bt=v.useRef(Gh);bt.current=()=>{if(!fy(ve))return;let me;const ze=b!==void 0?b:Z?Number.MIN_SAFE_INTEGER:0,Nt=kt(ve),Wt=kt(w),jn=Math.max(Nt,Wt),Qn=10**jn;if(!rx(ve)&&typeof ve!="number"||Number.isNaN(ve))me=Nh($,ze,x);else{const Ar=(Math.round(Number(ve)*Qn)-Math.round(w*Qn))/Qn;me=ze!==void 0&&Ar<ze?ze:Ar}const Cn=me.toFixed(jn);Ce(parseFloat(Cn)),p?.({floatValue:parseFloat(Cn),formattedValue:Cn,value:Cn},{source:"decrement"}),setTimeout(()=>Mt(Ee.current?.value.length),0)};const Qt=me=>{A?.(me),!(Y||!F)&&(me.key==="ArrowUp"&&(me.preventDefault(),ct.current()),me.key==="ArrowDown"&&(me.preventDefault(),bt.current()))},Ae=me=>{if(k?.(me),me.key==="Backspace"){const ze=Ee.current;ze.selectionStart===0&&ze.selectionStart===ze.selectionEnd&&(me.preventDefault(),window.setTimeout(()=>Mt(0),0))}},De=me=>{let ze=ve;E==="blur"&&typeof ze=="number"&&(ze=Nh(ze,b,x)),K&&typeof ze=="string"&&kt(ze)<15&&(ze=I6(ze,x,b)),ve!==ze&&Ce(ze),R?.(me)};sd(M,{increment:ct.current,decrement:bt.current});const Ze=me=>{me?ct.current():bt.current(),it.current+=1},_e=me=>{if(Ze(me),Oe){const ze=typeof O=="number"?O:O(it.current);Ge.current=window.setTimeout(()=>_e(me),ze)}},ge=(me,ze)=>{me.preventDefault(),Ee.current?.focus(),Ze(ze),Oe&&(Ge.current=window.setTimeout(()=>_e(ze),I))},Se=()=>{Ge.current&&window.clearTimeout(Ge.current),Ge.current=null,it.current=0},He=a.jsxs("div",{...q("controls"),children:[a.jsx(sr,{...q("control"),tabIndex:-1,"aria-hidden":!0,disabled:U||typeof ve=="number"&&x!==void 0&&ve>=x,mod:{direction:"up"},onMouseDown:me=>me.preventDefault(),onPointerDown:me=>{ge(me,!0)},onPointerUp:Se,onPointerLeave:Se,children:a.jsx(CE,{direction:"up"})}),a.jsx(sr,{...q("control"),tabIndex:-1,"aria-hidden":!0,disabled:U||typeof ve=="number"&&b!==void 0&&ve<=b,mod:{direction:"down"},onMouseDown:me=>me.preventDefault(),onPointerDown:me=>{ge(me,!1)},onPointerUp:Se,onPointerLeave:Se,children:a.jsx(CE,{direction:"down"})})]});return a.jsx(Dr,{component:A6,allowNegative:Z,className:Ot(nx.root,r),size:H,...L,readOnly:Y,disabled:U,value:ve,getInputRef:qn(t,Ee),onValueChange:St,rightSection:j||Y||!fy(ve)?C:C||He,classNames:ie,styles:xe,unstyled:c,__staticSelector:"NumberInput",decimalScale:D?P:0,onKeyDown:Qt,onKeyDownCapture:Ae,rightSectionPointerEvents:J??(U?"none":void 0),rightSectionWidth:Q??`var(--ni-right-section-width-${H||"sm"})`,allowLeadingZeros:z,onBlur:De,isAllowed:me=>E==="strict"?T?T(me)&&EE(me.floatValue,b,x):EE(me.floatValue,b,x):T?T(me):!0})});Oc.classes={...Dr.classes,...nx};Oc.displayName="@mantine/core/NumberInput";const[z6,nm]=Rr("Pagination.Root component was not found in tree");var Od={root:"m_4addd315",control:"m_326d024a",dots:"m_4ad7767d"};const $6={withPadding:!0},Md=be((e,t)=>{const n=ae("PaginationControl",$6,e),{classNames:r,className:o,style:l,styles:c,vars:d,active:f,disabled:p,withPadding:m,mod:g,...x}=n,b=nm(),w=p||b.disabled;return a.jsx(sr,{ref:t,disabled:w,mod:[{active:f,disabled:w,"with-padding":m},g],...b.getStyles("control",{className:o,style:l,classNames:r,styles:c,active:!w}),...x})});Md.classes=Od;Md.displayName="@mantine/core/PaginationControl";function Ld({style:e,children:t,path:n,...r}){return a.jsx("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",style:{width:"calc(var(--pagination-control-size) / 1.8)",height:"calc(var(--pagination-control-size) / 1.8)",...e},...r,children:a.jsx("path",{d:n,fill:"currentColor"})})}const U6=e=>a.jsx(Ld,{...e,path:"M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z"}),B6=e=>a.jsx(Ld,{...e,path:"M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z"}),V6=e=>a.jsx(Ld,{...e,path:"M6.85355 3.85355C7.04882 3.65829 7.04882 3.34171 6.85355 3.14645C6.65829 2.95118 6.34171 2.95118 6.14645 3.14645L2.14645 7.14645C1.95118 7.34171 1.95118 7.65829 2.14645 7.85355L6.14645 11.8536C6.34171 12.0488 6.65829 12.0488 6.85355 11.8536C7.04882 11.6583 7.04882 11.3417 6.85355 11.1464L3.20711 7.5L6.85355 3.85355ZM12.8536 3.85355C13.0488 3.65829 13.0488 3.34171 12.8536 3.14645C12.6583 2.95118 12.3417 2.95118 12.1464 3.14645L8.14645 7.14645C7.95118 7.34171 7.95118 7.65829 8.14645 7.85355L12.1464 11.8536C12.3417 12.0488 12.6583 12.0488 12.8536 11.8536C13.0488 11.6583 13.0488 11.3417 12.8536 11.1464L9.20711 7.5L12.8536 3.85355Z"}),F6=e=>a.jsx(Ld,{...e,path:"M2.14645 11.1464C1.95118 11.3417 1.95118 11.6583 2.14645 11.8536C2.34171 12.0488 2.65829 12.0488 2.85355 11.8536L6.85355 7.85355C7.04882 7.65829 7.04882 7.34171 6.85355 7.14645L2.85355 3.14645C2.65829 2.95118 2.34171 2.95118 2.14645 3.14645C1.95118 3.34171 1.95118 3.65829 2.14645 3.85355L5.79289 7.5L2.14645 11.1464ZM8.14645 11.1464C7.95118 11.3417 7.95118 11.6583 8.14645 11.8536C8.34171 12.0488 8.65829 12.0488 8.85355 11.8536L12.8536 7.85355C13.0488 7.65829 13.0488 7.34171 12.8536 7.14645L8.85355 3.14645C8.65829 2.95118 8.34171 2.95118 8.14645 3.14645C7.95118 3.34171 7.95118 3.65829 8.14645 3.85355L11.7929 7.5L8.14645 11.1464Z"}),H6=e=>a.jsx(Ld,{...e,path:"M2 8c0-.733.6-1.333 1.333-1.333.734 0 1.334.6 1.334 1.333s-.6 1.333-1.334 1.333C2.6 9.333 2 8.733 2 8zm9.333 0c0-.733.6-1.333 1.334-1.333C13.4 6.667 14 7.267 14 8s-.6 1.333-1.333 1.333c-.734 0-1.334-.6-1.334-1.333zM6.667 8c0-.733.6-1.333 1.333-1.333s1.333.6 1.333 1.333S8.733 9.333 8 9.333 6.667 8.733 6.667 8z"}),q6={icon:H6},rm=be((e,t)=>{const n=ae("PaginationDots",q6,e),{classNames:r,className:o,style:l,styles:c,vars:d,icon:f,...p}=n,m=nm(),g=f;return a.jsx(ce,{ref:t,...m.getStyles("dots",{className:o,style:l,styles:c,classNames:r}),...p,children:a.jsx(g,{style:{width:"calc(var(--pagination-control-size) / 1.8)",height:"calc(var(--pagination-control-size) / 1.8)"}})})});rm.classes=Od;rm.displayName="@mantine/core/PaginationDots";function im({icon:e,name:t,action:n,type:r}){const o={icon:e},l=v.forwardRef((c,d)=>{const{icon:f,...p}=ae(t,o,c),m=f,g=nm(),x=r==="next"?g.active===g.total:g.active===1;return a.jsx(Md,{disabled:g.disabled||x,ref:d,onClick:g[n],withPadding:!1,...p,children:a.jsx(m,{className:"mantine-rotate-rtl",style:{width:"calc(var(--pagination-control-size) / 1.8)",height:"calc(var(--pagination-control-size) / 1.8)"}})})});return l.displayName=`@mantine/core/${t}`,l}const tD=im({icon:U6,name:"PaginationNext",action:"onNext",type:"next"}),nD=im({icon:B6,name:"PaginationPrevious",action:"onPrevious",type:"previous"}),rD=im({icon:V6,name:"PaginationFirst",action:"onFirst",type:"previous"}),iD=im({icon:F6,name:"PaginationLast",action:"onLast",type:"next"});function J0({dotsIcon:e}){const t=nm(),n=t.range.map((r,o)=>r==="dots"?a.jsx(rm,{icon:e},o):a.jsx(Md,{active:r===t.active,"aria-current":r===t.active?"page":void 0,onClick:()=>t.onChange(r),disabled:t.disabled,...t.getItemProps?.(r),children:t.getItemProps?.(r)?.children??r},o));return a.jsx(a.Fragment,{children:n})}J0.displayName="@mantine/core/PaginationItems";const G6={siblings:1,boundaries:1},Q6=(e,{size:t,radius:n,color:r,autoContrast:o})=>({root:{"--pagination-control-radius":n===void 0?void 0:$t(n),"--pagination-control-size":at(t,"pagination-control-size"),"--pagination-control-fz":In(t),"--pagination-active-bg":r?Ft(r,e):void 0,"--pagination-active-color":hl(o,e)?ma({color:r,theme:e,autoContrast:o}):void 0}}),om=be((e,t)=>{const n=ae("PaginationRoot",G6,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,total:p,value:m,defaultValue:g,onChange:x,disabled:b,siblings:w,boundaries:j,color:C,radius:T,onNextPage:E,onPreviousPage:R,onFirstPage:D,onLastPage:P,getItemProps:A,autoContrast:k,...M}=n,$=$e({name:"Pagination",classes:Od,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:Q6}),{range:U,setPage:J,next:Z,previous:Y,active:H,first:Q,last:O}=t4({page:m,initialPage:g,onChange:x,total:p,siblings:w,boundaries:j}),I=Ur(E,Z),z=Ur(R,Y),F=Ur(D,Q),K=Ur(P,O);return a.jsx(z6,{value:{total:p,range:U,active:H,disabled:b,getItemProps:A,onChange:J,onNext:I,onPrevious:z,onFirst:F,onLast:K,getStyles:$},children:a.jsx(ce,{ref:t,...$("root"),...M})})});om.classes=Od;om.displayName="@mantine/core/PaginationRoot";const W6={withControls:!0,withPages:!0,siblings:1,boundaries:1,gap:8},Oi=be((e,t)=>{const n=ae("Pagination",W6,e),{withEdges:r,withControls:o,getControlProps:l,nextIcon:c,previousIcon:d,lastIcon:f,firstIcon:p,dotsIcon:m,total:g,gap:x,hideWithOnePage:b,withPages:w,...j}=n;return g<=0||b&&g===1?null:a.jsx(om,{ref:t,total:g,...j,children:a.jsxs(ye,{gap:x,children:[r&&a.jsx(rD,{icon:p,...l?.("first")}),o&&a.jsx(nD,{icon:d,...l?.("previous")}),w&&a.jsx(J0,{dotsIcon:m}),o&&a.jsx(tD,{icon:c,...l?.("next")}),r&&a.jsx(iD,{icon:f,...l?.("last")})]})})});Oi.classes=Od;Oi.displayName="@mantine/core/Pagination";Oi.Root=om;Oi.Control=Md;Oi.Dots=rm;Oi.First=rD;Oi.Last=iD;Oi.Next=tD;Oi.Previous=nD;Oi.Items=J0;const Y6=({reveal:e})=>a.jsx("svg",{viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"var(--psi-icon-size)",height:"var(--psi-icon-size)"},children:a.jsx("path",{d:e?"M13.3536 2.35355C13.5488 2.15829 13.5488 1.84171 13.3536 1.64645C13.1583 1.45118 12.8417 1.45118 12.6464 1.64645L10.6828 3.61012C9.70652 3.21671 8.63759 3 7.5 3C4.30786 3 1.65639 4.70638 0.0760002 7.23501C-0.0253338 7.39715 -0.0253334 7.60288 0.0760014 7.76501C0.902945 9.08812 2.02314 10.1861 3.36061 10.9323L1.64645 12.6464C1.45118 12.8417 1.45118 13.1583 1.64645 13.3536C1.84171 13.5488 2.15829 13.5488 2.35355 13.3536L4.31723 11.3899C5.29348 11.7833 6.36241 12 7.5 12C10.6921 12 13.3436 10.2936 14.924 7.76501C15.0253 7.60288 15.0253 7.39715 14.924 7.23501C14.0971 5.9119 12.9769 4.81391 11.6394 4.06771L13.3536 2.35355ZM9.90428 4.38861C9.15332 4.1361 8.34759 4 7.5 4C4.80285 4 2.52952 5.37816 1.09622 7.50001C1.87284 8.6497 2.89609 9.58106 4.09974 10.1931L9.90428 4.38861ZM5.09572 10.6114L10.9003 4.80685C12.1039 5.41894 13.1272 6.35031 13.9038 7.50001C12.4705 9.62183 10.1971 11 7.5 11C6.65241 11 5.84668 10.8639 5.09572 10.6114Z":"M7.5 11C4.80285 11 2.52952 9.62184 1.09622 7.50001C2.52952 5.37816 4.80285 4 7.5 4C10.1971 4 12.4705 5.37816 13.9038 7.50001C12.4705 9.62183 10.1971 11 7.5 11ZM7.5 3C4.30786 3 1.65639 4.70638 0.0760002 7.23501C-0.0253338 7.39715 -0.0253334 7.60288 0.0760014 7.76501C1.65639 10.2936 4.30786 12 7.5 12C10.6921 12 13.3436 10.2936 14.924 7.76501C15.0253 7.60288 15.0253 7.39715 14.924 7.23501C13.3436 4.70638 10.6921 3 7.5 3ZM7.5 9.5C8.60457 9.5 9.5 8.60457 9.5 7.5C9.5 6.39543 8.60457 5.5 7.5 5.5C6.39543 5.5 5.5 6.39543 5.5 7.5C5.5 8.60457 6.39543 9.5 7.5 9.5Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})});var ix={root:"m_f61ca620",input:"m_ccf8da4c",innerInput:"m_f2d85dd2",visibilityToggle:"m_b1072d44"};const K6={visibilityToggleIcon:Y6},X6=(e,{size:t})=>({root:{"--psi-icon-size":at(t,"psi-icon-size"),"--psi-button-size":at(t,"psi-button-size")}}),Qi=be((e,t)=>{const n=ae("PasswordInput",K6,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,required:p,error:m,leftSection:g,disabled:x,id:b,variant:w,inputContainer:j,description:C,label:T,size:E,errorProps:R,descriptionProps:D,labelProps:P,withAsterisk:A,inputWrapperOrder:k,wrapperProps:M,radius:$,rightSection:U,rightSectionWidth:J,rightSectionPointerEvents:Z,leftSectionWidth:Y,visible:H,defaultVisible:Q,onVisibilityChange:O,visibilityToggleIcon:I,visibilityToggleButtonProps:z,rightSectionProps:F,leftSectionProps:K,leftSectionPointerEvents:L,withErrorStyles:q,mod:ie,...xe}=n,ve=_r(b),[Ce,Oe]=Zn({value:H,defaultValue:Q,finalValue:!1,onChange:O}),Ee=()=>Oe(!Ce),Ge=$e({name:"PasswordInput",classes:ix,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:X6}),{resolvedClassNames:it,resolvedStyles:St}=fl({classNames:r,styles:c,props:n}),{styleProps:kt,rest:Mt}=ga(xe),ct=I,bt=R?.id||`${ve}-error`,Qt=D?.id||`${ve}-description`,Ze=`${!!m&&typeof m!="boolean"?bt:""} ${!!C?Qt:""}`,_e=Ze.trim().length>0?Ze.trim():void 0,ge=a.jsx(bn,{...Ge("visibilityToggle"),disabled:x,radius:$,"aria-hidden":!z,tabIndex:-1,...z,variant:z?.variant??"subtle",color:"gray",unstyled:d,onTouchEnd:Se=>{Se.preventDefault(),z?.onTouchEnd?.(Se),Ee()},onMouseDown:Se=>{Se.preventDefault(),z?.onMouseDown?.(Se),Ee()},onKeyDown:Se=>{z?.onKeyDown?.(Se),Se.key===" "&&(Se.preventDefault(),Ee())},children:a.jsx(ct,{reveal:Ce})});return a.jsx(un.Wrapper,{required:p,id:ve,label:T,error:m,description:C,size:E,classNames:it,styles:St,__staticSelector:"PasswordInput",unstyled:d,withAsterisk:A,inputWrapperOrder:k,inputContainer:j,variant:w,labelProps:{...P,htmlFor:ve},descriptionProps:{...D,id:Qt},errorProps:{...R,id:bt},mod:ie,...Ge("root"),...kt,...M,children:a.jsx(un,{component:"div",error:m,leftSection:g,size:E,classNames:{...it,input:Ot(ix.input,it.input)},styles:St,radius:$,disabled:x,__staticSelector:"PasswordInput",rightSectionWidth:J,rightSection:U??ge,variant:w,unstyled:d,leftSectionWidth:Y,rightSectionPointerEvents:Z||"all",rightSectionProps:F,leftSectionProps:K,leftSectionPointerEvents:L,withAria:!1,withErrorStyles:q,children:a.jsx("input",{required:p,"data-invalid":!!m||void 0,"data-with-left-section":!!g||void 0,...Ge("innerInput"),disabled:x,id:ve,ref:t,...Mt,"aria-describedby":_e,autoComplete:Mt.autoComplete||"off",type:Ce?"text":"password"})})})});Qi.classes={...Dr.classes,...ix};Qi.displayName="@mantine/core/PasswordInput";const[Z6,oD]=ha(),[J6,ez]=ha();var aD={card:"m_9dc8ae12"};const tz={withBorder:!0},nz=(e,{radius:t})=>({card:{"--card-radius":$t(t)}}),eb=be((e,t)=>{const n=ae("RadioCard",tz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,checked:p,mod:m,withBorder:g,value:x,onClick:b,name:w,onKeyDown:j,...C}=n,T=$e({name:"RadioCard",classes:aD,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:nz,rootSelector:"card"}),{dir:E}=ml(),R=oD(),D=typeof p=="boolean"?p:R?.value===x||!1,P=w||R?.name,A=k=>{if(j?.(k),["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"].includes(k.nativeEvent.code)){k.preventDefault();const M=Array.from(document.querySelectorAll(`[role="radio"][name="${P||"__mantine"}"]`)),$=M.findIndex(Z=>Z===k.target),U=$+1>=M.length?0:$+1,J=$-1<0?M.length-1:$-1;k.nativeEvent.code==="ArrowDown"&&(M[U].focus(),M[U].click()),k.nativeEvent.code==="ArrowUp"&&(M[J].focus(),M[J].click()),k.nativeEvent.code==="ArrowLeft"&&(M[E==="ltr"?J:U].focus(),M[E==="ltr"?J:U].click()),k.nativeEvent.code==="ArrowRight"&&(M[E==="ltr"?U:J].focus(),M[E==="ltr"?U:J].click())}};return a.jsx(J6,{value:{checked:D},children:a.jsx(sr,{ref:t,mod:[{"with-border":g,checked:D},m],...T("card"),...C,role:"radio","aria-checked":D,name:P,onClick:k=>{b?.(k),R?.onChange(x||"")},onKeyDown:A})})});eb.displayName="@mantine/core/RadioCard";eb.classes=aD;const rz={},tb=be((e,t)=>{const{value:n,defaultValue:r,onChange:o,size:l,wrapperProps:c,children:d,name:f,readOnly:p,...m}=ae("RadioGroup",rz,e),g=_r(f),[x,b]=Zn({value:n,defaultValue:r,finalValue:"",onChange:o}),w=j=>!p&&b(typeof j=="string"?j:j.currentTarget.value);return a.jsx(Z6,{value:{value:x,onChange:w,size:l,name:g},children:a.jsx(un.Wrapper,{size:l,ref:t,...c,...m,labelElement:"div",__staticSelector:"RadioGroup",children:a.jsx(D0,{role:"radiogroup",children:d})})})});tb.classes=un.Wrapper.classes;tb.displayName="@mantine/core/RadioGroup";function sD({size:e,style:t,...n}){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 5 5",style:{width:le(e),height:le(e),...t},"aria-hidden":!0,...n,children:a.jsx("circle",{cx:"2.5",cy:"2.5",r:"2.5",fill:"currentColor"})})}var lD={indicator:"m_717d7ff6",icon:"m_3e4da632","indicator--outline":"m_2980836c"};const iz={icon:sD},oz=(e,{radius:t,color:n,size:r,iconColor:o,variant:l,autoContrast:c})=>{const d=Ri({color:n||e.primaryColor,theme:e}),f=d.isThemeColor&&d.shade===void 0?`var(--mantine-color-${d.color}-outline)`:d.color;return{indicator:{"--radio-size":at(r,"radio-size"),"--radio-radius":t===void 0?void 0:$t(t),"--radio-color":l==="outline"?f:Ft(n,e),"--radio-icon-size":at(r,"radio-icon-size"),"--radio-icon-color":o?Ft(o,e):hl(c,e)?ma({color:n,theme:e,autoContrast:c}):void 0}}},nb=be((e,t)=>{const n=ae("RadioIndicator",iz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,icon:p,radius:m,color:g,iconColor:x,autoContrast:b,checked:w,mod:j,variant:C,disabled:T,...E}=n,R=p,D=$e({name:"RadioIndicator",classes:lD,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:oz,rootSelector:"indicator"}),P=ez(),A=typeof w=="boolean"?w:P?.checked||!1;return a.jsx(ce,{ref:t,...D("indicator",{variant:C}),variant:C,mod:[{checked:A,disabled:T},j],...E,children:a.jsx(R,{...D("icon")})})});nb.displayName="@mantine/core/RadioIndicator";nb.classes=lD;var cD={root:"m_f3f1af94",inner:"m_89c4f5e4",icon:"m_f3ed6b2b",radio:"m_8a3dbb89","radio--outline":"m_1bfe9d39"};const az={labelPosition:"right"},sz=(e,{size:t,radius:n,color:r,iconColor:o,variant:l,autoContrast:c})=>{const d=Ri({color:r||e.primaryColor,theme:e}),f=d.isThemeColor&&d.shade===void 0?`var(--mantine-color-${d.color}-outline)`:d.color;return{root:{"--radio-size":at(t,"radio-size"),"--radio-radius":n===void 0?void 0:$t(n),"--radio-color":l==="outline"?f:Ft(r,e),"--radio-icon-color":o?Ft(o,e):hl(c,e)?ma({color:r,theme:e,autoContrast:c}):void 0,"--radio-icon-size":at(t,"radio-icon-size")}}},ur=be((e,t)=>{const n=ae("Radio",az,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,id:p,size:m,label:g,labelPosition:x,description:b,error:w,radius:j,color:C,variant:T,disabled:E,wrapperProps:R,icon:D=sD,rootRef:P,iconColor:A,onChange:k,mod:M,...$}=n,U=$e({name:"Radio",classes:cD,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:sz}),J=oD(),Z=J?.size??m,Y=n.size?m:Z,{styleProps:H,rest:Q}=ga($),O=_r(p),I=J?{checked:J.value===Q.value,name:Q.name??J.name,onChange:z=>{J.onChange(z),k?.(z)}}:{};return a.jsx(Vp,{...U("root"),__staticSelector:"Radio",__stylesApiProps:n,id:O,size:Y,labelPosition:x,label:g,description:b,error:w,disabled:E,classNames:r,styles:c,unstyled:d,"data-checked":I.checked||void 0,variant:T,ref:P,mod:M,...H,...R,children:a.jsxs(ce,{...U("inner"),mod:{"label-position":x},children:[a.jsx(ce,{...U("radio",{focusable:!0,variant:T}),onChange:k,...Q,...I,component:"input",mod:{error:!!w},ref:t,id:O,disabled:E,type:"radio"}),a.jsx(D,{...U("icon"),"aria-hidden":!0})]})})});ur.classes=cD;ur.displayName="@mantine/core/Radio";ur.Group=tb;ur.Card=eb;ur.Indicator=nb;const lz={duration:100,transition:"fade"};function cz(e,t){return{...lz,...t,...e}}function uz({offset:e,position:t,defaultOpened:n}){const[r,o]=v.useState(n),l=v.useRef(null),{x:c,y:d,elements:f,refs:p,update:m,placement:g}=r0({placement:t,middleware:[Jx({crossAxis:!0,padding:5,rootBoundary:"document"})]}),x=g.includes("right")?e:t.includes("left")?e*-1:0,b=g.includes("bottom")?e:t.includes("top")?e*-1:0,w=v.useCallback(({clientX:j,clientY:C})=>{p.setPositionReference({getBoundingClientRect(){return{width:0,height:0,x:j,y:C,left:j+x,top:C+b,right:j,bottom:C}}})},[f.reference]);return v.useEffect(()=>{if(p.floating.current){const j=l.current;j.addEventListener("mousemove",w);const C=ia(p.floating.current);return C.forEach(T=>{T.addEventListener("scroll",m)}),()=>{j.removeEventListener("mousemove",w),C.forEach(T=>{T.removeEventListener("scroll",m)})}}},[f.reference,p.floating.current,m,w,r]),{handleMouseMove:w,x:c,y:d,opened:r,setOpened:o,boundaryRef:l,floating:p.setFloating}}var am={tooltip:"m_1b3c8819",arrow:"m_f898399f"};const dz={refProp:"ref",withinPortal:!0,offset:10,defaultOpened:!1,position:"right",zIndex:oi("popover")},fz=(e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:$t(t),"--tooltip-bg":n?Ft(n,e):void 0,"--tooltip-color":n?"var(--mantine-color-white)":void 0}}),rb=be((e,t)=>{const n=ae("TooltipFloating",dz,e),{children:r,refProp:o,withinPortal:l,style:c,className:d,classNames:f,styles:p,unstyled:m,radius:g,color:x,label:b,offset:w,position:j,multiline:C,zIndex:T,disabled:E,defaultOpened:R,variant:D,vars:P,portalProps:A,...k}=n,M=Sn(),$=$e({name:"TooltipFloating",props:n,classes:am,className:d,style:c,classNames:f,styles:p,unstyled:m,rootSelector:"tooltip",vars:P,varsResolver:fz}),{handleMouseMove:U,x:J,y:Z,opened:Y,boundaryRef:H,floating:Q,setOpened:O}=uz({offset:w,position:j,defaultOpened:R});if(!fa(r))throw new Error("[@mantine/core] Tooltip.Floating component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported");const I=qn(H,Rp(r),t),z=r.props,F=L=>{z.onMouseEnter?.(L),U(L),O(!0)},K=L=>{z.onMouseLeave?.(L),O(!1)};return a.jsxs(a.Fragment,{children:[a.jsx(fs,{...A,withinPortal:l,children:a.jsx(ce,{...k,...$("tooltip",{style:{...t2(c,M),zIndex:T,display:!E&&Y?"block":"none",top:(Z&&Math.round(Z))??"",left:(J&&Math.round(J))??""}}),variant:D,ref:Q,mod:{multiline:C},children:b})}),v.cloneElement(r,{...z,[o]:I,onMouseEnter:F,onMouseLeave:K})]})});rb.classes=am;rb.displayName="@mantine/core/TooltipFloating";const uD=v.createContext(!1),hz=uD.Provider,pz=()=>v.useContext(uD),mz={openDelay:0,closeDelay:0};function ib(e){const{openDelay:t,closeDelay:n,children:r}=ae("TooltipGroup",mz,e);return a.jsx(hz,{value:!0,children:a.jsx(H9,{delay:{open:t,close:n},children:r})})}ib.displayName="@mantine/core/TooltipGroup";ib.extend=e=>e;function gz(e){if(e===void 0)return{shift:!0,flip:!0};const t={...e};return e.shift===void 0&&(t.shift=!0),e.flip===void 0&&(t.flip=!0),t}function vz(e){const t=gz(e.middlewares),n=[b2(e.offset)];return t.shift&&n.push(Jx(typeof t.shift=="boolean"?{padding:8}:{padding:8,...t.shift})),t.flip&&n.push(typeof t.flip=="boolean"?Zh():Zh(t.flip)),n.push(S2({element:e.arrowRef,padding:e.arrowOffset})),t.inline?n.push(typeof t.inline=="boolean"?rd():rd(t.inline)):e.inline&&n.push(rd()),n}function yz(e){const[t,n]=v.useState(e.defaultOpened),o=typeof e.opened=="boolean"?e.opened:t,l=pz(),c=_r(),d=v.useCallback(A=>{n(A),A&&E(c)},[c]),{x:f,y:p,context:m,refs:g,update:x,placement:b,middlewareData:{arrow:{x:w,y:j}={}}}=r0({strategy:e.strategy,placement:e.position,open:o,onOpenChange:d,middleware:vz(e)}),{delay:C,currentId:T,setCurrentId:E}=q9(m,{id:c}),{getReferenceProps:R,getFloatingProps:D}=Z9([V9(m,{enabled:e.events?.hover,delay:l?C:{open:e.openDelay,close:e.closeDelay},mouseOnly:!e.events?.touch}),X9(m,{enabled:e.events?.focus,visibleOnly:!0}),e5(m,{role:"tooltip"}),Y9(m,{enabled:typeof e.opened>"u"})]);Q2({opened:o,position:e.position,positionDependencies:e.positionDependencies,floating:{refs:g,update:x}}),oa(()=>{e.onPositionChange?.(b)},[b]);const P=o&&T&&T!==c;return{x:f,y:p,arrowX:w,arrowY:j,reference:g.setReference,floating:g.setFloating,getFloatingProps:D,getReferenceProps:R,isGroupPhase:P,opened:o,placement:b}}const TE={position:"top",refProp:"ref",withinPortal:!0,inline:!1,defaultOpened:!1,arrowSize:4,arrowOffset:5,arrowRadius:0,arrowPosition:"side",offset:5,transitionProps:{duration:100,transition:"fade"},events:{hover:!0,focus:!1,touch:!1},zIndex:oi("popover"),positionDependencies:[],middlewares:{flip:!0,shift:!0,inline:!1}},xz=(e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:$t(t),"--tooltip-bg":n?Ft(n,e):void 0,"--tooltip-color":n?"var(--mantine-color-white)":void 0}}),ca=be((e,t)=>{const n=ae("Tooltip",TE,e),{children:r,position:o,refProp:l,label:c,openDelay:d,closeDelay:f,onPositionChange:p,opened:m,defaultOpened:g,withinPortal:x,radius:b,color:w,classNames:j,styles:C,unstyled:T,style:E,className:R,withArrow:D,arrowSize:P,arrowOffset:A,arrowRadius:k,arrowPosition:M,offset:$,transitionProps:U,multiline:J,events:Z,zIndex:Y,disabled:H,positionDependencies:Q,onClick:O,onMouseEnter:I,onMouseLeave:z,inline:F,variant:K,keepMounted:L,vars:q,portalProps:ie,mod:xe,floatingStrategy:ve,middlewares:Ce,...Oe}=ae("Tooltip",TE,n),{dir:Ee}=ml(),Ge=v.useRef(null),it=yz({position:U2(Ee,o),closeDelay:f,openDelay:d,onPositionChange:p,opened:m,defaultOpened:g,events:Z,arrowRef:Ge,arrowOffset:A,offset:typeof $=="number"?$+(D?P/2:0):$,positionDependencies:[...Q,r],inline:F,strategy:ve,middlewares:Ce}),St=$e({name:"Tooltip",props:n,classes:am,className:R,style:E,classNames:j,styles:C,unstyled:T,rootSelector:"tooltip",vars:q,varsResolver:xz});if(!fa(r))throw new Error("[@mantine/core] Tooltip component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported");const kt=qn(it.reference,Rp(r),t),Mt=cz(U,{duration:100,transition:"fade"}),ct=r.props;return a.jsxs(a.Fragment,{children:[a.jsx(fs,{...ie,withinPortal:x,children:a.jsx(_o,{...Mt,keepMounted:L,mounted:!H&&!!it.opened,duration:it.isGroupPhase?10:Mt.duration,children:bt=>a.jsxs(ce,{...Oe,"data-fixed":ve==="fixed"||void 0,variant:K,mod:[{multiline:J},xe],...it.getFloatingProps({ref:it.floating,className:St("tooltip").className,style:{...St("tooltip").style,...bt,zIndex:Y,top:it.y??0,left:it.x??0}}),children:[c,a.jsx(s0,{ref:Ge,arrowX:it.arrowX,arrowY:it.arrowY,visible:D,position:it.placement,arrowSize:P,arrowOffset:A,arrowRadius:k,arrowPosition:M,...St("arrow")})]})})}),v.cloneElement(r,it.getReferenceProps({onClick:O,onMouseEnter:I,onMouseLeave:z,onMouseMove:n.onMouseMove,onPointerDown:n.onPointerDown,onPointerEnter:n.onPointerEnter,className:Ot(R,ct.className),...ct,[l]:kt}))]})});ca.classes=am;ca.displayName="@mantine/core/Tooltip";ca.Floating=rb;ca.Group=ib;function bz({size:e,thickness:t,sum:n,value:r,root:o,offset:l}){const c=(e*.9-t*2)/2,d=Math.PI*c*2/100,f=o||r===void 0?`${(100-n)*d}, ${n*d}`:`${r*d}, ${(100-r)*d}`;return{strokeWidth:Number.isNaN(t)?12:t,cx:e/2||0,cy:e/2||0,r:c||0,transform:o?`scale(1, -1) translate(0, -${e})`:void 0,strokeDasharray:f,strokeDashoffset:o?0:l||0}}function dD({size:e,value:t,offset:n,sum:r,thickness:o,root:l,color:c,lineRoundCaps:d,tooltip:f,getStyles:p,display:m,...g}){const x=Sn();return a.jsx(ca.Floating,{disabled:!f,label:f,children:a.jsx(ce,{component:"circle",...g,...p("curve"),__vars:{"--curve-color":c?Ft(c,x):void 0},fill:"none",strokeLinecap:d?"round":"butt",...bz({sum:r,size:e,thickness:o,value:t,offset:n,root:l})})})}dD.displayName="@mantine/core/Curve";function Sz({size:e,thickness:t,sections:n,renderRoundedLineCaps:r,rootColor:o}){const l=n.reduce((m,g)=>m+g.value,0),c=Math.PI*((e*.9-t*2)/2)*2;let d=c;const f=[],p=[];for(let m=0;m<n.length;m+=1)f.push({sum:l,offset:d,data:n[m],root:!1}),d-=n[m].value/100*c;if(f.push({sum:l,offset:d,data:{color:o},root:!0}),p.push({...f[f.length-1],lineRoundCaps:!1}),f.length>2){p.push({...f[0],lineRoundCaps:r}),p.push({...f[f.length-2],lineRoundCaps:r});for(let m=1;m<=f.length-3;m+=1)p.push({...f[m],lineRoundCaps:!1})}else p.push({...f[0],lineRoundCaps:r});return p}var fD={root:"m_b32e4812",svg:"m_d43b5134",curve:"m_b1ca1fbf",label:"m_b23f9dc4"};function wz(e,t){return Math.min(e||12,(t||120)/4)}const jz={size:120,thickness:12},Cz=(e,{size:t,thickness:n,transitionDuration:r})=>({root:{"--rp-size":le(t),"--rp-label-offset":le(n*2),"--rp-transition-duration":r?`${r}ms`:void 0}}),sm=be((e,t)=>{const n=ae("RingProgress",jz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,label:p,sections:m,size:g,thickness:x,roundCaps:b,rootColor:w,transitionDuration:j,...C}=n,T=$e({name:"RingProgress",classes:fD,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:Cz}),E=wz(x,g),R=Sz({size:g,thickness:E,sections:m,renderRoundedLineCaps:b,rootColor:w}).map(({data:D,sum:P,root:A,lineRoundCaps:k,offset:M},$)=>v.createElement(dD,{...D,key:$,size:g,thickness:E,sum:P,offset:M,color:D?.color,root:A,lineRoundCaps:k,getStyles:T}));return a.jsxs(ce,{...T("root"),size:g,ref:t,...C,children:[a.jsx("svg",{...T("svg"),children:R}),p&&a.jsx("div",{...T("label"),children:p})]})});sm.classes=fD;sm.displayName="@mantine/core/RingProgress";var hD={root:"m_cf365364",indicator:"m_9e182ccd",label:"m_1738fcb2",input:"m_1714d588",control:"m_69686b9b",innerLabel:"m_78882f40"};const Ez={withItemsBorders:!0},Tz=(e,{radius:t,color:n,transitionDuration:r,size:o,transitionTimingFunction:l})=>({root:{"--sc-radius":t===void 0?void 0:$t(t),"--sc-color":n?Ft(n,e):void 0,"--sc-shadow":n?void 0:"var(--mantine-shadow-xs)","--sc-transition-duration":r===void 0?void 0:`${r}ms`,"--sc-transition-timing-function":l,"--sc-padding":at(o,"sc-padding"),"--sc-font-size":In(o)}}),Id=be((e,t)=>{const n=ae("SegmentedControl",Ez,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,data:p,value:m,defaultValue:g,onChange:x,size:b,name:w,disabled:j,readOnly:C,fullWidth:T,orientation:E,radius:R,color:D,transitionDuration:P,transitionTimingFunction:A,variant:k,autoContrast:M,withItemsBorders:$,mod:U,...J}=n,Z=$e({name:"SegmentedControl",props:n,classes:hD,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:Tz}),Y=Sn(),H=p.map(Ee=>typeof Ee=="string"?{label:Ee,value:Ee}:Ee),Q=s4(),[O,I]=v.useState(Qh()),[z,F]=v.useState(null),[K,L]=v.useState({}),q=(Ee,Ge)=>{K[Ge]=Ee,L(K)},[ie,xe]=Zn({value:m,defaultValue:g,finalValue:Array.isArray(p)?H.find(Ee=>!Ee.disabled)?.value??p[0]?.value??null:null,onChange:x}),ve=_r(w),Ce=H.map(Ee=>v.createElement(ce,{...Z("control"),mod:{active:ie===Ee.value,orientation:E},key:Ee.value},v.createElement("input",{...Z("input"),disabled:j||Ee.disabled,type:"radio",name:ve,value:Ee.value,id:`${ve}-${Ee.value}`,checked:ie===Ee.value,onChange:()=>!C&&xe(Ee.value),"data-focus-ring":Y.focusRing,key:`${Ee.value}-input`}),v.createElement(ce,{component:"label",...Z("label"),mod:{active:ie===Ee.value&&!(j||Ee.disabled),disabled:j||Ee.disabled,"read-only":C},htmlFor:`${ve}-${Ee.value}`,ref:Ge=>q(Ge,Ee.value),__vars:{"--sc-label-color":D!==void 0?ma({color:D,theme:Y,autoContrast:M}):void 0},key:`${Ee.value}-label`},a.jsx("span",{...Z("innerLabel"),children:Ee.label})))),Oe=qn(t,Ee=>F(Ee));return i4(()=>{I(Qh())},[p.length]),p.length===0?null:a.jsxs(ce,{...Z("root"),variant:k,size:b,ref:Oe,mod:[{"full-width":T,orientation:E,initialized:Q,"with-items-borders":$},U],...J,role:"radiogroup","data-disabled":j,children:[typeof ie=="string"&&a.jsx(f0,{target:K[ie],parent:z,component:"span",transitionDuration:"var(--sc-transition-duration)",...Z("indicator")},O),Ce]})});Id.classes=hD;Id.displayName="@mantine/core/SegmentedControl";function Rz({spacing:e,verticalSpacing:t,cols:n,selector:r}){const o=Sn(),l=t===void 0?e:t,c=ds({"--sg-spacing-x":Ln(Hi(e)),"--sg-spacing-y":Ln(Hi(l)),"--sg-cols":Hi(n)?.toString()}),d=rn(o.breakpoints).reduce((m,g)=>(m[g]||(m[g]={}),typeof e=="object"&&e[g]!==void 0&&(m[g]["--sg-spacing-x"]=Ln(e[g])),typeof l=="object"&&l[g]!==void 0&&(m[g]["--sg-spacing-y"]=Ln(l[g])),typeof n=="object"&&n[g]!==void 0&&(m[g]["--sg-cols"]=n[g]),m),{}),p=ad(rn(d),o.breakpoints).filter(m=>rn(d[m.value]).length>0).map(m=>({query:`(min-width: ${o.breakpoints[m.value]})`,styles:d[m.value]}));return a.jsx(pl,{styles:c,media:p,selector:r})}function hy(e){return typeof e=="object"&&e!==null?rn(e):[]}function _z(e){return e.sort((t,n)=>od(t)-od(n))}function Dz({spacing:e,verticalSpacing:t,cols:n}){const r=Array.from(new Set([...hy(e),...hy(t),...hy(n)]));return _z(r)}function Az({spacing:e,verticalSpacing:t,cols:n,selector:r}){const o=t===void 0?e:t,l=ds({"--sg-spacing-x":Ln(Hi(e)),"--sg-spacing-y":Ln(Hi(o)),"--sg-cols":Hi(n)?.toString()}),c=Dz({spacing:e,verticalSpacing:t,cols:n}),d=c.reduce((p,m)=>(p[m]||(p[m]={}),typeof e=="object"&&e[m]!==void 0&&(p[m]["--sg-spacing-x"]=Ln(e[m])),typeof o=="object"&&o[m]!==void 0&&(p[m]["--sg-spacing-y"]=Ln(o[m])),typeof n=="object"&&n[m]!==void 0&&(p[m]["--sg-cols"]=n[m]),p),{}),f=c.map(p=>({query:`simple-grid (min-width: ${p})`,styles:d[p]}));return a.jsx(pl,{styles:l,container:f,selector:r})}var pD={container:"m_925c2d2c",root:"m_2415a157"};const Pz={cols:1,spacing:"md",type:"media"},lm=be((e,t)=>{const n=ae("SimpleGrid",Pz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,cols:p,verticalSpacing:m,spacing:g,type:x,...b}=n,w=$e({name:"SimpleGrid",classes:pD,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f}),j=jd();return x==="container"?a.jsxs(a.Fragment,{children:[a.jsx(Az,{...n,selector:`.${j}`}),a.jsx("div",{...w("container"),children:a.jsx(ce,{ref:t,...w("root",{className:j}),...b})})]}):a.jsxs(a.Fragment,{children:[a.jsx(Rz,{...n,selector:`.${j}`}),a.jsx(ce,{ref:t,...w("root",{className:j}),...b})]})});lm.classes=pD;lm.displayName="@mantine/core/SimpleGrid";const kz={},cm=be((e,t)=>{const{w:n,h:r,miw:o,mih:l,...c}=ae("Space",kz,e);return a.jsx(ce,{ref:t,...c,w:n,miw:o??n,h:r,mih:l??r})});cm.displayName="@mantine/core/Space";var mD={root:"m_6d731127"};const Nz={gap:"md",align:"stretch",justify:"flex-start"},Oz=(e,{gap:t,align:n,justify:r})=>({root:{"--stack-gap":Ln(t),"--stack-align":n,"--stack-justify":r}}),Be=be((e,t)=>{const n=ae("Stack",Nz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,align:p,justify:m,gap:g,variant:x,...b}=n,w=$e({name:"Stack",props:n,classes:mD,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:Oz});return a.jsx(ce,{ref:t,...w("root"),variant:x,...b})});Be.classes=mD;Be.displayName="@mantine/core/Stack";const[Mz,Lz]=Rr("Stepper component was not found in tree"),ep=()=>null;ep.displayName="@mantine/core/StepperCompleted";var ob={root:"m_cbb4ea7e",steps:"m_aaf89d0b",separator:"m_2a371ac9",content:"m_78da155d",step:"m_cbb57068","step--horizontal":"m_f56b1e2c","step--vertical":"m_833edb7e",verticalSeparator:"m_6496b3f3",stepWrapper:"m_818e70b",stepIcon:"m_1959ad01",stepCompletedIcon:"m_a79331dc",stepBody:"m_1956aa2a",stepLabel:"m_12051f6c",stepDescription:"m_164eea74"};const xh=(e,t)=>typeof e=="function"?a.jsx(e,{step:t||0}):e,Iz={withIcon:!0,allowStepClick:!0,iconPosition:"left"},ab=be((e,t)=>{const{classNames:n,className:r,style:o,styles:l,vars:c,step:d,state:f,color:p,icon:m,completedIcon:g,progressIcon:x,label:b,description:w,withIcon:j,iconSize:C,loading:T,allowStepClick:E,allowStepSelect:R,iconPosition:D,orientation:P,mod:A,...k}=ae("StepperStep",Iz,e),M=Lz(),$=Sn(),U={classNames:n,styles:l},J=f==="stepCompleted"?null:f==="stepProgress"?x:m,Z={"data-progress":f==="stepProgress"||void 0,"data-completed":f==="stepCompleted"||void 0};return a.jsxs(sr,{...M.getStyles("step",{className:r,style:o,variant:M.orientation,...U}),mod:[{"icon-position":D||M.iconPosition,"allow-click":E},A],ref:t,...Z,...k,__vars:{"--step-color":p?Ft(p,$):void 0},tabIndex:E?0:-1,children:[j&&a.jsxs("span",{...M.getStyles("stepWrapper",U),children:[a.jsxs("span",{...M.getStyles("stepIcon",U),...Z,children:[a.jsx(_o,{mounted:f==="stepCompleted",transition:"pop",duration:200,children:Y=>a.jsx("span",{...M.getStyles("stepCompletedIcon",{style:Y,...U}),children:T?a.jsx(Fr,{color:"var(--mantine-color-white)",size:"calc(var(--stepper-icon-size) / 2)",...M.getStyles("stepLoader",U)}):xh(g,d)||a.jsx(Ad,{size:"60%"})})}),f!=="stepCompleted"?T?a.jsx(Fr,{...M.getStyles("stepLoader",U),size:"calc(var(--stepper-icon-size) / 2)",color:p}):xh(J||m,d):null]}),P==="vertical"&&a.jsx("span",{...M.getStyles("verticalSeparator",U),"data-active":f==="stepCompleted"||void 0})]}),(b||w)&&a.jsxs("span",{...M.getStyles("stepBody",U),"data-orientation":M.orientation,"data-icon-position":D||M.iconPosition,children:[b&&a.jsx("span",{...M.getStyles("stepLabel",U),children:xh(b,d)}),w&&a.jsx("span",{...M.getStyles("stepDescription",U),children:xh(w,d)})]})]})});ab.classes=ob;ab.displayName="@mantine/core/StepperStep";const zz={orientation:"horizontal",iconPosition:"left",allowNextStepsSelect:!0,wrap:!0},$z=(e,{color:t,iconSize:n,size:r,contentPadding:o,radius:l,autoContrast:c})=>({root:{"--stepper-color":t?Ft(t,e):void 0,"--stepper-icon-color":hl(c,e)?ma({color:t,theme:e,autoContrast:c}):void 0,"--stepper-icon-size":n===void 0?at(r,"stepper-icon-size"):le(n),"--stepper-content-padding":Ln(o),"--stepper-radius":l===void 0?void 0:$t(l),"--stepper-fz":In(r),"--stepper-spacing":Ln(r)}}),Mc=be((e,t)=>{const n=ae("Stepper",zz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,children:p,onStepClick:m,active:g,icon:x,completedIcon:b,progressIcon:w,color:j,iconSize:C,contentPadding:T,orientation:E,iconPosition:R,size:D,radius:P,allowNextStepsSelect:A,wrap:k,autoContrast:M,...$}=n,U=$e({name:"Stepper",classes:ob,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:$z}),J=v.Children.toArray(p),Z=J.filter(z=>z.type!==ep),Y=J.find(z=>z.type===ep),H=Z.reduce((z,F,K)=>{const L=g===K?"stepProgress":g>K?"stepCompleted":"stepInactive",ie=typeof m!="function"?!1:typeof F.props.allowStepSelect=="boolean"?F.props.allowStepSelect:L==="stepCompleted"||A;return z.push(v.cloneElement(F,{icon:F.props.icon||x||K+1,key:K,step:K,state:L,onClick:()=>ie&&m?.(K),allowStepClick:ie,completedIcon:F.props.completedIcon||b,progressIcon:F.props.progressIcon||w,color:F.props.color||j,iconSize:C,iconPosition:F.props.iconPosition||R,orientation:E})),E==="horizontal"&&K!==Z.length-1&&z.push(v.createElement("div",{...U("separator"),"data-active":K<g||void 0,"data-orientation":E,key:`separator-${K}`})),z},[]),Q=Z[g]?.props?.children,O=Y?.props?.children,I=g>Z.length-1?O:Q;return a.jsx(Mz,{value:{getStyles:U,orientation:E,iconPosition:R},children:a.jsxs(ce,{...U("root"),ref:t,size:D,...$,children:[a.jsx(ce,{...U("steps"),mod:{orientation:E,"icon-position":R,wrap:k&&E!=="vertical"},children:H}),I&&a.jsx("div",{...U("content"),children:I})]})})});Mc.classes=ob;Mc.displayName="@mantine/core/Stepper";Mc.Completed=ep;Mc.Step=ab;const gD=v.createContext(null),Uz=gD.Provider,Bz=()=>v.useContext(gD),Vz={},sb=be((e,t)=>{const{value:n,defaultValue:r,onChange:o,size:l,wrapperProps:c,children:d,readOnly:f,...p}=ae("SwitchGroup",Vz,e),[m,g]=Zn({value:n,defaultValue:r,finalValue:[],onChange:o}),x=b=>{const w=b.currentTarget.value;!f&&g(m.includes(w)?m.filter(j=>j!==w):[...m,w])};return a.jsx(Uz,{value:{value:m,onChange:x,size:l},children:a.jsx(un.Wrapper,{size:l,ref:t,...c,...p,labelElement:"div",__staticSelector:"SwitchGroup",children:a.jsx(D0,{role:"group",children:d})})})});sb.classes=un.Wrapper.classes;sb.displayName="@mantine/core/SwitchGroup";var vD={root:"m_5f93f3bb",input:"m_926b4011",track:"m_9307d992",thumb:"m_93039a1d",trackLabel:"m_8277e082"};const Fz={labelPosition:"right"},Hz=(e,{radius:t,color:n,size:r})=>({root:{"--switch-radius":t===void 0?void 0:$t(t),"--switch-height":at(r,"switch-height"),"--switch-width":at(r,"switch-width"),"--switch-thumb-size":at(r,"switch-thumb-size"),"--switch-label-font-size":at(r,"switch-label-font-size"),"--switch-track-label-padding":at(r,"switch-track-label-padding"),"--switch-color":n?Ft(n,e):void 0}}),zd=be((e,t)=>{const n=ae("Switch",Fz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,color:p,label:m,offLabel:g,onLabel:x,id:b,size:w,radius:j,wrapperProps:C,thumbIcon:T,checked:E,defaultChecked:R,onChange:D,labelPosition:P,description:A,error:k,disabled:M,variant:$,rootRef:U,mod:J,...Z}=n,Y=Bz(),H=w||Y?.size,Q=$e({name:"Switch",props:n,classes:vD,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:Hz}),{styleProps:O,rest:I}=ga(Z),z=_r(b),F=Y?{checked:Y.value.includes(I.value),onChange:Y.onChange}:{},[K,L]=Zn({value:F.checked??E,defaultValue:R,finalValue:!1});return a.jsxs(Vp,{...Q("root"),__staticSelector:"Switch",__stylesApiProps:n,id:z,size:H,labelPosition:P,label:m,description:A,error:k,disabled:M,bodyElement:"label",labelElement:"span",classNames:r,styles:c,unstyled:d,"data-checked":F.checked||E||void 0,variant:$,ref:U,mod:J,...O,...C,children:[a.jsx("input",{...I,disabled:M,checked:K,"data-checked":F.checked||E||void 0,onChange:q=>{Y?F.onChange?.(q):D?.(q),L(q.currentTarget.checked)},id:z,ref:t,type:"checkbox",role:"switch",...Q("input")}),a.jsxs(ce,{"aria-hidden":"true",component:"span",mod:{error:k,"label-position":P,"without-labels":!x&&!g},...Q("track"),children:[a.jsx(ce,{component:"span",mod:"reduce-motion",...Q("thumb"),children:T}),a.jsx("span",{...Q("trackLabel"),children:K?x:g})]})]})});zd.classes={...vD,...j_};zd.displayName="@mantine/core/Switch";zd.Group=sb;const[qz,Gz]=Rr("Table component was not found in the tree");var $d={table:"m_b23fa0ef",th:"m_4e7aa4f3",tr:"m_4e7aa4fd",td:"m_4e7aa4ef",tbody:"m_b2404537",thead:"m_b242d975",caption:"m_9e5a3ac7",scrollContainer:"m_a100c15",scrollContainerInner:"m_62259741"};function Qz(e,t){if(!t)return;const n={};return t.columnBorder&&e.withColumnBorders&&(n["data-with-column-border"]=!0),t.rowBorder&&e.withRowBorders&&(n["data-with-row-border"]=!0),t.striped&&e.striped&&(n["data-striped"]=e.striped),t.highlightOnHover&&e.highlightOnHover&&(n["data-hover"]=!0),t.captionSide&&e.captionSide&&(n["data-side"]=e.captionSide),t.stickyHeader&&e.stickyHeader&&(n["data-sticky"]=!0),n}function yl(e,t){const n=`Table${e.charAt(0).toUpperCase()}${e.slice(1)}`,r=be((o,l)=>{const c=ae(n,{},o),{classNames:d,className:f,style:p,styles:m,...g}=c,x=Gz();return a.jsx(ce,{component:e,ref:l,...Qz(x,t),...x.getStyles(e,{className:f,classNames:d,style:p,styles:m,props:c}),...g})});return r.displayName=`@mantine/core/${n}`,r.classes=$d,r}const ox=yl("th",{columnBorder:!0}),yD=yl("td",{columnBorder:!0}),Lh=yl("tr",{rowBorder:!0,striped:!0,highlightOnHover:!0}),xD=yl("thead",{stickyHeader:!0}),bD=yl("tbody"),SD=yl("tfoot"),wD=yl("caption",{captionSide:!0});function lb({data:e}){return a.jsxs(a.Fragment,{children:[e.caption&&a.jsx(wD,{children:e.caption}),e.head&&a.jsx(xD,{children:a.jsx(Lh,{children:e.head.map((t,n)=>a.jsx(ox,{children:t},n))})}),e.body&&a.jsx(bD,{children:e.body.map((t,n)=>a.jsx(Lh,{children:t.map((r,o)=>a.jsx(yD,{children:r},o))},n))}),e.foot&&a.jsx(SD,{children:a.jsx(Lh,{children:e.foot.map((t,n)=>a.jsx(ox,{children:t},n))})})]})}lb.displayName="@mantine/core/TableDataRenderer";const Wz={type:"scrollarea"},Yz=(e,{minWidth:t,maxHeight:n,type:r})=>({scrollContainer:{"--table-min-width":le(t),"--table-max-height":le(n),"--table-overflow":r==="native"?"auto":void 0}}),cb=be((e,t)=>{const n=ae("TableScrollContainer",Wz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,children:p,minWidth:m,maxHeight:g,type:x,scrollAreaProps:b,...w}=n,j=$e({name:"TableScrollContainer",classes:$d,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:Yz,rootSelector:"scrollContainer"});return a.jsx(ce,{component:x==="scrollarea"?ai:"div",...x==="scrollarea"?g?{offsetScrollbars:"xy",...b}:{offsetScrollbars:"x",...b}:{},ref:t,...j("scrollContainer"),...w,children:a.jsx("div",{...j("scrollContainerInner"),children:p})})});cb.classes=$d;cb.displayName="@mantine/core/TableScrollContainer";const Kz={withRowBorders:!0,verticalSpacing:7},Xz=(e,{layout:t,captionSide:n,horizontalSpacing:r,verticalSpacing:o,borderColor:l,stripedColor:c,highlightOnHoverColor:d,striped:f,highlightOnHover:p,stickyHeaderOffset:m,stickyHeader:g})=>({table:{"--table-layout":t,"--table-caption-side":n,"--table-horizontal-spacing":Ln(r),"--table-vertical-spacing":Ln(o),"--table-border-color":l?Ft(l,e):void 0,"--table-striped-color":f&&c?Ft(c,e):void 0,"--table-highlight-on-hover-color":p&&d?Ft(d,e):void 0,"--table-sticky-header-offset":g?le(m):void 0}}),fe=be((e,t)=>{const n=ae("Table",Kz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,horizontalSpacing:p,verticalSpacing:m,captionSide:g,stripedColor:x,highlightOnHoverColor:b,striped:w,highlightOnHover:j,withColumnBorders:C,withRowBorders:T,withTableBorder:E,borderColor:R,layout:D,variant:P,data:A,children:k,stickyHeader:M,stickyHeaderOffset:$,mod:U,tabularNums:J,...Z}=n,Y=$e({name:"Table",props:n,className:o,style:l,classes:$d,classNames:r,styles:c,unstyled:d,rootSelector:"table",vars:f,varsResolver:Xz});return a.jsx(qz,{value:{getStyles:Y,stickyHeader:M,striped:w===!0?"odd":w||void 0,highlightOnHover:j,withColumnBorders:C,withRowBorders:T,captionSide:g||"bottom"},children:a.jsx(ce,{component:"table",variant:P,ref:t,mod:[{"data-with-table-border":E,"data-tabular-nums":J},U],...Y("table"),...Z,children:k||!!A&&a.jsx(lb,{data:A})})})});fe.classes=$d;fe.displayName="@mantine/core/Table";fe.Td=yD;fe.Th=ox;fe.Tr=Lh;fe.Thead=xD;fe.Tbody=bD;fe.Tfoot=SD;fe.Caption=wD;fe.ScrollContainer=cb;fe.DataRenderer=lb;const[Zz,ub]=Rr("Tabs component was not found in the tree");var Ud={root:"m_89d60db1","list--default":"m_576c9d4",list:"m_89d33d6d",panel:"m_b0c91715",tab:"m_4ec4dce6",tabSection:"m_fc420b1f","tab--default":"m_539e827b","list--outline":"m_6772fbd5","tab--outline":"m_b59ab47c","tab--pills":"m_c3381914"};const Jz={},db=be((e,t)=>{const n=ae("TabsList",Jz,e),{children:r,className:o,grow:l,justify:c,classNames:d,styles:f,style:p,mod:m,...g}=n,x=ub();return a.jsx(ce,{...g,...x.getStyles("list",{className:o,style:p,classNames:d,styles:f,props:n,variant:x.variant}),ref:t,role:"tablist",variant:x.variant,mod:[{grow:l,orientation:x.orientation,placement:x.orientation==="vertical"&&x.placement,inverted:x.inverted},m],"aria-orientation":x.orientation,__vars:{"--tabs-justify":c},children:r})});db.classes=Ud;db.displayName="@mantine/core/TabsList";const e$={},fb=be((e,t)=>{const n=ae("TabsPanel",e$,e),{children:r,className:o,value:l,classNames:c,styles:d,style:f,mod:p,keepMounted:m,...g}=n,x=ub(),b=x.value===l,w=x.keepMounted||m||b?r:null;return a.jsx(ce,{...g,...x.getStyles("panel",{className:o,classNames:c,styles:d,style:[f,b?void 0:{display:"none"}],props:n}),ref:t,mod:[{orientation:x.orientation},p],role:"tabpanel",id:x.getPanelId(l),"aria-labelledby":x.getTabId(l),children:w})});fb.classes=Ud;fb.displayName="@mantine/core/TabsPanel";const t$={},hb=be((e,t)=>{const n=ae("TabsTab",t$,e),{className:r,children:o,rightSection:l,leftSection:c,value:d,onClick:f,onKeyDown:p,disabled:m,color:g,style:x,classNames:b,styles:w,vars:j,mod:C,tabIndex:T,...E}=n,R=Sn(),{dir:D}=ml(),P=ub(),A=d===P.value,k=$=>{P.onChange(P.allowTabDeactivation&&d===P.value?null:d),f?.($)},M={classNames:b,styles:w,props:n};return a.jsxs(sr,{...E,...P.getStyles("tab",{className:r,style:x,variant:P.variant,...M}),disabled:m,unstyled:P.unstyled,variant:P.variant,mod:[{active:A,disabled:m,orientation:P.orientation,inverted:P.inverted,placement:P.orientation==="vertical"&&P.placement},C],ref:t,role:"tab",id:P.getTabId(d),"aria-selected":A,tabIndex:T!==void 0?T:A||P.value===null?0:-1,"aria-controls":P.getPanelId(d),onClick:k,__vars:{"--tabs-color":g?Ft(g,R):void 0},onKeyDown:zR({siblingSelector:'[role="tab"]',parentSelector:'[role="tablist"]',activateOnFocus:P.activateTabWithKeyboard,loop:P.loop,orientation:P.orientation||"horizontal",dir:D,onKeyDown:p}),children:[c&&a.jsx("span",{...P.getStyles("tabSection",M),"data-position":"left",children:c}),o&&a.jsx("span",{...P.getStyles("tabLabel",M),children:o}),l&&a.jsx("span",{...P.getStyles("tabSection",M),"data-position":"right",children:l})]})});hb.classes=Ud;hb.displayName="@mantine/core/TabsTab";const RE="Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value",n$={keepMounted:!0,orientation:"horizontal",loop:!0,activateTabWithKeyboard:!0,allowTabDeactivation:!1,unstyled:!1,inverted:!1,variant:"default",placement:"left"},r$=(e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":$t(t),"--tabs-color":Ft(n,e),"--tabs-text-color":hl(r,e)?ma({color:n,theme:e,autoContrast:r}):void 0}}),Tt=be((e,t)=>{const n=ae("Tabs",n$,e),{defaultValue:r,value:o,onChange:l,orientation:c,children:d,loop:f,id:p,activateTabWithKeyboard:m,allowTabDeactivation:g,variant:x,color:b,radius:w,inverted:j,placement:C,keepMounted:T,classNames:E,styles:R,unstyled:D,className:P,style:A,vars:k,autoContrast:M,mod:$,...U}=n,J=_r(p),[Z,Y]=Zn({value:o,defaultValue:r,finalValue:null,onChange:l}),H=$e({name:"Tabs",props:n,classes:Ud,className:P,style:A,classNames:E,styles:R,unstyled:D,vars:k,varsResolver:r$});return a.jsx(Zz,{value:{placement:C,value:Z,orientation:c,id:J,loop:f,activateTabWithKeyboard:m,getTabId:bC(`${J}-tab`,RE),getPanelId:bC(`${J}-panel`,RE),onChange:Y,allowTabDeactivation:g,variant:x,color:b,radius:w,inverted:j,keepMounted:T,unstyled:D,getStyles:H},children:a.jsx(ce,{ref:t,id:J,variant:x,mod:[{orientation:c,inverted:c==="horizontal"&&j,placement:c==="vertical"&&C},$],...H("root"),...U,children:d})})});Tt.classes=Ud;Tt.displayName="@mantine/core/Tabs";Tt.Tab=hb;Tt.Panel=fb;Tt.List=db;const i$={},Ve=be((e,t)=>{const n=ae("TextInput",i$,e);return a.jsx(Dr,{component:"input",ref:t,...n,__staticSelector:"TextInput"})});Ve.classes=Dr.classes;Ve.displayName="@mantine/core/TextInput";var jD={root:"m_7341320d"};const o$={},a$=(e,{size:t,radius:n,variant:r,gradient:o,color:l,autoContrast:c})=>{const d=e.variantColorResolver({color:l||e.primaryColor,theme:e,gradient:o,variant:r||"filled",autoContrast:c});return{root:{"--ti-size":at(t,"ti-size"),"--ti-radius":n===void 0?void 0:$t(n),"--ti-bg":l||r?d.background:void 0,"--ti-color":l||r?d.color:void 0,"--ti-bd":l||r?d.border:void 0}}},pb=be((e,t)=>{const n=ae("ThemeIcon",o$,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,autoContrast:p,...m}=n,g=$e({name:"ThemeIcon",classes:jD,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:a$});return a.jsx(ce,{ref:t,...g("root"),...m})});pb.classes=jD;pb.displayName="@mantine/core/ThemeIcon";const s$=["h1","h2","h3","h4","h5","h6"],l$=["xs","sm","md","lg","xl"];function c$(e,t){const n=t!==void 0?t:`h${e}`;return s$.includes(n)?{fontSize:`var(--mantine-${n}-font-size)`,fontWeight:`var(--mantine-${n}-font-weight)`,lineHeight:`var(--mantine-${n}-line-height)`}:l$.includes(n)?{fontSize:`var(--mantine-font-size-${n})`,fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}:{fontSize:le(n),fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}}var CD={root:"m_8a5d1357"};const u$={order:1},d$=(e,{order:t,size:n,lineClamp:r,textWrap:o})=>{const l=c$(t,n);return{root:{"--title-fw":l.fontWeight,"--title-lh":l.lineHeight,"--title-fz":l.fontSize,"--title-line-clamp":typeof r=="number"?r.toString():void 0,"--title-text-wrap":o}}},Ie=be((e,t)=>{const n=ae("Title",u$,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,order:f,vars:p,size:m,variant:g,lineClamp:x,textWrap:b,mod:w,...j}=n,C=$e({name:"Title",props:n,classes:CD,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:p,varsResolver:d$});return[1,2,3,4,5,6].includes(f)?a.jsx(ce,{...C("root"),component:`h${f}`,variant:g,ref:t,mod:[{order:f,"data-line-clamp":typeof x=="number"},w],size:m,...j}):null});Ie.classes=CD;Ie.displayName="@mantine/core/Title";function f$(e){let t=e,n=!1;const r=new Set;return{getState(){return t},updateState(o){t=typeof o=="function"?o(t):o},setState(o){this.updateState(o),r.forEach(l=>l(t))},initialize(o){n||(t=o,n=!0)},subscribe(o){return r.add(o),()=>r.delete(o)}}}function h$(e){return v.useSyncExternalStore(e.subscribe,()=>e.getState(),()=>e.getState())}function p$(e,t,n){const r=[],o=[],l={};for(const c of e){const d=c.position||t;l[d]=l[d]||0,l[d]+=1,l[d]<=n?o.push(c):r.push(c)}return{notifications:o,queue:r}}const m$=()=>f$({notifications:[],queue:[],defaultPosition:"bottom-right",limit:5}),xl=m$(),g$=(e=xl)=>h$(e);function Xc(e,t){const n=e.getState(),r=t([...n.notifications,...n.queue]),o=p$(r,n.defaultPosition,n.limit);e.setState({notifications:o.notifications,queue:o.queue,limit:n.limit,defaultPosition:n.defaultPosition})}function Ne(e,t=xl){const n=e.id||Qh();return Xc(t,r=>e.id&&r.some(o=>o.id===e.id)?r:[...r,{...e,id:n}]),n}function ED(e,t=xl){return Xc(t,n=>n.filter(r=>r.id===e?(r.onClose?.(r),!1):!0)),e}function Qs(e,t=xl){return Xc(t,n=>n.map(r=>r.id===e.id?{...r,...e}:r)),e.id}function v$(e=xl){Xc(e,()=>[])}function y$(e=xl){Xc(e,t=>t.slice(0,e.getState().limit))}const Ci={show:Ne,hide:ED,update:Qs,clean:v$,cleanQueue:y$,updateState:Xc};function ax(e,t){return ax=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},ax(e,t)}function TD(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,ax(e,t)}var py={exports:{}},my,_E;function x$(){if(_E)return my;_E=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return my=e,my}var gy,DE;function b$(){if(DE)return gy;DE=1;var e=x$();function t(){}function n(){}return n.resetWarningCache=t,gy=function(){function r(c,d,f,p,m,g){if(g!==e){var x=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw x.name="Invariant Violation",x}}r.isRequired=r;function o(){return r}var l={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return l.PropTypes=l,l},gy}var AE;function S$(){return AE||(AE=1,py.exports=b$()()),py.exports}var w$=S$();const nn=Ox(w$),PE={disabled:!1},tp=Tn.createContext(null);var j$=function(t){return t.scrollTop},td="unmounted",Bs="exited",Vs="entering",bc="entered",sx="exiting",ba=(function(e){TD(t,e);function t(r,o){var l;l=e.call(this,r,o)||this;var c=o,d=c&&!c.isMounting?r.enter:r.appear,f;return l.appearStatus=null,r.in?d?(f=Bs,l.appearStatus=Vs):f=bc:r.unmountOnExit||r.mountOnEnter?f=td:f=Bs,l.state={status:f},l.nextCallback=null,l}t.getDerivedStateFromProps=function(o,l){var c=o.in;return c&&l.status===td?{status:Bs}:null};var n=t.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(o){var l=null;if(o!==this.props){var c=this.state.status;this.props.in?c!==Vs&&c!==bc&&(l=Vs):(c===Vs||c===bc)&&(l=sx)}this.updateStatus(!1,l)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var o=this.props.timeout,l,c,d;return l=c=d=o,o!=null&&typeof o!="number"&&(l=o.exit,c=o.enter,d=o.appear!==void 0?o.appear:c),{exit:l,enter:c,appear:d}},n.updateStatus=function(o,l){if(o===void 0&&(o=!1),l!==null)if(this.cancelNextCallback(),l===Vs){if(this.props.unmountOnExit||this.props.mountOnEnter){var c=this.props.nodeRef?this.props.nodeRef.current:ed.findDOMNode(this);c&&j$(c)}this.performEnter(o)}else this.performExit();else this.props.unmountOnExit&&this.state.status===Bs&&this.setState({status:td})},n.performEnter=function(o){var l=this,c=this.props.enter,d=this.context?this.context.isMounting:o,f=this.props.nodeRef?[d]:[ed.findDOMNode(this),d],p=f[0],m=f[1],g=this.getTimeouts(),x=d?g.appear:g.enter;if(!o&&!c||PE.disabled){this.safeSetState({status:bc},function(){l.props.onEntered(p)});return}this.props.onEnter(p,m),this.safeSetState({status:Vs},function(){l.props.onEntering(p,m),l.onTransitionEnd(x,function(){l.safeSetState({status:bc},function(){l.props.onEntered(p,m)})})})},n.performExit=function(){var o=this,l=this.props.exit,c=this.getTimeouts(),d=this.props.nodeRef?void 0:ed.findDOMNode(this);if(!l||PE.disabled){this.safeSetState({status:Bs},function(){o.props.onExited(d)});return}this.props.onExit(d),this.safeSetState({status:sx},function(){o.props.onExiting(d),o.onTransitionEnd(c.exit,function(){o.safeSetState({status:Bs},function(){o.props.onExited(d)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(o,l){l=this.setNextCallback(l),this.setState(o,l)},n.setNextCallback=function(o){var l=this,c=!0;return this.nextCallback=function(d){c&&(c=!1,l.nextCallback=null,o(d))},this.nextCallback.cancel=function(){c=!1},this.nextCallback},n.onTransitionEnd=function(o,l){this.setNextCallback(l);var c=this.props.nodeRef?this.props.nodeRef.current:ed.findDOMNode(this),d=o==null&&!this.props.addEndListener;if(!c||d){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var f=this.props.nodeRef?[this.nextCallback]:[c,this.nextCallback],p=f[0],m=f[1];this.props.addEndListener(p,m)}o!=null&&setTimeout(this.nextCallback,o)},n.render=function(){var o=this.state.status;if(o===td)return null;var l=this.props,c=l.children;l.in,l.mountOnEnter,l.unmountOnExit,l.appear,l.enter,l.exit,l.timeout,l.addEndListener,l.onEnter,l.onEntering,l.onEntered,l.onExit,l.onExiting,l.onExited,l.nodeRef;var d=$0(l,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return Tn.createElement(tp.Provider,{value:null},typeof c=="function"?c(o,d):Tn.cloneElement(Tn.Children.only(c),d))},t})(Tn.Component);ba.contextType=tp;ba.propTypes={};function hc(){}ba.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:hc,onEntering:hc,onEntered:hc,onExit:hc,onExiting:hc,onExited:hc};ba.UNMOUNTED=td;ba.EXITED=Bs;ba.ENTERING=Vs;ba.ENTERED=bc;ba.EXITING=sx;function C$(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function mb(e,t){var n=function(l){return t&&v.isValidElement(l)?t(l):l},r=Object.create(null);return e&&v.Children.map(e,function(o){return o}).forEach(function(o){r[o.key]=n(o)}),r}function E$(e,t){e=e||{},t=t||{};function n(m){return m in t?t[m]:e[m]}var r=Object.create(null),o=[];for(var l in e)l in t?o.length&&(r[l]=o,o=[]):o.push(l);var c,d={};for(var f in t){if(r[f])for(c=0;c<r[f].length;c++){var p=r[f][c];d[r[f][c]]=n(p)}d[f]=n(f)}for(c=0;c<o.length;c++)d[o[c]]=n(o[c]);return d}function Ws(e,t,n){return n[t]!=null?n[t]:e.props[t]}function T$(e,t){return mb(e.children,function(n){return v.cloneElement(n,{onExited:t.bind(null,n),in:!0,appear:Ws(n,"appear",e),enter:Ws(n,"enter",e),exit:Ws(n,"exit",e)})})}function R$(e,t,n){var r=mb(e.children),o=E$(t,r);return Object.keys(o).forEach(function(l){var c=o[l];if(v.isValidElement(c)){var d=l in t,f=l in r,p=t[l],m=v.isValidElement(p)&&!p.props.in;f&&(!d||m)?o[l]=v.cloneElement(c,{onExited:n.bind(null,c),in:!0,exit:Ws(c,"exit",e),enter:Ws(c,"enter",e)}):!f&&d&&!m?o[l]=v.cloneElement(c,{in:!1}):f&&d&&v.isValidElement(p)&&(o[l]=v.cloneElement(c,{onExited:n.bind(null,c),in:p.props.in,exit:Ws(c,"exit",e),enter:Ws(c,"enter",e)}))}}),o}var _$=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},D$={component:"div",childFactory:function(t){return t}},Xa=(function(e){TD(t,e);function t(r,o){var l;l=e.call(this,r,o)||this;var c=l.handleExited.bind(C$(l));return l.state={contextValue:{isMounting:!0},handleExited:c,firstRender:!0},l}var n=t.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},t.getDerivedStateFromProps=function(o,l){var c=l.children,d=l.handleExited,f=l.firstRender;return{children:f?T$(o,d):R$(o,c,d),firstRender:!1}},n.handleExited=function(o,l){var c=mb(this.props.children);o.key in c||(o.props.onExited&&o.props.onExited(l),this.mounted&&this.setState(function(d){var f=Jh({},d.children);return delete f[o.key],{children:f}}))},n.render=function(){var o=this.props,l=o.component,c=o.childFactory,d=$0(o,["component","childFactory"]),f=this.state.contextValue,p=_$(this.state.children).map(c);return delete d.appear,delete d.enter,delete d.exit,l===null?Tn.createElement(tp.Provider,{value:f},p):Tn.createElement(tp.Provider,{value:f},Tn.createElement(l,d,p))},t})(Tn.Component);Xa.propTypes={};Xa.defaultProps=D$;const RD=["bottom-center","bottom-left","bottom-right","top-center","top-left","top-right"];function A$(e,t){return e.reduce((n,r)=>(n[r.position||t].push(r),n),RD.reduce((n,r)=>(n[r]=[],n),{}))}const kE={left:"translateX(-100%)",right:"translateX(100%)","top-center":"translateY(-100%)","bottom-center":"translateY(100%)"},P$={left:"translateX(0)",right:"translateX(0)","top-center":"translateY(0)","bottom-center":"translateY(0)"};function k$({state:e,maxHeight:t,position:n,transitionDuration:r}){const[o,l]=n.split("-"),c=l==="center"?`${o}-center`:l,d={opacity:0,maxHeight:t,transform:kE[c],transitionDuration:`${r}ms, ${r}ms, ${r}ms`,transitionTimingFunction:"cubic-bezier(.51,.3,0,1.21), cubic-bezier(.51,.3,0,1.21), linear",transitionProperty:"opacity, transform, max-height"},f={opacity:1,transform:P$[c]},p={opacity:0,maxHeight:0,transform:kE[c]};return{...d,...{entering:f,entered:f,exiting:p,exited:p}[e]}}function N$(e,t){return typeof t=="number"?t:t===!1||e===!1?!1:e}const _D=v.forwardRef(({data:e,onHide:t,autoClose:n,...r},o)=>{const{autoClose:l,message:c,...d}=e,f=N$(n,e.autoClose),p=v.useRef(-1),m=()=>window.clearTimeout(p.current),g=()=>{t(e.id),m()},x=()=>{typeof f=="number"&&(p.current=window.setTimeout(g,f))};return v.useEffect(()=>{e.onOpen?.(e)},[]),v.useEffect(()=>(x(),m),[f]),a.jsx(X0,{...r,...d,onClose:g,ref:o,onMouseEnter:m,onMouseLeave:x,children:c})});_D.displayName="@mantine/notifications/NotificationContainer";var DD={root:"m_b37d9ac7",notification:"m_5ed0edd0"};const O$=ba,M$={position:"bottom-right",autoClose:4e3,transitionDuration:250,containerWidth:440,notificationMaxHeight:200,limit:5,zIndex:oi("overlay"),store:xl,withinPortal:!0},L$=(e,{zIndex:t,containerWidth:n})=>({root:{"--notifications-z-index":t?.toString(),"--notifications-container-width":le(n)}}),Sa=be((e,t)=>{const n=ae("Notifications",M$,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,position:p,autoClose:m,transitionDuration:g,containerWidth:x,notificationMaxHeight:b,limit:w,zIndex:j,store:C,portalProps:T,withinPortal:E,...R}=n,D=Sn(),P=g$(C),A=XO(),k=$x(),M=v.useRef({}),$=v.useRef(0),J=(D.respectReducedMotion?k:!1)?1:g,Z=$e({name:"Notifications",classes:DD,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:L$});v.useEffect(()=>{C?.updateState(Q=>({...Q,limit:w||5,defaultPosition:p}))},[w,p]),oa(()=>{P.notifications.length>$.current&&setTimeout(()=>A(),0),$.current=P.notifications.length},[P.notifications]);const Y=A$(P.notifications,p),H=RD.reduce((Q,O)=>(Q[O]=Y[O].map(({style:I,...z})=>a.jsx(O$,{timeout:J,onEnter:()=>M.current[z.id].offsetHeight,nodeRef:{current:M.current[z.id]},children:F=>a.jsx(_D,{ref:K=>{M.current[z.id]=K},data:z,onHide:K=>ED(K,C),autoClose:m,...Z("notification",{style:{...k$({state:F,position:O,transitionDuration:J,maxHeight:b}),...I}})})},z.id)),Q),{});return a.jsxs(fs,{withinPortal:E,...T,children:[a.jsx(ce,{...Z("root"),"data-position":"top-center",ref:t,...R,children:a.jsx(Xa,{children:H["top-center"]})}),a.jsx(ce,{...Z("root"),"data-position":"top-left",...R,children:a.jsx(Xa,{children:H["top-left"]})}),a.jsx(ce,{...Z("root",{className:_c.classNames.fullWidth}),"data-position":"top-right",...R,children:a.jsx(Xa,{children:H["top-right"]})}),a.jsx(ce,{...Z("root",{className:_c.classNames.fullWidth}),"data-position":"bottom-right",...R,children:a.jsx(Xa,{children:H["bottom-right"]})}),a.jsx(ce,{...Z("root"),"data-position":"bottom-left",...R,children:a.jsx(Xa,{children:H["bottom-left"]})}),a.jsx(ce,{...Z("root"),"data-position":"bottom-center",...R,children:a.jsx(Xa,{children:H["bottom-center"]})})]})});Sa.classes=DD;Sa.displayName="@mantine/notifications/Notifications";Sa.show=Ci.show;Sa.hide=Ci.hide;Sa.update=Ci.update;Sa.clean=Ci.clean;Sa.cleanQueue=Ci.cleanQueue;Sa.updateState=Ci.updateState;class I${constructor(t,n){this.operator=t,this.child=n}toString(){return`${this.operator}(${this.child.toString()})`}}class Bd{constructor(t,n,r){this.operator=t,this.left=n,this.right=r}toString(){return`(${this.left.toString()} ${this.operator} ${this.right.toString()})`}}class z${constructor(){this.prefixParselets={},this.infixParselets={}}registerInfix(t,n){return this.infixParselets[t]=n,this}registerPrefix(t,n){return this.prefixParselets[t]=n,this}prefix(t,n,r){return this.registerPrefix(t,{parse(o,l){const c=o.consumeAndParse(n);return r(l,c)}})}infixLeft(t,n,r){return this.registerInfix(t,{parse(o,l,c){const d=o.consumeAndParse(n);return r(l,c,d)},precedence:n})}construct(t){return new $$(t,this.prefixParselets,this.infixParselets)}}class $${constructor(t,n,r){this.tokens=t,this.prefixParselets=n,this.infixParselets=r}hasMore(){return this.tokens.length>0}match(t){return this.peek()?.id!==t?!1:(this.consume(),!0)}consumeAndParse(t=1/0){const n=this.consume(),r=this.prefixParselets[n.id];if(!r)throw Error(`Parse error at "${n.value}" (line ${n.line}, column ${n.column}). No matching prefix parselet.`);let o=r.parse(this,n);for(;t>this.getPrecedence();){const l=this.consume();o=this.getInfixParselet(l).parse(this,o,l)}return o}getPrecedence(){const t=this.peek();if(!t)return 1/0;const n=this.getInfixParselet(t);return n?n.precedence:1/0}consume(t,n){if(!this.tokens.length)throw Error("Cant consume unknown more tokens.");if(t&&this.peek()?.id!==t){const r=this.peek();throw Error(`Expected ${t} but got "${r.id}" (${r.value}) at line ${r.line} column ${r.column}.`)}if(n&&this.peek()?.value!==n){const r=this.peek();throw Error(`Expected "${n}" but got "${r.value}" at line ${r.line} column ${r.column}.`)}return this.tokens.shift()}peek(){return this.tokens.length>0?this.tokens[0]:void 0}removeComments(){this.tokens=this.tokens.filter(t=>t.id!=="Comment")}getInfixParselet(t){return this.infixParselets[t.id==="Symbol"?t.value:t.id]}}class AD{constructor(t=10){this.max=t,this.cache=new Map}clear(){this.cache.clear()}get(t){const n=this.cache.get(t);return n&&(this.cache.delete(t),this.cache.set(t,n)),n}set(t,n){this.cache.has(t)?this.cache.delete(t):this.cache.size>=this.max&&this.cache.delete(this.first()),this.cache.set(t,n)}delete(t){this.cache.delete(t)}keys(){return this.cache.keys()}first(){return this.cache.keys().next().value}}const Ji="http://hl7.org",PD="ok",U$="created",B$="gone",V$="not-modified",F$="not-found",H$="unauthorized",q$="forbidden",G$="accepted",Q$={resourceType:"OperationOutcome",id:PD,issue:[{severity:"information",code:"informational",details:{text:"All OK"}}]},W$={resourceType:"OperationOutcome",id:F$,issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},hd={resourceType:"OperationOutcome",id:H$,issue:[{severity:"error",code:"login",details:{text:"Unauthorized"}}]},Y$={...hd,issue:[...hd.issue,{severity:"error",code:"expired",details:{text:"Token expired"}}]},NE={...hd,issue:[...hd.issue,{severity:"error",code:"invalid",details:{text:"Token not issued for this audience"}}]},Vd={resourceType:"OperationOutcome",id:q$,issue:[{severity:"error",code:"forbidden",details:{text:"Forbidden"}}]};function xo(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},...t?{expression:[t]}:void 0}]}}function gn(e){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"structure",details:{text:e}}]}}function K$(e){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"exception",details:{text:"Internal server error"},diagnostics:e.toString()}]}}function X$(e){return!e||typeof e!="object"?!1:e instanceof Error||typeof DOMException<"u"&&e instanceof DOMException?!0:Object.prototype.toString.call(e)==="[object Error]"}function um(e){return typeof e=="object"&&e!==null&&e.resourceType==="OperationOutcome"}function kD(e){return e.id===PD||e.id===U$||e.id===V$||e.id===G$}function Z$(e){return e.id===B$}class ft extends Error{constructor(t,n){super(ND(t)),this.outcome=t,this.cause=n}}function qt(e){return e instanceof ft?e.outcome:um(e)?e:xo(Ye(e))}function Ye(e){return e?typeof e=="string"?e:X$(e)?e.message:um(e)?ND(e):typeof e=="object"&&"code"in e&&typeof e.code=="string"?e.code:JSON.stringify(e):"Unknown error"}function ND(e){const t=e.issue?.map(OD)??[];return t.length>0?t.join("; "):"Unknown error"}function OD(e){let t;return e.details?.text?e.diagnostics?t=`${e.details.text} (${e.diagnostics})`:t=e.details.text:e.diagnostics?t=e.diagnostics:t="Unknown error",e.expression?.length&&(t+=` (${e.expression.join(", ")})`),t}function J$(e,t){const n=t.max&&t.max===Number.MAX_SAFE_INTEGER?Number.POSITIVE_INFINITY:t.max;return{path:e,description:"",type:t.type??[],min:t.min??0,max:n??1,isArray:!!n&&n>1,constraints:[]}}function e8(e){const t=Object.create(null);for(const[n,r]of Object.entries(e))t[n]={name:n,type:n,path:n,elements:Object.fromEntries(Object.entries(r.elements).map(([o,l])=>[o,J$(o,l)])),constraints:[],innerTypes:[]};return t}const t8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]}}},n8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]}}},r8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},type:{type:[{code:"code"}]},text:{type:[{code:"string"}]},line:{max:9007199254740991,type:[{code:"string"}]},city:{type:[{code:"string"}]},district:{type:[{code:"string"}]},state:{type:[{code:"string"}]},postalCode:{type:[{code:"string"}]},country:{type:[{code:"string"}]},period:{type:[{code:"Period"}]}}},i8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},o8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},"author[x]":{type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Organization"]},{code:"string"}]},time:{type:[{code:"dateTime"}]},text:{min:1,type:[{code:"markdown"}]}}},a8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},contentType:{type:[{code:"code"}]},language:{type:[{code:"code"}]},data:{type:[{code:"base64Binary"}]},url:{type:[{code:"url"}]},size:{type:[{code:"unsignedInt"}]},hash:{type:[{code:"base64Binary"}]},title:{type:[{code:"string"}]},creation:{type:[{code:"dateTime"}]}}},s8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},coding:{max:9007199254740991,type:[{code:"Coding"}]},text:{type:[{code:"string"}]}}},l8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},system:{type:[{code:"uri"}]},version:{type:[{code:"string"}]},code:{type:[{code:"code"}]},display:{type:[{code:"string"}]},userSelected:{type:[{code:"boolean"}]}}},c8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},name:{type:[{code:"string"}]},telecom:{max:9007199254740991,type:[{code:"ContactPoint"}]}}},u8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},system:{type:[{code:"code"}]},value:{type:[{code:"string"}]},use:{type:[{code:"code"}]},rank:{type:[{code:"positiveInt"}]},period:{type:[{code:"Period"}]}}},d8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},name:{min:1,type:[{code:"string"}]},contact:{max:9007199254740991,type:[{code:"ContactDetail"}]}}},f8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},h8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},"subject[x]":{type:[{code:"CodeableConcept"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Group"]}]},mustSupport:{max:9007199254740991,type:[{code:"string"}]},codeFilter:{max:9007199254740991,type:[{code:"DataRequirementCodeFilter"}]},dateFilter:{max:9007199254740991,type:[{code:"DataRequirementDateFilter"}]},limit:{type:[{code:"positiveInt"}]},sort:{max:9007199254740991,type:[{code:"DataRequirementSort"}]}}},p8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{type:[{code:"string"}]},searchParam:{type:[{code:"string"}]},valueSet:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]},code:{max:9007199254740991,type:[{code:"Coding"}]}}},m8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{type:[{code:"string"}]},searchParam:{type:[{code:"string"}]},"value[x]":{type:[{code:"dateTime"},{code:"Period"},{code:"Duration"}]}}},g8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},direction:{min:1,type:[{code:"code"}]}}},v8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},y8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},sequence:{type:[{code:"integer"}]},text:{type:[{code:"string"}]},additionalInstruction:{max:9007199254740991,type:[{code:"CodeableConcept"}]},patientInstruction:{type:[{code:"string"}]},timing:{type:[{code:"Timing"}]},"asNeeded[x]":{type:[{code:"boolean"},{code:"CodeableConcept"}]},site:{type:[{code:"CodeableConcept"}]},route:{type:[{code:"CodeableConcept"}]},method:{type:[{code:"CodeableConcept"}]},doseAndRate:{max:9007199254740991,type:[{code:"DosageDoseAndRate"}]},maxDosePerPeriod:{type:[{code:"Ratio"}]},maxDosePerAdministration:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},maxDosePerLifetime:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},x8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{type:[{code:"CodeableConcept"}]},"dose[x]":{type:[{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},"rate[x]":{type:[{code:"Ratio"},{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},b8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},S8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},representation:{max:9007199254740991,type:[{code:"code"}]},sliceName:{type:[{code:"string"}]},sliceIsConstraining:{type:[{code:"boolean"}]},label:{type:[{code:"string"}]},code:{max:9007199254740991,type:[{code:"Coding"}]},slicing:{type:[{code:"ElementDefinitionSlicing"}]},short:{type:[{code:"string"}]},definition:{type:[{code:"markdown"}]},comment:{type:[{code:"markdown"}]},requirements:{type:[{code:"markdown"}]},alias:{max:9007199254740991,type:[{code:"string"}]},min:{type:[{code:"unsignedInt"}]},max:{type:[{code:"string"}]},base:{type:[{code:"ElementDefinitionBase"}]},contentReference:{type:[{code:"uri"}]},type:{max:9007199254740991,type:[{code:"ElementDefinitionType"}]},"defaultValue[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},meaningWhenMissing:{type:[{code:"markdown"}]},orderMeaning:{type:[{code:"string"}]},"fixed[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},"pattern[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},example:{max:9007199254740991,type:[{code:"ElementDefinitionExample"}]},"minValue[x]":{type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},"maxValue[x]":{type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},maxLength:{type:[{code:"integer"}]},condition:{max:9007199254740991,type:[{code:"id"}]},constraint:{max:9007199254740991,type:[{code:"ElementDefinitionConstraint"}]},mustSupport:{type:[{code:"boolean"}]},isModifier:{type:[{code:"boolean"}]},isModifierReason:{type:[{code:"string"}]},isSummary:{type:[{code:"boolean"}]},binding:{type:[{code:"ElementDefinitionBinding"}]},mapping:{max:9007199254740991,type:[{code:"ElementDefinitionMapping"}]}}},w8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},path:{min:1,type:[{code:"string"}]}}},j8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},discriminator:{max:9007199254740991,type:[{code:"ElementDefinitionSlicingDiscriminator"}]},description:{type:[{code:"string"}]},ordered:{type:[{code:"boolean"}]},rules:{min:1,type:[{code:"code"}]}}},C8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},min:{min:1,type:[{code:"unsignedInt"}]},max:{min:1,type:[{code:"string"}]}}},E8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},code:{min:1,type:[{code:"uri"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},targetProfile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},aggregation:{max:9007199254740991,type:[{code:"code"}]},versioning:{type:[{code:"code"}]}}},T8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},label:{min:1,type:[{code:"string"}]},"value[x]":{min:1,type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}}},R8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},key:{min:1,type:[{code:"id"}]},requirements:{type:[{code:"string"}]},severity:{min:1,type:[{code:"code"}]},human:{min:1,type:[{code:"string"}]},expression:{type:[{code:"string"}]},xpath:{type:[{code:"string"}]},source:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},_8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},strength:{min:1,type:[{code:"code"}]},description:{type:[{code:"string"}]},valueSet:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]}}},D8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},identity:{min:1,type:[{code:"id"}]},language:{type:[{code:"code"}]},map:{min:1,type:[{code:"string"}]},comment:{type:[{code:"string"}]}}},A8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},description:{type:[{code:"string"}]},name:{type:[{code:"id"}]},language:{min:1,type:[{code:"code"}]},expression:{type:[{code:"string"}]},reference:{type:[{code:"uri"}]}}},P8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},url:{min:1,type:[{code:"uri"}]},"value[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}}},k8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},text:{type:[{code:"string"}]},family:{type:[{code:"string"}]},given:{max:9007199254740991,type:[{code:"string"}]},prefix:{max:9007199254740991,type:[{code:"string"}]},suffix:{max:9007199254740991,type:[{code:"string"}]},period:{type:[{code:"Period"}]}}},N8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},type:{type:[{code:"CodeableConcept"}]},system:{type:[{code:"uri"}]},value:{type:[{code:"string"}]},period:{type:[{code:"Period"}]},assigner:{type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},O8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},country:{min:1,type:[{code:"CodeableConcept"}]},jurisdiction:{type:[{code:"CodeableConcept"}]},status:{min:1,type:[{code:"CodeableConcept"}]},dateRange:{min:1,type:[{code:"Period"}]},restoreDate:{type:[{code:"dateTime"}]}}},M8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},versionId:{type:[{code:"id"}]},lastUpdated:{type:[{code:"instant"}]},source:{type:[{code:"uri"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},security:{max:9007199254740991,type:[{code:"Coding"}]},tag:{max:9007199254740991,type:[{code:"Coding"}]},project:{type:[{code:"uri"}]},author:{type:[{code:"Reference"}]},onBehalfOf:{type:[{code:"Reference"}]},account:{type:[{code:"Reference"}]},accounts:{max:9007199254740991,type:[{code:"Reference"}]},compartment:{max:9007199254740991,type:[{code:"Reference"}]}}},L8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},currency:{type:[{code:"code"}]}}},I8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},status:{min:1,type:[{code:"code"}]},div:{min:1,type:[{code:"xhtml"}]}}},z8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},name:{type:[{code:"code"}]},use:{min:1,type:[{code:"code"}]},min:{type:[{code:"integer"}]},max:{type:[{code:"string"}]},documentation:{type:[{code:"string"}]},type:{min:1,type:[{code:"code"}]},profile:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},$8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},start:{type:[{code:"dateTime"}]},end:{type:[{code:"dateTime"}]}}},U8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},"age[x]":{type:[{code:"Range"},{code:"CodeableConcept"}]},gender:{type:[{code:"CodeableConcept"}]},race:{type:[{code:"CodeableConcept"}]},physiologicalCondition:{type:[{code:"CodeableConcept"}]}}},B8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},height:{type:[{code:"Quantity"}]},width:{type:[{code:"Quantity"}]},depth:{type:[{code:"Quantity"}]},weight:{type:[{code:"Quantity"}]},nominalVolume:{type:[{code:"Quantity"}]},externalDiameter:{type:[{code:"Quantity"}]},shape:{type:[{code:"string"}]},color:{max:9007199254740991,type:[{code:"string"}]},imprint:{max:9007199254740991,type:[{code:"string"}]},image:{max:9007199254740991,type:[{code:"Attachment"}]},scoring:{type:[{code:"CodeableConcept"}]}}},V8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},identifier:{type:[{code:"Identifier"}]},type:{min:1,type:[{code:"CodeableConcept"}]},period:{min:1,type:[{code:"Quantity"}]},specialPrecautionsForStorage:{max:9007199254740991,type:[{code:"CodeableConcept"}]}}},F8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},H8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},low:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},high:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},q8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},numerator:{type:[{code:"Quantity"}]},denominator:{type:[{code:"Quantity"}]}}},G8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},reference:{type:[{code:"string"}]},type:{type:[{code:"uri"}]},identifier:{type:[{code:"Identifier"}]},display:{type:[{code:"string"}]}}},Q8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},label:{type:[{code:"string"}]},display:{type:[{code:"string"}]},citation:{type:[{code:"markdown"}]},url:{type:[{code:"url"}]},document:{type:[{code:"Attachment"}]},resource:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/Resource"]}]}}},W8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},origin:{min:1,type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},period:{min:1,type:[{code:"decimal"}]},factor:{type:[{code:"decimal"}]},lowerLimit:{type:[{code:"decimal"}]},upperLimit:{type:[{code:"decimal"}]},dimensions:{min:1,type:[{code:"positiveInt"}]},data:{type:[{code:"string"}]}}},Y8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,max:9007199254740991,type:[{code:"Coding"}]},when:{min:1,type:[{code:"instant"}]},who:{min:1,type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},onBehalfOf:{type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},targetFormat:{type:[{code:"code"}]},sigFormat:{type:[{code:"code"}]},data:{type:[{code:"base64Binary"}]}}},K8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},"amount[x]":{type:[{code:"Quantity"},{code:"Range"},{code:"string"}]},amountType:{type:[{code:"CodeableConcept"}]},amountText:{type:[{code:"string"}]},referenceRange:{type:[{code:"SubstanceAmountReferenceRange"}]}}},X8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},lowLimit:{type:[{code:"Quantity"}]},highLimit:{type:[{code:"Quantity"}]}}},Z8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},event:{max:9007199254740991,type:[{code:"dateTime"}]},repeat:{type:[{code:"TimingRepeat"}]},code:{type:[{code:"CodeableConcept"}]}}},J8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},"bounds[x]":{type:[{code:"Duration"},{code:"Range"},{code:"Period"}]},count:{type:[{code:"positiveInt"}]},countMax:{type:[{code:"positiveInt"}]},duration:{type:[{code:"decimal"}]},durationMax:{type:[{code:"decimal"}]},durationUnit:{type:[{code:"code"}]},frequency:{type:[{code:"positiveInt"}]},frequencyMax:{type:[{code:"positiveInt"}]},period:{type:[{code:"decimal"}]},periodMax:{type:[{code:"decimal"}]},periodUnit:{type:[{code:"code"}]},dayOfWeek:{max:9007199254740991,type:[{code:"code"}]},timeOfDay:{max:9007199254740991,type:[{code:"time"}]},when:{max:9007199254740991,type:[{code:"code"}]},offset:{type:[{code:"unsignedInt"}]}}},eU={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},name:{type:[{code:"string"}]},"timing[x]":{type:[{code:"Timing"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Schedule"]},{code:"date"},{code:"dateTime"}]},data:{max:9007199254740991,type:[{code:"DataRequirement"}]},condition:{type:[{code:"Expression"}]}}},tU={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},code:{min:1,type:[{code:"Coding"}]},"value[x]":{min:1,type:[{code:"CodeableConcept"},{code:"Quantity"},{code:"Range"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/PlanDefinition","http://hl7.org/fhir/StructureDefinition/ResearchStudy","http://hl7.org/fhir/StructureDefinition/InsurancePlan","http://hl7.org/fhir/StructureDefinition/HealthcareService","http://hl7.org/fhir/StructureDefinition/Group","http://hl7.org/fhir/StructureDefinition/Location","http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},nU={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},rU={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{max:0,type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},iU={elements:{authorizeUrl:{min:1,type:[{code:"string"}]},tokenUrl:{min:1,type:[{code:"string"}]},tokenAuthMethod:{type:[{code:"code"}]},userInfoUrl:{min:1,type:[{code:"string"}]},clientId:{min:1,type:[{code:"string"}]},clientSecret:{min:1,type:[{code:"string"}]},usePkce:{type:[{code:"boolean"}]},useSubject:{type:[{code:"boolean"}]}}},oU={Element:t8,BackboneElement:n8,Address:r8,Age:i8,Annotation:o8,Attachment:a8,CodeableConcept:s8,Coding:l8,ContactDetail:c8,ContactPoint:u8,Contributor:d8,Count:f8,DataRequirement:h8,DataRequirementCodeFilter:p8,DataRequirementDateFilter:m8,DataRequirementSort:g8,Distance:v8,Dosage:y8,DosageDoseAndRate:x8,Duration:b8,ElementDefinition:S8,ElementDefinitionSlicingDiscriminator:w8,ElementDefinitionSlicing:j8,ElementDefinitionBase:C8,ElementDefinitionType:E8,ElementDefinitionExample:T8,ElementDefinitionConstraint:R8,ElementDefinitionBinding:_8,ElementDefinitionMapping:D8,Expression:A8,Extension:P8,HumanName:k8,Identifier:N8,MarketingStatus:O8,Meta:M8,Money:L8,Narrative:I8,ParameterDefinition:z8,Period:$8,Population:U8,ProdCharacteristic:B8,ProductShelfLife:V8,Quantity:F8,Range:H8,Ratio:q8,Reference:G8,RelatedArtifact:Q8,SampledData:W8,Signature:Y8,SubstanceAmount:K8,SubstanceAmountReferenceRange:X8,Timing:Z8,TimingRepeat:J8,TriggerDefinition:eU,UsageContext:tU,MoneyQuantity:nU,SimpleQuantity:rU,IdentityProvider:iU};function aU(e){return new lU(e).parse()}const np=e8(oU),gb=Object.create(null),OE=Object.create(null),sU={"http://hl7.org/fhir/StructureDefinition/MoneyQuantity":"MoneyQuantity","http://hl7.org/fhir/StructureDefinition/SimpleQuantity":"SimpleQuantity","http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/ViewDefinition":"ViewDefinition"};function MD(e){let t;return t=OE[e],t||(t=OE[e]=Object.create(null)),t}function ME(e){const n=(Array.isArray(e)?e:e.entry?.map(r=>r.resource)??[]).filter(r=>r?.resourceType==="StructureDefinition");ZU(n);for(const r of n)LD(r)}function LD(e){if(!e?.name)throw new Error("Failed loading StructureDefinition from bundle");if(e.resourceType!=="StructureDefinition")return;const t=aU(e),n=sU[e.url];let r,o;n?(r=np,o=n):e.url===`http://hl7.org/fhir/StructureDefinition/${e.type}`||e.url===`https://medplum.com/fhir/StructureDefinition/${e.type}`||e.type?.startsWith("http://")||e.type?.startsWith("https://")?(r=np,o=e.type):(r=MD(e.url),o=e.type),r[o]=t;for(const l of t.innerTypes)l.parentType=t,r[l.name]=l;gb[e.url]=t}function ID(e){return!!np[e]}function dm(e,t){if(t){const n=MD(t)[e];if(n)return n}return np[e]}function zD(e,t){const n=dm(e,t);if(!n)throw new ft(xo("Unknown data type: "+e));return n}function vb(e){return!!gb[e]}function Zc(e){return gb[e]}class lU{constructor(t){if(!t.snapshot?.element||t.snapshot.element.length===0)throw new Error(`No snapshot defined for StructureDefinition '${t.name}'`);this.root=t.snapshot.element[0],this.elements=t.snapshot.element.slice(1),this.elementIndex=Object.create(null),this.index=0,this.resourceSchema={name:t.name,path:this.root.path,title:t.title,type:t.type,url:t.url,version:t.version,kind:t.kind,description:dU(t),elements:{},constraints:this.parseElementDefinition(this.root).constraints,innerTypes:[],summaryProperties:new Set,mandatoryProperties:new Set},this.innerTypes=[]}parse(){let t=this.next();for(;t;){if(t.sliceName)this.parseSliceStart(t);else if(t.id?.includes(":")){if(this.slicingContext?.current){const n=vy(t,this.slicingContext.path);this.slicingContext.current.elements[n]=this.parseElementDefinition(t)}}else{const n=this.parseElementDefinition(t);this.checkFieldEnter(t,n);let r=this.backboneContext;for(;r;){if(t.path?.startsWith(r.path+".")){r.type.elements[vy(t,r.path)]=n;break}r=r.parent}if(!r){const o=vy(t,this.root.path);t.isSummary&&this.resourceSchema.summaryProperties?.add(o.replace("[x]","")),n.min>0&&this.resourceSchema.mandatoryProperties?.add(o.replace("[x]","")),this.resourceSchema.elements[o]=n}this.checkFieldExit(t)}t=this.next()}return this.checkFieldExit(),this.innerTypes.length>0&&(this.resourceSchema.innerTypes=this.innerTypes),this.resourceSchema}checkFieldEnter(t,n){this.isInnerType(t)&&this.enterInnerType(t),this.slicingContext&&!pc(this.slicingContext.path,t?.path)&&(this.slicingContext=void 0),t.slicing&&!this.slicingContext&&this.enterSlice(t,n)}enterInnerType(t){for(;this.backboneContext&&!pc(this.backboneContext?.path,t.path);)this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;const n=FE(t);this.backboneContext={type:{name:n,type:n,path:t.path,title:t.label,description:t.definition,elements:{},constraints:this.parseElementDefinition(t).constraints,innerTypes:[]},path:t.path,parent:pc(this.backboneContext?.path,t.path)?this.backboneContext:this.backboneContext?.parent}}enterSlice(t,n){uU(t)&&!this.peek()?.sliceName||(n.slicing={discriminator:(t.slicing?.discriminator??[]).map(r=>{if(r.type!=="value"&&r.type!=="pattern"&&r.type!=="type")throw new Error(`Unsupported slicing discriminator type: ${r.type}`);return{path:r.path,type:r.type}}),slices:[],ordered:t.slicing?.ordered??!1,rule:t.slicing?.rules},this.slicingContext={field:n.slicing,path:t.path??""})}checkFieldExit(t=void 0){if(this.backboneContext&&!pc(this.backboneContext.path,t?.path))if(this.backboneContext.parent)do this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;while(this.backboneContext&&!pc(this.backboneContext.path,t?.path));else this.innerTypes.push(this.backboneContext.type),this.backboneContext=void 0}next(){const t=this.peek();if(t)return this.index++,t}peek(){const t=this.elements[this.index];if(t){if(this.elementIndex[t.path??""]=t,t.contentReference){const n=t.contentReference.slice(t.contentReference.indexOf("#")+1),r=this.elementIndex[n];return r?{...r,id:t.id,path:t.path,min:t.min??r.min,max:t.max??r.max,base:{path:r.base?.path??n,min:t.base?.min??r.base?.min??r.min,max:t.base?.max??r.base?.max??r.max},contentReference:t.contentReference,definition:t.definition}:void 0}return t}}isInnerType(t){const n=this.peek();return!!(pc(t?.path,n?.path)&&t.type?.some(r=>["BackboneElement","Element"].includes(r.code)))}parseSliceStart(t){if(!this.slicingContext)throw new Error(`Invalid slice start before discriminator: ${t.sliceName} (${t.id})`);this.slicingContext.current={...this.parseElementDefinition(t),name:t.sliceName??"",definition:t.definition,elements:{}},this.slicingContext.field.slices.push(this.slicingContext.current)}parseElementDefinitionType(t){return(t.type??[]).map(n=>{let r;return(n.code==="BackboneElement"||n.code==="Element")&&(r=FE(t)),r||(r=Do(n,"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type")?.valueUrl),r||(r=n.code??""),{code:r,targetProfile:n.targetProfile,profile:n.profile}})}parseElementDefinition(t){const n=LE(t.max),r=t.base?.max?LE(t.base.max):n,o={type:"ElementDefinition",value:t};return{description:t.definition||"",path:t.path||t.base?.path||"",min:t.min??0,max:n,isArray:r>1,constraints:(t.constraint??[]).map(l=>({key:l.key??"",severity:l.severity??"error",expression:l.expression??"",description:l.human??""})),type:this.parseElementDefinitionType(t),fixed:IE(Lc(o,"fixed[x]")),pattern:IE(Lc(o,"pattern[x]")),binding:t.binding}}}function LE(e){return e==="*"?Number.POSITIVE_INFINITY:Number.parseInt(e,10)}function vy(e,t=""){return cU(e.path,t)}function cU(e,t){return e?t&&e.startsWith(t)?e.substring(t.length+1):e:""}function pc(e,t){return!e||!t?!1:t.startsWith(e+".")||t===e}function IE(e){return Array.isArray(e)&&e.length>0?e[0]:vn(e)?void 0:e}function uU(e){const t=e.slicing?.discriminator;return!!(e.type?.some(n=>n.code==="Extension")&&t?.length===1&&t[0].type==="value"&&t[0].path==="url")}function dU(e){let t=e.description;return t?.startsWith(`Base StructureDefinition for ${e.name} Type: `)&&(t=t.substring(`Base StructureDefinition for ${e.name} Type: `.length)),t}function fU(e,t,n){if(e===void 0)return[void 0];if(t==="$this")return[e];const r=n?.withPath?hU:Lc,[o,...l]=t.split(".");let c=[r(e,o,n)];for(const d of l){const f=[];for(const p of c)if(Array.isArray(p))for(const m of p)f.push(r(m,d,n));else(n?.withPath&&p&&p.value!==void 0||!n?.withPath&&p!==void 0)&&f.push(r(p,d,n));c=f}return c}function hU(e,t,n){const r=e.path;return pU(Lc(e,t,n),r,t)}function pU(e,t,n){const r=t?t+".":"";return e===void 0?{type:"undefined",value:void 0,path:`${r}${n}`}:Array.isArray(e)?e.map((o,l)=>({...o,path:`${r}${n}[${l}]`})):{...e,path:`${r}${n}`}}const $D={date:/^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1]))?)?$/,dateTime:/^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1])(T([01]\d|2[0-3])(:[0-5]\d:([0-5]\d|60)(\.\d{1,9})?)?)?)?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00)?)?)?$/};function mU(e,t,n,r){if(Array.isArray(e))return!1;let o;t.path==="$this"?o=n:o=(r??n.elements)[t.path];const l=n.type;switch(t.type){case"value":case"pattern":if(!e||!o)return!1;if(o.pattern)return bb(e,o.pattern);if(o.fixed)return Co(e,o.fixed);if(o.binding?.strength==="required"&&o.binding.valueSet)return!0;break;case"type":return!e||!l?.length?!1:l.some(c=>c.code===e.type)}return!1}function tt(e){return[{type:re.boolean,value:e}]}function ri(e){return e==null?{type:"undefined",value:void 0}:Number.isSafeInteger(e)?{type:re.integer,value:e}:typeof e=="number"?{type:re.decimal,value:e}:typeof e=="boolean"?{type:re.boolean,value:e}:typeof e=="string"?{type:re.string,value:e}:Ei(e)?{type:re.Quantity,value:e}:Ao(e)?{type:e.resourceType,value:e}:ZD(e)?{type:re.CodeableConcept,value:e}:XD(e)?{type:re.Coding,value:e}:{type:re.BackboneElement,value:e}}function go(e){return e.length===0?!1:!!e[0].value}function ua(e,t){if(e.length!==0){if(e.length===1&&(!t||e[0].type===t))return e[0];throw new Error(`Expected singleton of type ${t}, but found ${JSON.stringify(e)}`)}}function Lc(e,t,n){if(!e.value)return;const r=ms(e.type,t,n?.profileUrl);return r?UD(e,t,r):Fd(e,t)}function UD(e,t,n){const r=e.value,o=n.type;if(!o||o.length===0)return;let l,c="undefined",d;const f=n.path.lastIndexOf("."),p=n.path.substring(f+1);for(const m of o){const g=p.replace("[x]",$n(m.code));if(l=r[g],d=r["_"+g],l!==void 0||d!==void 0){c=m.code;break}}if(d)if(Array.isArray(l)){l=l.slice();for(let m=0;m<Math.max(l.length,d.length);m++)l[m]=yy(l[m],d[m])}else if(!l&&Array.isArray(d)){l=d.slice();for(let m=0;m<d.length;m++)l[m]=yy(void 0,d[m])}else l=yy(l,d);if(!vn(l))return(c==="Element"||c==="BackboneElement")&&(c=n.type[0].code),Array.isArray(l)?l.map(m=>zE(m,c)):zE(l,c)}function zE(e,t){return t==="Resource"&&Ao(e)&&(t=e.resourceType),{type:t,value:e}}function Fd(e,t){const n=e.value;if(!n||typeof n!="object")return;let r;if(t in n){const o=n[t];Array.isArray(o)?r=o.map(ri):r=ri(o)}else{const o=t.endsWith("[x]")?t.substring(0,t.length-3):t;for(const l of Object.values(re)){const c=o+$n(l);if(c in n){const d=n[c];Array.isArray(d)?r=d.map(f=>({type:l,value:f})):r={type:l,value:d};break}}}if(Array.isArray(r)){if(r.length===0||vn(r[0]))return}else if(vn(r))return;return r}function BD(e){const t=[];for(const n of e){let r=!1;for(const o of t)if(go(fm(n,o))){r=!0;break}r||t.push(n)}return t}function gU(e){return tt(!go(e))}function vU(e,t){return e.length===0||t.length===0?[]:e.length!==t.length?tt(!1):tt(e.every((n,r)=>go(fm(n,t[r]))))}function yU(e,t){return e.length===0||t.length===0?[]:e.length!==t.length?tt(!0):tt(e.some((n,r)=>!go(fm(n,t[r]))))}function fm(e,t){const n=e.value?.valueOf(),r=t.value?.valueOf();return typeof n=="number"&&typeof r=="number"?tt(Math.abs(n-r)<1e-8):Ei(n)&&Ei(r)?tt(QD(n,r)):tt(typeof n=="object"&&typeof r=="object"?yb(e,t):n===r)}function VD(e,t){return e.length===0&&t.length===0?tt(!0):e.length!==t.length?tt(!1):(e.sort($E),t.sort($E),tt(e.every((n,r)=>go(xU(n,t[r])))))}function xU(e,t){const{type:n,value:r}=e,{type:o,value:l}=t,c=r?.valueOf(),d=l?.valueOf();return typeof c=="number"&&typeof d=="number"?tt(Math.abs(c-d)<.01):Ei(c)&&Ei(d)?tt(QD(c,d)):tt(n==="Coding"&&o==="Coding"?typeof c!="object"||typeof d!="object"?!1:c.code===d.code&&c.system===d.system:typeof c=="object"&&typeof d=="object"?yb({...c,id:void 0},{...d,id:void 0}):typeof c=="string"&&typeof d=="string"?c.toLowerCase()===d.toLowerCase():c===d)}function $E(e,t){const n=e.value?.valueOf(),r=t.value?.valueOf();return typeof n=="number"&&typeof r=="number"?n-r:typeof n=="string"&&typeof r=="string"?n.localeCompare(r):0}function FD(e,t){const{value:n}=e;if(n==null)return!1;let r=t;switch(r.startsWith("System.")&&(r=r.substring(7)),r.startsWith("FHIR.")&&(r=r.substring(5)),r){case"Boolean":return typeof n=="boolean";case"Decimal":case"Integer":return typeof n=="number";case"Date":return HD(n);case"DateTime":return pd(n);case"Time":return typeof n=="string"&&!!/^T\d/.exec(n);case"Period":return qD(n);case"Quantity":return Ei(n);default:return e.type===r||typeof n=="object"&&n?.resourceType===r}}function HD(e){return typeof e=="string"&&!!$D.date.exec(e)}function pd(e){return typeof e=="string"&&!!$D.dateTime.exec(e)}function qD(e){return!!(e&&typeof e=="object"&&("start"in e&&pd(e.start)||"end"in e&&pd(e.end)))}function GD(e){if(e){if(HD(e)||pd(e))return{start:bh(e,"0000-01-01T00:00:00.000"),end:bh(e,"xxxx-12-31T23:59:59.999")};if(qD(e))return{start:e.start?bh(e.start,"0000-01-01T00:00:00.000"):void 0,end:e.end?bh(e.end,"xxxx-12-31T23:59:59.999"):void 0}}}function bh(e,t){let n="Z";const r=Math.max(e.indexOf("+",10),e.indexOf("-",10));r>-1?(n=e.substring(r),e=e.substring(0,r)):e.endsWith("Z")&&(e=e.substring(0,e.length-1));const o=e+t.substring(e.length)+n;return new Date(o).toISOString()}function Ei(e){return!!(e&&typeof e=="object"&&"value"in e&&typeof e.value=="number")}function QD(e,t){return Math.abs(e.value-t.value)<.01&&(e.unit===t.unit||e.code===t.code||e.unit===t.code||e.code===t.unit)}function yb(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const l=e[o],c=t[o];if(UE(l)&&UE(c)){if(!yb(l,c))return!1}else if(l!==c)return!1}return!0}function UE(e){return e!==null&&typeof e=="object"}function yy(e,t){if(t){if(typeof t!="object")throw new Error("Primitive extension must be an object");return bU(e??{},t)}return e}function bU(e,t){return delete t.__proto__,delete t.constructor,Object.assign(e,t)}function WD(e,t){return Ao(e,t)&&"id"in e&&typeof e.id=="string"}function Ht(e){const t=_t(e)??"undefined/undefined",n=da(e);return n===t?{reference:t}:{reference:t,display:n}}function _t(e){if(wa(e))return e.reference;if(WD(e))return`${e.resourceType}/${e.id}`}function rl(e){if(e)return wa(e)?e.reference.split("/")[1]:e.id}function SU(e){return e.resourceType==="Patient"||e.resourceType==="Practitioner"||e.resourceType==="RelatedPerson"}function da(e){if(SU(e)){const t=wU(e);if(t)return t}if(e.resourceType==="Device"){const t=jU(e);if(t)return t}if(e.resourceType==="MedicationRequest"&&e.medicationCodeableConcept)return ls(e.medicationCodeableConcept);if(e.resourceType==="Subscription"&&e.criteria)return e.criteria;if(e.resourceType==="User"&&e.email)return e.email;if("name"in e&&e.name&&typeof e.name=="string")return e.name;if("code"in e&&e.code){let t=e.code;if(Array.isArray(t)&&(t=t[0]),ZD(t))return ls(t);if(OU(t))return t.text}return _t(e)??""}function wU(e){const t=e.name;if(t&&t.length>0)return Jc(t[0])}function jU(e){const t=e.deviceName;if(t&&t.length>0)return t[0].name}function CU(e){if(!("photo"in e))return;const t=e.photo;if(t)if(Array.isArray(t))for(const n of t){const r=BE(n);if(r)return r}else return BE(t)}function BE(e){if(e.url&&e.contentType?.startsWith("image/"))return e.url}function YD(e,t){const n=new Date(e);n.setUTCHours(0,0,0,0);const r=t?new Date(t):new Date;r.setUTCHours(0,0,0,0);const o=n.getUTCFullYear(),l=n.getUTCMonth(),c=n.getUTCDate(),d=r.getUTCFullYear(),f=r.getUTCMonth(),p=r.getUTCDate();let m=d-o;(f<l||f===l&&p<c)&&m--;let g=d*12+f-(o*12+l);p<c&&g--;const x=Math.floor((r.getTime()-n.getTime())/(1e3*60*60*24));return{years:m,months:g,days:x}}function EU(e,t){const{years:n,months:r,days:o}=YD(e,t);return n>=2?n.toString().padStart(3,"0")+"Y":r>=1?r.toString().padStart(3,"0")+"M":o.toString().padStart(3,"0")+"D"}function Do(e,...t){let n=e;for(let r=0;r<t.length&&n;r++)n=n?.extension?.find(o=>o.url===t[r]);return n}function Ki(e,t){const n=xb(e);return JSON.stringify(n,null,t?2:void 0)??""}function xb(e){if(!(e==null||e===""))return typeof e=="object"?Array.isArray(e)?TU(e):RU(e):e}function TU(e){const t=e.length;if(t===0)return;let n,r=0;for(let o=0;o<t;o++){const l=e[o],c=xb(l);c!==l&&!n&&(n=Array.from(e)),c===void 0?n&&(n[o]=null):(n&&(n[o]=c),r++)}if(r!==0)return n??e}function RU(e){let t,n=0;for(const r in e){const o=e[r],l=xb(o);l!==o&&!t&&(t={...e}),l===void 0?t&&delete t[r]:(t&&(t[r]=l),n++)}if(n!==0)return t??e}function vn(e){if(e==null)return!0;const t=typeof e;return t==="string"||t==="object"?!Rn(e):!1}function Rn(e){if(e==null)return!1;const t=typeof e;return t==="string"&&e!==""||t==="object"&&("length"in e&&e.length>0||Object.keys(e).length>0)}function _U(e){if(!e)return;let t=e.length-1;for(;t>=0&&vn(e[t]);)t--;return t>=0?e.slice(0,t+1):void 0}function Co(e,t,n){return e===t||vn(e)&&vn(t)?!0:vn(e)||vn(t)?!1:Array.isArray(e)&&Array.isArray(t)?DU(e,t):Array.isArray(e)||Array.isArray(t)?!1:pr(e)&&pr(t)?AU(e,t,n):(pr(e)||pr(t),!1)}function DU(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Co(e[n],t[n]))return!1;return!0}function AU(e,t,n){const r=new Set;Object.keys(e).forEach(o=>r.add(o)),Object.keys(t).forEach(o=>r.add(o)),n==="meta"&&(r.delete("versionId"),r.delete("lastUpdated"),r.delete("author"));for(const o of r){const l=e[o],c=t[o];if(!Co(l,c,o))return!1}return!0}function bb(e,t){return vn(e)?!0:vn(t)?!1:Array.isArray(e)&&Array.isArray(t)?PU(e,t):Array.isArray(e)||Array.isArray(t)?!1:pr(e)&&pr(t)?kU(e,t):pr(e)||pr(t)?!1:e===t}function PU(e,t){return t.every(n=>e.some(r=>bb(r,n)))}function kU(e,t){return Object.entries(t).every(([n,r])=>n in e&&bb(e[n],r))}function ii(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function KD(e){return/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i.test(e)}function pr(e){return e!==null&&typeof e=="object"}function NU(e){return typeof e=="string"}function XD(e){return pr(e)&&"code"in e&&typeof e.code=="string"}function ZD(e){return pr(e)&&"coding"in e&&Array.isArray(e.coding)&&e.coding.every(XD)}function OU(e){return pr(e)&&"text"in e&&typeof e.text=="string"}const JD=[];for(let e=0;e<256;e++)JD.push(e.toString(16).padStart(2,"0"));function MU(e){const t=eA(e),n=new Uint8Array(t),r=new Array(n.length);for(let o=0;o<n.length;o++)r[o]=JD[n[o]];return r.join("")}function LU(e){const t=eA(e),n=new Uint8Array(t),r=new Array(n.length);for(let o=0;o<n.length;o++)r[o]=String.fromCharCode(n[o]);return window.btoa(r.join(""))}function eA(e){return ArrayBuffer.isView(e)?e.buffer:e}function $n(e){return e?e.charAt(0).toUpperCase()+e.substring(1):""}function Sb(e){return e.length>0&&e.startsWith(e[0].toUpperCase())}function Ys(e,t){const n=e+".";if(t.startsWith(n))return t.slice(n.length)}function IU(e,t){return e.coding?.find(n=>n.system===t)?.code}function zU(e){if(e!==void 0)return Array.isArray(e)?e:[e]}const VE=e=>new Promise(t=>{setTimeout(t,e)});function lx(e,t,n){const r=[];for(let o=0;o<n-1;o++){const l=e.indexOf(t);if(l<0)break;r.push(e.slice(0,l)),e=e.slice(l+t.length)}return r.push(e),r}function $U(e){let t,n=!1;return function(){return n||(t=e(),n=!0),t}}function Wu(e,t){return e?(e.push(t),e):[t]}function Ic(e){return e.sort((t,n)=>t.localeCompare(n))}function wb(e){return e.endsWith("/")?e:e+"/"}function UU(e){return e.startsWith("/")?e.slice(1):e}function fo(e,t){return new URL(UU(t),wb(e.toString())).toString()}function BU(e,t){return fo(e,t).toString().replace("http://","ws://").replace("https://","wss://")}function VU(e){return typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)&&(e=Object.fromEntries(Object.entries(e).filter(t=>t[1]!==void 0))),new URLSearchParams(e).toString()}function tA(e,t){return e?.meta?.profile?.includes(t)||(e.meta=e.meta??{},e.meta.profile=e.meta.profile??[],e.meta.profile.push(t)),e}function FU(e,t){if(e?.meta?.profile?.includes(t)){const n=e.meta.profile.indexOf(t);e.meta.profile.splice(n,1)}return e}function il(e){if(!e)return"";switch(e.type){case"Address":return nA(e.value);case"CodeableConcept":return ls(e.value);case"Coding":return Hd(e.value);case"ContactPoint":return e.value.value;case"HumanName":return Jc(e.value);case"Quantity":return Ks(e.value);case"Reference":return HU(e.value);default:return e.value?.toString()??""}}function HU(e){return e?e.display??e.reference??Ki(e):""}function nA(e,t){if(!e)return"";const n=[];if(e.line&&n.push(...e.line),e.city||e.state||e.postalCode){const r=[];e.city&&r.push(e.city),e.state&&r.push(e.state),e.postalCode&&r.push(e.postalCode),n.push(r.join(", "))}return e.use&&t?.use,n.join(", ").trim()}function Jc(e,t){if(!e)return"";const n=[];if(e.prefix&&t?.prefix!==!1&&n.push(...e.prefix),e.given&&n.push(...e.given),e.family&&n.push(e.family),e.suffix&&t?.suffix!==!1&&n.push(...e.suffix),e.use&&(t?.all||t?.use)&&n.push("["+e.use+"]"),n.length===0){const r=gd(e.text);if(r)return r}return n.join(" ").trim()}function hm(e){return e instanceof Date&&!isNaN(e.getTime())}function qU(e,t,n){if(!e)return"";const r=new Date("2000-01-01T"+e+"Z");return hm(r)?r.toLocaleTimeString(t,n):""}function mr(e,t,n){if(!e)return"";const r=new Date(e);return hm(r)?r.toLocaleString(t,n):""}function GU(e,t,n){return!e||!e.start&&!e.end?"":mr(e.start,t,n)+" - "+mr(e.end,t,n)}const QU={s:"every second",min:"every minute",h:"hourly",d:"daily",wk:"weekly",mo:"monthly",a:"annually"},WU={s:"second",min:"minute",h:"hour",d:"day",wk:"week",mo:"month",a:"year"},YU={s:"seconds",min:"minutes",h:"hours",d:"days",wk:"weeks",mo:"months",a:"years"};function rA(e){if(!e)return"";const t=[];return KU(t,e.repeat),e.event&&t.push(e.event.map(n=>mr(n)).join(", ")),$n(t.join(" ").trim())}function KU(e,t){if(!t?.periodUnit)return;const n=t.frequency??1,r=t.period??1,o=t.periodUnit;n===1&&r===1?e.push(QU[o]):(n===1?e.push("once"):e.push(n+" times"),r===1?e.push("per "+WU[o]):e.push("per "+r+" "+YU[o])),t.dayOfWeek&&e.push("on "+t.dayOfWeek.map($n).join(", ")),t.timeOfDay&&e.push("at "+t.timeOfDay.map(l=>qU(l)).join(", "))}function md(e,t,n=!1){if(n&&t===void 0)throw new Error("Precision must be specified for exclusive ranges");const r=e?.low&&{...e.low,comparator:void 0},o=e?.high&&{...e.high,comparator:void 0};return r?.value===void 0&&o?.value===void 0?"":r?.value!==void 0&&o?.value===void 0?`>= ${Ks(r)}`:r?.value===void 0&&o?.value!==void 0?`<= ${Ks(o)}`:(r?.unit===o?.unit&&delete r?.unit,`${Ks(r)} - ${Ks(o)}`)}function Ks(e,t){if(!e)return"";const n=[];return e.comparator&&(n.push(e.comparator),n.push(" ")),e.value!==void 0&&n.push(e.value),e.unit&&(e.unit!=="%"&&n[n.length-1]!==" "&&n.push(" "),n.push(e.unit)),n.join("").trim()}function XU(e){return e?.value===void 0?"":e.value.toLocaleString(void 0,{style:"currency",currency:e.currency??"USD",currencyDisplay:"narrowSymbol"})}function ls(e){if(!e)return"";const t=gd(e.text);return t||(e.coding?e.coding.map(n=>Hd(n)).join(", "):"")}function Hd(e,t){const n=gd(e?.display);return n?`${n}`:gd(e?.code)??""}function iA(e){if(!e)return"";const t=[];if(e.valueQuantity)t.push(Ks(e.valueQuantity));else if(e.valueCodeableConcept)t.push(ls(e.valueCodeableConcept));else{const n=gd(e.valueString);n&&t.push(n)}return"component"in e&&t.push(e.component.map(n=>iA(n)).join(" / ")),t.join(" / ").trim()}function gd(e){return typeof e=="string"?e:void 0}const re={Address:"Address",Age:"Age",Annotation:"Annotation",Attachment:"Attachment",BackboneElement:"BackboneElement",CodeableConcept:"CodeableConcept",Coding:"Coding",ContactDetail:"ContactDetail",ContactPoint:"ContactPoint",Contributor:"Contributor",Count:"Count",DataRequirement:"DataRequirement",Distance:"Distance",Dosage:"Dosage",Duration:"Duration",Expression:"Expression",Extension:"Extension",HumanName:"HumanName",Identifier:"Identifier",MarketingStatus:"MarketingStatus",Meta:"Meta",Money:"Money",Narrative:"Narrative",ParameterDefinition:"ParameterDefinition",Period:"Period",Population:"Population",ProdCharacteristic:"ProdCharacteristic",ProductShelfLife:"ProductShelfLife",Quantity:"Quantity",Range:"Range",Ratio:"Ratio",Reference:"Reference",RelatedArtifact:"RelatedArtifact",SampledData:"SampledData",Signature:"Signature",SubstanceAmount:"SubstanceAmount",SystemString:"http://hl7.org/fhirpath/System.String",Timing:"Timing",TriggerDefinition:"TriggerDefinition",UsageContext:"UsageContext",base64Binary:"base64Binary",boolean:"boolean",canonical:"canonical",code:"code",date:"date",dateTime:"dateTime",decimal:"decimal",id:"id",instant:"instant",integer:"integer",markdown:"markdown",oid:"oid",positiveInt:"positiveInt",string:"string",time:"time",unsignedInt:"unsignedInt",uri:"uri",url:"url",uuid:"uuid"};function ZU(e){const t=Array.isArray(e)?e:e.entry?.map(n=>n.resource)??[];for(const n of t)n?.resourceType==="StructureDefinition"&&n.kind==="resource"&&oA(n.type)}function oA(e){let t=Eo.types[e];return t||(t={searchParamsDetails:{}},Eo.types[e]=t),!t.searchParams&&e!=="Binary"&&(t.searchParams={_id:{base:[e],code:"_id",type:"token",expression:e+".id"},_lastUpdated:{base:[e],code:"_lastUpdated",type:"date",expression:e+".meta.lastUpdated"},_compartment:{base:[e],code:"_compartment",type:"reference",expression:e+".meta.compartment"},_profile:{base:[e],code:"_profile",type:"uri",expression:e+".meta.profile"},_security:{base:[e],code:"_security",type:"token",expression:e+".meta.security"},_source:{base:[e],code:"_source",type:"uri",expression:e+".meta.source"},_tag:{base:[e],code:"_tag",type:"token",expression:e+".meta.tag"}}),t}function JU(e){for(const t of e.base??[]){const n=oA(t);n.searchParams||(n.searchParams={}),n.searchParams[e.code]=e}}function FE(e){const t=e.type?.[0]?.code;return t==="BackboneElement"||t==="Element"?eB((e.base?.path??e.path)?.split(".")):t}function eB(e){return e.length===1?e[0]:e.map($n).join("")}function jb(e){return Eo.types[e]?.searchParams}function tB(e,t){return Eo.types[e]?.searchParams?.[t]}function ol(e){const t=e.replaceAll("[x]","").split(".").pop();return aA(t)}function aA(e){let t;return e.length<100?t=e.match(/[A-Z]+(?![a-z])|[A-Z]?[a-z]+|\d+/g)??[]:t=e.split(/(?=[A-Z])/),t.map(rB).join(" ").replace("_"," ").replace(/\s+/g," ")}const nB=new Set(["ID","IP","PKCE","JWKS","URI","URL","OMB","UDI"]);function rB(e){const t=e.toUpperCase();return e===t?e:nB.has(t)?t:t.charAt(0)+e.slice(1)}function ms(e,t,n){const r=dm(e,n);if(r)return iB(r.elements,t)}function iB(e,t){const n=e[t]??e[t+"[x]"];if(n)return n;for(let r=0;r<t.length;r++){const o=t[r];if(o>="A"&&o<="Z"){const l=t.slice(0,r)+"[x]",c=e[l];if(c)return c}}}function Ao(e,t){return!(!e||typeof e!="object"||!("resourceType"in e)||t&&e.resourceType!==t)}function wa(e,t){return!!(e&&typeof e=="object"&&"reference"in e&&typeof e.reference=="string")}const Eo={types:{}};function Ih(e){if(e.startsWith("T"))return e+"T00:00:00.000Z".substring(e.length);if(e.length<=10)return e;try{return new Date(e).toISOString()}catch{return e}}const Jo=()=>[],zr={empty:(e,t)=>tt(t.length===0||t.every(n=>vn(n.value))),hasValue:(e,t)=>tt(t.length!==0),exists:(e,t,n)=>tt(n?t.filter(r=>go(n.eval(e,[r]))).length>0:t.length>0&&t.every(r=>!vn(r.value))),all:(e,t,n)=>tt(t.every(r=>go(n.eval(e,[r])))),allTrue:(e,t)=>{for(const n of t)if(!n.value)return tt(!1);return tt(!0)},anyTrue:(e,t)=>{for(const n of t)if(n.value)return tt(!0);return tt(!1)},allFalse:(e,t)=>{for(const n of t)if(n.value)return tt(!1);return tt(!0)},anyFalse:(e,t)=>{for(const n of t)if(!n.value)return tt(!0);return tt(!1)},subsetOf:(e,t,n)=>{if(t.length===0)return tt(!0);const r=n.eval(e,zs(e));return r.length===0?tt(!1):tt(t.every(o=>r.some(l=>l.value===o.value)))},supersetOf:(e,t,n)=>{const r=n.eval(e,zs(e));return r.length===0?tt(!0):t.length===0?tt(!1):tt(r.every(o=>t.some(l=>l.value===o.value)))},count:(e,t)=>[{type:re.integer,value:t.length}],distinct:(e,t)=>{const n=[];for(const r of t)n.some(o=>o.value===r.value)||n.push(r);return n},isDistinct:(e,t)=>tt(t.length===zr.distinct(e,t).length),where:(e,t,n)=>t.filter(r=>go(n.eval(e,[r]))),select:(e,t,n)=>t.map(r=>n.eval({parent:e,variables:{$this:r}},[r])).flat(),repeat:Jo,ofType:(e,t,n)=>t.filter(r=>r.type===n.name),single:(e,t)=>{if(t.length>1)throw new Error("Expected input length one for single()");return t.length===0?[]:t.slice(0,1)},first:(e,t)=>t.length===0?[]:t.slice(0,1),last:(e,t)=>t.length===0?[]:t.slice(t.length-1,t.length),tail:(e,t)=>t.length===0?[]:t.slice(1,t.length),skip:(e,t,n)=>{const r=n.eval(e,t)[0]?.value;if(typeof r!="number")throw new Error("Expected a number for skip(num)");return r>=t.length?[]:r<=0?t:t.slice(r,t.length)},take:(e,t,n)=>{const r=n.eval(e,t)[0]?.value;if(typeof r!="number")throw new Error("Expected a number for take(num)");return r>=t.length?t:r<=0?[]:t.slice(0,r)},intersect:(e,t,n)=>{if(!n)return t;const r=n.eval(e,zs(e)),o=[];for(const l of t)!o.some(c=>c.value===l.value)&&r.some(c=>c.value===l.value)&&o.push(l);return o},exclude:(e,t,n)=>{if(!n)return t;const r=n.eval(e,zs(e)),o=[];for(const l of t)r.some(c=>c.value===l.value)||o.push(l);return o},union:(e,t,n)=>{if(!n)return t;const r=n.eval(e,zs(e));return BD([...t,...r])},combine:(e,t,n)=>{if(!n)return t;const r=n.eval(e,zs(e));return[...t,...r]},htmlChecks:(e,t,n)=>[ri(!0)],iif:(e,t,n,r,o)=>{const l=n.eval(e,t);if(l.length>1||l.length===1&&typeof l[0].value!="boolean")throw new Error("Expected criterion to evaluate to a Boolean");return go(l)?r.eval(e,t):o?o.eval(e,t):[]},toBoolean:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);if(typeof n=="boolean")return[{type:re.boolean,value:n}];if(typeof n=="number"&&(n===0||n===1))return tt(!!n);if(typeof n=="string"){const r=n.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(r))return tt(!0);if(["false","f","no","n","0","0.0"].includes(r))return tt(!1)}return[]},convertsToBoolean:(e,t)=>t.length===0?[]:tt(zr.toBoolean(e,t).length===1),toInteger:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);return typeof n=="number"?[{type:re.integer,value:n}]:typeof n=="string"&&/^[+-]?\d+$/.exec(n)?[{type:re.integer,value:parseInt(n,10)}]:typeof n=="boolean"?[{type:re.integer,value:n?1:0}]:[]},convertsToInteger:(e,t)=>t.length===0?[]:tt(zr.toInteger(e,t).length===1),toDate:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);return typeof n=="string"&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:re.date,value:Ih(n)}]:[]},convertsToDate:(e,t)=>t.length===0?[]:tt(zr.toDate(e,t).length===1),toDateTime:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);return typeof n=="string"&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:re.dateTime,value:Ih(n)}]:[]},convertsToDateTime:(e,t)=>t.length===0?[]:tt(zr.toDateTime(e,t).length===1),toDecimal:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);return typeof n=="number"?[{type:re.decimal,value:n}]:typeof n=="string"&&/^-?\d{1,9}(\.\d{1,9})?$/.exec(n)?[{type:re.decimal,value:parseFloat(n)}]:typeof n=="boolean"?[{type:re.decimal,value:n?1:0}]:[]},convertsToDecimal:(e,t)=>t.length===0?[]:tt(zr.toDecimal(e,t).length===1),toQuantity:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);return Ei(n)?[{type:re.Quantity,value:n}]:typeof n=="number"?[{type:re.Quantity,value:{value:n,unit:"1"}}]:typeof n=="string"&&/^-?\d{1,9}(\.\d{1,9})?/.exec(n)?[{type:re.Quantity,value:{value:parseFloat(n),unit:"1"}}]:typeof n=="boolean"?[{type:re.Quantity,value:{value:n?1:0,unit:"1"}}]:[]},convertsToQuantity:(e,t)=>t.length===0?[]:tt(zr.toQuantity(e,t).length===1),toString:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);return n==null?[]:Ei(n)?[{type:re.string,value:`${n.value} '${n.unit}'`}]:[{type:re.string,value:n.toString()}]},convertsToString:(e,t)=>t.length===0?[]:tt(zr.toString(e,t).length===1),toTime:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);if(typeof n=="string"){const r=/^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(n);if(r)return[{type:re.time,value:Ih("T"+r[1])}]}return[]},convertsToTime:(e,t)=>t.length===0?[]:tt(zr.toTime(e,t).length===1),indexOf:(e,t,n)=>Si((r,o)=>r.indexOf(o),e,t,n),substring:(e,t,n,r)=>Si((o,l,c)=>{const d=l,f=c?d+c:o.length;return d<0||d>=o.length?void 0:o.substring(d,f)},e,t,n,r),startsWith:(e,t,n)=>Si((r,o)=>r.startsWith(o),e,t,n),endsWith:(e,t,n)=>Si((r,o)=>r.endsWith(o),e,t,n),contains:(e,t,n)=>Si((r,o)=>r.includes(o),e,t,n),upper:(e,t)=>Si(n=>n.toUpperCase(),e,t),lower:(e,t)=>Si(n=>n.toLowerCase(),e,t),replace:(e,t,n,r)=>Si((o,l,c)=>o.replaceAll(l,c),e,t,n,r),matches:(e,t,n)=>Si((r,o)=>!!new RegExp(o).exec(r),e,t,n),replaceMatches:(e,t,n,r)=>Si((o,l,c)=>o.replaceAll(new RegExp(l,"g"),c.replaceAll(/\$\{(\w+)\}/g,"$<$1>")),e,t,n,r),length:(e,t)=>Si(n=>n.length,e,t),toChars:(e,t)=>Si(n=>n?n.split(""):void 0,e,t),encode:Jo,decode:Jo,escape:Jo,unescape:Jo,trim:Jo,split:Jo,join:(e,t,n)=>{const r=n?.eval(e,zs(e))[0]?.value??"";if(typeof r!="string")throw new Error("Separator must be a string.");return[{type:re.string,value:t.map(o=>o.value?.toString()??"").join(r)}]},abs:(e,t)=>co(Math.abs,e,t),ceiling:(e,t)=>co(Math.ceil,e,t),exp:(e,t)=>co(Math.exp,e,t),floor:(e,t)=>co(Math.floor,e,t),ln:(e,t)=>co(Math.log,e,t),log:(e,t,n)=>co((r,o)=>Math.log(r)/Math.log(o),e,t,n),power:(e,t,n)=>co(Math.pow,e,t,n),round:(e,t,...n)=>co((r,o=0)=>{if(typeof o!="number"||o<0)throw new Error("Invalid precision provided to round()");const l=Math.pow(10,o);return Math.round(r*l)/l},e,t,...n),sqrt:(e,t)=>co(Math.sqrt,e,t),truncate:(e,t)=>co(n=>n|0,e,t),children:Jo,descendants:Jo,trace:(e,t,n)=>t,now:()=>[{type:re.dateTime,value:new Date().toISOString()}],timeOfDay:()=>[{type:re.time,value:new Date().toISOString().substring(11)}],today:()=>[{type:re.date,value:new Date().toISOString().substring(0,10)}],between:(e,t,n,r,o)=>{const l=zr.toDateTime(e,n.eval(e,t));if(l.length===0)throw new Error("Invalid start date");const c=zr.toDateTime(e,r.eval(e,t));if(c.length===0)throw new Error("Invalid end date");const d=o.eval(e,t)[0]?.value;if(d!=="years"&&d!=="months"&&d!=="days")throw new Error("Invalid units");const f=YD(l[0].value,c[0].value);return[{type:re.Quantity,value:{value:f[d],unit:d}}]},is:(e,t,n)=>{let r="";return n instanceof rp?r=n.name:n instanceof Cb&&(r=n.left.name+"."+n.right.name),r?t.map(o=>({type:re.boolean,value:FD(o,r)})):[]},not:(e,t)=>zr.toBoolean(e,t).map(n=>({type:re.boolean,value:!n.value})),resolve:(e,t)=>t.map(n=>{const r=n.value;let o;if(typeof r=="string")o=r;else if(typeof r=="object"){const l=r;if(l.resource)return ri(l.resource);l.reference?o=l.reference:l.type&&l.identifier&&(o=`${l.type}?identifier=${l.identifier.system}|${l.identifier.value}`)}if(o?.includes("?")){const[l]=o.split("?");return{type:l,value:{resourceType:l}}}if(o?.includes("/")){const[l,c]=o.split("/");return{type:l,value:{resourceType:l,id:c}}}return{type:re.BackboneElement,value:void 0}}).filter(n=>!!n.value),as:(e,t)=>t,type:(e,t)=>t.map(({value:n})=>typeof n=="boolean"?{type:re.BackboneElement,value:{namespace:"System",name:"Boolean"}}:typeof n=="number"?{type:re.BackboneElement,value:{namespace:"System",name:"Integer"}}:Ao(n)?{type:re.BackboneElement,value:{namespace:"FHIR",name:n.resourceType}}:{type:re.BackboneElement,value:null}),conformsTo:(e,t,n)=>{const r=n.eval(e,t)[0].value;if(!r.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const o=r.replace("http://hl7.org/fhir/StructureDefinition/","");return t.map(l=>({type:re.boolean,value:l.value?.resourceType===o}))},getResourceKey:(e,t)=>{const n=t[0].value;return n?.id?[{type:re.id,value:n.id}]:[]},getReferenceKey:(e,t,n)=>{const r=t[0].value;if(!r?.reference)return[];let o="";return n instanceof rp&&(o=n.name),o&&!r.reference.startsWith(o+"/")?[]:[{type:re.id,value:rl(r)}]},extension:(e,t,n)=>{const r=n.eval(e,t)[0].value,o=t?.[0]?.value;if(o){const l=Do(o,r);if(l)return[{type:re.Extension,value:l}]}return[]}};function Si(e,t,n,...r){if(n.length===0)return[];const[{value:o}]=ho(n,1);if(typeof o!="string")throw new Error("String function cannot be called with non-string");const l=r.map(d=>d?.eval(t,n)[0]?.value),c=e(o,...l);return c===void 0?[]:Array.isArray(c)?c.map(ri):[ri(c)]}function co(e,t,n,...r){if(n.length===0)return[];const[{value:o}]=ho(n,1),l=Ei(o),c=l?o.value:o;if(typeof c!="number")throw new Error("Math function cannot be called with non-number");const d=e(c,...r.map(m=>m.eval(t,n)[0]?.value)),f=l?re.Quantity:n[0].type,p=l?{...o,value:d}:d;return[{type:f,value:p}]}function ho(e,t){if(e.length!==t)throw new Error(`Expected ${t} arguments`);for(const n of e)if(n==null)throw new Error("Expected non-null argument");return e}function zs(e){let t=e;for(;t.parent?.variables.$this;)t=t.parent;return[t.variables.$this]}class sA{constructor(t,n){this.original=t,this.child=n}eval(t,n){try{if(n.length>0){const r=[];for(const o of n)r.push(this.child.eval({parent:t,variables:{$this:o}},[o]));return r.flat()}else return this.child.eval(t,[])}catch(r){throw new Error(`FhirPathError on "${this.original}": ${r}`,{cause:r})}}toString(){return this.child.toString()}}class mc{constructor(t){this.value=t}eval(){return[this.value]}toString(){const t=this.value.value;return typeof t=="string"?`'${t}'`:t.toString()}}class rp{constructor(t){this.name=t}eval(t,n){if(this.name==="$this")return n;const r=this.getVariable(t);if(r)return[r];if(this.name.startsWith("%"))throw new Error(`Undefined variable ${this.name}`);return n.flatMap(o=>this.evalValue(o)).filter(o=>o?.value!==void 0)}getVariable(t){const n=t.variables[this.name];if(n!==void 0)return n;if(t.parent)return this.getVariable(t.parent)}evalValue(t){const n=t.value;if(!(!n||typeof n!="object"))return Ao(n,this.name)?t:Lc(t,this.name)}toString(){return this.name}}class oB{eval(){return[]}toString(){return"{}"}}class aB extends I${constructor(t,n,r){super(t,n),this.impl=r}eval(t,n){return this.impl(this.child.eval(t,n))}toString(){return this.operator+this.child.toString()}}class ip extends Bd{constructor(t,n){super("as",t,n)}eval(t,n){return zr.ofType(t,this.left.eval(t,n),this.right)}}class qr extends Bd{}class Vi extends qr{constructor(t,n,r,o){super(t,n,r),this.impl=o}eval(t,n){const r=this.left.eval(t,n);if(r.length!==1)return[];const o=this.right.eval(t,n);if(o.length!==1)return[];const l=r[0].value,c=o[0].value,d=Ei(l)?l.value:l,f=Ei(c)?c.value:c,p=this.impl(d,f);return typeof p=="boolean"?tt(p):Ei(l)?[{type:re.Quantity,value:{...l,value:p}}]:[ri(p)]}}class sB extends Bd{constructor(t,n){super("&",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n),l=[...r,...o];return l.length>0&&l.every(c=>typeof c.value=="string")?[{type:re.string,value:l.map(c=>c.value).join("")}]:l}}class lB extends qr{constructor(t,n){super("contains",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return tt(r.some(l=>l.value===o[0].value))}}class cB extends qr{constructor(t,n){super("in",t,n)}eval(t,n){const r=ua(this.left.eval(t,n)),o=this.right.eval(t,n);return r?tt(o.some(l=>fm(r,l)[0].value)):[]}}class Cb extends Bd{constructor(t,n){super(".",t,n)}eval(t,n){return this.right.eval(t,this.left.eval(t,n))}toString(){return`${this.left.toString()}.${this.right.toString()}`}}class Eb extends Bd{constructor(t,n){super("|",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return BD([...r,...o])}}class uB extends qr{constructor(t,n){super("=",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return vU(r,o)}}class dB extends qr{constructor(t,n){super("!=",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return yU(r,o)}}class fB extends qr{constructor(t,n){super("~",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return VD(r,o)}}class hB extends qr{constructor(t,n){super("!~",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return gU(VD(r,o))}}class Tb extends qr{constructor(t,n){super("is",t,n)}eval(t,n){const r=this.left.eval(t,n);if(r.length!==1)return[];const o=this.right.name;return tt(FD(r[0],o))}}class pB extends qr{constructor(t,n){super("and",t,n)}eval(t,n){const r=ua(this.left.eval(t,n),"boolean"),o=ua(this.right.eval(t,n),"boolean");return r?.value===!0&&o?.value===!0?tt(!0):r?.value===!1||o?.value===!1?tt(!1):[]}}class mB extends qr{constructor(t,n){super("or",t,n)}eval(t,n){const r=ua(this.left.eval(t,n),"boolean"),o=ua(this.right.eval(t,n),"boolean");return r?.value===!1&&o?.value===!1?tt(!1):r?.value||o?.value?tt(!0):[]}}class gB extends qr{constructor(t,n){super("xor",t,n)}eval(t,n){const r=ua(this.left.eval(t,n),"boolean"),o=ua(this.right.eval(t,n),"boolean");return!r||!o?[]:tt(r.value!==o.value)}}class vB extends qr{constructor(t,n){super("implies",t,n)}eval(t,n){const r=ua(this.left.eval(t,n),"boolean"),o=ua(this.right.eval(t,n),"boolean");return o?.value===!0||r?.value===!1?tt(!0):!r||!o?[]:tt(!1)}}class Rb{constructor(t,n){this.name=t,this.args=n}eval(t,n){const r=zr[this.name];if(!r)throw new Error("Unrecognized function: "+this.name);return r(t,n,...this.args)}toString(){return`${this.name}(${this.args.map(t=>t.toString()).join(", ")})`}}class _b{constructor(t,n){this.left=t,this.expr=n}eval(t,n){const r=this.expr.eval(t,n);if(r.length!==1)return[];const o=r[0].value;if(typeof o!="number")throw new Error("Invalid indexer expression: should return integer}");const l=this.left.eval(t,n);return o in l?[l[o]]:[]}toString(){return`${this.left.toString()}[${this.expr.toString()}]`}}const yB=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"],xB={"'":"'",'"':'"',"`":"`",r:"\r",n:`
|
|
76
|
+
`),l=!1),Object.assign(Object.assign({},e),{allowNegative:l})}function D6(e){e=_6(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,n=e.allowNegative,r=e.allowLeadingZeros,o=e.onKeyDown;o===void 0&&(o=es);var l=e.onBlur;l===void 0&&(l=es);var c=e.thousandSeparator,d=e.decimalScale,f=e.fixedDecimalScale,p=e.prefix;p===void 0&&(p="");var m=e.defaultValue,g=e.value,x=e.valueIsNumericString,b=e.onValueChange,w=W_(e,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),j=tm(e),C=j.decimalSeparator,T=j.allowedDecimalSeparators,E=function(O){return jE(O,e)},R=function(O,I){return T6(O,I,e)},D=Cc(g)?m:g,P=x??E6(D,p,t);Cc(g)?Cc(m)||(P=P||typeof m=="number"):P=P||typeof g=="number";var A=function(O){return Y_(O)?O:(typeof O=="number"&&(O=Z_(O)),P&&typeof d=="number"?SE(O,d,!!f):O)},k=eD(A(g),A(m),!!P,E,R,b),M=k[0],$=M.numAsString,U=M.formattedValue,J=k[1],Z=function(O){var I=O.target,z=O.key,F=I.selectionStart,K=I.selectionEnd,L=I.value;if(L===void 0&&(L=""),(z==="Backspace"||z==="Delete")&&K<p.length){O.preventDefault();return}if(F!==K){o(O);return}z==="Backspace"&&L[0]==="-"&&F===p.length+1&&n&&Hs(I,1),d&&f&&(z==="Backspace"&&L[F-1]===C?(Hs(I,F-1),O.preventDefault()):z==="Delete"&&L[F]===C&&O.preventDefault()),T?.includes(z)&&L[F]===C&&Hs(I,F+1);var q=c===!0?",":c;z==="Backspace"&&L[F-1]===q&&Hs(I,F-1),z==="Delete"&&L[F]===q&&Hs(I,F+1),o(O)},Y=function(O){var I=$;if(I.match(/\d/g)||(I=""),r||(I=f6(I)),f&&d&&(I=SE(I,d,f)),I!==$){var z=jE(I,e);J({formattedValue:z,value:I,floatValue:parseFloat(I)},{event:O,source:dd.event})}l(O)},H=function(O){return O===C?!0:fd(O)},Q=function(O){var I=O.currentValue,z=O.lastValue,F=O.formattedValue,K=O.currentValueIndex,L=O.formattedValueIndex,q=I[K],ie=F[L],xe=J_(z,I),ve=xe.to,Ce=function(Oe){return R(Oe).indexOf(".")+p.length};return g===0&&f&&d&&I[ve.start]===C&&Ce(I)<K&&Ce(F)>L?!1:K>=ve.start&&K<ve.end&&T&&T.includes(q)&&ie===C?!0:q===ie};return Object.assign(Object.assign({},w),{value:U,valueIsNumericString:!1,isValidInputCharacter:H,isCharacterSame:Q,onValueChange:J,format:E,removeFormatting:R,getCaretBoundary:function(O){return R6(O,e)},onKeyDown:Z,onBlur:Y})}function A6(e){var t=D6(e);return Tn.createElement(w6,Object.assign({},t))}function CE({direction:e,style:t,...n}){return a.jsx("svg",{style:{width:"var(--ni-chevron-size)",height:"var(--ni-chevron-size)",transform:e==="up"?"rotate(180deg)":void 0,...t},viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n,children:a.jsx("path",{d:"M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})})}var nx={root:"m_e2f5cd4e",controls:"m_95e17d22",control:"m_80b4b171"};const P6=/^(0\.0*|-0(\.0*)?)$/,k6=/^-?0\d+(\.\d+)?\.?$/;function rx(e){return typeof e=="string"&&e!==""&&!Number.isNaN(Number(e))}function fy(e){return typeof e=="number"?e<Number.MAX_SAFE_INTEGER:e===""||rx(e)&&Number(e)<Number.MAX_SAFE_INTEGER}function N6(e){return e.toString().replace(".","").length}function O6(e,t){return(typeof e=="number"?e<Number.MAX_SAFE_INTEGER:!Number.isNaN(Number(e)))&&!Number.isNaN(e)&&N6(t)<14&&t!==""}function EE(e,t,n){if(e===void 0)return!0;const r=t===void 0||e>=t,o=n===void 0||e<=n;return r&&o}const M6={step:1,clampBehavior:"blur",allowDecimal:!0,allowNegative:!0,withKeyboardEvents:!0,allowLeadingZeros:!0,trimLeadingZeroesOnBlur:!0,startValue:0},L6=(e,{size:t})=>({controls:{"--ni-chevron-size":at(t,"ni-chevron-size")}});function I6(e,t,n){const r=e.toString().replace(/^0+/,""),o=parseFloat(r);return Number.isNaN(o)?r:o>Number.MAX_SAFE_INTEGER?t!==void 0?String(t):r:Nh(o,n,t)}const Oc=be((e,t)=>{const n=ae("NumberInput",M6,e),{className:r,classNames:o,styles:l,unstyled:c,vars:d,onChange:f,onValueChange:p,value:m,defaultValue:g,max:x,min:b,step:w,hideControls:j,rightSection:C,isAllowed:T,clampBehavior:E,onBlur:R,allowDecimal:D,decimalScale:P,onKeyDown:A,onKeyDownCapture:k,handlersRef:M,startValue:$,disabled:U,rightSectionPointerEvents:J,allowNegative:Z,readOnly:Y,size:H,rightSectionWidth:Q,stepHoldInterval:O,stepHoldDelay:I,allowLeadingZeros:z,withKeyboardEvents:F,trimLeadingZeroesOnBlur:K,...L}=n,q=$e({name:"NumberInput",classes:nx,props:n,classNames:o,styles:l,unstyled:c,vars:d,varsResolver:L6}),{resolvedClassNames:ie,resolvedStyles:xe}=fl({classNames:o,styles:l,props:n}),[ve,Ce]=Zn({value:m,defaultValue:g,finalValue:"",onChange:f}),Oe=I!==void 0&&O!==void 0,Ee=v.useRef(null),Ge=v.useRef(null),it=v.useRef(0),St=(me,ze)=>{ze.source==="event"&&Ce(O6(me.floatValue,me.value)&&!P6.test(me.value)&&!(z&&k6.test(me.value))?me.floatValue:me.value),p?.(me,ze)},kt=me=>{const ze=String(me).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return ze?Math.max(0,(ze[1]?ze[1].length:0)-(ze[2]?+ze[2]:0)):0},Mt=me=>{Ee.current&&typeof me<"u"&&Ee.current.setSelectionRange(me,me)},ct=v.useRef(Gh);ct.current=()=>{if(!fy(ve))return;let me;const ze=kt(ve),Nt=kt(w),Wt=Math.max(ze,Nt),jn=10**Wt;if(!rx(ve)&&(typeof ve!="number"||Number.isNaN(ve)))me=Nh($,b,x);else if(x!==void 0){const Cn=(Math.round(Number(ve)*jn)+Math.round(w*jn))/jn;me=Cn<=x?Cn:x}else me=(Math.round(Number(ve)*jn)+Math.round(w*jn))/jn;const Qn=me.toFixed(Wt);Ce(parseFloat(Qn)),p?.({floatValue:parseFloat(Qn),formattedValue:Qn,value:Qn},{source:"increment"}),setTimeout(()=>Mt(Ee.current?.value.length),0)};const bt=v.useRef(Gh);bt.current=()=>{if(!fy(ve))return;let me;const ze=b!==void 0?b:Z?Number.MIN_SAFE_INTEGER:0,Nt=kt(ve),Wt=kt(w),jn=Math.max(Nt,Wt),Qn=10**jn;if(!rx(ve)&&typeof ve!="number"||Number.isNaN(ve))me=Nh($,ze,x);else{const Ar=(Math.round(Number(ve)*Qn)-Math.round(w*Qn))/Qn;me=ze!==void 0&&Ar<ze?ze:Ar}const Cn=me.toFixed(jn);Ce(parseFloat(Cn)),p?.({floatValue:parseFloat(Cn),formattedValue:Cn,value:Cn},{source:"decrement"}),setTimeout(()=>Mt(Ee.current?.value.length),0)};const Qt=me=>{A?.(me),!(Y||!F)&&(me.key==="ArrowUp"&&(me.preventDefault(),ct.current()),me.key==="ArrowDown"&&(me.preventDefault(),bt.current()))},Ae=me=>{if(k?.(me),me.key==="Backspace"){const ze=Ee.current;ze.selectionStart===0&&ze.selectionStart===ze.selectionEnd&&(me.preventDefault(),window.setTimeout(()=>Mt(0),0))}},De=me=>{let ze=ve;E==="blur"&&typeof ze=="number"&&(ze=Nh(ze,b,x)),K&&typeof ze=="string"&&kt(ze)<15&&(ze=I6(ze,x,b)),ve!==ze&&Ce(ze),R?.(me)};sd(M,{increment:ct.current,decrement:bt.current});const Ze=me=>{me?ct.current():bt.current(),it.current+=1},_e=me=>{if(Ze(me),Oe){const ze=typeof O=="number"?O:O(it.current);Ge.current=window.setTimeout(()=>_e(me),ze)}},ge=(me,ze)=>{me.preventDefault(),Ee.current?.focus(),Ze(ze),Oe&&(Ge.current=window.setTimeout(()=>_e(ze),I))},Se=()=>{Ge.current&&window.clearTimeout(Ge.current),Ge.current=null,it.current=0},He=a.jsxs("div",{...q("controls"),children:[a.jsx(sr,{...q("control"),tabIndex:-1,"aria-hidden":!0,disabled:U||typeof ve=="number"&&x!==void 0&&ve>=x,mod:{direction:"up"},onMouseDown:me=>me.preventDefault(),onPointerDown:me=>{ge(me,!0)},onPointerUp:Se,onPointerLeave:Se,children:a.jsx(CE,{direction:"up"})}),a.jsx(sr,{...q("control"),tabIndex:-1,"aria-hidden":!0,disabled:U||typeof ve=="number"&&b!==void 0&&ve<=b,mod:{direction:"down"},onMouseDown:me=>me.preventDefault(),onPointerDown:me=>{ge(me,!1)},onPointerUp:Se,onPointerLeave:Se,children:a.jsx(CE,{direction:"down"})})]});return a.jsx(Dr,{component:A6,allowNegative:Z,className:Ot(nx.root,r),size:H,...L,readOnly:Y,disabled:U,value:ve,getInputRef:qn(t,Ee),onValueChange:St,rightSection:j||Y||!fy(ve)?C:C||He,classNames:ie,styles:xe,unstyled:c,__staticSelector:"NumberInput",decimalScale:D?P:0,onKeyDown:Qt,onKeyDownCapture:Ae,rightSectionPointerEvents:J??(U?"none":void 0),rightSectionWidth:Q??`var(--ni-right-section-width-${H||"sm"})`,allowLeadingZeros:z,onBlur:De,isAllowed:me=>E==="strict"?T?T(me)&&EE(me.floatValue,b,x):EE(me.floatValue,b,x):T?T(me):!0})});Oc.classes={...Dr.classes,...nx};Oc.displayName="@mantine/core/NumberInput";const[z6,nm]=Rr("Pagination.Root component was not found in tree");var Od={root:"m_4addd315",control:"m_326d024a",dots:"m_4ad7767d"};const $6={withPadding:!0},Md=be((e,t)=>{const n=ae("PaginationControl",$6,e),{classNames:r,className:o,style:l,styles:c,vars:d,active:f,disabled:p,withPadding:m,mod:g,...x}=n,b=nm(),w=p||b.disabled;return a.jsx(sr,{ref:t,disabled:w,mod:[{active:f,disabled:w,"with-padding":m},g],...b.getStyles("control",{className:o,style:l,classNames:r,styles:c,active:!w}),...x})});Md.classes=Od;Md.displayName="@mantine/core/PaginationControl";function Ld({style:e,children:t,path:n,...r}){return a.jsx("svg",{viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",style:{width:"calc(var(--pagination-control-size) / 1.8)",height:"calc(var(--pagination-control-size) / 1.8)",...e},...r,children:a.jsx("path",{d:n,fill:"currentColor"})})}const U6=e=>a.jsx(Ld,{...e,path:"M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z"}),B6=e=>a.jsx(Ld,{...e,path:"M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z"}),V6=e=>a.jsx(Ld,{...e,path:"M6.85355 3.85355C7.04882 3.65829 7.04882 3.34171 6.85355 3.14645C6.65829 2.95118 6.34171 2.95118 6.14645 3.14645L2.14645 7.14645C1.95118 7.34171 1.95118 7.65829 2.14645 7.85355L6.14645 11.8536C6.34171 12.0488 6.65829 12.0488 6.85355 11.8536C7.04882 11.6583 7.04882 11.3417 6.85355 11.1464L3.20711 7.5L6.85355 3.85355ZM12.8536 3.85355C13.0488 3.65829 13.0488 3.34171 12.8536 3.14645C12.6583 2.95118 12.3417 2.95118 12.1464 3.14645L8.14645 7.14645C7.95118 7.34171 7.95118 7.65829 8.14645 7.85355L12.1464 11.8536C12.3417 12.0488 12.6583 12.0488 12.8536 11.8536C13.0488 11.6583 13.0488 11.3417 12.8536 11.1464L9.20711 7.5L12.8536 3.85355Z"}),F6=e=>a.jsx(Ld,{...e,path:"M2.14645 11.1464C1.95118 11.3417 1.95118 11.6583 2.14645 11.8536C2.34171 12.0488 2.65829 12.0488 2.85355 11.8536L6.85355 7.85355C7.04882 7.65829 7.04882 7.34171 6.85355 7.14645L2.85355 3.14645C2.65829 2.95118 2.34171 2.95118 2.14645 3.14645C1.95118 3.34171 1.95118 3.65829 2.14645 3.85355L5.79289 7.5L2.14645 11.1464ZM8.14645 11.1464C7.95118 11.3417 7.95118 11.6583 8.14645 11.8536C8.34171 12.0488 8.65829 12.0488 8.85355 11.8536L12.8536 7.85355C13.0488 7.65829 13.0488 7.34171 12.8536 7.14645L8.85355 3.14645C8.65829 2.95118 8.34171 2.95118 8.14645 3.14645C7.95118 3.34171 7.95118 3.65829 8.14645 3.85355L11.7929 7.5L8.14645 11.1464Z"}),H6=e=>a.jsx(Ld,{...e,path:"M2 8c0-.733.6-1.333 1.333-1.333.734 0 1.334.6 1.334 1.333s-.6 1.333-1.334 1.333C2.6 9.333 2 8.733 2 8zm9.333 0c0-.733.6-1.333 1.334-1.333C13.4 6.667 14 7.267 14 8s-.6 1.333-1.333 1.333c-.734 0-1.334-.6-1.334-1.333zM6.667 8c0-.733.6-1.333 1.333-1.333s1.333.6 1.333 1.333S8.733 9.333 8 9.333 6.667 8.733 6.667 8z"}),q6={icon:H6},rm=be((e,t)=>{const n=ae("PaginationDots",q6,e),{classNames:r,className:o,style:l,styles:c,vars:d,icon:f,...p}=n,m=nm(),g=f;return a.jsx(ce,{ref:t,...m.getStyles("dots",{className:o,style:l,styles:c,classNames:r}),...p,children:a.jsx(g,{style:{width:"calc(var(--pagination-control-size) / 1.8)",height:"calc(var(--pagination-control-size) / 1.8)"}})})});rm.classes=Od;rm.displayName="@mantine/core/PaginationDots";function im({icon:e,name:t,action:n,type:r}){const o={icon:e},l=v.forwardRef((c,d)=>{const{icon:f,...p}=ae(t,o,c),m=f,g=nm(),x=r==="next"?g.active===g.total:g.active===1;return a.jsx(Md,{disabled:g.disabled||x,ref:d,onClick:g[n],withPadding:!1,...p,children:a.jsx(m,{className:"mantine-rotate-rtl",style:{width:"calc(var(--pagination-control-size) / 1.8)",height:"calc(var(--pagination-control-size) / 1.8)"}})})});return l.displayName=`@mantine/core/${t}`,l}const tD=im({icon:U6,name:"PaginationNext",action:"onNext",type:"next"}),nD=im({icon:B6,name:"PaginationPrevious",action:"onPrevious",type:"previous"}),rD=im({icon:V6,name:"PaginationFirst",action:"onFirst",type:"previous"}),iD=im({icon:F6,name:"PaginationLast",action:"onLast",type:"next"});function J0({dotsIcon:e}){const t=nm(),n=t.range.map((r,o)=>r==="dots"?a.jsx(rm,{icon:e},o):a.jsx(Md,{active:r===t.active,"aria-current":r===t.active?"page":void 0,onClick:()=>t.onChange(r),disabled:t.disabled,...t.getItemProps?.(r),children:t.getItemProps?.(r)?.children??r},o));return a.jsx(a.Fragment,{children:n})}J0.displayName="@mantine/core/PaginationItems";const G6={siblings:1,boundaries:1},Q6=(e,{size:t,radius:n,color:r,autoContrast:o})=>({root:{"--pagination-control-radius":n===void 0?void 0:$t(n),"--pagination-control-size":at(t,"pagination-control-size"),"--pagination-control-fz":In(t),"--pagination-active-bg":r?Ft(r,e):void 0,"--pagination-active-color":hl(o,e)?ma({color:r,theme:e,autoContrast:o}):void 0}}),om=be((e,t)=>{const n=ae("PaginationRoot",G6,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,total:p,value:m,defaultValue:g,onChange:x,disabled:b,siblings:w,boundaries:j,color:C,radius:T,onNextPage:E,onPreviousPage:R,onFirstPage:D,onLastPage:P,getItemProps:A,autoContrast:k,...M}=n,$=$e({name:"Pagination",classes:Od,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:Q6}),{range:U,setPage:J,next:Z,previous:Y,active:H,first:Q,last:O}=t4({page:m,initialPage:g,onChange:x,total:p,siblings:w,boundaries:j}),I=Ur(E,Z),z=Ur(R,Y),F=Ur(D,Q),K=Ur(P,O);return a.jsx(z6,{value:{total:p,range:U,active:H,disabled:b,getItemProps:A,onChange:J,onNext:I,onPrevious:z,onFirst:F,onLast:K,getStyles:$},children:a.jsx(ce,{ref:t,...$("root"),...M})})});om.classes=Od;om.displayName="@mantine/core/PaginationRoot";const W6={withControls:!0,withPages:!0,siblings:1,boundaries:1,gap:8},Oi=be((e,t)=>{const n=ae("Pagination",W6,e),{withEdges:r,withControls:o,getControlProps:l,nextIcon:c,previousIcon:d,lastIcon:f,firstIcon:p,dotsIcon:m,total:g,gap:x,hideWithOnePage:b,withPages:w,...j}=n;return g<=0||b&&g===1?null:a.jsx(om,{ref:t,total:g,...j,children:a.jsxs(ye,{gap:x,children:[r&&a.jsx(rD,{icon:p,...l?.("first")}),o&&a.jsx(nD,{icon:d,...l?.("previous")}),w&&a.jsx(J0,{dotsIcon:m}),o&&a.jsx(tD,{icon:c,...l?.("next")}),r&&a.jsx(iD,{icon:f,...l?.("last")})]})})});Oi.classes=Od;Oi.displayName="@mantine/core/Pagination";Oi.Root=om;Oi.Control=Md;Oi.Dots=rm;Oi.First=rD;Oi.Last=iD;Oi.Next=tD;Oi.Previous=nD;Oi.Items=J0;const Y6=({reveal:e})=>a.jsx("svg",{viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"var(--psi-icon-size)",height:"var(--psi-icon-size)"},children:a.jsx("path",{d:e?"M13.3536 2.35355C13.5488 2.15829 13.5488 1.84171 13.3536 1.64645C13.1583 1.45118 12.8417 1.45118 12.6464 1.64645L10.6828 3.61012C9.70652 3.21671 8.63759 3 7.5 3C4.30786 3 1.65639 4.70638 0.0760002 7.23501C-0.0253338 7.39715 -0.0253334 7.60288 0.0760014 7.76501C0.902945 9.08812 2.02314 10.1861 3.36061 10.9323L1.64645 12.6464C1.45118 12.8417 1.45118 13.1583 1.64645 13.3536C1.84171 13.5488 2.15829 13.5488 2.35355 13.3536L4.31723 11.3899C5.29348 11.7833 6.36241 12 7.5 12C10.6921 12 13.3436 10.2936 14.924 7.76501C15.0253 7.60288 15.0253 7.39715 14.924 7.23501C14.0971 5.9119 12.9769 4.81391 11.6394 4.06771L13.3536 2.35355ZM9.90428 4.38861C9.15332 4.1361 8.34759 4 7.5 4C4.80285 4 2.52952 5.37816 1.09622 7.50001C1.87284 8.6497 2.89609 9.58106 4.09974 10.1931L9.90428 4.38861ZM5.09572 10.6114L10.9003 4.80685C12.1039 5.41894 13.1272 6.35031 13.9038 7.50001C12.4705 9.62183 10.1971 11 7.5 11C6.65241 11 5.84668 10.8639 5.09572 10.6114Z":"M7.5 11C4.80285 11 2.52952 9.62184 1.09622 7.50001C2.52952 5.37816 4.80285 4 7.5 4C10.1971 4 12.4705 5.37816 13.9038 7.50001C12.4705 9.62183 10.1971 11 7.5 11ZM7.5 3C4.30786 3 1.65639 4.70638 0.0760002 7.23501C-0.0253338 7.39715 -0.0253334 7.60288 0.0760014 7.76501C1.65639 10.2936 4.30786 12 7.5 12C10.6921 12 13.3436 10.2936 14.924 7.76501C15.0253 7.60288 15.0253 7.39715 14.924 7.23501C13.3436 4.70638 10.6921 3 7.5 3ZM7.5 9.5C8.60457 9.5 9.5 8.60457 9.5 7.5C9.5 6.39543 8.60457 5.5 7.5 5.5C6.39543 5.5 5.5 6.39543 5.5 7.5C5.5 8.60457 6.39543 9.5 7.5 9.5Z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"})});var ix={root:"m_f61ca620",input:"m_ccf8da4c",innerInput:"m_f2d85dd2",visibilityToggle:"m_b1072d44"};const K6={visibilityToggleIcon:Y6},X6=(e,{size:t})=>({root:{"--psi-icon-size":at(t,"psi-icon-size"),"--psi-button-size":at(t,"psi-button-size")}}),Qi=be((e,t)=>{const n=ae("PasswordInput",K6,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,required:p,error:m,leftSection:g,disabled:x,id:b,variant:w,inputContainer:j,description:C,label:T,size:E,errorProps:R,descriptionProps:D,labelProps:P,withAsterisk:A,inputWrapperOrder:k,wrapperProps:M,radius:$,rightSection:U,rightSectionWidth:J,rightSectionPointerEvents:Z,leftSectionWidth:Y,visible:H,defaultVisible:Q,onVisibilityChange:O,visibilityToggleIcon:I,visibilityToggleButtonProps:z,rightSectionProps:F,leftSectionProps:K,leftSectionPointerEvents:L,withErrorStyles:q,mod:ie,...xe}=n,ve=_r(b),[Ce,Oe]=Zn({value:H,defaultValue:Q,finalValue:!1,onChange:O}),Ee=()=>Oe(!Ce),Ge=$e({name:"PasswordInput",classes:ix,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:X6}),{resolvedClassNames:it,resolvedStyles:St}=fl({classNames:r,styles:c,props:n}),{styleProps:kt,rest:Mt}=ga(xe),ct=I,bt=R?.id||`${ve}-error`,Qt=D?.id||`${ve}-description`,Ze=`${!!m&&typeof m!="boolean"?bt:""} ${!!C?Qt:""}`,_e=Ze.trim().length>0?Ze.trim():void 0,ge=a.jsx(bn,{...Ge("visibilityToggle"),disabled:x,radius:$,"aria-hidden":!z,tabIndex:-1,...z,variant:z?.variant??"subtle",color:"gray",unstyled:d,onTouchEnd:Se=>{Se.preventDefault(),z?.onTouchEnd?.(Se),Ee()},onMouseDown:Se=>{Se.preventDefault(),z?.onMouseDown?.(Se),Ee()},onKeyDown:Se=>{z?.onKeyDown?.(Se),Se.key===" "&&(Se.preventDefault(),Ee())},children:a.jsx(ct,{reveal:Ce})});return a.jsx(un.Wrapper,{required:p,id:ve,label:T,error:m,description:C,size:E,classNames:it,styles:St,__staticSelector:"PasswordInput",unstyled:d,withAsterisk:A,inputWrapperOrder:k,inputContainer:j,variant:w,labelProps:{...P,htmlFor:ve},descriptionProps:{...D,id:Qt},errorProps:{...R,id:bt},mod:ie,...Ge("root"),...kt,...M,children:a.jsx(un,{component:"div",error:m,leftSection:g,size:E,classNames:{...it,input:Ot(ix.input,it.input)},styles:St,radius:$,disabled:x,__staticSelector:"PasswordInput",rightSectionWidth:J,rightSection:U??ge,variant:w,unstyled:d,leftSectionWidth:Y,rightSectionPointerEvents:Z||"all",rightSectionProps:F,leftSectionProps:K,leftSectionPointerEvents:L,withAria:!1,withErrorStyles:q,children:a.jsx("input",{required:p,"data-invalid":!!m||void 0,"data-with-left-section":!!g||void 0,...Ge("innerInput"),disabled:x,id:ve,ref:t,...Mt,"aria-describedby":_e,autoComplete:Mt.autoComplete||"off",type:Ce?"text":"password"})})})});Qi.classes={...Dr.classes,...ix};Qi.displayName="@mantine/core/PasswordInput";const[Z6,oD]=ha(),[J6,ez]=ha();var aD={card:"m_9dc8ae12"};const tz={withBorder:!0},nz=(e,{radius:t})=>({card:{"--card-radius":$t(t)}}),eb=be((e,t)=>{const n=ae("RadioCard",tz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,checked:p,mod:m,withBorder:g,value:x,onClick:b,name:w,onKeyDown:j,...C}=n,T=$e({name:"RadioCard",classes:aD,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:nz,rootSelector:"card"}),{dir:E}=ml(),R=oD(),D=typeof p=="boolean"?p:R?.value===x||!1,P=w||R?.name,A=k=>{if(j?.(k),["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"].includes(k.nativeEvent.code)){k.preventDefault();const M=Array.from(document.querySelectorAll(`[role="radio"][name="${P||"__mantine"}"]`)),$=M.findIndex(Z=>Z===k.target),U=$+1>=M.length?0:$+1,J=$-1<0?M.length-1:$-1;k.nativeEvent.code==="ArrowDown"&&(M[U].focus(),M[U].click()),k.nativeEvent.code==="ArrowUp"&&(M[J].focus(),M[J].click()),k.nativeEvent.code==="ArrowLeft"&&(M[E==="ltr"?J:U].focus(),M[E==="ltr"?J:U].click()),k.nativeEvent.code==="ArrowRight"&&(M[E==="ltr"?U:J].focus(),M[E==="ltr"?U:J].click())}};return a.jsx(J6,{value:{checked:D},children:a.jsx(sr,{ref:t,mod:[{"with-border":g,checked:D},m],...T("card"),...C,role:"radio","aria-checked":D,name:P,onClick:k=>{b?.(k),R?.onChange(x||"")},onKeyDown:A})})});eb.displayName="@mantine/core/RadioCard";eb.classes=aD;const rz={},tb=be((e,t)=>{const{value:n,defaultValue:r,onChange:o,size:l,wrapperProps:c,children:d,name:f,readOnly:p,...m}=ae("RadioGroup",rz,e),g=_r(f),[x,b]=Zn({value:n,defaultValue:r,finalValue:"",onChange:o}),w=j=>!p&&b(typeof j=="string"?j:j.currentTarget.value);return a.jsx(Z6,{value:{value:x,onChange:w,size:l,name:g},children:a.jsx(un.Wrapper,{size:l,ref:t,...c,...m,labelElement:"div",__staticSelector:"RadioGroup",children:a.jsx(D0,{role:"radiogroup",children:d})})})});tb.classes=un.Wrapper.classes;tb.displayName="@mantine/core/RadioGroup";function sD({size:e,style:t,...n}){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 5 5",style:{width:le(e),height:le(e),...t},"aria-hidden":!0,...n,children:a.jsx("circle",{cx:"2.5",cy:"2.5",r:"2.5",fill:"currentColor"})})}var lD={indicator:"m_717d7ff6",icon:"m_3e4da632","indicator--outline":"m_2980836c"};const iz={icon:sD},oz=(e,{radius:t,color:n,size:r,iconColor:o,variant:l,autoContrast:c})=>{const d=Ri({color:n||e.primaryColor,theme:e}),f=d.isThemeColor&&d.shade===void 0?`var(--mantine-color-${d.color}-outline)`:d.color;return{indicator:{"--radio-size":at(r,"radio-size"),"--radio-radius":t===void 0?void 0:$t(t),"--radio-color":l==="outline"?f:Ft(n,e),"--radio-icon-size":at(r,"radio-icon-size"),"--radio-icon-color":o?Ft(o,e):hl(c,e)?ma({color:n,theme:e,autoContrast:c}):void 0}}},nb=be((e,t)=>{const n=ae("RadioIndicator",iz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,icon:p,radius:m,color:g,iconColor:x,autoContrast:b,checked:w,mod:j,variant:C,disabled:T,...E}=n,R=p,D=$e({name:"RadioIndicator",classes:lD,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:oz,rootSelector:"indicator"}),P=ez(),A=typeof w=="boolean"?w:P?.checked||!1;return a.jsx(ce,{ref:t,...D("indicator",{variant:C}),variant:C,mod:[{checked:A,disabled:T},j],...E,children:a.jsx(R,{...D("icon")})})});nb.displayName="@mantine/core/RadioIndicator";nb.classes=lD;var cD={root:"m_f3f1af94",inner:"m_89c4f5e4",icon:"m_f3ed6b2b",radio:"m_8a3dbb89","radio--outline":"m_1bfe9d39"};const az={labelPosition:"right"},sz=(e,{size:t,radius:n,color:r,iconColor:o,variant:l,autoContrast:c})=>{const d=Ri({color:r||e.primaryColor,theme:e}),f=d.isThemeColor&&d.shade===void 0?`var(--mantine-color-${d.color}-outline)`:d.color;return{root:{"--radio-size":at(t,"radio-size"),"--radio-radius":n===void 0?void 0:$t(n),"--radio-color":l==="outline"?f:Ft(r,e),"--radio-icon-color":o?Ft(o,e):hl(c,e)?ma({color:r,theme:e,autoContrast:c}):void 0,"--radio-icon-size":at(t,"radio-icon-size")}}},ur=be((e,t)=>{const n=ae("Radio",az,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,id:p,size:m,label:g,labelPosition:x,description:b,error:w,radius:j,color:C,variant:T,disabled:E,wrapperProps:R,icon:D=sD,rootRef:P,iconColor:A,onChange:k,mod:M,...$}=n,U=$e({name:"Radio",classes:cD,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:sz}),J=oD(),Z=J?.size??m,Y=n.size?m:Z,{styleProps:H,rest:Q}=ga($),O=_r(p),I=J?{checked:J.value===Q.value,name:Q.name??J.name,onChange:z=>{J.onChange(z),k?.(z)}}:{};return a.jsx(Vp,{...U("root"),__staticSelector:"Radio",__stylesApiProps:n,id:O,size:Y,labelPosition:x,label:g,description:b,error:w,disabled:E,classNames:r,styles:c,unstyled:d,"data-checked":I.checked||void 0,variant:T,ref:P,mod:M,...H,...R,children:a.jsxs(ce,{...U("inner"),mod:{"label-position":x},children:[a.jsx(ce,{...U("radio",{focusable:!0,variant:T}),onChange:k,...Q,...I,component:"input",mod:{error:!!w},ref:t,id:O,disabled:E,type:"radio"}),a.jsx(D,{...U("icon"),"aria-hidden":!0})]})})});ur.classes=cD;ur.displayName="@mantine/core/Radio";ur.Group=tb;ur.Card=eb;ur.Indicator=nb;const lz={duration:100,transition:"fade"};function cz(e,t){return{...lz,...t,...e}}function uz({offset:e,position:t,defaultOpened:n}){const[r,o]=v.useState(n),l=v.useRef(null),{x:c,y:d,elements:f,refs:p,update:m,placement:g}=r0({placement:t,middleware:[Jx({crossAxis:!0,padding:5,rootBoundary:"document"})]}),x=g.includes("right")?e:t.includes("left")?e*-1:0,b=g.includes("bottom")?e:t.includes("top")?e*-1:0,w=v.useCallback(({clientX:j,clientY:C})=>{p.setPositionReference({getBoundingClientRect(){return{width:0,height:0,x:j,y:C,left:j+x,top:C+b,right:j,bottom:C}}})},[f.reference]);return v.useEffect(()=>{if(p.floating.current){const j=l.current;j.addEventListener("mousemove",w);const C=ia(p.floating.current);return C.forEach(T=>{T.addEventListener("scroll",m)}),()=>{j.removeEventListener("mousemove",w),C.forEach(T=>{T.removeEventListener("scroll",m)})}}},[f.reference,p.floating.current,m,w,r]),{handleMouseMove:w,x:c,y:d,opened:r,setOpened:o,boundaryRef:l,floating:p.setFloating}}var am={tooltip:"m_1b3c8819",arrow:"m_f898399f"};const dz={refProp:"ref",withinPortal:!0,offset:10,defaultOpened:!1,position:"right",zIndex:oi("popover")},fz=(e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:$t(t),"--tooltip-bg":n?Ft(n,e):void 0,"--tooltip-color":n?"var(--mantine-color-white)":void 0}}),rb=be((e,t)=>{const n=ae("TooltipFloating",dz,e),{children:r,refProp:o,withinPortal:l,style:c,className:d,classNames:f,styles:p,unstyled:m,radius:g,color:x,label:b,offset:w,position:j,multiline:C,zIndex:T,disabled:E,defaultOpened:R,variant:D,vars:P,portalProps:A,...k}=n,M=Sn(),$=$e({name:"TooltipFloating",props:n,classes:am,className:d,style:c,classNames:f,styles:p,unstyled:m,rootSelector:"tooltip",vars:P,varsResolver:fz}),{handleMouseMove:U,x:J,y:Z,opened:Y,boundaryRef:H,floating:Q,setOpened:O}=uz({offset:w,position:j,defaultOpened:R});if(!fa(r))throw new Error("[@mantine/core] Tooltip.Floating component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported");const I=qn(H,Rp(r),t),z=r.props,F=L=>{z.onMouseEnter?.(L),U(L),O(!0)},K=L=>{z.onMouseLeave?.(L),O(!1)};return a.jsxs(a.Fragment,{children:[a.jsx(fs,{...A,withinPortal:l,children:a.jsx(ce,{...k,...$("tooltip",{style:{...t2(c,M),zIndex:T,display:!E&&Y?"block":"none",top:(Z&&Math.round(Z))??"",left:(J&&Math.round(J))??""}}),variant:D,ref:Q,mod:{multiline:C},children:b})}),v.cloneElement(r,{...z,[o]:I,onMouseEnter:F,onMouseLeave:K})]})});rb.classes=am;rb.displayName="@mantine/core/TooltipFloating";const uD=v.createContext(!1),hz=uD.Provider,pz=()=>v.useContext(uD),mz={openDelay:0,closeDelay:0};function ib(e){const{openDelay:t,closeDelay:n,children:r}=ae("TooltipGroup",mz,e);return a.jsx(hz,{value:!0,children:a.jsx(H9,{delay:{open:t,close:n},children:r})})}ib.displayName="@mantine/core/TooltipGroup";ib.extend=e=>e;function gz(e){if(e===void 0)return{shift:!0,flip:!0};const t={...e};return e.shift===void 0&&(t.shift=!0),e.flip===void 0&&(t.flip=!0),t}function vz(e){const t=gz(e.middlewares),n=[b2(e.offset)];return t.shift&&n.push(Jx(typeof t.shift=="boolean"?{padding:8}:{padding:8,...t.shift})),t.flip&&n.push(typeof t.flip=="boolean"?Zh():Zh(t.flip)),n.push(S2({element:e.arrowRef,padding:e.arrowOffset})),t.inline?n.push(typeof t.inline=="boolean"?rd():rd(t.inline)):e.inline&&n.push(rd()),n}function yz(e){const[t,n]=v.useState(e.defaultOpened),o=typeof e.opened=="boolean"?e.opened:t,l=pz(),c=_r(),d=v.useCallback(A=>{n(A),A&&E(c)},[c]),{x:f,y:p,context:m,refs:g,update:x,placement:b,middlewareData:{arrow:{x:w,y:j}={}}}=r0({strategy:e.strategy,placement:e.position,open:o,onOpenChange:d,middleware:vz(e)}),{delay:C,currentId:T,setCurrentId:E}=q9(m,{id:c}),{getReferenceProps:R,getFloatingProps:D}=Z9([V9(m,{enabled:e.events?.hover,delay:l?C:{open:e.openDelay,close:e.closeDelay},mouseOnly:!e.events?.touch}),X9(m,{enabled:e.events?.focus,visibleOnly:!0}),e5(m,{role:"tooltip"}),Y9(m,{enabled:typeof e.opened>"u"})]);Q2({opened:o,position:e.position,positionDependencies:e.positionDependencies,floating:{refs:g,update:x}}),oa(()=>{e.onPositionChange?.(b)},[b]);const P=o&&T&&T!==c;return{x:f,y:p,arrowX:w,arrowY:j,reference:g.setReference,floating:g.setFloating,getFloatingProps:D,getReferenceProps:R,isGroupPhase:P,opened:o,placement:b}}const TE={position:"top",refProp:"ref",withinPortal:!0,inline:!1,defaultOpened:!1,arrowSize:4,arrowOffset:5,arrowRadius:0,arrowPosition:"side",offset:5,transitionProps:{duration:100,transition:"fade"},events:{hover:!0,focus:!1,touch:!1},zIndex:oi("popover"),positionDependencies:[],middlewares:{flip:!0,shift:!0,inline:!1}},xz=(e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:$t(t),"--tooltip-bg":n?Ft(n,e):void 0,"--tooltip-color":n?"var(--mantine-color-white)":void 0}}),ca=be((e,t)=>{const n=ae("Tooltip",TE,e),{children:r,position:o,refProp:l,label:c,openDelay:d,closeDelay:f,onPositionChange:p,opened:m,defaultOpened:g,withinPortal:x,radius:b,color:w,classNames:j,styles:C,unstyled:T,style:E,className:R,withArrow:D,arrowSize:P,arrowOffset:A,arrowRadius:k,arrowPosition:M,offset:$,transitionProps:U,multiline:J,events:Z,zIndex:Y,disabled:H,positionDependencies:Q,onClick:O,onMouseEnter:I,onMouseLeave:z,inline:F,variant:K,keepMounted:L,vars:q,portalProps:ie,mod:xe,floatingStrategy:ve,middlewares:Ce,...Oe}=ae("Tooltip",TE,n),{dir:Ee}=ml(),Ge=v.useRef(null),it=yz({position:U2(Ee,o),closeDelay:f,openDelay:d,onPositionChange:p,opened:m,defaultOpened:g,events:Z,arrowRef:Ge,arrowOffset:A,offset:typeof $=="number"?$+(D?P/2:0):$,positionDependencies:[...Q,r],inline:F,strategy:ve,middlewares:Ce}),St=$e({name:"Tooltip",props:n,classes:am,className:R,style:E,classNames:j,styles:C,unstyled:T,rootSelector:"tooltip",vars:q,varsResolver:xz});if(!fa(r))throw new Error("[@mantine/core] Tooltip component children should be an element or a component that accepts ref, fragments, strings, numbers and other primitive values are not supported");const kt=qn(it.reference,Rp(r),t),Mt=cz(U,{duration:100,transition:"fade"}),ct=r.props;return a.jsxs(a.Fragment,{children:[a.jsx(fs,{...ie,withinPortal:x,children:a.jsx(_o,{...Mt,keepMounted:L,mounted:!H&&!!it.opened,duration:it.isGroupPhase?10:Mt.duration,children:bt=>a.jsxs(ce,{...Oe,"data-fixed":ve==="fixed"||void 0,variant:K,mod:[{multiline:J},xe],...it.getFloatingProps({ref:it.floating,className:St("tooltip").className,style:{...St("tooltip").style,...bt,zIndex:Y,top:it.y??0,left:it.x??0}}),children:[c,a.jsx(s0,{ref:Ge,arrowX:it.arrowX,arrowY:it.arrowY,visible:D,position:it.placement,arrowSize:P,arrowOffset:A,arrowRadius:k,arrowPosition:M,...St("arrow")})]})})}),v.cloneElement(r,it.getReferenceProps({onClick:O,onMouseEnter:I,onMouseLeave:z,onMouseMove:n.onMouseMove,onPointerDown:n.onPointerDown,onPointerEnter:n.onPointerEnter,className:Ot(R,ct.className),...ct,[l]:kt}))]})});ca.classes=am;ca.displayName="@mantine/core/Tooltip";ca.Floating=rb;ca.Group=ib;function bz({size:e,thickness:t,sum:n,value:r,root:o,offset:l}){const c=(e*.9-t*2)/2,d=Math.PI*c*2/100,f=o||r===void 0?`${(100-n)*d}, ${n*d}`:`${r*d}, ${(100-r)*d}`;return{strokeWidth:Number.isNaN(t)?12:t,cx:e/2||0,cy:e/2||0,r:c||0,transform:o?`scale(1, -1) translate(0, -${e})`:void 0,strokeDasharray:f,strokeDashoffset:o?0:l||0}}function dD({size:e,value:t,offset:n,sum:r,thickness:o,root:l,color:c,lineRoundCaps:d,tooltip:f,getStyles:p,display:m,...g}){const x=Sn();return a.jsx(ca.Floating,{disabled:!f,label:f,children:a.jsx(ce,{component:"circle",...g,...p("curve"),__vars:{"--curve-color":c?Ft(c,x):void 0},fill:"none",strokeLinecap:d?"round":"butt",...bz({sum:r,size:e,thickness:o,value:t,offset:n,root:l})})})}dD.displayName="@mantine/core/Curve";function Sz({size:e,thickness:t,sections:n,renderRoundedLineCaps:r,rootColor:o}){const l=n.reduce((m,g)=>m+g.value,0),c=Math.PI*((e*.9-t*2)/2)*2;let d=c;const f=[],p=[];for(let m=0;m<n.length;m+=1)f.push({sum:l,offset:d,data:n[m],root:!1}),d-=n[m].value/100*c;if(f.push({sum:l,offset:d,data:{color:o},root:!0}),p.push({...f[f.length-1],lineRoundCaps:!1}),f.length>2){p.push({...f[0],lineRoundCaps:r}),p.push({...f[f.length-2],lineRoundCaps:r});for(let m=1;m<=f.length-3;m+=1)p.push({...f[m],lineRoundCaps:!1})}else p.push({...f[0],lineRoundCaps:r});return p}var fD={root:"m_b32e4812",svg:"m_d43b5134",curve:"m_b1ca1fbf",label:"m_b23f9dc4"};function wz(e,t){return Math.min(e||12,(t||120)/4)}const jz={size:120,thickness:12},Cz=(e,{size:t,thickness:n,transitionDuration:r})=>({root:{"--rp-size":le(t),"--rp-label-offset":le(n*2),"--rp-transition-duration":r?`${r}ms`:void 0}}),sm=be((e,t)=>{const n=ae("RingProgress",jz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,label:p,sections:m,size:g,thickness:x,roundCaps:b,rootColor:w,transitionDuration:j,...C}=n,T=$e({name:"RingProgress",classes:fD,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:Cz}),E=wz(x,g),R=Sz({size:g,thickness:E,sections:m,renderRoundedLineCaps:b,rootColor:w}).map(({data:D,sum:P,root:A,lineRoundCaps:k,offset:M},$)=>v.createElement(dD,{...D,key:$,size:g,thickness:E,sum:P,offset:M,color:D?.color,root:A,lineRoundCaps:k,getStyles:T}));return a.jsxs(ce,{...T("root"),size:g,ref:t,...C,children:[a.jsx("svg",{...T("svg"),children:R}),p&&a.jsx("div",{...T("label"),children:p})]})});sm.classes=fD;sm.displayName="@mantine/core/RingProgress";var hD={root:"m_cf365364",indicator:"m_9e182ccd",label:"m_1738fcb2",input:"m_1714d588",control:"m_69686b9b",innerLabel:"m_78882f40"};const Ez={withItemsBorders:!0},Tz=(e,{radius:t,color:n,transitionDuration:r,size:o,transitionTimingFunction:l})=>({root:{"--sc-radius":t===void 0?void 0:$t(t),"--sc-color":n?Ft(n,e):void 0,"--sc-shadow":n?void 0:"var(--mantine-shadow-xs)","--sc-transition-duration":r===void 0?void 0:`${r}ms`,"--sc-transition-timing-function":l,"--sc-padding":at(o,"sc-padding"),"--sc-font-size":In(o)}}),Id=be((e,t)=>{const n=ae("SegmentedControl",Ez,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,data:p,value:m,defaultValue:g,onChange:x,size:b,name:w,disabled:j,readOnly:C,fullWidth:T,orientation:E,radius:R,color:D,transitionDuration:P,transitionTimingFunction:A,variant:k,autoContrast:M,withItemsBorders:$,mod:U,...J}=n,Z=$e({name:"SegmentedControl",props:n,classes:hD,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:Tz}),Y=Sn(),H=p.map(Ee=>typeof Ee=="string"?{label:Ee,value:Ee}:Ee),Q=s4(),[O,I]=v.useState(Qh()),[z,F]=v.useState(null),[K,L]=v.useState({}),q=(Ee,Ge)=>{K[Ge]=Ee,L(K)},[ie,xe]=Zn({value:m,defaultValue:g,finalValue:Array.isArray(p)?H.find(Ee=>!Ee.disabled)?.value??p[0]?.value??null:null,onChange:x}),ve=_r(w),Ce=H.map(Ee=>v.createElement(ce,{...Z("control"),mod:{active:ie===Ee.value,orientation:E},key:Ee.value},v.createElement("input",{...Z("input"),disabled:j||Ee.disabled,type:"radio",name:ve,value:Ee.value,id:`${ve}-${Ee.value}`,checked:ie===Ee.value,onChange:()=>!C&&xe(Ee.value),"data-focus-ring":Y.focusRing,key:`${Ee.value}-input`}),v.createElement(ce,{component:"label",...Z("label"),mod:{active:ie===Ee.value&&!(j||Ee.disabled),disabled:j||Ee.disabled,"read-only":C},htmlFor:`${ve}-${Ee.value}`,ref:Ge=>q(Ge,Ee.value),__vars:{"--sc-label-color":D!==void 0?ma({color:D,theme:Y,autoContrast:M}):void 0},key:`${Ee.value}-label`},a.jsx("span",{...Z("innerLabel"),children:Ee.label})))),Oe=qn(t,Ee=>F(Ee));return i4(()=>{I(Qh())},[p.length]),p.length===0?null:a.jsxs(ce,{...Z("root"),variant:k,size:b,ref:Oe,mod:[{"full-width":T,orientation:E,initialized:Q,"with-items-borders":$},U],...J,role:"radiogroup","data-disabled":j,children:[typeof ie=="string"&&a.jsx(f0,{target:K[ie],parent:z,component:"span",transitionDuration:"var(--sc-transition-duration)",...Z("indicator")},O),Ce]})});Id.classes=hD;Id.displayName="@mantine/core/SegmentedControl";function Rz({spacing:e,verticalSpacing:t,cols:n,selector:r}){const o=Sn(),l=t===void 0?e:t,c=ds({"--sg-spacing-x":Ln(Hi(e)),"--sg-spacing-y":Ln(Hi(l)),"--sg-cols":Hi(n)?.toString()}),d=rn(o.breakpoints).reduce((m,g)=>(m[g]||(m[g]={}),typeof e=="object"&&e[g]!==void 0&&(m[g]["--sg-spacing-x"]=Ln(e[g])),typeof l=="object"&&l[g]!==void 0&&(m[g]["--sg-spacing-y"]=Ln(l[g])),typeof n=="object"&&n[g]!==void 0&&(m[g]["--sg-cols"]=n[g]),m),{}),p=ad(rn(d),o.breakpoints).filter(m=>rn(d[m.value]).length>0).map(m=>({query:`(min-width: ${o.breakpoints[m.value]})`,styles:d[m.value]}));return a.jsx(pl,{styles:c,media:p,selector:r})}function hy(e){return typeof e=="object"&&e!==null?rn(e):[]}function _z(e){return e.sort((t,n)=>od(t)-od(n))}function Dz({spacing:e,verticalSpacing:t,cols:n}){const r=Array.from(new Set([...hy(e),...hy(t),...hy(n)]));return _z(r)}function Az({spacing:e,verticalSpacing:t,cols:n,selector:r}){const o=t===void 0?e:t,l=ds({"--sg-spacing-x":Ln(Hi(e)),"--sg-spacing-y":Ln(Hi(o)),"--sg-cols":Hi(n)?.toString()}),c=Dz({spacing:e,verticalSpacing:t,cols:n}),d=c.reduce((p,m)=>(p[m]||(p[m]={}),typeof e=="object"&&e[m]!==void 0&&(p[m]["--sg-spacing-x"]=Ln(e[m])),typeof o=="object"&&o[m]!==void 0&&(p[m]["--sg-spacing-y"]=Ln(o[m])),typeof n=="object"&&n[m]!==void 0&&(p[m]["--sg-cols"]=n[m]),p),{}),f=c.map(p=>({query:`simple-grid (min-width: ${p})`,styles:d[p]}));return a.jsx(pl,{styles:l,container:f,selector:r})}var pD={container:"m_925c2d2c",root:"m_2415a157"};const Pz={cols:1,spacing:"md",type:"media"},lm=be((e,t)=>{const n=ae("SimpleGrid",Pz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,cols:p,verticalSpacing:m,spacing:g,type:x,...b}=n,w=$e({name:"SimpleGrid",classes:pD,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f}),j=jd();return x==="container"?a.jsxs(a.Fragment,{children:[a.jsx(Az,{...n,selector:`.${j}`}),a.jsx("div",{...w("container"),children:a.jsx(ce,{ref:t,...w("root",{className:j}),...b})})]}):a.jsxs(a.Fragment,{children:[a.jsx(Rz,{...n,selector:`.${j}`}),a.jsx(ce,{ref:t,...w("root",{className:j}),...b})]})});lm.classes=pD;lm.displayName="@mantine/core/SimpleGrid";const kz={},cm=be((e,t)=>{const{w:n,h:r,miw:o,mih:l,...c}=ae("Space",kz,e);return a.jsx(ce,{ref:t,...c,w:n,miw:o??n,h:r,mih:l??r})});cm.displayName="@mantine/core/Space";var mD={root:"m_6d731127"};const Nz={gap:"md",align:"stretch",justify:"flex-start"},Oz=(e,{gap:t,align:n,justify:r})=>({root:{"--stack-gap":Ln(t),"--stack-align":n,"--stack-justify":r}}),Be=be((e,t)=>{const n=ae("Stack",Nz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,align:p,justify:m,gap:g,variant:x,...b}=n,w=$e({name:"Stack",props:n,classes:mD,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:Oz});return a.jsx(ce,{ref:t,...w("root"),variant:x,...b})});Be.classes=mD;Be.displayName="@mantine/core/Stack";const[Mz,Lz]=Rr("Stepper component was not found in tree"),ep=()=>null;ep.displayName="@mantine/core/StepperCompleted";var ob={root:"m_cbb4ea7e",steps:"m_aaf89d0b",separator:"m_2a371ac9",content:"m_78da155d",step:"m_cbb57068","step--horizontal":"m_f56b1e2c","step--vertical":"m_833edb7e",verticalSeparator:"m_6496b3f3",stepWrapper:"m_818e70b",stepIcon:"m_1959ad01",stepCompletedIcon:"m_a79331dc",stepBody:"m_1956aa2a",stepLabel:"m_12051f6c",stepDescription:"m_164eea74"};const xh=(e,t)=>typeof e=="function"?a.jsx(e,{step:t||0}):e,Iz={withIcon:!0,allowStepClick:!0,iconPosition:"left"},ab=be((e,t)=>{const{classNames:n,className:r,style:o,styles:l,vars:c,step:d,state:f,color:p,icon:m,completedIcon:g,progressIcon:x,label:b,description:w,withIcon:j,iconSize:C,loading:T,allowStepClick:E,allowStepSelect:R,iconPosition:D,orientation:P,mod:A,...k}=ae("StepperStep",Iz,e),M=Lz(),$=Sn(),U={classNames:n,styles:l},J=f==="stepCompleted"?null:f==="stepProgress"?x:m,Z={"data-progress":f==="stepProgress"||void 0,"data-completed":f==="stepCompleted"||void 0};return a.jsxs(sr,{...M.getStyles("step",{className:r,style:o,variant:M.orientation,...U}),mod:[{"icon-position":D||M.iconPosition,"allow-click":E},A],ref:t,...Z,...k,__vars:{"--step-color":p?Ft(p,$):void 0},tabIndex:E?0:-1,children:[j&&a.jsxs("span",{...M.getStyles("stepWrapper",U),children:[a.jsxs("span",{...M.getStyles("stepIcon",U),...Z,children:[a.jsx(_o,{mounted:f==="stepCompleted",transition:"pop",duration:200,children:Y=>a.jsx("span",{...M.getStyles("stepCompletedIcon",{style:Y,...U}),children:T?a.jsx(Fr,{color:"var(--mantine-color-white)",size:"calc(var(--stepper-icon-size) / 2)",...M.getStyles("stepLoader",U)}):xh(g,d)||a.jsx(Ad,{size:"60%"})})}),f!=="stepCompleted"?T?a.jsx(Fr,{...M.getStyles("stepLoader",U),size:"calc(var(--stepper-icon-size) / 2)",color:p}):xh(J||m,d):null]}),P==="vertical"&&a.jsx("span",{...M.getStyles("verticalSeparator",U),"data-active":f==="stepCompleted"||void 0})]}),(b||w)&&a.jsxs("span",{...M.getStyles("stepBody",U),"data-orientation":M.orientation,"data-icon-position":D||M.iconPosition,children:[b&&a.jsx("span",{...M.getStyles("stepLabel",U),children:xh(b,d)}),w&&a.jsx("span",{...M.getStyles("stepDescription",U),children:xh(w,d)})]})]})});ab.classes=ob;ab.displayName="@mantine/core/StepperStep";const zz={orientation:"horizontal",iconPosition:"left",allowNextStepsSelect:!0,wrap:!0},$z=(e,{color:t,iconSize:n,size:r,contentPadding:o,radius:l,autoContrast:c})=>({root:{"--stepper-color":t?Ft(t,e):void 0,"--stepper-icon-color":hl(c,e)?ma({color:t,theme:e,autoContrast:c}):void 0,"--stepper-icon-size":n===void 0?at(r,"stepper-icon-size"):le(n),"--stepper-content-padding":Ln(o),"--stepper-radius":l===void 0?void 0:$t(l),"--stepper-fz":In(r),"--stepper-spacing":Ln(r)}}),Mc=be((e,t)=>{const n=ae("Stepper",zz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,children:p,onStepClick:m,active:g,icon:x,completedIcon:b,progressIcon:w,color:j,iconSize:C,contentPadding:T,orientation:E,iconPosition:R,size:D,radius:P,allowNextStepsSelect:A,wrap:k,autoContrast:M,...$}=n,U=$e({name:"Stepper",classes:ob,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:$z}),J=v.Children.toArray(p),Z=J.filter(z=>z.type!==ep),Y=J.find(z=>z.type===ep),H=Z.reduce((z,F,K)=>{const L=g===K?"stepProgress":g>K?"stepCompleted":"stepInactive",ie=typeof m!="function"?!1:typeof F.props.allowStepSelect=="boolean"?F.props.allowStepSelect:L==="stepCompleted"||A;return z.push(v.cloneElement(F,{icon:F.props.icon||x||K+1,key:K,step:K,state:L,onClick:()=>ie&&m?.(K),allowStepClick:ie,completedIcon:F.props.completedIcon||b,progressIcon:F.props.progressIcon||w,color:F.props.color||j,iconSize:C,iconPosition:F.props.iconPosition||R,orientation:E})),E==="horizontal"&&K!==Z.length-1&&z.push(v.createElement("div",{...U("separator"),"data-active":K<g||void 0,"data-orientation":E,key:`separator-${K}`})),z},[]),Q=Z[g]?.props?.children,O=Y?.props?.children,I=g>Z.length-1?O:Q;return a.jsx(Mz,{value:{getStyles:U,orientation:E,iconPosition:R},children:a.jsxs(ce,{...U("root"),ref:t,size:D,...$,children:[a.jsx(ce,{...U("steps"),mod:{orientation:E,"icon-position":R,wrap:k&&E!=="vertical"},children:H}),I&&a.jsx("div",{...U("content"),children:I})]})})});Mc.classes=ob;Mc.displayName="@mantine/core/Stepper";Mc.Completed=ep;Mc.Step=ab;const gD=v.createContext(null),Uz=gD.Provider,Bz=()=>v.useContext(gD),Vz={},sb=be((e,t)=>{const{value:n,defaultValue:r,onChange:o,size:l,wrapperProps:c,children:d,readOnly:f,...p}=ae("SwitchGroup",Vz,e),[m,g]=Zn({value:n,defaultValue:r,finalValue:[],onChange:o}),x=b=>{const w=b.currentTarget.value;!f&&g(m.includes(w)?m.filter(j=>j!==w):[...m,w])};return a.jsx(Uz,{value:{value:m,onChange:x,size:l},children:a.jsx(un.Wrapper,{size:l,ref:t,...c,...p,labelElement:"div",__staticSelector:"SwitchGroup",children:a.jsx(D0,{role:"group",children:d})})})});sb.classes=un.Wrapper.classes;sb.displayName="@mantine/core/SwitchGroup";var vD={root:"m_5f93f3bb",input:"m_926b4011",track:"m_9307d992",thumb:"m_93039a1d",trackLabel:"m_8277e082"};const Fz={labelPosition:"right"},Hz=(e,{radius:t,color:n,size:r})=>({root:{"--switch-radius":t===void 0?void 0:$t(t),"--switch-height":at(r,"switch-height"),"--switch-width":at(r,"switch-width"),"--switch-thumb-size":at(r,"switch-thumb-size"),"--switch-label-font-size":at(r,"switch-label-font-size"),"--switch-track-label-padding":at(r,"switch-track-label-padding"),"--switch-color":n?Ft(n,e):void 0}}),zd=be((e,t)=>{const n=ae("Switch",Fz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,color:p,label:m,offLabel:g,onLabel:x,id:b,size:w,radius:j,wrapperProps:C,thumbIcon:T,checked:E,defaultChecked:R,onChange:D,labelPosition:P,description:A,error:k,disabled:M,variant:$,rootRef:U,mod:J,...Z}=n,Y=Bz(),H=w||Y?.size,Q=$e({name:"Switch",props:n,classes:vD,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:Hz}),{styleProps:O,rest:I}=ga(Z),z=_r(b),F=Y?{checked:Y.value.includes(I.value),onChange:Y.onChange}:{},[K,L]=Zn({value:F.checked??E,defaultValue:R,finalValue:!1});return a.jsxs(Vp,{...Q("root"),__staticSelector:"Switch",__stylesApiProps:n,id:z,size:H,labelPosition:P,label:m,description:A,error:k,disabled:M,bodyElement:"label",labelElement:"span",classNames:r,styles:c,unstyled:d,"data-checked":F.checked||E||void 0,variant:$,ref:U,mod:J,...O,...C,children:[a.jsx("input",{...I,disabled:M,checked:K,"data-checked":F.checked||E||void 0,onChange:q=>{Y?F.onChange?.(q):D?.(q),L(q.currentTarget.checked)},id:z,ref:t,type:"checkbox",role:"switch",...Q("input")}),a.jsxs(ce,{"aria-hidden":"true",component:"span",mod:{error:k,"label-position":P,"without-labels":!x&&!g},...Q("track"),children:[a.jsx(ce,{component:"span",mod:"reduce-motion",...Q("thumb"),children:T}),a.jsx("span",{...Q("trackLabel"),children:K?x:g})]})]})});zd.classes={...vD,...j_};zd.displayName="@mantine/core/Switch";zd.Group=sb;const[qz,Gz]=Rr("Table component was not found in the tree");var $d={table:"m_b23fa0ef",th:"m_4e7aa4f3",tr:"m_4e7aa4fd",td:"m_4e7aa4ef",tbody:"m_b2404537",thead:"m_b242d975",caption:"m_9e5a3ac7",scrollContainer:"m_a100c15",scrollContainerInner:"m_62259741"};function Qz(e,t){if(!t)return;const n={};return t.columnBorder&&e.withColumnBorders&&(n["data-with-column-border"]=!0),t.rowBorder&&e.withRowBorders&&(n["data-with-row-border"]=!0),t.striped&&e.striped&&(n["data-striped"]=e.striped),t.highlightOnHover&&e.highlightOnHover&&(n["data-hover"]=!0),t.captionSide&&e.captionSide&&(n["data-side"]=e.captionSide),t.stickyHeader&&e.stickyHeader&&(n["data-sticky"]=!0),n}function yl(e,t){const n=`Table${e.charAt(0).toUpperCase()}${e.slice(1)}`,r=be((o,l)=>{const c=ae(n,{},o),{classNames:d,className:f,style:p,styles:m,...g}=c,x=Gz();return a.jsx(ce,{component:e,ref:l,...Qz(x,t),...x.getStyles(e,{className:f,classNames:d,style:p,styles:m,props:c}),...g})});return r.displayName=`@mantine/core/${n}`,r.classes=$d,r}const ox=yl("th",{columnBorder:!0}),yD=yl("td",{columnBorder:!0}),Lh=yl("tr",{rowBorder:!0,striped:!0,highlightOnHover:!0}),xD=yl("thead",{stickyHeader:!0}),bD=yl("tbody"),SD=yl("tfoot"),wD=yl("caption",{captionSide:!0});function lb({data:e}){return a.jsxs(a.Fragment,{children:[e.caption&&a.jsx(wD,{children:e.caption}),e.head&&a.jsx(xD,{children:a.jsx(Lh,{children:e.head.map((t,n)=>a.jsx(ox,{children:t},n))})}),e.body&&a.jsx(bD,{children:e.body.map((t,n)=>a.jsx(Lh,{children:t.map((r,o)=>a.jsx(yD,{children:r},o))},n))}),e.foot&&a.jsx(SD,{children:a.jsx(Lh,{children:e.foot.map((t,n)=>a.jsx(ox,{children:t},n))})})]})}lb.displayName="@mantine/core/TableDataRenderer";const Wz={type:"scrollarea"},Yz=(e,{minWidth:t,maxHeight:n,type:r})=>({scrollContainer:{"--table-min-width":le(t),"--table-max-height":le(n),"--table-overflow":r==="native"?"auto":void 0}}),cb=be((e,t)=>{const n=ae("TableScrollContainer",Wz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,children:p,minWidth:m,maxHeight:g,type:x,scrollAreaProps:b,...w}=n,j=$e({name:"TableScrollContainer",classes:$d,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:Yz,rootSelector:"scrollContainer"});return a.jsx(ce,{component:x==="scrollarea"?ai:"div",...x==="scrollarea"?g?{offsetScrollbars:"xy",...b}:{offsetScrollbars:"x",...b}:{},ref:t,...j("scrollContainer"),...w,children:a.jsx("div",{...j("scrollContainerInner"),children:p})})});cb.classes=$d;cb.displayName="@mantine/core/TableScrollContainer";const Kz={withRowBorders:!0,verticalSpacing:7},Xz=(e,{layout:t,captionSide:n,horizontalSpacing:r,verticalSpacing:o,borderColor:l,stripedColor:c,highlightOnHoverColor:d,striped:f,highlightOnHover:p,stickyHeaderOffset:m,stickyHeader:g})=>({table:{"--table-layout":t,"--table-caption-side":n,"--table-horizontal-spacing":Ln(r),"--table-vertical-spacing":Ln(o),"--table-border-color":l?Ft(l,e):void 0,"--table-striped-color":f&&c?Ft(c,e):void 0,"--table-highlight-on-hover-color":p&&d?Ft(d,e):void 0,"--table-sticky-header-offset":g?le(m):void 0}}),fe=be((e,t)=>{const n=ae("Table",Kz,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,horizontalSpacing:p,verticalSpacing:m,captionSide:g,stripedColor:x,highlightOnHoverColor:b,striped:w,highlightOnHover:j,withColumnBorders:C,withRowBorders:T,withTableBorder:E,borderColor:R,layout:D,variant:P,data:A,children:k,stickyHeader:M,stickyHeaderOffset:$,mod:U,tabularNums:J,...Z}=n,Y=$e({name:"Table",props:n,className:o,style:l,classes:$d,classNames:r,styles:c,unstyled:d,rootSelector:"table",vars:f,varsResolver:Xz});return a.jsx(qz,{value:{getStyles:Y,stickyHeader:M,striped:w===!0?"odd":w||void 0,highlightOnHover:j,withColumnBorders:C,withRowBorders:T,captionSide:g||"bottom"},children:a.jsx(ce,{component:"table",variant:P,ref:t,mod:[{"data-with-table-border":E,"data-tabular-nums":J},U],...Y("table"),...Z,children:k||!!A&&a.jsx(lb,{data:A})})})});fe.classes=$d;fe.displayName="@mantine/core/Table";fe.Td=yD;fe.Th=ox;fe.Tr=Lh;fe.Thead=xD;fe.Tbody=bD;fe.Tfoot=SD;fe.Caption=wD;fe.ScrollContainer=cb;fe.DataRenderer=lb;const[Zz,ub]=Rr("Tabs component was not found in the tree");var Ud={root:"m_89d60db1","list--default":"m_576c9d4",list:"m_89d33d6d",panel:"m_b0c91715",tab:"m_4ec4dce6",tabSection:"m_fc420b1f","tab--default":"m_539e827b","list--outline":"m_6772fbd5","tab--outline":"m_b59ab47c","tab--pills":"m_c3381914"};const Jz={},db=be((e,t)=>{const n=ae("TabsList",Jz,e),{children:r,className:o,grow:l,justify:c,classNames:d,styles:f,style:p,mod:m,...g}=n,x=ub();return a.jsx(ce,{...g,...x.getStyles("list",{className:o,style:p,classNames:d,styles:f,props:n,variant:x.variant}),ref:t,role:"tablist",variant:x.variant,mod:[{grow:l,orientation:x.orientation,placement:x.orientation==="vertical"&&x.placement,inverted:x.inverted},m],"aria-orientation":x.orientation,__vars:{"--tabs-justify":c},children:r})});db.classes=Ud;db.displayName="@mantine/core/TabsList";const e$={},fb=be((e,t)=>{const n=ae("TabsPanel",e$,e),{children:r,className:o,value:l,classNames:c,styles:d,style:f,mod:p,keepMounted:m,...g}=n,x=ub(),b=x.value===l,w=x.keepMounted||m||b?r:null;return a.jsx(ce,{...g,...x.getStyles("panel",{className:o,classNames:c,styles:d,style:[f,b?void 0:{display:"none"}],props:n}),ref:t,mod:[{orientation:x.orientation},p],role:"tabpanel",id:x.getPanelId(l),"aria-labelledby":x.getTabId(l),children:w})});fb.classes=Ud;fb.displayName="@mantine/core/TabsPanel";const t$={},hb=be((e,t)=>{const n=ae("TabsTab",t$,e),{className:r,children:o,rightSection:l,leftSection:c,value:d,onClick:f,onKeyDown:p,disabled:m,color:g,style:x,classNames:b,styles:w,vars:j,mod:C,tabIndex:T,...E}=n,R=Sn(),{dir:D}=ml(),P=ub(),A=d===P.value,k=$=>{P.onChange(P.allowTabDeactivation&&d===P.value?null:d),f?.($)},M={classNames:b,styles:w,props:n};return a.jsxs(sr,{...E,...P.getStyles("tab",{className:r,style:x,variant:P.variant,...M}),disabled:m,unstyled:P.unstyled,variant:P.variant,mod:[{active:A,disabled:m,orientation:P.orientation,inverted:P.inverted,placement:P.orientation==="vertical"&&P.placement},C],ref:t,role:"tab",id:P.getTabId(d),"aria-selected":A,tabIndex:T!==void 0?T:A||P.value===null?0:-1,"aria-controls":P.getPanelId(d),onClick:k,__vars:{"--tabs-color":g?Ft(g,R):void 0},onKeyDown:zR({siblingSelector:'[role="tab"]',parentSelector:'[role="tablist"]',activateOnFocus:P.activateTabWithKeyboard,loop:P.loop,orientation:P.orientation||"horizontal",dir:D,onKeyDown:p}),children:[c&&a.jsx("span",{...P.getStyles("tabSection",M),"data-position":"left",children:c}),o&&a.jsx("span",{...P.getStyles("tabLabel",M),children:o}),l&&a.jsx("span",{...P.getStyles("tabSection",M),"data-position":"right",children:l})]})});hb.classes=Ud;hb.displayName="@mantine/core/TabsTab";const RE="Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value",n$={keepMounted:!0,orientation:"horizontal",loop:!0,activateTabWithKeyboard:!0,allowTabDeactivation:!1,unstyled:!1,inverted:!1,variant:"default",placement:"left"},r$=(e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":$t(t),"--tabs-color":Ft(n,e),"--tabs-text-color":hl(r,e)?ma({color:n,theme:e,autoContrast:r}):void 0}}),Tt=be((e,t)=>{const n=ae("Tabs",n$,e),{defaultValue:r,value:o,onChange:l,orientation:c,children:d,loop:f,id:p,activateTabWithKeyboard:m,allowTabDeactivation:g,variant:x,color:b,radius:w,inverted:j,placement:C,keepMounted:T,classNames:E,styles:R,unstyled:D,className:P,style:A,vars:k,autoContrast:M,mod:$,...U}=n,J=_r(p),[Z,Y]=Zn({value:o,defaultValue:r,finalValue:null,onChange:l}),H=$e({name:"Tabs",props:n,classes:Ud,className:P,style:A,classNames:E,styles:R,unstyled:D,vars:k,varsResolver:r$});return a.jsx(Zz,{value:{placement:C,value:Z,orientation:c,id:J,loop:f,activateTabWithKeyboard:m,getTabId:bC(`${J}-tab`,RE),getPanelId:bC(`${J}-panel`,RE),onChange:Y,allowTabDeactivation:g,variant:x,color:b,radius:w,inverted:j,keepMounted:T,unstyled:D,getStyles:H},children:a.jsx(ce,{ref:t,id:J,variant:x,mod:[{orientation:c,inverted:c==="horizontal"&&j,placement:c==="vertical"&&C},$],...H("root"),...U,children:d})})});Tt.classes=Ud;Tt.displayName="@mantine/core/Tabs";Tt.Tab=hb;Tt.Panel=fb;Tt.List=db;const i$={},Ve=be((e,t)=>{const n=ae("TextInput",i$,e);return a.jsx(Dr,{component:"input",ref:t,...n,__staticSelector:"TextInput"})});Ve.classes=Dr.classes;Ve.displayName="@mantine/core/TextInput";var jD={root:"m_7341320d"};const o$={},a$=(e,{size:t,radius:n,variant:r,gradient:o,color:l,autoContrast:c})=>{const d=e.variantColorResolver({color:l||e.primaryColor,theme:e,gradient:o,variant:r||"filled",autoContrast:c});return{root:{"--ti-size":at(t,"ti-size"),"--ti-radius":n===void 0?void 0:$t(n),"--ti-bg":l||r?d.background:void 0,"--ti-color":l||r?d.color:void 0,"--ti-bd":l||r?d.border:void 0}}},pb=be((e,t)=>{const n=ae("ThemeIcon",o$,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,autoContrast:p,...m}=n,g=$e({name:"ThemeIcon",classes:jD,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:a$});return a.jsx(ce,{ref:t,...g("root"),...m})});pb.classes=jD;pb.displayName="@mantine/core/ThemeIcon";const s$=["h1","h2","h3","h4","h5","h6"],l$=["xs","sm","md","lg","xl"];function c$(e,t){const n=t!==void 0?t:`h${e}`;return s$.includes(n)?{fontSize:`var(--mantine-${n}-font-size)`,fontWeight:`var(--mantine-${n}-font-weight)`,lineHeight:`var(--mantine-${n}-line-height)`}:l$.includes(n)?{fontSize:`var(--mantine-font-size-${n})`,fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}:{fontSize:le(n),fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}}var CD={root:"m_8a5d1357"};const u$={order:1},d$=(e,{order:t,size:n,lineClamp:r,textWrap:o})=>{const l=c$(t,n);return{root:{"--title-fw":l.fontWeight,"--title-lh":l.lineHeight,"--title-fz":l.fontSize,"--title-line-clamp":typeof r=="number"?r.toString():void 0,"--title-text-wrap":o}}},Ie=be((e,t)=>{const n=ae("Title",u$,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,order:f,vars:p,size:m,variant:g,lineClamp:x,textWrap:b,mod:w,...j}=n,C=$e({name:"Title",props:n,classes:CD,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:p,varsResolver:d$});return[1,2,3,4,5,6].includes(f)?a.jsx(ce,{...C("root"),component:`h${f}`,variant:g,ref:t,mod:[{order:f,"data-line-clamp":typeof x=="number"},w],size:m,...j}):null});Ie.classes=CD;Ie.displayName="@mantine/core/Title";function f$(e){let t=e,n=!1;const r=new Set;return{getState(){return t},updateState(o){t=typeof o=="function"?o(t):o},setState(o){this.updateState(o),r.forEach(l=>l(t))},initialize(o){n||(t=o,n=!0)},subscribe(o){return r.add(o),()=>r.delete(o)}}}function h$(e){return v.useSyncExternalStore(e.subscribe,()=>e.getState(),()=>e.getState())}function p$(e,t,n){const r=[],o=[],l={};for(const c of e){const d=c.position||t;l[d]=l[d]||0,l[d]+=1,l[d]<=n?o.push(c):r.push(c)}return{notifications:o,queue:r}}const m$=()=>f$({notifications:[],queue:[],defaultPosition:"bottom-right",limit:5}),xl=m$(),g$=(e=xl)=>h$(e);function Xc(e,t){const n=e.getState(),r=t([...n.notifications,...n.queue]),o=p$(r,n.defaultPosition,n.limit);e.setState({notifications:o.notifications,queue:o.queue,limit:n.limit,defaultPosition:n.defaultPosition})}function Ne(e,t=xl){const n=e.id||Qh();return Xc(t,r=>e.id&&r.some(o=>o.id===e.id)?r:[...r,{...e,id:n}]),n}function ED(e,t=xl){return Xc(t,n=>n.filter(r=>r.id===e?(r.onClose?.(r),!1):!0)),e}function Qs(e,t=xl){return Xc(t,n=>n.map(r=>r.id===e.id?{...r,...e}:r)),e.id}function v$(e=xl){Xc(e,()=>[])}function y$(e=xl){Xc(e,t=>t.slice(0,e.getState().limit))}const Ci={show:Ne,hide:ED,update:Qs,clean:v$,cleanQueue:y$,updateState:Xc};function ax(e,t){return ax=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},ax(e,t)}function TD(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,ax(e,t)}var py={exports:{}},my,_E;function x$(){if(_E)return my;_E=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return my=e,my}var gy,DE;function b$(){if(DE)return gy;DE=1;var e=x$();function t(){}function n(){}return n.resetWarningCache=t,gy=function(){function r(c,d,f,p,m,g){if(g!==e){var x=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw x.name="Invariant Violation",x}}r.isRequired=r;function o(){return r}var l={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return l.PropTypes=l,l},gy}var AE;function S$(){return AE||(AE=1,py.exports=b$()()),py.exports}var w$=S$();const nn=Ox(w$),PE={disabled:!1},tp=Tn.createContext(null);var j$=function(t){return t.scrollTop},td="unmounted",Bs="exited",Vs="entering",bc="entered",sx="exiting",ba=(function(e){TD(t,e);function t(r,o){var l;l=e.call(this,r,o)||this;var c=o,d=c&&!c.isMounting?r.enter:r.appear,f;return l.appearStatus=null,r.in?d?(f=Bs,l.appearStatus=Vs):f=bc:r.unmountOnExit||r.mountOnEnter?f=td:f=Bs,l.state={status:f},l.nextCallback=null,l}t.getDerivedStateFromProps=function(o,l){var c=o.in;return c&&l.status===td?{status:Bs}:null};var n=t.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(o){var l=null;if(o!==this.props){var c=this.state.status;this.props.in?c!==Vs&&c!==bc&&(l=Vs):(c===Vs||c===bc)&&(l=sx)}this.updateStatus(!1,l)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var o=this.props.timeout,l,c,d;return l=c=d=o,o!=null&&typeof o!="number"&&(l=o.exit,c=o.enter,d=o.appear!==void 0?o.appear:c),{exit:l,enter:c,appear:d}},n.updateStatus=function(o,l){if(o===void 0&&(o=!1),l!==null)if(this.cancelNextCallback(),l===Vs){if(this.props.unmountOnExit||this.props.mountOnEnter){var c=this.props.nodeRef?this.props.nodeRef.current:ed.findDOMNode(this);c&&j$(c)}this.performEnter(o)}else this.performExit();else this.props.unmountOnExit&&this.state.status===Bs&&this.setState({status:td})},n.performEnter=function(o){var l=this,c=this.props.enter,d=this.context?this.context.isMounting:o,f=this.props.nodeRef?[d]:[ed.findDOMNode(this),d],p=f[0],m=f[1],g=this.getTimeouts(),x=d?g.appear:g.enter;if(!o&&!c||PE.disabled){this.safeSetState({status:bc},function(){l.props.onEntered(p)});return}this.props.onEnter(p,m),this.safeSetState({status:Vs},function(){l.props.onEntering(p,m),l.onTransitionEnd(x,function(){l.safeSetState({status:bc},function(){l.props.onEntered(p,m)})})})},n.performExit=function(){var o=this,l=this.props.exit,c=this.getTimeouts(),d=this.props.nodeRef?void 0:ed.findDOMNode(this);if(!l||PE.disabled){this.safeSetState({status:Bs},function(){o.props.onExited(d)});return}this.props.onExit(d),this.safeSetState({status:sx},function(){o.props.onExiting(d),o.onTransitionEnd(c.exit,function(){o.safeSetState({status:Bs},function(){o.props.onExited(d)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(o,l){l=this.setNextCallback(l),this.setState(o,l)},n.setNextCallback=function(o){var l=this,c=!0;return this.nextCallback=function(d){c&&(c=!1,l.nextCallback=null,o(d))},this.nextCallback.cancel=function(){c=!1},this.nextCallback},n.onTransitionEnd=function(o,l){this.setNextCallback(l);var c=this.props.nodeRef?this.props.nodeRef.current:ed.findDOMNode(this),d=o==null&&!this.props.addEndListener;if(!c||d){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var f=this.props.nodeRef?[this.nextCallback]:[c,this.nextCallback],p=f[0],m=f[1];this.props.addEndListener(p,m)}o!=null&&setTimeout(this.nextCallback,o)},n.render=function(){var o=this.state.status;if(o===td)return null;var l=this.props,c=l.children;l.in,l.mountOnEnter,l.unmountOnExit,l.appear,l.enter,l.exit,l.timeout,l.addEndListener,l.onEnter,l.onEntering,l.onEntered,l.onExit,l.onExiting,l.onExited,l.nodeRef;var d=$0(l,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return Tn.createElement(tp.Provider,{value:null},typeof c=="function"?c(o,d):Tn.cloneElement(Tn.Children.only(c),d))},t})(Tn.Component);ba.contextType=tp;ba.propTypes={};function hc(){}ba.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:hc,onEntering:hc,onEntered:hc,onExit:hc,onExiting:hc,onExited:hc};ba.UNMOUNTED=td;ba.EXITED=Bs;ba.ENTERING=Vs;ba.ENTERED=bc;ba.EXITING=sx;function C$(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function mb(e,t){var n=function(l){return t&&v.isValidElement(l)?t(l):l},r=Object.create(null);return e&&v.Children.map(e,function(o){return o}).forEach(function(o){r[o.key]=n(o)}),r}function E$(e,t){e=e||{},t=t||{};function n(m){return m in t?t[m]:e[m]}var r=Object.create(null),o=[];for(var l in e)l in t?o.length&&(r[l]=o,o=[]):o.push(l);var c,d={};for(var f in t){if(r[f])for(c=0;c<r[f].length;c++){var p=r[f][c];d[r[f][c]]=n(p)}d[f]=n(f)}for(c=0;c<o.length;c++)d[o[c]]=n(o[c]);return d}function Ws(e,t,n){return n[t]!=null?n[t]:e.props[t]}function T$(e,t){return mb(e.children,function(n){return v.cloneElement(n,{onExited:t.bind(null,n),in:!0,appear:Ws(n,"appear",e),enter:Ws(n,"enter",e),exit:Ws(n,"exit",e)})})}function R$(e,t,n){var r=mb(e.children),o=E$(t,r);return Object.keys(o).forEach(function(l){var c=o[l];if(v.isValidElement(c)){var d=l in t,f=l in r,p=t[l],m=v.isValidElement(p)&&!p.props.in;f&&(!d||m)?o[l]=v.cloneElement(c,{onExited:n.bind(null,c),in:!0,exit:Ws(c,"exit",e),enter:Ws(c,"enter",e)}):!f&&d&&!m?o[l]=v.cloneElement(c,{in:!1}):f&&d&&v.isValidElement(p)&&(o[l]=v.cloneElement(c,{onExited:n.bind(null,c),in:p.props.in,exit:Ws(c,"exit",e),enter:Ws(c,"enter",e)}))}}),o}var _$=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},D$={component:"div",childFactory:function(t){return t}},Xa=(function(e){TD(t,e);function t(r,o){var l;l=e.call(this,r,o)||this;var c=l.handleExited.bind(C$(l));return l.state={contextValue:{isMounting:!0},handleExited:c,firstRender:!0},l}var n=t.prototype;return n.componentDidMount=function(){this.mounted=!0,this.setState({contextValue:{isMounting:!1}})},n.componentWillUnmount=function(){this.mounted=!1},t.getDerivedStateFromProps=function(o,l){var c=l.children,d=l.handleExited,f=l.firstRender;return{children:f?T$(o,d):R$(o,c,d),firstRender:!1}},n.handleExited=function(o,l){var c=mb(this.props.children);o.key in c||(o.props.onExited&&o.props.onExited(l),this.mounted&&this.setState(function(d){var f=Jh({},d.children);return delete f[o.key],{children:f}}))},n.render=function(){var o=this.props,l=o.component,c=o.childFactory,d=$0(o,["component","childFactory"]),f=this.state.contextValue,p=_$(this.state.children).map(c);return delete d.appear,delete d.enter,delete d.exit,l===null?Tn.createElement(tp.Provider,{value:f},p):Tn.createElement(tp.Provider,{value:f},Tn.createElement(l,d,p))},t})(Tn.Component);Xa.propTypes={};Xa.defaultProps=D$;const RD=["bottom-center","bottom-left","bottom-right","top-center","top-left","top-right"];function A$(e,t){return e.reduce((n,r)=>(n[r.position||t].push(r),n),RD.reduce((n,r)=>(n[r]=[],n),{}))}const kE={left:"translateX(-100%)",right:"translateX(100%)","top-center":"translateY(-100%)","bottom-center":"translateY(100%)"},P$={left:"translateX(0)",right:"translateX(0)","top-center":"translateY(0)","bottom-center":"translateY(0)"};function k$({state:e,maxHeight:t,position:n,transitionDuration:r}){const[o,l]=n.split("-"),c=l==="center"?`${o}-center`:l,d={opacity:0,maxHeight:t,transform:kE[c],transitionDuration:`${r}ms, ${r}ms, ${r}ms`,transitionTimingFunction:"cubic-bezier(.51,.3,0,1.21), cubic-bezier(.51,.3,0,1.21), linear",transitionProperty:"opacity, transform, max-height"},f={opacity:1,transform:P$[c]},p={opacity:0,maxHeight:0,transform:kE[c]};return{...d,...{entering:f,entered:f,exiting:p,exited:p}[e]}}function N$(e,t){return typeof t=="number"?t:t===!1||e===!1?!1:e}const _D=v.forwardRef(({data:e,onHide:t,autoClose:n,...r},o)=>{const{autoClose:l,message:c,...d}=e,f=N$(n,e.autoClose),p=v.useRef(-1),m=()=>window.clearTimeout(p.current),g=()=>{t(e.id),m()},x=()=>{typeof f=="number"&&(p.current=window.setTimeout(g,f))};return v.useEffect(()=>{e.onOpen?.(e)},[]),v.useEffect(()=>(x(),m),[f]),a.jsx(X0,{...r,...d,onClose:g,ref:o,onMouseEnter:m,onMouseLeave:x,children:c})});_D.displayName="@mantine/notifications/NotificationContainer";var DD={root:"m_b37d9ac7",notification:"m_5ed0edd0"};const O$=ba,M$={position:"bottom-right",autoClose:4e3,transitionDuration:250,containerWidth:440,notificationMaxHeight:200,limit:5,zIndex:oi("overlay"),store:xl,withinPortal:!0},L$=(e,{zIndex:t,containerWidth:n})=>({root:{"--notifications-z-index":t?.toString(),"--notifications-container-width":le(n)}}),Sa=be((e,t)=>{const n=ae("Notifications",M$,e),{classNames:r,className:o,style:l,styles:c,unstyled:d,vars:f,position:p,autoClose:m,transitionDuration:g,containerWidth:x,notificationMaxHeight:b,limit:w,zIndex:j,store:C,portalProps:T,withinPortal:E,...R}=n,D=Sn(),P=g$(C),A=XO(),k=$x(),M=v.useRef({}),$=v.useRef(0),J=(D.respectReducedMotion?k:!1)?1:g,Z=$e({name:"Notifications",classes:DD,props:n,className:o,style:l,classNames:r,styles:c,unstyled:d,vars:f,varsResolver:L$});v.useEffect(()=>{C?.updateState(Q=>({...Q,limit:w||5,defaultPosition:p}))},[w,p]),oa(()=>{P.notifications.length>$.current&&setTimeout(()=>A(),0),$.current=P.notifications.length},[P.notifications]);const Y=A$(P.notifications,p),H=RD.reduce((Q,O)=>(Q[O]=Y[O].map(({style:I,...z})=>a.jsx(O$,{timeout:J,onEnter:()=>M.current[z.id].offsetHeight,nodeRef:{current:M.current[z.id]},children:F=>a.jsx(_D,{ref:K=>{M.current[z.id]=K},data:z,onHide:K=>ED(K,C),autoClose:m,...Z("notification",{style:{...k$({state:F,position:O,transitionDuration:J,maxHeight:b}),...I}})})},z.id)),Q),{});return a.jsxs(fs,{withinPortal:E,...T,children:[a.jsx(ce,{...Z("root"),"data-position":"top-center",ref:t,...R,children:a.jsx(Xa,{children:H["top-center"]})}),a.jsx(ce,{...Z("root"),"data-position":"top-left",...R,children:a.jsx(Xa,{children:H["top-left"]})}),a.jsx(ce,{...Z("root",{className:_c.classNames.fullWidth}),"data-position":"top-right",...R,children:a.jsx(Xa,{children:H["top-right"]})}),a.jsx(ce,{...Z("root",{className:_c.classNames.fullWidth}),"data-position":"bottom-right",...R,children:a.jsx(Xa,{children:H["bottom-right"]})}),a.jsx(ce,{...Z("root"),"data-position":"bottom-left",...R,children:a.jsx(Xa,{children:H["bottom-left"]})}),a.jsx(ce,{...Z("root"),"data-position":"bottom-center",...R,children:a.jsx(Xa,{children:H["bottom-center"]})})]})});Sa.classes=DD;Sa.displayName="@mantine/notifications/Notifications";Sa.show=Ci.show;Sa.hide=Ci.hide;Sa.update=Ci.update;Sa.clean=Ci.clean;Sa.cleanQueue=Ci.cleanQueue;Sa.updateState=Ci.updateState;class I${constructor(t,n){this.operator=t,this.child=n}toString(){return`${this.operator}(${this.child.toString()})`}}class Bd{constructor(t,n,r){this.operator=t,this.left=n,this.right=r}toString(){return`(${this.left.toString()} ${this.operator} ${this.right.toString()})`}}class z${constructor(){this.prefixParselets={},this.infixParselets={}}registerInfix(t,n){return this.infixParselets[t]=n,this}registerPrefix(t,n){return this.prefixParselets[t]=n,this}prefix(t,n,r){return this.registerPrefix(t,{parse(o,l){const c=o.consumeAndParse(n);return r(l,c)}})}infixLeft(t,n,r){return this.registerInfix(t,{parse(o,l,c){const d=o.consumeAndParse(n);return r(l,c,d)},precedence:n})}construct(t){return new $$(t,this.prefixParselets,this.infixParselets)}}class $${constructor(t,n,r){this.tokens=t,this.prefixParselets=n,this.infixParselets=r}hasMore(){return this.tokens.length>0}match(t){return this.peek()?.id!==t?!1:(this.consume(),!0)}consumeAndParse(t=1/0){const n=this.consume(),r=this.prefixParselets[n.id];if(!r)throw Error(`Parse error at "${n.value}" (line ${n.line}, column ${n.column}). No matching prefix parselet.`);let o=r.parse(this,n);for(;t>this.getPrecedence();){const l=this.consume();o=this.getInfixParselet(l).parse(this,o,l)}return o}getPrecedence(){const t=this.peek();if(!t)return 1/0;const n=this.getInfixParselet(t);return n?n.precedence:1/0}consume(t,n){if(!this.tokens.length)throw Error("Cant consume unknown more tokens.");if(t&&this.peek()?.id!==t){const r=this.peek();throw Error(`Expected ${t} but got "${r.id}" (${r.value}) at line ${r.line} column ${r.column}.`)}if(n&&this.peek()?.value!==n){const r=this.peek();throw Error(`Expected "${n}" but got "${r.value}" at line ${r.line} column ${r.column}.`)}return this.tokens.shift()}peek(){return this.tokens.length>0?this.tokens[0]:void 0}removeComments(){this.tokens=this.tokens.filter(t=>t.id!=="Comment")}getInfixParselet(t){return this.infixParselets[t.id==="Symbol"?t.value:t.id]}}class AD{constructor(t=10){this.max=t,this.cache=new Map}clear(){this.cache.clear()}get(t){const n=this.cache.get(t);return n&&(this.cache.delete(t),this.cache.set(t,n)),n}set(t,n){this.cache.has(t)?this.cache.delete(t):this.cache.size>=this.max&&this.cache.delete(this.first()),this.cache.set(t,n)}delete(t){this.cache.delete(t)}keys(){return this.cache.keys()}first(){return this.cache.keys().next().value}}const Ji="http://hl7.org",PD="ok",U$="created",B$="gone",V$="not-modified",F$="not-found",H$="unauthorized",q$="forbidden",G$="accepted",Q$={resourceType:"OperationOutcome",id:PD,issue:[{severity:"information",code:"informational",details:{text:"All OK"}}]},W$={resourceType:"OperationOutcome",id:F$,issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},hd={resourceType:"OperationOutcome",id:H$,issue:[{severity:"error",code:"login",details:{text:"Unauthorized"}}]},Y$={...hd,issue:[...hd.issue,{severity:"error",code:"expired",details:{text:"Token expired"}}]},NE={...hd,issue:[...hd.issue,{severity:"error",code:"invalid",details:{text:"Token not issued for this audience"}}]},Vd={resourceType:"OperationOutcome",id:q$,issue:[{severity:"error",code:"forbidden",details:{text:"Forbidden"}}]};function xo(e,t){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"invalid",details:{text:e},...t?{expression:[t]}:void 0}]}}function gn(e){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"structure",details:{text:e}}]}}function K$(e){return{resourceType:"OperationOutcome",issue:[{severity:"error",code:"exception",details:{text:"Internal server error"},diagnostics:e.toString()}]}}function X$(e){return!e||typeof e!="object"?!1:e instanceof Error||typeof DOMException<"u"&&e instanceof DOMException?!0:Object.prototype.toString.call(e)==="[object Error]"}function um(e){return typeof e=="object"&&e!==null&&e.resourceType==="OperationOutcome"}function kD(e){return e.id===PD||e.id===U$||e.id===V$||e.id===G$}function Z$(e){return e.id===B$}class ft extends Error{constructor(t,n){super(ND(t)),this.outcome=t,this.cause=n}}function qt(e){return e instanceof ft?e.outcome:um(e)?e:xo(Ye(e))}function Ye(e){return e?typeof e=="string"?e:X$(e)?e.message:um(e)?ND(e):typeof e=="object"&&"code"in e&&typeof e.code=="string"?e.code:JSON.stringify(e):"Unknown error"}function ND(e){const t=e.issue?.map(OD)??[];return t.length>0?t.join("; "):"Unknown error"}function OD(e){let t;return e.details?.text?e.diagnostics?t=`${e.details.text} (${e.diagnostics})`:t=e.details.text:e.diagnostics?t=e.diagnostics:t="Unknown error",e.expression?.length&&(t+=` (${e.expression.join(", ")})`),t}function J$(e,t){const n=t.max&&t.max===Number.MAX_SAFE_INTEGER?Number.POSITIVE_INFINITY:t.max;return{path:e,description:"",type:t.type??[],min:t.min??0,max:n??1,isArray:!!n&&n>1,constraints:[]}}function e8(e){const t=Object.create(null);for(const[n,r]of Object.entries(e))t[n]={name:n,type:n,path:n,elements:Object.fromEntries(Object.entries(r.elements).map(([o,l])=>[o,J$(o,l)])),constraints:[],innerTypes:[]};return t}const t8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]}}},n8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]}}},r8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},type:{type:[{code:"code"}]},text:{type:[{code:"string"}]},line:{max:9007199254740991,type:[{code:"string"}]},city:{type:[{code:"string"}]},district:{type:[{code:"string"}]},state:{type:[{code:"string"}]},postalCode:{type:[{code:"string"}]},country:{type:[{code:"string"}]},period:{type:[{code:"Period"}]}}},i8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},o8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},"author[x]":{type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Organization"]},{code:"string"}]},time:{type:[{code:"dateTime"}]},text:{min:1,type:[{code:"markdown"}]}}},a8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},contentType:{type:[{code:"code"}]},language:{type:[{code:"code"}]},data:{type:[{code:"base64Binary"}]},url:{type:[{code:"url"}]},size:{type:[{code:"unsignedInt"}]},hash:{type:[{code:"base64Binary"}]},title:{type:[{code:"string"}]},creation:{type:[{code:"dateTime"}]}}},s8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},coding:{max:9007199254740991,type:[{code:"Coding"}]},text:{type:[{code:"string"}]}}},l8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},system:{type:[{code:"uri"}]},version:{type:[{code:"string"}]},code:{type:[{code:"code"}]},display:{type:[{code:"string"}]},userSelected:{type:[{code:"boolean"}]}}},c8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},name:{type:[{code:"string"}]},telecom:{max:9007199254740991,type:[{code:"ContactPoint"}]}}},u8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},system:{type:[{code:"code"}]},value:{type:[{code:"string"}]},use:{type:[{code:"code"}]},rank:{type:[{code:"positiveInt"}]},period:{type:[{code:"Period"}]}}},d8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},name:{min:1,type:[{code:"string"}]},contact:{max:9007199254740991,type:[{code:"ContactDetail"}]}}},f8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},h8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},"subject[x]":{type:[{code:"CodeableConcept"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Group"]}]},mustSupport:{max:9007199254740991,type:[{code:"string"}]},codeFilter:{max:9007199254740991,type:[{code:"DataRequirementCodeFilter"}]},dateFilter:{max:9007199254740991,type:[{code:"DataRequirementDateFilter"}]},limit:{type:[{code:"positiveInt"}]},sort:{max:9007199254740991,type:[{code:"DataRequirementSort"}]}}},p8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{type:[{code:"string"}]},searchParam:{type:[{code:"string"}]},valueSet:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]},code:{max:9007199254740991,type:[{code:"Coding"}]}}},m8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{type:[{code:"string"}]},searchParam:{type:[{code:"string"}]},"value[x]":{type:[{code:"dateTime"},{code:"Period"},{code:"Duration"}]}}},g8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},direction:{min:1,type:[{code:"code"}]}}},v8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},y8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},sequence:{type:[{code:"integer"}]},text:{type:[{code:"string"}]},additionalInstruction:{max:9007199254740991,type:[{code:"CodeableConcept"}]},patientInstruction:{type:[{code:"string"}]},timing:{type:[{code:"Timing"}]},"asNeeded[x]":{type:[{code:"boolean"},{code:"CodeableConcept"}]},site:{type:[{code:"CodeableConcept"}]},route:{type:[{code:"CodeableConcept"}]},method:{type:[{code:"CodeableConcept"}]},doseAndRate:{max:9007199254740991,type:[{code:"DosageDoseAndRate"}]},maxDosePerPeriod:{type:[{code:"Ratio"}]},maxDosePerAdministration:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},maxDosePerLifetime:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},x8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{type:[{code:"CodeableConcept"}]},"dose[x]":{type:[{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},"rate[x]":{type:[{code:"Ratio"},{code:"Range"},{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},b8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},S8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},representation:{max:9007199254740991,type:[{code:"code"}]},sliceName:{type:[{code:"string"}]},sliceIsConstraining:{type:[{code:"boolean"}]},label:{type:[{code:"string"}]},code:{max:9007199254740991,type:[{code:"Coding"}]},slicing:{type:[{code:"ElementDefinitionSlicing"}]},short:{type:[{code:"string"}]},definition:{type:[{code:"markdown"}]},comment:{type:[{code:"markdown"}]},requirements:{type:[{code:"markdown"}]},alias:{max:9007199254740991,type:[{code:"string"}]},min:{type:[{code:"unsignedInt"}]},max:{type:[{code:"string"}]},base:{type:[{code:"ElementDefinitionBase"}]},contentReference:{type:[{code:"uri"}]},type:{max:9007199254740991,type:[{code:"ElementDefinitionType"}]},"defaultValue[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},meaningWhenMissing:{type:[{code:"markdown"}]},orderMeaning:{type:[{code:"string"}]},"fixed[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},"pattern[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]},example:{max:9007199254740991,type:[{code:"ElementDefinitionExample"}]},"minValue[x]":{type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},"maxValue[x]":{type:[{code:"date"},{code:"dateTime"},{code:"instant"},{code:"time"},{code:"decimal"},{code:"integer"},{code:"positiveInt"},{code:"unsignedInt"},{code:"Quantity"}]},maxLength:{type:[{code:"integer"}]},condition:{max:9007199254740991,type:[{code:"id"}]},constraint:{max:9007199254740991,type:[{code:"ElementDefinitionConstraint"}]},mustSupport:{type:[{code:"boolean"}]},isModifier:{type:[{code:"boolean"}]},isModifierReason:{type:[{code:"string"}]},isSummary:{type:[{code:"boolean"}]},binding:{type:[{code:"ElementDefinitionBinding"}]},mapping:{max:9007199254740991,type:[{code:"ElementDefinitionMapping"}]}}},w8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},path:{min:1,type:[{code:"string"}]}}},j8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},discriminator:{max:9007199254740991,type:[{code:"ElementDefinitionSlicingDiscriminator"}]},description:{type:[{code:"string"}]},ordered:{type:[{code:"boolean"}]},rules:{min:1,type:[{code:"code"}]}}},C8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},path:{min:1,type:[{code:"string"}]},min:{min:1,type:[{code:"unsignedInt"}]},max:{min:1,type:[{code:"string"}]}}},E8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},code:{min:1,type:[{code:"uri"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},targetProfile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition","http://hl7.org/fhir/StructureDefinition/ImplementationGuide"]}]},aggregation:{max:9007199254740991,type:[{code:"code"}]},versioning:{type:[{code:"code"}]}}},T8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},label:{min:1,type:[{code:"string"}]},"value[x]":{min:1,type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}}},R8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},key:{min:1,type:[{code:"id"}]},requirements:{type:[{code:"string"}]},severity:{min:1,type:[{code:"code"}]},human:{min:1,type:[{code:"string"}]},expression:{type:[{code:"string"}]},xpath:{type:[{code:"string"}]},source:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},_8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},strength:{min:1,type:[{code:"code"}]},description:{type:[{code:"string"}]},valueSet:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/ValueSet"]}]}}},D8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},identity:{min:1,type:[{code:"id"}]},language:{type:[{code:"code"}]},map:{min:1,type:[{code:"string"}]},comment:{type:[{code:"string"}]}}},A8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},description:{type:[{code:"string"}]},name:{type:[{code:"id"}]},language:{min:1,type:[{code:"code"}]},expression:{type:[{code:"string"}]},reference:{type:[{code:"uri"}]}}},P8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},url:{min:1,type:[{code:"uri"}]},"value[x]":{type:[{code:"base64Binary"},{code:"boolean"},{code:"canonical"},{code:"code"},{code:"date"},{code:"dateTime"},{code:"decimal"},{code:"id"},{code:"instant"},{code:"integer"},{code:"markdown"},{code:"oid"},{code:"positiveInt"},{code:"string"},{code:"time"},{code:"unsignedInt"},{code:"uri"},{code:"url"},{code:"uuid"},{code:"Address"},{code:"Age"},{code:"Annotation"},{code:"Attachment"},{code:"CodeableConcept"},{code:"Coding"},{code:"ContactPoint"},{code:"Count"},{code:"Distance"},{code:"Duration"},{code:"HumanName"},{code:"Identifier"},{code:"Money"},{code:"Period"},{code:"Quantity"},{code:"Range"},{code:"Ratio"},{code:"Reference"},{code:"SampledData"},{code:"Signature"},{code:"Timing"},{code:"ContactDetail"},{code:"Contributor"},{code:"DataRequirement"},{code:"Expression"},{code:"ParameterDefinition"},{code:"RelatedArtifact"},{code:"TriggerDefinition"},{code:"UsageContext"},{code:"Dosage"},{code:"Meta"}]}}},k8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},text:{type:[{code:"string"}]},family:{type:[{code:"string"}]},given:{max:9007199254740991,type:[{code:"string"}]},prefix:{max:9007199254740991,type:[{code:"string"}]},suffix:{max:9007199254740991,type:[{code:"string"}]},period:{type:[{code:"Period"}]}}},N8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},use:{type:[{code:"code"}]},type:{type:[{code:"CodeableConcept"}]},system:{type:[{code:"uri"}]},value:{type:[{code:"string"}]},period:{type:[{code:"Period"}]},assigner:{type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},O8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},country:{min:1,type:[{code:"CodeableConcept"}]},jurisdiction:{type:[{code:"CodeableConcept"}]},status:{min:1,type:[{code:"CodeableConcept"}]},dateRange:{min:1,type:[{code:"Period"}]},restoreDate:{type:[{code:"dateTime"}]}}},M8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},versionId:{type:[{code:"id"}]},lastUpdated:{type:[{code:"instant"}]},source:{type:[{code:"uri"}]},profile:{max:9007199254740991,type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]},security:{max:9007199254740991,type:[{code:"Coding"}]},tag:{max:9007199254740991,type:[{code:"Coding"}]},project:{type:[{code:"uri"}]},author:{type:[{code:"Reference"}]},onBehalfOf:{type:[{code:"Reference"}]},account:{type:[{code:"Reference"}]},accounts:{max:9007199254740991,type:[{code:"Reference"}]},compartment:{max:9007199254740991,type:[{code:"Reference"}]}}},L8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},currency:{type:[{code:"code"}]}}},I8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},status:{min:1,type:[{code:"code"}]},div:{min:1,type:[{code:"xhtml"}]}}},z8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},name:{type:[{code:"code"}]},use:{min:1,type:[{code:"code"}]},min:{type:[{code:"integer"}]},max:{type:[{code:"string"}]},documentation:{type:[{code:"string"}]},type:{min:1,type:[{code:"code"}]},profile:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/StructureDefinition"]}]}}},$8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},start:{type:[{code:"dateTime"}]},end:{type:[{code:"dateTime"}]}}},U8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},"age[x]":{type:[{code:"Range"},{code:"CodeableConcept"}]},gender:{type:[{code:"CodeableConcept"}]},race:{type:[{code:"CodeableConcept"}]},physiologicalCondition:{type:[{code:"CodeableConcept"}]}}},B8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},height:{type:[{code:"Quantity"}]},width:{type:[{code:"Quantity"}]},depth:{type:[{code:"Quantity"}]},weight:{type:[{code:"Quantity"}]},nominalVolume:{type:[{code:"Quantity"}]},externalDiameter:{type:[{code:"Quantity"}]},shape:{type:[{code:"string"}]},color:{max:9007199254740991,type:[{code:"string"}]},imprint:{max:9007199254740991,type:[{code:"string"}]},image:{max:9007199254740991,type:[{code:"Attachment"}]},scoring:{type:[{code:"CodeableConcept"}]}}},V8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},identifier:{type:[{code:"Identifier"}]},type:{min:1,type:[{code:"CodeableConcept"}]},period:{min:1,type:[{code:"Quantity"}]},specialPrecautionsForStorage:{max:9007199254740991,type:[{code:"CodeableConcept"}]}}},F8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},H8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},low:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},high:{type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]}}},q8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},numerator:{type:[{code:"Quantity"}]},denominator:{type:[{code:"Quantity"}]}}},G8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},reference:{type:[{code:"string"}]},type:{type:[{code:"uri"}]},identifier:{type:[{code:"Identifier"}]},display:{type:[{code:"string"}]}}},Q8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},label:{type:[{code:"string"}]},display:{type:[{code:"string"}]},citation:{type:[{code:"markdown"}]},url:{type:[{code:"url"}]},document:{type:[{code:"Attachment"}]},resource:{type:[{code:"canonical",targetProfile:["http://hl7.org/fhir/StructureDefinition/Resource"]}]}}},W8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},origin:{min:1,type:[{code:"Quantity",profile:["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"]}]},period:{min:1,type:[{code:"decimal"}]},factor:{type:[{code:"decimal"}]},lowerLimit:{type:[{code:"decimal"}]},upperLimit:{type:[{code:"decimal"}]},dimensions:{min:1,type:[{code:"positiveInt"}]},data:{type:[{code:"string"}]}}},Y8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,max:9007199254740991,type:[{code:"Coding"}]},when:{min:1,type:[{code:"instant"}]},who:{min:1,type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},onBehalfOf:{type:[{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Practitioner","http://hl7.org/fhir/StructureDefinition/PractitionerRole","http://hl7.org/fhir/StructureDefinition/RelatedPerson","http://hl7.org/fhir/StructureDefinition/Patient","http://hl7.org/fhir/StructureDefinition/Device","http://hl7.org/fhir/StructureDefinition/Organization"]}]},targetFormat:{type:[{code:"code"}]},sigFormat:{type:[{code:"code"}]},data:{type:[{code:"base64Binary"}]}}},K8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},"amount[x]":{type:[{code:"Quantity"},{code:"Range"},{code:"string"}]},amountType:{type:[{code:"CodeableConcept"}]},amountText:{type:[{code:"string"}]},referenceRange:{type:[{code:"SubstanceAmountReferenceRange"}]}}},X8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},lowLimit:{type:[{code:"Quantity"}]},highLimit:{type:[{code:"Quantity"}]}}},Z8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},modifierExtension:{max:9007199254740991,type:[{code:"Extension"}]},event:{max:9007199254740991,type:[{code:"dateTime"}]},repeat:{type:[{code:"TimingRepeat"}]},code:{type:[{code:"CodeableConcept"}]}}},J8={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},"bounds[x]":{type:[{code:"Duration"},{code:"Range"},{code:"Period"}]},count:{type:[{code:"positiveInt"}]},countMax:{type:[{code:"positiveInt"}]},duration:{type:[{code:"decimal"}]},durationMax:{type:[{code:"decimal"}]},durationUnit:{type:[{code:"code"}]},frequency:{type:[{code:"positiveInt"}]},frequencyMax:{type:[{code:"positiveInt"}]},period:{type:[{code:"decimal"}]},periodMax:{type:[{code:"decimal"}]},periodUnit:{type:[{code:"code"}]},dayOfWeek:{max:9007199254740991,type:[{code:"code"}]},timeOfDay:{max:9007199254740991,type:[{code:"time"}]},when:{max:9007199254740991,type:[{code:"code"}]},offset:{type:[{code:"unsignedInt"}]}}},eU={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},type:{min:1,type:[{code:"code"}]},name:{type:[{code:"string"}]},"timing[x]":{type:[{code:"Timing"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/Schedule"]},{code:"date"},{code:"dateTime"}]},data:{max:9007199254740991,type:[{code:"DataRequirement"}]},condition:{type:[{code:"Expression"}]}}},tU={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},code:{min:1,type:[{code:"Coding"}]},"value[x]":{min:1,type:[{code:"CodeableConcept"},{code:"Quantity"},{code:"Range"},{code:"Reference",targetProfile:["http://hl7.org/fhir/StructureDefinition/PlanDefinition","http://hl7.org/fhir/StructureDefinition/ResearchStudy","http://hl7.org/fhir/StructureDefinition/InsurancePlan","http://hl7.org/fhir/StructureDefinition/HealthcareService","http://hl7.org/fhir/StructureDefinition/Group","http://hl7.org/fhir/StructureDefinition/Location","http://hl7.org/fhir/StructureDefinition/Organization"]}]}}},nU={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},rU={elements:{id:{type:[{code:"string"}]},extension:{max:9007199254740991,type:[{code:"Extension"}]},value:{type:[{code:"decimal"}]},comparator:{max:0,type:[{code:"code"}]},unit:{type:[{code:"string"}]},system:{type:[{code:"uri"}]},code:{type:[{code:"code"}]}}},iU={elements:{authorizeUrl:{min:1,type:[{code:"string"}]},tokenUrl:{min:1,type:[{code:"string"}]},tokenAuthMethod:{type:[{code:"code"}]},userInfoUrl:{min:1,type:[{code:"string"}]},clientId:{min:1,type:[{code:"string"}]},clientSecret:{min:1,type:[{code:"string"}]},usePkce:{type:[{code:"boolean"}]},useSubject:{type:[{code:"boolean"}]}}},oU={Element:t8,BackboneElement:n8,Address:r8,Age:i8,Annotation:o8,Attachment:a8,CodeableConcept:s8,Coding:l8,ContactDetail:c8,ContactPoint:u8,Contributor:d8,Count:f8,DataRequirement:h8,DataRequirementCodeFilter:p8,DataRequirementDateFilter:m8,DataRequirementSort:g8,Distance:v8,Dosage:y8,DosageDoseAndRate:x8,Duration:b8,ElementDefinition:S8,ElementDefinitionSlicingDiscriminator:w8,ElementDefinitionSlicing:j8,ElementDefinitionBase:C8,ElementDefinitionType:E8,ElementDefinitionExample:T8,ElementDefinitionConstraint:R8,ElementDefinitionBinding:_8,ElementDefinitionMapping:D8,Expression:A8,Extension:P8,HumanName:k8,Identifier:N8,MarketingStatus:O8,Meta:M8,Money:L8,Narrative:I8,ParameterDefinition:z8,Period:$8,Population:U8,ProdCharacteristic:B8,ProductShelfLife:V8,Quantity:F8,Range:H8,Ratio:q8,Reference:G8,RelatedArtifact:Q8,SampledData:W8,Signature:Y8,SubstanceAmount:K8,SubstanceAmountReferenceRange:X8,Timing:Z8,TimingRepeat:J8,TriggerDefinition:eU,UsageContext:tU,MoneyQuantity:nU,SimpleQuantity:rU,IdentityProvider:iU};function aU(e){return new lU(e).parse()}const np=e8(oU),gb=Object.create(null),OE=Object.create(null),sU={"http://hl7.org/fhir/StructureDefinition/MoneyQuantity":"MoneyQuantity","http://hl7.org/fhir/StructureDefinition/SimpleQuantity":"SimpleQuantity","http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/ViewDefinition":"ViewDefinition"};function MD(e){let t;return t=OE[e],t||(t=OE[e]=Object.create(null)),t}function ME(e){const n=(Array.isArray(e)?e:e.entry?.map(r=>r.resource)??[]).filter(r=>r?.resourceType==="StructureDefinition");ZU(n);for(const r of n)LD(r)}function LD(e){if(!e?.name)throw new Error("Failed loading StructureDefinition from bundle");if(e.resourceType!=="StructureDefinition")return;const t=aU(e),n=sU[e.url];let r,o;n?(r=np,o=n):e.url===`http://hl7.org/fhir/StructureDefinition/${e.type}`||e.url===`https://medplum.com/fhir/StructureDefinition/${e.type}`||e.type?.startsWith("http://")||e.type?.startsWith("https://")?(r=np,o=e.type):(r=MD(e.url),o=e.type),r[o]=t;for(const l of t.innerTypes)l.parentType=t,r[l.name]=l;gb[e.url]=t}function ID(e){return!!np[e]}function dm(e,t){if(t){const n=MD(t)[e];if(n)return n}return np[e]}function zD(e,t){const n=dm(e,t);if(!n)throw new ft(xo("Unknown data type: "+e));return n}function vb(e){return!!gb[e]}function Zc(e){return gb[e]}class lU{constructor(t){if(!t.snapshot?.element||t.snapshot.element.length===0)throw new Error(`No snapshot defined for StructureDefinition '${t.name}'`);this.root=t.snapshot.element[0],this.elements=t.snapshot.element.slice(1),this.elementIndex=Object.create(null),this.index=0,this.resourceSchema={name:t.name,path:this.root.path,title:t.title,type:t.type,url:t.url,version:t.version,kind:t.kind,description:dU(t),elements:{},constraints:this.parseElementDefinition(this.root).constraints,innerTypes:[],summaryProperties:new Set,mandatoryProperties:new Set},this.innerTypes=[]}parse(){let t=this.next();for(;t;){if(t.sliceName)this.parseSliceStart(t);else if(t.id?.includes(":")){if(this.slicingContext?.current){const n=vy(t,this.slicingContext.path);this.slicingContext.current.elements[n]=this.parseElementDefinition(t)}}else{const n=this.parseElementDefinition(t);this.checkFieldEnter(t,n);let r=this.backboneContext;for(;r;){if(t.path?.startsWith(r.path+".")){r.type.elements[vy(t,r.path)]=n;break}r=r.parent}if(!r){const o=vy(t,this.root.path);t.isSummary&&this.resourceSchema.summaryProperties?.add(o.replace("[x]","")),n.min>0&&this.resourceSchema.mandatoryProperties?.add(o.replace("[x]","")),this.resourceSchema.elements[o]=n}this.checkFieldExit(t)}t=this.next()}return this.checkFieldExit(),this.innerTypes.length>0&&(this.resourceSchema.innerTypes=this.innerTypes),this.resourceSchema}checkFieldEnter(t,n){this.isInnerType(t)&&this.enterInnerType(t),this.slicingContext&&!pc(this.slicingContext.path,t?.path)&&(this.slicingContext=void 0),t.slicing&&!this.slicingContext&&this.enterSlice(t,n)}enterInnerType(t){for(;this.backboneContext&&!pc(this.backboneContext?.path,t.path);)this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;const n=FE(t);this.backboneContext={type:{name:n,type:n,path:t.path,title:t.label,description:t.definition,elements:{},constraints:this.parseElementDefinition(t).constraints,innerTypes:[]},path:t.path,parent:pc(this.backboneContext?.path,t.path)?this.backboneContext:this.backboneContext?.parent}}enterSlice(t,n){uU(t)&&!this.peek()?.sliceName||(n.slicing={discriminator:(t.slicing?.discriminator??[]).map(r=>{if(r.type!=="value"&&r.type!=="pattern"&&r.type!=="type")throw new Error(`Unsupported slicing discriminator type: ${r.type}`);return{path:r.path,type:r.type}}),slices:[],ordered:t.slicing?.ordered??!1,rule:t.slicing?.rules},this.slicingContext={field:n.slicing,path:t.path??""})}checkFieldExit(t=void 0){if(this.backboneContext&&!pc(this.backboneContext.path,t?.path))if(this.backboneContext.parent)do this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;while(this.backboneContext&&!pc(this.backboneContext.path,t?.path));else this.innerTypes.push(this.backboneContext.type),this.backboneContext=void 0}next(){const t=this.peek();if(t)return this.index++,t}peek(){const t=this.elements[this.index];if(t){if(this.elementIndex[t.path??""]=t,t.contentReference){const n=t.contentReference.slice(t.contentReference.indexOf("#")+1),r=this.elementIndex[n];return r?{...r,id:t.id,path:t.path,min:t.min??r.min,max:t.max??r.max,base:{path:r.base?.path??n,min:t.base?.min??r.base?.min??r.min,max:t.base?.max??r.base?.max??r.max},contentReference:t.contentReference,definition:t.definition}:void 0}return t}}isInnerType(t){const n=this.peek();return!!(pc(t?.path,n?.path)&&t.type?.some(r=>["BackboneElement","Element"].includes(r.code)))}parseSliceStart(t){if(!this.slicingContext)throw new Error(`Invalid slice start before discriminator: ${t.sliceName} (${t.id})`);this.slicingContext.current={...this.parseElementDefinition(t),name:t.sliceName??"",definition:t.definition,elements:{}},this.slicingContext.field.slices.push(this.slicingContext.current)}parseElementDefinitionType(t){return(t.type??[]).map(n=>{let r;return(n.code==="BackboneElement"||n.code==="Element")&&(r=FE(t)),r||(r=Do(n,"http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type")?.valueUrl),r||(r=n.code??""),{code:r,targetProfile:n.targetProfile,profile:n.profile}})}parseElementDefinition(t){const n=LE(t.max),r=t.base?.max?LE(t.base.max):n,o={type:"ElementDefinition",value:t};return{description:t.definition||"",path:t.path||t.base?.path||"",min:t.min??0,max:n,isArray:r>1,constraints:(t.constraint??[]).map(l=>({key:l.key??"",severity:l.severity??"error",expression:l.expression??"",description:l.human??""})),type:this.parseElementDefinitionType(t),fixed:IE(Lc(o,"fixed[x]")),pattern:IE(Lc(o,"pattern[x]")),binding:t.binding}}}function LE(e){return e==="*"?Number.POSITIVE_INFINITY:Number.parseInt(e,10)}function vy(e,t=""){return cU(e.path,t)}function cU(e,t){return e?t&&e.startsWith(t)?e.substring(t.length+1):e:""}function pc(e,t){return!e||!t?!1:t.startsWith(e+".")||t===e}function IE(e){return Array.isArray(e)&&e.length>0?e[0]:vn(e)?void 0:e}function uU(e){const t=e.slicing?.discriminator;return!!(e.type?.some(n=>n.code==="Extension")&&t?.length===1&&t[0].type==="value"&&t[0].path==="url")}function dU(e){let t=e.description;return t?.startsWith(`Base StructureDefinition for ${e.name} Type: `)&&(t=t.substring(`Base StructureDefinition for ${e.name} Type: `.length)),t}function fU(e,t,n){if(e===void 0)return[void 0];if(t==="$this")return[e];const r=n?.withPath?hU:Lc,[o,...l]=t.split(".");let c=[r(e,o,n)];for(const d of l){const f=[];for(const p of c)if(Array.isArray(p))for(const m of p)f.push(r(m,d,n));else(n?.withPath&&p?.value!==void 0||!n?.withPath&&p!==void 0)&&f.push(r(p,d,n));c=f}return c}function hU(e,t,n){const r=e.path;return pU(Lc(e,t,n),r,t)}function pU(e,t,n){const r=t?t+".":"";return e===void 0?{type:"undefined",value:void 0,path:`${r}${n}`}:Array.isArray(e)?e.map((o,l)=>({...o,path:`${r}${n}[${l}]`})):{...e,path:`${r}${n}`}}const $D={date:/^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1]))?)?$/,dateTime:/^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1])(T([01]\d|2[0-3])(:[0-5]\d:([0-5]\d|60)(\.\d{1,9})?)?)?)?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00)?)?)?$/};function mU(e,t,n,r){if(Array.isArray(e))return!1;let o;t.path==="$this"?o=n:o=(r??n.elements)[t.path];const l=n.type;switch(t.type){case"value":case"pattern":if(!e||!o)return!1;if(o.pattern)return bb(e,o.pattern);if(o.fixed)return Co(e,o.fixed);if(o.binding?.strength==="required"&&o.binding.valueSet)return!0;break;case"type":return!e||!l?.length?!1:l.some(c=>c.code===e.type)}return!1}function tt(e){return[{type:re.boolean,value:e}]}function ri(e){return e==null?{type:"undefined",value:void 0}:Number.isSafeInteger(e)?{type:re.integer,value:e}:typeof e=="number"?{type:re.decimal,value:e}:typeof e=="boolean"?{type:re.boolean,value:e}:typeof e=="string"?{type:re.string,value:e}:Ei(e)?{type:re.Quantity,value:e}:Ao(e)?{type:e.resourceType,value:e}:ZD(e)?{type:re.CodeableConcept,value:e}:XD(e)?{type:re.Coding,value:e}:{type:re.BackboneElement,value:e}}function go(e){return e.length===0?!1:!!e[0].value}function ua(e,t){if(e.length!==0){if(e.length===1&&(!t||e[0].type===t))return e[0];throw new Error(`Expected singleton of type ${t}, but found ${JSON.stringify(e)}`)}}function Lc(e,t,n){if(!e.value)return;const r=ms(e.type,t,n?.profileUrl);return r?UD(e,t,r):Fd(e,t)}function UD(e,t,n){const r=e.value,o=n.type;if(!o||o.length===0)return;let l,c="undefined",d;const f=n.path.lastIndexOf("."),p=n.path.substring(f+1);for(const m of o){const g=p.replace("[x]",$n(m.code));if(l=r[g],d=r["_"+g],l!==void 0||d!==void 0){c=m.code;break}}if(d)if(Array.isArray(l)){l=l.slice();for(let m=0;m<Math.max(l.length,d.length);m++)l[m]=yy(l[m],d[m])}else if(!l&&Array.isArray(d)){l=d.slice();for(let m=0;m<d.length;m++)l[m]=yy(void 0,d[m])}else l=yy(l,d);if(!vn(l))return(c==="Element"||c==="BackboneElement")&&(c=n.type[0].code),Array.isArray(l)?l.map(m=>zE(m,c)):zE(l,c)}function zE(e,t){return t==="Resource"&&Ao(e)&&(t=e.resourceType),{type:t,value:e}}function Fd(e,t){const n=e.value;if(!n||typeof n!="object")return;let r;if(t in n){const o=n[t];Array.isArray(o)?r=o.map(ri):r=ri(o)}else{const o=t.endsWith("[x]")?t.substring(0,t.length-3):t;for(const l of Object.values(re)){const c=o+$n(l);if(c in n){const d=n[c];Array.isArray(d)?r=d.map(f=>({type:l,value:f})):r={type:l,value:d};break}}}if(Array.isArray(r)){if(r.length===0||vn(r[0]))return}else if(vn(r))return;return r}function BD(e){const t=[];for(const n of e){let r=!1;for(const o of t)if(go(fm(n,o))){r=!0;break}r||t.push(n)}return t}function gU(e){return tt(!go(e))}function vU(e,t){return e.length===0||t.length===0?[]:e.length!==t.length?tt(!1):tt(e.every((n,r)=>go(fm(n,t[r]))))}function yU(e,t){return e.length===0||t.length===0?[]:e.length!==t.length?tt(!0):tt(e.some((n,r)=>!go(fm(n,t[r]))))}function fm(e,t){const n=e.value?.valueOf(),r=t.value?.valueOf();return typeof n=="number"&&typeof r=="number"?tt(Math.abs(n-r)<1e-8):Ei(n)&&Ei(r)?tt(QD(n,r)):tt(typeof n=="object"&&typeof r=="object"?yb(e,t):n===r)}function VD(e,t){return e.length===0&&t.length===0?tt(!0):e.length!==t.length?tt(!1):(e.sort($E),t.sort($E),tt(e.every((n,r)=>go(xU(n,t[r])))))}function xU(e,t){const{type:n,value:r}=e,{type:o,value:l}=t,c=r?.valueOf(),d=l?.valueOf();return typeof c=="number"&&typeof d=="number"?tt(Math.abs(c-d)<.01):Ei(c)&&Ei(d)?tt(QD(c,d)):tt(n==="Coding"&&o==="Coding"?typeof c!="object"||typeof d!="object"?!1:c.code===d.code&&c.system===d.system:typeof c=="object"&&typeof d=="object"?yb({...c,id:void 0},{...d,id:void 0}):typeof c=="string"&&typeof d=="string"?c.toLowerCase()===d.toLowerCase():c===d)}function $E(e,t){const n=e.value?.valueOf(),r=t.value?.valueOf();return typeof n=="number"&&typeof r=="number"?n-r:typeof n=="string"&&typeof r=="string"?n.localeCompare(r):0}function FD(e,t){const{value:n}=e;if(n==null)return!1;let r=t;switch(r.startsWith("System.")&&(r=r.substring(7)),r.startsWith("FHIR.")&&(r=r.substring(5)),r){case"Boolean":return typeof n=="boolean";case"Decimal":case"Integer":return typeof n=="number";case"Date":return HD(n);case"DateTime":return pd(n);case"Time":return typeof n=="string"&&!!/^T\d/.exec(n);case"Period":return qD(n);case"Quantity":return Ei(n);default:return e.type===r||typeof n=="object"&&n?.resourceType===r}}function HD(e){return typeof e=="string"&&!!$D.date.exec(e)}function pd(e){return typeof e=="string"&&!!$D.dateTime.exec(e)}function qD(e){return!!(e&&typeof e=="object"&&("start"in e&&pd(e.start)||"end"in e&&pd(e.end)))}function GD(e){if(e){if(HD(e)||pd(e))return{start:bh(e,"0000-01-01T00:00:00.000"),end:bh(e,"xxxx-12-31T23:59:59.999")};if(qD(e))return{start:e.start?bh(e.start,"0000-01-01T00:00:00.000"):void 0,end:e.end?bh(e.end,"xxxx-12-31T23:59:59.999"):void 0}}}function bh(e,t){let n="Z";const r=Math.max(e.indexOf("+",10),e.indexOf("-",10));r>-1?(n=e.substring(r),e=e.substring(0,r)):e.endsWith("Z")&&(e=e.substring(0,e.length-1));const o=e+t.substring(e.length)+n;return new Date(o).toISOString()}function Ei(e){return!!(e&&typeof e=="object"&&"value"in e&&typeof e.value=="number")}function QD(e,t){return Math.abs(e.value-t.value)<.01&&(e.unit===t.unit||e.code===t.code||e.unit===t.code||e.code===t.unit)}function yb(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n){const l=e[o],c=t[o];if(UE(l)&&UE(c)){if(!yb(l,c))return!1}else if(l!==c)return!1}return!0}function UE(e){return e!==null&&typeof e=="object"}function yy(e,t){if(t){if(typeof t!="object")throw new Error("Primitive extension must be an object");return bU(e??{},t)}return e}function bU(e,t){return delete t.__proto__,delete t.constructor,Object.assign(e,t)}function WD(e,t){return Ao(e,t)&&"id"in e&&typeof e.id=="string"}function Ht(e){const t=_t(e)??"undefined/undefined",n=da(e);return n===t?{reference:t}:{reference:t,display:n}}function _t(e){if(wa(e))return e.reference;if(WD(e))return`${e.resourceType}/${e.id}`}function rl(e){if(e)return wa(e)?e.reference.split("/")[1]:e.id}function SU(e){return e.resourceType==="Patient"||e.resourceType==="Practitioner"||e.resourceType==="RelatedPerson"}function da(e){if(SU(e)){const t=wU(e);if(t)return t}if(e.resourceType==="Device"){const t=jU(e);if(t)return t}if(e.resourceType==="MedicationRequest"&&e.medicationCodeableConcept)return ls(e.medicationCodeableConcept);if(e.resourceType==="Subscription"&&e.criteria)return e.criteria;if(e.resourceType==="User"&&e.email)return e.email;if("name"in e&&e.name&&typeof e.name=="string")return e.name;if("code"in e&&e.code){let t=e.code;if(Array.isArray(t)&&(t=t[0]),ZD(t))return ls(t);if(OU(t))return t.text}return _t(e)??""}function wU(e){const t=e.name;if(t&&t.length>0)return Jc(t[0])}function jU(e){const t=e.deviceName;if(t&&t.length>0)return t[0].name}function CU(e){if(!("photo"in e))return;const t=e.photo;if(t)if(Array.isArray(t))for(const n of t){const r=BE(n);if(r)return r}else return BE(t)}function BE(e){if(e.url&&e.contentType?.startsWith("image/"))return e.url}function YD(e,t){const n=new Date(e);n.setUTCHours(0,0,0,0);const r=t?new Date(t):new Date;r.setUTCHours(0,0,0,0);const o=n.getUTCFullYear(),l=n.getUTCMonth(),c=n.getUTCDate(),d=r.getUTCFullYear(),f=r.getUTCMonth(),p=r.getUTCDate();let m=d-o;(f<l||f===l&&p<c)&&m--;let g=d*12+f-(o*12+l);p<c&&g--;const x=Math.floor((r.getTime()-n.getTime())/(1e3*60*60*24));return{years:m,months:g,days:x}}function EU(e,t){const{years:n,months:r,days:o}=YD(e,t);return n>=2?n.toString().padStart(3,"0")+"Y":r>=1?r.toString().padStart(3,"0")+"M":o.toString().padStart(3,"0")+"D"}function Do(e,...t){let n=e;for(let r=0;r<t.length&&n;r++)n=n?.extension?.find(o=>o.url===t[r]);return n}function Ki(e,t){const n=xb(e);return JSON.stringify(n,null,t?2:void 0)??""}function xb(e){if(!(e==null||e===""))return typeof e=="object"?Array.isArray(e)?TU(e):RU(e):e}function TU(e){const t=e.length;if(t===0)return;let n,r=0;for(let o=0;o<t;o++){const l=e[o],c=xb(l);c!==l&&!n&&(n=Array.from(e)),c===void 0?n&&(n[o]=null):(n&&(n[o]=c),r++)}if(r!==0)return n??e}function RU(e){let t,n=0;for(const r in e){const o=e[r],l=xb(o);l!==o&&!t&&(t={...e}),l===void 0?t&&delete t[r]:(t&&(t[r]=l),n++)}if(n!==0)return t??e}function vn(e){if(e==null)return!0;const t=typeof e;return t==="string"||t==="object"?!Rn(e):!1}function Rn(e){if(e==null)return!1;const t=typeof e;return t==="string"&&e!==""||t==="object"&&("length"in e&&e.length>0||Object.keys(e).length>0)}function _U(e){if(!e)return;let t=e.length-1;for(;t>=0&&vn(e[t]);)t--;return t>=0?e.slice(0,t+1):void 0}function Co(e,t,n){return e===t||vn(e)&&vn(t)?!0:vn(e)||vn(t)?!1:Array.isArray(e)&&Array.isArray(t)?DU(e,t):Array.isArray(e)||Array.isArray(t)?!1:pr(e)&&pr(t)?AU(e,t,n):(pr(e)||pr(t),!1)}function DU(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Co(e[n],t[n]))return!1;return!0}function AU(e,t,n){const r=new Set;Object.keys(e).forEach(o=>r.add(o)),Object.keys(t).forEach(o=>r.add(o)),n==="meta"&&(r.delete("versionId"),r.delete("lastUpdated"),r.delete("author"));for(const o of r){const l=e[o],c=t[o];if(!Co(l,c,o))return!1}return!0}function bb(e,t){return vn(e)?!0:vn(t)?!1:Array.isArray(e)&&Array.isArray(t)?PU(e,t):Array.isArray(e)||Array.isArray(t)?!1:pr(e)&&pr(t)?kU(e,t):pr(e)||pr(t)?!1:e===t}function PU(e,t){return t.every(n=>e.some(r=>bb(r,n)))}function kU(e,t){return Object.entries(t).every(([n,r])=>n in e&&bb(e[n],r))}function ii(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function KD(e){return/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i.test(e)}function pr(e){return e!==null&&typeof e=="object"}function NU(e){return typeof e=="string"}function XD(e){return pr(e)&&"code"in e&&typeof e.code=="string"}function ZD(e){return pr(e)&&"coding"in e&&Array.isArray(e.coding)&&e.coding.every(XD)}function OU(e){return pr(e)&&"text"in e&&typeof e.text=="string"}const JD=[];for(let e=0;e<256;e++)JD.push(e.toString(16).padStart(2,"0"));function MU(e){const t=eA(e),n=new Uint8Array(t),r=new Array(n.length);for(let o=0;o<n.length;o++)r[o]=JD[n[o]];return r.join("")}function LU(e){const t=eA(e),n=new Uint8Array(t),r=new Array(n.length);for(let o=0;o<n.length;o++)r[o]=String.fromCharCode(n[o]);return window.btoa(r.join(""))}function eA(e){return ArrayBuffer.isView(e)?e.buffer:e}function $n(e){return e?e.charAt(0).toUpperCase()+e.substring(1):""}function Sb(e){return e.length>0&&e.startsWith(e[0].toUpperCase())}function Ys(e,t){const n=e+".";if(t.startsWith(n))return t.slice(n.length)}function IU(e,t){return e.coding?.find(n=>n.system===t)?.code}function zU(e){if(e!==void 0)return Array.isArray(e)?e:[e]}const VE=e=>new Promise(t=>{setTimeout(t,e)});function lx(e,t,n){const r=[];for(let o=0;o<n-1;o++){const l=e.indexOf(t);if(l<0)break;r.push(e.slice(0,l)),e=e.slice(l+t.length)}return r.push(e),r}function $U(e){let t,n=!1;return function(){return n||(t=e(),n=!0),t}}function Wu(e,t){return e?(e.push(t),e):[t]}function Ic(e){return e.sort((t,n)=>t.localeCompare(n))}function wb(e){return e.endsWith("/")?e:e+"/"}function UU(e){return e.startsWith("/")?e.slice(1):e}function fo(e,t){return new URL(UU(t),wb(e.toString())).toString()}function BU(e,t){return fo(e,t).toString().replace("http://","ws://").replace("https://","wss://")}function VU(e){return typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)&&(e=Object.fromEntries(Object.entries(e).filter(t=>t[1]!==void 0))),new URLSearchParams(e).toString()}function tA(e,t){return e?.meta?.profile?.includes(t)||(e.meta=e.meta??{},e.meta.profile=e.meta.profile??[],e.meta.profile.push(t)),e}function FU(e,t){if(e?.meta?.profile?.includes(t)){const n=e.meta.profile.indexOf(t);e.meta.profile.splice(n,1)}return e}function il(e){if(!e)return"";switch(e.type){case"Address":return nA(e.value);case"CodeableConcept":return ls(e.value);case"Coding":return Hd(e.value);case"ContactPoint":return e.value.value;case"HumanName":return Jc(e.value);case"Quantity":return Ks(e.value);case"Reference":return HU(e.value);default:return e.value?.toString()??""}}function HU(e){return e?e.display??e.reference??Ki(e):""}function nA(e,t){if(!e)return"";const n=[];if(e.line&&n.push(...e.line),e.city||e.state||e.postalCode){const r=[];e.city&&r.push(e.city),e.state&&r.push(e.state),e.postalCode&&r.push(e.postalCode),n.push(r.join(", "))}return e.use&&t?.use,n.join(", ").trim()}function Jc(e,t){if(!e)return"";const n=[];if(e.prefix&&t?.prefix!==!1&&n.push(...e.prefix),e.given&&n.push(...e.given),e.family&&n.push(e.family),e.suffix&&t?.suffix!==!1&&n.push(...e.suffix),e.use&&(t?.all||t?.use)&&n.push("["+e.use+"]"),n.length===0){const r=gd(e.text);if(r)return r}return n.join(" ").trim()}function hm(e){return e instanceof Date&&!isNaN(e.getTime())}function qU(e,t,n){if(!e)return"";const r=new Date("2000-01-01T"+e+"Z");return hm(r)?r.toLocaleTimeString(t,n):""}function mr(e,t,n){if(!e)return"";const r=new Date(e);return hm(r)?r.toLocaleString(t,n):""}function GU(e,t,n){return!e||!e.start&&!e.end?"":mr(e.start,t,n)+" - "+mr(e.end,t,n)}const QU={s:"every second",min:"every minute",h:"hourly",d:"daily",wk:"weekly",mo:"monthly",a:"annually"},WU={s:"second",min:"minute",h:"hour",d:"day",wk:"week",mo:"month",a:"year"},YU={s:"seconds",min:"minutes",h:"hours",d:"days",wk:"weeks",mo:"months",a:"years"};function rA(e){if(!e)return"";const t=[];return KU(t,e.repeat),e.event&&t.push(e.event.map(n=>mr(n)).join(", ")),$n(t.join(" ").trim())}function KU(e,t){if(!t?.periodUnit)return;const n=t.frequency??1,r=t.period??1,o=t.periodUnit;n===1&&r===1?e.push(QU[o]):(n===1?e.push("once"):e.push(n+" times"),r===1?e.push("per "+WU[o]):e.push("per "+r+" "+YU[o])),t.dayOfWeek&&e.push("on "+t.dayOfWeek.map($n).join(", ")),t.timeOfDay&&e.push("at "+t.timeOfDay.map(l=>qU(l)).join(", "))}function md(e,t,n=!1){if(n&&t===void 0)throw new Error("Precision must be specified for exclusive ranges");const r=e?.low&&{...e.low,comparator:void 0},o=e?.high&&{...e.high,comparator:void 0};return r?.value===void 0&&o?.value===void 0?"":r?.value!==void 0&&o?.value===void 0?`>= ${Ks(r)}`:r?.value===void 0&&o?.value!==void 0?`<= ${Ks(o)}`:(r?.unit===o?.unit&&delete r?.unit,`${Ks(r)} - ${Ks(o)}`)}function Ks(e,t){if(!e)return"";const n=[];return e.comparator&&(n.push(e.comparator),n.push(" ")),e.value!==void 0&&n.push(e.value),e.unit&&(e.unit!=="%"&&n[n.length-1]!==" "&&n.push(" "),n.push(e.unit)),n.join("").trim()}function XU(e){return e?.value===void 0?"":e.value.toLocaleString(void 0,{style:"currency",currency:e.currency??"USD",currencyDisplay:"narrowSymbol"})}function ls(e){if(!e)return"";const t=gd(e.text);return t||(e.coding?e.coding.map(n=>Hd(n)).join(", "):"")}function Hd(e,t){const n=gd(e?.display);return n?`${n}`:gd(e?.code)??""}function iA(e){if(!e)return"";const t=[];if(e.valueQuantity)t.push(Ks(e.valueQuantity));else if(e.valueCodeableConcept)t.push(ls(e.valueCodeableConcept));else{const n=gd(e.valueString);n&&t.push(n)}return"component"in e&&t.push(e.component.map(n=>iA(n)).join(" / ")),t.join(" / ").trim()}function gd(e){return typeof e=="string"?e:void 0}const re={Address:"Address",Age:"Age",Annotation:"Annotation",Attachment:"Attachment",BackboneElement:"BackboneElement",CodeableConcept:"CodeableConcept",Coding:"Coding",ContactDetail:"ContactDetail",ContactPoint:"ContactPoint",Contributor:"Contributor",Count:"Count",DataRequirement:"DataRequirement",Distance:"Distance",Dosage:"Dosage",Duration:"Duration",Expression:"Expression",Extension:"Extension",HumanName:"HumanName",Identifier:"Identifier",MarketingStatus:"MarketingStatus",Meta:"Meta",Money:"Money",Narrative:"Narrative",ParameterDefinition:"ParameterDefinition",Period:"Period",Population:"Population",ProdCharacteristic:"ProdCharacteristic",ProductShelfLife:"ProductShelfLife",Quantity:"Quantity",Range:"Range",Ratio:"Ratio",Reference:"Reference",RelatedArtifact:"RelatedArtifact",SampledData:"SampledData",Signature:"Signature",SubstanceAmount:"SubstanceAmount",SystemString:"http://hl7.org/fhirpath/System.String",Timing:"Timing",TriggerDefinition:"TriggerDefinition",UsageContext:"UsageContext",base64Binary:"base64Binary",boolean:"boolean",canonical:"canonical",code:"code",date:"date",dateTime:"dateTime",decimal:"decimal",id:"id",instant:"instant",integer:"integer",markdown:"markdown",oid:"oid",positiveInt:"positiveInt",string:"string",time:"time",unsignedInt:"unsignedInt",uri:"uri",url:"url",uuid:"uuid"};function ZU(e){const t=Array.isArray(e)?e:e.entry?.map(n=>n.resource)??[];for(const n of t)n?.resourceType==="StructureDefinition"&&n.kind==="resource"&&oA(n.type)}function oA(e){let t=Eo.types[e];return t||(t={searchParamsDetails:{}},Eo.types[e]=t),!t.searchParams&&e!=="Binary"&&(t.searchParams={_id:{base:[e],code:"_id",type:"token",expression:e+".id"},_lastUpdated:{base:[e],code:"_lastUpdated",type:"date",expression:e+".meta.lastUpdated"},_compartment:{base:[e],code:"_compartment",type:"reference",expression:e+".meta.compartment"},_profile:{base:[e],code:"_profile",type:"uri",expression:e+".meta.profile"},_security:{base:[e],code:"_security",type:"token",expression:e+".meta.security"},_source:{base:[e],code:"_source",type:"uri",expression:e+".meta.source"},_tag:{base:[e],code:"_tag",type:"token",expression:e+".meta.tag"}}),t}function JU(e){for(const t of e.base??[]){const n=oA(t);n.searchParams||(n.searchParams={}),n.searchParams[e.code]=e}}function FE(e){const t=e.type?.[0]?.code;return t==="BackboneElement"||t==="Element"?eB((e.base?.path??e.path)?.split(".")):t}function eB(e){return e.length===1?e[0]:e.map($n).join("")}function jb(e){return Eo.types[e]?.searchParams}function tB(e,t){return Eo.types[e]?.searchParams?.[t]}function ol(e){const t=e.replaceAll("[x]","").split(".").pop();return aA(t)}function aA(e){let t;return e.length<100?t=e.match(/[A-Z]+(?![a-z])|[A-Z]?[a-z]+|\d+/g)??[]:t=e.split(/(?=[A-Z])/),t.map(rB).join(" ").replace("_"," ").replace(/\s+/g," ")}const nB=new Set(["ID","IP","PKCE","JWKS","URI","URL","OMB","UDI"]);function rB(e){const t=e.toUpperCase();return e===t?e:nB.has(t)?t:t.charAt(0)+e.slice(1)}function ms(e,t,n){const r=dm(e,n);if(r)return iB(r.elements,t)}function iB(e,t){const n=e[t]??e[t+"[x]"];if(n)return n;for(let r=0;r<t.length;r++){const o=t[r];if(o>="A"&&o<="Z"){const l=t.slice(0,r)+"[x]",c=e[l];if(c)return c}}}function Ao(e,t){return!(!e||typeof e!="object"||!("resourceType"in e)||t&&e.resourceType!==t)}function wa(e,t){return!!(e&&typeof e=="object"&&"reference"in e&&typeof e.reference=="string")}const Eo={types:{}};function Ih(e){if(e.startsWith("T"))return e+"T00:00:00.000Z".substring(e.length);if(e.length<=10)return e;try{return new Date(e).toISOString()}catch{return e}}const Jo=()=>[],zr={empty:(e,t)=>tt(t.length===0||t.every(n=>vn(n.value))),hasValue:(e,t)=>tt(t.length!==0),exists:(e,t,n)=>tt(n?t.filter(r=>go(n.eval(e,[r]))).length>0:t.length>0&&t.every(r=>!vn(r.value))),all:(e,t,n)=>tt(t.every(r=>go(n.eval(e,[r])))),allTrue:(e,t)=>{for(const n of t)if(!n.value)return tt(!1);return tt(!0)},anyTrue:(e,t)=>{for(const n of t)if(n.value)return tt(!0);return tt(!1)},allFalse:(e,t)=>{for(const n of t)if(n.value)return tt(!1);return tt(!0)},anyFalse:(e,t)=>{for(const n of t)if(!n.value)return tt(!0);return tt(!1)},subsetOf:(e,t,n)=>{if(t.length===0)return tt(!0);const r=n.eval(e,zs(e));return r.length===0?tt(!1):tt(t.every(o=>r.some(l=>l.value===o.value)))},supersetOf:(e,t,n)=>{const r=n.eval(e,zs(e));return r.length===0?tt(!0):t.length===0?tt(!1):tt(r.every(o=>t.some(l=>l.value===o.value)))},count:(e,t)=>[{type:re.integer,value:t.length}],distinct:(e,t)=>{const n=[];for(const r of t)n.some(o=>o.value===r.value)||n.push(r);return n},isDistinct:(e,t)=>tt(t.length===zr.distinct(e,t).length),where:(e,t,n)=>t.filter(r=>go(n.eval(e,[r]))),select:(e,t,n)=>t.map(r=>n.eval({parent:e,variables:{$this:r}},[r])).flat(),repeat:Jo,ofType:(e,t,n)=>t.filter(r=>r.type===n.name),single:(e,t)=>{if(t.length>1)throw new Error("Expected input length one for single()");return t.length===0?[]:t.slice(0,1)},first:(e,t)=>t.length===0?[]:t.slice(0,1),last:(e,t)=>t.length===0?[]:t.slice(t.length-1,t.length),tail:(e,t)=>t.length===0?[]:t.slice(1,t.length),skip:(e,t,n)=>{const r=n.eval(e,t)[0]?.value;if(typeof r!="number")throw new Error("Expected a number for skip(num)");return r>=t.length?[]:r<=0?t:t.slice(r,t.length)},take:(e,t,n)=>{const r=n.eval(e,t)[0]?.value;if(typeof r!="number")throw new Error("Expected a number for take(num)");return r>=t.length?t:r<=0?[]:t.slice(0,r)},intersect:(e,t,n)=>{if(!n)return t;const r=n.eval(e,zs(e)),o=[];for(const l of t)!o.some(c=>c.value===l.value)&&r.some(c=>c.value===l.value)&&o.push(l);return o},exclude:(e,t,n)=>{if(!n)return t;const r=n.eval(e,zs(e)),o=[];for(const l of t)r.some(c=>c.value===l.value)||o.push(l);return o},union:(e,t,n)=>{if(!n)return t;const r=n.eval(e,zs(e));return BD([...t,...r])},combine:(e,t,n)=>{if(!n)return t;const r=n.eval(e,zs(e));return[...t,...r]},htmlChecks:(e,t,n)=>[ri(!0)],iif:(e,t,n,r,o)=>{const l=n.eval(e,t);if(l.length>1||l.length===1&&typeof l[0].value!="boolean")throw new Error("Expected criterion to evaluate to a Boolean");return go(l)?r.eval(e,t):o?o.eval(e,t):[]},toBoolean:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);if(typeof n=="boolean")return[{type:re.boolean,value:n}];if(typeof n=="number"&&(n===0||n===1))return tt(!!n);if(typeof n=="string"){const r=n.toLowerCase();if(["true","t","yes","y","1","1.0"].includes(r))return tt(!0);if(["false","f","no","n","0","0.0"].includes(r))return tt(!1)}return[]},convertsToBoolean:(e,t)=>t.length===0?[]:tt(zr.toBoolean(e,t).length===1),toInteger:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);return typeof n=="number"?[{type:re.integer,value:n}]:typeof n=="string"&&/^[+-]?\d+$/.exec(n)?[{type:re.integer,value:parseInt(n,10)}]:typeof n=="boolean"?[{type:re.integer,value:n?1:0}]:[]},convertsToInteger:(e,t)=>t.length===0?[]:tt(zr.toInteger(e,t).length===1),toDate:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);return typeof n=="string"&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:re.date,value:Ih(n)}]:[]},convertsToDate:(e,t)=>t.length===0?[]:tt(zr.toDate(e,t).length===1),toDateTime:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);return typeof n=="string"&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:re.dateTime,value:Ih(n)}]:[]},convertsToDateTime:(e,t)=>t.length===0?[]:tt(zr.toDateTime(e,t).length===1),toDecimal:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);return typeof n=="number"?[{type:re.decimal,value:n}]:typeof n=="string"&&/^-?\d{1,9}(\.\d{1,9})?$/.exec(n)?[{type:re.decimal,value:parseFloat(n)}]:typeof n=="boolean"?[{type:re.decimal,value:n?1:0}]:[]},convertsToDecimal:(e,t)=>t.length===0?[]:tt(zr.toDecimal(e,t).length===1),toQuantity:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);return Ei(n)?[{type:re.Quantity,value:n}]:typeof n=="number"?[{type:re.Quantity,value:{value:n,unit:"1"}}]:typeof n=="string"&&/^-?\d{1,9}(\.\d{1,9})?/.exec(n)?[{type:re.Quantity,value:{value:parseFloat(n),unit:"1"}}]:typeof n=="boolean"?[{type:re.Quantity,value:{value:n?1:0,unit:"1"}}]:[]},convertsToQuantity:(e,t)=>t.length===0?[]:tt(zr.toQuantity(e,t).length===1),toString:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);return n==null?[]:Ei(n)?[{type:re.string,value:`${n.value} '${n.unit}'`}]:[{type:re.string,value:n.toString()}]},convertsToString:(e,t)=>t.length===0?[]:tt(zr.toString(e,t).length===1),toTime:(e,t)=>{if(t.length===0)return[];const[{value:n}]=ho(t,1);if(typeof n=="string"){const r=/^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(n);if(r)return[{type:re.time,value:Ih("T"+r[1])}]}return[]},convertsToTime:(e,t)=>t.length===0?[]:tt(zr.toTime(e,t).length===1),indexOf:(e,t,n)=>Si((r,o)=>r.indexOf(o),e,t,n),substring:(e,t,n,r)=>Si((o,l,c)=>{const d=l,f=c?d+c:o.length;return d<0||d>=o.length?void 0:o.substring(d,f)},e,t,n,r),startsWith:(e,t,n)=>Si((r,o)=>r.startsWith(o),e,t,n),endsWith:(e,t,n)=>Si((r,o)=>r.endsWith(o),e,t,n),contains:(e,t,n)=>Si((r,o)=>r.includes(o),e,t,n),upper:(e,t)=>Si(n=>n.toUpperCase(),e,t),lower:(e,t)=>Si(n=>n.toLowerCase(),e,t),replace:(e,t,n,r)=>Si((o,l,c)=>o.replaceAll(l,c),e,t,n,r),matches:(e,t,n)=>Si((r,o)=>!!new RegExp(o).exec(r),e,t,n),replaceMatches:(e,t,n,r)=>Si((o,l,c)=>o.replaceAll(new RegExp(l,"g"),c.replaceAll(/\$\{(\w+)\}/g,"$<$1>")),e,t,n,r),length:(e,t)=>Si(n=>n.length,e,t),toChars:(e,t)=>Si(n=>n?n.split(""):void 0,e,t),encode:Jo,decode:Jo,escape:Jo,unescape:Jo,trim:Jo,split:Jo,join:(e,t,n)=>{const r=n?.eval(e,zs(e))[0]?.value??"";if(typeof r!="string")throw new Error("Separator must be a string.");return[{type:re.string,value:t.map(o=>o.value?.toString()??"").join(r)}]},abs:(e,t)=>co(Math.abs,e,t),ceiling:(e,t)=>co(Math.ceil,e,t),exp:(e,t)=>co(Math.exp,e,t),floor:(e,t)=>co(Math.floor,e,t),ln:(e,t)=>co(Math.log,e,t),log:(e,t,n)=>co((r,o)=>Math.log(r)/Math.log(o),e,t,n),power:(e,t,n)=>co(Math.pow,e,t,n),round:(e,t,...n)=>co((r,o=0)=>{if(typeof o!="number"||o<0)throw new Error("Invalid precision provided to round()");const l=Math.pow(10,o);return Math.round(r*l)/l},e,t,...n),sqrt:(e,t)=>co(Math.sqrt,e,t),truncate:(e,t)=>co(n=>n|0,e,t),children:Jo,descendants:Jo,trace:(e,t,n)=>t,now:()=>[{type:re.dateTime,value:new Date().toISOString()}],timeOfDay:()=>[{type:re.time,value:new Date().toISOString().substring(11)}],today:()=>[{type:re.date,value:new Date().toISOString().substring(0,10)}],between:(e,t,n,r,o)=>{const l=zr.toDateTime(e,n.eval(e,t));if(l.length===0)throw new Error("Invalid start date");const c=zr.toDateTime(e,r.eval(e,t));if(c.length===0)throw new Error("Invalid end date");const d=o.eval(e,t)[0]?.value;if(d!=="years"&&d!=="months"&&d!=="days")throw new Error("Invalid units");const f=YD(l[0].value,c[0].value);return[{type:re.Quantity,value:{value:f[d],unit:d}}]},is:(e,t,n)=>{let r="";return n instanceof rp?r=n.name:n instanceof Cb&&(r=n.left.name+"."+n.right.name),r?t.map(o=>({type:re.boolean,value:FD(o,r)})):[]},not:(e,t)=>zr.toBoolean(e,t).map(n=>({type:re.boolean,value:!n.value})),resolve:(e,t)=>t.map(n=>{const r=n.value;let o;if(typeof r=="string")o=r;else if(typeof r=="object"){const l=r;if(l.resource)return ri(l.resource);l.reference?o=l.reference:l.type&&l.identifier&&(o=`${l.type}?identifier=${l.identifier.system}|${l.identifier.value}`)}if(o?.includes("?")){const[l]=o.split("?");return{type:l,value:{resourceType:l}}}if(o?.includes("/")){const[l,c]=o.split("/");return{type:l,value:{resourceType:l,id:c}}}return{type:re.BackboneElement,value:void 0}}).filter(n=>!!n.value),as:(e,t)=>t,type:(e,t)=>t.map(({value:n})=>typeof n=="boolean"?{type:re.BackboneElement,value:{namespace:"System",name:"Boolean"}}:typeof n=="number"?{type:re.BackboneElement,value:{namespace:"System",name:"Integer"}}:Ao(n)?{type:re.BackboneElement,value:{namespace:"FHIR",name:n.resourceType}}:{type:re.BackboneElement,value:null}),conformsTo:(e,t,n)=>{const r=n.eval(e,t)[0].value;if(!r.startsWith("http://hl7.org/fhir/StructureDefinition/"))throw new Error("Expected a StructureDefinition URL");const o=r.replace("http://hl7.org/fhir/StructureDefinition/","");return t.map(l=>({type:re.boolean,value:l.value?.resourceType===o}))},getResourceKey:(e,t)=>{const n=t[0].value;return n?.id?[{type:re.id,value:n.id}]:[]},getReferenceKey:(e,t,n)=>{const r=t[0].value;if(!r?.reference)return[];let o="";return n instanceof rp&&(o=n.name),o&&!r.reference.startsWith(o+"/")?[]:[{type:re.id,value:rl(r)}]},extension:(e,t,n)=>{const r=n.eval(e,t)[0].value,o=t?.[0]?.value;if(o){const l=Do(o,r);if(l)return[{type:re.Extension,value:l}]}return[]}};function Si(e,t,n,...r){if(n.length===0)return[];const[{value:o}]=ho(n,1);if(typeof o!="string")throw new Error("String function cannot be called with non-string");const l=r.map(d=>d?.eval(t,n)[0]?.value),c=e(o,...l);return c===void 0?[]:Array.isArray(c)?c.map(ri):[ri(c)]}function co(e,t,n,...r){if(n.length===0)return[];const[{value:o}]=ho(n,1),l=Ei(o),c=l?o.value:o;if(typeof c!="number")throw new Error("Math function cannot be called with non-number");const d=e(c,...r.map(m=>m.eval(t,n)[0]?.value)),f=l?re.Quantity:n[0].type,p=l?{...o,value:d}:d;return[{type:f,value:p}]}function ho(e,t){if(e.length!==t)throw new Error(`Expected ${t} arguments`);for(const n of e)if(n==null)throw new Error("Expected non-null argument");return e}function zs(e){let t=e;for(;t.parent?.variables.$this;)t=t.parent;return[t.variables.$this]}class sA{constructor(t,n){this.original=t,this.child=n}eval(t,n){try{if(n.length>0){const r=[];for(const o of n)r.push(this.child.eval({parent:t,variables:{$this:o}},[o]));return r.flat()}else return this.child.eval(t,[])}catch(r){throw new Error(`FhirPathError on "${this.original}": ${r}`,{cause:r})}}toString(){return this.child.toString()}}class mc{constructor(t){this.value=t}eval(){return[this.value]}toString(){const t=this.value.value;return typeof t=="string"?`'${t}'`:t.toString()}}class rp{constructor(t){this.name=t}eval(t,n){if(this.name==="$this")return n;const r=this.getVariable(t);if(r)return[r];if(this.name.startsWith("%"))throw new Error(`Undefined variable ${this.name}`);return n.flatMap(o=>this.evalValue(o)).filter(o=>o?.value!==void 0)}getVariable(t){const n=t.variables[this.name];if(n!==void 0)return n;if(t.parent)return this.getVariable(t.parent)}evalValue(t){const n=t.value;if(!(!n||typeof n!="object"))return Ao(n,this.name)?t:Lc(t,this.name)}toString(){return this.name}}class oB{eval(){return[]}toString(){return"{}"}}class aB extends I${constructor(t,n,r){super(t,n),this.impl=r}eval(t,n){return this.impl(this.child.eval(t,n))}toString(){return this.operator+this.child.toString()}}class ip extends Bd{constructor(t,n){super("as",t,n)}eval(t,n){return zr.ofType(t,this.left.eval(t,n),this.right)}}class qr extends Bd{}class Vi extends qr{constructor(t,n,r,o){super(t,n,r),this.impl=o}eval(t,n){const r=this.left.eval(t,n);if(r.length!==1)return[];const o=this.right.eval(t,n);if(o.length!==1)return[];const l=r[0].value,c=o[0].value,d=Ei(l)?l.value:l,f=Ei(c)?c.value:c,p=this.impl(d,f);return typeof p=="boolean"?tt(p):Ei(l)?[{type:re.Quantity,value:{...l,value:p}}]:[ri(p)]}}class sB extends Bd{constructor(t,n){super("&",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n),l=[...r,...o];return l.length>0&&l.every(c=>typeof c.value=="string")?[{type:re.string,value:l.map(c=>c.value).join("")}]:l}}class lB extends qr{constructor(t,n){super("contains",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return tt(r.some(l=>l.value===o[0].value))}}class cB extends qr{constructor(t,n){super("in",t,n)}eval(t,n){const r=ua(this.left.eval(t,n)),o=this.right.eval(t,n);return r?tt(o.some(l=>fm(r,l)[0].value)):[]}}class Cb extends Bd{constructor(t,n){super(".",t,n)}eval(t,n){return this.right.eval(t,this.left.eval(t,n))}toString(){return`${this.left.toString()}.${this.right.toString()}`}}class Eb extends Bd{constructor(t,n){super("|",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return BD([...r,...o])}}class uB extends qr{constructor(t,n){super("=",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return vU(r,o)}}class dB extends qr{constructor(t,n){super("!=",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return yU(r,o)}}class fB extends qr{constructor(t,n){super("~",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return VD(r,o)}}class hB extends qr{constructor(t,n){super("!~",t,n)}eval(t,n){const r=this.left.eval(t,n),o=this.right.eval(t,n);return gU(VD(r,o))}}class Tb extends qr{constructor(t,n){super("is",t,n)}eval(t,n){const r=this.left.eval(t,n);if(r.length!==1)return[];const o=this.right.name;return tt(FD(r[0],o))}}class pB extends qr{constructor(t,n){super("and",t,n)}eval(t,n){const r=ua(this.left.eval(t,n),"boolean"),o=ua(this.right.eval(t,n),"boolean");return r?.value===!0&&o?.value===!0?tt(!0):r?.value===!1||o?.value===!1?tt(!1):[]}}class mB extends qr{constructor(t,n){super("or",t,n)}eval(t,n){const r=ua(this.left.eval(t,n),"boolean"),o=ua(this.right.eval(t,n),"boolean");return r?.value===!1&&o?.value===!1?tt(!1):r?.value||o?.value?tt(!0):[]}}class gB extends qr{constructor(t,n){super("xor",t,n)}eval(t,n){const r=ua(this.left.eval(t,n),"boolean"),o=ua(this.right.eval(t,n),"boolean");return!r||!o?[]:tt(r.value!==o.value)}}class vB extends qr{constructor(t,n){super("implies",t,n)}eval(t,n){const r=ua(this.left.eval(t,n),"boolean"),o=ua(this.right.eval(t,n),"boolean");return o?.value===!0||r?.value===!1?tt(!0):!r||!o?[]:tt(!1)}}class Rb{constructor(t,n){this.name=t,this.args=n}eval(t,n){const r=zr[this.name];if(!r)throw new Error("Unrecognized function: "+this.name);return r(t,n,...this.args)}toString(){return`${this.name}(${this.args.map(t=>t.toString()).join(", ")})`}}class _b{constructor(t,n){this.left=t,this.expr=n}eval(t,n){const r=this.expr.eval(t,n);if(r.length!==1)return[];const o=r[0].value;if(typeof o!="number")throw new Error("Invalid indexer expression: should return integer}");const l=this.left.eval(t,n);return o in l?[l[o]]:[]}toString(){return`${this.left.toString()}[${this.expr.toString()}]`}}const yB=["year","years","month","months","week","weeks","day","days","hour","hours","minute","minutes","second","seconds","millisecond","milliseconds"],xB={"'":"'",'"':'"',"`":"`",r:"\r",n:`
|
|
77
77
|
`,t:" ",f:"\f","\\":"\\"};class bB{constructor(t,n,r,o){this.result=[],this.pos={index:0,line:1,column:0},this.markStack=[],this.str=t,this.keywords=n,this.operators=r,this.dateTimeLiterals=!!o?.dateTimeLiterals,this.symbolRegex=o?.symbolRegex??/[$\w%]/}tokenize(){for(;this.pos.index<this.str.length;){const t=this.consumeToken();t&&this.result.push(t)}return this.result}prevToken(){return this.result.slice(-1)[0]}peekToken(){this.mark();const t=this.consumeToken();return this.reset(),t}consumeToken(){this.consumeWhitespace();const t=this.curr();if(!t)return;this.mark();const n=this.peek();return t==="/"&&n==="*"?this.consumeMultiLineComment():t==="/"&&n==="/"?this.consumeSingleLineComment():t==="'"||t==='"'||t==="`"?this.consumeString(t):t==="@"?this.consumeDateTime():/\d/.exec(t)?this.consumeNumber():/\w/.exec(t)?this.consumeSymbol():(t==="$"||t==="%")&&/\w/.exec(n)?this.consumeSymbol():(t==="$"||t==="%")&&(n==="'"||n==='"'||n==="`")?this.consumeQuotedSymbol(n):this.consumeOperator()}consumeWhitespace(){this.consumeWhile(()=>/\s/.exec(this.curr()))}consumeMultiLineComment(){const t=this.pos.index;return this.consumeWhile(()=>this.curr()!=="*"||this.peek()!=="/"),this.advance(),this.advance(),this.buildToken("Comment",this.str.substring(t,this.pos.index))}consumeSingleLineComment(){return this.buildToken("Comment",this.consumeWhile(()=>this.curr()!==`
|
|
78
78
|
`))}consumeString(t){this.advance();let n="",r;for(;r=this.consumeChar(t);)n+=r;const o=this.buildToken(t==="`"?"Symbol":"String",n);return this.advance(),o}consumeChar(t){const n=this.curr();if(n==="\\"){this.advance();const r=this.curr(),o=xB[r];if(o!==void 0)return this.advance(),o;if(r==="u"){this.advance();const l=/^[0-9a-fA-F]{4}$/.exec(this.str.substring(this.pos.index,this.pos.index+4))?.[0];return l?(this.advance(),this.advance(),this.advance(),this.advance(),String.fromCodePoint(parseInt(l,16))):"u"}return this.consumeChar(t)}return n===t||!n?"":(this.advance(),n)}consumeQuotedSymbol(t){this.mark();const n=this.pos.index;this.advance(),this.consumeString(t);const r=this.str.substring(n,this.pos.index);return this.buildToken("Symbol",r)}consumeDateTime(){this.advance();const t=this.pos.index;this.consumeWhile(()=>/[\d-]/.exec(this.curr()));let n=!1,r=!1;if(this.curr()==="T"&&(n=!0,this.advance(),this.consumeWhile(()=>/[\d:]/.exec(this.curr())),this.curr()==="."&&/\d/.exec(this.peek())&&(this.advance(),this.consumeWhile(()=>/\d/.exec(this.curr()))),this.curr()==="Z"?(r=!0,this.advance()):(this.curr()==="+"||this.curr()==="-")&&(r=!0,this.advance(),this.consumeWhile(()=>/[\d:]/.exec(this.curr())))),this.pos.index===t)throw new Error("Invalid DateTime literal");let o=this.str.substring(t,this.pos.index);return o.endsWith("T")?o=o.substring(0,o.length-1):!o.startsWith("T")&&n&&!r&&(o+="Z"),this.buildToken("DateTime",o)}consumeNumber(){const t=this.pos.index;let n="Number";return this.consumeWhile(()=>/\d/.exec(this.curr())),this.curr()==="."&&/\d/.exec(this.peek())&&(this.advance(),this.consumeWhile(()=>/\d/.exec(this.curr()))),this.curr()==="-"&&this.dateTimeLiterals?(this.pos.index=t-1,this.consumeDateTime()):(this.curr()===" "&&SB(this.peekToken())&&(n="Quantity",this.consumeToken()),this.buildToken(n,this.str.substring(t,this.pos.index)))}consumeSymbol(){const t=this.consumeWhile(()=>this.symbolRegex.exec(this.curr()));return this.prevToken()?.value!=="."&&this.keywords.includes(t)?this.buildToken(t,t):this.buildToken("Symbol",t)}consumeOperator(){const t=this.curr(),n=this.peek(),r=t+n;return this.operators.includes(r)?(this.advance(),this.advance(),this.buildToken(r,r)):(this.advance(),this.buildToken(t,t))}consumeWhile(t){const n=this.pos.index;for(;this.pos.index<this.str.length&&t();)this.advance();return this.str.substring(n,this.pos.index)}curr(){return this.str[this.pos.index]}peek(){return this.str[this.pos.index+1]??""}mark(){this.markStack.push({...this.pos})}reset(){const t=this.markStack.pop();if(!t)throw new Error("No mark to reset to");this.pos.index=t.index,this.pos.line=t.line,this.pos.column=t.column}advance(){this.pos.index++,this.curr()===`
|
|
79
79
|
`?(this.pos.line++,this.pos.column=0):this.pos.column++}buildToken(t,n){const r=this.markStack.pop();if(!r)throw new Error("No mark for token");return{id:t,value:n,...r}}}function SB(e){return!!(e&&(e.id==="String"||e.id==="Symbol"&&yB.includes(e.value)))}const wB=["true","false"],jB=["!=","!~","<=",">=","{}","->"];function CB(e){return new bB(e,wB,jB).tokenize()}const Xt={FunctionCall:0,Dot:1,Indexer:2,UnaryAdd:3,UnarySubtract:3,Multiply:4,Divide:4,Modulo:4,Add:5,Subtract:5,Ampersand:5,Is:6,As:6,Union:7,GreaterThan:8,GreaterThanOrEquals:8,LessThan:8,LessThanOrEquals:8,Equals:9,Equivalent:9,NotEquals:9,NotEquivalent:9,In:10,Contains:10,And:11,Xor:12,Or:12,Implies:13},EB={parse(e){const t=e.consumeAndParse();if(!e.match(")"))throw new Error("Parse error: expected `)` got `"+e.peek()?.value+"`");return t}},TB={parse(e,t){const n=e.consumeAndParse();if(!e.match("]"))throw new Error("Parse error: expected `]`");return new _b(t,n)},precedence:Xt.Indexer},RB={parse(e,t){if(!(t instanceof rp))throw new Error("Unexpected parentheses");const n=[];for(;!e.match(")");)n.push(e.consumeAndParse()),e.match(",");return new Rb(t.name,n)},precedence:Xt.FunctionCall};function _B(e){const t=e.split(" "),n=parseFloat(t[0]);let r=t[1];return r?.startsWith("'")&&r.endsWith("'")?r=r.substring(1,r.length-1):r="{"+r+"}",{value:n,unit:r}}function DB(){return new z$().registerPrefix("String",{parse:(e,t)=>new mc({type:re.string,value:t.value})}).registerPrefix("DateTime",{parse:(e,t)=>new mc({type:re.dateTime,value:Ih(t.value)})}).registerPrefix("Quantity",{parse:(e,t)=>new mc({type:re.Quantity,value:_B(t.value)})}).registerPrefix("Number",{parse:(e,t)=>new mc({type:t.value.includes(".")?re.decimal:re.integer,value:parseFloat(t.value)})}).registerPrefix("true",{parse:()=>new mc({type:re.boolean,value:!0})}).registerPrefix("false",{parse:()=>new mc({type:re.boolean,value:!1})}).registerPrefix("Symbol",{parse:(e,t)=>new rp(t.value)}).registerPrefix("{}",{parse:()=>new oB}).registerPrefix("(",EB).registerInfix("[",TB).registerInfix("(",RB).prefix("+",Xt.UnaryAdd,(e,t)=>new aB("+",t,n=>n)).prefix("-",Xt.UnarySubtract,(e,t)=>new Vi("-",t,t,(n,r)=>-r)).infixLeft(".",Xt.Dot,(e,t,n)=>new Cb(e,n)).infixLeft("/",Xt.Divide,(e,t,n)=>new Vi("/",e,n,(r,o)=>r/o)).infixLeft("*",Xt.Multiply,(e,t,n)=>new Vi("*",e,n,(r,o)=>r*o)).infixLeft("+",Xt.Add,(e,t,n)=>new Vi("+",e,n,(r,o)=>r+o)).infixLeft("-",Xt.Subtract,(e,t,n)=>new Vi("-",e,n,(r,o)=>r-o)).infixLeft("|",Xt.Union,(e,t,n)=>new Eb(e,n)).infixLeft("=",Xt.Equals,(e,t,n)=>new uB(e,n)).infixLeft("!=",Xt.NotEquals,(e,t,n)=>new dB(e,n)).infixLeft("~",Xt.Equivalent,(e,t,n)=>new fB(e,n)).infixLeft("!~",Xt.NotEquivalent,(e,t,n)=>new hB(e,n)).infixLeft("<",Xt.LessThan,(e,t,n)=>new Vi("<",e,n,(r,o)=>r<o)).infixLeft("<=",Xt.LessThanOrEquals,(e,t,n)=>new Vi("<=",e,n,(r,o)=>r<=o)).infixLeft(">",Xt.GreaterThan,(e,t,n)=>new Vi(">",e,n,(r,o)=>r>o)).infixLeft(">=",Xt.GreaterThanOrEquals,(e,t,n)=>new Vi(">=",e,n,(r,o)=>r>=o)).infixLeft("&",Xt.Ampersand,(e,t,n)=>new sB(e,n)).infixLeft("and",Xt.And,(e,t,n)=>new pB(e,n)).infixLeft("as",Xt.As,(e,t,n)=>new ip(e,n)).infixLeft("contains",Xt.Contains,(e,t,n)=>new lB(e,n)).infixLeft("div",Xt.Divide,(e,t,n)=>new Vi("div",e,n,(r,o)=>r/o|0)).infixLeft("in",Xt.In,(e,t,n)=>new cB(e,n)).infixLeft("is",Xt.Is,(e,t,n)=>new Tb(e,n)).infixLeft("mod",Xt.Modulo,(e,t,n)=>new Vi("mod",e,n,(r,o)=>r%o)).infixLeft("or",Xt.Or,(e,t,n)=>new mB(e,n)).infixLeft("xor",Xt.Xor,(e,t,n)=>new gB(e,n)).infixLeft("implies",Xt.Implies,(e,t,n)=>new vB(e,n))}const AB=DB();function Db(e){return new sA(e,AB.construct(CB(e)).consumeAndParse())}function PB(e,t){const n=Array.isArray(t)?t:[t];for(let r=0;r<n.length;r++){const o=n[r];typeof o=="object"&&"type"in o&&"value"in o||(n[r]=ri(n[r]))}return cs(e,n).map(r=>r.value)}function cs(e,t,n={},r=void 0){let o;if(typeof e=="string"){const l=r?.get(e);o=l??Db(e),r&&!l&&r.set(e,o)}else o=e;return o.eval({variables:n},t).map(l=>({type:l.type,value:l.value?.valueOf()}))}function kB(e){const t=[];for(const n of e){const r=GD(n.value);r&&t.push(r)}return t}function NB(e){const t=new Set;for(const n of e){const r=il(n);r&&t.add(r)}return Array.from(t)}function OB(e){const t=new Set;for(const n of e){const{value:r}=n;r&&(NU(r)?t.add(r):wa(r)?t.add(r.reference):WD(r)?t.add(_t(r)):typeof r.identifier=="object"&&t.add(`identifier:${r.identifier.system}|${r.identifier.value}`))}return Array.from(t)}function MB(e,t={}){const n=[];for(const r of e)LB(t,n,r);return n}function LB(e,t,n){const{type:r,value:o}=n;switch(r){case re.Identifier:IB(t,e,o);break;case re.CodeableConcept:zB(t,e,o);break;case re.Coding:lA(t,e,o);break;case re.ContactPoint:$B(t,e,o);break;default:al(t,e,void 0,o?.toString())}}function IB(e,t,n){n?.type?.text&&al(e,t,t.textSearchSystem,n.type.text),al(e,t,n?.system,n?.value)}function zB(e,t,n){if(n?.text&&al(e,t,t.textSearchSystem,n.text),n?.coding)for(const r of n.coding)lA(e,t,r)}function lA(e,t,n){n&&(n.display&&al(e,t,t.textSearchSystem,n.display),al(e,t,n.system,n.code))}function $B(e,t,n){n&&al(e,t,n.system,n.value?.toLocaleLowerCase())}function al(e,t,n,r){(n||r)&&!e.some(o=>o.system===n&&o.value===r)&&e.push({system:n,value:r&&t.caseInsensitive?r.toLocaleLowerCase():r})}const pm=20,de={EQUALS:"eq",NOT_EQUALS:"ne",GREATER_THAN:"gt",LESS_THAN:"lt",GREATER_THAN_OR_EQUALS:"ge",LESS_THAN_OR_EQUALS:"le",STARTS_AFTER:"sa",ENDS_BEFORE:"eb",APPROXIMATELY:"ap",CONTAINS:"contains",STARTS_WITH:"sw",EXACT:"exact",TEXT:"text",NOT:"not",ABOVE:"above",BELOW:"below",IN:"in",NOT_IN:"not-in",OF_TYPE:"of-type",MISSING:"missing",PRESENT:"present",IDENTIFIER:"identifier",ITERATE:"iterate"},cA={contains:de.CONTAINS,exact:de.EXACT,above:de.ABOVE,below:de.BELOW,text:de.TEXT,not:de.NOT,in:de.IN,"not-in":de.NOT_IN,"of-type":de.OF_TYPE,missing:de.MISSING,identifier:de.IDENTIFIER,iterate:de.ITERATE},Ab={eq:de.EQUALS,ne:de.NOT_EQUALS,lt:de.LESS_THAN,le:de.LESS_THAN_OR_EQUALS,gt:de.GREATER_THAN,ge:de.GREATER_THAN_OR_EQUALS,sa:de.STARTS_AFTER,eb:de.ENDS_BEFORE,ap:de.APPROXIMATELY,sw:de.STARTS_WITH};function uA(e,t){if(!e)throw new Error("Invalid search URL");let n="",r;if(typeof e=="string")if(e.includes("?")){const[c,d]=e.split("?");n=c,r=new URLSearchParams(d)}else n=e;else typeof e=="object"&&(n=e.pathname,r=e.searchParams);let o;n.includes("/")?o=n.split("/").filter(Boolean).pop():o=n;const l=[];return r&&l.push(...r.entries()),UB(o,l)}function UB(e,t){const n={resourceType:e};for(const[r,o]of t)BB(n,r,o);return n}function BB(e,t,n){let r,o;const l=t.indexOf(":");if(l>=0?(r=t.substring(0,l),o=t.substring(l+1)):(r=t,o=""),r!=="_"){if(r==="_has"||t.includes(".")){e.filters=Wu(e.filters,{code:t,operator:de.EQUALS,value:n});return}switch(r){case"_sort":VB(e,n);break;case"_cursor":e.cursor=n;break;case"_count":e.count=parseInt(n,10);break;case"_offset":e.offset=parseInt(n,10);break;case"_total":e.total=n;break;case"_summary":n==="count"?(e.total="accurate",e.count=0):(n==="true"||n==="data"||n==="text")&&(e.summary=n);break;case"_include":{const c=HE(n);o==="iterate"&&(c.modifier=de.ITERATE),e.include=Wu(e.include,c);break}case"_revinclude":{const c=HE(n);o==="iterate"&&(c.modifier=de.ITERATE),e.revInclude=Wu(e.revInclude,c);break}case"_fields":case"_elements":e.fields=n.split(",");break;case"_type":e.types=n.split(",");break;case"_format":e.format=n;break;case"_pretty":e.pretty=n==="true";break;default:{const c=Eo.types[e.resourceType]?.searchParams?.[r];c?e.filters=Wu(e.filters,HB(c,o,n)):e.filters=Wu(e.filters,qB(r,o,n))}}}}function VB(e,t){for(const n of t.split(",")){let r,o=!1;n.startsWith("-")?(r=n.substring(1),o=!0):r=n,e.sortRules||(e.sortRules=[]),e.sortRules.push({code:r,descending:o})}}const FB=[de.MISSING,de.PRESENT];function HB(e,t,n){if(FB.includes(t))return{code:e.code,operator:t,value:n};switch(e.type){case"number":case"date":case"quantity":{const{operator:r,value:o}=GB(n);if(!qE(e,o))throw new ft(xo(`Invalid format for ${e.type} search parameter: ${o}`));return{code:e.code,operator:r,value:o}}case"reference":case"string":case"token":case"uri":if(!qE(e,n))throw new ft(xo(`Invalid format for ${e.type} search parameter: ${n}`));return{code:e.code,operator:QB(t),value:n};default:throw new Error("Unrecognized search parameter type: "+e.type)}}function qB(e,t,n){let r=de.EQUALS;if(t)r=t;else if(n.length>=2){const o=n.substring(0,2);o in Ab&&(n.length===2||n.at(2)?.match(/\d/))&&(r=o,n=n.substring(o.length))}return{code:e,operator:r,value:n}}function GB(e){const t=e.substring(0,2),n=Ab[t];return n?{operator:n,value:e.substring(2)}:{operator:de.EQUALS,value:e}}function QB(e){return cA[e]??de.EQUALS}function HE(e){const t=e.split(":");if(t.includes("*"))throw new ft(xo("'*' is not supported as a value for search inclusion parameters"));if(t.length===1)throw new ft(xo(`Invalid include value '${e}': must be of the form ResourceType:search-parameter`));if(t.length===2)return{resourceType:t[0],searchParam:t[1]};if(t.length===3)return{resourceType:t[0],searchParam:t[1],targetType:t[2]};throw new ft(xo(`Invalid include value '${e}'`))}function qE(e,t){switch(e.type){case"date":return pd(t);default:return!0}}function is(e){const t=[];return e.fields&&t.push("_fields="+e.fields.join(",")),e.filters&&e.filters.forEach(n=>t.push(WB(n))),e.sortRules&&e.sortRules.length>0&&t.push(YB(e.sortRules)),e.cursor!==void 0&&t.push("_cursor="+encodeURIComponent(e.cursor)),e.offset!==void 0&&e.offset!==0&&t.push("_offset="+e.offset),e.count!==void 0&&t.push("_count="+e.count),e.total!==void 0&&t.push("_total="+e.total),e.types&&e.types.length>0&&t.push("_type="+e.types.join(",")),e.include&&e.include.forEach(n=>t.push(GE("_include",n))),e.revInclude&&e.revInclude.forEach(n=>t.push(GE("_revinclude",n))),t.length===0?"":(Ic(t),"?"+t.join("&"))}function WB(e){const t=e.operator in cA?":"+e.operator:"",n=e.operator!==de.EQUALS&&e.operator in Ab?e.operator:"";return`${e.code}${t}=${n}${encodeURIComponent(e.value)}`}function YB(e){return"_sort="+e.map(t=>t.descending?"-"+t.code:t.code).join(",")}function GE(e,t){return e+(t.modifier?":"+t.modifier:"")+"="+t.resourceType+":"+t.searchParam+(t.targetType?":"+t.targetType:"")}function mm(e){const t=[];let n="",r=!1;for(const o of e)r?(n+=o,r=!1):o==="\\"?r=!0:o===","?(t.push(n),n=""):n+=o;return t.push(n),t}function KB(e,t){if(t.resourceType!==e.resourceType)return!1;if(t.filters){for(const n of t.filters)if(!XB(e,t,n))return!1}return!0}function XB(e,t,n){const r=Eo.types[t.resourceType]?.searchParams?.[n.code];if(!r)return!1;const o=cs(r.expression,[ri(e)]);if(n.operator===de.MISSING||n.operator===de.PRESENT)return ZB(o,n);switch(r.type){case"reference":return JB(o,n);case"string":case"uri":return nV(o,n);case"token":return eV(o,n);case"date":return iV(o,n);default:return!1}}function ZB(e,t){const n=e.length>0;return(t.operator===de.MISSING&&t.value==="false"||t.operator===de.PRESENT&&t.value==="true")===n}function JB(e,t){const n=gm(t.operator);if(t.value===""&&e.length===0)return t.operator===de.EQUALS;const r=OB(e);for(const o of mm(t.value)){let l=r.includes(o);if(!l&&t.code==="_compartment"&&(l=r.some(c=>c?.endsWith("/"+o))),l)return!n}return n}function eV(e,t){const n=MB(e),r=mm(t.value),o=gm(t.operator);for(const l of n)for(const c of r)if(tV(l,c))return!o;return o}function tV(e,t){if(t.includes("|")){const[n,r]=t.split("|").map(o=>o.toLowerCase());return!n&&!r?!1:n?e.system?.toLowerCase()===n&&(!r||e.value?.toLowerCase()===r):!e.system&&e.value?.toLowerCase()===r}return e.value?.toLowerCase()===t.toLowerCase()}function nV(e,t){const n=NB(e),r=mm(t.value),o=gm(t.operator);for(const l of n)for(const c of r)if(rV(l,c))return!o;return o}function rV(e,t){return e.toLowerCase().includes(t.toLowerCase())}function iV(e,t){const n=kB(e),r=mm(t.value),o=gm(t.operator);for(const l of n)for(const c of r)if(oV(l,t.operator,c))return!o;return o}function oV(e,t,n){if(!e)return!1;const r=GD(n);if(!r)return!1;const o=e.start??"0000",l=e.end??"9999",c=r.start,d=r.end;switch(t){case de.APPROXIMATELY:case de.EQUALS:case de.NOT_EQUALS:return o<d&&l>c;case de.LESS_THAN:return o<c;case de.GREATER_THAN:return l>d;case de.LESS_THAN_OR_EQUALS:return o<=d;case de.GREATER_THAN_OR_EQUALS:return l>=c;case de.STARTS_AFTER:return o>d;case de.ENDS_BEFORE:return l<c;default:return!1}}function gm(e){return e===de.NOT_EQUALS||e===de.NOT}const aV={resourceType:"*"},sV=["DomainConfiguration","JsonWebKey","Login"],lV=["PasswordChangeRequest","UserSecurityRequest","Project","ProjectMembership","User"],Xs={READ:"read",VREAD:"vread",UPDATE:"update",HISTORY:"history",SEARCH:"search"},cV=[Xs.READ,Xs.VREAD,Xs.HISTORY,Xs.SEARCH];function uV(e,t){return sV.includes(t)?!1:dV(e,Xs.UPDATE,t)}function dV(e,t,n){return!!e.resource?.some(r=>fA(r,n,t))}function dA(e,t,n){return n?n.resource?.find(r=>fV(e,t,r)):aV}function fV(e,t,n){const r=e.resourceType;return fA(n,r,t)?r==="Binary"?!0:!(n.compartment&&!e.meta?.compartment?.some(o=>o.reference===n.compartment?.reference)||n.criteria&&!KB(e,uA(n.criteria))):!1}function fA(e,t,n){return e.resourceType!==t&&(e.resourceType!=="*"||lV.includes(t))?!1:e.interaction?e.interaction.includes(n):!e.readonly||cV.includes(n)}function po(){return typeof window<"u"}function hA(){return typeof Buffer<"u"?Buffer:void 0}const Xn={assign(e){po()&&globalThis.location.assign(e)},reload(){po()&&globalThis.location.reload()},getSearch(){return po()?globalThis.location.search:""},getPathname(){return po()?globalThis.location.pathname:""},getLocation(){return po()?globalThis.location.toString():""},getOrigin(){return po()?globalThis.location.protocol+"//"+globalThis.location.host+"/":""}};function hV(e){if(po()){const n=window.atob(e),r=Uint8Array.from(n,o=>o.charCodeAt(0));return new window.TextDecoder().decode(r)}const t=hA();if(t)return t.from(e,"base64").toString("utf-8");throw new Error("Unable to decode base64")}function QE(e){if(po()){const n=new window.TextEncoder().encode(e),r=String.fromCharCode.apply(null,n);return window.btoa(r)}const t=hA();if(t)return t.from(e,"utf8").toString("base64");throw new Error("Unable to encode base64")}function pV(e){e=e.padEnd(e.length+(4-e.length%4)%4,"=");const t=e.replace(/-/g,"+").replace(/_/g,"/");return hV(t)}function WE(){const e=new Uint32Array(28);return crypto.getRandomValues(e),MU(e.buffer)}async function mV(e){return crypto.subtle.digest("SHA-256",new TextEncoder().encode(e))}function pA(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function mA(e){const t={};e=ii(e);for(const o of e.entry||[]){const l=o.resource;if(!l)continue;l.meta!==void 0&&(delete l.meta.author,delete l.meta.compartment,delete l.meta.lastUpdated,delete l.meta.project,delete l.meta.versionId,Object.keys(l.meta).length===0&&delete l.meta);const c=l?.id;c&&(t[c]=pA(),o.fullUrl="urn:uuid:"+t[c],delete o.resource?.id)}const n=e.entry,r=JSON.stringify({resourceType:"Bundle",type:"transaction",entry:n?.map(o=>({fullUrl:o.fullUrl,request:{method:"POST",url:o.resource?.resourceType},resource:o.resource}))},(o,l)=>gV(o,l,t),2);return vV(JSON.parse(r))}function gV(e,t,n){if(e==="reference"&&typeof t=="string"){let r;if(t.includes("/")?r=t.split("/")[1]:t.startsWith("urn:uuid:")?r=t.slice(9):t.startsWith("#")&&(r=t.slice(1)),r){const o=n[r];if(o)return"urn:uuid:"+o}}return t}function vV(e){const t=xV(e),{sorted:n,cycles:r}=yV(t),o={};for(const c of e.entry??[])c.fullUrl&&(o[c.fullUrl]=c);const l=n.map(c=>o[c]);for(const c of r)for(const d of c){const f=o[d],p={...f,request:{...f.request,method:"PUT"}};l.push(p)}return{...e,entry:l}}const gc={NotVisited:"NotVisited",Visiting:"Visiting",Visited:"Visited"};function yV(e){const t=[],n={},r=[];for(const l of Object.keys(e))n[l]=gc.NotVisited;function o(l,c){if(n[l]===gc.Visited)return!0;if(n[l]===gc.Visiting){const f=c.lastIndexOf(l);return f!==-1&&r.push(c.slice(f)),!0}n[l]=gc.Visiting,c.push(l);let d=!1;for(const f of e[l])o(f,c)||(d=!0);return n[l]=gc.Visited,c.pop(),t.unshift(l),!d}for(const l in e)n[l]===gc.NotVisited&&o(l,[]);return{sorted:t,cycles:r}}function gA(e,t){for(const n in e)if(e[n]&&typeof e[n]=="object"){const r=e[n];if(wa(r)){const o=r.reference;o.startsWith("urn:uuid:")&&t(o)}else gA(r,t)}}function xV(e){const t={};for(const n of e.entry||[])n.fullUrl&&(t[n.fullUrl]=[]);for(const n of e.entry||[]){const r=n.fullUrl;n.resource&&gA(n.resource,o=>{t[o]&&t[o].push(r)})}return t}const ln={FHIR_JSON:"application/fhir+json",FORM_URL_ENCODED:"application/x-www-form-urlencoded",HL7_V2:"x-application/hl7-v2+er7",JSON:"application/json",JSON_PATCH:"application/json-patch+json",TEXT:"text/plain",PING:"x-application/ping",XML:"text/xml",CDA_XML:"application/cda+xml"};let bV=class{constructor(){this.listeners={}}addEventListener(t,n){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(n)}removeEventListener(t,n){const r=this.listeners[t];if(r){for(let o=0;o<r.length;o++)if(r[o]===n){r.splice(o,1);return}}}dispatchEvent(t){const n=this.listeners[t.type];if(n)for(const r of n)r.call(this,t);return!t.defaultPrevented}removeAllListeners(){this.listeners={}}};class vm{constructor(){this.emitter=new bV}dispatchEvent(t){this.emitter.dispatchEvent(t)}addEventListener(t,n){this.emitter.addEventListener(t,n)}removeEventListener(t,n){this.emitter.removeEventListener(t,n)}removeAllListeners(){this.emitter.removeAllListeners()}}const cx={"Patient-open":"Patient-open","Patient-close":"Patient-close","ImagingStudy-open":"ImagingStudy-open","ImagingStudy-close":"ImagingStudy-close","Encounter-open":"Encounter-open","Encounter-close":"Encounter-close","DiagnosticReport-open":"DiagnosticReport-open","DiagnosticReport-close":"DiagnosticReport-close","DiagnosticReport-select":"DiagnosticReport-select","DiagnosticReport-update":"DiagnosticReport-update",syncerror:"syncerror"},SV=["Patient","Encounter","ImagingStudy","DiagnosticReport","OperationOutcome","Bundle"],Pb=["DiagnosticReport-update"];function wV(e){return Pb.includes(e)}function jV(e){if(Pb.includes(e))throw new ft(gn(`'context.version' is required for '${e}'.`))}const CV={"Patient-open":{patient:{resourceType:"Patient"},encounter:{resourceType:"Encounter",optional:!0}},"Patient-close":{patient:{resourceType:"Patient"},encounter:{resourceType:"Encounter",optional:!0}},"ImagingStudy-open":{study:{resourceType:"ImagingStudy"},encounter:{resourceType:"Encounter",optional:!0},patient:{resourceType:"Patient",optional:!0}},"ImagingStudy-close":{study:{resourceType:"ImagingStudy"},encounter:{resourceType:"Encounter",optional:!0},patient:{resourceType:"Patient",optional:!0}},"Encounter-open":{encounter:{resourceType:"Encounter"},patient:{resourceType:"Patient"}},"Encounter-close":{encounter:{resourceType:"Encounter"},patient:{resourceType:"Patient"}},"DiagnosticReport-open":{report:{resourceType:"DiagnosticReport"},encounter:{resourceType:"Encounter",optional:!0},study:{resourceType:"ImagingStudy",optional:!0,manyAllowed:!0},patient:{resourceType:"Patient"}},"DiagnosticReport-close":{report:{resourceType:"DiagnosticReport"},encounter:{resourceType:"Encounter",optional:!0},study:{resourceType:"ImagingStudy",optional:!0,manyAllowed:!0},patient:{resourceType:"Patient"}},"DiagnosticReport-select":{report:{resourceType:"DiagnosticReport",reference:!0},patient:{resourceType:"Patient",optional:!0,reference:!0},select:{resourceType:"*",reference:!0,manyAllowed:!0}},"DiagnosticReport-update":{report:{resourceType:"DiagnosticReport",reference:!0},patient:{resourceType:"Patient",optional:!0,reference:!0},updates:{resourceType:"Bundle"}},syncerror:{operationoutcome:{resourceType:"OperationOutcome"}}};function EV(e){return SV.includes(e)}function vA(e){return!!e.endpoint}function YE(e){if(!kb(e))throw new ft(gn("subscriptionRequest must be an object conforming to SubscriptionRequest type."));const{channelType:t,mode:n,topic:r,events:o}=e,l={"hub.channel.type":t,"hub.mode":n,"hub.topic":r,"hub.events":o.join(",")};return vA(e)&&(l.endpoint=e.endpoint),new URLSearchParams(l).toString()}function kb(e){if(typeof e!="object")return!1;const{channelType:t,mode:n,topic:r,events:o}=e;if(!(t&&n&&r&&o)||typeof r!="string"||typeof o!="object"||!Array.isArray(o)||o.length<1||t!=="websocket"||n!=="subscribe"&&n!=="unsubscribe")return!1;for(const l of o)if(!cx[l])return!1;return!(vA(e)&&!(typeof e.endpoint=="string"&&e.endpoint.startsWith("ws")))}function TV(e,t,n,r){if(typeof t!="object")throw new ft(gn(`context[${n}] is invalid. Context must contain a single valid FHIR resource! Resource is not an object.`));if(!(t.id&&typeof t.id=="string"))throw new ft(gn(`context[${n}] is invalid. Resource must contain a valid string ID.`));if(!t.resourceType)throw new ft(gn(`context[${n}] is invalid. Resource must contain a resource type. No resource type found.`));const o=r.resourceType;if(o!=="*"){if(!EV(t.resourceType))throw new ft(gn(`context[${n}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));if(o&&t.resourceType!==o)throw new ft(gn(`context[${n}] is invalid. context[${n}] for the '${e}' event should contain resource of type ${o}.`))}}function RV(e,t,n,r,o){if(o.set(t.key,(o.get(t.key)??0)+1),r.reference){if(!wa(t.reference))throw new ft(gn(`context[${n}] is invalid. Expected key '${t.key}' to be a reference.`))}else TV(e,t.resource,n,r)}function _V(e,t){const n=new Map,r=CV[e];for(let o=0;o<t.length;o++){const l=t[o].key;if(!r[l])throw new ft(gn(`Key '${l}' not found for event '${e}'. Make sure to add only valid keys.`));RV(e,t[o],o,r[l],n)}for(const[o,l]of Object.entries(r)){if(!(l.optional||n.has(o)))throw new ft(gn(`Missing required key '${o}' on context for '${e}' event.`));if(!l.manyAllowed&&(n.get(o)??0)>1)throw new ft(gn(`${n.get(o)} context entries with key '${o}' found for the '${e}' event when schema only allows for 1.`))}}function KE(e,t,n,r){if(!(e&&typeof e=="string"))throw new ft(gn("Must provide a topic."));if(!cx[t])throw new ft(gn(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(cx).join(", ")}`));if(typeof n!="object")throw new ft(gn("context must be a context object or array of context objects."));if(Pb.includes(t)&&!r)throw new ft(gn(`The '${t}' event must contain a 'context.versionId'.`));const o=Array.isArray(n)?n:[n];return _V(t,o),{timestamp:new Date().toISOString(),id:pA(),event:{"hub.topic":e,"hub.event":t,context:o,...r?{"context.versionId":r}:{}}}}class DV extends vm{constructor(t){if(super(),this.subRequest=t,!t.endpoint)throw new ft(gn("Subscription request should contain an endpoint."));if(!kb(t))throw new ft(gn("Subscription request failed validation."));const n=new WebSocket(t.endpoint);n.addEventListener("open",()=>{this.dispatchEvent({type:"connect"}),n.addEventListener("message",r=>{const o=JSON.parse(r.data);if(o["hub.topic"])return;const l=o;l.event["hub.event"]!=="heartbeat"&&(this.dispatchEvent({type:"message",payload:l}),n.send(JSON.stringify({id:o?.id,timestamp:new Date().toISOString()})))}),n.addEventListener("close",()=>{this.dispatchEvent({type:"disconnect"})})}),this.websocket=n}disconnect(){this.websocket.close()}}function AV(e){return JSON.parse(pV(e))}function PV(e){return e.split(".").length===3}function Nb(e){const[t,n,r]=e.split(".");return AV(n)}function kV(e){try{return typeof Nb(e).login_id=="string"}catch{return!1}}function NV(e){try{const n=Nb(e).exp;return typeof n=="number"?n*1e3:void 0}catch{return}}class OV{constructor(t){this.medplum=t}async get(t){return this.medplum.get(`keyvalue/v1/${t}`)}async set(t,n){await this.medplum.put(`keyvalue/v1/${t}`,n,ln.TEXT)}async delete(t){await this.medplum.delete(`keyvalue/v1/${t}`)}}var yA;yA=Symbol.toStringTag;class Fi{constructor(t){this[yA]="ReadablePromise",this.status="pending",this.suspender=t.then(n=>(this.status="success",this.response=n,n),n=>{throw this.status="error",this.error=n,n})}isPending(){return this.status==="pending"}isOk(){return this.status==="success"}read(){switch(this.status){case"pending":throw this.suspender;case"error":throw this.error;default:return this.response}}then(t,n){return this.suspender.then(t,n)}catch(t){return this.suspender.catch(t)}finally(t){return this.suspender.finally(t)}}class MV{constructor(t){this.storage=t??(typeof localStorage<"u"?localStorage:new LV)}clear(){this.storage.clear()}getString(t){return this.storage.getItem(t)??void 0}setString(t,n){n?this.storage.setItem(t,n):this.storage.removeItem(t)}getObject(t){const n=this.getString(t);return n?JSON.parse(n):void 0}setObject(t,n){this.setString(t,n?Ki(n):void 0)}}class LV{constructor(){this.data=new Map}get length(){return this.data.size}clear(){this.data.clear()}getItem(t){return this.data.get(t)??null}setItem(t,n){n?this.data.set(t,n):this.data.delete(t)}removeItem(t){this.data.delete(t)}key(t){return Array.from(this.data.keys())[t]}}/*!
|
|
@@ -84,7 +84,7 @@ function F3(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&
|
|
|
84
84
|
*
|
|
85
85
|
* Copy of "partysocket" from Partykit team, a fork of the original "Reconnecting WebSocket"
|
|
86
86
|
* https://github.com/partykit/partykit/blob/main/packages/partysocket
|
|
87
|
-
*/const Ec={Event:typeof globalThis.Event<"u"?globalThis.Event:void 0,ErrorEvent:void 0,CloseEvent:void 0};let XE=!1;function IV(){if(typeof globalThis.Event>"u")throw new Error("Unable to lazy init events for ReconnectingWebSocket. globalThis.Event is not defined yet");Ec.Event=globalThis.Event,Ec.ErrorEvent=class extends Event{constructor(t,n){super("error",n),this.message=t.message,this.error=t}},Ec.CloseEvent=class extends Event{constructor(t=1e3,n="",r){super("close",r),this.wasClean=!0,this.code=t,this.reason=n}}}function zV(e,t){if(!e)throw new Error(t)}function Sh(e){return new e.constructor(e.type,e)}const $s={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0};let ZE=!1;class Za extends vm{constructor(t,n,r={}){XE||(IV(),XE=!0),super(),this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._closeCalled=!1,this._messageQueue=[],this._debugLogger=console.log.bind(console),this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=o=>{this._debug("open event");const{minUptime:l=$s.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),l),zV(this._ws,"WebSocket is not defined"),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(c=>this._ws?.send(c)),this._messageQueue=[],this.onopen&&this.onopen(o),this.dispatchEvent(Sh(o))},this._handleMessage=o=>{this._debug("message event"),this.onmessage&&this.onmessage(o),this.dispatchEvent(Sh(o))},this._handleError=o=>{this._debug("error event",o.message),this._disconnect(void 0,o.message==="TIMEOUT"?"timeout":void 0),this.onerror&&this.onerror(o),this._debug("exec error listeners"),this.dispatchEvent(Sh(o)),this._connect()},this._handleClose=o=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(o),this.dispatchEvent(Sh(o))},this._url=t,this._protocols=n,this._options=r,this._options.startClosed&&(this._shouldReconnect=!1),this._options.binaryType?this._binaryType=this._options.binaryType:this._binaryType="blob",this._options.debugLogger&&(this._debugLogger=this._options.debugLogger),this._connect()}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}get CONNECTING(){return Za.CONNECTING}get OPEN(){return Za.OPEN}get CLOSING(){return Za.CLOSING}get CLOSED(){return Za.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(t){this._binaryType=t,this._ws&&(this._ws.binaryType=t)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((n,r)=>(typeof r=="string"?n+=r.length:r instanceof Blob?n+=r.size:n+=r.byteLength,n),0)+(this._ws?.bufferedAmount??0)}get extensions(){return this._ws?.extensions??""}get protocol(){return this._ws?.protocol??""}get readyState(){return this._ws?this._ws.readyState:this._options.startClosed?Za.CLOSED:Za.CONNECTING}get url(){return this._ws?this._ws.url:""}get shouldReconnect(){return this._shouldReconnect}close(t=1e3,n){if(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(t,n)}reconnect(t,n){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,n),this._connect())}send(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{const{maxEnqueuedMessages:n=$s.maxEnqueuedMessages}=this._options;this._messageQueue.length<n&&(this._debug("enqueue",t),this._messageQueue.push(t))}}_debug(...t){this._options.debug&&this._debugLogger("RWS>",...t)}_getNextDelay(){const{reconnectionDelayGrowFactor:t=$s.reconnectionDelayGrowFactor,minReconnectionDelay:n=$s.minReconnectionDelay,maxReconnectionDelay:r=$s.maxReconnectionDelay}=this._options;let o=0;return this._retryCount>0&&(o=n*Math.pow(t,this._retryCount-1),o>r&&(o=r)),this._debug("next delay",o),o}_wait(){return new Promise(t=>{setTimeout(t,this._getNextDelay())})}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;const{maxRetries:t=$s.maxRetries,connectionTimeout:n=$s.connectionTimeout}=this._options;if(this._retryCount>=t){this._debug("max retries reached",this._retryCount,">=",t);return}this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),this._wait().then(()=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&typeof WebSocket>"u"&&!ZE&&(console.error("‼️ No WebSocket implementation available. You should define options.WebSocket."),ZE=!0);const r=this._options.WebSocket||WebSocket;this._debug("connect",{url:this._url,protocols:this._protocols}),this._ws=this._protocols?new r(this._url,this._protocols):new r(this._url),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),n)}).catch(r=>{this._connectLock=!1,this._handleError(new Ec.ErrorEvent(Error(r.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new Ec.ErrorEvent(Error("TIMEOUT"),this))}_disconnect(t=1e3,n){if(this._clearTimeouts(),!!this._ws){this._removeListeners();try{this._ws.close(t,n),this._handleClose(new Ec.CloseEvent(t,n,this))}catch{}}}_acceptOpen(){this._debug("accept open"),this._retryCount=0}_removeListeners(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))}_addListeners(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}}const $V=5e3;class ux extends vm{constructor(...t){super(),this.criteria=new Set(t)}getCriteria(){return this.criteria}_addCriteria(t){this.criteria.add(t)}_removeCriteria(t){this.criteria.delete(t)}}class UV{constructor(t,n){this.connecting=!1,this.criteria=t,this.emitter=new ux(t),this.refCount=1,this.subscriptionProps=n?{...n}:void 0}clearAttachedSubscription(){this.subscriptionId=void 0,this.token=void 0}}class BV{constructor(t,n,r){if(this.pingTimer=void 0,this.waitingForPong=!1,!(t instanceof bA))throw new ft(gn("First arg of constructor should be a `MedplumClient`"));let o;try{o=new URL(n).toString()}catch{throw new ft(gn("Not a valid URL"))}const l=r?.ReconnectingWebSocket?new r.ReconnectingWebSocket(o,void 0,{debug:r?.debug,debugLogger:r?.debugLogger}):new Za(o,void 0,{debug:r?.debug,debugLogger:r?.debugLogger});this.medplum=t,this.ws=l,this.masterSubEmitter=new ux,this.criteriaEntries=new Map,this.criteriaEntriesBySubscriptionId=new Map,this.wsClosed=!1,this.pingIntervalMs=r?.pingIntervalMs??$V,this.currentProfile=t.getProfile(),this.setupListeners()}setupListeners(){const t=this.ws;t.addEventListener("message",n=>{try{const r=JSON.parse(n.data);if(r.type==="pong"){this.waitingForPong=!1;return}const o=r,l=o?.entry?.[0]?.resource;if(l.type==="heartbeat"){this.masterSubEmitter?.dispatchEvent({type:"heartbeat",payload:o});return}if(l.type==="handshake"){const d=rl(l.subscription),f={type:"connect",payload:{subscriptionId:d}};this.masterSubEmitter?.dispatchEvent(f);const p=this.criteriaEntriesBySubscriptionId.get(d);if(!p){console.warn("Received handshake for criteria the SubscriptionManager is not listening for yet");return}p.connecting=!1,p.emitter.dispatchEvent({...f});return}this.masterSubEmitter?.dispatchEvent({type:"message",payload:o});const c=this.criteriaEntriesBySubscriptionId.get(rl(l.subscription));if(!c){console.warn("Received notification for criteria the SubscriptionManager is not listening for");return}c.emitter.dispatchEvent({type:"message",payload:o})}catch(r){console.error(r);const o={type:"error",payload:r};this.masterSubEmitter?.dispatchEvent(o);for(const l of this.getAllCriteriaEmitters())l.dispatchEvent({...o})}}),t.addEventListener("error",()=>{const n={type:"error",payload:new ft(K$(new Error("WebSocket error")))};this.masterSubEmitter?.dispatchEvent(n);for(const r of this.getAllCriteriaEmitters())r.dispatchEvent({...n})}),t.addEventListener("close",()=>{const n={type:"close"};this.masterSubEmitter?.dispatchEvent(n);for(const r of this.getAllCriteriaEmitters())r.dispatchEvent({...n});this.pingTimer&&(clearInterval(this.pingTimer),this.pingTimer=void 0,this.waitingForPong=!1),this.wsClosed&&(this.criteriaEntries.clear(),this.criteriaEntriesBySubscriptionId.clear(),this.masterSubEmitter?.removeAllListeners())}),t.addEventListener("open",()=>{const n={type:"open"};this.masterSubEmitter?.dispatchEvent(n);for(const r of this.getAllCriteriaEmitters())r.dispatchEvent({...n});this.refreshAllSubscriptions().catch(console.error),this.pingTimer||(this.pingTimer=setInterval(()=>{if(this.waitingForPong){this.waitingForPong=!1,t.reconnect();return}t.send(JSON.stringify({type:"ping"})),this.waitingForPong=!0},this.pingIntervalMs))}),this.medplum.addEventListener("change",()=>{const n=this.medplum.getProfile();this.currentProfile&&n===void 0?this.ws.close():n&&this.currentProfile?.id!==n.id&&this.ws.reconnect(),this.currentProfile=n})}emitError(t,n){const r={type:"error",payload:n};this.masterSubEmitter?.dispatchEvent(r),t.emitter.dispatchEvent({...r})}maybeEmitDisconnect(t){const{subscriptionId:n}=t;if(n){const r={type:"disconnect",payload:{subscriptionId:n}};this.masterSubEmitter?.dispatchEvent(r),t.emitter.dispatchEvent({...r})}else console.warn("Called disconnect for `CriteriaEntry` before `subscriptionId` was present.")}async getTokenForCriteria(t){let n=t?.subscriptionId;n||(n=(await this.medplum.createResource({...t.subscriptionProps,resourceType:"Subscription",status:"active",reason:`WebSocket subscription for ${_t(this.medplum.getProfile())}`,channel:{type:"websocket"},criteria:t.criteria})).id);const{parameter:r}=await this.medplum.get(`fhir/R4/Subscription/${n}/$get-ws-binding-token`),o=r?.find(c=>c.name==="token")?.valueString,l=r?.find(c=>c.name==="websocket-url")?.valueUrl;if(!o)throw new ft(gn("Failed to get token"));if(!l)throw new ft(gn("Failed to get URL from $get-ws-binding-token"));return[n,o]}maybeGetCriteriaEntry(t,n){const r=this.criteriaEntries.get(t);if(r){if(!n)return r.bareCriteria;for(const o of r.criteriaWithProps)if(Co(n,o.subscriptionProps))return o}}getAllCriteriaEmitters(){const t=[];for(const n of this.criteriaEntries.values()){n.bareCriteria&&t.push(n.bareCriteria.emitter);for(const r of n.criteriaWithProps)t.push(r.emitter)}return t}addCriteriaEntry(t){const{criteria:n,subscriptionProps:r}=t;let o;this.criteriaEntries.has(n)?o=this.criteriaEntries.get(n):(o={criteriaWithProps:[]},this.criteriaEntries.set(n,o)),r?o.criteriaWithProps.push(t):o.bareCriteria=t}removeCriteriaEntry(t){const{criteria:n,subscriptionProps:r,subscriptionId:o,token:l}=t;if(!this.criteriaEntries.has(n))return;const c=this.criteriaEntries.get(n);r?c.criteriaWithProps=c.criteriaWithProps.filter(d=>{const f=d.subscriptionProps;return!Co(r,f)}):c.bareCriteria=void 0,!c.bareCriteria&&c.criteriaWithProps.length===0&&(this.criteriaEntries.delete(n),this.masterSubEmitter?._removeCriteria(n)),o&&this.criteriaEntriesBySubscriptionId.delete(o),l&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"unbind-from-token",payload:{token:l}}))}async subscribeToCriteria(t){if(!(this.ws.readyState!==WebSocket.OPEN||t.connecting)){t.connecting=!0;try{const[n,r]=await this.getTokenForCriteria(t);t.subscriptionId=n,t.token=r,this.criteriaEntriesBySubscriptionId.set(n,t),this.ws.send(JSON.stringify({type:"bind-with-token",payload:{token:r}}))}catch(n){console.error(Ye(n)),this.emitError(t,n),this.removeCriteriaEntry(t)}}}async refreshAllSubscriptions(){this.criteriaEntriesBySubscriptionId.clear();for(const t of this.criteriaEntries.values())for(const n of[...t.bareCriteria?[t.bareCriteria]:[],...t.criteriaWithProps])n.clearAttachedSubscription(),await this.subscribeToCriteria(n)}addCriteria(t,n){this.masterSubEmitter&&this.masterSubEmitter._addCriteria(t);const r=this.maybeGetCriteriaEntry(t,n);if(r)return r.refCount+=1,r.emitter;const o=new UV(t,n);return this.addCriteriaEntry(o),this.subscribeToCriteria(o).catch(console.error),o.emitter}removeCriteria(t,n){const r=this.maybeGetCriteriaEntry(t,n);if(!r){console.warn("Criteria not known to `SubscriptionManager`. Possibly called remove too many times.");return}r.refCount-=1,!(r.refCount>0)&&(this.maybeEmitDisconnect(r),this.removeCriteriaEntry(r))}getWebSocket(){return this.ws}closeWebSocket(){this.wsClosed||(this.wsClosed=!0,this.ws.close())}reconnectWebSocket(){this.ws.reconnect(),this.wsClosed=!1}getCriteriaCount(){return this.getAllCriteriaEmitters().length}getMasterEmitter(){return this.masterSubEmitter||(this.masterSubEmitter=new ux(...Array.from(this.criteriaEntries.keys()))),this.masterSubEmitter}}const xA="4.5.1-199a27ba6",VV=ln.FHIR_JSON+", */*; q=0.1",FV="https://api.medplum.com/",HV=1e3,qV=6e4,GV=0,QV=3e5,WV="Binary/",JE={resourceType:"Device",id:"system",deviceName:[{type:"model-name",name:"System"}]},vc={ClientCredentials:"client_credentials",AuthorizationCode:"authorization_code",RefreshToken:"refresh_token",JwtBearer:"urn:ietf:params:oauth:grant-type:jwt-bearer",TokenExchange:"urn:ietf:params:oauth:grant-type:token-exchange"},YV={AccessToken:"urn:ietf:params:oauth:token-type:access_token"},KV={JwtBearer:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"};class bA extends vm{constructor(t){if(super(),this.initComplete=!0,t?.baseUrl&&!t.baseUrl.startsWith("http"))throw new Error("Base URL must start with http or https");this.options=t??{},this.fetch=t?.fetch??XV(),this.storage=t?.storage??new MV,this.createPdfImpl=t?.createPdf,this.baseUrl=wb(t?.baseUrl??FV),this.fhirBaseUrl=fo(this.baseUrl,t?.fhirUrlPath??"fhir/R4"),this.authorizeUrl=fo(this.baseUrl,t?.authorizeUrl??"oauth2/authorize"),this.tokenUrl=fo(this.baseUrl,t?.tokenUrl??"oauth2/token"),this.logoutUrl=fo(this.baseUrl,t?.logoutUrl??"oauth2/logout"),this.fhircastHubUrl=fo(this.baseUrl,t?.fhircastHubUrl??"fhircast/STU3"),this.clientId=t?.clientId??"",this.clientSecret=t?.clientSecret??"",this.credentialsInHeader=t?.authCredentialsMethod==="header",this.defaultHeaders=t?.defaultHeaders??{},this.onUnauthenticated=t?.onUnauthenticated,this.refreshGracePeriod=t?.refreshGracePeriod??QV,this.cacheTime=t?.cacheTime??(po()?qV:GV),this.cacheTime>0?this.requestCache=new AD(t?.resourceCacheSize??HV):this.requestCache=void 0,t?.autoBatchTime?(this.autoBatchTime=t.autoBatchTime,this.autoBatchQueue=[]):(this.autoBatchTime=0,this.autoBatchQueue=void 0),t?.accessToken&&this.setAccessToken(t.accessToken),this.storage.getInitPromise===void 0?(t?.accessToken||this.attemptResumeActiveLogin().catch(console.error),this.initPromise=Promise.resolve(),this.dispatchEvent({type:"storageInitialized"})):(this.initComplete=!1,this.initPromise=this.storage.getInitPromise(),this.initPromise.then(()=>{t?.accessToken||this.attemptResumeActiveLogin().catch(console.error),this.initComplete=!0,this.dispatchEvent({type:"storageInitialized"})}).catch(n=>{console.error(n),this.initComplete=!0,this.dispatchEvent({type:"storageInitFailed",payload:{error:n}})})),this.setupStorageListener()}get isInitialized(){return this.initComplete}getInitPromise(){return this.initPromise}async attemptResumeActiveLogin(){const t=this.getActiveLogin();t&&(this.setAccessToken(t.accessToken,t.refreshToken),await this.refreshProfile())}getBaseUrl(){return this.baseUrl}getAuthorizeUrl(){return this.authorizeUrl}getTokenUrl(){return this.tokenUrl}getLogoutUrl(){return this.logoutUrl}getFhircastHubUrl(){return this.fhircastHubUrl}getDefaultHeaders(){return this.defaultHeaders}clear(){this.storage.clear(),po()&&sessionStorage.clear(),this.clearActiveLogin()}clearActiveLogin(){this.storage.setString("activeLogin",void 0),this.requestCache?.clear(),this.accessToken=void 0,this.refreshToken=void 0,this.refreshPromise=void 0,this.accessTokenExpires=void 0,this.sessionDetails=void 0,this.medplumServer=void 0,this.dispatchEvent({type:"change"})}invalidateUrl(t){t=t.toString(),this.requestCache?.delete(t)}invalidateAll(){this.requestCache?.clear()}invalidateSearches(t){const n=fo(this.fhirBaseUrl,t);if(this.requestCache)for(const r of this.requestCache.keys())(r.endsWith(n)||r.includes(n+"?"))&&this.requestCache.delete(r)}get(t,n={}){t=t.toString();const r=this.getCacheEntry(t,n);if(r)return r.value;let o;t.startsWith(this.fhirBaseUrl)&&this.autoBatchQueue&&!n.disableAutoBatch?o=new Promise((c,d)=>{this.autoBatchQueue.push({method:"GET",url:t.replace(this.fhirBaseUrl,""),options:n,resolve:c,reject:d}),this.autoBatchTimerId||(this.autoBatchTimerId=setTimeout(()=>this.executeAutoBatch(),this.autoBatchTime))}):o=this.request("GET",t,n);const l=new Fi(o);return this.setCacheEntry(t,l),l}post(t,n,r,o={}){return t=t.toString(),this.setRequestBody(o,n),r&&this.setRequestContentType(o,r),this.invalidateUrl(t),this.request("POST",t,o)}put(t,n,r,o={}){return t=t.toString(),this.setRequestBody(o,n),r&&this.setRequestContentType(o,r),this.invalidateUrl(t),this.request("PUT",t,o)}patch(t,n,r={}){return t=t.toString(),this.setRequestBody(r,n),this.setRequestContentType(r,ln.JSON_PATCH),this.invalidateUrl(t),this.request("PATCH",t,r)}delete(t,n){return t=t.toString(),this.invalidateUrl(t),this.request("DELETE",t,n)}async startNewUser(t,n){const{codeChallengeMethod:r,codeChallenge:o}=await this.startPkce();return this.post("auth/newuser",{...t,clientId:t.clientId??this.clientId,codeChallengeMethod:r,codeChallenge:o},void 0,n)}async startNewProject(t,n){return this.post("auth/newproject",t,void 0,n)}async startNewPatient(t,n){return this.post("auth/newpatient",t,void 0,n)}async startLogin(t,n){return this.post("auth/login",{...await this.ensureCodeChallenge(t),clientId:t.clientId??this.clientId,scope:t.scope},void 0,n)}async startGoogleLogin(t,n){return this.post("auth/google",{...await this.ensureCodeChallenge(t),clientId:t.clientId??this.clientId,scope:t.scope},void 0,n)}async ensureCodeChallenge(t){return t.codeChallenge?t:{...t,...await this.startPkce()}}async signOut(){await this.post(this.logoutUrl,{}),this.clear()}async signInWithRedirect(t){const r=new URLSearchParams(Xn.getSearch()).get("code");if(!r){await this.requestAuthorization(t);return}return this.processCode(r)}signOutWithRedirect(){Xn.assign(this.logoutUrl)}async signInWithExternalAuth(t,n,r,o,l=!0){let c=o;l&&(c=await this.ensureCodeChallenge(o)),Xn.assign(this.getExternalAuthRedirectUri(t,n,r,c,l))}async exchangeExternalAccessToken(t,n){if(n=n??this.clientId,!n)throw new Error("MedplumClient is missing clientId");return this.fetchTokens({grant_type:vc.TokenExchange,subject_token_type:YV.AccessToken,client_id:n,subject_token:t})}getExternalAuthRedirectUri(t,n,r,o,l=!0){const c=new URL(t);if(c.searchParams.set("response_type","code"),c.searchParams.set("client_id",n),c.searchParams.set("redirect_uri",r),c.searchParams.set("scope",o.scope??"openid profile email"),c.searchParams.set("state",JSON.stringify(o)),l){const{codeChallenge:d,codeChallengeMethod:f}=o;if(!f)throw new Error("`LoginRequest` for external auth must include a `codeChallengeMethod`.");if(!d)throw new Error("`LoginRequest` for external auth must include a `codeChallenge`.");c.searchParams.set("code_challenge_method",f),c.searchParams.set("code_challenge",d)}return c.toString()}fhirUrl(...t){return new URL(fo(this.fhirBaseUrl,t.join("/")))}fhirSearchUrl(t,n){const r=this.fhirUrl(t);return n&&(r.search=VU(n)),r}search(t,n,r){const o=this.fhirSearchUrl(t,n),l="search-"+o.toString(),c=this.getCacheEntry(l,r);if(c)return c.value;const d=this.getBundle(o,r);return this.setCacheEntry(l,d),d}searchOne(t,n,r){const o=this.fhirSearchUrl(t,n);o.searchParams.set("_count","1"),o.searchParams.sort();const l="searchOne-"+o.toString(),c=this.getCacheEntry(l,r);if(c)return c.value;const d=new Fi(this.search(t,o.searchParams,r).then(f=>f.entry?.[0]?.resource));return this.setCacheEntry(l,d),d}searchResources(t,n,r){const l="searchResources-"+this.fhirSearchUrl(t,n).toString(),c=this.getCacheEntry(l,r);if(c)return c.value;const d=new Fi(this.search(t,n,r).then(tT));return this.setCacheEntry(l,d),d}async*searchResourcePages(t,n,r){let o=this.fhirSearchUrl(t,n);for(;o;){const l=new URL(o).searchParams;l.has("_count")||l.set("_count","1000");const c=await this.search(t,l,r),d=c.link?.find(f=>f.relation==="next");if(!c.entry?.length&&!d)break;yield tT(c),o=d?.url?new URL(d.url):void 0}}valueSetExpand(t,n){const r=this.fhirUrl("ValueSet","$expand");return r.search=new URLSearchParams(t).toString(),this.get(r.toString(),n)}getCached(t,n){const r=this.requestCache?.get(this.fhirUrl(t,n).toString())?.value;return r?.isOk()?r.read():void 0}getCachedReference(t){const n=t.reference;if(!n)return;if(n==="system")return JE;const[r,o]=n.split("/");if(!(!r||!o))return this.getCached(r,o)}readResource(t,n,r){if(!n)throw new Error('The "id" parameter cannot be null, undefined, or an empty string.');return this.get(this.fhirUrl(t,n),r)}readReference(t,n){const r=t.reference;if(!r)return new Fi(Promise.reject(new Error("Missing reference")));if(r==="system")return new Fi(Promise.resolve(JE));const[o,l]=r.split("/");return!o||!l?new Fi(Promise.reject(new Error("Invalid reference"))):this.readResource(o,l,n)}requestSchema(t){if(ID(t))return Promise.resolve();const n=t+"-requestSchema",r=this.getCacheEntry(n,void 0);if(r)return r.value;const o=new Fi((async()=>{const l=`{
|
|
87
|
+
*/const Ec={Event:typeof globalThis.Event<"u"?globalThis.Event:void 0,ErrorEvent:void 0,CloseEvent:void 0};let XE=!1;function IV(){if(typeof globalThis.Event>"u")throw new Error("Unable to lazy init events for ReconnectingWebSocket. globalThis.Event is not defined yet");Ec.Event=globalThis.Event,Ec.ErrorEvent=class extends Event{constructor(t,n){super("error",n),this.message=t.message,this.error=t}},Ec.CloseEvent=class extends Event{constructor(t=1e3,n="",r){super("close",r),this.wasClean=!0,this.code=t,this.reason=n}}}function zV(e,t){if(!e)throw new Error(t)}function Sh(e){return new e.constructor(e.type,e)}const $s={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0};let ZE=!1;class Za extends vm{constructor(t,n,r={}){XE||(IV(),XE=!0),super(),this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._closeCalled=!1,this._messageQueue=[],this._debugLogger=console.log.bind(console),this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=o=>{this._debug("open event");const{minUptime:l=$s.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),l),zV(this._ws,"WebSocket is not defined"),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(c=>this._ws?.send(c)),this._messageQueue=[],this.onopen&&this.onopen(o),this.dispatchEvent(Sh(o))},this._handleMessage=o=>{this._debug("message event"),this.onmessage&&this.onmessage(o),this.dispatchEvent(Sh(o))},this._handleError=o=>{this._debug("error event",o.message),this._disconnect(void 0,o.message==="TIMEOUT"?"timeout":void 0),this.onerror&&this.onerror(o),this._debug("exec error listeners"),this.dispatchEvent(Sh(o)),this._connect()},this._handleClose=o=>{this._debug("close event"),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(o),this.dispatchEvent(Sh(o))},this._url=t,this._protocols=n,this._options=r,this._options.startClosed&&(this._shouldReconnect=!1),this._options.binaryType?this._binaryType=this._options.binaryType:this._binaryType="blob",this._options.debugLogger&&(this._debugLogger=this._options.debugLogger),this._connect()}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}get CONNECTING(){return Za.CONNECTING}get OPEN(){return Za.OPEN}get CLOSING(){return Za.CLOSING}get CLOSED(){return Za.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(t){this._binaryType=t,this._ws&&(this._ws.binaryType=t)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((n,r)=>(typeof r=="string"?n+=r.length:r instanceof Blob?n+=r.size:n+=r.byteLength,n),0)+(this._ws?.bufferedAmount??0)}get extensions(){return this._ws?.extensions??""}get protocol(){return this._ws?.protocol??""}get readyState(){return this._ws?this._ws.readyState:this._options.startClosed?Za.CLOSED:Za.CONNECTING}get url(){return this._ws?this._ws.url:""}get shouldReconnect(){return this._shouldReconnect}close(t=1e3,n){if(this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(t,n)}reconnect(t,n){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,n),this._connect())}send(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{const{maxEnqueuedMessages:n=$s.maxEnqueuedMessages}=this._options;this._messageQueue.length<n&&(this._debug("enqueue",t),this._messageQueue.push(t))}}_debug(...t){this._options.debug&&this._debugLogger("RWS>",...t)}_getNextDelay(){const{reconnectionDelayGrowFactor:t=$s.reconnectionDelayGrowFactor,minReconnectionDelay:n=$s.minReconnectionDelay,maxReconnectionDelay:r=$s.maxReconnectionDelay}=this._options;let o=0;return this._retryCount>0&&(o=n*Math.pow(t,this._retryCount-1),o>r&&(o=r)),this._debug("next delay",o),o}_wait(){return new Promise(t=>{setTimeout(t,this._getNextDelay())})}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;const{maxRetries:t=$s.maxRetries,connectionTimeout:n=$s.connectionTimeout}=this._options;if(this._retryCount>=t){this._debug("max retries reached",this._retryCount,">=",t);return}this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),this._wait().then(()=>{if(this._closeCalled){this._connectLock=!1;return}!this._options.WebSocket&&typeof WebSocket>"u"&&!ZE&&(console.error("‼️ No WebSocket implementation available. You should define options.WebSocket."),ZE=!0);const r=this._options.WebSocket||WebSocket;this._debug("connect",{url:this._url,protocols:this._protocols}),this._ws=this._protocols?new r(this._url,this._protocols):new r(this._url),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),n)}).catch(r=>{this._connectLock=!1,this._handleError(new Ec.ErrorEvent(Error(r.message),this))})}_handleTimeout(){this._debug("timeout event"),this._handleError(new Ec.ErrorEvent(Error("TIMEOUT"),this))}_disconnect(t=1e3,n){if(this._clearTimeouts(),!!this._ws){this._removeListeners();try{this._ws.close(t,n),this._handleClose(new Ec.CloseEvent(t,n,this))}catch{}}}_acceptOpen(){this._debug("accept open"),this._retryCount=0}_removeListeners(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))}_addListeners(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}}const $V=5e3;class ux extends vm{constructor(...t){super(),this.criteria=new Set(t)}getCriteria(){return this.criteria}_addCriteria(t){this.criteria.add(t)}_removeCriteria(t){this.criteria.delete(t)}}class UV{constructor(t,n){this.connecting=!1,this.criteria=t,this.emitter=new ux(t),this.refCount=1,this.subscriptionProps=n?{...n}:void 0}clearAttachedSubscription(){this.subscriptionId=void 0,this.token=void 0}}class BV{constructor(t,n,r){if(this.pingTimer=void 0,this.waitingForPong=!1,!(t instanceof bA))throw new ft(gn("First arg of constructor should be a `MedplumClient`"));let o;try{o=new URL(n).toString()}catch{throw new ft(gn("Not a valid URL"))}const l=r?.ReconnectingWebSocket?new r.ReconnectingWebSocket(o,void 0,{debug:r?.debug,debugLogger:r?.debugLogger}):new Za(o,void 0,{debug:r?.debug,debugLogger:r?.debugLogger});this.medplum=t,this.ws=l,this.masterSubEmitter=new ux,this.criteriaEntries=new Map,this.criteriaEntriesBySubscriptionId=new Map,this.wsClosed=!1,this.pingIntervalMs=r?.pingIntervalMs??$V,this.currentProfile=t.getProfile(),this.setupListeners()}setupListeners(){const t=this.ws;t.addEventListener("message",n=>{try{const r=JSON.parse(n.data);if(r.type==="pong"){this.waitingForPong=!1;return}const o=r,l=o?.entry?.[0]?.resource;if(l.type==="heartbeat"){this.masterSubEmitter?.dispatchEvent({type:"heartbeat",payload:o});return}if(l.type==="handshake"){const d=rl(l.subscription),f={type:"connect",payload:{subscriptionId:d}};this.masterSubEmitter?.dispatchEvent(f);const p=this.criteriaEntriesBySubscriptionId.get(d);if(!p){console.warn("Received handshake for criteria the SubscriptionManager is not listening for yet");return}p.connecting=!1,p.emitter.dispatchEvent({...f});return}this.masterSubEmitter?.dispatchEvent({type:"message",payload:o});const c=this.criteriaEntriesBySubscriptionId.get(rl(l.subscription));if(!c){console.warn("Received notification for criteria the SubscriptionManager is not listening for");return}c.emitter.dispatchEvent({type:"message",payload:o})}catch(r){console.error(r);const o={type:"error",payload:r};this.masterSubEmitter?.dispatchEvent(o);for(const l of this.getAllCriteriaEmitters())l.dispatchEvent({...o})}}),t.addEventListener("error",()=>{const n={type:"error",payload:new ft(K$(new Error("WebSocket error")))};this.masterSubEmitter?.dispatchEvent(n);for(const r of this.getAllCriteriaEmitters())r.dispatchEvent({...n})}),t.addEventListener("close",()=>{const n={type:"close"};this.masterSubEmitter?.dispatchEvent(n);for(const r of this.getAllCriteriaEmitters())r.dispatchEvent({...n});this.pingTimer&&(clearInterval(this.pingTimer),this.pingTimer=void 0,this.waitingForPong=!1),this.wsClosed&&(this.criteriaEntries.clear(),this.criteriaEntriesBySubscriptionId.clear(),this.masterSubEmitter?.removeAllListeners())}),t.addEventListener("open",()=>{const n={type:"open"};this.masterSubEmitter?.dispatchEvent(n);for(const r of this.getAllCriteriaEmitters())r.dispatchEvent({...n});this.refreshAllSubscriptions().catch(console.error),this.pingTimer||(this.pingTimer=setInterval(()=>{if(this.waitingForPong){this.waitingForPong=!1,t.reconnect();return}t.send(JSON.stringify({type:"ping"})),this.waitingForPong=!0},this.pingIntervalMs))}),this.medplum.addEventListener("change",()=>{const n=this.medplum.getProfile();this.currentProfile&&n===void 0?this.ws.close():n&&this.currentProfile?.id!==n.id&&this.ws.reconnect(),this.currentProfile=n})}emitError(t,n){const r={type:"error",payload:n};this.masterSubEmitter?.dispatchEvent(r),t.emitter.dispatchEvent({...r})}maybeEmitDisconnect(t){const{subscriptionId:n}=t;if(n){const r={type:"disconnect",payload:{subscriptionId:n}};this.masterSubEmitter?.dispatchEvent(r),t.emitter.dispatchEvent({...r})}else console.warn("Called disconnect for `CriteriaEntry` before `subscriptionId` was present.")}async getTokenForCriteria(t){let n=t?.subscriptionId;n||(n=(await this.medplum.createResource({...t.subscriptionProps,resourceType:"Subscription",status:"active",reason:`WebSocket subscription for ${_t(this.medplum.getProfile())}`,channel:{type:"websocket"},criteria:t.criteria})).id);const{parameter:r}=await this.medplum.get(`fhir/R4/Subscription/${n}/$get-ws-binding-token`),o=r?.find(c=>c.name==="token")?.valueString,l=r?.find(c=>c.name==="websocket-url")?.valueUrl;if(!o)throw new ft(gn("Failed to get token"));if(!l)throw new ft(gn("Failed to get URL from $get-ws-binding-token"));return[n,o]}maybeGetCriteriaEntry(t,n){const r=this.criteriaEntries.get(t);if(r){if(!n)return r.bareCriteria;for(const o of r.criteriaWithProps)if(Co(n,o.subscriptionProps))return o}}getAllCriteriaEmitters(){const t=[];for(const n of this.criteriaEntries.values()){n.bareCriteria&&t.push(n.bareCriteria.emitter);for(const r of n.criteriaWithProps)t.push(r.emitter)}return t}addCriteriaEntry(t){const{criteria:n,subscriptionProps:r}=t;let o;this.criteriaEntries.has(n)?o=this.criteriaEntries.get(n):(o={criteriaWithProps:[]},this.criteriaEntries.set(n,o)),r?o.criteriaWithProps.push(t):o.bareCriteria=t}removeCriteriaEntry(t){const{criteria:n,subscriptionProps:r,subscriptionId:o,token:l}=t;if(!this.criteriaEntries.has(n))return;const c=this.criteriaEntries.get(n);r?c.criteriaWithProps=c.criteriaWithProps.filter(d=>{const f=d.subscriptionProps;return!Co(r,f)}):c.bareCriteria=void 0,!c.bareCriteria&&c.criteriaWithProps.length===0&&(this.criteriaEntries.delete(n),this.masterSubEmitter?._removeCriteria(n)),o&&this.criteriaEntriesBySubscriptionId.delete(o),l&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"unbind-from-token",payload:{token:l}}))}async subscribeToCriteria(t){if(!(this.ws.readyState!==WebSocket.OPEN||t.connecting)){t.connecting=!0;try{const[n,r]=await this.getTokenForCriteria(t);t.subscriptionId=n,t.token=r,this.criteriaEntriesBySubscriptionId.set(n,t),this.ws.send(JSON.stringify({type:"bind-with-token",payload:{token:r}}))}catch(n){console.error(Ye(n)),this.emitError(t,n),this.removeCriteriaEntry(t)}}}async refreshAllSubscriptions(){this.criteriaEntriesBySubscriptionId.clear();for(const t of this.criteriaEntries.values())for(const n of[...t.bareCriteria?[t.bareCriteria]:[],...t.criteriaWithProps])n.clearAttachedSubscription(),await this.subscribeToCriteria(n)}addCriteria(t,n){this.masterSubEmitter&&this.masterSubEmitter._addCriteria(t);const r=this.maybeGetCriteriaEntry(t,n);if(r)return r.refCount+=1,r.emitter;const o=new UV(t,n);return this.addCriteriaEntry(o),this.subscribeToCriteria(o).catch(console.error),o.emitter}removeCriteria(t,n){const r=this.maybeGetCriteriaEntry(t,n);if(!r){console.warn("Criteria not known to `SubscriptionManager`. Possibly called remove too many times.");return}r.refCount-=1,!(r.refCount>0)&&(this.maybeEmitDisconnect(r),this.removeCriteriaEntry(r))}getWebSocket(){return this.ws}closeWebSocket(){this.wsClosed||(this.wsClosed=!0,this.ws.close())}reconnectWebSocket(){this.ws.reconnect(),this.wsClosed=!1}getCriteriaCount(){return this.getAllCriteriaEmitters().length}getMasterEmitter(){return this.masterSubEmitter||(this.masterSubEmitter=new ux(...Array.from(this.criteriaEntries.keys()))),this.masterSubEmitter}}const xA="4.5.2-515c26d74",VV=ln.FHIR_JSON+", */*; q=0.1",FV="https://api.medplum.com/",HV=1e3,qV=6e4,GV=0,QV=3e5,WV="Binary/",JE={resourceType:"Device",id:"system",deviceName:[{type:"model-name",name:"System"}]},vc={ClientCredentials:"client_credentials",AuthorizationCode:"authorization_code",RefreshToken:"refresh_token",JwtBearer:"urn:ietf:params:oauth:grant-type:jwt-bearer",TokenExchange:"urn:ietf:params:oauth:grant-type:token-exchange"},YV={AccessToken:"urn:ietf:params:oauth:token-type:access_token"},KV={JwtBearer:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"};class bA extends vm{constructor(t){if(super(),this.initComplete=!0,t?.baseUrl&&!t.baseUrl.startsWith("http"))throw new Error("Base URL must start with http or https");this.options=t??{},this.fetch=t?.fetch??XV(),this.storage=t?.storage??new MV,this.createPdfImpl=t?.createPdf,this.baseUrl=wb(t?.baseUrl??FV),this.fhirBaseUrl=fo(this.baseUrl,t?.fhirUrlPath??"fhir/R4"),this.authorizeUrl=fo(this.baseUrl,t?.authorizeUrl??"oauth2/authorize"),this.tokenUrl=fo(this.baseUrl,t?.tokenUrl??"oauth2/token"),this.logoutUrl=fo(this.baseUrl,t?.logoutUrl??"oauth2/logout"),this.fhircastHubUrl=fo(this.baseUrl,t?.fhircastHubUrl??"fhircast/STU3"),this.clientId=t?.clientId??"",this.clientSecret=t?.clientSecret??"",this.credentialsInHeader=t?.authCredentialsMethod==="header",this.defaultHeaders=t?.defaultHeaders??{},this.onUnauthenticated=t?.onUnauthenticated,this.refreshGracePeriod=t?.refreshGracePeriod??QV,this.cacheTime=t?.cacheTime??(po()?qV:GV),this.cacheTime>0?this.requestCache=new AD(t?.resourceCacheSize??HV):this.requestCache=void 0,t?.autoBatchTime?(this.autoBatchTime=t.autoBatchTime,this.autoBatchQueue=[]):(this.autoBatchTime=0,this.autoBatchQueue=void 0),t?.accessToken&&this.setAccessToken(t.accessToken),this.storage.getInitPromise===void 0?(t?.accessToken||this.attemptResumeActiveLogin().catch(console.error),this.initPromise=Promise.resolve(),this.dispatchEvent({type:"storageInitialized"})):(this.initComplete=!1,this.initPromise=this.storage.getInitPromise(),this.initPromise.then(()=>{t?.accessToken||this.attemptResumeActiveLogin().catch(console.error),this.initComplete=!0,this.dispatchEvent({type:"storageInitialized"})}).catch(n=>{console.error(n),this.initComplete=!0,this.dispatchEvent({type:"storageInitFailed",payload:{error:n}})})),this.setupStorageListener()}get isInitialized(){return this.initComplete}getInitPromise(){return this.initPromise}async attemptResumeActiveLogin(){const t=this.getActiveLogin();t&&(this.setAccessToken(t.accessToken,t.refreshToken),await this.refreshProfile())}getBaseUrl(){return this.baseUrl}getAuthorizeUrl(){return this.authorizeUrl}getTokenUrl(){return this.tokenUrl}getLogoutUrl(){return this.logoutUrl}getFhircastHubUrl(){return this.fhircastHubUrl}getDefaultHeaders(){return this.defaultHeaders}clear(){this.storage.clear(),po()&&sessionStorage.clear(),this.clearActiveLogin()}clearActiveLogin(){this.storage.setString("activeLogin",void 0),this.requestCache?.clear(),this.accessToken=void 0,this.refreshToken=void 0,this.refreshPromise=void 0,this.accessTokenExpires=void 0,this.sessionDetails=void 0,this.medplumServer=void 0,this.dispatchEvent({type:"change"})}invalidateUrl(t){t=t.toString(),this.requestCache?.delete(t)}invalidateAll(){this.requestCache?.clear()}invalidateSearches(t){const n=fo(this.fhirBaseUrl,t);if(this.requestCache)for(const r of this.requestCache.keys())(r.endsWith(n)||r.includes(n+"?"))&&this.requestCache.delete(r)}get(t,n={}){t=t.toString();const r=this.getCacheEntry(t,n);if(r)return r.value;let o;t.startsWith(this.fhirBaseUrl)&&this.autoBatchQueue&&!n.disableAutoBatch?o=new Promise((c,d)=>{this.autoBatchQueue.push({method:"GET",url:t.replace(this.fhirBaseUrl,""),options:n,resolve:c,reject:d}),this.autoBatchTimerId||(this.autoBatchTimerId=setTimeout(()=>this.executeAutoBatch(),this.autoBatchTime))}):o=this.request("GET",t,n);const l=new Fi(o);return this.setCacheEntry(t,l),l}post(t,n,r,o={}){return t=t.toString(),this.setRequestBody(o,n),r&&this.setRequestContentType(o,r),this.invalidateUrl(t),this.request("POST",t,o)}put(t,n,r,o={}){return t=t.toString(),this.setRequestBody(o,n),r&&this.setRequestContentType(o,r),this.invalidateUrl(t),this.request("PUT",t,o)}patch(t,n,r={}){return t=t.toString(),this.setRequestBody(r,n),this.setRequestContentType(r,ln.JSON_PATCH),this.invalidateUrl(t),this.request("PATCH",t,r)}delete(t,n){return t=t.toString(),this.invalidateUrl(t),this.request("DELETE",t,n)}async startNewUser(t,n){const{codeChallengeMethod:r,codeChallenge:o}=await this.startPkce();return this.post("auth/newuser",{...t,clientId:t.clientId??this.clientId,codeChallengeMethod:r,codeChallenge:o},void 0,n)}async startNewProject(t,n){return this.post("auth/newproject",t,void 0,n)}async startNewPatient(t,n){return this.post("auth/newpatient",t,void 0,n)}async startLogin(t,n){return this.post("auth/login",{...await this.ensureCodeChallenge(t),clientId:t.clientId??this.clientId,scope:t.scope},void 0,n)}async startGoogleLogin(t,n){return this.post("auth/google",{...await this.ensureCodeChallenge(t),clientId:t.clientId??this.clientId,scope:t.scope},void 0,n)}async ensureCodeChallenge(t){return t.codeChallenge?t:{...t,...await this.startPkce()}}async signOut(){await this.post(this.logoutUrl,{}),this.clear()}async signInWithRedirect(t){const r=new URLSearchParams(Xn.getSearch()).get("code");if(!r){await this.requestAuthorization(t);return}return this.processCode(r)}signOutWithRedirect(){Xn.assign(this.logoutUrl)}async signInWithExternalAuth(t,n,r,o,l=!0){let c=o;l&&(c=await this.ensureCodeChallenge(o)),Xn.assign(this.getExternalAuthRedirectUri(t,n,r,c,l))}async exchangeExternalAccessToken(t,n){if(n=n??this.clientId,!n)throw new Error("MedplumClient is missing clientId");return this.fetchTokens({grant_type:vc.TokenExchange,subject_token_type:YV.AccessToken,client_id:n,subject_token:t})}getExternalAuthRedirectUri(t,n,r,o,l=!0){const c=new URL(t);if(c.searchParams.set("response_type","code"),c.searchParams.set("client_id",n),c.searchParams.set("redirect_uri",r),c.searchParams.set("scope",o.scope??"openid profile email"),c.searchParams.set("state",JSON.stringify(o)),l){const{codeChallenge:d,codeChallengeMethod:f}=o;if(!f)throw new Error("`LoginRequest` for external auth must include a `codeChallengeMethod`.");if(!d)throw new Error("`LoginRequest` for external auth must include a `codeChallenge`.");c.searchParams.set("code_challenge_method",f),c.searchParams.set("code_challenge",d)}return c.toString()}fhirUrl(...t){return new URL(fo(this.fhirBaseUrl,t.join("/")))}fhirSearchUrl(t,n){const r=this.fhirUrl(t);return n&&(r.search=VU(n)),r}search(t,n,r){const o=this.fhirSearchUrl(t,n),l="search-"+o.toString(),c=this.getCacheEntry(l,r);if(c)return c.value;const d=this.getBundle(o,r);return this.setCacheEntry(l,d),d}searchOne(t,n,r){const o=this.fhirSearchUrl(t,n);o.searchParams.set("_count","1"),o.searchParams.sort();const l="searchOne-"+o.toString(),c=this.getCacheEntry(l,r);if(c)return c.value;const d=new Fi(this.search(t,o.searchParams,r).then(f=>f.entry?.[0]?.resource));return this.setCacheEntry(l,d),d}searchResources(t,n,r){const l="searchResources-"+this.fhirSearchUrl(t,n).toString(),c=this.getCacheEntry(l,r);if(c)return c.value;const d=new Fi(this.search(t,n,r).then(tT));return this.setCacheEntry(l,d),d}async*searchResourcePages(t,n,r){let o=this.fhirSearchUrl(t,n);for(;o;){const l=new URL(o).searchParams;l.has("_count")||l.set("_count","1000");const c=await this.search(t,l,r),d=c.link?.find(f=>f.relation==="next");if(!c.entry?.length&&!d)break;yield tT(c),o=d?.url?new URL(d.url):void 0}}valueSetExpand(t,n){const r=this.fhirUrl("ValueSet","$expand");return r.search=new URLSearchParams(t).toString(),this.get(r.toString(),n)}getCached(t,n){const r=this.requestCache?.get(this.fhirUrl(t,n).toString())?.value;return r?.isOk()?r.read():void 0}getCachedReference(t){const n=t.reference;if(!n)return;if(n==="system")return JE;const[r,o]=n.split("/");if(!(!r||!o))return this.getCached(r,o)}readResource(t,n,r){if(!n)throw new Error('The "id" parameter cannot be null, undefined, or an empty string.');return this.get(this.fhirUrl(t,n),r)}readReference(t,n){const r=t.reference;if(!r)return new Fi(Promise.reject(new Error("Missing reference")));if(r==="system")return new Fi(Promise.resolve(JE));const[o,l]=r.split("/");return!o||!l?new Fi(Promise.reject(new Error("Invalid reference"))):this.readResource(o,l,n)}requestSchema(t){if(ID(t))return Promise.resolve();const n=t+"-requestSchema",r=this.getCacheEntry(n,void 0);if(r)return r.value;const o=new Fi((async()=>{const l=`{
|
|
88
88
|
StructureDefinitionList(_filter: "name eq ${t}") {
|
|
89
89
|
resourceType,
|
|
90
90
|
name,
|
|
@@ -549,7 +549,7 @@ function F3(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&
|
|
|
549
549
|
name,
|
|
550
550
|
title,
|
|
551
551
|
}
|
|
552
|
-
}`.replace(/\s+/g," ");return(await e.graphql(r)).data.StructureDefinitionList[0]}function yW(e){return e.type==="profile"&&!e?.error&&vn(e.resourceType)}function xW(e,t,n){return t===void 0?e:n===void 0?t:`${t}[${n}]`}const bW="_indented_ldk1d_1",fP={indented:bW};function Xb({propertyDisplayName:e,onClick:t,testId:n}){const r=e?`Add ${e}`:"Add";return e?a.jsx(ke,{title:r,size:"sm",color:"green.6",variant:"subtle","data-testid":n,leftSection:a.jsx(cp,{size:"1.25rem"}),onClick:t,children:r}):a.jsx(bn,{title:r,color:"green.6","data-testid":n,onClick:t,children:a.jsx(cp,{size:"1.25rem"})})}function hP({propertyDisplayName:e,onClick:t,testId:n}){return a.jsx(bn,{title:e?`Remove ${e}`:"Remove",color:"red.5","data-testid":n,variant:"subtle",onClick:t,children:a.jsx(lp,{size:"1.25rem"})})}function SW(e){const{slice:t,property:n}=e,[r,o]=v.useState(e.defaultValue),l=t.typeSchema?.elements??t.elements,c=v.useContext(an),d=v.useMemo(()=>{if(Rn(l))return zc({parentContext:c,elements:l,path:e.path,profileUrl:t.typeSchema?.url})},[c,e.path,t.typeSchema?.url,l]);function f(b){o(b),e.onChange&&e.onChange(b)}const p=t.min>0,m=vn(t.elements),g=aA(t.name),x=e.property.readonly&&r.length===0;return Tm(an.Provider,d,a.jsx(Pt,{title:g,description:t.definition,withAsterisk:p,fhirPath:`${n.path}:${t.name}`,testId:e.testId,readonly:e.property.readonly,children:x?a.jsx(Te,{c:"dimmed",children:"(empty)"}):a.jsxs(Be,{className:m?fP.indented:void 0,children:[r.map((b,w)=>a.jsxs(ye,{wrap:"nowrap",children:[a.jsx("div",{style:{flexGrow:1},"data-testid":e.testId&&`${e.testId}-elements-${w}`,children:a.jsx(Zb,{elementDefinitionType:t.type[0],name:t.name,defaultValue:b,onChange:j=>{const C=[...r];C[w]=j,f(C)},outcome:e.outcome,min:t.min,max:t.max,binding:t.binding,path:e.path,valuePath:void 0,readOnly:e.property.readonly})}),!e.property.readonly&&r.length>t.min&&a.jsx(hP,{propertyDisplayName:g,testId:e.testId&&`${e.testId}-remove-${w}`,onClick:j=>{cn(j);const C=[...r];C.splice(w,1),f(C)}})]},`${w}-${r.length}`)),!e.property.readonly&&r.length<t.max&&a.jsx(ye,{wrap:"nowrap",style:{justifyContent:"flex-start"},children:a.jsx(Xb,{propertyDisplayName:g,onClick:b=>{cn(b);const w=[...r,void 0];f(w)},testId:e.testId&&`${e.testId}-add`})})]})}))}function wW(e){const{property:t}=e,n=Re(),[r,o]=v.useState(!0),[l,c]=v.useState([]),[d]=v.useState(()=>Array.isArray(e.defaultValue)?e.defaultValue:[]),[f,p]=v.useState(()=>[d]),m=v.useContext(an),g=t.type[0]?.code;v.useEffect(()=>{aP({medplum:n,property:t}).then(E=>{c(E);const R=oP(d,E,t.slicing,m.profileUrl);jW(R,E),p(R),o(!1)}).catch(E=>{console.error(E),o(!1)})},[n,t,d,m.profileUrl,p]);function x(E,R){const D=[...f];if(D[R]=E,p(D),e.onChange){const P=D.flat().filter(A=>A!==void 0);e.onChange(P)}}if(r)return a.jsx("div",{children:"Loading..."});const b=l.length,w=f[b],j=!(e.hideNonSliceValues??(g==="Extension"&&l.length>0)),C=ol(t.path),T=e.property.readonly&&l.length===0&&d.length===0;return a.jsxs(Be,{className:e.indent?fP.indented:void 0,children:[T&&a.jsx(Te,{c:"dimmed",children:"(empty)"}),l.map((E,R)=>a.jsx(SW,{slice:E,path:e.path,valuePath:e.valuePath,property:t,defaultValue:f[R],onChange:D=>{x(D,R)},testId:`slice-${E.name}`},E.name)),j&&w.map((E,R)=>a.jsxs(ye,{wrap:"nowrap",style:{flexGrow:1},children:[a.jsx("div",{style:{flexGrow:1},children:a.jsx(Wd,{arrayElement:!0,property:e.property,name:e.name+"."+R,path:e.path,valuePath:xW(e.path,e.valuePath,R),defaultValue:E,onChange:D=>{const P=[...w];P[R]=D,x(P,b)},defaultPropertyType:void 0,outcome:e.outcome})}),!e.property.readonly&&a.jsx(hP,{propertyDisplayName:C,testId:`nonsliced-remove-${R}`,onClick:D=>{cn(D);const P=[...w];P.splice(R,1),x(P,b)}})]},`${R}-${w.length}`)),!e.property.readonly&&j&&f.flat().length<t.max&&a.jsx(ye,{wrap:"nowrap",style:{justifyContent:"flex-start"},children:a.jsx(Xb,{propertyDisplayName:C,onClick:E=>{cn(E);const R=[...w];R.push(void 0),x(R,b)},testId:"nonsliced-add"})})]})}function jW(e,t){for(let n=0;n<t.length;n++){const r=t[n],o=e[n];for(;o.length<r.min;)o.push(void 0)}}function CW(e){const[t,n]=v.useState(!1),r=UR(),o=v.useRef(null),l={...e.styles};return t||(l.input||(l.input={}),l.input.WebkitTextSecurity="disc"),a.jsxs(jo,{gap:"xs",children:[a.jsx(vl,{...e,styles:{...l,root:{...l.root??{},flexGrow:1}},ref:o,autosize:!0,minRows:1,onFocus:()=>n(!0),onBlur:()=>n(!1)}),a.jsx(bn,{title:"Copy secret",onClick:()=>{r.copy(o.current?.value),Ne({color:"green",message:"Copied"})},children:a.jsx(Ub,{})})]})}const EW=["sun","mon","tue","wed","thu","fri","sat"];function TW(e){const[t,n]=v.useState(e.defaultValue),[r,o]=v.useState(!e.disabled&&(e.defaultModalOpen??!1)),l=v.useRef(t);return l.current=t,a.jsxs(a.Fragment,{children:[a.jsxs(ye,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx("span",{children:rA(l.current)||"No repeat"}),a.jsx(ke,{disabled:e.disabled,onClick:()=>o(!0),children:"Edit"})]}),!e.disabled&&a.jsx(RW,{path:e.path,visible:r,defaultValue:l.current,onOk:c=>{e.onChange&&e.onChange(c),n(c),o(!1)},onCancel:()=>o(!1)})]})}const bT={repeat:{period:1,periodUnit:"d"}};function RW(e){const[t,n]=v.useState(e.defaultValue||bT),{getExtendedProps:r}=v.useContext(an),[o,l,c,d,f]=v.useMemo(()=>["event","repeat","repeat.period","repeat.periodUnit","repeat.dayOfWeek"].map(j=>r(e.path+"."+j)),[r,e.path]),p=v.useRef(t);p.current=t;function m(j){n({...p.current,event:[j]})}function g(j){n({...p.current,repeat:j})}function x(j){g({...p.current?.repeat,period:j})}function b(j){g({...p.current?.repeat,periodUnit:j})}function w(j){g({...p.current?.repeat,dayOfWeek:j})}return a.jsx(Un,{title:"Timing",closeButtonProps:{"aria-label":"Close"},opened:e.visible,onClose:()=>e.onCancel(),children:a.jsxs(Be,{children:[a.jsx(Pt,{title:"Starts on",htmlFor:"timing-dialog-start",children:a.jsx(So,{disabled:o?.readonly,name:"timing-dialog-start",onChange:j=>m(j)})}),a.jsx(zd,{disabled:l?.readonly,label:"Repeat",checked:!!t.repeat,onChange:j=>g(j.currentTarget.checked?bT.repeat:void 0)}),t.repeat&&a.jsxs(a.Fragment,{children:[a.jsx(Pt,{title:"Repeat every",htmlFor:"timing-dialog-period",children:a.jsxs(ye,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(Ve,{disabled:c?.readonly,type:"number",step:1,id:"timing-dialog-period",name:"timing-dialog-period",defaultValue:t.repeat.period||1,onChange:j=>x(parseInt(j.currentTarget.value,10)||1)}),a.jsx(on,{disabled:d?.readonly,id:"timing-dialog-periodUnit",name:"timing-dialog-periodUnit",defaultValue:t.repeat.periodUnit,onChange:j=>b(j.currentTarget.value),data:[{label:"second",value:"s"},{label:"minute",value:"min"},{label:"hour",value:"h"},{label:"day",value:"d"},{label:"week",value:"wk"},{label:"month",value:"mo"},{label:"year",value:"a"}]})]})}),t.repeat.periodUnit==="wk"&&a.jsx(Pt,{title:"Repeat on",children:a.jsx(ud.Group,{multiple:!0,onChange:w,children:a.jsx(ye,{justify:"space-between",mt:"md",gap:"xs",children:EW.map(j=>a.jsx(ud,{value:j,size:"xs",radius:"xl",disabled:f?.readonly,children:j.charAt(0).toUpperCase()},j))})})})]}),a.jsx(ye,{justify:"flex-end",children:a.jsx(ke,{onClick:()=>e.onOk(t),children:"OK"})})]})})}function Wd(e){const{property:t,name:n,onChange:r,defaultValue:o}=e,l=e.defaultPropertyType&&e.defaultPropertyType!=="undefined"?e.defaultPropertyType:t.type[0].code,c=t.type;if((t.isArray||t.max>1)&&!e.arrayElement){if(l===re.Attachment)return a.jsx(lQ,{name:n,defaultValue:o,onChange:r,disabled:t.readonly});const d=c[0]?.code!==re.Extension;return a.jsx(wW,{property:t,name:n,path:e.path,valuePath:e.valuePath,defaultValue:o,indent:d,onChange:r,outcome:e.outcome})}else return c.length>1?a.jsx(_W,{elementDefinitionTypes:c,...e}):a.jsx(Zb,{name:n,defaultValue:o,onChange:d=>{if(e.onChange){const f=e.name.replace("[x]",$n(c[0].code));e.onChange(d,f)}},outcome:e.outcome,elementDefinitionType:c[0],min:t.min,max:t.min,binding:t.binding,path:e.path,valuePath:e.valuePath,readOnly:t.readonly})}function _W(e){const t=e.elementDefinitionTypes;let n;e.defaultPropertyType&&(n=t.find(l=>l.code===e.defaultPropertyType)),n||(n=t[0]);const[r,o]=v.useState(n);return a.jsxs(ye,{gap:"xs",grow:!0,wrap:"nowrap",align:"flex-start",children:[a.jsx(on,{disabled:e.property.readonly,style:{width:"200px"},defaultValue:r.code,"data-testid":e.name&&e.name+"-selector",onChange:l=>{o(t.find(c=>c.code===l.currentTarget.value))},data:t.map(l=>({value:l.code,label:l.code}))}),a.jsx(Zb,{name:e.name,defaultValue:e.defaultValue,outcome:e.outcome,elementDefinitionType:r,onChange:l=>{e.onChange&&e.onChange(l,e.name.replace("[x]",$n(r.code)))},min:e.property.min,max:e.property.max,binding:e.property.binding,path:e.property.path,valuePath:e.valuePath,readOnly:e.property.readonly})]})}function Zb(e){const{name:t,onChange:n,outcome:r,binding:o,path:l,valuePath:c,readOnly:d}=e,f=e.min!==void 0&&e.min>0,p=e.elementDefinitionType.code,m=v.useContext(an),g=v.useMemo(()=>{if(!Sb(p)||!vn(e.defaultValue))return e.defaultValue;const w=Object.create(null);if(m.path===e.path)rT(w,m.elements);else{const j=Ys(m.path,e.path);if(j===void 0)return e.defaultValue;rT(w,m.elements,j)}return Rn(w)?w:e.defaultValue},[p,m.path,m.elements,e.path,e.defaultValue]);if(!p)return a.jsx("div",{children:"Property type not specified "});function x(){return{name:t,defaultValue:g,onChange:n,outcome:r,path:l,valuePath:c,disabled:d}}function b(){const w=At(e.outcome,c??l);return{id:t,name:t,"data-testid":t,defaultValue:g,required:f,error:w,disabled:d}}switch(p){case re.SystemString:case re.canonical:case re.string:case re.time:case re.uri:case re.url:return e.path==="Project.secret.value[x]"?a.jsx(CW,{...b(),onChange:w=>{e.onChange&&e.onChange(w.currentTarget.value)}}):a.jsx(Ve,{...b(),onChange:w=>{n&&n(w.currentTarget.value)}});case re.date:return a.jsx(Ve,{...b(),type:"date",onChange:w=>{n&&n(w.currentTarget.value)}});case re.dateTime:case re.instant:return a.jsx(So,{...b(),onChange:n,outcome:r});case re.decimal:case re.integer:case re.positiveInt:case re.unsignedInt:return a.jsx(Ve,{...b(),type:"number",step:p===re.decimal?"any":"1",onChange:w=>{if(n){const j=w.currentTarget.valueAsNumber;n(Number.isNaN(j)?void 0:j)}}});case re.code:return a.jsx(WA,{...b(),error:void 0,onChange:n,binding:o?.valueSet,creatable:!0,maxValues:1});case re.boolean:return a.jsx(Pn,{...b(),defaultChecked:!!g,onChange:w=>{n&&n(w.currentTarget.checked)}});case re.base64Binary:case re.markdown:return a.jsx(vl,{...b(),spellCheck:p!==re.base64Binary,onChange:w=>{n&&n(w.currentTarget.value)}});case re.Address:return a.jsx(JF,{...x()});case re.Annotation:return a.jsx(eH,{...x()});case re.Attachment:return a.jsx(YA,{...x()});case re.CodeableConcept:return a.jsx(QQ,{binding:o?.valueSet,...x()});case re.Coding:return a.jsx(KQ,{binding:o?.valueSet,...x()});case re.ContactDetail:return a.jsx(JQ,{...x()});case re.ContactPoint:return a.jsx(dP,{...x()});case re.Extension:return a.jsx(nW,{...x(),propertyType:e.elementDefinitionType});case re.HumanName:return a.jsx(rW,{...x()});case re.Identifier:return a.jsx(iW,{...x()});case re.Money:return a.jsx(aW,{...x()});case re.Period:return a.jsx(sW,{...x()});case re.Duration:case re.Quantity:return a.jsx(ll,{...x()});case re.Range:return a.jsx(Kb,{...x()});case re.Ratio:return a.jsx(cW,{...x()});case re.Reference:return a.jsx(os,{...x(),targetTypes:AW(e.elementDefinitionType)});case re.Timing:return a.jsx(TW,{...x()});case re.Dosage:case re.UsageContext:default:return a.jsx(Jb,{...x(),typeName:p})}}const DW=[`${Ji}/fhir/StructureDefinition/`,"https://medplum.com/fhir/StructureDefinition/"];function AW(e){return e?.targetProfile?.map(t=>{const n=DW.find(r=>t.startsWith(r));return n?t.slice(n.length):t})}function PW(e){const[t,n]=v.useState(e.defaultValue??{}),r=v.useContext(an),o=v.useMemo(()=>ZF(r.elements),[r.elements]);function l(d){n(d),e.onChange&&e.onChange(d)}const c={type:e.type,value:t};return a.jsx(Be,{style:{flexGrow:1},"data-testid":e.testId,children:o.map(([d,f])=>{const[p,m]=OQ(c,d,f),g=f.min!==void 0&&f.min>0,x=e.valuePath?e.valuePath+"."+d:void 0,b=a.jsx(Wd,{property:f,name:d,path:e.path+"."+d,valuePath:x,defaultValue:p,defaultPropertyType:m,onChange:(w,j)=>{l(qQ({...t},d,j??d,f,w))},outcome:e.outcome},d);return e.type==="Extension"||Ib.includes(d)?b:f.type.length===1&&f.type[0].code==="boolean"?a.jsx(uP,{title:ol(d),description:f.description,htmlFor:d,fhirPath:f.path,withAsterisk:g,readonly:f.readonly,children:b},d):a.jsx(Pt,{title:ol(d),description:f.description,withAsterisk:g,htmlFor:d,outcome:e.outcome,fhirPath:f.path,errorExpression:x,readonly:f.readonly,children:b},d)})})}function Jb(e){const[t]=v.useState(()=>e.defaultValue??{}),n=v.useContext(an),r=e.profileUrl??n?.profileUrl,o=v.useMemo(()=>dm(e.typeName,r),[e.typeName,r]),l=o?.type??e.typeName,c=v.useMemo(()=>{if(o)return zc({parentContext:n,elements:o.elements,path:e.path,profileUrl:o.url,accessPolicyResource:e.accessPolicyResource})},[o,n,e.path,e.accessPolicyResource]);return o?Tm(an.Provider,c,a.jsx(PW,{path:e.path,valuePath:e.valuePath,type:l,defaultValue:t,onChange:e.onChange,outcome:e.outcome})):a.jsxs("div",{children:[l," not implemented"]})}const kW="_noteCite_10swh_5",NW="_noteRoot_10swh_10",ST={noteCite:kW,noteRoot:NW};function pP({value:e}){return e?a.jsx(Be,{justify:"flex-start",gap:"xs",children:e.map(t=>t.text&&a.jsx(N0,{classNames:{cite:ST.noteCite,root:ST.noteRoot},cite:t.authorReference?.display||t.authorString,icon:null,children:t.text},`note-${t.text}`))}):null}function jl(e){const{value:t,link:n,...r}=e,[o,l]=v.useState(),c=Gt(t,l);let d;if(o&&!kD(o))d=`[${Ye(o)}]`;else if(c)d=da(c);else return null;return n?a.jsx(mt,{to:t,...r,children:d}):a.jsx(Te,{component:"span",...r,children:d})}function Tc(e){return a.jsxs(ye,{gap:"xs",children:[a.jsx(gs,{size:24,radius:12,value:e.value,link:e.link}),a.jsx(jl,{value:e.value,link:e.link})]})}const OW={draft:"blue",active:"blue","on-hold":"yellow",revoked:"red",completed:"green","entered-in-error":"red",unknown:"gray",retired:"gray",registered:"blue",preliminary:"blue",final:"green",amended:"yellow",corrected:"yellow",cancelled:"red",requested:"blue",received:"blue",accepted:"blue",rejected:"red",ready:"blue","in-progress":"blue",failed:"red",proposed:"blue",pending:"blue",booked:"blue",arrived:"blue",fulfilled:"green",noshow:"red","checked-in":"blue",waitlist:"gray",routine:"gray",urgent:"red",asap:"red",stat:"red","not-done":"red",connected:"green",disconnected:"red",finished:"green",planned:"gray"};function Rm(e){const{status:t,...n}=e;return a.jsx(Hp,{color:e.color||OW[t],...n,children:t.replace(/-/g," ")})}const MW="_table_pe9td_1",LW="_criticalRow_pe9td_12",mP={table:MW,criticalRow:LW};eS.defaultProps={hideObservationNotes:!1,hideSpecimenInfo:!1,hideSubject:!1};function eS(e){const t=Re(),n=Gt(e.value),[r,o]=v.useState();if(v.useEffect(()=>{n?.specimen&&Promise.allSettled(n.specimen.map(c=>t.readReference(c))).then(c=>c.filter(d=>d.status==="fulfilled").map(d=>d.value)).then(o).catch(console.error)},[t,n]),!n)return null;const l=r?.flatMap(c=>c.note||[])||[];if(n.presentedForm&&n.presentedForm.length>0){const c=n.presentedForm[0];c.contentType?.startsWith("text/plain")&&c.data&&l.push({text:window.atob(c.data)})}return a.jsxs(Be,{children:[a.jsx(Ie,{children:"Diagnostic Report"}),a.jsx(IW,{value:n,hideSubject:e.hideSubject}),r&&!e.hideSpecimenInfo&&zW(r),n.result&&a.jsx($W,{hideObservationNotes:e.hideObservationNotes,value:n.result}),l.length>0&&a.jsx(pP,{value:l})]})}function IW({value:e,hideSubject:t=!1}){return a.jsxs(ye,{mt:"md",gap:30,children:[e.subject&&!t&&a.jsxs("div",{children:[a.jsx(Te,{size:"xs",tt:"uppercase",c:"dimmed",children:"Subject"}),a.jsx(Tc,{value:e.subject,link:!0})]}),e.resultsInterpreter?.map(n=>a.jsxs("div",{children:[a.jsx(Te,{size:"xs",tt:"uppercase",c:"dimmed",children:"Interpreter"}),a.jsx(Tc,{value:n,link:!0})]},n.reference)),e.performer?.map(n=>a.jsxs("div",{children:[a.jsx(Te,{size:"xs",tt:"uppercase",c:"dimmed",children:"Performer"}),a.jsx(Tc,{value:n,link:!0})]},n.reference)),e.issued&&a.jsxs("div",{children:[a.jsx(Te,{size:"xs",tt:"uppercase",c:"dimmed",children:"Issued"}),a.jsx(Te,{children:mr(e.issued)})]}),e.status&&a.jsxs("div",{children:[a.jsx(Te,{size:"xs",tt:"uppercase",c:"dimmed",children:"Status"}),a.jsx(Rm,{status:e.status})]})]})}function zW(e){return a.jsxs(Be,{gap:"xs",children:[a.jsx(Ie,{order:2,size:"h6",children:"Specimens"}),a.jsx(Er,{type:"ordered",children:e?.map(t=>a.jsx(Er.Item,{ml:"sm",children:a.jsxs(ye,{gap:20,children:[a.jsxs(ye,{gap:5,children:[a.jsx(Te,{fw:500,children:"Collected:"})," ",mr(t.collection?.collectedDateTime)]}),a.jsxs(ye,{gap:5,children:[a.jsx(Te,{fw:500,children:"Received:"})," ",mr(t.receivedTime)]})]})},`specimen-${t.id}`))})]})}function $W(e){return a.jsxs("table",{className:mP.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Test"}),a.jsx("th",{children:"Value"}),a.jsx("th",{children:"Reference Range"}),a.jsx("th",{children:"Interpretation"}),a.jsx("th",{children:"Category"}),a.jsx("th",{children:"Performer"}),a.jsx("th",{children:"Status"})]})}),a.jsx("tbody",{children:a.jsx(gP,{value:e.value,ancestorIds:e.ancestorIds,hideObservationNotes:e.hideObservationNotes})})]})}function gP(e){return a.jsx(a.Fragment,{children:e.value?.map(t=>a.jsx(UW,{value:t,ancestorIds:e.ancestorIds,hideObservationNotes:e.hideObservationNotes},`obs-${wa(t)?t.reference:t.id}`))})}function UW(e){const t=Gt(e.value);if(!t||e.ancestorIds?.includes(t.id))return null;const n=!e.hideObservationNotes&&t.note,r=FW(t);return a.jsxs(a.Fragment,{children:[a.jsxs("tr",{className:Ot({[mP.criticalRow]:r}),children:[a.jsx("td",{rowSpan:n?2:1,children:a.jsx(mt,{to:t,children:a.jsx(bo,{value:t.code})})}),a.jsx("td",{children:a.jsx(BW,{value:t})}),a.jsx("td",{children:a.jsx(VW,{value:t.referenceRange})}),a.jsx("td",{children:t.interpretation&&t.interpretation.length>0&&a.jsx(bo,{value:t.interpretation[0]})}),a.jsx("td",{children:t.category&&t.category.length>0&&a.jsx(a.Fragment,{children:t.category.map(o=>a.jsx("div",{children:a.jsx(bo,{value:o})},`category-${ls(o)}`))})}),a.jsx("td",{children:t.performer?.map(o=>a.jsx(dp,{value:o},o.reference))}),a.jsx("td",{children:t.status&&a.jsx(Rm,{status:t.status})})]}),t.hasMember&&a.jsx(gP,{value:t.hasMember,ancestorIds:e.ancestorIds?[...e.ancestorIds,t.id]:[t.id],hideObservationNotes:e.hideObservationNotes}),n&&a.jsx("tr",{children:a.jsx("td",{colSpan:6,children:a.jsx(pP,{value:t.note})})})]})}function BW(e){const t=e.value;return a.jsx(a.Fragment,{children:iA(t)})}function VW(e){const t=e.value&&e.value.length>0&&e.value[0];return t?t.text?a.jsx(a.Fragment,{children:t.text}):a.jsx(Wb,{value:t}):null}function FW(e){const t=e.interpretation?.[0]?.coding?.[0]?.code;return t==="AA"||t==="LL"||t==="HH"||t==="A"}var wy={},ea={},wT;function vP(){if(wT)return ea;wT=1,Object.defineProperty(ea,"__esModule",{value:!0}),ea.Pointer=ea.escapeToken=ea.unescapeToken=void 0;function e(r){return r.replace(/~1/g,"/").replace(/~0/g,"~")}ea.unescapeToken=e;function t(r){return r.replace(/~/g,"~0").replace(/\//g,"~1")}ea.escapeToken=t;var n=(function(){function r(o){o===void 0&&(o=[""]),this.tokens=o}return r.fromJSON=function(o){var l=o.split("/").map(e);if(l[0]!=="")throw new Error("Invalid JSON Pointer: ".concat(o));return new r(l)},r.prototype.toString=function(){return this.tokens.map(t).join("/")},r.prototype.evaluate=function(o){for(var l=null,c="",d=o,f=1,p=this.tokens.length;f<p;f++)l=d,c=this.tokens[f],!(c=="__proto__"||c=="constructor"||c=="prototype")&&(d=(l||{})[c]);return{parent:l,key:c,value:d}},r.prototype.get=function(o){return this.evaluate(o).value},r.prototype.set=function(o,l){var c=this.evaluate(o);c.parent&&(c.parent[c.key]=l)},r.prototype.push=function(o){this.tokens.push(o)},r.prototype.add=function(o){var l=this.tokens.concat(String(o));return new r(l)},r})();return ea.Pointer=n,ea}var hn={},jy={},jT;function yP(){return jT||(jT=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.clone=e.objectType=e.hasOwnProperty=void 0,e.hasOwnProperty=Object.prototype.hasOwnProperty;function t(o){return o===void 0?"undefined":o===null?"null":Array.isArray(o)?"array":typeof o}e.objectType=t;function n(o){return o!=null&&typeof o=="object"}function r(o){if(!n(o))return o;if(o.constructor==Array){for(var l=o.length,c=new Array(l),d=0;d<l;d++)c[d]=r(o[d]);return c}if(o.constructor==Date){var f=new Date(+o);return f}var p={};for(var m in o)e.hasOwnProperty.call(o,m)&&(p[m]=r(o[m]));return p}e.clone=r})(jy)),jy}var jr={},CT;function xP(){if(CT)return jr;CT=1,Object.defineProperty(jr,"__esModule",{value:!0}),jr.diffAny=jr.diffObjects=jr.diffArrays=jr.intersection=jr.subtract=jr.isDestructive=void 0;var e=yP();function t(m){var g=m.op;return g==="remove"||g==="replace"||g==="copy"||g==="move"}jr.isDestructive=t;function n(m,g){var x={};for(var b in m)e.hasOwnProperty.call(m,b)&&m[b]!==void 0&&(x[b]=1);for(var w in g)e.hasOwnProperty.call(g,w)&&g[w]!==void 0&&delete x[w];return Object.keys(x)}jr.subtract=n;function r(m){for(var g=m.length,x={},b=0;b<g;b++){var w=m[b];for(var j in w)e.hasOwnProperty.call(w,j)&&w[j]!==void 0&&(x[j]=(x[j]||0)+1)}for(var j in x)x[j]<g&&delete x[j];return Object.keys(x)}jr.intersection=r;function o(m){return m.op==="add"}function l(m){return m.op==="remove"}function c(m,g){return{operations:m.operations.concat(g),cost:m.cost+1}}function d(m,g,x,b){b===void 0&&(b=p);var w={"0,0":{operations:[],cost:0}};function j(D,P){var A="".concat(D,",").concat(P),k=w[A];if(k===void 0){if(D>0&&P>0&&!b(m[D-1],g[P-1],x.add(String(D-1))).length)k=j(D-1,P-1);else{var M=[];if(D>0){var $=j(D-1,P),U={op:"remove",index:D-1};M.push(c($,U))}if(P>0){var J=j(D,P-1),Z={op:"add",index:D-1,value:g[P-1]};M.push(c(J,Z))}if(D>0&&P>0){var Y=j(D-1,P-1),H={op:"replace",index:D-1,original:m[D-1],value:g[P-1]};M.push(c(Y,H))}var Q=M.sort(function(O,I){return O.cost-I.cost})[0];k=Q}w[A]=k}return k}var C=isNaN(m.length)||m.length<=0?0:m.length,T=isNaN(g.length)||g.length<=0?0:g.length,E=j(C,T).operations,R=E.reduce(function(D,P){var A=D[0],k=D[1];if(o(P)){var M=P.index+1+k,$=M<C+k?String(M):"-",U={op:P.op,path:x.add($).toString(),value:P.value};return[A.concat(U),k+1]}else if(l(P)){var U={op:P.op,path:x.add(String(P.index+k)).toString()};return[A.concat(U),k-1]}else{var J=x.add(String(P.index+k)),Z=b(P.original,P.value,J);return[A.concat.apply(A,Z),k]}},[[],0])[0];return R}jr.diffArrays=d;function f(m,g,x,b){b===void 0&&(b=p);var w=[];return n(m,g).forEach(function(j){w.push({op:"remove",path:x.add(j).toString()})}),n(g,m).forEach(function(j){w.push({op:"add",path:x.add(j).toString(),value:g[j]})}),r([m,g]).forEach(function(j){w.push.apply(w,b(m[j],g[j],x.add(j)))}),w}jr.diffObjects=f;function p(m,g,x,b){if(b===void 0&&(b=p),m===g)return[];var w=(0,e.objectType)(m),j=(0,e.objectType)(g);return w=="array"&&j=="array"?d(m,g,x,b):w=="object"&&j=="object"?f(m,g,x,b):[{op:"replace",path:x.toString(),value:g}]}return jr.diffAny=p,jr}var ET;function HW(){if(ET)return hn;ET=1;var e=hn&&hn.__extends||(function(){var C=function(T,E){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(R,D){R.__proto__=D}||function(R,D){for(var P in D)Object.prototype.hasOwnProperty.call(D,P)&&(R[P]=D[P])},C(T,E)};return function(T,E){if(typeof E!="function"&&E!==null)throw new TypeError("Class extends value "+String(E)+" is not a constructor or null");C(T,E);function R(){this.constructor=T}T.prototype=E===null?Object.create(E):(R.prototype=E.prototype,new R)}})();Object.defineProperty(hn,"__esModule",{value:!0}),hn.apply=hn.InvalidOperationError=hn.test=hn.copy=hn.move=hn.replace=hn.remove=hn.add=hn.TestError=hn.MissingError=void 0;var t=vP(),n=yP(),r=xP(),o=(function(C){e(T,C);function T(E){var R=C.call(this,"Value required at path: ".concat(E))||this;return R.path=E,R.name="MissingError",R}return T})(Error);hn.MissingError=o;var l=(function(C){e(T,C);function T(E,R){var D=C.call(this,"Test failed: ".concat(E," != ").concat(R))||this;return D.actual=E,D.expected=R,D.name="TestError",D}return T})(Error);hn.TestError=l;function c(C,T,E){if(Array.isArray(C))if(T=="-")C.push(E);else{var R=parseInt(T,10);C.splice(R,0,E)}else C[T]=E}function d(C,T){if(Array.isArray(C)){var E=parseInt(T,10);C.splice(E,1)}else delete C[T]}function f(C,T){var E=t.Pointer.fromJSON(T.path).evaluate(C);return E.parent===void 0?new o(T.path):(c(E.parent,E.key,(0,n.clone)(T.value)),null)}hn.add=f;function p(C,T){var E=t.Pointer.fromJSON(T.path).evaluate(C);return E.value===void 0?new o(T.path):(d(E.parent,E.key),null)}hn.remove=p;function m(C,T){var E=t.Pointer.fromJSON(T.path).evaluate(C);if(E.parent===null)return new o(T.path);if(Array.isArray(E.parent)){if(parseInt(E.key,10)>=E.parent.length)return new o(T.path)}else if(E.value===void 0)return new o(T.path);return E.parent[E.key]=(0,n.clone)(T.value),null}hn.replace=m;function g(C,T){var E=t.Pointer.fromJSON(T.from).evaluate(C);if(E.value===void 0)return new o(T.from);var R=t.Pointer.fromJSON(T.path).evaluate(C);return R.parent===void 0?new o(T.path):(d(E.parent,E.key),c(R.parent,R.key,E.value),null)}hn.move=g;function x(C,T){var E=t.Pointer.fromJSON(T.from).evaluate(C);if(E.value===void 0)return new o(T.from);var R=t.Pointer.fromJSON(T.path).evaluate(C);return R.parent===void 0?new o(T.path):(c(R.parent,R.key,(0,n.clone)(E.value)),null)}hn.copy=x;function b(C,T){var E=t.Pointer.fromJSON(T.path).evaluate(C);return(0,r.diffAny)(E.value,T.value,new t.Pointer).length?new l(E.value,T.value):null}hn.test=b;var w=(function(C){e(T,C);function T(E){var R=C.call(this,"Invalid operation: ".concat(E.op))||this;return R.operation=E,R.name="InvalidOperationError",R}return T})(Error);hn.InvalidOperationError=w;function j(C,T){switch(T.op){case"add":return f(C,T);case"remove":return p(C,T);case"replace":return m(C,T);case"move":return g(C,T);case"copy":return x(C,T);case"test":return b(C,T)}return new w(T)}return hn.apply=j,hn}var TT;function qW(){return TT||(TT=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.createTests=e.createPatch=e.applyPatch=e.Pointer=void 0;var t=vP();Object.defineProperty(e,"Pointer",{enumerable:!0,get:function(){return t.Pointer}});var n=HW(),r=xP();function o(p,m){return m.map(function(g){return(0,n.apply)(p,g)})}e.applyPatch=o;function l(p){function m(g,x,b){var w=p(g,x,b);return Array.isArray(w)?w:(0,r.diffAny)(g,x,b,m)}return m}function c(p,m,g){var x=new t.Pointer;return(g?l(g):r.diffAny)(p,m,x)}e.createPatch=c;function d(p,m){var g=t.Pointer.fromJSON(m).evaluate(p);if(g!==void 0)return{op:"test",path:m,value:g.value}}function f(p,m){var g=new Array;return m.filter(r.isDestructive).forEach(function(x){var b=d(p,x.path);if(b&&g.push(b),"from"in x){var w=d(p,x.from);w&&g.push(w)}}),g}e.createTests=f})(wy)),wy}var bP=qW();const GW="_removed_el5zk_1",QW="_added_el5zk_6",RT={removed:GW,added:QW};function WW(e){const{name:t,path:n,property:r,originalValue:o,revisedValue:l}=e,c=!!r?.type?.find(m=>m.code==="Attachment"),[d,f]=v.useState(c),p=()=>f(m=>!m);return a.jsx(a.Fragment,{children:c&&!d||!c?a.jsx(a.Fragment,{children:a.jsxs(fe.Tr,{children:[a.jsx(fe.Td,{children:t}),a.jsx(fe.Td,{className:RT.removed,children:o&&a.jsx(Xi,{path:n,property:r,propertyType:o.type,value:o.value,ignoreMissingValues:!0})}),a.jsx(fe.Td,{className:RT.added,children:l&&a.jsx(Xi,{path:n,property:r,propertyType:l.type,value:l.value,ignoreMissingValues:!0})})]})}):a.jsxs(fe.Tr,{children:[a.jsx(fe.Td,{children:t}),a.jsx(fe.Td,{colSpan:2,style:{textAlign:"right"},children:a.jsx(ke,{onClick:p,variant:"light",children:"Expand"})})]})})}const YW="_root_15xvr_1",KW={root:YW};function XW(e){const t=Re(),{original:n,revised:r}=e,[o,l]=v.useState(!1);v.useEffect(()=>{t.requestSchema(e.original.resourceType).then(()=>l(!0)).catch(console.log)},[t,e.original.resourceType]);const c=v.useMemo(()=>{if(!o)return null;const d=[ri(n)],f=[ri(r)],p=[],m=ZW(bP.createPatch(n,r));for(const g of m){const x=g.path,b=JW(x),w=eY(n.resourceType,b),j=g.op==="add"?void 0:cs(b,d),C=g.op==="remove"?void 0:cs(b,f);p.push({key:`op-${g.op}-${g.path}`,name:`${$n(g.op)} ${b}`,path:w?.path??n.resourceType+"."+b,property:w,originalValue:_T(w,j),revisedValue:_T(w,C)})}return p},[o,n,r]);return c?a.jsxs(fe,{className:KW.root,children:[a.jsx(fe.Thead,{children:a.jsxs(fe.Tr,{children:[a.jsx(fe.Th,{}),a.jsx(fe.Th,{children:"Before"}),a.jsx(fe.Th,{children:"After"})]})}),a.jsx(fe.Tbody,{children:c.map(d=>{const{key:f,...p}=d;return a.jsx(WW,{...p},f)})})]}):null}function ZW(e){const t=[];for(const n of e){const{op:r,path:o}=n;if(o.startsWith("/meta/author")||o.startsWith("/meta/compartment")||o.startsWith("/meta/lastUpdated")||o.startsWith("/meta/versionId"))continue;const l=e.filter(d=>d.op===r&&d.path===o).length,c={op:r,path:o};l>1&&(r==="add"||r==="remove")&&/\/[0-9-]+$/.test(o)&&(c.op="replace",c.path=o.replace(/\/[^/]+$/,"")),t.some(d=>d.op===c.op&&d.path===c.path)||t.push(c)}return t}function JW(e){const t=e.split("/").filter(Boolean);let n="";for(let r=0;r<t.length;r++){const o=t[r];o==="-"?n+=".last()":/^\d+$/.test(o)?n+=`[${o}]`:(r>0&&(n+="."),n+=o)}return n.endsWith(".url")&&(n=n.replace(/\.url$/,"")),n}function eY(e,t){return ym(e,{code:e+"."+t,expression:e+"."+t})?.elementDefinitions?.[0]}function _T(e,t){return t&&{type:Array.isArray(t)?t[0].type:t.type,value:tY(t,!!e?.isArray)}}function tY(e,t){const n=zU(e).flatMap(r=>r.value);return t?n:n[0]}function tS(e){const{profileUrl:t}=e,n=Re(),r=n.getAccessPolicy(),o=Gt(e.value),[l,c]=v.useState(!1);v.useEffect(()=>{if(o)if(t)n.requestProfileSchema(t,{expandProfile:!0}).then(()=>{Zc(t)?c(!0):console.error(`Schema not found for ${t}`)}).catch(f=>{console.error("Error in requestProfileSchema",f)});else{const f=o.resourceType;n.requestSchema(f).then(()=>{c(!0)}).catch(console.error)}},[n,t,o]);const d=v.useMemo(()=>o&&dA(o,Xs.READ,r),[r,o]);return!l||!o?null:a.jsx(fp,{path:o.resourceType,value:{type:o.resourceType,value:e.forceUseInput?e.value:o},profileUrl:t,ignoreMissingValues:e.ignoreMissingValues,accessPolicyResource:d})}const nY="_item_5q6yx_1",rY="_itemPadding_5q6yx_5",DT={item:nY,itemPadding:rY};function iY(e){return a.jsx(eu,{children:e.children})}function cl(e){const{resource:t,profile:n,padding:r,popupMenuItems:o,...l}=e,c=n??t.meta?.author,d=e.dateTime??t.meta?.lastUpdated;return a.jsxs(Sl,{"data-testid":"timeline-item",fill:!0,...l,children:[a.jsxs(ye,{justify:"space-between",gap:8,mx:"xs",my:"sm",children:[a.jsx(gs,{value:c,link:!0,size:"md"}),a.jsxs("div",{style:{flex:1},children:[a.jsx(Te,{size:"sm",children:a.jsx(jl,{c:"dark",fw:500,value:c,link:!0})}),a.jsxs(Te,{size:"xs",children:[a.jsx(mt,{c:"dimmed",to:e.resource,children:mr(d)}),a.jsx(Te,{component:"span",c:"dimmed",mx:8,children:"·"}),a.jsx(mt,{c:"dimmed",to:e.resource,children:e.resource.resourceType})]})]}),o&&a.jsxs(je,{position:"bottom-end",shadow:"md",width:200,children:[a.jsx(je.Target,{children:a.jsx(bn,{color:"gray",variant:"subtle",radius:"xl","aria-label":`Actions for ${_t(e.resource)}`,children:a.jsx(qH,{})})}),o]})]}),a.jsx(VA,{children:a.jsx("div",{className:Ot(DT.item,{[DT.itemPadding]:r}),children:e.children})})]})}function SP(e,t){e.sort((n,r)=>{const o=AT(n,t),l=AT(r,t);return o>l?1:o<l?-1:PT(n,t)-PT(r,t)})}function AT(e,t){if(!wP(e,t)){const n=e.priority;if(typeof n=="string")return{stat:4,asap:3,urgent:2}[n]??0}return 0}function PT(e,t){if(!wP(e,t)){if(e.resourceType==="Communication"&&e.sent)return new Date(e.sent).getTime();if((e.resourceType==="DiagnosticReport"||e.resourceType==="Media"||e.resourceType==="Observation")&&e.issued)return new Date(e.issued).getTime();if(e.resourceType==="DocumentReference"&&e.date)return new Date(e.date).getTime()}const n=e.meta?.lastUpdated;return n?new Date(n).getTime():0}function wP(e,t){return!!t&&e.resourceType===t.resourceType&&e.id===t.id}const oY="_pinnedComment_u08s5_1",aY={pinnedComment:oY};function _m(e){const t=Re(),n=t.getProfile(),r=v.useRef(null),o=Gt(e.value),[l,c]=v.useState(),[d,f]=v.useState([]),[p,m]=v.useState(10),g=e.loadTimelineResources,x=v.useRef(d);x.current=d;const b=v.useCallback(k=>{SP(k,o),k.reverse(),f(k)},[o]),w=v.useCallback(k=>{const M=[];for(const $ of k){if($.status!=="fulfilled")continue;const U=$.value;if(U.type==="history"&&c(U),U.entry)for(const J of U.entry)M.push(J.resource)}b(M)},[b]),j=v.useCallback(k=>b([...x.current,k]),[b]),C=v.useCallback(()=>{let k,M;"resourceType"in e.value?(k=e.value.resourceType,M=e.value.id):[k,M]=e.value.reference?.split("/"),g(t,k,M).then(w).catch(console.error)},[t,e.value,g,w]);v.useEffect(()=>C(),[C]);function T(k){!o||!e.createCommunication||t.createResource(e.createCommunication(o,n,k)).then(M=>j(M)).catch(console.error)}function E(k){!o||!e.createMedia||t.createResource(e.createMedia(o,n,k)).then(M=>j(M)).then(()=>Qs({id:"upload-notification",color:"teal",title:"Upload complete",message:"",icon:a.jsx(Po,{size:16}),autoClose:2e3})).catch(M=>Qs({id:"upload-notification",color:"red",title:"Upload error",message:Ye(M),icon:a.jsx(uT,{size:16}),autoClose:2e3}))}function R(){Ne({id:"upload-notification",loading:!0,title:"Initializing upload...",message:"Please wait...",autoClose:!1,withCloseButton:!1})}function D(k){Qs({id:"upload-notification",loading:!0,title:"Uploading...",message:hY(k),autoClose:!1,withCloseButton:!1})}function P(k){Qs({id:"upload-notification",color:"red",title:"Upload error",message:Ye(k),icon:a.jsx(uT,{size:16}),autoClose:2e3})}if(!o)return a.jsx(ar,{style:{width:"100%",height:"100%"},children:a.jsx(Fr,{})});const A=d.filter(k=>k).slice(0,p);return a.jsxs(iY,{children:[e.createCommunication&&a.jsx(Sl,{children:a.jsx(ut,{testid:"timeline-form",onSubmit:k=>{T(k.text);const M=r.current;M&&(M.value="",M.focus())},children:a.jsxs(ye,{gap:"xs",wrap:"nowrap",style:{width:"100%"},children:[a.jsx(gs,{value:n}),a.jsx(Ve,{name:"text",ref:r,placeholder:"Add comment",style:{width:"100%",maxWidth:300}}),a.jsx(bn,{type:"submit",radius:"xl",color:"blue",variant:"filled",children:a.jsx(yq,{size:16})}),a.jsx(Qb,{securityContext:Ht(o),onUpload:E,onUploadStart:R,onUploadProgress:D,onUploadError:P,children:k=>a.jsx(bn,{...k,radius:"xl",color:"blue",variant:"filled",children:a.jsx($b,{size:16})})})]})})}),A.map(k=>{const M=`${k.resourceType}/${k.id}/${k.meta?.versionId}`,$=e.getMenu?e.getMenu({primaryResource:o,currentResource:k,reloadTimeline:C}):void 0;if(k.resourceType===o.resourceType&&k.id===o.id)return a.jsx(sY,{history:l,resource:k,popupMenuItems:$},M);switch(k.resourceType){case"AuditEvent":return a.jsx(dY,{resource:k,popupMenuItems:$},M);case"Communication":return a.jsx(cY,{resource:k,popupMenuItems:$},M);case"DiagnosticReport":return a.jsx(fY,{resource:k,popupMenuItems:$},M);case"Media":return a.jsx(uY,{resource:k,popupMenuItems:$},M);default:return a.jsx(cl,{resource:k,padding:!0,children:a.jsx(tS,{value:k,ignoreMissingValues:!0})},M)}}),p<d.length&&a.jsx(ye,{justify:"center",pb:"lg",children:a.jsx(ke,{onClick:()=>m(p+10),children:"Show More"})})]})}function sY(e){const{history:t,resource:n,...r}=e,o=lY(t,n);return o?a.jsx(cl,{resource:n,padding:!0,...r,children:a.jsx(XW,{original:o,revised:e.resource})}):a.jsxs(cl,{resource:n,padding:!0,...r,children:[a.jsx("h3",{children:"Created"}),a.jsx(tS,{value:n,ignoreMissingValues:!0,forceUseInput:!0})]})}function lY(e,t){const n=e.entry??[],r=n.findIndex(o=>o.resource?.meta?.versionId===t.meta?.versionId);if(!(r>=n.length-1))return n[r+1].resource}function cY(e){const n=!e.resource.priority||e.resource.priority==="routine"?void 0:aY.pinnedComment;return a.jsx(cl,{resource:e.resource,profile:e.resource.sender,dateTime:e.resource.sent,padding:!0,className:n,popupMenuItems:e.popupMenuItems,children:a.jsx("p",{children:e.resource.payload?.[0]?.contentString})})}function uY(e){const t=e.resource.content?.contentType,n=t&&!t.startsWith("image/")&&!t.startsWith("video/")&&t!=="application/pdf";return a.jsx(cl,{resource:e.resource,padding:!!n,popupMenuItems:e.popupMenuItems,children:a.jsx(Qd,{value:e.resource.content})})}function dY(e){return a.jsx(cl,{resource:e.resource,padding:!0,popupMenuItems:e.popupMenuItems,children:a.jsx(ai,{children:a.jsx("pre",{children:e.resource.outcomeDesc})})})}function fY(e){return a.jsx(cl,{resource:e.resource,padding:!0,popupMenuItems:e.popupMenuItems,children:a.jsx(eS,{value:e.resource})})}function hY(e){if(e.lengthComputable){const t=100*e.loaded/e.total;return`Uploaded: ${Cy(e.loaded)} / ${Cy(e.total)} ${t.toFixed(2)}%`}return`Uploaded: ${Cy(e.loaded)}`}function Cy(e){if(e===0)return"0.00 B";const t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toFixed(2)+" "+" KMGTP".charAt(t)+"B"}function pY(e){const{resource:t,...n}=e;return a.jsx(_m,{value:t,loadTimelineResources:async(r,o,l)=>{const c=`${o}/${l}`;return Promise.allSettled([r.readHistory(o,l),r.search("Task",{_filter:`based-on eq ${c} or focus eq ${c} or subject eq ${c}`,_count:100})])},...n})}function mY(e){const{encounter:t,...n}=e;return a.jsx(_m,{value:t,loadTimelineResources:async(r,o,l)=>Promise.allSettled([r.readHistory("Encounter",l),r.search("Communication","encounter=Encounter/"+l),r.search("Media","encounter=Encounter/"+l)]),createCommunication:(r,o,l)=>({resourceType:"Communication",status:"completed",encounter:Ht(r),subject:r.subject,sender:Ht(o),sent:new Date().toISOString(),payload:[{contentString:l}]}),createMedia:(r,o,l)=>({resourceType:"Media",status:"completed",encounter:Ht(r),subject:r.subject,operator:Ht(o),issued:new Date().toISOString(),content:l}),...n})}function gY(e){let t;try{t=PB(e.path,e.resource)}catch(n){return console.warn("FhirPathDisplay:",n),null}if(t.length>1)throw new Error(`Component "path" for "FhirPathDisplay" must resolve to a single element. Received ${t.length} elements [${JSON.stringify(t,null,2)}]`);return a.jsx(Xi,{value:t[0]||"",propertyType:e.propertyType})}function vY(e){return a.jsxs(Un,{title:"Export",closeButtonProps:{"aria-label":"Close"},opened:e.visible,onClose:e.onCancel,children:[a.jsxs(ce,{display:"flex",style:{justifyContent:"space-between"},children:[e.exportCsv&&a.jsx(kT,{text:"CSV",exportLogic:e.exportCsv,onCancel:e.onCancel}),e.exportTransactionBundle&&a.jsx(kT,{text:"Transaction Bundle",exportLogic:e.exportTransactionBundle,onCancel:e.onCancel})]}),a.jsx(Te,{style:{marginTop:"10px",marginLeft:"2px"},children:"Limited to 1000 records"})]})}function kT(e){return a.jsx(ke,{onClick:()=>{e.exportLogic(),e.onCancel()},children:`Export as ${e.text}`})}const yY={string:[de.EQUALS,de.NOT,de.CONTAINS,de.EXACT],fulltext:[de.EQUALS,de.NOT,de.CONTAINS,de.EXACT],token:[de.EQUALS,de.NOT],reference:[de.EQUALS,de.NOT],numeric:[de.EQUALS,de.NOT_EQUALS,de.GREATER_THAN,de.LESS_THAN,de.GREATER_THAN_OR_EQUALS,de.LESS_THAN_OR_EQUALS],quantity:[de.EQUALS,de.NOT_EQUALS,de.GREATER_THAN,de.LESS_THAN,de.GREATER_THAN_OR_EQUALS,de.LESS_THAN_OR_EQUALS],date:[de.EQUALS,de.NOT_EQUALS,de.GREATER_THAN,de.LESS_THAN,de.GREATER_THAN_OR_EQUALS,de.LESS_THAN_OR_EQUALS,de.STARTS_AFTER,de.ENDS_BEFORE,de.APPROXIMATELY],datetime:[de.EQUALS,de.NOT_EQUALS,de.GREATER_THAN,de.LESS_THAN,de.GREATER_THAN_OR_EQUALS,de.LESS_THAN_OR_EQUALS,de.STARTS_AFTER,de.ENDS_BEFORE,de.APPROXIMATELY],uri:[de.EQUALS,de.NOT,de.ABOVE,de.BELOW]},xY={eq:"equals",ne:"not equals",gt:"greater than",lt:"less than",ge:"greater than or equals",le:"less than or equals",sa:"starts after",eb:"ends before",ap:"approximately",sw:"starts with",contains:"contains",exact:"exact",text:"text",not:"not",above:"above",below:"below",in:"in","not-in":"not in","of-type":"of type",missing:"missing",present:"present",identifier:"identifier",iterate:"iterate"};function nS(e,t){return{...e,filters:t,offset:0,name:void 0}}function jP(e,t){return nS(e,(e.filters??[]).filter(n=>n.code!==t))}function Dm(e,t,n,r,o){const l=[];return e.filters&&l.push(...e.filters),l.push({code:t,operator:n,value:r??""}),nS(e,l)}function bY(e,t){if(!e.filters)return e;const n=[...e.filters];return n.splice(t,1),{...e,filters:n,name:void 0}}function SY(e,t){return rS(e,t,-1)}function wY(e,t){return rS(e,t,0)}function jY(e,t){return rS(e,t,1)}function rS(e,t,n){const r=new Date;r.setDate(r.getDate()+n),r.setHours(0,0,0,0);const o=new Date(r.getTime());return o.setDate(o.getDate()+1),o.setTime(o.getTime()-1),Am(e,t,r,o)}function CY(e,t){const n=new Date,r=new Date(n.getTime()+1440*60*1e3);return Am(e,t,n,r)}function EY(e,t){return iS(e,t,-1)}function TY(e,t){return iS(e,t,0)}function RY(e,t){return iS(e,t,1)}function iS(e,t,n){const r=new Date;r.setMonth(r.getMonth()+n),r.setDate(1),r.setHours(0,0,0,0);const o=new Date(r.getTime());return o.setMonth(o.getMonth()+1),o.setDate(1),o.setHours(0,0,0,0),o.setTime(o.getTime()-1),Am(e,t,r,o)}function _Y(e,t){const n=new Date;return n.setMonth(0),n.setDate(1),n.setHours(0,0,0,0),Am(e,t,n,new Date)}function Am(e,t,n,r){return e=jP(e,t),e=NT(e,t,de.GREATER_THAN_OR_EQUALS,n),e=NT(e,t,de.LESS_THAN_OR_EQUALS,r),e}function NT(e,t,n,r){return Dm(e,t,n,r.toISOString())}function OT(e,t,n=!0){return Dm(e,t,de.MISSING,n.toString())}function DY(e,t){return e.offset===t?e:{...e,offset:t,name:void 0}}function AY(e,t){const n=e.count??pm,r=(t-1)*n;return DY(e,r)}function PY(e,t,n){return t===kY(e)&&n!==void 0&&n===NY(e)?e:{...e,sortRules:[{code:t,descending:!!n}],name:void 0}}function kY(e){const t=e.sortRules;if(!t||t.length===0)return;const n=t[0].code;return n.startsWith("-")?n.substr(1):n}function NY(e){const t=e.sortRules;return!t||t.length===0?!1:!!t[0].descending}function OY(e){return yY[e.type]}function CP(e){return xY[e]??""}function ul(e){let t=e;return t.includes(".")&&(t=t.split(".").pop()),t==="versionId"?"Version ID":(t=t.replace("[x]",""),t=t.replace(/([A-Z])/g," $1"),t=t.replace(/[-_]/g," "),t=t.replace(/\s+/g," "),t=t.trim(),t.toLowerCase()==="id"?"ID":t.split(/\s/).map($n).join(" "))}function MY(e,t){const n=t.name;return n==="id"?a.jsx(mt,{to:`/${e.resourceType}/${e.id}`,children:e.id}):n==="meta.versionId"?e.meta?.versionId:n==="_lastUpdated"?mr(e.meta?.lastUpdated):t.elementDefinition&&`${e.resourceType}.${t.name}`===t.elementDefinition.path?LY(e,t.elementDefinition):t.searchParams&&t.searchParams.length===1&&t.name===t.searchParams[0].code?IY(e,t.searchParams[0]):null}function LY(e,t){const n=t.path?.split(".")?.pop()?.replaceAll("[x]","")??"",[r,o]=Em({type:e.resourceType,value:e},n);return r?a.jsx(Xi,{path:t.path,property:t,propertyType:o,value:r,maxWidth:200,ignoreMissingValues:!0,link:!1}):null}function IY(e,t){const n=cs(t.expression,[{type:e.resourceType,value:e}]);return!n||n.length===0?null:a.jsx(a.Fragment,{children:n.map((r,o)=>a.jsx(Xi,{propertyType:r.type,value:r.value,maxWidth:200,ignoreMissingValues:!0,link:!1},`${o}-${n.length}`))})}function zY(e){const t=v.useRef(!1),[n,r]=v.useState({search:JSON.parse(Ki(e.search))}),[o,l]=v.useState(!1);v.useEffect(()=>{r({search:e.search})},[e.search]);const c=v.useMemo(()=>{if(!e.visible)return[];const f=e.search.resourceType,p=zD(f),m=jb(f);return Ic($Y(p,m)).map(g=>({value:g,label:ul(g)}))},[e.visible,e.search.resourceType]);function d(f){r({search:{...n.search,fields:f}})}return a.jsx(Un,{title:"Fields",closeButtonProps:{"aria-label":"Close"},opened:e.visible,onClose:()=>{e.onCancel()},size:"auto",withOverlay:!0,closeOnClickOutside:!1,overlayProps:{onMouseDownCapture:()=>{t.current=o},onClick:()=>{t.current||e.onCancel(),t.current=!1},children:a.jsx("div",{"data-testid":"overlay-child"})},children:a.jsxs(Be,{children:[a.jsx(em,{style:{width:550},placeholder:"Select fields to display",data:c,value:n.search.fields??[],onChange:d,onDropdownOpen:()=>l(!0),onDropdownClose:()=>l(!1),maxDropdownHeight:"250px",clearButtonProps:{"aria-label":"Clear selection"},clearable:!0,searchable:!0}),a.jsx(ye,{justify:"flex-end",children:a.jsx(ke,{onClick:()=>e.onOk(n.search),children:"OK"})})]})})}function $Y(e,t){const n=[],r=new Set,o=new Set;for(const l of Object.keys(e.elements))n.push(l),r.add(l.toLowerCase()),o.add(ul(l));if(t)for(const l of Object.keys(t)){const c=ul(l);!r.has(l)&&!o.has(c)&&(n.push(l),r.add(l),o.add(c))}return n}function EP(e){const t=ym(e.resourceType,e.searchParam),n=e.name??"filter-value";switch(t.type){case dr.REFERENCE:return a.jsx(os,{name:n,defaultValue:e.defaultValue?{reference:e.defaultValue}:void 0,targetTypes:e.searchParam.target,autoFocus:e.autoFocus,onChange:r=>{r?e.onChange(r.reference):e.onChange("")}});case dr.BOOLEAN:return a.jsx(Pn,{name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultChecked:e.defaultValue==="true",autoFocus:e.autoFocus,onChange:r=>e.onChange(r.currentTarget.checked.toString())});case dr.DATE:return a.jsx(Ve,{type:"date",name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:r=>e.onChange(r.currentTarget.value)});case dr.DATETIME:return a.jsx(So,{name:n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:e.onChange});case dr.NUMBER:return a.jsx(Ve,{type:"number",name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:r=>e.onChange(r.currentTarget.value)});case dr.QUANTITY:return a.jsx(ll,{name:n,path:"",defaultValue:UY(e.defaultValue),autoFocus:e.autoFocus,onChange:r=>{r?e.onChange(`${r.value}`):e.onChange("")}});default:return a.jsx(Ve,{name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:r=>e.onChange(r.currentTarget.value),placeholder:"Search value"})}}function UY(e){if(e){const[t,n,r]=e.split("|");if(t)return{value:parseFloat(t),system:n,unit:r}}}function BY(e){const[t,n]=v.useState(ii(e.search)),r=v.useRef(t);r.current=t,v.useEffect(()=>{n(ii(e.search))},[e.search]);function o(f){n(Dm(r.current,f.code,f.operator,f.value))}const l=e.search.resourceType,c=jb(l)??{},d=t.filters||[];return a.jsx(Un,{title:"Filters",closeButtonProps:{"aria-label":"Close"},size:900,opened:e.visible,onClose:e.onCancel,children:a.jsxs(ut,{onSubmit:()=>e.onOk(r.current),children:[a.jsxs("div",{children:[a.jsxs("table",{children:[a.jsxs("colgroup",{children:[a.jsx("col",{style:{width:200}}),a.jsx("col",{style:{width:200}}),a.jsx("col",{style:{width:380}}),a.jsx("col",{style:{width:40}})]}),a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Field"}),a.jsx("th",{children:"Operation"}),a.jsx("th",{children:"Value"}),a.jsx("th",{})]})}),a.jsx("tbody",{children:d.map((f,p)=>a.jsx(VY,{id:`filter-${p}-row`,resourceType:l,searchParams:c,value:f,onChange:m=>{const g=[...d];g[p]=m,n(nS(r.current,g))},onDelete:()=>n(bY(r.current,p))},`filter-${p}-row`))})]}),a.jsx(Xb,{propertyDisplayName:"Filter",onClick:()=>o({})})]}),a.jsx(ye,{justify:"flex-end",mt:"xl",children:a.jsx(vr,{children:"OK"})})]})})}function VY(e){const t=e.value,n=v.useRef(t);n.current=t;function r(f){n.current.code=f,n.current.operator=de.EQUALS,n.current.value="",e.onChange(n.current)}function o(f){n.current.operator=f,n.current.value="",e.onChange(n.current)}function l(f){n.current.value=f,e.onChange(n.current)}const c=e.searchParams[t.code],d=c&&OY(c);return a.jsxs("tr",{children:[a.jsx("td",{children:a.jsx(on,{"data-testid":`${e.id}-filter-field`,defaultValue:e.value.code,onChange:f=>r(f.currentTarget.value),data:["",...Object.keys(e.searchParams).map(f=>({value:f,label:ul(f)}))]})}),a.jsx("td",{children:d&&a.jsx(on,{"data-testid":`${e.id}-filter-operation`,defaultValue:t.operator,onChange:f=>o(f.currentTarget.value),data:["",...d.map(f=>({value:f,label:CP(f)}))]},`${e.id}-filter-value-${e.value.code}`)}),a.jsx("td",{children:c&&t.operator&&a.jsx(EP,{name:`${e.id}-filter-value`,resourceType:e.resourceType,searchParam:c,defaultValue:t.value,onChange:l},`${e.id}-filter-value-${e.value.code}-${e.value.operator}`)}),a.jsx("td",{children:e.onDelete&&a.jsx(bn,{variant:"outline",color:"red",radius:"xl","aria-label":"Delete filter",onClick:e.onDelete,children:a.jsx(sl,{style:{width:"70%",height:"70%"},stroke:1.5})})})]})}function FY(e){const[t,n]=v.useState(e.defaultValue??"");if(!e.searchParam||!e.filter)return null;function r(){e.onOk({...e.filter,value:t})}return a.jsx(Un,{title:e.title,size:"xl",opened:e.visible,onClose:e.onCancel,children:a.jsx(ut,{onSubmit:r,children:a.jsxs(hr,{children:[a.jsx(hr.Col,{span:10,children:a.jsx(EP,{resourceType:e.resourceType,searchParam:e.searchParam,defaultValue:t,autoFocus:!0,onChange:n})}),a.jsx(hr.Col,{span:2,children:a.jsx(ke,{onClick:r,fullWidth:!0,children:"OK"})})]})})})}function HY(e){const{resourceType:t,filter:n}=e,r=Eo.types[t].searchParams?.[n.code];if(r){if(r.type==="reference"&&(n.operator===de.EQUALS||n.operator===de.NOT_EQUALS))return a.jsx(jl,{value:{reference:n.value}});const o=ym(t,r);if(n.code==="_lastUpdated"||o.type===dr.DATETIME)return a.jsx(a.Fragment,{children:mr(n.value)})}return a.jsx(a.Fragment,{children:n.value})}function qY(e){if(!e.searchParams)return null;function t(l,c){o(PY(e.search,l.code,c))}function n(l){o(jP(e.search,l.code))}function r(l,c){e.onPrompt(l,{code:l.code,operator:c,value:""})}function o(l){e.onChange(l)}return e.searchParams.length===1?a.jsx(GY,{search:e.search,searchParam:e.searchParams[0],onSort:t,onPrompt:r,onChange:o,onClear:n}):a.jsx(je.Dropdown,{children:e.searchParams.map(l=>a.jsx(je.Item,{children:ul(l.code)},l.code))})}function GY(e){switch(e.searchParam.type){case"date":return a.jsx(QY,{...e});case"number":case"quantity":return a.jsx(WY,{...e});case"reference":return a.jsx(YY,{...e});case"string":return a.jsx(KY,{...e});case"token":case"uri":return a.jsx(XY,{...e});default:return a.jsxs(a.Fragment,{children:["Unknown search param type: ",e.searchParam.type]})}}function QY(e){const{searchParam:t}=e,n=t.code;return a.jsxs(je.Dropdown,{children:[a.jsx(je.Item,{leftSection:a.jsx(Bb,{size:14}),onClick:()=>e.onSort(t,!1),children:"Sort Oldest to Newest"}),a.jsx(je.Item,{leftSection:a.jsx(Vb,{size:14}),onClick:()=>e.onSort(t,!0),children:"Sort Newest to Oldest"}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(Gd,{size:14}),onClick:()=>e.onPrompt(t,de.EQUALS),children:"Equals..."}),a.jsx(je.Item,{leftSection:a.jsx(qd,{size:14}),onClick:()=>e.onPrompt(t,de.NOT_EQUALS),children:"Does not equal..."}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx($A,{size:14}),onClick:()=>e.onPrompt(t,de.ENDS_BEFORE),children:"Before..."}),a.jsx(je.Item,{leftSection:a.jsx(zA,{size:14}),onClick:()=>e.onPrompt(t,de.STARTS_AFTER),children:"After..."}),a.jsx(je.Item,{leftSection:a.jsx(gH,{size:14}),onClick:()=>e.onPrompt(t,de.EQUALS),children:"Between..."}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(jY(e.search,n)),children:"Tomorrow"}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(wY(e.search,n)),children:"Today"}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(SY(e.search,n)),children:"Yesterday"}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(CY(e.search,n)),children:"Next 24 Hours"}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(RY(e.search,n)),children:"Next Month"}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(TY(e.search,n)),children:"This Month"}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(EY(e.search,n)),children:"Last Month"}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(_Y(e.search,n)),children:"Year to date"}),a.jsx(Yd,{...e})]})}function WY(e){const{searchParam:t}=e;return a.jsxs(je.Dropdown,{children:[a.jsx(je.Item,{leftSection:a.jsx(Bb,{size:14}),onClick:()=>e.onSort(t,!1),children:"Sort Smallest to Largest"}),a.jsx(je.Item,{leftSection:a.jsx(Vb,{size:14}),onClick:()=>e.onSort(t,!0),children:"Sort Largest to Smallest"}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(Gd,{size:14}),onClick:()=>e.onPrompt(t,de.EQUALS),children:"Equals..."}),a.jsx(je.Item,{leftSection:a.jsx(qd,{size:14}),onClick:()=>e.onPrompt(t,de.NOT_EQUALS),children:"Does not equal..."}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(zA,{size:14}),onClick:()=>e.onPrompt(t,de.GREATER_THAN),children:"Greater than..."}),a.jsx(je.Item,{leftSection:a.jsx(px,{size:14}),onClick:()=>e.onPrompt(t,de.GREATER_THAN_OR_EQUALS),children:"Greater than or equal to..."}),a.jsx(je.Item,{leftSection:a.jsx($A,{size:14}),onClick:()=>e.onPrompt(t,de.LESS_THAN),children:"Less than..."}),a.jsx(je.Item,{leftSection:a.jsx(px,{size:14}),onClick:()=>e.onPrompt(t,de.LESS_THAN_OR_EQUALS),children:"Less than or equal to..."}),a.jsx(Yd,{...e})]})}function YY(e){const{searchParam:t}=e;return a.jsxs(je.Dropdown,{children:[a.jsx(je.Item,{leftSection:a.jsx(Gd,{size:14}),onClick:()=>e.onPrompt(t,de.EQUALS),children:"Equals..."}),a.jsx(je.Item,{leftSection:a.jsx(qd,{size:14}),onClick:()=>e.onPrompt(t,de.NOT),children:"Does not equal..."}),a.jsx(Yd,{...e})]})}function KY(e){const{searchParam:t}=e;return a.jsxs(je.Dropdown,{children:[a.jsx(je.Item,{leftSection:a.jsx(Bb,{size:14}),onClick:()=>e.onSort(t,!1),children:"Sort A to Z"}),a.jsx(je.Item,{leftSection:a.jsx(Vb,{size:14}),onClick:()=>e.onSort(t,!0),children:"Sort Z to A"}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(Gd,{size:14}),onClick:()=>e.onPrompt(t,de.EQUALS),children:"Equals..."}),a.jsx(je.Item,{leftSection:a.jsx(qd,{size:14}),onClick:()=>e.onPrompt(t,de.NOT),children:"Does not equal..."}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(wH,{size:14}),onClick:()=>e.onPrompt(t,de.CONTAINS),children:"Contains..."}),a.jsx(je.Item,{leftSection:a.jsx(bH,{size:14}),onClick:()=>e.onPrompt(t,de.EQUALS),children:"Does not contain..."}),a.jsx(Yd,{...e})]})}function XY(e){const{searchParam:t}=e;return a.jsxs(je.Dropdown,{children:[a.jsx(je.Item,{leftSection:a.jsx(Gd,{size:14}),onClick:()=>e.onPrompt(t,de.EQUALS),children:"Equals..."}),a.jsx(je.Item,{leftSection:a.jsx(qd,{size:14}),onClick:()=>e.onPrompt(t,de.NOT),children:"Does not equal..."}),a.jsx(Yd,{...e})]})}function Yd(e){const{searchParam:t}=e,n=t.code;return a.jsxs(a.Fragment,{children:[a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(fH,{size:14}),onClick:()=>e.onChange(OT(e.search,n)),children:"Missing"}),a.jsx(je.Item,{leftSection:a.jsx(uH,{size:14}),onClick:()=>e.onChange(OT(e.search,n,!1)),children:"Not missing"}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(sl,{size:14}),onClick:()=>e.onClear(t),children:"Clear filters"})]})}function TP(e){switch(e){case"next":return{"aria-label":"Next page"};case"previous":return{"aria-label":"Previous page"};case"first":return{"aria-label":"First page"};case"last":return{"aria-label":"Last page"};default:return{}}}const ZY="_root_vlout_1",JY="_table_vlout_8",eK="_tr_vlout_12",tK="_control_vlout_22",nK="_icon_vlout_31",Yu={root:ZY,table:JY,tr:eK,control:tK,icon:nK};function rK(e){const t=e.resourceType,n=[];for(const r of e.fields||["id","_lastUpdated"])n.push(iK(t,r));return n}function iK(e,t){if(t==="_lastUpdated")return{name:"_lastUpdated",searchParams:[{resourceType:"SearchParameter",base:["Resource"],code:"_lastUpdated",name:"_lastUpdated",type:"date",expression:"Resource.meta.lastUpdated"}]};if(t==="meta.versionId")return{name:"meta.versionId",searchParams:[{resourceType:"SearchParameter",base:["Resource"],code:"_versionId",name:"_versionId",type:"token",expression:"Resource.meta.versionId"}]};const n=ms(e,t),r=tB(e,t.toLowerCase());if(n&&r)return{name:t,elementDefinition:n,searchParams:[r]};if(n){const o=jb(e);let l;if(o){const c=new RegExp(`${e}\\.${t.replaceAll("[x]","")}([^\\w-]|$)`);l=Object.values(o).filter(d=>!!d.expression&&c.test(d?.expression)),l.length===0&&(l=void 0)}return{name:t,elementDefinition:n,searchParams:l}}if(r){const o=ym(e,r);return{name:t,elementDefinition:o.elementDefinitions?.[0],searchParams:[r]}}return{name:t}}class oK extends Event{constructor(t){super("change"),this.definition=t}}class aK extends Event{constructor(t){super("load"),this.response=t}}class hp extends Event{constructor(t,n){super("click"),this.resource=t,this.browserEvent=n}}function nu(e){const t=Re(),[n,r]=v.useState(),{search:o,onLoad:l}=e,[c,d]=v.useState(o);Co(o,c)||d(o);const[f,p]=v.useState({selected:{},fieldEditorVisible:!1,filterEditorVisible:!1,exportDialogVisible:!1,filterDialogVisible:!1}),m=v.useRef(f);m.current=f;const g=c.total??"accurate",x=v.useCallback(H=>{r(void 0),t.requestSchema(c.resourceType).then(()=>t.search(c.resourceType,is({...c,total:g,fields:void 0}),H)).then(Q=>{p({...m.current,searchResponse:Q}),l&&l(new aK(Q))}).catch(Q=>{p({...m.current,searchResponse:void 0}),r(qt(Q))})},[t,c,g,l]),b=v.useCallback(()=>{p({...m.current,searchResponse:void 0}),x({cache:"reload"})},[x]);v.useEffect(()=>{x()},[x]);function w(H,Q){H.stopPropagation();const I=H.target.checked,z={...m.current.selected};I?z[Q]=!0:delete z[Q],p({...m.current,selected:z})}function j(H){H.stopPropagation();const O=H.target.checked,I={},z=m.current.searchResponse;O&&z?.entry&&z.entry.forEach(F=>{F.resource?.id&&(I[F.resource.id]=!0)}),p({...m.current,selected:I})}function C(){const H=m.current;if(!H.searchResponse?.entry||H.searchResponse.entry.length===0)return!1;for(const Q of H.searchResponse.entry)if(Q.resource?.id&&!H.selected[Q.resource.id])return!1;return!0}function T(H){e.onChange&&e.onChange(new oK(H))}function E(H,Q){if(HA(H.target)||H.button===2)return;cn(H);const O=FA(H);!O&&e.onClick&&e.onClick(new hp(Q,H)),O&&e.onAuxClick&&e.onAuxClick(new hp(Q,H))}function R(){return!!(e.onExport??e.onExportCsv??e.onExportTransactionBundle)}if(n)return a.jsx(yr,{outcome:n});if(!ID(c.resourceType))return a.jsx(ar,{style:{width:"100%",height:"100%"},children:a.jsx(Fr,{})});const D=e.checkboxesEnabled,P=rK(c),A=c.resourceType,k=f.searchResponse,$=k?.entry?.map(H=>H.resource),U="subtle",J="gray",Z=16,Y=window.innerWidth<768;return a.jsxs("div",{className:Yu.root,"data-testid":"search-control",children:[!e.hideToolbar&&a.jsxs(ye,{justify:"space-between",mb:"xl",children:[a.jsxs(ye,{gap:2,children:[a.jsx(ke,{size:"compact-md",variant:U,color:J,leftSection:a.jsx(LH,{size:Z}),onClick:()=>p({...m.current,fieldEditorVisible:!0,dialogOpenTime:Date.now()}),children:"Fields"}),a.jsx(ke,{size:"compact-md",variant:U,color:J,leftSection:a.jsx(rq,{size:Z}),onClick:()=>p({...m.current,filterEditorVisible:!0,dialogOpenTime:Date.now()}),children:"Filters"}),e.onNew&&a.jsx(ke,{size:"compact-md",variant:U,color:J,leftSection:a.jsx(tq,{size:Z}),onClick:e.onNew,children:"New..."}),!Y&&R()&&a.jsx(ke,{size:"compact-md",variant:U,color:J,leftSection:a.jsx(Jq,{size:Z}),onClick:e.onExport?e.onExport:()=>p({...m.current,exportDialogVisible:!0,dialogOpenTime:Date.now()}),children:"Export..."}),!Y&&e.onDelete&&a.jsx(ke,{size:"compact-md",variant:U,color:J,leftSection:a.jsx(wm,{size:Z}),onClick:()=>e.onDelete(Object.keys(f.selected)),children:"Delete..."}),!Y&&e.onBulk&&a.jsx(ke,{size:"compact-md",variant:U,color:J,leftSection:a.jsx(pH,{size:Z}),onClick:()=>e.onBulk(Object.keys(f.selected)),children:"Bulk..."})]}),a.jsxs(ye,{gap:2,children:[k&&a.jsxs(Te,{size:"xs",c:"dimmed","data-testid":"count-display",children:[RP(c,k).toLocaleString(),"-",dK(c,k).toLocaleString(),k.total!==void 0&&` of ${c.total==="estimate"?"~":""}${k.total?.toLocaleString()}`]}),a.jsx(bn,{variant:U,color:J,title:"Refresh",onClick:b,children:a.jsx(BA,{size:Z})})]})]}),a.jsxs(fe,{className:Yu.table,children:[a.jsxs(fe.Thead,{children:[a.jsxs(fe.Tr,{children:[D&&a.jsx(fe.Th,{children:a.jsx("input",{type:"checkbox",value:"checked","aria-label":"all-checkbox","data-testid":"all-checkbox",checked:C(),onChange:H=>j(H)})}),P.map(H=>a.jsx(fe.Th,{children:a.jsxs(je,{shadow:"md",width:240,position:"bottom-end",children:[a.jsx(je.Target,{children:a.jsx(sr,{className:Yu.control,p:2,children:a.jsxs(ye,{justify:"space-between",wrap:"nowrap",children:[a.jsx(Te,{fw:500,children:ul(H.name)}),a.jsx(ar,{className:Yu.icon,children:a.jsx(rH,{size:14,stroke:1.5})})]})})}),a.jsx(qY,{search:c,searchParams:H.searchParams,onPrompt:(Q,O)=>{p({...m.current,filterDialogVisible:!0,filterDialogSearchParam:Q,filterDialogFilter:O,dialogOpenTime:Date.now()})},onChange:Q=>{T(Q)}})]})},H.name))]}),!e.hideFilters&&a.jsxs(fe.Tr,{children:[D&&a.jsx(fe.Th,{}),P.map(H=>a.jsx(fe.Th,{children:H.searchParams&&a.jsx(lK,{resourceType:A,searchParams:H.searchParams,filters:c.filters})},H.name))]})]}),a.jsx(fe.Tbody,{children:$?.map(H=>H&&a.jsxs(fe.Tr,{className:Yu.tr,"data-testid":"search-control-row",onClick:Q=>E(Q,H),onAuxClick:Q=>E(Q,H),children:[D&&a.jsx(fe.Td,{children:a.jsx("input",{type:"checkbox",value:"checked","data-testid":"row-checkbox","aria-label":`Checkbox for ${H.id}`,checked:!!f.selected[H.id],onChange:Q=>w(Q,H.id)})}),P.map(Q=>a.jsx(fe.Td,{children:MY(H,Q)},Q.name))]},H.id))})]}),!$?.length&&a.jsx(eu,{children:a.jsx(ar,{style:{height:150},children:a.jsx(Te,{size:"xl",c:"dimmed",children:"No results"})})}),k&&a.jsx(ar,{m:"md",p:"md",children:a.jsx(Oi,{value:cK(c),total:uK(c,k),onChange:H=>T(AY(c,H)),getControlProps:TP})}),a.jsx(zY,{search:c,visible:m.current.fieldEditorVisible,onOk:H=>{T(H),p({...m.current,fieldEditorVisible:!1})},onCancel:()=>{p({...m.current,fieldEditorVisible:!1})}},`search-field-editor-${f.dialogOpenTime}`),a.jsx(BY,{search:c,visible:m.current.filterEditorVisible,onOk:H=>{T(H),p({...m.current,filterEditorVisible:!1})},onCancel:()=>{p({...m.current,filterEditorVisible:!1})}},`search-filter-editor-${f.dialogOpenTime}`),a.jsx(vY,{visible:m.current.exportDialogVisible,exportCsv:e.onExportCsv,exportTransactionBundle:e.onExportTransactionBundle,onCancel:()=>{p({...m.current,exportDialogVisible:!1})}},`search-export-dialog-${f.dialogOpenTime}`),a.jsx(FY,{visible:m.current.filterDialogVisible,title:f.filterDialogSearchParam?.code?ul(f.filterDialogSearchParam.code):"",resourceType:A,searchParam:f.filterDialogSearchParam,filter:f.filterDialogFilter,defaultValue:"",onOk:H=>{T(Dm(c,H.code,H.operator,H.value)),p({...m.current,filterDialogVisible:!1})},onCancel:()=>{p({...m.current,filterDialogVisible:!1})}},`search-filter-dialog-${f.dialogOpenTime}`)]})}const sK=nu;function lK(e){const t=(e.filters??[]).filter(n=>e.searchParams.find(r=>r.code===n.code));return t.length===0?a.jsx("span",{children:"no filters"}):a.jsx(a.Fragment,{children:t.map(n=>a.jsxs("div",{children:[CP(n.operator)," ",a.jsx(HY,{resourceType:e.resourceType,filter:n})]},`filter-${n.code}-${n.operator}-${n.value}`))})}function cK(e){return Math.floor((e.offset??0)/(e.count??pm))+1}function uK(e,t){const n=e.count??pm,r=_P(e,t);return Math.ceil(r/n)}function RP(e,t){return Math.min(_P(e,t),(e.offset??0)+1)}function dK(e,t){return Math.max(RP(e,t)+(t.entry?.length??0)-1,0)}function _P(e,t){let n=t.total;return n===void 0&&(n=(e.offset??0)+(t.entry?.length??0)+(t.link?.some(r=>r.relation==="next")?1:0)),n}function fK(e){const t=Re(),[n,r]=v.useState(!1),[o,l]=v.useState(),{query:c,fields:d}=e,[f,p]=v.useState(),[m,g]=v.useState({}),x=v.useRef(f);x.current=f;const b=v.useRef({});b.current=m,v.useEffect(()=>{l(void 0),t.graphql(c).then(p).catch(R=>l(qt(R)))},[t,c]);function w(R,D){R.stopPropagation();const A=R.target.checked,k={...b.current};A?k[D]=!0:delete k[D],g(k)}function j(R){R.stopPropagation();const P=R.target.checked,A={},k=x.current?.data.ResourceList;P&&k&&k.forEach(M=>{M.id&&(A[M.id]=!0)}),g(A)}function C(){const R=x.current?.data.ResourceList;if(!R||R.length===0)return!1;for(const D of R)if(D.id&&!b.current[D.id])return!1;return!0}function T(R,D){HA(R.target)||(cn(R),R.button!==1&&e.onClick&&e.onClick(new hp(D,R)),R.button===1&&e.onAuxClick&&e.onAuxClick(new hp(D,R)))}if(v.useEffect(()=>{t.requestSchema(e.resourceType).then(()=>r(!0)).catch(console.log)},[t,e.resourceType]),!n)return a.jsx(Fr,{});const E=e.checkboxesEnabled;return a.jsxs("div",{onContextMenu:R=>cn(R),"data-testid":"search-control",children:[a.jsxs(fe,{children:[a.jsx(fe.Thead,{children:a.jsxs(fe.Tr,{children:[E&&a.jsx(fe.Th,{children:a.jsx("input",{type:"checkbox",value:"checked","aria-label":"all-checkbox","data-testid":"all-checkbox",checked:C(),onChange:R=>j(R)})}),d.map(R=>a.jsx(fe.Th,{children:R.name},R.name))]})}),a.jsx(fe.Tbody,{children:f?.data.ResourceList.map(R=>R&&a.jsxs(fe.Tr,{"data-testid":"search-control-row",onClick:D=>T(D,R),onAuxClick:D=>T(D,R),children:[E&&a.jsx(fe.Td,{children:a.jsx("input",{type:"checkbox",value:"checked","data-testid":"row-checkbox","aria-label":`Checkbox for ${R.id}`,checked:!!m[R.id],onChange:D=>w(D,R.id)})}),d.map(D=>a.jsx(fe.Td,{children:a.jsx(gY,{propertyType:D.propertyType,path:D.fhirPath,resource:R})},D.name))]},R.id))})]}),f?.data.ResourceList.length===0&&a.jsx("div",{"data-testid":"empty-search",children:"No results"}),o&&a.jsx("div",{"data-testid":"search-error",children:a.jsx("pre",{style:{textAlign:"left"},children:JSON.stringify(o,void 0,2)})}),e.onBulk&&a.jsx(ke,{onClick:()=>e.onBulk(Object.keys(b.current)),children:"Bulk..."})]})}const hK=v.memo(fK),pK="_root_1fbwr_1",mK="_entry_1fbwr_8",gK="_key_1fbwr_13",vK="_value_1fbwr_20",Pm={root:pK,entry:mK,key:gK,value:vK};function ht(e){return a.jsx(ai,{children:a.jsx("div",{className:Pm.root,children:e.children})})}ht.Entry=function(t){return a.jsx("div",{className:Pm.entry,children:t.children})};ht.Key=function(t){return a.jsx("div",{className:Pm.key,children:t.children})};ht.Value=function(t){return a.jsx("div",{className:Pm.value,children:t.children})};function yK(e){const{group:t}=e;return a.jsx(Tr,{withBorder:!0,radius:"md",p:"xs",display:"flex",style:{alignItems:"center",justifyContent:"center"},children:a.jsxs(ye,{children:[t.measureScore&&a.jsx(SK,{group:t}),!t.measureScore&&a.jsx(bK,{group:t})]})})}function xK(e){const{measure:t}=e;return a.jsxs(a.Fragment,{children:[a.jsx(Te,{fz:"md",fw:500,mb:8,children:t.title}),a.jsx(Te,{fz:"xs",c:"dimmed",mb:8,children:t.subtitle})]})}function bK(e){const{group:t}=e,n=t.population,r=n?.find(f=>ls(f.code)==="numerator"),o=n?.find(f=>ls(f.code)==="denominator"),l=r?.count,c=o?.count;if(c===0)return a.jsxs(ce,{children:[a.jsx(Ie,{order:3,children:"Not Applicable"}),a.jsx(Te,{children:`Denominator: ${c}`})]});if(l===void 0||c===void 0)return a.jsxs(ce,{children:[a.jsx(Ie,{order:3,children:"Insufficient Data"}),a.jsx(Te,{children:`Numerator: ${l}`}),a.jsx(Te,{children:`Denominator: ${c}`})]});const d=l/c*100;return a.jsx(sm,{size:120,thickness:12,roundCaps:!0,sections:[{value:d,color:DP(d)}],label:a.jsx(jo,{justify:"center",children:a.jsxs(Te,{fw:700,fz:18,children:[l," / ",c]})})})}function SK(e){const{group:t}=e,n=t.measureScore?.unit??t.measureScore?.code;return a.jsx(a.Fragment,{children:n==="%"?a.jsx(sm,{size:120,thickness:12,roundCaps:!0,sections:[{value:wK(t),color:DP(t?.measureScore?.value??0)}],label:a.jsx(jo,{justify:"center",children:a.jsx(Te,{fw:700,fz:18,children:a.jsx(vd,{value:t.measureScore})})})}):a.jsx(jo,{h:120,align:"center",children:a.jsx(Ie,{order:3,children:a.jsx(vd,{value:t.measureScore})})})})}function wK(e){const t=e.measureScore?.value,n=e.measureScore?.unit;return t?t<=1&&n==="%"?t*100:t:0}function DP(e){return e<=33?"red":e<=67?"yellow":"green"}function jK(e){const t=Gt(e.measureReport),[n]=YF("Measure",{url:t?.measure});return t?a.jsxs(ce,{children:[n&&a.jsx(xK,{measure:n}),a.jsx(lm,{cols:{base:3,sm:1},spacing:{base:"md",sm:"sm"},children:t.group?.map((r,o)=>a.jsx(yK,{group:r},r.id??o))})]}):null}const Ey="patient-export",Ty="Patient Export",CK={everything:{operation:"$everything",extension:"json",contentType:ln.FHIR_JSON},summary:{operation:"$summary",extension:"json",contentType:ln.FHIR_JSON},ccda:{operation:"$ccda-export",extension:"xml",contentType:ln.CDA_XML},ccdaReferral:{operation:"$ccda-export",type:"referral",extension:"xml",contentType:ln.CDA_XML}};function EK(e){const t=Re(),{patient:n}=e,r=v.useCallback(async o=>{const l=rl(n),c=o.format,{operation:d,type:f,contentType:p,extension:m}=CK[c],g=t.fhirUrl("Patient",l,d),x={};f&&(x.type=f),o.author&&(x.author={reference:o.author}),o.authoredOn&&(x.authoredOn=Yb(o.authoredOn)),o.startDate&&(x.start=o.startDate),o.endDate&&(x.end=o.endDate),Ci.show({id:Ey,title:Ty,loading:!0,message:"Exporting...",autoClose:!1,withCloseButton:!1});try{const b=await t.post(g,x,void 0,{cache:"no-cache",headers:{Accept:p}}),w=`Patient-export-${l}-${new Date().toISOString().replaceAll(":","-")}.${m}`;TK(b,w,p),Ci.update({id:Ey,title:Ty,color:"green",message:"Done",icon:a.jsx(Po,{size:"1rem"}),loading:!1,autoClose:!0,withCloseButton:!0})}catch(b){Ci.update({id:Ey,title:Ty,color:"red",message:Ye(b),icon:a.jsx(sl,{size:"1rem"}),loading:!1,autoClose:!1,withCloseButton:!0})}},[t,n]);return a.jsx(ut,{onSubmit:r,children:a.jsxs(Be,{children:[a.jsx(Pt,{title:"Export Format",description:"Required",withAsterisk:!0,children:a.jsx(Id,{name:"format",data:[{label:"FHIR Everything",value:"everything"},{label:"Patient Summary",value:"summary"},{label:"C-CDA",value:"ccda"},{label:"C-CDA Referral",value:"ccdaReferral"}],fullWidth:!0})}),a.jsx(Pt,{title:"Author",description:"Optional author for composition. Default value is current user.",children:a.jsx(os,{name:"author",placeholder:"Author",targetTypes:["Organization","Practitioner","PractitionerRole"]})}),a.jsx(Pt,{title:"Authored On",description:"Optional date for composition authored on. Default value is current date.",children:a.jsx(So,{name:"authoredOn",placeholder:"Authored on"})}),a.jsx(Pt,{title:"Start Date",description:"The start date of care. If no start date is provided, all records prior to the end date are in scope.",children:a.jsx(So,{name:"startDate",placeholder:"Start date"})}),a.jsx(Pt,{title:"End Date",description:"The end date of care. If no end date is provided, all records subsequent to the start date are in scope.",children:a.jsx(So,{name:"endDate",placeholder:"End date"})}),a.jsx(ye,{justify:"right",children:a.jsx(vr,{children:"Request Export"})})]})})}function TK(e,t,n){const r=typeof e=="string"?e:JSON.stringify(e,null,2),o=new Blob([r],{type:n}),l=window.URL.createObjectURL(o),c=document.createElement("a");document.body.appendChild(c),c.style.display="none",c.href=l,c.download=t,c.click(),window.URL.revokeObjectURL(l)}function RK(e){if(e.gender==="male")return"blue";if(e.gender==="female")return"pink"}function AP(e){const t=Gt(e.patient);return t?a.jsxs(ht,{children:[a.jsx(gs,{value:t,size:"lg",color:RK(t)}),a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:"Name"}),a.jsx(ht.Value,{children:a.jsx(mt,{to:t,fw:500,children:t.name?a.jsx(Fb,{value:t.name[0],options:{use:!1}}):"[blank]"})})]}),t.birthDate&&a.jsxs(a.Fragment,{children:[a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:"DoB"}),a.jsx(ht.Value,{children:t.birthDate})]}),a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:"Age"}),a.jsx(ht.Value,{children:EU(t.birthDate)})]})]}),t.gender&&a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:"Gender"}),a.jsx(ht.Value,{children:t.gender})]}),t.address&&a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:"State"}),a.jsx(ht.Value,{children:t.address[0]?.state})]}),t.identifier?.map(n=>a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:n?.system}),a.jsx(ht.Value,{children:n?.value})]},`${n?.system}-${n?.value}`))]}):null}function _K(e){const{patient:t,...n}=e,r=v.useCallback((o,l,c)=>{const d=`${l}/${c}`,f=100;return Promise.allSettled([o.readHistory("Patient",c),o.search("Communication",{subject:d,_count:f}),o.search("Device",{patient:d,_count:f}),o.search("DeviceRequest",{patient:d,_count:f}),o.search("DiagnosticReport",{subject:d,_count:f}),o.search("Media",{subject:d,_count:f}),o.search("ServiceRequest",{subject:d,_count:f}),o.search("Task",{subject:d,_count:f})])},[]);return a.jsx(_m,{value:t,loadTimelineResources:r,createCommunication:(o,l,c)=>({resourceType:"Communication",status:"completed",subject:Ht(o),sender:Ht(l),sent:new Date().toISOString(),payload:[{contentString:c}]}),createMedia:(o,l,c)=>({resourceType:"Media",status:"completed",subject:Ht(o),operator:Ht(l),issued:new Date().toISOString(),content:c}),...n})}const DK="_section_pqpwm_1",AK="_hovering_pqpwm_7",vx={section:DK,hovering:AK};function PK(e){const t=Re(),n=Gt(e.value),[r,o]=v.useState(!1),[l,c]=v.useState(),[d,f]=v.useState(),[p,m]=v.useState();function g(){f(void 0)}function x(){c(void 0)}const b=v.useRef(p);if(b.current=p,v.useEffect(()=>{t.requestSchema("PlanDefinition").then(()=>o(!0)).catch(console.log)},[t]),v.useEffect(()=>(m(LK(n??{resourceType:"PlanDefinition",status:"active"})),document.addEventListener("mouseover",g),document.addEventListener("click",x),()=>{document.removeEventListener("mouseover",g),document.removeEventListener("click",x)}),[n]),!r||!p)return null;function w(j,C){m({...b.current,[j]:C})}return a.jsx("div",{children:a.jsxs(ut,{testid:"questionnaire-form",onSubmit:()=>e.onSubmit(p),children:[a.jsx(Ve,{label:"Plan Title",py:"md",defaultValue:p.title,onChange:j=>w("title",j.currentTarget.value)}),a.jsx(kK,{actions:p.action||[],selectedKey:l,setSelectedKey:c,hoverKey:d,setHoverKey:f,onChange:j=>w("action",j)}),a.jsx(vr,{children:"Save"})]})})}function kK(e){const t=v.useRef(e.actions);t.current=e.actions;function n(l){e.onChange(t.current.map(c=>c.id===l.id?l:c))}function r(l){e.onChange([...t.current,l]),e.setSelectedKey(l.id)}function o(l){e.onChange(t.current.filter(c=>c!==l))}return a.jsxs(Be,{gap:"md",className:vx.section,children:[e.actions.map(l=>a.jsx(NK,{action:l,selectedKey:e.selectedKey,setSelectedKey:e.setSelectedKey,hoverKey:e.hoverKey,setHoverKey:e.setHoverKey,onChange:n,onRemove:()=>o(l)},l.id)),a.jsx("div",{children:a.jsx(ke,{variant:"outline",onClick:l=>{cn(l),r({id:PP()})},children:"Add action"})})]})}function NK(e){const{action:t}=e,n=MK(t);function r(l){l.stopPropagation(),e.setSelectedKey(e.action.id)}function o(l){cn(l),e.setHoverKey(e.action.id)}return a.jsx("div",{onClick:r,onMouseOver:o,onFocus:o,children:a.jsx(OK,{action:t,actionType:n,onChange:e.onChange,selectedKey:e.selectedKey,hoverKey:e.hoverKey,onRemove:e.onRemove})})}function OK(e){const{action:t}=e,[n,r]=v.useState(e.actionType),o=e.selectedKey===e.action.id,l=e.hoverKey===e.action.id;function c(f,p){e.onChange({...t,[f]:p})}const d=Ot(vx.section,{[vx.hovering]:l&&!o});return a.jsxs(Tr,{"data-testid":t.id,className:d,p:0,radius:"sm",withBorder:!0,children:[a.jsxs(jo,{w:"100%",p:"xs",bg:"gray.0",gap:"md",align:"center",justify:"space-between",children:[a.jsx(Ve,{w:"100%",name:`actionTitle-${t.id}`,defaultValue:t.title,placeholder:"Title",onChange:f=>c("title",f.currentTarget.value)}),a.jsx(hs,{"data-testid":"close-button",onClick:e.onRemove})]}),o&&a.jsxs(Be,{gap:"xl",p:"md",children:[a.jsx(ce,{children:a.jsx(Ve,{label:"Task Description",placeholder:"Enter task description",name:`actionDescription-${t.id}`,defaultValue:t.description,onChange:f=>c("description",f.currentTarget.value)})}),a.jsx(ce,{children:a.jsx(on,{label:"Type of Action",value:n,onChange:f=>{const p=f.currentTarget.value==="standard"?void 0:f.currentTarget.value;r(p),e.onChange({...e.action,definitionCanonical:p==="standard"?void 0:e.action.definitionCanonical})},data:[{value:"standard",label:"Standard task"},{value:"questionnaire",label:"Task with Questionnaire"},{value:"activitydefinition",label:"Task with Activity Definition"}]})}),n==="questionnaire"&&a.jsxs(Be,{gap:0,children:[a.jsxs(ye,{gap:0,mb:"xs",children:[a.jsx(Te,{fw:600,children:"Select questionnaire"}),a.jsx(Te,{c:"red",children:"*"})]}),a.jsxs(Te,{size:"sm",c:"dimmed",mb:"sm",children:["Questionnaire to be shown in the task in Encounter view. You can create new one from"," ",a.jsx(Dt,{href:"/Questionnaire",target:"_blank",c:"blue",children:"questionnaires list"})]}),a.jsx(MT,{resourceType:"Questionnaire",action:t,onChange:e.onChange})]}),n==="activitydefinition"&&a.jsxs(Be,{gap:0,children:[a.jsxs(ye,{gap:0,mb:"xs",children:[a.jsx(Te,{fw:600,children:"Select activity definition"}),a.jsx(Te,{c:"red",children:"*"})]}),a.jsxs(Te,{size:"sm",c:"dimmed",mb:"sm",children:["ActivityDefinition.kind resource to be shown in the task in Encounter view. You can create new one from"," ",a.jsx(Dt,{href:"/ActivityDefinition",target:"_blank",c:"blue",children:"activity definitions list"})]}),a.jsx(MT,{resourceType:"ActivityDefinition",action:t,onChange:e.onChange})]})]})]})}function MT(e){const{id:t,definitionCanonical:n}=e.action,r=n?.startsWith(e.resourceType+"/")?{reference:n}:void 0;return a.jsx(wl,{name:t,resourceType:e.resourceType,defaultValue:r,onChange:o=>{o?e.onChange({...e.action,definitionCanonical:_t(o)}):e.onChange({...e.action,definitionCanonical:void 0})}})}function MK(e){return e.definitionCanonical?.startsWith("Questionnaire")?"questionnaire":e.definitionCanonical?.startsWith("ActivityDefinition")?"activitydefinition":"standard"}let Ry=1;function PP(e){if(e){if(e.startsWith("id-")){const t=parseInt(e.substring(3),10);isNaN(t)||(Ry=Math.max(Ry,t+1))}return e}return"id-"+Ry++}function LK(e){return{...e,action:kP(e.action)}}function kP(e){if(e)return e.map(t=>({...t,id:PP(t.id),action:kP(t.action)}))}const el=30,pp=50;function mp(e){const t=e.formState,n=e.item,r=e.responseItem;function o(g){t&&e.context&&t.onChangeAnswer(e.context,e.item,g)}const l=n.type;if(!l)return null;const c=n.linkId;if(!c)return null;let d;n.initial&&n.initial.length>0?d=n.initial[0]:n.answerOption&&n.answerOption.length>0&&(d=n.answerOption.find(g=>g.initialSelected));const f=aS(r,e.index)??Lb(d),p=Do(r,`${Ji}/fhir/StructureDefinition/questionnaire-validationError`);let m=null;switch(l){case xt.display:m=a.jsx("p",{children:e.item.text},e.item.linkId);break;case xt.boolean:m=a.jsx(uP,{title:e.item.text,htmlFor:e.item.linkId,children:a.jsx(Pn,{id:e.item.linkId,name:e.item.linkId,required:e.required??n.required,defaultChecked:f?.value,onChange:g=>o([{valueBoolean:g.currentTarget.checked}])})},e.item.linkId);break;case xt.decimal:m=a.jsx(Ve,{type:"number",step:"any",id:c,name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>o(g.currentTarget.value===""?[]:[{valueDecimal:g.currentTarget.valueAsNumber}])});break;case xt.integer:m=a.jsx(Ve,{type:"number",step:1,id:c,name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>o(g.currentTarget.value===""?[]:[{valueInteger:g.currentTarget.valueAsNumber}])});break;case xt.date:m=a.jsx(Ve,{type:"date",id:c,name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>o([{valueDate:g.currentTarget.value}])});break;case xt.dateTime:m=a.jsx(So,{name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>o([{valueDateTime:g}])});break;case xt.time:m=a.jsx(Ve,{type:"time",id:c,name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>o([{valueTime:g.currentTarget.value}])});break;case xt.string:case xt.url:m=a.jsx(Ve,{id:c,name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>{const x=g.currentTarget.value;o(x===""?[]:[{valueString:x}])}});break;case xt.text:m=a.jsx(vl,{id:c,name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>{const x=g.currentTarget.value;o(x===""?[]:[{valueString:x}])}});break;case xt.attachment:m=a.jsx(ye,{py:4,children:a.jsx(YA,{path:"",name:c,defaultValue:f?.value,onChange:g=>o([{valueAttachment:g}])})});break;case xt.reference:m=a.jsx(os,{name:c,required:e.required??n.required,targetTypes:AA(n),searchCriteria:$F(n,t?.subject,t?.encounter),defaultValue:f?.value,onChange:g=>o([{valueReference:g}])});break;case xt.quantity:m=a.jsx(ll,{path:"",name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>o([{valueQuantity:g}]),disableWheel:!0});break;case xt.choice:case xt.openChoice:FK(n)?m=a.jsx(UK,{name:c,item:n,required:e.required??n.required,initial:d,response:r,onChangeAnswer:g=>o(g)}):VK(n)||n.answerValueSet&&!HK(n)?m=a.jsx(IK,{name:c,item:n,required:e.required??n.required,initial:d,response:r,onChangeAnswer:g=>o(g)}):m=a.jsx($K,{name:c,item:n,required:e.required??n.required,initial:d,response:r,onChangeAnswer:g=>o(g)});break;default:return null}return a.jsxs(a.Fragment,{children:[m,p?.valueString&&a.jsx(Te,{c:"red",size:"lg",mt:4,children:p.valueString})]})}function IK(e){const{name:t,item:n,required:r,initial:o,onChangeAnswer:l,response:c}=e;if(!n.answerOption?.length&&!n.answerValueSet)return a.jsx(oS,{});const d=Lb(o),f=aS(c)??d,p=MP(c),m=n.repeats||qK(n);if(n.answerValueSet)return a.jsx(jm,{name:t,placeholder:"Select items",binding:n.answerValueSet,maxValues:m?void 0:1,required:r,onChange:g=>{m?g.length===0?l([{}]):l(g.map(x=>({valueCoding:x}))):l([{valueCoding:g[0]}])},defaultValue:f?.value});if(m){const{propertyName:g,data:x}=GK(n);return a.jsx(em,{data:x,placeholder:"Select items",searchable:!0,defaultValue:p||[il(d)],required:r,onChange:b=>{if(b.length===0)l([{}]);else{const w=_A(b,g,n);l(w)}}})}else{const g=[""];if(n.answerOption)for(const x of n.answerOption){const b=To(x);g.push(il(b))}return a.jsx(on,{id:t,name:t,required:r,onChange:x=>{const b=x.currentTarget.selectedIndex;if(b===0){l([{}]);return}const w=n.answerOption[b-1],j=To(w),C="value"+$n(j.type);l([{[C]:j.value}])},defaultValue:Hd(f?.value)||f?.value,data:g})}}function zK(e,t){return e?t.valueSetExpand({url:e,count:el+1}).then(n=>n.expansion?.contains??[]):Promise.resolve([])}function NP(e){const t=Re(),[n,r]=v.useState([]),[o,l]=v.useState(!1);return v.useEffect(()=>{async function c(){if(e){l(!0);try{const d=await zK(e,t);r(d)}catch(d){console.error("Error loading value set:",d)}finally{l(!1)}}}c().catch(console.error)},[e,t]),[n,o]}function OP(e,t){return e.map((n,r)=>{const o=`${t}-valueset-${r}`,l={type:"Coding",value:{system:n.system,code:n.code,display:n.display}};return[o,l]})}function $K(e){const{name:t,item:n,required:r,initial:o,onChangeAnswer:l,response:c}=e,d=ms("QuestionnaireItemAnswerOption","value[x]"),f=Lb(o),[p,m]=NP(n.answerValueSet),g=[];let x;if(n.answerValueSet)g.push(...OP(p,t));else if(n.answerOption){const C=n.answerOption.slice(0,pp).map((T,E)=>{const R=`${t}-option-${E}`,D=To(T);return D?.value?(f&&Ki(D)===Ki(f)&&(x=R),[R,D]):null}).filter(T=>T!==null);g.push(...C)}const b=aS(c),w=BK(g,b);if(m)return a.jsx(Te,{children:"Loading options..."});if(g.length===0)return a.jsx(oS,{});const j=g.slice(0,el);return a.jsxs(a.Fragment,{children:[a.jsx(ur.Group,{name:t,value:w??x,required:r,onChange:C=>{const T=g.find(E=>E[0]===C);if(T){const E=T[1],R="value"+$n(E.type);l([{[R]:E.value}])}},children:j.map(([C,T])=>a.jsx(ur,{id:C,value:C,py:4,required:r,label:a.jsx(Xi,{property:d,propertyType:T.type,value:T.value})},C))}),(n.answerValueSet&&g.length>el||n.answerOption&&g.length>pp)&&a.jsxs(Te,{size:"sm",c:"dimmed",mt:"xs",children:["Showing first ",el," options"]})]})}function UK(e){const{name:t,item:n,onChangeAnswer:r,response:o}=e,l=ms("QuestionnaireItemAnswerOption","value[x]"),[c,d]=NP(n.answerValueSet),f=n.answerValueSet?(o?.answer?.map(w=>w.valueCoding)||[]).filter(w=>w!==void 0):MP(o),[p,m]=v.useState(f),g=[];if(n.answerValueSet)g.push(...OP(c,t));else if(n.answerOption){const w=n.answerOption.slice(0,pp).map((j,C)=>{const T=`${t}-option-${C}`,E=To(j);return E?.value?[T,E]:null}).filter(j=>j!==null);g.push(...w)}if(d)return a.jsx(Te,{children:"Loading options..."});if(g.length===0)return a.jsx(oS,{});const x=g.slice(0,el),b=(w,j)=>{if(n.answerValueSet){const C=p;let T;j?T=[...C,w.value]:T=C.filter(E=>!Co(E,w.value)),m(T),T.length===0?r([{}]):r(T.map(E=>({valueCoding:E})))}else{const C=p,T=il(w);let E;if(j?E=[...C,T]:E=C.filter(R=>R!==T),m(E),E.length===0)r([{}]);else{const R=_A(E,"value"+$n(w.type),n);r(R)}}};return a.jsxs(ye,{style:{flexDirection:"column",alignItems:"flex-start"},children:[x.map(([w,j])=>{const C=il(j),T=n.answerValueSet?p.some(E=>Co(E,j.value)):p.includes(C);return a.jsx(Pn,{id:w,label:a.jsx(Xi,{property:l,propertyType:j.type,value:j.value}),checked:T,onChange:E=>b(j,E.currentTarget.checked)},w)}),(n.answerValueSet&&g.length>el||n.answerOption&&g.length>pp)&&a.jsxs(Te,{size:"sm",c:"dimmed",children:["Showing first ",el," options"]})]})}function oS(){return a.jsx(Ve,{disabled:!0,placeholder:"No Answers Defined"})}function aS(e,t=0){return To(e?.answer?.[t]??{})}function MP(e){const t=e?.answer;return t?t.map(r=>To(r)).map(r=>Hd(r?.value)||r?.value).filter(Boolean):[]}function BK(e,t){return e.find(n=>Co(n[1].value,t?.value))?.[0]}function km(e,t){return!!e.extension?.some(n=>n.url===Ob&&n.valueCodeableConcept?.coding?.[0]?.code===t)}function VK(e){return km(e,"drop-down")}function FK(e){return km(e,"check-box")}function HK(e){return km(e,"radio-button")}function qK(e){return km(e,"multi-select")}function GK(e){if(e.answerOption?.length===0)return{propertyName:"",data:[]};const t=e.answerOption[0],n=To(t),r="value"+$n(n.type),o=(e.answerOption??[]).map(l=>{const c=To(l),d=il(c);return{value:d,label:d}});return{propertyName:r,data:o}}const QK="_section_my8o4_1",WK="_hovering_my8o4_10",YK="_editing_my8o4_14",KK="_questionBody_my8o4_20",XK="_topActions_my8o4_24",ZK="_bottomActions_my8o4_33",JK="_movementActions_my8o4_44",eX="_movementIcons_my8o4_56",tX="_columnAlignment_my8o4_60",nX="_linkIdInput_my8o4_65",rX="_typeSelect_my8o4_70",iX="_preserveBreaks_my8o4_74",ei={section:QK,hovering:WK,editing:YK,questionBody:KK,topActions:XK,bottomActions:ZK,movementActions:JK,movementIcons:eX,columnAlignment:tX,linkIdInput:nX,typeSelect:rX,preserveBreaks:iX};function oX(e){const t=Re(),n=Gt(e.questionnaire),[r,o]=v.useState(!1),[l,c]=v.useState(),[d,f]=v.useState(),[p,m]=v.useState();function g(){m(void 0)}function x(){f(void 0)}v.useEffect(()=>{t.requestSchema("Questionnaire").then(()=>o(!0)).catch(console.log)},[t]),v.useEffect(()=>(c(cX(n??{resourceType:"Questionnaire",status:"active"})),document.addEventListener("mouseover",g),document.addEventListener("click",x),()=>{document.removeEventListener("mouseover",g),document.removeEventListener("click",x)}),[n]);const b=(w,j)=>{c(w),e.autoSave&&!j&&e.onSubmit&&e.onSubmit(w)};return!r||!l?null:a.jsx("div",{children:a.jsxs(ut,{testid:"questionnaire-form",onSubmit:()=>e.onSubmit(l),children:[a.jsx(LP,{item:l,selectedKey:d,setSelectedKey:f,hoverKey:p,setHoverKey:m,onChange:b}),a.jsx(vr,{children:"Save"})]})})}function LP(e){const t=e.item,n=e.item,r=Ao(e.item),o=r||n.type===xt.group,l=n.linkId??"[untitled]",c=e.selectedKey===e.item.id,d=e.hoverKey===e.item.id,f=v.useRef(e.item);f.current=e.item;function p(R){cn(R),e.setSelectedKey(e.item.id)}function m(R){cn(R),e.setHoverKey(e.item.id)}function g(R){const D=f.current;e.onChange({...D,item:D.item?.map(P=>P.id===R.id?R:P)})}function x(R,D){e.onChange({...e.item,item:[...e.item.item??[],R]},D)}function b(R){e.onChange({...e.item,item:e.item.item?.filter(D=>D!==R)})}function w(R,D){e.onChange({...f.current,[R]:D})}function j(R){e.onChange({...e.item,...R})}function C(R){e.onChange({...e.item,item:e.item.item?.map(D=>D===R?{...D,repeats:!D.repeats}:D)})}function T(R,D){const P=fX(e.item.item,R,D);e.onChange({...e.item,item:P})}const E=Ot(ei.section,{[ei.editing]:c,[ei.hovering]:d&&!c});return a.jsxs("div",{"data-testid":n.linkId,className:E,onClick:p,onMouseOver:m,onFocus:m,children:[a.jsx("div",{className:ei.questionBody,children:c?a.jsxs(a.Fragment,{children:[r&&a.jsx(Ve,{size:"xl",defaultValue:t.title,onBlur:R=>w("title",R.currentTarget.value)}),!r&&a.jsx(vl,{autosize:!0,minRows:2,defaultValue:n.text,onBlur:R=>w("text",R.currentTarget.value)}),n.type==="reference"&&a.jsx(lX,{item:n,onChange:j}),DF(n)&&a.jsx(aX,{item:n,onChange:R=>j(R)})]}):a.jsxs(a.Fragment,{children:[t.title&&a.jsx(Ie,{children:t.title}),n.text&&a.jsx("div",{className:ei.preserveBreaks,children:n.text}),!o&&a.jsx(mp,{item:n,index:0,required:!1,responseItem:{linkId:n.linkId}})]})}),n.item?.map((R,D)=>a.jsx("div",{children:a.jsx(LP,{item:R,selectedKey:e.selectedKey,setSelectedKey:e.setSelectedKey,hoverKey:e.hoverKey,isFirst:D===0,isLast:D===(e.item.item??[]).length-1,setHoverKey:e.setHoverKey,onChange:g,onRemove:()=>b(R),onRepeatable:C,onMoveUp:()=>T(D,-1),onMoveDown:()=>T(D,1)})},R.id)),!o&&a.jsx("div",{className:ei.topActions,children:c?a.jsxs(a.Fragment,{children:[a.jsx(Ve,{size:"xs",className:ei.linkIdInput,defaultValue:n.linkId,onBlur:R=>w("linkId",R.currentTarget.value)}),!o&&a.jsx(on,{size:"xs",className:ei.typeSelect,defaultValue:n.type,onChange:R=>w("type",R.currentTarget.value),data:[{value:"display",label:"Display"},{value:"boolean",label:"Boolean"},{value:"decimal",label:"Decimal"},{value:"integer",label:"Integer"},{value:"date",label:"Date"},{value:"dateTime",label:"Date/Time"},{value:"time",label:"Time"},{value:"string",label:"String"},{value:"text",label:"Text"},{value:"url",label:"URL"},{value:"choice",label:"Choice"},{value:"open-choice",label:"Open Choice"},{value:"attachment",label:"Attachment"},{value:"reference",label:"Reference"},{value:"quantity",label:"Quantity"}]})]}):a.jsx("div",{children:l})}),!r&&a.jsx(ce,{className:ei.movementActions,children:a.jsxs(ce,{className:ei.columnAlignment,children:[!e.isFirst&&a.jsx(Dt,{href:"#",onClick:R=>{R.preventDefault(),e.onMoveUp&&e.onMoveUp()},children:a.jsx(lH,{"data-testid":"up-button",size:15,className:ei.movementIcons})}),!e.isLast&&a.jsx(Dt,{href:"#",onClick:R=>{R.preventDefault(),e.onMoveDown&&e.onMoveDown()},children:a.jsx(aH,{"data-testid":"down-button",size:15,className:ei.movementIcons})})]})}),a.jsxs("div",{className:ei.bottomActions,children:[o&&a.jsxs(a.Fragment,{children:[a.jsx(Dt,{href:"#",onClick:R=>{R.preventDefault(),x({id:dl(),linkId:bx("q"),type:"string",text:"Question"})},children:"Add item"}),a.jsx(Dt,{href:"#",onClick:R=>{R.preventDefault(),x({id:dl(),linkId:bx("g"),type:"group",text:"Group"},!0)},children:"Add group"})]}),r&&a.jsx(Dt,{href:"#",onClick:R=>{R.preventDefault(),x(dX(),!0)},children:"Add Page"}),c&&!r&&a.jsxs(a.Fragment,{children:[a.jsx(Dt,{href:"#",onClick:R=>{R.preventDefault(),e.onRepeatable&&e.onRepeatable(n)},children:n.repeats?"Remove Repeatable":"Make Repeatable"}),a.jsx(Dt,{href:"#",onClick:R=>{R.preventDefault(),e.onRemove&&e.onRemove()},children:"Remove"})]})]})]})}function aX(e){const t=ms("QuestionnaireItemAnswerOption","value[x]"),n=e.item.answerOption??[];return a.jsxs("div",{children:[e.item.answerValueSet!==void 0?a.jsx(Ve,{placeholder:"Enter Value Set",defaultValue:e.item.answerValueSet,onChange:r=>e.onChange({...e.item,answerValueSet:r.target.value})}):a.jsx(sX,{options:n,property:t,item:e.item,onChange:e.onChange}),a.jsxs(ce,{display:"flex",children:[a.jsx(Dt,{href:"#",onClick:r=>{cn(r),e.onChange({...e.item,answerValueSet:void 0,answerOption:[...n,{id:dl()}]})},children:"Add choice"}),a.jsx(cm,{w:"lg"}),a.jsx(Dt,{href:"#",onClick:r=>{cn(r),e.onChange({...e.item,answerOption:[],answerValueSet:""})},children:"Add value set"})]})]})}function sX(e){return a.jsx("div",{children:e.options.map(t=>{const[n,r]=Em({type:"QuestionnaireItemAnswerOption",value:t},"value");return a.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",width:"80%"},children:[a.jsx("div",{children:a.jsx(Wd,{name:"value[x]",path:"Questionnaire.answerOption.value[x]",property:e.property,defaultPropertyType:r,defaultValue:n,onChange:(o,l)=>{const c=[...e.options],d=c.findIndex(f=>f.id===t.id);c[d]={id:t.id,[l]:o},e.onChange({...e.item,answerOption:c})},outcome:void 0},t.id)}),a.jsx("div",{children:a.jsx(Dt,{href:"#",onClick:o=>{cn(o),e.onChange({...e.item,answerOption:e.options.filter(l=>l.id!==t.id)})},children:"Remove"})})]},t.id)})})}function lX(e){const t=AA(e.item)??[];return a.jsxs(a.Fragment,{children:[t.map((n,r)=>a.jsxs(ye,{children:[a.jsx(Gb,{name:"resourceType",placeholder:"Resource Type",defaultValue:n,onChange:o=>{e.onChange(Sy(e.item,t.map(l=>l===n?o:l)))}}),a.jsx(Dt,{href:"#",onClick:o=>{cn(o),e.onChange(Sy(e.item,t.filter(l=>l!==n)))},children:"Remove"})]},`${n}-${r}`)),a.jsx(Dt,{href:"#",onClick:n=>{cn(n),e.onChange(Sy(e.item,[...t,""]))},children:"Add Resource Type"})]})}let yx=1,xx=1;function bx(e){return e+yx++}function dl(){return"id-"+xx++}function cX(e){return{...e,id:e.id||dl(),item:IP(e.item)}}function IP(e){if(e)return e.forEach(t=>{t.id?.match(/^id-\d+$/)&&(xx=Math.max(xx,parseInt(t.id.substring(3),10)+1)),t.linkId?.match(/^q\d+$/)&&(yx=Math.max(yx,parseInt(t.linkId.substring(1),10)+1))}),e.map(t=>({...t,id:t.id||dl(),item:IP(t.item),answerOption:uX(t.answerOption)}))}function uX(e){if(e)return e.map(t=>({...t,id:t.id||dl()}))}function dX(){return{id:dl(),linkId:bx("s"),type:"group",text:"New Page",extension:[{url:Ob,valueCodeableConcept:{coding:[{system:"http://hl7.org/fhir/questionnaire-item-control",code:"page"}]}}]}}function fX(e,t,n){const r=e??[],o=t+n;if(o<0||o>=r.length)return r;const l=[...r];return[l[t],l[o]]=[l[o],l[t]],l}/*!
|
|
552
|
+
}`.replace(/\s+/g," ");return(await e.graphql(r)).data.StructureDefinitionList[0]}function yW(e){return e.type==="profile"&&!e?.error&&vn(e.resourceType)}function xW(e,t,n){return t===void 0?e:n===void 0?t:`${t}[${n}]`}const bW="_indented_ldk1d_1",fP={indented:bW};function Xb({propertyDisplayName:e,onClick:t,testId:n}){const r=e?`Add ${e}`:"Add";return e?a.jsx(ke,{title:r,size:"sm",color:"green.6",variant:"subtle","data-testid":n,leftSection:a.jsx(cp,{size:"1.25rem"}),onClick:t,children:r}):a.jsx(bn,{title:r,color:"green.6","data-testid":n,onClick:t,children:a.jsx(cp,{size:"1.25rem"})})}function hP({propertyDisplayName:e,onClick:t,testId:n}){return a.jsx(bn,{title:e?`Remove ${e}`:"Remove",color:"red.5","data-testid":n,variant:"subtle",onClick:t,children:a.jsx(lp,{size:"1.25rem"})})}function SW(e){const{slice:t,property:n}=e,[r,o]=v.useState(e.defaultValue),l=t.typeSchema?.elements??t.elements,c=v.useContext(an),d=v.useMemo(()=>{if(Rn(l))return zc({parentContext:c,elements:l,path:e.path,profileUrl:t.typeSchema?.url})},[c,e.path,t.typeSchema?.url,l]);function f(b){o(b),e.onChange&&e.onChange(b)}const p=t.min>0,m=vn(t.elements),g=aA(t.name),x=e.property.readonly&&r.length===0;return Tm(an.Provider,d,a.jsx(Pt,{title:g,description:t.definition,withAsterisk:p,fhirPath:`${n.path}:${t.name}`,testId:e.testId,readonly:e.property.readonly,children:x?a.jsx(Te,{c:"dimmed",children:"(empty)"}):a.jsxs(Be,{className:m?fP.indented:void 0,children:[r.map((b,w)=>a.jsxs(ye,{wrap:"nowrap",children:[a.jsx("div",{style:{flexGrow:1},"data-testid":e.testId&&`${e.testId}-elements-${w}`,children:a.jsx(Zb,{elementDefinitionType:t.type[0],name:t.name,defaultValue:b,onChange:j=>{const C=[...r];C[w]=j,f(C)},outcome:e.outcome,min:t.min,max:t.max,binding:t.binding,path:e.path,valuePath:void 0,readOnly:e.property.readonly})}),!e.property.readonly&&r.length>t.min&&a.jsx(hP,{propertyDisplayName:g,testId:e.testId&&`${e.testId}-remove-${w}`,onClick:j=>{cn(j);const C=[...r];C.splice(w,1),f(C)}})]},`${w}-${r.length}`)),!e.property.readonly&&r.length<t.max&&a.jsx(ye,{wrap:"nowrap",style:{justifyContent:"flex-start"},children:a.jsx(Xb,{propertyDisplayName:g,onClick:b=>{cn(b);const w=[...r,void 0];f(w)},testId:e.testId&&`${e.testId}-add`})})]})}))}function wW(e){const{property:t}=e,n=Re(),[r,o]=v.useState(!0),[l,c]=v.useState([]),[d]=v.useState(()=>Array.isArray(e.defaultValue)?e.defaultValue:[]),[f,p]=v.useState(()=>[d]),m=v.useContext(an),g=t.type[0]?.code;v.useEffect(()=>{aP({medplum:n,property:t}).then(E=>{c(E);const R=oP(d,E,t.slicing,m.profileUrl);jW(R,E),p(R),o(!1)}).catch(E=>{console.error(E),o(!1)})},[n,t,d,m.profileUrl,p]);function x(E,R){const D=[...f];if(D[R]=E,p(D),e.onChange){const P=D.flat().filter(A=>A!==void 0);e.onChange(P)}}if(r)return a.jsx("div",{children:"Loading..."});const b=l.length,w=f[b],j=!(e.hideNonSliceValues??(g==="Extension"&&l.length>0)),C=ol(t.path),T=e.property.readonly&&l.length===0&&d.length===0;return a.jsxs(Be,{className:e.indent?fP.indented:void 0,children:[T&&a.jsx(Te,{c:"dimmed",children:"(empty)"}),l.map((E,R)=>a.jsx(SW,{slice:E,path:e.path,valuePath:e.valuePath,property:t,defaultValue:f[R],onChange:D=>{x(D,R)},testId:`slice-${E.name}`},E.name)),j&&w.map((E,R)=>a.jsxs(ye,{wrap:"nowrap",style:{flexGrow:1},children:[a.jsx("div",{style:{flexGrow:1},children:a.jsx(Wd,{arrayElement:!0,property:e.property,name:e.name+"."+R,path:e.path,valuePath:xW(e.path,e.valuePath,R),defaultValue:E,onChange:D=>{const P=[...w];P[R]=D,x(P,b)},defaultPropertyType:void 0,outcome:e.outcome})}),!e.property.readonly&&a.jsx(hP,{propertyDisplayName:C,testId:`nonsliced-remove-${R}`,onClick:D=>{cn(D);const P=[...w];P.splice(R,1),x(P,b)}})]},`${R}-${w.length}`)),!e.property.readonly&&j&&f.flat().length<t.max&&a.jsx(ye,{wrap:"nowrap",style:{justifyContent:"flex-start"},children:a.jsx(Xb,{propertyDisplayName:C,onClick:E=>{cn(E);const R=[...w];R.push(void 0),x(R,b)},testId:"nonsliced-add"})})]})}function jW(e,t){for(let n=0;n<t.length;n++){const r=t[n],o=e[n];for(;o.length<r.min;)o.push(void 0)}}function CW(e){const[t,n]=v.useState(!1),r=UR(),o=v.useRef(null),l={...e.styles};return t||(l.input||(l.input={}),l.input.WebkitTextSecurity="disc"),a.jsxs(jo,{gap:"xs",children:[a.jsx(vl,{...e,styles:{...l,root:{...l.root??{},flexGrow:1}},ref:o,autosize:!0,minRows:1,onFocus:()=>n(!0),onBlur:()=>n(!1)}),a.jsx(bn,{title:"Copy secret",onClick:()=>{r.copy(o.current?.value),Ne({color:"green",message:"Copied"})},children:a.jsx(Ub,{})})]})}const EW=["sun","mon","tue","wed","thu","fri","sat"];function TW(e){const[t,n]=v.useState(e.defaultValue),[r,o]=v.useState(!e.disabled&&(e.defaultModalOpen??!1)),l=v.useRef(t);return l.current=t,a.jsxs(a.Fragment,{children:[a.jsxs(ye,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx("span",{children:rA(l.current)||"No repeat"}),a.jsx(ke,{disabled:e.disabled,onClick:()=>o(!0),children:"Edit"})]}),!e.disabled&&a.jsx(RW,{path:e.path,visible:r,defaultValue:l.current,onOk:c=>{e.onChange&&e.onChange(c),n(c),o(!1)},onCancel:()=>o(!1)})]})}const bT={repeat:{period:1,periodUnit:"d"}};function RW(e){const[t,n]=v.useState(e.defaultValue||bT),{getExtendedProps:r}=v.useContext(an),[o,l,c,d,f]=v.useMemo(()=>["event","repeat","repeat.period","repeat.periodUnit","repeat.dayOfWeek"].map(j=>r(e.path+"."+j)),[r,e.path]),p=v.useRef(t);p.current=t;function m(j){n({...p.current,event:[j]})}function g(j){n({...p.current,repeat:j})}function x(j){g({...p.current?.repeat,period:j})}function b(j){g({...p.current?.repeat,periodUnit:j})}function w(j){g({...p.current?.repeat,dayOfWeek:j})}return a.jsx(Un,{title:"Timing",closeButtonProps:{"aria-label":"Close"},opened:e.visible,onClose:()=>e.onCancel(),children:a.jsxs(Be,{children:[a.jsx(Pt,{title:"Starts on",htmlFor:"timing-dialog-start",children:a.jsx(So,{disabled:o?.readonly,name:"timing-dialog-start",onChange:j=>m(j)})}),a.jsx(zd,{disabled:l?.readonly,label:"Repeat",checked:!!t.repeat,onChange:j=>g(j.currentTarget.checked?bT.repeat:void 0)}),t.repeat&&a.jsxs(a.Fragment,{children:[a.jsx(Pt,{title:"Repeat every",htmlFor:"timing-dialog-period",children:a.jsxs(ye,{gap:"xs",grow:!0,wrap:"nowrap",children:[a.jsx(Ve,{disabled:c?.readonly,type:"number",step:1,id:"timing-dialog-period",name:"timing-dialog-period",defaultValue:t.repeat.period||1,onChange:j=>x(parseInt(j.currentTarget.value,10)||1)}),a.jsx(on,{disabled:d?.readonly,id:"timing-dialog-periodUnit",name:"timing-dialog-periodUnit",defaultValue:t.repeat.periodUnit,onChange:j=>b(j.currentTarget.value),data:[{label:"second",value:"s"},{label:"minute",value:"min"},{label:"hour",value:"h"},{label:"day",value:"d"},{label:"week",value:"wk"},{label:"month",value:"mo"},{label:"year",value:"a"}]})]})}),t.repeat.periodUnit==="wk"&&a.jsx(Pt,{title:"Repeat on",children:a.jsx(ud.Group,{multiple:!0,onChange:w,children:a.jsx(ye,{justify:"space-between",mt:"md",gap:"xs",children:EW.map(j=>a.jsx(ud,{value:j,size:"xs",radius:"xl",disabled:f?.readonly,children:j.charAt(0).toUpperCase()},j))})})})]}),a.jsx(ye,{justify:"flex-end",children:a.jsx(ke,{onClick:()=>e.onOk(t),children:"OK"})})]})})}function Wd(e){const{property:t,name:n,onChange:r,defaultValue:o}=e,l=e.defaultPropertyType&&e.defaultPropertyType!=="undefined"?e.defaultPropertyType:t.type[0].code,c=t.type;if((t.isArray||t.max>1)&&!e.arrayElement){if(l===re.Attachment)return a.jsx(lQ,{name:n,defaultValue:o,onChange:r,disabled:t.readonly});const d=c[0]?.code!==re.Extension;return a.jsx(wW,{property:t,name:n,path:e.path,valuePath:e.valuePath,defaultValue:o,indent:d,onChange:r,outcome:e.outcome})}else return c.length>1?a.jsx(_W,{elementDefinitionTypes:c,...e}):a.jsx(Zb,{name:n,defaultValue:o,onChange:d=>{if(e.onChange){const f=e.name.replace("[x]",$n(c[0].code));e.onChange(d,f)}},outcome:e.outcome,elementDefinitionType:c[0],min:t.min,max:t.min,binding:t.binding,path:e.path,valuePath:e.valuePath,readOnly:t.readonly})}function _W(e){const t=e.elementDefinitionTypes;let n;e.defaultPropertyType&&(n=t.find(l=>l.code===e.defaultPropertyType)),n||(n=t[0]);const[r,o]=v.useState(n);return a.jsxs(ye,{gap:"xs",grow:!0,wrap:"nowrap",align:"flex-start",children:[a.jsx(on,{disabled:e.property.readonly,style:{width:"200px"},defaultValue:r.code,"data-testid":e.name&&e.name+"-selector",onChange:l=>{o(t.find(c=>c.code===l.currentTarget.value))},data:t.map(l=>({value:l.code,label:l.code}))}),a.jsx(Zb,{name:e.name,defaultValue:e.defaultValue,outcome:e.outcome,elementDefinitionType:r,onChange:l=>{e.onChange&&e.onChange(l,e.name.replace("[x]",$n(r.code)))},min:e.property.min,max:e.property.max,binding:e.property.binding,path:e.property.path,valuePath:e.valuePath,readOnly:e.property.readonly})]})}function Zb(e){const{name:t,onChange:n,outcome:r,binding:o,path:l,valuePath:c,readOnly:d}=e,f=e.min!==void 0&&e.min>0,p=e.elementDefinitionType.code,m=v.useContext(an),g=v.useMemo(()=>{if(!Sb(p)||!vn(e.defaultValue))return e.defaultValue;const w=Object.create(null);if(m.path===e.path)rT(w,m.elements);else{const j=Ys(m.path,e.path);if(j===void 0)return e.defaultValue;rT(w,m.elements,j)}return Rn(w)?w:e.defaultValue},[p,m.path,m.elements,e.path,e.defaultValue]);if(!p)return a.jsx("div",{children:"Property type not specified "});function x(){return{name:t,defaultValue:g,onChange:n,outcome:r,path:l,valuePath:c,disabled:d}}function b(){const w=At(e.outcome,c??l);return{id:t,name:t,"data-testid":t,defaultValue:g,required:f,error:w,disabled:d}}switch(p){case re.SystemString:case re.canonical:case re.string:case re.time:case re.uri:case re.url:return e.path==="Project.secret.value[x]"?a.jsx(CW,{...b(),onChange:w=>{e.onChange&&e.onChange(w.currentTarget.value)}}):a.jsx(Ve,{...b(),onChange:w=>{n&&n(w.currentTarget.value)}});case re.date:return a.jsx(Ve,{...b(),type:"date",onChange:w=>{n&&n(w.currentTarget.value)}});case re.dateTime:case re.instant:return a.jsx(So,{...b(),onChange:n,outcome:r});case re.decimal:case re.integer:case re.positiveInt:case re.unsignedInt:return a.jsx(Ve,{...b(),type:"number",step:p===re.decimal?"any":"1",onChange:w=>{if(n){const j=w.currentTarget.valueAsNumber;n(Number.isNaN(j)?void 0:j)}}});case re.code:return a.jsx(WA,{...b(),error:void 0,onChange:n,binding:o?.valueSet,creatable:!0,maxValues:1});case re.boolean:return a.jsx(Pn,{...b(),defaultChecked:!!g,onChange:w=>{n&&n(w.currentTarget.checked)}});case re.base64Binary:case re.markdown:return a.jsx(vl,{...b(),spellCheck:p!==re.base64Binary,onChange:w=>{n&&n(w.currentTarget.value)}});case re.Address:return a.jsx(JF,{...x()});case re.Annotation:return a.jsx(eH,{...x()});case re.Attachment:return a.jsx(YA,{...x()});case re.CodeableConcept:return a.jsx(QQ,{binding:o?.valueSet,...x()});case re.Coding:return a.jsx(KQ,{binding:o?.valueSet,...x()});case re.ContactDetail:return a.jsx(JQ,{...x()});case re.ContactPoint:return a.jsx(dP,{...x()});case re.Extension:return a.jsx(nW,{...x(),propertyType:e.elementDefinitionType});case re.HumanName:return a.jsx(rW,{...x()});case re.Identifier:return a.jsx(iW,{...x()});case re.Money:return a.jsx(aW,{...x()});case re.Period:return a.jsx(sW,{...x()});case re.Duration:case re.Quantity:return a.jsx(ll,{...x()});case re.Range:return a.jsx(Kb,{...x()});case re.Ratio:return a.jsx(cW,{...x()});case re.Reference:return a.jsx(os,{...x(),targetTypes:AW(e.elementDefinitionType)});case re.Timing:return a.jsx(TW,{...x()});case re.Dosage:case re.UsageContext:default:return a.jsx(Jb,{...x(),typeName:p})}}const DW=[`${Ji}/fhir/StructureDefinition/`,"https://medplum.com/fhir/StructureDefinition/"];function AW(e){return e?.targetProfile?.map(t=>{const n=DW.find(r=>t.startsWith(r));return n?t.slice(n.length):t})}function PW(e){const[t,n]=v.useState(e.defaultValue??{}),r=v.useContext(an),o=v.useMemo(()=>ZF(r.elements),[r.elements]);function l(d){n(d),e.onChange&&e.onChange(d)}const c={type:e.type,value:t};return a.jsx(Be,{style:{flexGrow:1},"data-testid":e.testId,children:o.map(([d,f])=>{const[p,m]=OQ(c,d,f),g=f.min!==void 0&&f.min>0,x=e.valuePath?e.valuePath+"."+d:void 0,b=a.jsx(Wd,{property:f,name:d,path:e.path+"."+d,valuePath:x,defaultValue:p,defaultPropertyType:m,onChange:(w,j)=>{l(qQ({...t},d,j??d,f,w))},outcome:e.outcome},d);return e.type==="Extension"||Ib.includes(d)?b:f.type.length===1&&f.type[0].code==="boolean"?a.jsx(uP,{title:ol(d),description:f.description,htmlFor:d,fhirPath:f.path,withAsterisk:g,readonly:f.readonly,children:b},d):a.jsx(Pt,{title:ol(d),description:f.description,withAsterisk:g,htmlFor:d,outcome:e.outcome,fhirPath:f.path,errorExpression:x,readonly:f.readonly,children:b},d)})})}function Jb(e){const[t]=v.useState(()=>e.defaultValue??{}),n=v.useContext(an),r=e.profileUrl??n?.profileUrl,o=v.useMemo(()=>dm(e.typeName,r),[e.typeName,r]),l=o?.type??e.typeName,c=v.useMemo(()=>{if(o)return zc({parentContext:n,elements:o.elements,path:e.path,profileUrl:o.url,accessPolicyResource:e.accessPolicyResource})},[o,n,e.path,e.accessPolicyResource]);return o?Tm(an.Provider,c,a.jsx(PW,{path:e.path,valuePath:e.valuePath,type:l,defaultValue:t,onChange:e.onChange,outcome:e.outcome})):a.jsxs("div",{children:[l," not implemented"]})}const kW="_noteCite_10swh_5",NW="_noteRoot_10swh_10",ST={noteCite:kW,noteRoot:NW};function pP({value:e}){return e?a.jsx(Be,{justify:"flex-start",gap:"xs",children:e.map(t=>t.text&&a.jsx(N0,{classNames:{cite:ST.noteCite,root:ST.noteRoot},cite:t.authorReference?.display||t.authorString,icon:null,children:t.text},`note-${t.text}`))}):null}function jl(e){const{value:t,link:n,...r}=e,[o,l]=v.useState(),c=Gt(t,l);let d;if(o&&!kD(o))d=`[${Ye(o)}]`;else if(c)d=da(c);else return null;return n?a.jsx(mt,{to:t,...r,children:d}):a.jsx(Te,{component:"span",...r,children:d})}function Tc(e){return a.jsxs(ye,{gap:"xs",children:[a.jsx(gs,{size:24,radius:12,value:e.value,link:e.link}),a.jsx(jl,{value:e.value,link:e.link})]})}const OW={draft:"blue",active:"blue","on-hold":"yellow",revoked:"red",completed:"green","entered-in-error":"red",unknown:"gray",retired:"gray",registered:"blue",preliminary:"blue",final:"green",amended:"yellow",corrected:"yellow",cancelled:"red",requested:"blue",received:"blue",accepted:"blue",rejected:"red",ready:"blue","in-progress":"blue",failed:"red",proposed:"blue",pending:"blue",booked:"blue",arrived:"blue",fulfilled:"green",noshow:"red","checked-in":"blue",waitlist:"gray",routine:"gray",urgent:"red",asap:"red",stat:"red","not-done":"red",connected:"green",disconnected:"red",finished:"green",planned:"gray"};function Rm(e){const{status:t,...n}=e;return a.jsx(Hp,{color:e.color||OW[t],...n,children:t.replace(/-/g," ")})}const MW="_table_pe9td_1",LW="_criticalRow_pe9td_12",mP={table:MW,criticalRow:LW};eS.defaultProps={hideObservationNotes:!1,hideSpecimenInfo:!1,hideSubject:!1};function eS(e){const t=Re(),n=Gt(e.value),[r,o]=v.useState();if(v.useEffect(()=>{n?.specimen&&Promise.allSettled(n.specimen.map(c=>t.readReference(c))).then(c=>c.filter(d=>d.status==="fulfilled").map(d=>d.value)).then(o).catch(console.error)},[t,n]),!n)return null;const l=r?.flatMap(c=>c.note||[])||[];if(n.presentedForm&&n.presentedForm.length>0){const c=n.presentedForm[0];c.contentType?.startsWith("text/plain")&&c.data&&l.push({text:window.atob(c.data)})}return a.jsxs(Be,{children:[a.jsx(Ie,{children:"Diagnostic Report"}),a.jsx(IW,{value:n,hideSubject:e.hideSubject}),r&&!e.hideSpecimenInfo&&zW(r),n.result&&a.jsx($W,{hideObservationNotes:e.hideObservationNotes,value:n.result}),l.length>0&&a.jsx(pP,{value:l})]})}function IW({value:e,hideSubject:t=!1}){return a.jsxs(ye,{mt:"md",gap:30,children:[e.subject&&!t&&a.jsxs("div",{children:[a.jsx(Te,{size:"xs",tt:"uppercase",c:"dimmed",children:"Subject"}),a.jsx(Tc,{value:e.subject,link:!0})]}),e.resultsInterpreter?.map(n=>a.jsxs("div",{children:[a.jsx(Te,{size:"xs",tt:"uppercase",c:"dimmed",children:"Interpreter"}),a.jsx(Tc,{value:n,link:!0})]},n.reference)),e.performer?.map(n=>a.jsxs("div",{children:[a.jsx(Te,{size:"xs",tt:"uppercase",c:"dimmed",children:"Performer"}),a.jsx(Tc,{value:n,link:!0})]},n.reference)),e.issued&&a.jsxs("div",{children:[a.jsx(Te,{size:"xs",tt:"uppercase",c:"dimmed",children:"Issued"}),a.jsx(Te,{children:mr(e.issued)})]}),e.status&&a.jsxs("div",{children:[a.jsx(Te,{size:"xs",tt:"uppercase",c:"dimmed",children:"Status"}),a.jsx(Rm,{status:e.status})]})]})}function zW(e){return a.jsxs(Be,{gap:"xs",children:[a.jsx(Ie,{order:2,size:"h6",children:"Specimens"}),a.jsx(Er,{type:"ordered",children:e?.map(t=>a.jsx(Er.Item,{ml:"sm",children:a.jsxs(ye,{gap:20,children:[a.jsxs(ye,{gap:5,children:[a.jsx(Te,{fw:500,children:"Collected:"})," ",mr(t.collection?.collectedDateTime)]}),a.jsxs(ye,{gap:5,children:[a.jsx(Te,{fw:500,children:"Received:"})," ",mr(t.receivedTime)]})]})},`specimen-${t.id}`))})]})}function $W(e){return a.jsxs("table",{className:mP.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Test"}),a.jsx("th",{children:"Value"}),a.jsx("th",{children:"Reference Range"}),a.jsx("th",{children:"Interpretation"}),a.jsx("th",{children:"Category"}),a.jsx("th",{children:"Performer"}),a.jsx("th",{children:"Status"})]})}),a.jsx("tbody",{children:a.jsx(gP,{value:e.value,ancestorIds:e.ancestorIds,hideObservationNotes:e.hideObservationNotes})})]})}function gP(e){return a.jsx(a.Fragment,{children:e.value?.map(t=>a.jsx(UW,{value:t,ancestorIds:e.ancestorIds,hideObservationNotes:e.hideObservationNotes},`obs-${wa(t)?t.reference:t.id}`))})}function UW(e){const t=Gt(e.value);if(!t||e.ancestorIds?.includes(t.id))return null;const n=!e.hideObservationNotes&&t.note,r=FW(t);return a.jsxs(a.Fragment,{children:[a.jsxs("tr",{className:Ot({[mP.criticalRow]:r}),children:[a.jsx("td",{rowSpan:n?2:1,children:a.jsx(mt,{to:t,children:a.jsx(bo,{value:t.code})})}),a.jsx("td",{children:a.jsx(BW,{value:t})}),a.jsx("td",{children:a.jsx(VW,{value:t.referenceRange})}),a.jsx("td",{children:t.interpretation&&t.interpretation.length>0&&a.jsx(bo,{value:t.interpretation[0]})}),a.jsx("td",{children:t.category&&t.category.length>0&&a.jsx(a.Fragment,{children:t.category.map(o=>a.jsx("div",{children:a.jsx(bo,{value:o})},`category-${ls(o)}`))})}),a.jsx("td",{children:t.performer?.map(o=>a.jsx(dp,{value:o},o.reference))}),a.jsx("td",{children:t.status&&a.jsx(Rm,{status:t.status})})]}),t.hasMember&&a.jsx(gP,{value:t.hasMember,ancestorIds:e.ancestorIds?[...e.ancestorIds,t.id]:[t.id],hideObservationNotes:e.hideObservationNotes}),n&&a.jsx("tr",{children:a.jsx("td",{colSpan:6,children:a.jsx(pP,{value:t.note})})})]})}function BW(e){const t=e.value;return a.jsx(a.Fragment,{children:iA(t)})}function VW(e){const t=e.value&&e.value.length>0&&e.value[0];return t?t.text?a.jsx(a.Fragment,{children:t.text}):a.jsx(Wb,{value:t}):null}function FW(e){const t=e.interpretation?.[0]?.coding?.[0]?.code;return t==="AA"||t==="LL"||t==="HH"||t==="A"}var wy={},ea={},wT;function vP(){if(wT)return ea;wT=1,Object.defineProperty(ea,"__esModule",{value:!0}),ea.Pointer=ea.escapeToken=ea.unescapeToken=void 0;function e(r){return r.replace(/~1/g,"/").replace(/~0/g,"~")}ea.unescapeToken=e;function t(r){return r.replace(/~/g,"~0").replace(/\//g,"~1")}ea.escapeToken=t;var n=(function(){function r(o){o===void 0&&(o=[""]),this.tokens=o}return r.fromJSON=function(o){var l=o.split("/").map(e);if(l[0]!=="")throw new Error("Invalid JSON Pointer: ".concat(o));return new r(l)},r.prototype.toString=function(){return this.tokens.map(t).join("/")},r.prototype.evaluate=function(o){for(var l=null,c="",d=o,f=1,p=this.tokens.length;f<p;f++)l=d,c=this.tokens[f],!(c=="__proto__"||c=="constructor"||c=="prototype")&&(d=(l||{})[c]);return{parent:l,key:c,value:d}},r.prototype.get=function(o){return this.evaluate(o).value},r.prototype.set=function(o,l){var c=this.evaluate(o);c.parent&&(c.parent[c.key]=l)},r.prototype.push=function(o){this.tokens.push(o)},r.prototype.add=function(o){var l=this.tokens.concat(String(o));return new r(l)},r})();return ea.Pointer=n,ea}var hn={},jy={},jT;function yP(){return jT||(jT=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.clone=e.objectType=e.hasOwnProperty=void 0,e.hasOwnProperty=Object.prototype.hasOwnProperty;function t(o){return o===void 0?"undefined":o===null?"null":Array.isArray(o)?"array":typeof o}e.objectType=t;function n(o){return o!=null&&typeof o=="object"}function r(o){if(!n(o))return o;if(o.constructor==Array){for(var l=o.length,c=new Array(l),d=0;d<l;d++)c[d]=r(o[d]);return c}if(o.constructor==Date){var f=new Date(+o);return f}var p={};for(var m in o)e.hasOwnProperty.call(o,m)&&(p[m]=r(o[m]));return p}e.clone=r})(jy)),jy}var jr={},CT;function xP(){if(CT)return jr;CT=1,Object.defineProperty(jr,"__esModule",{value:!0}),jr.diffAny=jr.diffObjects=jr.diffArrays=jr.intersection=jr.subtract=jr.isDestructive=void 0;var e=yP();function t(m){var g=m.op;return g==="remove"||g==="replace"||g==="copy"||g==="move"}jr.isDestructive=t;function n(m,g){var x={};for(var b in m)e.hasOwnProperty.call(m,b)&&m[b]!==void 0&&(x[b]=1);for(var w in g)e.hasOwnProperty.call(g,w)&&g[w]!==void 0&&delete x[w];return Object.keys(x)}jr.subtract=n;function r(m){for(var g=m.length,x={},b=0;b<g;b++){var w=m[b];for(var j in w)e.hasOwnProperty.call(w,j)&&w[j]!==void 0&&(x[j]=(x[j]||0)+1)}for(var j in x)x[j]<g&&delete x[j];return Object.keys(x)}jr.intersection=r;function o(m){return m.op==="add"}function l(m){return m.op==="remove"}function c(m,g){return{operations:m.operations.concat(g),cost:m.cost+1}}function d(m,g,x,b){b===void 0&&(b=p);var w={"0,0":{operations:[],cost:0}};function j(D,P){var A="".concat(D,",").concat(P),k=w[A];if(k===void 0){if(D>0&&P>0&&!b(m[D-1],g[P-1],x.add(String(D-1))).length)k=j(D-1,P-1);else{var M=[];if(D>0){var $=j(D-1,P),U={op:"remove",index:D-1};M.push(c($,U))}if(P>0){var J=j(D,P-1),Z={op:"add",index:D-1,value:g[P-1]};M.push(c(J,Z))}if(D>0&&P>0){var Y=j(D-1,P-1),H={op:"replace",index:D-1,original:m[D-1],value:g[P-1]};M.push(c(Y,H))}var Q=M.sort(function(O,I){return O.cost-I.cost})[0];k=Q}w[A]=k}return k}var C=isNaN(m.length)||m.length<=0?0:m.length,T=isNaN(g.length)||g.length<=0?0:g.length,E=j(C,T).operations,R=E.reduce(function(D,P){var A=D[0],k=D[1];if(o(P)){var M=P.index+1+k,$=M<C+k?String(M):"-",U={op:P.op,path:x.add($).toString(),value:P.value};return[A.concat(U),k+1]}else if(l(P)){var U={op:P.op,path:x.add(String(P.index+k)).toString()};return[A.concat(U),k-1]}else{var J=x.add(String(P.index+k)),Z=b(P.original,P.value,J);return[A.concat.apply(A,Z),k]}},[[],0])[0];return R}jr.diffArrays=d;function f(m,g,x,b){b===void 0&&(b=p);var w=[];return n(m,g).forEach(function(j){w.push({op:"remove",path:x.add(j).toString()})}),n(g,m).forEach(function(j){w.push({op:"add",path:x.add(j).toString(),value:g[j]})}),r([m,g]).forEach(function(j){w.push.apply(w,b(m[j],g[j],x.add(j)))}),w}jr.diffObjects=f;function p(m,g,x,b){if(b===void 0&&(b=p),m===g)return[];var w=(0,e.objectType)(m),j=(0,e.objectType)(g);return w=="array"&&j=="array"?d(m,g,x,b):w=="object"&&j=="object"?f(m,g,x,b):[{op:"replace",path:x.toString(),value:g}]}return jr.diffAny=p,jr}var ET;function HW(){if(ET)return hn;ET=1;var e=hn&&hn.__extends||(function(){var C=function(T,E){return C=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(R,D){R.__proto__=D}||function(R,D){for(var P in D)Object.prototype.hasOwnProperty.call(D,P)&&(R[P]=D[P])},C(T,E)};return function(T,E){if(typeof E!="function"&&E!==null)throw new TypeError("Class extends value "+String(E)+" is not a constructor or null");C(T,E);function R(){this.constructor=T}T.prototype=E===null?Object.create(E):(R.prototype=E.prototype,new R)}})();Object.defineProperty(hn,"__esModule",{value:!0}),hn.apply=hn.InvalidOperationError=hn.test=hn.copy=hn.move=hn.replace=hn.remove=hn.add=hn.TestError=hn.MissingError=void 0;var t=vP(),n=yP(),r=xP(),o=(function(C){e(T,C);function T(E){var R=C.call(this,"Value required at path: ".concat(E))||this;return R.path=E,R.name="MissingError",R}return T})(Error);hn.MissingError=o;var l=(function(C){e(T,C);function T(E,R){var D=C.call(this,"Test failed: ".concat(E," != ").concat(R))||this;return D.actual=E,D.expected=R,D.name="TestError",D}return T})(Error);hn.TestError=l;function c(C,T,E){if(Array.isArray(C))if(T=="-")C.push(E);else{var R=parseInt(T,10);C.splice(R,0,E)}else C[T]=E}function d(C,T){if(Array.isArray(C)){var E=parseInt(T,10);C.splice(E,1)}else delete C[T]}function f(C,T){var E=t.Pointer.fromJSON(T.path).evaluate(C);return E.parent===void 0?new o(T.path):(c(E.parent,E.key,(0,n.clone)(T.value)),null)}hn.add=f;function p(C,T){var E=t.Pointer.fromJSON(T.path).evaluate(C);return E.value===void 0?new o(T.path):(d(E.parent,E.key),null)}hn.remove=p;function m(C,T){var E=t.Pointer.fromJSON(T.path).evaluate(C);if(E.parent===null)return new o(T.path);if(Array.isArray(E.parent)){if(parseInt(E.key,10)>=E.parent.length)return new o(T.path)}else if(E.value===void 0)return new o(T.path);return E.parent[E.key]=(0,n.clone)(T.value),null}hn.replace=m;function g(C,T){var E=t.Pointer.fromJSON(T.from).evaluate(C);if(E.value===void 0)return new o(T.from);var R=t.Pointer.fromJSON(T.path).evaluate(C);return R.parent===void 0?new o(T.path):(d(E.parent,E.key),c(R.parent,R.key,E.value),null)}hn.move=g;function x(C,T){var E=t.Pointer.fromJSON(T.from).evaluate(C);if(E.value===void 0)return new o(T.from);var R=t.Pointer.fromJSON(T.path).evaluate(C);return R.parent===void 0?new o(T.path):(c(R.parent,R.key,(0,n.clone)(E.value)),null)}hn.copy=x;function b(C,T){var E=t.Pointer.fromJSON(T.path).evaluate(C);return(0,r.diffAny)(E.value,T.value,new t.Pointer).length?new l(E.value,T.value):null}hn.test=b;var w=(function(C){e(T,C);function T(E){var R=C.call(this,"Invalid operation: ".concat(E.op))||this;return R.operation=E,R.name="InvalidOperationError",R}return T})(Error);hn.InvalidOperationError=w;function j(C,T){switch(T.op){case"add":return f(C,T);case"remove":return p(C,T);case"replace":return m(C,T);case"move":return g(C,T);case"copy":return x(C,T);case"test":return b(C,T)}return new w(T)}return hn.apply=j,hn}var TT;function qW(){return TT||(TT=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.createTests=e.createPatch=e.applyPatch=e.Pointer=void 0;var t=vP();Object.defineProperty(e,"Pointer",{enumerable:!0,get:function(){return t.Pointer}});var n=HW(),r=xP();function o(p,m){return m.map(function(g){return(0,n.apply)(p,g)})}e.applyPatch=o;function l(p){function m(g,x,b){var w=p(g,x,b);return Array.isArray(w)?w:(0,r.diffAny)(g,x,b,m)}return m}function c(p,m,g){var x=new t.Pointer;return(g?l(g):r.diffAny)(p,m,x)}e.createPatch=c;function d(p,m){var g=t.Pointer.fromJSON(m).evaluate(p);if(g!==void 0)return{op:"test",path:m,value:g.value}}function f(p,m){var g=new Array;return m.filter(r.isDestructive).forEach(function(x){var b=d(p,x.path);if(b&&g.push(b),"from"in x){var w=d(p,x.from);w&&g.push(w)}}),g}e.createTests=f})(wy)),wy}var bP=qW();const GW="_removed_el5zk_1",QW="_added_el5zk_6",RT={removed:GW,added:QW};function WW(e){const{name:t,path:n,property:r,originalValue:o,revisedValue:l}=e,c=!!r?.type?.find(m=>m.code==="Attachment"),[d,f]=v.useState(c),p=()=>f(m=>!m);return a.jsx(a.Fragment,{children:c&&!d||!c?a.jsx(a.Fragment,{children:a.jsxs(fe.Tr,{children:[a.jsx(fe.Td,{children:t}),a.jsx(fe.Td,{className:RT.removed,children:o&&a.jsx(Xi,{path:n,property:r,propertyType:o.type,value:o.value,ignoreMissingValues:!0})}),a.jsx(fe.Td,{className:RT.added,children:l&&a.jsx(Xi,{path:n,property:r,propertyType:l.type,value:l.value,ignoreMissingValues:!0})})]})}):a.jsxs(fe.Tr,{children:[a.jsx(fe.Td,{children:t}),a.jsx(fe.Td,{colSpan:2,style:{textAlign:"right"},children:a.jsx(ke,{onClick:p,variant:"light",children:"Expand"})})]})})}const YW="_root_15xvr_1",KW={root:YW};function XW(e){const t=Re(),{original:n,revised:r}=e,[o,l]=v.useState(!1);v.useEffect(()=>{t.requestSchema(e.original.resourceType).then(()=>l(!0)).catch(console.log)},[t,e.original.resourceType]);const c=v.useMemo(()=>{if(!o)return null;const d=[ri(n)],f=[ri(r)],p=[],m=ZW(bP.createPatch(n,r));for(const g of m){const x=g.path,b=JW(x),w=eY(n.resourceType,b),j=g.op==="add"?void 0:cs(b,d),C=g.op==="remove"?void 0:cs(b,f);p.push({key:`op-${g.op}-${g.path}`,name:`${$n(g.op)} ${b}`,path:w?.path??n.resourceType+"."+b,property:w,originalValue:_T(w,j),revisedValue:_T(w,C)})}return p},[o,n,r]);return c?a.jsxs(fe,{className:KW.root,children:[a.jsx(fe.Thead,{children:a.jsxs(fe.Tr,{children:[a.jsx(fe.Th,{}),a.jsx(fe.Th,{children:"Before"}),a.jsx(fe.Th,{children:"After"})]})}),a.jsx(fe.Tbody,{children:c.map(d=>{const{key:f,...p}=d;return a.jsx(WW,{...p},f)})})]}):null}function ZW(e){const t=[];for(const n of e){const{op:r,path:o}=n;if(o.startsWith("/meta/author")||o.startsWith("/meta/compartment")||o.startsWith("/meta/lastUpdated")||o.startsWith("/meta/versionId"))continue;const l=e.filter(d=>d.op===r&&d.path===o).length,c={op:r,path:o};l>1&&(r==="add"||r==="remove")&&/\/[0-9-]+$/.test(o)&&(c.op="replace",c.path=o.replace(/\/[^/]+$/,"")),t.some(d=>d.op===c.op&&d.path===c.path)||t.push(c)}return t}function JW(e){const t=e.split("/").filter(Boolean);let n="";for(let r=0;r<t.length;r++){const o=t[r];o==="-"?n+=".last()":/^\d+$/.test(o)?n+=`[${o}]`:(r>0&&(n+="."),n+=o)}return n.endsWith(".url")&&(n=n.replace(/\.url$/,"")),n}function eY(e,t){try{return ym(e,{resourceType:"SearchParameter",base:[e],code:e+"."+t,expression:e+"."+t})?.elementDefinitions?.[0]}catch(n){console.warn("Failed to get element definition",{resourceType:e,fhirPath:t,err:n});return}}function _T(e,t){return t&&{type:Array.isArray(t)?t[0].type:t.type,value:tY(t,!!e?.isArray)}}function tY(e,t){const n=zU(e).flatMap(r=>r.value);return t?n:n[0]}function tS(e){const{profileUrl:t}=e,n=Re(),r=n.getAccessPolicy(),o=Gt(e.value),[l,c]=v.useState(!1);v.useEffect(()=>{if(o)if(t)n.requestProfileSchema(t,{expandProfile:!0}).then(()=>{Zc(t)?c(!0):console.error(`Schema not found for ${t}`)}).catch(f=>{console.error("Error in requestProfileSchema",f)});else{const f=o.resourceType;n.requestSchema(f).then(()=>{c(!0)}).catch(console.error)}},[n,t,o]);const d=v.useMemo(()=>o&&dA(o,Xs.READ,r),[r,o]);return!l||!o?null:a.jsx(fp,{path:o.resourceType,value:{type:o.resourceType,value:e.forceUseInput?e.value:o},profileUrl:t,ignoreMissingValues:e.ignoreMissingValues,accessPolicyResource:d})}const nY="_item_5q6yx_1",rY="_itemPadding_5q6yx_5",DT={item:nY,itemPadding:rY};function iY(e){return a.jsx(eu,{children:e.children})}function cl(e){const{resource:t,profile:n,padding:r,popupMenuItems:o,...l}=e,c=n??t.meta?.author,d=e.dateTime??t.meta?.lastUpdated;return a.jsxs(Sl,{"data-testid":"timeline-item",fill:!0,...l,children:[a.jsxs(ye,{justify:"space-between",gap:8,mx:"xs",my:"sm",children:[a.jsx(gs,{value:c,link:!0,size:"md"}),a.jsxs("div",{style:{flex:1},children:[a.jsx(Te,{size:"sm",children:a.jsx(jl,{c:"dark",fw:500,value:c,link:!0})}),a.jsxs(Te,{size:"xs",children:[a.jsx(mt,{c:"dimmed",to:e.resource,children:mr(d)}),a.jsx(Te,{component:"span",c:"dimmed",mx:8,children:"·"}),a.jsx(mt,{c:"dimmed",to:e.resource,children:e.resource.resourceType})]})]}),o&&a.jsxs(je,{position:"bottom-end",shadow:"md",width:200,children:[a.jsx(je.Target,{children:a.jsx(bn,{color:"gray",variant:"subtle",radius:"xl","aria-label":`Actions for ${_t(e.resource)}`,children:a.jsx(qH,{})})}),o]})]}),a.jsx(VA,{children:a.jsx("div",{className:Ot(DT.item,{[DT.itemPadding]:r}),children:e.children})})]})}function SP(e,t){e.sort((n,r)=>{const o=AT(n,t),l=AT(r,t);return o>l?1:o<l?-1:PT(n,t)-PT(r,t)})}function AT(e,t){if(!wP(e,t)){const n=e.priority;if(typeof n=="string")return{stat:4,asap:3,urgent:2}[n]??0}return 0}function PT(e,t){if(!wP(e,t)){if(e.resourceType==="Communication"&&e.sent)return new Date(e.sent).getTime();if((e.resourceType==="DiagnosticReport"||e.resourceType==="Media"||e.resourceType==="Observation")&&e.issued)return new Date(e.issued).getTime();if(e.resourceType==="DocumentReference"&&e.date)return new Date(e.date).getTime()}const n=e.meta?.lastUpdated;return n?new Date(n).getTime():0}function wP(e,t){return!!t&&e.resourceType===t.resourceType&&e.id===t.id}const oY="_pinnedComment_u08s5_1",aY={pinnedComment:oY};function _m(e){const t=Re(),n=t.getProfile(),r=v.useRef(null),o=Gt(e.value),[l,c]=v.useState(),[d,f]=v.useState([]),[p,m]=v.useState(10),g=e.loadTimelineResources,x=v.useRef(d);x.current=d;const b=v.useCallback(k=>{SP(k,o),k.reverse(),f(k)},[o]),w=v.useCallback(k=>{const M=[];for(const $ of k){if($.status!=="fulfilled")continue;const U=$.value;if(U.type==="history"&&c(U),U.entry)for(const J of U.entry)M.push(J.resource)}b(M)},[b]),j=v.useCallback(k=>b([...x.current,k]),[b]),C=v.useCallback(()=>{let k,M;"resourceType"in e.value?(k=e.value.resourceType,M=e.value.id):[k,M]=e.value.reference?.split("/"),g(t,k,M).then(w).catch(console.error)},[t,e.value,g,w]);v.useEffect(()=>C(),[C]);function T(k){!o||!e.createCommunication||t.createResource(e.createCommunication(o,n,k)).then(M=>j(M)).catch(console.error)}function E(k){!o||!e.createMedia||t.createResource(e.createMedia(o,n,k)).then(M=>j(M)).then(()=>Qs({id:"upload-notification",color:"teal",title:"Upload complete",message:"",icon:a.jsx(Po,{size:16}),autoClose:2e3})).catch(M=>Qs({id:"upload-notification",color:"red",title:"Upload error",message:Ye(M),icon:a.jsx(uT,{size:16}),autoClose:2e3}))}function R(){Ne({id:"upload-notification",loading:!0,title:"Initializing upload...",message:"Please wait...",autoClose:!1,withCloseButton:!1})}function D(k){Qs({id:"upload-notification",loading:!0,title:"Uploading...",message:hY(k),autoClose:!1,withCloseButton:!1})}function P(k){Qs({id:"upload-notification",color:"red",title:"Upload error",message:Ye(k),icon:a.jsx(uT,{size:16}),autoClose:2e3})}if(!o)return a.jsx(ar,{style:{width:"100%",height:"100%"},children:a.jsx(Fr,{})});const A=d.filter(k=>k).slice(0,p);return a.jsxs(iY,{children:[e.createCommunication&&a.jsx(Sl,{children:a.jsx(ut,{testid:"timeline-form",onSubmit:k=>{T(k.text);const M=r.current;M&&(M.value="",M.focus())},children:a.jsxs(ye,{gap:"xs",wrap:"nowrap",style:{width:"100%"},children:[a.jsx(gs,{value:n}),a.jsx(Ve,{name:"text",ref:r,placeholder:"Add comment",style:{width:"100%",maxWidth:300}}),a.jsx(bn,{type:"submit",radius:"xl",color:"blue",variant:"filled",children:a.jsx(yq,{size:16})}),a.jsx(Qb,{securityContext:Ht(o),onUpload:E,onUploadStart:R,onUploadProgress:D,onUploadError:P,children:k=>a.jsx(bn,{...k,radius:"xl",color:"blue",variant:"filled",children:a.jsx($b,{size:16})})})]})})}),A.map(k=>{const M=`${k.resourceType}/${k.id}/${k.meta?.versionId}`,$=e.getMenu?e.getMenu({primaryResource:o,currentResource:k,reloadTimeline:C}):void 0;if(k.resourceType===o.resourceType&&k.id===o.id)return a.jsx(sY,{history:l,resource:k,popupMenuItems:$},M);switch(k.resourceType){case"AuditEvent":return a.jsx(dY,{resource:k,popupMenuItems:$},M);case"Communication":return a.jsx(cY,{resource:k,popupMenuItems:$},M);case"DiagnosticReport":return a.jsx(fY,{resource:k,popupMenuItems:$},M);case"Media":return a.jsx(uY,{resource:k,popupMenuItems:$},M);default:return a.jsx(cl,{resource:k,padding:!0,children:a.jsx(tS,{value:k,ignoreMissingValues:!0})},M)}}),p<d.length&&a.jsx(ye,{justify:"center",pb:"lg",children:a.jsx(ke,{onClick:()=>m(p+10),children:"Show More"})})]})}function sY(e){const{history:t,resource:n,...r}=e,o=lY(t,n);return o?a.jsx(cl,{resource:n,padding:!0,...r,children:a.jsx(XW,{original:o,revised:e.resource})}):a.jsxs(cl,{resource:n,padding:!0,...r,children:[a.jsx("h3",{children:"Created"}),a.jsx(tS,{value:n,ignoreMissingValues:!0,forceUseInput:!0})]})}function lY(e,t){const n=e.entry??[],r=n.findIndex(o=>o.resource?.meta?.versionId===t.meta?.versionId);if(!(r>=n.length-1))return n[r+1].resource}function cY(e){const n=!e.resource.priority||e.resource.priority==="routine"?void 0:aY.pinnedComment;return a.jsx(cl,{resource:e.resource,profile:e.resource.sender,dateTime:e.resource.sent,padding:!0,className:n,popupMenuItems:e.popupMenuItems,children:a.jsx("p",{children:e.resource.payload?.[0]?.contentString})})}function uY(e){const t=e.resource.content?.contentType,n=t&&!t.startsWith("image/")&&!t.startsWith("video/")&&t!=="application/pdf";return a.jsx(cl,{resource:e.resource,padding:!!n,popupMenuItems:e.popupMenuItems,children:a.jsx(Qd,{value:e.resource.content})})}function dY(e){return a.jsx(cl,{resource:e.resource,padding:!0,popupMenuItems:e.popupMenuItems,children:a.jsx(ai,{children:a.jsx("pre",{children:e.resource.outcomeDesc})})})}function fY(e){return a.jsx(cl,{resource:e.resource,padding:!0,popupMenuItems:e.popupMenuItems,children:a.jsx(eS,{value:e.resource})})}function hY(e){if(e.lengthComputable){const t=100*e.loaded/e.total;return`Uploaded: ${Cy(e.loaded)} / ${Cy(e.total)} ${t.toFixed(2)}%`}return`Uploaded: ${Cy(e.loaded)}`}function Cy(e){if(e===0)return"0.00 B";const t=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,t)).toFixed(2)+" "+" KMGTP".charAt(t)+"B"}function pY(e){const{resource:t,...n}=e;return a.jsx(_m,{value:t,loadTimelineResources:async(r,o,l)=>{const c=`${o}/${l}`;return Promise.allSettled([r.readHistory(o,l),r.search("Task",{_filter:`based-on eq ${c} or focus eq ${c} or subject eq ${c}`,_count:100})])},...n})}function mY(e){const{encounter:t,...n}=e;return a.jsx(_m,{value:t,loadTimelineResources:async(r,o,l)=>Promise.allSettled([r.readHistory("Encounter",l),r.search("Communication","encounter=Encounter/"+l),r.search("Media","encounter=Encounter/"+l)]),createCommunication:(r,o,l)=>({resourceType:"Communication",status:"completed",encounter:Ht(r),subject:r.subject,sender:Ht(o),sent:new Date().toISOString(),payload:[{contentString:l}]}),createMedia:(r,o,l)=>({resourceType:"Media",status:"completed",encounter:Ht(r),subject:r.subject,operator:Ht(o),issued:new Date().toISOString(),content:l}),...n})}function gY(e){let t;try{t=PB(e.path,e.resource)}catch(n){return console.warn("FhirPathDisplay:",n),null}if(t.length>1)throw new Error(`Component "path" for "FhirPathDisplay" must resolve to a single element. Received ${t.length} elements [${JSON.stringify(t,null,2)}]`);return a.jsx(Xi,{value:t[0]||"",propertyType:e.propertyType})}function vY(e){return a.jsxs(Un,{title:"Export",closeButtonProps:{"aria-label":"Close"},opened:e.visible,onClose:e.onCancel,children:[a.jsxs(ce,{display:"flex",style:{justifyContent:"space-between"},children:[e.exportCsv&&a.jsx(kT,{text:"CSV",exportLogic:e.exportCsv,onCancel:e.onCancel}),e.exportTransactionBundle&&a.jsx(kT,{text:"Transaction Bundle",exportLogic:e.exportTransactionBundle,onCancel:e.onCancel})]}),a.jsx(Te,{style:{marginTop:"10px",marginLeft:"2px"},children:"Limited to 1000 records"})]})}function kT(e){return a.jsx(ke,{onClick:()=>{e.exportLogic(),e.onCancel()},children:`Export as ${e.text}`})}const yY={string:[de.EQUALS,de.NOT,de.CONTAINS,de.EXACT],fulltext:[de.EQUALS,de.NOT,de.CONTAINS,de.EXACT],token:[de.EQUALS,de.NOT],reference:[de.EQUALS,de.NOT],numeric:[de.EQUALS,de.NOT_EQUALS,de.GREATER_THAN,de.LESS_THAN,de.GREATER_THAN_OR_EQUALS,de.LESS_THAN_OR_EQUALS],quantity:[de.EQUALS,de.NOT_EQUALS,de.GREATER_THAN,de.LESS_THAN,de.GREATER_THAN_OR_EQUALS,de.LESS_THAN_OR_EQUALS],date:[de.EQUALS,de.NOT_EQUALS,de.GREATER_THAN,de.LESS_THAN,de.GREATER_THAN_OR_EQUALS,de.LESS_THAN_OR_EQUALS,de.STARTS_AFTER,de.ENDS_BEFORE,de.APPROXIMATELY],datetime:[de.EQUALS,de.NOT_EQUALS,de.GREATER_THAN,de.LESS_THAN,de.GREATER_THAN_OR_EQUALS,de.LESS_THAN_OR_EQUALS,de.STARTS_AFTER,de.ENDS_BEFORE,de.APPROXIMATELY],uri:[de.EQUALS,de.NOT,de.ABOVE,de.BELOW]},xY={eq:"equals",ne:"not equals",gt:"greater than",lt:"less than",ge:"greater than or equals",le:"less than or equals",sa:"starts after",eb:"ends before",ap:"approximately",sw:"starts with",contains:"contains",exact:"exact",text:"text",not:"not",above:"above",below:"below",in:"in","not-in":"not in","of-type":"of type",missing:"missing",present:"present",identifier:"identifier",iterate:"iterate"};function nS(e,t){return{...e,filters:t,offset:0,name:void 0}}function jP(e,t){return nS(e,(e.filters??[]).filter(n=>n.code!==t))}function Dm(e,t,n,r,o){const l=[];return e.filters&&l.push(...e.filters),l.push({code:t,operator:n,value:r??""}),nS(e,l)}function bY(e,t){if(!e.filters)return e;const n=[...e.filters];return n.splice(t,1),{...e,filters:n,name:void 0}}function SY(e,t){return rS(e,t,-1)}function wY(e,t){return rS(e,t,0)}function jY(e,t){return rS(e,t,1)}function rS(e,t,n){const r=new Date;r.setDate(r.getDate()+n),r.setHours(0,0,0,0);const o=new Date(r.getTime());return o.setDate(o.getDate()+1),o.setTime(o.getTime()-1),Am(e,t,r,o)}function CY(e,t){const n=new Date,r=new Date(n.getTime()+1440*60*1e3);return Am(e,t,n,r)}function EY(e,t){return iS(e,t,-1)}function TY(e,t){return iS(e,t,0)}function RY(e,t){return iS(e,t,1)}function iS(e,t,n){const r=new Date;r.setMonth(r.getMonth()+n),r.setDate(1),r.setHours(0,0,0,0);const o=new Date(r.getTime());return o.setMonth(o.getMonth()+1),o.setDate(1),o.setHours(0,0,0,0),o.setTime(o.getTime()-1),Am(e,t,r,o)}function _Y(e,t){const n=new Date;return n.setMonth(0),n.setDate(1),n.setHours(0,0,0,0),Am(e,t,n,new Date)}function Am(e,t,n,r){return e=jP(e,t),e=NT(e,t,de.GREATER_THAN_OR_EQUALS,n),e=NT(e,t,de.LESS_THAN_OR_EQUALS,r),e}function NT(e,t,n,r){return Dm(e,t,n,r.toISOString())}function OT(e,t,n=!0){return Dm(e,t,de.MISSING,n.toString())}function DY(e,t){return e.offset===t?e:{...e,offset:t,name:void 0}}function AY(e,t){const n=e.count??pm,r=(t-1)*n;return DY(e,r)}function PY(e,t,n){return t===kY(e)&&n!==void 0&&n===NY(e)?e:{...e,sortRules:[{code:t,descending:!!n}],name:void 0}}function kY(e){const t=e.sortRules;if(!t||t.length===0)return;const n=t[0].code;return n.startsWith("-")?n.substr(1):n}function NY(e){const t=e.sortRules;return!t||t.length===0?!1:!!t[0].descending}function OY(e){return yY[e.type]}function CP(e){return xY[e]??""}function ul(e){let t=e;return t.includes(".")&&(t=t.split(".").pop()),t==="versionId"?"Version ID":(t=t.replace("[x]",""),t=t.replace(/([A-Z])/g," $1"),t=t.replace(/[-_]/g," "),t=t.replace(/\s+/g," "),t=t.trim(),t.toLowerCase()==="id"?"ID":t.split(/\s/).map($n).join(" "))}function MY(e,t){const n=t.name;return n==="id"?a.jsx(mt,{to:`/${e.resourceType}/${e.id}`,children:e.id}):n==="meta.versionId"?e.meta?.versionId:n==="_lastUpdated"?mr(e.meta?.lastUpdated):`${e.resourceType}.${t.name}`===t.elementDefinition?.path?LY(e,t.elementDefinition):t.searchParams?.length===1&&t.name===t.searchParams[0].code?IY(e,t.searchParams[0]):null}function LY(e,t){const n=t.path?.split(".")?.pop()?.replaceAll("[x]","")??"",[r,o]=Em({type:e.resourceType,value:e},n);return r?a.jsx(Xi,{path:t.path,property:t,propertyType:o,value:r,maxWidth:200,ignoreMissingValues:!0,link:!1}):null}function IY(e,t){const n=cs(t.expression,[{type:e.resourceType,value:e}]);return!n||n.length===0?null:a.jsx(a.Fragment,{children:n.map((r,o)=>a.jsx(Xi,{propertyType:r.type,value:r.value,maxWidth:200,ignoreMissingValues:!0,link:!1},`${o}-${n.length}`))})}function zY(e){const t=v.useRef(!1),[n,r]=v.useState({search:JSON.parse(Ki(e.search))}),[o,l]=v.useState(!1);v.useEffect(()=>{r({search:e.search})},[e.search]);const c=v.useMemo(()=>{if(!e.visible)return[];const f=e.search.resourceType,p=zD(f),m=jb(f);return Ic($Y(p,m)).map(g=>({value:g,label:ul(g)}))},[e.visible,e.search.resourceType]);function d(f){r({search:{...n.search,fields:f}})}return a.jsx(Un,{title:"Fields",closeButtonProps:{"aria-label":"Close"},opened:e.visible,onClose:()=>{e.onCancel()},size:"auto",withOverlay:!0,closeOnClickOutside:!1,overlayProps:{onMouseDownCapture:()=>{t.current=o},onClick:()=>{t.current||e.onCancel(),t.current=!1},children:a.jsx("div",{"data-testid":"overlay-child"})},children:a.jsxs(Be,{children:[a.jsx(em,{style:{width:550},placeholder:"Select fields to display",data:c,value:n.search.fields??[],onChange:d,onDropdownOpen:()=>l(!0),onDropdownClose:()=>l(!1),maxDropdownHeight:"250px",clearButtonProps:{"aria-label":"Clear selection"},clearable:!0,searchable:!0}),a.jsx(ye,{justify:"flex-end",children:a.jsx(ke,{onClick:()=>e.onOk(n.search),children:"OK"})})]})})}function $Y(e,t){const n=[],r=new Set,o=new Set;for(const l of Object.keys(e.elements))n.push(l),r.add(l.toLowerCase()),o.add(ul(l));if(t)for(const l of Object.keys(t)){const c=ul(l);!r.has(l)&&!o.has(c)&&(n.push(l),r.add(l),o.add(c))}return n}function EP(e){const t=ym(e.resourceType,e.searchParam),n=e.name??"filter-value";switch(t.type){case dr.REFERENCE:return a.jsx(os,{name:n,defaultValue:e.defaultValue?{reference:e.defaultValue}:void 0,targetTypes:e.searchParam.target,autoFocus:e.autoFocus,onChange:r=>{r?e.onChange(r.reference):e.onChange("")}});case dr.BOOLEAN:return a.jsx(Pn,{name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultChecked:e.defaultValue==="true",autoFocus:e.autoFocus,onChange:r=>e.onChange(r.currentTarget.checked.toString())});case dr.DATE:return a.jsx(Ve,{type:"date",name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:r=>e.onChange(r.currentTarget.value)});case dr.DATETIME:return a.jsx(So,{name:n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:e.onChange});case dr.NUMBER:return a.jsx(Ve,{type:"number",name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:r=>e.onChange(r.currentTarget.value)});case dr.QUANTITY:return a.jsx(ll,{name:n,path:"",defaultValue:UY(e.defaultValue),autoFocus:e.autoFocus,onChange:r=>{r?e.onChange(`${r.value}`):e.onChange("")}});default:return a.jsx(Ve,{name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:r=>e.onChange(r.currentTarget.value),placeholder:"Search value"})}}function UY(e){if(e){const[t,n,r]=e.split("|");if(t)return{value:parseFloat(t),system:n,unit:r}}}function BY(e){const[t,n]=v.useState(ii(e.search)),r=v.useRef(t);r.current=t,v.useEffect(()=>{n(ii(e.search))},[e.search]);function o(f){n(Dm(r.current,f.code,f.operator,f.value))}const l=e.search.resourceType,c=jb(l)??{},d=t.filters||[];return a.jsx(Un,{title:"Filters",closeButtonProps:{"aria-label":"Close"},size:900,opened:e.visible,onClose:e.onCancel,children:a.jsxs(ut,{onSubmit:()=>e.onOk(r.current),children:[a.jsxs("div",{children:[a.jsxs("table",{children:[a.jsxs("colgroup",{children:[a.jsx("col",{style:{width:200}}),a.jsx("col",{style:{width:200}}),a.jsx("col",{style:{width:380}}),a.jsx("col",{style:{width:40}})]}),a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Field"}),a.jsx("th",{children:"Operation"}),a.jsx("th",{children:"Value"}),a.jsx("th",{})]})}),a.jsx("tbody",{children:d.map((f,p)=>a.jsx(VY,{id:`filter-${p}-row`,resourceType:l,searchParams:c,value:f,onChange:m=>{const g=[...d];g[p]=m,n(nS(r.current,g))},onDelete:()=>n(bY(r.current,p))},`filter-${p}-row`))})]}),a.jsx(Xb,{propertyDisplayName:"Filter",onClick:()=>o({})})]}),a.jsx(ye,{justify:"flex-end",mt:"xl",children:a.jsx(vr,{children:"OK"})})]})})}function VY(e){const t=e.value,n=v.useRef(t);n.current=t;function r(f){n.current.code=f,n.current.operator=de.EQUALS,n.current.value="",e.onChange(n.current)}function o(f){n.current.operator=f,n.current.value="",e.onChange(n.current)}function l(f){n.current.value=f,e.onChange(n.current)}const c=e.searchParams[t.code],d=c&&OY(c);return a.jsxs("tr",{children:[a.jsx("td",{children:a.jsx(on,{"data-testid":`${e.id}-filter-field`,defaultValue:e.value.code,onChange:f=>r(f.currentTarget.value),data:["",...Object.keys(e.searchParams).map(f=>({value:f,label:ul(f)}))]})}),a.jsx("td",{children:d&&a.jsx(on,{"data-testid":`${e.id}-filter-operation`,defaultValue:t.operator,onChange:f=>o(f.currentTarget.value),data:["",...d.map(f=>({value:f,label:CP(f)}))]},`${e.id}-filter-value-${e.value.code}`)}),a.jsx("td",{children:c&&t.operator&&a.jsx(EP,{name:`${e.id}-filter-value`,resourceType:e.resourceType,searchParam:c,defaultValue:t.value,onChange:l},`${e.id}-filter-value-${e.value.code}-${e.value.operator}`)}),a.jsx("td",{children:e.onDelete&&a.jsx(bn,{variant:"outline",color:"red",radius:"xl","aria-label":"Delete filter",onClick:e.onDelete,children:a.jsx(sl,{style:{width:"70%",height:"70%"},stroke:1.5})})})]})}function FY(e){const[t,n]=v.useState(e.defaultValue??"");if(!e.searchParam||!e.filter)return null;function r(){e.onOk({...e.filter,value:t})}return a.jsx(Un,{title:e.title,size:"xl",opened:e.visible,onClose:e.onCancel,children:a.jsx(ut,{onSubmit:r,children:a.jsxs(hr,{children:[a.jsx(hr.Col,{span:10,children:a.jsx(EP,{resourceType:e.resourceType,searchParam:e.searchParam,defaultValue:t,autoFocus:!0,onChange:n})}),a.jsx(hr.Col,{span:2,children:a.jsx(ke,{onClick:r,fullWidth:!0,children:"OK"})})]})})})}function HY(e){const{resourceType:t,filter:n}=e,r=Eo.types[t].searchParams?.[n.code];if(r){if(r.type==="reference"&&(n.operator===de.EQUALS||n.operator===de.NOT_EQUALS))return a.jsx(jl,{value:{reference:n.value}});const o=ym(t,r);if(n.code==="_lastUpdated"||o.type===dr.DATETIME)return a.jsx(a.Fragment,{children:mr(n.value)})}return a.jsx(a.Fragment,{children:n.value})}function qY(e){if(!e.searchParams)return null;function t(l,c){o(PY(e.search,l.code,c))}function n(l){o(jP(e.search,l.code))}function r(l,c){e.onPrompt(l,{code:l.code,operator:c,value:""})}function o(l){e.onChange(l)}return e.searchParams.length===1?a.jsx(GY,{search:e.search,searchParam:e.searchParams[0],onSort:t,onPrompt:r,onChange:o,onClear:n}):a.jsx(je.Dropdown,{children:e.searchParams.map(l=>a.jsx(je.Item,{children:ul(l.code)},l.code))})}function GY(e){switch(e.searchParam.type){case"date":return a.jsx(QY,{...e});case"number":case"quantity":return a.jsx(WY,{...e});case"reference":return a.jsx(YY,{...e});case"string":return a.jsx(KY,{...e});case"token":case"uri":return a.jsx(XY,{...e});default:return a.jsxs(a.Fragment,{children:["Unknown search param type: ",e.searchParam.type]})}}function QY(e){const{searchParam:t}=e,n=t.code;return a.jsxs(je.Dropdown,{children:[a.jsx(je.Item,{leftSection:a.jsx(Bb,{size:14}),onClick:()=>e.onSort(t,!1),children:"Sort Oldest to Newest"}),a.jsx(je.Item,{leftSection:a.jsx(Vb,{size:14}),onClick:()=>e.onSort(t,!0),children:"Sort Newest to Oldest"}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(Gd,{size:14}),onClick:()=>e.onPrompt(t,de.EQUALS),children:"Equals..."}),a.jsx(je.Item,{leftSection:a.jsx(qd,{size:14}),onClick:()=>e.onPrompt(t,de.NOT_EQUALS),children:"Does not equal..."}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx($A,{size:14}),onClick:()=>e.onPrompt(t,de.ENDS_BEFORE),children:"Before..."}),a.jsx(je.Item,{leftSection:a.jsx(zA,{size:14}),onClick:()=>e.onPrompt(t,de.STARTS_AFTER),children:"After..."}),a.jsx(je.Item,{leftSection:a.jsx(gH,{size:14}),onClick:()=>e.onPrompt(t,de.EQUALS),children:"Between..."}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(jY(e.search,n)),children:"Tomorrow"}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(wY(e.search,n)),children:"Today"}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(SY(e.search,n)),children:"Yesterday"}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(CY(e.search,n)),children:"Next 24 Hours"}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(RY(e.search,n)),children:"Next Month"}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(TY(e.search,n)),children:"This Month"}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(EY(e.search,n)),children:"Last Month"}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(Ka,{size:14}),onClick:()=>e.onChange(_Y(e.search,n)),children:"Year to date"}),a.jsx(Yd,{...e})]})}function WY(e){const{searchParam:t}=e;return a.jsxs(je.Dropdown,{children:[a.jsx(je.Item,{leftSection:a.jsx(Bb,{size:14}),onClick:()=>e.onSort(t,!1),children:"Sort Smallest to Largest"}),a.jsx(je.Item,{leftSection:a.jsx(Vb,{size:14}),onClick:()=>e.onSort(t,!0),children:"Sort Largest to Smallest"}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(Gd,{size:14}),onClick:()=>e.onPrompt(t,de.EQUALS),children:"Equals..."}),a.jsx(je.Item,{leftSection:a.jsx(qd,{size:14}),onClick:()=>e.onPrompt(t,de.NOT_EQUALS),children:"Does not equal..."}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(zA,{size:14}),onClick:()=>e.onPrompt(t,de.GREATER_THAN),children:"Greater than..."}),a.jsx(je.Item,{leftSection:a.jsx(px,{size:14}),onClick:()=>e.onPrompt(t,de.GREATER_THAN_OR_EQUALS),children:"Greater than or equal to..."}),a.jsx(je.Item,{leftSection:a.jsx($A,{size:14}),onClick:()=>e.onPrompt(t,de.LESS_THAN),children:"Less than..."}),a.jsx(je.Item,{leftSection:a.jsx(px,{size:14}),onClick:()=>e.onPrompt(t,de.LESS_THAN_OR_EQUALS),children:"Less than or equal to..."}),a.jsx(Yd,{...e})]})}function YY(e){const{searchParam:t}=e;return a.jsxs(je.Dropdown,{children:[a.jsx(je.Item,{leftSection:a.jsx(Gd,{size:14}),onClick:()=>e.onPrompt(t,de.EQUALS),children:"Equals..."}),a.jsx(je.Item,{leftSection:a.jsx(qd,{size:14}),onClick:()=>e.onPrompt(t,de.NOT),children:"Does not equal..."}),a.jsx(Yd,{...e})]})}function KY(e){const{searchParam:t}=e;return a.jsxs(je.Dropdown,{children:[a.jsx(je.Item,{leftSection:a.jsx(Bb,{size:14}),onClick:()=>e.onSort(t,!1),children:"Sort A to Z"}),a.jsx(je.Item,{leftSection:a.jsx(Vb,{size:14}),onClick:()=>e.onSort(t,!0),children:"Sort Z to A"}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(Gd,{size:14}),onClick:()=>e.onPrompt(t,de.EQUALS),children:"Equals..."}),a.jsx(je.Item,{leftSection:a.jsx(qd,{size:14}),onClick:()=>e.onPrompt(t,de.NOT),children:"Does not equal..."}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(wH,{size:14}),onClick:()=>e.onPrompt(t,de.CONTAINS),children:"Contains..."}),a.jsx(je.Item,{leftSection:a.jsx(bH,{size:14}),onClick:()=>e.onPrompt(t,de.EQUALS),children:"Does not contain..."}),a.jsx(Yd,{...e})]})}function XY(e){const{searchParam:t}=e;return a.jsxs(je.Dropdown,{children:[a.jsx(je.Item,{leftSection:a.jsx(Gd,{size:14}),onClick:()=>e.onPrompt(t,de.EQUALS),children:"Equals..."}),a.jsx(je.Item,{leftSection:a.jsx(qd,{size:14}),onClick:()=>e.onPrompt(t,de.NOT),children:"Does not equal..."}),a.jsx(Yd,{...e})]})}function Yd(e){const{searchParam:t}=e,n=t.code;return a.jsxs(a.Fragment,{children:[a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(fH,{size:14}),onClick:()=>e.onChange(OT(e.search,n)),children:"Missing"}),a.jsx(je.Item,{leftSection:a.jsx(uH,{size:14}),onClick:()=>e.onChange(OT(e.search,n,!1)),children:"Not missing"}),a.jsx(je.Divider,{}),a.jsx(je.Item,{leftSection:a.jsx(sl,{size:14}),onClick:()=>e.onClear(t),children:"Clear filters"})]})}function TP(e){switch(e){case"next":return{"aria-label":"Next page"};case"previous":return{"aria-label":"Previous page"};case"first":return{"aria-label":"First page"};case"last":return{"aria-label":"Last page"};default:return{}}}const ZY="_root_vlout_1",JY="_table_vlout_8",eK="_tr_vlout_12",tK="_control_vlout_22",nK="_icon_vlout_31",Yu={root:ZY,table:JY,tr:eK,control:tK,icon:nK};function rK(e){const t=e.resourceType,n=[];for(const r of e.fields||["id","_lastUpdated"])n.push(iK(t,r));return n}function iK(e,t){if(t==="_lastUpdated")return{name:"_lastUpdated",searchParams:[{resourceType:"SearchParameter",base:["Resource"],code:"_lastUpdated",name:"_lastUpdated",type:"date",expression:"Resource.meta.lastUpdated"}]};if(t==="meta.versionId")return{name:"meta.versionId",searchParams:[{resourceType:"SearchParameter",base:["Resource"],code:"_versionId",name:"_versionId",type:"token",expression:"Resource.meta.versionId"}]};const n=ms(e,t),r=tB(e,t.toLowerCase());if(n&&r)return{name:t,elementDefinition:n,searchParams:[r]};if(n){const o=jb(e);let l;if(o){const c=new RegExp(`${e}\\.${t.replaceAll("[x]","")}([^\\w-]|$)`);l=Object.values(o).filter(d=>!!d.expression&&c.test(d?.expression)),l.length===0&&(l=void 0)}return{name:t,elementDefinition:n,searchParams:l}}if(r){const o=ym(e,r);return{name:t,elementDefinition:o.elementDefinitions?.[0],searchParams:[r]}}return{name:t}}class oK extends Event{constructor(t){super("change"),this.definition=t}}class aK extends Event{constructor(t){super("load"),this.response=t}}class hp extends Event{constructor(t,n){super("click"),this.resource=t,this.browserEvent=n}}function nu(e){const t=Re(),[n,r]=v.useState(),{search:o,onLoad:l}=e,[c,d]=v.useState(o);Co(o,c)||d(o);const[f,p]=v.useState({selected:{},fieldEditorVisible:!1,filterEditorVisible:!1,exportDialogVisible:!1,filterDialogVisible:!1}),m=v.useRef(f);m.current=f;const g=c.total??"accurate",x=v.useCallback(H=>{r(void 0),t.requestSchema(c.resourceType).then(()=>t.search(c.resourceType,is({...c,total:g,fields:void 0}),H)).then(Q=>{p({...m.current,searchResponse:Q}),l&&l(new aK(Q))}).catch(Q=>{p({...m.current,searchResponse:void 0}),r(qt(Q))})},[t,c,g,l]),b=v.useCallback(()=>{p({...m.current,searchResponse:void 0}),x({cache:"reload"})},[x]);v.useEffect(()=>{x()},[x]);function w(H,Q){H.stopPropagation();const I=H.target.checked,z={...m.current.selected};I?z[Q]=!0:delete z[Q],p({...m.current,selected:z})}function j(H){H.stopPropagation();const O=H.target.checked,I={},z=m.current.searchResponse;O&&z?.entry&&z.entry.forEach(F=>{F.resource?.id&&(I[F.resource.id]=!0)}),p({...m.current,selected:I})}function C(){const H=m.current;if(!H.searchResponse?.entry||H.searchResponse.entry.length===0)return!1;for(const Q of H.searchResponse.entry)if(Q.resource?.id&&!H.selected[Q.resource.id])return!1;return!0}function T(H){e.onChange&&e.onChange(new oK(H))}function E(H,Q){if(HA(H.target)||H.button===2)return;cn(H);const O=FA(H);!O&&e.onClick&&e.onClick(new hp(Q,H)),O&&e.onAuxClick&&e.onAuxClick(new hp(Q,H))}function R(){return!!(e.onExport??e.onExportCsv??e.onExportTransactionBundle)}if(n)return a.jsx(yr,{outcome:n});if(!ID(c.resourceType))return a.jsx(ar,{style:{width:"100%",height:"100%"},children:a.jsx(Fr,{})});const D=e.checkboxesEnabled,P=rK(c),A=c.resourceType,k=f.searchResponse,$=k?.entry?.map(H=>H.resource),U="subtle",J="gray",Z=16,Y=window.innerWidth<768;return a.jsxs("div",{className:Yu.root,"data-testid":"search-control",children:[!e.hideToolbar&&a.jsxs(ye,{justify:"space-between",mb:"xl",children:[a.jsxs(ye,{gap:2,children:[a.jsx(ke,{size:"compact-md",variant:U,color:J,leftSection:a.jsx(LH,{size:Z}),onClick:()=>p({...m.current,fieldEditorVisible:!0,dialogOpenTime:Date.now()}),children:"Fields"}),a.jsx(ke,{size:"compact-md",variant:U,color:J,leftSection:a.jsx(rq,{size:Z}),onClick:()=>p({...m.current,filterEditorVisible:!0,dialogOpenTime:Date.now()}),children:"Filters"}),e.onNew&&a.jsx(ke,{size:"compact-md",variant:U,color:J,leftSection:a.jsx(tq,{size:Z}),onClick:e.onNew,children:"New..."}),!Y&&R()&&a.jsx(ke,{size:"compact-md",variant:U,color:J,leftSection:a.jsx(Jq,{size:Z}),onClick:e.onExport?e.onExport:()=>p({...m.current,exportDialogVisible:!0,dialogOpenTime:Date.now()}),children:"Export..."}),!Y&&e.onDelete&&a.jsx(ke,{size:"compact-md",variant:U,color:J,leftSection:a.jsx(wm,{size:Z}),onClick:()=>e.onDelete(Object.keys(f.selected)),children:"Delete..."}),!Y&&e.onBulk&&a.jsx(ke,{size:"compact-md",variant:U,color:J,leftSection:a.jsx(pH,{size:Z}),onClick:()=>e.onBulk(Object.keys(f.selected)),children:"Bulk..."})]}),a.jsxs(ye,{gap:2,children:[k&&a.jsxs(Te,{size:"xs",c:"dimmed","data-testid":"count-display",children:[RP(c,k).toLocaleString(),"-",dK(c,k).toLocaleString(),k.total!==void 0&&` of ${c.total==="estimate"?"~":""}${k.total?.toLocaleString()}`]}),a.jsx(bn,{variant:U,color:J,title:"Refresh",onClick:b,children:a.jsx(BA,{size:Z})})]})]}),a.jsxs(fe,{className:Yu.table,children:[a.jsxs(fe.Thead,{children:[a.jsxs(fe.Tr,{children:[D&&a.jsx(fe.Th,{children:a.jsx("input",{type:"checkbox",value:"checked","aria-label":"all-checkbox","data-testid":"all-checkbox",checked:C(),onChange:H=>j(H)})}),P.map(H=>a.jsx(fe.Th,{children:a.jsxs(je,{shadow:"md",width:240,position:"bottom-end",children:[a.jsx(je.Target,{children:a.jsx(sr,{className:Yu.control,p:2,children:a.jsxs(ye,{justify:"space-between",wrap:"nowrap",children:[a.jsx(Te,{fw:500,children:ul(H.name)}),a.jsx(ar,{className:Yu.icon,children:a.jsx(rH,{size:14,stroke:1.5})})]})})}),a.jsx(qY,{search:c,searchParams:H.searchParams,onPrompt:(Q,O)=>{p({...m.current,filterDialogVisible:!0,filterDialogSearchParam:Q,filterDialogFilter:O,dialogOpenTime:Date.now()})},onChange:Q=>{T(Q)}})]})},H.name))]}),!e.hideFilters&&a.jsxs(fe.Tr,{children:[D&&a.jsx(fe.Th,{}),P.map(H=>a.jsx(fe.Th,{children:H.searchParams&&a.jsx(lK,{resourceType:A,searchParams:H.searchParams,filters:c.filters})},H.name))]})]}),a.jsx(fe.Tbody,{children:$?.map(H=>H&&a.jsxs(fe.Tr,{className:Yu.tr,"data-testid":"search-control-row",onClick:Q=>E(Q,H),onAuxClick:Q=>E(Q,H),children:[D&&a.jsx(fe.Td,{children:a.jsx("input",{type:"checkbox",value:"checked","data-testid":"row-checkbox","aria-label":`Checkbox for ${H.id}`,checked:!!f.selected[H.id],onChange:Q=>w(Q,H.id)})}),P.map(Q=>a.jsx(fe.Td,{children:MY(H,Q)},Q.name))]},H.id))})]}),!$?.length&&a.jsx(eu,{children:a.jsx(ar,{style:{height:150},children:a.jsx(Te,{size:"xl",c:"dimmed",children:"No results"})})}),k&&a.jsx(ar,{m:"md",p:"md",children:a.jsx(Oi,{value:cK(c),total:uK(c,k),onChange:H=>T(AY(c,H)),getControlProps:TP})}),a.jsx(zY,{search:c,visible:m.current.fieldEditorVisible,onOk:H=>{T(H),p({...m.current,fieldEditorVisible:!1})},onCancel:()=>{p({...m.current,fieldEditorVisible:!1})}},`search-field-editor-${f.dialogOpenTime}`),a.jsx(BY,{search:c,visible:m.current.filterEditorVisible,onOk:H=>{T(H),p({...m.current,filterEditorVisible:!1})},onCancel:()=>{p({...m.current,filterEditorVisible:!1})}},`search-filter-editor-${f.dialogOpenTime}`),a.jsx(vY,{visible:m.current.exportDialogVisible,exportCsv:e.onExportCsv,exportTransactionBundle:e.onExportTransactionBundle,onCancel:()=>{p({...m.current,exportDialogVisible:!1})}},`search-export-dialog-${f.dialogOpenTime}`),a.jsx(FY,{visible:m.current.filterDialogVisible,title:f.filterDialogSearchParam?.code?ul(f.filterDialogSearchParam.code):"",resourceType:A,searchParam:f.filterDialogSearchParam,filter:f.filterDialogFilter,defaultValue:"",onOk:H=>{T(Dm(c,H.code,H.operator,H.value)),p({...m.current,filterDialogVisible:!1})},onCancel:()=>{p({...m.current,filterDialogVisible:!1})}},`search-filter-dialog-${f.dialogOpenTime}`)]})}const sK=nu;function lK(e){const t=(e.filters??[]).filter(n=>e.searchParams.find(r=>r.code===n.code));return t.length===0?a.jsx("span",{children:"no filters"}):a.jsx(a.Fragment,{children:t.map(n=>a.jsxs("div",{children:[CP(n.operator)," ",a.jsx(HY,{resourceType:e.resourceType,filter:n})]},`filter-${n.code}-${n.operator}-${n.value}`))})}function cK(e){return Math.floor((e.offset??0)/(e.count??pm))+1}function uK(e,t){const n=e.count??pm,r=_P(e,t);return Math.ceil(r/n)}function RP(e,t){return Math.min(_P(e,t),(e.offset??0)+1)}function dK(e,t){return Math.max(RP(e,t)+(t.entry?.length??0)-1,0)}function _P(e,t){let n=t.total;return n===void 0&&(n=(e.offset??0)+(t.entry?.length??0)+(t.link?.some(r=>r.relation==="next")?1:0)),n}function fK(e){const t=Re(),[n,r]=v.useState(!1),[o,l]=v.useState(),{query:c,fields:d}=e,[f,p]=v.useState(),[m,g]=v.useState({}),x=v.useRef(f);x.current=f;const b=v.useRef({});b.current=m,v.useEffect(()=>{l(void 0),t.graphql(c).then(p).catch(R=>l(qt(R)))},[t,c]);function w(R,D){R.stopPropagation();const A=R.target.checked,k={...b.current};A?k[D]=!0:delete k[D],g(k)}function j(R){R.stopPropagation();const P=R.target.checked,A={},k=x.current?.data.ResourceList;P&&k&&k.forEach(M=>{M.id&&(A[M.id]=!0)}),g(A)}function C(){const R=x.current?.data.ResourceList;if(!R||R.length===0)return!1;for(const D of R)if(D.id&&!b.current[D.id])return!1;return!0}function T(R,D){HA(R.target)||(cn(R),R.button!==1&&e.onClick&&e.onClick(new hp(D,R)),R.button===1&&e.onAuxClick&&e.onAuxClick(new hp(D,R)))}if(v.useEffect(()=>{t.requestSchema(e.resourceType).then(()=>r(!0)).catch(console.log)},[t,e.resourceType]),!n)return a.jsx(Fr,{});const E=e.checkboxesEnabled;return a.jsxs("div",{onContextMenu:R=>cn(R),"data-testid":"search-control",children:[a.jsxs(fe,{children:[a.jsx(fe.Thead,{children:a.jsxs(fe.Tr,{children:[E&&a.jsx(fe.Th,{children:a.jsx("input",{type:"checkbox",value:"checked","aria-label":"all-checkbox","data-testid":"all-checkbox",checked:C(),onChange:R=>j(R)})}),d.map(R=>a.jsx(fe.Th,{children:R.name},R.name))]})}),a.jsx(fe.Tbody,{children:f?.data.ResourceList.map(R=>R&&a.jsxs(fe.Tr,{"data-testid":"search-control-row",onClick:D=>T(D,R),onAuxClick:D=>T(D,R),children:[E&&a.jsx(fe.Td,{children:a.jsx("input",{type:"checkbox",value:"checked","data-testid":"row-checkbox","aria-label":`Checkbox for ${R.id}`,checked:!!m[R.id],onChange:D=>w(D,R.id)})}),d.map(D=>a.jsx(fe.Td,{children:a.jsx(gY,{propertyType:D.propertyType,path:D.fhirPath,resource:R})},D.name))]},R.id))})]}),f?.data.ResourceList.length===0&&a.jsx("div",{"data-testid":"empty-search",children:"No results"}),o&&a.jsx("div",{"data-testid":"search-error",children:a.jsx("pre",{style:{textAlign:"left"},children:JSON.stringify(o,void 0,2)})}),e.onBulk&&a.jsx(ke,{onClick:()=>e.onBulk(Object.keys(b.current)),children:"Bulk..."})]})}const hK=v.memo(fK),pK="_root_1fbwr_1",mK="_entry_1fbwr_8",gK="_key_1fbwr_13",vK="_value_1fbwr_20",Pm={root:pK,entry:mK,key:gK,value:vK};function ht(e){return a.jsx(ai,{children:a.jsx("div",{className:Pm.root,children:e.children})})}ht.Entry=function(t){return a.jsx("div",{className:Pm.entry,children:t.children})};ht.Key=function(t){return a.jsx("div",{className:Pm.key,children:t.children})};ht.Value=function(t){return a.jsx("div",{className:Pm.value,children:t.children})};function yK(e){const{group:t}=e;return a.jsx(Tr,{withBorder:!0,radius:"md",p:"xs",display:"flex",style:{alignItems:"center",justifyContent:"center"},children:a.jsxs(ye,{children:[t.measureScore&&a.jsx(SK,{group:t}),!t.measureScore&&a.jsx(bK,{group:t})]})})}function xK(e){const{measure:t}=e;return a.jsxs(a.Fragment,{children:[a.jsx(Te,{fz:"md",fw:500,mb:8,children:t.title}),a.jsx(Te,{fz:"xs",c:"dimmed",mb:8,children:t.subtitle})]})}function bK(e){const{group:t}=e,n=t.population,r=n?.find(f=>ls(f.code)==="numerator"),o=n?.find(f=>ls(f.code)==="denominator"),l=r?.count,c=o?.count;if(c===0)return a.jsxs(ce,{children:[a.jsx(Ie,{order:3,children:"Not Applicable"}),a.jsx(Te,{children:`Denominator: ${c}`})]});if(l===void 0||c===void 0)return a.jsxs(ce,{children:[a.jsx(Ie,{order:3,children:"Insufficient Data"}),a.jsx(Te,{children:`Numerator: ${l}`}),a.jsx(Te,{children:`Denominator: ${c}`})]});const d=l/c*100;return a.jsx(sm,{size:120,thickness:12,roundCaps:!0,sections:[{value:d,color:DP(d)}],label:a.jsx(jo,{justify:"center",children:a.jsxs(Te,{fw:700,fz:18,children:[l," / ",c]})})})}function SK(e){const{group:t}=e,n=t.measureScore?.unit??t.measureScore?.code;return a.jsx(a.Fragment,{children:n==="%"?a.jsx(sm,{size:120,thickness:12,roundCaps:!0,sections:[{value:wK(t),color:DP(t?.measureScore?.value??0)}],label:a.jsx(jo,{justify:"center",children:a.jsx(Te,{fw:700,fz:18,children:a.jsx(vd,{value:t.measureScore})})})}):a.jsx(jo,{h:120,align:"center",children:a.jsx(Ie,{order:3,children:a.jsx(vd,{value:t.measureScore})})})})}function wK(e){const t=e.measureScore?.value,n=e.measureScore?.unit;return t?t<=1&&n==="%"?t*100:t:0}function DP(e){return e<=33?"red":e<=67?"yellow":"green"}function jK(e){const t=Gt(e.measureReport),[n]=YF("Measure",{url:t?.measure});return t?a.jsxs(ce,{children:[n&&a.jsx(xK,{measure:n}),a.jsx(lm,{cols:{base:3,sm:1},spacing:{base:"md",sm:"sm"},children:t.group?.map((r,o)=>a.jsx(yK,{group:r},r.id??o))})]}):null}const Ey="patient-export",Ty="Patient Export",CK={everything:{operation:"$everything",extension:"json",contentType:ln.FHIR_JSON},summary:{operation:"$summary",extension:"json",contentType:ln.FHIR_JSON},ccda:{operation:"$ccda-export",extension:"xml",contentType:ln.CDA_XML},ccdaReferral:{operation:"$ccda-export",type:"referral",extension:"xml",contentType:ln.CDA_XML}};function EK(e){const t=Re(),{patient:n}=e,r=v.useCallback(async o=>{const l=rl(n),c=o.format,{operation:d,type:f,contentType:p,extension:m}=CK[c],g=t.fhirUrl("Patient",l,d),x={};f&&(x.type=f),o.author&&(x.author={reference:o.author}),o.authoredOn&&(x.authoredOn=Yb(o.authoredOn)),o.startDate&&(x.start=o.startDate),o.endDate&&(x.end=o.endDate),Ci.show({id:Ey,title:Ty,loading:!0,message:"Exporting...",autoClose:!1,withCloseButton:!1});try{const b=await t.post(g,x,void 0,{cache:"no-cache",headers:{Accept:p}}),w=`Patient-export-${l}-${new Date().toISOString().replaceAll(":","-")}.${m}`;TK(b,w,p),Ci.update({id:Ey,title:Ty,color:"green",message:"Done",icon:a.jsx(Po,{size:"1rem"}),loading:!1,autoClose:!0,withCloseButton:!0})}catch(b){Ci.update({id:Ey,title:Ty,color:"red",message:Ye(b),icon:a.jsx(sl,{size:"1rem"}),loading:!1,autoClose:!1,withCloseButton:!0})}},[t,n]);return a.jsx(ut,{onSubmit:r,children:a.jsxs(Be,{children:[a.jsx(Pt,{title:"Export Format",description:"Required",withAsterisk:!0,children:a.jsx(Id,{name:"format",data:[{label:"FHIR Everything",value:"everything"},{label:"Patient Summary",value:"summary"},{label:"C-CDA",value:"ccda"},{label:"C-CDA Referral",value:"ccdaReferral"}],fullWidth:!0})}),a.jsx(Pt,{title:"Author",description:"Optional author for composition. Default value is current user.",children:a.jsx(os,{name:"author",placeholder:"Author",targetTypes:["Organization","Practitioner","PractitionerRole"]})}),a.jsx(Pt,{title:"Authored On",description:"Optional date for composition authored on. Default value is current date.",children:a.jsx(So,{name:"authoredOn",placeholder:"Authored on"})}),a.jsx(Pt,{title:"Start Date",description:"The start date of care. If no start date is provided, all records prior to the end date are in scope.",children:a.jsx(So,{name:"startDate",placeholder:"Start date"})}),a.jsx(Pt,{title:"End Date",description:"The end date of care. If no end date is provided, all records subsequent to the start date are in scope.",children:a.jsx(So,{name:"endDate",placeholder:"End date"})}),a.jsx(ye,{justify:"right",children:a.jsx(vr,{children:"Request Export"})})]})})}function TK(e,t,n){const r=typeof e=="string"?e:JSON.stringify(e,null,2),o=new Blob([r],{type:n}),l=window.URL.createObjectURL(o),c=document.createElement("a");document.body.appendChild(c),c.style.display="none",c.href=l,c.download=t,c.click(),window.URL.revokeObjectURL(l)}function RK(e){if(e.gender==="male")return"blue";if(e.gender==="female")return"pink"}function AP(e){const t=Gt(e.patient);return t?a.jsxs(ht,{children:[a.jsx(gs,{value:t,size:"lg",color:RK(t)}),a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:"Name"}),a.jsx(ht.Value,{children:a.jsx(mt,{to:t,fw:500,children:t.name?a.jsx(Fb,{value:t.name[0],options:{use:!1}}):"[blank]"})})]}),t.birthDate&&a.jsxs(a.Fragment,{children:[a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:"DoB"}),a.jsx(ht.Value,{children:t.birthDate})]}),a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:"Age"}),a.jsx(ht.Value,{children:EU(t.birthDate)})]})]}),t.gender&&a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:"Gender"}),a.jsx(ht.Value,{children:t.gender})]}),t.address&&a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:"State"}),a.jsx(ht.Value,{children:t.address[0]?.state})]}),t.identifier?.map(n=>a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:n?.system}),a.jsx(ht.Value,{children:n?.value})]},`${n?.system}-${n?.value}`))]}):null}function _K(e){const{patient:t,...n}=e,r=v.useCallback((o,l,c)=>{const d=`${l}/${c}`,f=100;return Promise.allSettled([o.readHistory("Patient",c),o.search("Communication",{subject:d,_count:f}),o.search("Device",{patient:d,_count:f}),o.search("DeviceRequest",{patient:d,_count:f}),o.search("DiagnosticReport",{subject:d,_count:f}),o.search("Media",{subject:d,_count:f}),o.search("ServiceRequest",{subject:d,_count:f}),o.search("Task",{subject:d,_count:f})])},[]);return a.jsx(_m,{value:t,loadTimelineResources:r,createCommunication:(o,l,c)=>({resourceType:"Communication",status:"completed",subject:Ht(o),sender:Ht(l),sent:new Date().toISOString(),payload:[{contentString:c}]}),createMedia:(o,l,c)=>({resourceType:"Media",status:"completed",subject:Ht(o),operator:Ht(l),issued:new Date().toISOString(),content:c}),...n})}const DK="_section_pqpwm_1",AK="_hovering_pqpwm_7",vx={section:DK,hovering:AK};function PK(e){const t=Re(),n=Gt(e.value),[r,o]=v.useState(!1),[l,c]=v.useState(),[d,f]=v.useState(),[p,m]=v.useState();function g(){f(void 0)}function x(){c(void 0)}const b=v.useRef(p);if(b.current=p,v.useEffect(()=>{t.requestSchema("PlanDefinition").then(()=>o(!0)).catch(console.log)},[t]),v.useEffect(()=>(m(LK(n??{resourceType:"PlanDefinition",status:"active"})),document.addEventListener("mouseover",g),document.addEventListener("click",x),()=>{document.removeEventListener("mouseover",g),document.removeEventListener("click",x)}),[n]),!r||!p)return null;function w(j,C){m({...b.current,[j]:C})}return a.jsx("div",{children:a.jsxs(ut,{testid:"questionnaire-form",onSubmit:()=>e.onSubmit(p),children:[a.jsx(Ve,{label:"Plan Title",py:"md",defaultValue:p.title,onChange:j=>w("title",j.currentTarget.value)}),a.jsx(kK,{actions:p.action||[],selectedKey:l,setSelectedKey:c,hoverKey:d,setHoverKey:f,onChange:j=>w("action",j)}),a.jsx(vr,{children:"Save"})]})})}function kK(e){const t=v.useRef(e.actions);t.current=e.actions;function n(l){e.onChange(t.current.map(c=>c.id===l.id?l:c))}function r(l){e.onChange([...t.current,l]),e.setSelectedKey(l.id)}function o(l){e.onChange(t.current.filter(c=>c!==l))}return a.jsxs(Be,{gap:"md",className:vx.section,children:[e.actions.map(l=>a.jsx(NK,{action:l,selectedKey:e.selectedKey,setSelectedKey:e.setSelectedKey,hoverKey:e.hoverKey,setHoverKey:e.setHoverKey,onChange:n,onRemove:()=>o(l)},l.id)),a.jsx("div",{children:a.jsx(ke,{variant:"outline",onClick:l=>{cn(l),r({id:PP()})},children:"Add action"})})]})}function NK(e){const{action:t}=e,n=MK(t);function r(l){l.stopPropagation(),e.setSelectedKey(e.action.id)}function o(l){cn(l),e.setHoverKey(e.action.id)}return a.jsx("div",{onClick:r,onMouseOver:o,onFocus:o,children:a.jsx(OK,{action:t,actionType:n,onChange:e.onChange,selectedKey:e.selectedKey,hoverKey:e.hoverKey,onRemove:e.onRemove})})}function OK(e){const{action:t}=e,[n,r]=v.useState(e.actionType),o=e.selectedKey===e.action.id,l=e.hoverKey===e.action.id;function c(f,p){e.onChange({...t,[f]:p})}const d=Ot(vx.section,{[vx.hovering]:l&&!o});return a.jsxs(Tr,{"data-testid":t.id,className:d,p:0,radius:"sm",withBorder:!0,children:[a.jsxs(jo,{w:"100%",p:"xs",bg:"gray.0",gap:"md",align:"center",justify:"space-between",children:[a.jsx(Ve,{w:"100%",name:`actionTitle-${t.id}`,defaultValue:t.title,placeholder:"Title",onChange:f=>c("title",f.currentTarget.value)}),a.jsx(hs,{"data-testid":"close-button",onClick:e.onRemove})]}),o&&a.jsxs(Be,{gap:"xl",p:"md",children:[a.jsx(ce,{children:a.jsx(Ve,{label:"Task Description",placeholder:"Enter task description",name:`actionDescription-${t.id}`,defaultValue:t.description,onChange:f=>c("description",f.currentTarget.value)})}),a.jsx(ce,{children:a.jsx(on,{label:"Type of Action",value:n,onChange:f=>{const p=f.currentTarget.value==="standard"?void 0:f.currentTarget.value;r(p),e.onChange({...e.action,definitionCanonical:p==="standard"?void 0:e.action.definitionCanonical})},data:[{value:"standard",label:"Standard task"},{value:"questionnaire",label:"Task with Questionnaire"},{value:"activitydefinition",label:"Task with Activity Definition"}]})}),n==="questionnaire"&&a.jsxs(Be,{gap:0,children:[a.jsxs(ye,{gap:0,mb:"xs",children:[a.jsx(Te,{fw:600,children:"Select questionnaire"}),a.jsx(Te,{c:"red",children:"*"})]}),a.jsxs(Te,{size:"sm",c:"dimmed",mb:"sm",children:["Questionnaire to be shown in the task in Encounter view. You can create new one from"," ",a.jsx(Dt,{href:"/Questionnaire",target:"_blank",c:"blue",children:"questionnaires list"})]}),a.jsx(MT,{resourceType:"Questionnaire",action:t,onChange:e.onChange})]}),n==="activitydefinition"&&a.jsxs(Be,{gap:0,children:[a.jsxs(ye,{gap:0,mb:"xs",children:[a.jsx(Te,{fw:600,children:"Select activity definition"}),a.jsx(Te,{c:"red",children:"*"})]}),a.jsxs(Te,{size:"sm",c:"dimmed",mb:"sm",children:["ActivityDefinition.kind resource to be shown in the task in Encounter view. You can create new one from"," ",a.jsx(Dt,{href:"/ActivityDefinition",target:"_blank",c:"blue",children:"activity definitions list"})]}),a.jsx(MT,{resourceType:"ActivityDefinition",action:t,onChange:e.onChange})]})]})]})}function MT(e){const{id:t,definitionCanonical:n}=e.action,r=n?.startsWith(e.resourceType+"/")?{reference:n}:void 0;return a.jsx(wl,{name:t,resourceType:e.resourceType,defaultValue:r,onChange:o=>{o?e.onChange({...e.action,definitionCanonical:_t(o)}):e.onChange({...e.action,definitionCanonical:void 0})}})}function MK(e){return e.definitionCanonical?.startsWith("Questionnaire")?"questionnaire":e.definitionCanonical?.startsWith("ActivityDefinition")?"activitydefinition":"standard"}let Ry=1;function PP(e){if(e){if(e.startsWith("id-")){const t=parseInt(e.substring(3),10);isNaN(t)||(Ry=Math.max(Ry,t+1))}return e}return"id-"+Ry++}function LK(e){return{...e,action:kP(e.action)}}function kP(e){if(e)return e.map(t=>({...t,id:PP(t.id),action:kP(t.action)}))}const el=30,pp=50;function mp(e){const t=e.formState,n=e.item,r=e.responseItem;function o(g){t&&e.context&&t.onChangeAnswer(e.context,e.item,g)}const l=n.type;if(!l)return null;const c=n.linkId;if(!c)return null;let d;n.initial&&n.initial.length>0?d=n.initial[0]:n.answerOption&&n.answerOption.length>0&&(d=n.answerOption.find(g=>g.initialSelected));const f=aS(r,e.index)??Lb(d),p=Do(r,`${Ji}/fhir/StructureDefinition/questionnaire-validationError`);let m=null;switch(l){case xt.display:m=a.jsx("p",{children:e.item.text},e.item.linkId);break;case xt.boolean:m=a.jsx(uP,{title:e.item.text,htmlFor:e.item.linkId,children:a.jsx(Pn,{id:e.item.linkId,name:e.item.linkId,required:e.required??n.required,defaultChecked:f?.value,onChange:g=>o([{valueBoolean:g.currentTarget.checked}])})},e.item.linkId);break;case xt.decimal:m=a.jsx(Ve,{type:"number",step:"any",id:c,name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>o(g.currentTarget.value===""?[]:[{valueDecimal:g.currentTarget.valueAsNumber}])});break;case xt.integer:m=a.jsx(Ve,{type:"number",step:1,id:c,name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>o(g.currentTarget.value===""?[]:[{valueInteger:g.currentTarget.valueAsNumber}])});break;case xt.date:m=a.jsx(Ve,{type:"date",id:c,name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>o([{valueDate:g.currentTarget.value}])});break;case xt.dateTime:m=a.jsx(So,{name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>o([{valueDateTime:g}])});break;case xt.time:m=a.jsx(Ve,{type:"time",id:c,name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>o([{valueTime:g.currentTarget.value}])});break;case xt.string:case xt.url:m=a.jsx(Ve,{id:c,name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>{const x=g.currentTarget.value;o(x===""?[]:[{valueString:x}])}});break;case xt.text:m=a.jsx(vl,{id:c,name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>{const x=g.currentTarget.value;o(x===""?[]:[{valueString:x}])}});break;case xt.attachment:m=a.jsx(ye,{py:4,children:a.jsx(YA,{path:"",name:c,defaultValue:f?.value,onChange:g=>o([{valueAttachment:g}])})});break;case xt.reference:m=a.jsx(os,{name:c,required:e.required??n.required,targetTypes:AA(n),searchCriteria:$F(n,t?.subject,t?.encounter),defaultValue:f?.value,onChange:g=>o([{valueReference:g}])});break;case xt.quantity:m=a.jsx(ll,{path:"",name:c,required:e.required??n.required,defaultValue:f?.value,onChange:g=>o([{valueQuantity:g}]),disableWheel:!0});break;case xt.choice:case xt.openChoice:FK(n)?m=a.jsx(UK,{name:c,item:n,required:e.required??n.required,initial:d,response:r,onChangeAnswer:g=>o(g)}):VK(n)||n.answerValueSet&&!HK(n)?m=a.jsx(IK,{name:c,item:n,required:e.required??n.required,initial:d,response:r,onChangeAnswer:g=>o(g)}):m=a.jsx($K,{name:c,item:n,required:e.required??n.required,initial:d,response:r,onChangeAnswer:g=>o(g)});break;default:return null}return a.jsxs(a.Fragment,{children:[m,p?.valueString&&a.jsx(Te,{c:"red",size:"lg",mt:4,children:p.valueString})]})}function IK(e){const{name:t,item:n,required:r,initial:o,onChangeAnswer:l,response:c}=e;if(!n.answerOption?.length&&!n.answerValueSet)return a.jsx(oS,{});const d=Lb(o),f=aS(c)??d,p=MP(c),m=n.repeats||qK(n);if(n.answerValueSet)return a.jsx(jm,{name:t,placeholder:"Select items",binding:n.answerValueSet,maxValues:m?void 0:1,required:r,onChange:g=>{m?g.length===0?l([{}]):l(g.map(x=>({valueCoding:x}))):l([{valueCoding:g[0]}])},defaultValue:f?.value});if(m){const{propertyName:g,data:x}=GK(n);return a.jsx(em,{data:x,placeholder:"Select items",searchable:!0,defaultValue:p||[il(d)],required:r,onChange:b=>{if(b.length===0)l([{}]);else{const w=_A(b,g,n);l(w)}}})}else{const g=[""];if(n.answerOption)for(const x of n.answerOption){const b=To(x);g.push(il(b))}return a.jsx(on,{id:t,name:t,required:r,onChange:x=>{const b=x.currentTarget.selectedIndex;if(b===0){l([{}]);return}const w=n.answerOption[b-1],j=To(w),C="value"+$n(j.type);l([{[C]:j.value}])},defaultValue:Hd(f?.value)||f?.value,data:g})}}function zK(e,t){return e?t.valueSetExpand({url:e,count:el+1}).then(n=>n.expansion?.contains??[]):Promise.resolve([])}function NP(e){const t=Re(),[n,r]=v.useState([]),[o,l]=v.useState(!1);return v.useEffect(()=>{async function c(){if(e){l(!0);try{const d=await zK(e,t);r(d)}catch(d){console.error("Error loading value set:",d)}finally{l(!1)}}}c().catch(console.error)},[e,t]),[n,o]}function OP(e,t){return e.map((n,r)=>{const o=`${t}-valueset-${r}`,l={type:"Coding",value:{system:n.system,code:n.code,display:n.display}};return[o,l]})}function $K(e){const{name:t,item:n,required:r,initial:o,onChangeAnswer:l,response:c}=e,d=ms("QuestionnaireItemAnswerOption","value[x]"),f=Lb(o),[p,m]=NP(n.answerValueSet),g=[];let x;if(n.answerValueSet)g.push(...OP(p,t));else if(n.answerOption){const C=n.answerOption.slice(0,pp).map((T,E)=>{const R=`${t}-option-${E}`,D=To(T);return D?.value?(f&&Ki(D)===Ki(f)&&(x=R),[R,D]):null}).filter(T=>T!==null);g.push(...C)}const b=aS(c),w=BK(g,b);if(m)return a.jsx(Te,{children:"Loading options..."});if(g.length===0)return a.jsx(oS,{});const j=g.slice(0,el);return a.jsxs(a.Fragment,{children:[a.jsx(ur.Group,{name:t,value:w??x,required:r,onChange:C=>{const T=g.find(E=>E[0]===C);if(T){const E=T[1],R="value"+$n(E.type);l([{[R]:E.value}])}},children:j.map(([C,T])=>a.jsx(ur,{id:C,value:C,py:4,required:r,label:a.jsx(Xi,{property:d,propertyType:T.type,value:T.value})},C))}),(n.answerValueSet&&g.length>el||n.answerOption&&g.length>pp)&&a.jsxs(Te,{size:"sm",c:"dimmed",mt:"xs",children:["Showing first ",el," options"]})]})}function UK(e){const{name:t,item:n,onChangeAnswer:r,response:o}=e,l=ms("QuestionnaireItemAnswerOption","value[x]"),[c,d]=NP(n.answerValueSet),f=n.answerValueSet?(o?.answer?.map(w=>w.valueCoding)||[]).filter(w=>w!==void 0):MP(o),[p,m]=v.useState(f),g=[];if(n.answerValueSet)g.push(...OP(c,t));else if(n.answerOption){const w=n.answerOption.slice(0,pp).map((j,C)=>{const T=`${t}-option-${C}`,E=To(j);return E?.value?[T,E]:null}).filter(j=>j!==null);g.push(...w)}if(d)return a.jsx(Te,{children:"Loading options..."});if(g.length===0)return a.jsx(oS,{});const x=g.slice(0,el),b=(w,j)=>{if(n.answerValueSet){const C=p;let T;j?T=[...C,w.value]:T=C.filter(E=>!Co(E,w.value)),m(T),T.length===0?r([{}]):r(T.map(E=>({valueCoding:E})))}else{const C=p,T=il(w);let E;if(j?E=[...C,T]:E=C.filter(R=>R!==T),m(E),E.length===0)r([{}]);else{const R=_A(E,"value"+$n(w.type),n);r(R)}}};return a.jsxs(ye,{style:{flexDirection:"column",alignItems:"flex-start"},children:[x.map(([w,j])=>{const C=il(j),T=n.answerValueSet?p.some(E=>Co(E,j.value)):p.includes(C);return a.jsx(Pn,{id:w,label:a.jsx(Xi,{property:l,propertyType:j.type,value:j.value}),checked:T,onChange:E=>b(j,E.currentTarget.checked)},w)}),(n.answerValueSet&&g.length>el||n.answerOption&&g.length>pp)&&a.jsxs(Te,{size:"sm",c:"dimmed",children:["Showing first ",el," options"]})]})}function oS(){return a.jsx(Ve,{disabled:!0,placeholder:"No Answers Defined"})}function aS(e,t=0){return To(e?.answer?.[t]??{})}function MP(e){const t=e?.answer;return t?t.map(r=>To(r)).map(r=>Hd(r?.value)||r?.value).filter(Boolean):[]}function BK(e,t){return e.find(n=>Co(n[1].value,t?.value))?.[0]}function km(e,t){return!!e.extension?.some(n=>n.url===Ob&&n.valueCodeableConcept?.coding?.[0]?.code===t)}function VK(e){return km(e,"drop-down")}function FK(e){return km(e,"check-box")}function HK(e){return km(e,"radio-button")}function qK(e){return km(e,"multi-select")}function GK(e){if(e.answerOption?.length===0)return{propertyName:"",data:[]};const t=e.answerOption[0],n=To(t),r="value"+$n(n.type),o=(e.answerOption??[]).map(l=>{const c=To(l),d=il(c);return{value:d,label:d}});return{propertyName:r,data:o}}const QK="_section_my8o4_1",WK="_hovering_my8o4_10",YK="_editing_my8o4_14",KK="_questionBody_my8o4_20",XK="_topActions_my8o4_24",ZK="_bottomActions_my8o4_33",JK="_movementActions_my8o4_44",eX="_movementIcons_my8o4_56",tX="_columnAlignment_my8o4_60",nX="_linkIdInput_my8o4_65",rX="_typeSelect_my8o4_70",iX="_preserveBreaks_my8o4_74",ei={section:QK,hovering:WK,editing:YK,questionBody:KK,topActions:XK,bottomActions:ZK,movementActions:JK,movementIcons:eX,columnAlignment:tX,linkIdInput:nX,typeSelect:rX,preserveBreaks:iX};function oX(e){const t=Re(),n=Gt(e.questionnaire),[r,o]=v.useState(!1),[l,c]=v.useState(),[d,f]=v.useState(),[p,m]=v.useState();function g(){m(void 0)}function x(){f(void 0)}v.useEffect(()=>{t.requestSchema("Questionnaire").then(()=>o(!0)).catch(console.log)},[t]),v.useEffect(()=>(c(cX(n??{resourceType:"Questionnaire",status:"active"})),document.addEventListener("mouseover",g),document.addEventListener("click",x),()=>{document.removeEventListener("mouseover",g),document.removeEventListener("click",x)}),[n]);const b=(w,j)=>{c(w),e.autoSave&&!j&&e.onSubmit&&e.onSubmit(w)};return!r||!l?null:a.jsx("div",{children:a.jsxs(ut,{testid:"questionnaire-form",onSubmit:()=>e.onSubmit(l),children:[a.jsx(LP,{item:l,selectedKey:d,setSelectedKey:f,hoverKey:p,setHoverKey:m,onChange:b}),a.jsx(vr,{children:"Save"})]})})}function LP(e){const t=e.item,n=e.item,r=Ao(e.item),o=r||n.type===xt.group,l=n.linkId??"[untitled]",c=e.selectedKey===e.item.id,d=e.hoverKey===e.item.id,f=v.useRef(e.item);f.current=e.item;function p(R){cn(R),e.setSelectedKey(e.item.id)}function m(R){cn(R),e.setHoverKey(e.item.id)}function g(R){const D=f.current;e.onChange({...D,item:D.item?.map(P=>P.id===R.id?R:P)})}function x(R,D){e.onChange({...e.item,item:[...e.item.item??[],R]},D)}function b(R){e.onChange({...e.item,item:e.item.item?.filter(D=>D!==R)})}function w(R,D){e.onChange({...f.current,[R]:D})}function j(R){e.onChange({...e.item,...R})}function C(R){e.onChange({...e.item,item:e.item.item?.map(D=>D===R?{...D,repeats:!D.repeats}:D)})}function T(R,D){const P=fX(e.item.item,R,D);e.onChange({...e.item,item:P})}const E=Ot(ei.section,{[ei.editing]:c,[ei.hovering]:d&&!c});return a.jsxs("div",{"data-testid":n.linkId,className:E,onClick:p,onMouseOver:m,onFocus:m,children:[a.jsx("div",{className:ei.questionBody,children:c?a.jsxs(a.Fragment,{children:[r&&a.jsx(Ve,{size:"xl",defaultValue:t.title,onBlur:R=>w("title",R.currentTarget.value)}),!r&&a.jsx(vl,{autosize:!0,minRows:2,defaultValue:n.text,onBlur:R=>w("text",R.currentTarget.value)}),n.type==="reference"&&a.jsx(lX,{item:n,onChange:j}),DF(n)&&a.jsx(aX,{item:n,onChange:R=>j(R)})]}):a.jsxs(a.Fragment,{children:[t.title&&a.jsx(Ie,{children:t.title}),n.text&&a.jsx("div",{className:ei.preserveBreaks,children:n.text}),!o&&a.jsx(mp,{item:n,index:0,required:!1,responseItem:{linkId:n.linkId}})]})}),n.item?.map((R,D)=>a.jsx("div",{children:a.jsx(LP,{item:R,selectedKey:e.selectedKey,setSelectedKey:e.setSelectedKey,hoverKey:e.hoverKey,isFirst:D===0,isLast:D===(e.item.item??[]).length-1,setHoverKey:e.setHoverKey,onChange:g,onRemove:()=>b(R),onRepeatable:C,onMoveUp:()=>T(D,-1),onMoveDown:()=>T(D,1)})},R.id)),!o&&a.jsx("div",{className:ei.topActions,children:c?a.jsxs(a.Fragment,{children:[a.jsx(Ve,{size:"xs",className:ei.linkIdInput,defaultValue:n.linkId,onBlur:R=>w("linkId",R.currentTarget.value)}),!o&&a.jsx(on,{size:"xs",className:ei.typeSelect,defaultValue:n.type,onChange:R=>w("type",R.currentTarget.value),data:[{value:"display",label:"Display"},{value:"boolean",label:"Boolean"},{value:"decimal",label:"Decimal"},{value:"integer",label:"Integer"},{value:"date",label:"Date"},{value:"dateTime",label:"Date/Time"},{value:"time",label:"Time"},{value:"string",label:"String"},{value:"text",label:"Text"},{value:"url",label:"URL"},{value:"choice",label:"Choice"},{value:"open-choice",label:"Open Choice"},{value:"attachment",label:"Attachment"},{value:"reference",label:"Reference"},{value:"quantity",label:"Quantity"}]})]}):a.jsx("div",{children:l})}),!r&&a.jsx(ce,{className:ei.movementActions,children:a.jsxs(ce,{className:ei.columnAlignment,children:[!e.isFirst&&a.jsx(Dt,{href:"#",onClick:R=>{R.preventDefault(),e.onMoveUp&&e.onMoveUp()},children:a.jsx(lH,{"data-testid":"up-button",size:15,className:ei.movementIcons})}),!e.isLast&&a.jsx(Dt,{href:"#",onClick:R=>{R.preventDefault(),e.onMoveDown&&e.onMoveDown()},children:a.jsx(aH,{"data-testid":"down-button",size:15,className:ei.movementIcons})})]})}),a.jsxs("div",{className:ei.bottomActions,children:[o&&a.jsxs(a.Fragment,{children:[a.jsx(Dt,{href:"#",onClick:R=>{R.preventDefault(),x({id:dl(),linkId:bx("q"),type:"string",text:"Question"})},children:"Add item"}),a.jsx(Dt,{href:"#",onClick:R=>{R.preventDefault(),x({id:dl(),linkId:bx("g"),type:"group",text:"Group"},!0)},children:"Add group"})]}),r&&a.jsx(Dt,{href:"#",onClick:R=>{R.preventDefault(),x(dX(),!0)},children:"Add Page"}),c&&!r&&a.jsxs(a.Fragment,{children:[a.jsx(Dt,{href:"#",onClick:R=>{R.preventDefault(),e.onRepeatable&&e.onRepeatable(n)},children:n.repeats?"Remove Repeatable":"Make Repeatable"}),a.jsx(Dt,{href:"#",onClick:R=>{R.preventDefault(),e.onRemove&&e.onRemove()},children:"Remove"})]})]})]})}function aX(e){const t=ms("QuestionnaireItemAnswerOption","value[x]"),n=e.item.answerOption??[];return a.jsxs("div",{children:[e.item.answerValueSet!==void 0?a.jsx(Ve,{placeholder:"Enter Value Set",defaultValue:e.item.answerValueSet,onChange:r=>e.onChange({...e.item,answerValueSet:r.target.value})}):a.jsx(sX,{options:n,property:t,item:e.item,onChange:e.onChange}),a.jsxs(ce,{display:"flex",children:[a.jsx(Dt,{href:"#",onClick:r=>{cn(r),e.onChange({...e.item,answerValueSet:void 0,answerOption:[...n,{id:dl()}]})},children:"Add choice"}),a.jsx(cm,{w:"lg"}),a.jsx(Dt,{href:"#",onClick:r=>{cn(r),e.onChange({...e.item,answerOption:[],answerValueSet:""})},children:"Add value set"})]})]})}function sX(e){return a.jsx("div",{children:e.options.map(t=>{const[n,r]=Em({type:"QuestionnaireItemAnswerOption",value:t},"value");return a.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",width:"80%"},children:[a.jsx("div",{children:a.jsx(Wd,{name:"value[x]",path:"Questionnaire.answerOption.value[x]",property:e.property,defaultPropertyType:r,defaultValue:n,onChange:(o,l)=>{const c=[...e.options],d=c.findIndex(f=>f.id===t.id);c[d]={id:t.id,[l]:o},e.onChange({...e.item,answerOption:c})},outcome:void 0},t.id)}),a.jsx("div",{children:a.jsx(Dt,{href:"#",onClick:o=>{cn(o),e.onChange({...e.item,answerOption:e.options.filter(l=>l.id!==t.id)})},children:"Remove"})})]},t.id)})})}function lX(e){const t=AA(e.item)??[];return a.jsxs(a.Fragment,{children:[t.map((n,r)=>a.jsxs(ye,{children:[a.jsx(Gb,{name:"resourceType",placeholder:"Resource Type",defaultValue:n,onChange:o=>{e.onChange(Sy(e.item,t.map(l=>l===n?o:l)))}}),a.jsx(Dt,{href:"#",onClick:o=>{cn(o),e.onChange(Sy(e.item,t.filter(l=>l!==n)))},children:"Remove"})]},`${n}-${r}`)),a.jsx(Dt,{href:"#",onClick:n=>{cn(n),e.onChange(Sy(e.item,[...t,""]))},children:"Add Resource Type"})]})}let yx=1,xx=1;function bx(e){return e+yx++}function dl(){return"id-"+xx++}function cX(e){return{...e,id:e.id||dl(),item:IP(e.item)}}function IP(e){if(e)return e.forEach(t=>{t.id?.match(/^id-\d+$/)&&(xx=Math.max(xx,parseInt(t.id.substring(3),10)+1)),t.linkId?.match(/^q\d+$/)&&(yx=Math.max(yx,parseInt(t.linkId.substring(1),10)+1))}),e.map(t=>({...t,id:t.id||dl(),item:IP(t.item),answerOption:uX(t.answerOption)}))}function uX(e){if(e)return e.map(t=>({...t,id:t.id||dl()}))}function dX(){return{id:dl(),linkId:bx("s"),type:"group",text:"New Page",extension:[{url:Ob,valueCodeableConcept:{coding:[{system:"http://hl7.org/fhir/questionnaire-item-control",code:"page"}]}}]}}function fX(e,t,n){const r=e??[],o=t+n;if(o<0||o>=r.length)return r;const l=[...r];return[l[t],l[o]]=[l[o],l[t]],l}/*!
|
|
553
553
|
* Signature Pad v5.1.1 | https://github.com/szimek/signature_pad
|
|
554
554
|
* (c) 2025 Szymon Nowak | Released under the MIT license
|
|
555
555
|
*/var gp=class{x;y;pressure;time;constructor(e,t,n,r){if(isNaN(e)||isNaN(t))throw new Error(`Point is invalid: (${e}, ${t})`);this.x=+e,this.y=+t,this.pressure=n||0,this.time=r||Date.now()}distanceTo(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))}equals(e){return this.x===e.x&&this.y===e.y&&this.pressure===e.pressure&&this.time===e.time}velocityFrom(e){return this.time!==e.time?this.distanceTo(e)/(this.time-e.time):0}},hX=class zP{constructor(t,n,r,o,l,c){this.startPoint=t,this.control2=n,this.control1=r,this.endPoint=o,this.startWidth=l,this.endWidth=c}static fromPoints(t,n){const r=this.calculateControlPoints(t[0],t[1],t[2]).c2,o=this.calculateControlPoints(t[1],t[2],t[3]).c1;return new zP(t[1],r,o,t[2],n.start,n.end)}static calculateControlPoints(t,n,r){const o=t.x-n.x,l=t.y-n.y,c=n.x-r.x,d=n.y-r.y,f={x:(t.x+n.x)/2,y:(t.y+n.y)/2},p={x:(n.x+r.x)/2,y:(n.y+r.y)/2},m=Math.sqrt(o*o+l*l),g=Math.sqrt(c*c+d*d),x=f.x-p.x,b=f.y-p.y,w=m+g==0?0:g/(m+g),j={x:p.x+x*w,y:p.y+b*w},C=n.x-j.x,T=n.y-j.y;return{c1:new gp(f.x+C,f.y+T),c2:new gp(p.x+C,p.y+T)}}length(){let n=0,r,o;for(let l=0;l<=10;l+=1){const c=l/10,d=this.point(c,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),f=this.point(c,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(l>0){const p=d-r,m=f-o;n+=Math.sqrt(p*p+m*m)}r=d,o=f}return n}point(t,n,r,o,l){return n*(1-t)*(1-t)*(1-t)+3*r*(1-t)*(1-t)*t+3*o*(1-t)*t*t+l*t*t*t}},pX=class{_et;constructor(){try{this._et=new EventTarget}catch{this._et=document}}addEventListener(e,t,n){this._et.addEventListener(e,t,n)}dispatchEvent(e){return this._et.dispatchEvent(e)}removeEventListener(e,t,n){this._et.removeEventListener(e,t,n)}};function mX(e,t=250){let n=0,r=null,o,l,c;const d=()=>{n=Date.now(),r=null,o=e.apply(l,c),r||(l=null,c=[])};return function(...p){const m=Date.now(),g=t-(m-n);return l=this,c=p,g<=0||g>t?(r&&(clearTimeout(r),r=null),n=m,o=e.apply(l,c),r||(l=null,c=[])):r||(r=window.setTimeout(d,g)),o}}var gX=class Sx extends pX{constructor(t,n={}){super(),this.canvas=t,this.velocityFilterWeight=n.velocityFilterWeight||.7,this.minWidth=n.minWidth||.5,this.maxWidth=n.maxWidth||2.5,this.throttle=n.throttle??16,this.minDistance=n.minDistance??5,this.dotSize=n.dotSize||0,this.penColor=n.penColor||"black",this.backgroundColor=n.backgroundColor||"rgba(0,0,0,0)",this.compositeOperation=n.compositeOperation||"source-over",this.canvasContextOptions=n.canvasContextOptions??{},this._strokeMoveUpdate=this.throttle?mX(Sx.prototype._strokeUpdate,this.throttle):Sx.prototype._strokeUpdate,this._handleMouseDown=this._handleMouseDown.bind(this),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this._handleTouchStart=this._handleTouchStart.bind(this),this._handleTouchMove=this._handleTouchMove.bind(this),this._handleTouchEnd=this._handleTouchEnd.bind(this),this._handlePointerDown=this._handlePointerDown.bind(this),this._handlePointerMove=this._handlePointerMove.bind(this),this._handlePointerUp=this._handlePointerUp.bind(this),this._ctx=t.getContext("2d",this.canvasContextOptions),this.clear(),this.on()}dotSize;minWidth;maxWidth;penColor;minDistance;velocityFilterWeight;compositeOperation;backgroundColor;throttle;canvasContextOptions;_ctx;_drawingStroke=!1;_isEmpty=!0;_dataUrl;_dataUrlOptions;_lastPoints=[];_data=[];_lastVelocity=0;_lastWidth=0;_strokeMoveUpdate;_strokePointerId;clear(){const{_ctx:t,canvas:n}=this;t.fillStyle=this.backgroundColor,t.clearRect(0,0,n.width,n.height),t.fillRect(0,0,n.width,n.height),this._data=[],this._reset(this._getPointGroupOptions()),this._isEmpty=!0,this._dataUrl=void 0,this._dataUrlOptions=void 0,this._strokePointerId=void 0}redraw(){const t=this._data,n=this._dataUrl,r=this._dataUrlOptions;this.clear(),n&&this.fromDataURL(n,r),this.fromData(t,{clear:!1})}fromDataURL(t,n={}){return new Promise((r,o)=>{const l=new Image,c=n.ratio||window.devicePixelRatio||1,d=n.width||this.canvas.width/c,f=n.height||this.canvas.height/c,p=n.xOffset||0,m=n.yOffset||0;this._reset(this._getPointGroupOptions()),l.onload=()=>{this._ctx.drawImage(l,p,m,d,f),r()},l.onerror=g=>{o(g)},l.crossOrigin="anonymous",l.src=t,this._isEmpty=!1,this._dataUrl=t,this._dataUrlOptions={...n}})}toDataURL(t="image/png",n){switch(t){case"image/svg+xml":return typeof n!="object"&&(n=void 0),`data:image/svg+xml;base64,${btoa(this.toSVG(n))}`;default:return typeof n!="number"&&(n=void 0),this.canvas.toDataURL(t,n)}}on(){this.canvas.style.touchAction="none",this.canvas.style.msTouchAction="none",this.canvas.style.userSelect="none";const t=/Macintosh/.test(navigator.userAgent)&&"ontouchstart"in document;window.PointerEvent&&!t?this._handlePointerEvents():(this._handleMouseEvents(),"ontouchstart"in window&&this._handleTouchEvents())}off(){this.canvas.style.touchAction="auto",this.canvas.style.msTouchAction="auto",this.canvas.style.userSelect="auto",this.canvas.removeEventListener("pointerdown",this._handlePointerDown),this.canvas.removeEventListener("mousedown",this._handleMouseDown),this.canvas.removeEventListener("touchstart",this._handleTouchStart),this._removeMoveUpEventListeners()}_getListenerFunctions(){const t=window.document===this.canvas.ownerDocument?window:this.canvas.ownerDocument.defaultView??this.canvas.ownerDocument;return{addEventListener:t.addEventListener.bind(t),removeEventListener:t.removeEventListener.bind(t)}}_removeMoveUpEventListeners(){const{removeEventListener:t}=this._getListenerFunctions();t("pointermove",this._handlePointerMove),t("pointerup",this._handlePointerUp),t("mousemove",this._handleMouseMove),t("mouseup",this._handleMouseUp),t("touchmove",this._handleTouchMove),t("touchend",this._handleTouchEnd)}isEmpty(){return this._isEmpty}fromData(t,{clear:n=!0}={}){n&&this.clear(),this._fromData(t,this._drawCurve.bind(this),this._drawDot.bind(this)),this._data=this._data.concat(t)}toData(){return this._data}_isLeftButtonPressed(t,n){return n?t.buttons===1:(t.buttons&1)===1}_pointerEventToSignatureEvent(t){return{event:t,type:t.type,x:t.clientX,y:t.clientY,pressure:"pressure"in t?t.pressure:0}}_touchEventToSignatureEvent(t){const n=t.changedTouches[0];return{event:t,type:t.type,x:n.clientX,y:n.clientY,pressure:n.force}}_handleMouseDown(t){!this._isLeftButtonPressed(t,!0)||this._drawingStroke||this._strokeBegin(this._pointerEventToSignatureEvent(t))}_handleMouseMove(t){if(!this._isLeftButtonPressed(t,!0)||!this._drawingStroke){this._strokeEnd(this._pointerEventToSignatureEvent(t),!1);return}this._strokeMoveUpdate(this._pointerEventToSignatureEvent(t))}_handleMouseUp(t){this._isLeftButtonPressed(t)||this._strokeEnd(this._pointerEventToSignatureEvent(t))}_handleTouchStart(t){t.targetTouches.length!==1||this._drawingStroke||(t.cancelable&&t.preventDefault(),this._strokeBegin(this._touchEventToSignatureEvent(t)))}_handleTouchMove(t){if(t.targetTouches.length===1){if(t.cancelable&&t.preventDefault(),!this._drawingStroke){this._strokeEnd(this._touchEventToSignatureEvent(t),!1);return}this._strokeMoveUpdate(this._touchEventToSignatureEvent(t))}}_handleTouchEnd(t){t.targetTouches.length===0&&(t.cancelable&&t.preventDefault(),this._strokeEnd(this._touchEventToSignatureEvent(t)))}_getPointerId(t){return t.persistentDeviceId||t.pointerId}_allowPointerId(t,n=!1){return typeof this._strokePointerId>"u"?n:this._getPointerId(t)===this._strokePointerId}_handlePointerDown(t){this._drawingStroke||!this._isLeftButtonPressed(t)||!this._allowPointerId(t,!0)||(this._strokePointerId=this._getPointerId(t),t.preventDefault(),this._strokeBegin(this._pointerEventToSignatureEvent(t)))}_handlePointerMove(t){if(this._allowPointerId(t)){if(!this._isLeftButtonPressed(t,!0)||!this._drawingStroke){this._strokeEnd(this._pointerEventToSignatureEvent(t),!1);return}t.preventDefault(),this._strokeMoveUpdate(this._pointerEventToSignatureEvent(t))}}_handlePointerUp(t){this._isLeftButtonPressed(t)||!this._allowPointerId(t)||(t.preventDefault(),this._strokeEnd(this._pointerEventToSignatureEvent(t)))}_getPointGroupOptions(t){return{penColor:t&&"penColor"in t?t.penColor:this.penColor,dotSize:t&&"dotSize"in t?t.dotSize:this.dotSize,minWidth:t&&"minWidth"in t?t.minWidth:this.minWidth,maxWidth:t&&"maxWidth"in t?t.maxWidth:this.maxWidth,velocityFilterWeight:t&&"velocityFilterWeight"in t?t.velocityFilterWeight:this.velocityFilterWeight,compositeOperation:t&&"compositeOperation"in t?t.compositeOperation:this.compositeOperation}}_strokeBegin(t){if(!this.dispatchEvent(new CustomEvent("beginStroke",{detail:t,cancelable:!0})))return;const{addEventListener:r}=this._getListenerFunctions();switch(t.event.type){case"mousedown":r("mousemove",this._handleMouseMove,{passive:!1}),r("mouseup",this._handleMouseUp,{passive:!1});break;case"touchstart":r("touchmove",this._handleTouchMove,{passive:!1}),r("touchend",this._handleTouchEnd,{passive:!1});break;case"pointerdown":r("pointermove",this._handlePointerMove,{passive:!1}),r("pointerup",this._handlePointerUp,{passive:!1});break}this._drawingStroke=!0;const o=this._getPointGroupOptions(),l={...o,points:[]};this._data.push(l),this._reset(o),this._strokeUpdate(t)}_strokeUpdate(t){if(!this._drawingStroke)return;if(this._data.length===0){this._strokeBegin(t);return}this.dispatchEvent(new CustomEvent("beforeUpdateStroke",{detail:t}));const n=this._createPoint(t.x,t.y,t.pressure),r=this._data[this._data.length-1],o=r.points,l=o.length>0&&o[o.length-1],c=l?n.distanceTo(l)<=this.minDistance:!1,d=this._getPointGroupOptions(r);if(!l||!(l&&c)){const f=this._addPoint(n,d);l?f&&this._drawCurve(f,d):this._drawDot(n,d),o.push({time:n.time,x:n.x,y:n.y,pressure:n.pressure})}this.dispatchEvent(new CustomEvent("afterUpdateStroke",{detail:t}))}_strokeEnd(t,n=!0){this._removeMoveUpEventListeners(),this._drawingStroke&&(n&&this._strokeUpdate(t),this._drawingStroke=!1,this._strokePointerId=void 0,this.dispatchEvent(new CustomEvent("endStroke",{detail:t})))}_handlePointerEvents(){this._drawingStroke=!1,this.canvas.addEventListener("pointerdown",this._handlePointerDown,{passive:!1})}_handleMouseEvents(){this._drawingStroke=!1,this.canvas.addEventListener("mousedown",this._handleMouseDown,{passive:!1})}_handleTouchEvents(){this.canvas.addEventListener("touchstart",this._handleTouchStart,{passive:!1})}_reset(t){this._lastPoints=[],this._lastVelocity=0,this._lastWidth=(t.minWidth+t.maxWidth)/2,this._ctx.fillStyle=t.penColor,this._ctx.globalCompositeOperation=t.compositeOperation}_createPoint(t,n,r){const o=this.canvas.getBoundingClientRect();return new gp(t-o.left,n-o.top,r,new Date().getTime())}_addPoint(t,n){const{_lastPoints:r}=this;if(r.push(t),r.length>2){r.length===3&&r.unshift(r[0]);const o=this._calculateCurveWidths(r[1],r[2],n),l=hX.fromPoints(r,o);return r.shift(),l}return null}_calculateCurveWidths(t,n,r){const o=r.velocityFilterWeight*n.velocityFrom(t)+(1-r.velocityFilterWeight)*this._lastVelocity,l=this._strokeWidth(o,r),c={end:l,start:this._lastWidth};return this._lastVelocity=o,this._lastWidth=l,c}_strokeWidth(t,n){return Math.max(n.maxWidth/(t+1),n.minWidth)}_drawCurveSegment(t,n,r){const o=this._ctx;o.moveTo(t,n),o.arc(t,n,r,0,2*Math.PI,!1),this._isEmpty=!1}_drawCurve(t,n){const r=this._ctx,o=t.endWidth-t.startWidth,l=Math.ceil(t.length())*2;r.beginPath(),r.fillStyle=n.penColor;for(let c=0;c<l;c+=1){const d=c/l,f=d*d,p=f*d,m=1-d,g=m*m,x=g*m;let b=x*t.startPoint.x;b+=3*g*d*t.control1.x,b+=3*m*f*t.control2.x,b+=p*t.endPoint.x;let w=x*t.startPoint.y;w+=3*g*d*t.control1.y,w+=3*m*f*t.control2.y,w+=p*t.endPoint.y;const j=Math.min(t.startWidth+p*o,n.maxWidth);this._drawCurveSegment(b,w,j)}r.closePath(),r.fill()}_drawDot(t,n){const r=this._ctx,o=n.dotSize>0?n.dotSize:(n.minWidth+n.maxWidth)/2;r.beginPath(),this._drawCurveSegment(t.x,t.y,o),r.closePath(),r.fillStyle=n.penColor,r.fill()}_fromData(t,n,r){for(const o of t){const{points:l}=o,c=this._getPointGroupOptions(o);if(l.length>1)for(let d=0;d<l.length;d+=1){const f=l[d],p=new gp(f.x,f.y,f.pressure,f.time);d===0&&this._reset(c);const m=this._addPoint(p,c);m&&n(m,c)}else this._reset(c),r(l[0],c)}}toSVG({includeBackgroundColor:t=!1,includeDataUrl:n=!1}={}){const r=this._data,o=Math.max(window.devicePixelRatio||1,1),l=0,c=0,d=this.canvas.width/o,f=this.canvas.height/o,p=document.createElementNS("http://www.w3.org/2000/svg","svg");if(p.setAttribute("xmlns","http://www.w3.org/2000/svg"),p.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),p.setAttribute("viewBox",`${l} ${c} ${d} ${f}`),p.setAttribute("width",d.toString()),p.setAttribute("height",f.toString()),t&&this.backgroundColor){const m=document.createElement("rect");m.setAttribute("width","100%"),m.setAttribute("height","100%"),m.setAttribute("fill",this.backgroundColor),p.appendChild(m)}if(n&&this._dataUrl){const m=this._dataUrlOptions?.ratio||window.devicePixelRatio||1,g=this._dataUrlOptions?.width||this.canvas.width/m,x=this._dataUrlOptions?.height||this.canvas.height/m,b=this._dataUrlOptions?.xOffset||0,w=this._dataUrlOptions?.yOffset||0,j=document.createElement("image");j.setAttribute("x",b.toString()),j.setAttribute("y",w.toString()),j.setAttribute("width",g.toString()),j.setAttribute("height",x.toString()),j.setAttribute("preserveAspectRatio","none"),j.setAttribute("href",this._dataUrl),p.appendChild(j)}return this._fromData(r,(m,{penColor:g})=>{const x=document.createElement("path");if(!isNaN(m.control1.x)&&!isNaN(m.control1.y)&&!isNaN(m.control2.x)&&!isNaN(m.control2.y)){const b=`M ${m.startPoint.x.toFixed(3)},${m.startPoint.y.toFixed(3)} C ${m.control1.x.toFixed(3)},${m.control1.y.toFixed(3)} ${m.control2.x.toFixed(3)},${m.control2.y.toFixed(3)} ${m.endPoint.x.toFixed(3)},${m.endPoint.y.toFixed(3)}`;x.setAttribute("d",b),x.setAttribute("stroke-width",(m.endWidth*2.25).toFixed(3)),x.setAttribute("stroke",g),x.setAttribute("fill","none"),x.setAttribute("stroke-linecap","round"),p.appendChild(x)}},(m,{penColor:g,dotSize:x,minWidth:b,maxWidth:w})=>{const j=document.createElement("circle"),C=x>0?x:(b+w)/2;j.setAttribute("r",C.toString()),j.setAttribute("cx",m.x.toString()),j.setAttribute("cy",m.y.toString()),j.setAttribute("fill",g),p.appendChild(j)}),p.outerHTML}};function vX(e){const t=Re(),{width:n=500,height:r=200,defaultValue:o,who:l,onChange:c,...d}=e,f=v.useRef(null),p=v.useRef(null),m=v.useRef(c);m.current=c,v.useEffect(()=>{function x(){m.current?.({type:[{system:Ji+"/fhir/signature-type",code:"ProofOfOrigin",display:"Proof of Origin"}],when:new Date().toISOString(),who:l??Ht(t.getProfile()),data:p.current?.toDataURL().split(",")[1]})}if(f.current){const b=new gX(f.current);o?.data&&b.fromDataURL(o.data).catch(console.error),b.addEventListener("endStroke",x),p.current=b}return()=>{p.current&&p.current.removeEventListener("beginStroke",x)}},[t,o,l]);const g=()=>{p.current&&p.current.clear(),m.current?.(void 0)};return a.jsxs(Tr,{withBorder:!0,p:0,w:n,h:r,pos:"relative",...d,children:[a.jsx("canvas",{ref:f,width:n,height:r,"aria-label":"Signature input area"}),a.jsx(ke,{onClick:g,"aria-label":"Clear signature",pos:"absolute",top:0,right:0,size:"xs",leftSection:a.jsx(wm,{size:16}),variant:"subtle",color:"gray",children:"Clear"})]})}function $P(e){const t=[...e.context,e.responseItem];return a.jsxs("div",{children:[e.item.text&&a.jsx(Ie,{order:3,mb:"md",children:e.item.text}),a.jsx(wx,{formState:e.formState,context:t,items:e.item.item??[],responseItems:e.responseItem.item??[]})]},e.item.linkId)}function yX(e){return a.jsxs(a.Fragment,{children:[e.responseItems.map(t=>a.jsx($P,{formState:e.formState,context:e.context,item:e.item,responseItem:t},`group-${t.id}`)),a.jsx(Dt,{onClick:()=>e.formState.onAddGroup(e.context,e.item),children:`Add Group: ${e.item.text}`})]})}function xX(e){const{formState:t,context:n,item:r,responseItem:o}=e,l=r.type!==xt.choice&&r.type!==xt.openChoice,c=o.answer&&o.answer.length>0?o.answer:[{}];return a.jsxs(Pt,{htmlFor:e.item.linkId,title:e.item.text,withAsterisk:e.item.required,children:[a.jsx(Be,{gap:"xs",children:c?.map((d,f)=>a.jsx(mp,{formState:t,context:n,item:r,responseItem:o,index:f},`${r.linkId}-${f}`))}),l&&a.jsx(Dt,{onClick:()=>t.onAddAnswer(n,r),children:"Add Item"})]},e.item.linkId)}function wx(e){const{formState:t,context:n,items:r,responseItems:o}=e;return a.jsx(Be,{children:r.map((l,c)=>{if(!AF(l,t.questionnaireResponse))return null;if(l.type===xt.display)return a.jsx("p",{children:l.text},`display-${l.id}-${c}`);const d=o.filter(f=>f.linkId===l.linkId);return l.type===xt.group&&l.repeats?a.jsx(yX,{formState:t,context:n,item:l,responseItems:d},`repeating-group-${l.id}-${c}`):l.type===xt.group?a.jsx($P,{formState:t,context:n,item:l,responseItem:d[0]},`group-${l.id}-${c}`):l.type===xt.boolean?a.jsx(mp,{formState:t,context:n,item:l,responseItem:d[0],index:0},`boolean-item-${l.id}-${c}`):l.repeats?a.jsx(xX,{formState:t,context:n,item:l,responseItem:d[0]},`repeating-item-${l.id}-${c}`):a.jsx(Pt,{htmlFor:l.linkId,title:l.text,withAsterisk:l.required,children:a.jsx(mp,{formState:t,context:n,item:l,responseItem:d[0],index:0})},`repeating-item-${l.id}-${c}`)})})}function bX(e){const{formState:t,submitButtonText:n,excludeButtons:r,children:o}=e,l=t.pages,c=t.activePage,d=c>0,f=c<l.length-1,p=c===l.length-1;return a.jsxs(a.Fragment,{children:[a.jsx(Mc,{active:c,allowNextStepsSelect:!1,p:6,children:l.map((m,g)=>a.jsx(Mc.Step,{label:m.title,children:g===c&&o},m.linkId))}),!r&&a.jsxs(ye,{justify:"flex-end",mt:"xl",gap:"xs",children:[d&&a.jsx(ke,{onClick:t.onPrevPage,children:"Back"}),f&&a.jsx(ke,{onClick:m=>{m.currentTarget.closest("form").reportValidity()&&t.onNextPage()},children:"Next"}),p&&a.jsx(vr,{children:n??"Submit"})]})]})}function UP(e){const t=Re(),[n,r]=v.useState(!1),o=v.useRef(e);o.current=e;const l=v.useCallback(g=>{r(!1),o.current.onChange?.(g)},[]),c=FF({questionnaire:e.questionnaire,defaultValue:e.questionnaireResponse,subject:e.subject,encounter:e.encounter,source:e.source,disablePagination:e.disablePagination,onChange:l}),d=v.useRef(c);d.current=c;const f=v.useMemo(()=>c.loading?!1:!!Do(c.questionnaire,_F),[c]),p=v.useMemo(()=>c.loading?!1:!!c.questionnaireResponse.extension?.find(g=>g.url===$h),[c]),m=v.useCallback(()=>{const g=d.current;if(g.loading)return;const x=o.current.onSubmit;if(!x)return;if(f&&!p){r(!0);return}const b=g.questionnaire,w=g.questionnaireResponse,j=o.current.subject;let C=o.current.source;if(!C){const T=t.getProfile();T&&(C=Ht(T))}x({...w,questionnaire:b.url??_t(b),subject:j,source:C,authored:new Date().toISOString(),status:"completed"})},[t,f,p]);return c.loading?null:a.jsxs(ut,{testid:"questionnaire-form",onSubmit:m,children:[c.questionnaire.title&&a.jsx(Ie,{children:c.questionnaire.title}),c.pagination?a.jsx(bX,{formState:c,submitButtonText:e.submitButtonText,excludeButtons:e.excludeButtons,children:a.jsx(wx,{formState:c,context:[],items:c.items,responseItems:c.responseItems})}):a.jsxs(a.Fragment,{children:[a.jsx(wx,{formState:c,context:[],items:c.items,responseItems:c.responseItems}),f&&a.jsxs(Be,{mt:"md",gap:0,children:[a.jsx(Te,{size:"sm",fw:500,children:"Signature"}),a.jsx(vX,{onChange:c.onChangeSignature}),!p&&n&&a.jsx(Te,{c:"red",size:"sm",children:"Signature is required."})]}),!e.excludeButtons&&a.jsx(ye,{justify:"flex-end",mt:"xl",gap:"xs",children:a.jsx(vr,{children:e.submitButtonText??"Submit"})})]})]})}const SX="_section_4m5it_1",wX={section:SX},jX=["gender","age","gestationalAge","context","appliesTo","category"],CX={definition:{resourceType:"ObservationDefinition",code:{text:""}},onSubmit:()=>{}};function EX(e){e=Object.assign(CX,e);const t=e.definition,[n,r]=v.useState([]),[o,l]=v.useState(1),[c,d]=v.useState(1);return v.useEffect(()=>{const w=_X(t,d);r(DX(w.qualifiedInterval||[],l))},[t]),a.jsxs(ut,{testid:"reference-range-editor",onSubmit:f,children:[a.jsx(Be,{children:n.map(w=>a.jsx(TX,{unit:PX(t.quantitativeDetails?.unit),onChange:g,onAdd:x,onRemove:b,onRemoveGroup:m,intervalGroup:w},`group-${w.id}`))}),a.jsx(bn,{title:"Add Group",variant:"subtle",size:"sm",onClick:w=>{cn(w),p({id:`group-id-${o}`,filters:{},intervals:[]}),l(j=>j+1)},children:a.jsx(cp,{})}),a.jsx(ye,{justify:"flex-end",children:a.jsx(vr,{children:"Save"})})]});function f(){const w=n.flatMap(j=>j.intervals).filter(j=>!kX(j));e.onSubmit({...t,qualifiedInterval:w})}function p(w){r(j=>[...j,w])}function m(w){r(j=>j.filter(C=>C.id!==w.id))}function g(w,j){r(C=>{C=[...C];const T=C.find(R=>R.id===w),E=T?.intervals.findIndex(R=>R.id===j.id);return E!==void 0&&T?.intervals[E]&&(T.intervals[E]=j),C})}function x(w,j){j.id===void 0&&(j.id=`id-${c}`,d(C=>C+1)),r(C=>{C=[...C];const T=C.findIndex(E=>E.id===w);if(T!==-1){const E={...C[T]};j={...j,...E.filters},E.intervals=[...E.intervals,j],C[T]=E}return C})}function b(w,j){r(C=>{C=[...C];const T=C.find(E=>E.id===w);return T&&(T.intervals=T.intervals.filter(E=>E.id!==j.id)),C})}}function TX(e){const{intervalGroup:t,unit:n}=e;return a.jsx(eu,{"data-testid":t.id,className:wX.section,children:a.jsxs(Be,{gap:"lg",children:[a.jsx(ye,{justify:"flex-end",children:a.jsx(bn,{title:"Remove Group",variant:"subtle","data-testid":`remove-group-button-${t.id}`,size:"sm",onClick:r=>{cn(r),e.onRemoveGroup(t)},children:a.jsx(lp,{})},`remove-group-button-${t.id}`)}),a.jsx(RX,{intervalGroup:t,onChange:e.onChange}),a.jsx(pn,{}),t.intervals.map(r=>a.jsxs(Be,{gap:"xs",children:[a.jsxs(ye,{children:[a.jsx(Ve,{"data-testid":`condition-${r.id}`,defaultValue:r.condition,label:"Condition: ",size:"sm",onChange:o=>{cn(o),e.onChange(t.id,{...r,condition:o.currentTarget.value.trim()})}},`condition-${r.id}`),a.jsx(bn,{title:"Remove Interval",variant:"subtle",size:"sm","data-testid":`remove-interval-${r.id}`,onClick:o=>{cn(o),e.onRemove(t.id,r)},children:a.jsx(lp,{})},`remove-interval-${r.id}`)]}),a.jsx(Kb,{path:"",onChange:o=>{e.onChange(t.id,{...r,range:o})},name:`range-${r.id}`,defaultValue:r.range},`range-${r.id}`)]},`interval-${r.id}`)),a.jsx(bn,{title:"Add Interval",variant:"subtle",size:"sm",onClick:r=>{cn(r),e.onAdd(t.id,{range:{low:{unit:n},high:{unit:n}}})},children:a.jsx(cp,{})})]})})}function RX(e){const{intervalGroup:t,onChange:n}=e;t.filters.age||(t.filters.age={});for(const r of["low","high"])t.filters.age[r]?.unit||(t.filters.age[r]={...t.filters.age[r],unit:"years",system:"http://unitsofmeasure.org"});return a.jsxs(Be,{style:{maxWidth:"50%"},children:[a.jsx(ye,{children:a.jsx(on,{data:["","male","female"],label:"Gender:",defaultValue:t.filters.gender||"",onChange:r=>{for(const o of t.intervals){let l=r.currentTarget.value;l===""&&(l=void 0),n(t.id,{...o,gender:l})}}})}),a.jsxs(ye,{gap:"xs",children:[a.jsx(Te,{component:"label",htmlFor:`div-age-${t.id}`,children:"Age:"}),a.jsx("div",{id:`div-age-${t.id}`,children:a.jsx(Kb,{path:"",name:`age-${t.id}`,defaultValue:t.filters.age,onChange:r=>{for(const o of t.intervals)n(t.id,{...o,age:r})}},`age-${t.id}`)})]}),a.jsx(on,{data:["","pre-puberty","follicular","midcycle","luteal","postmenopausal"],label:"Endocrine:",defaultValue:t.filters.context?.text||"",onChange:r=>{for(const o of t.intervals){let l=r.currentTarget.value;l===""?(l=void 0,n(t.id,{...o,context:void 0})):n(t.id,{...o,context:{text:l,coding:[{code:l,system:"http://terminology.hl7.org/CodeSystem/referencerange-meaning"}]}})}}}),a.jsx(on,{data:["","reference","critical","absolute"],label:"Category: ",defaultValue:t.filters.category,onChange:r=>{for(const o of t.intervals){const l=r.currentTarget.value;l===""?n(t.id,{...o,category:void 0}):n(t.id,{...o,category:l})}}})]})}function _X(e,t){const n=e.qualifiedInterval||[];let r=Math.max(...n.map(o=>{const l=parseInt(o.id?.substring(3)||"",10);return isNaN(l)?Number.NEGATIVE_INFINITY:l}))+1;return Number.isFinite(r)||(r=1),e={...e,qualifiedInterval:n.map(o=>({...o,id:o.id||`id-${r++}`}))},t(r),e}function DX(e,t){let n=1;const r={};for(const o of e){const l=AX(o);l in r||(r[l]={id:`group-id-${n++}`,filters:Object.fromEntries(jX.map(c=>[c,o[c]])),intervals:[]}),r[l].intervals.push(o)}return t(n),Object.values(r)}function AX(e){return[`gender=${e.gender}`,`age=${md(e.age)}`,`gestationalAge=${md(e.gestationalAge)}`,`context=${e.context?.text}`,`appliesTo=${e.appliesTo?.map(n=>n.text).join("+")}`,`category=${e.category}`].join(":")}function PX(e){return e&&(IU(e,"http://unitsofmeasure.org")||e.text)}function kX(e){return e.range?.low?.value===void 0&&e.range?.high?.value===void 0}function NX(e){const t=Re(),n=Gt(e.value),[r,o]=v.useState(!1),[l,c]=v.useState();if(v.useEffect(()=>{n&&!r&&(t.executeBatch(d(n)).then(c).catch(console.log),o(!0))},[t,n,r]),!n||!l)return null;return a.jsx(hr,{children:n.action?.map((p,m)=>{const g=p.resource&&f(p.resource),x=g?.input?.[0]?.valueReference,b=g?.output?.[0]?.valueReference;return a.jsxs(v.Fragment,{children:[a.jsx(hr.Col,{span:1,p:"md",children:g?.status==="completed"?a.jsx(_H,{}):a.jsx(Qq,{color:"gray"})}),a.jsxs(hr.Col,{span:9,p:"xs",children:[a.jsx(Te,{fw:500,children:p.title}),p.description&&a.jsx("div",{children:p.description}),a.jsxs("div",{children:["Last edited by ",a.jsx(jl,{value:g?.meta?.author})," on ",mr(g?.meta?.lastUpdated)]}),a.jsxs("div",{children:["Status: ",a.jsx(Rm,{status:g?.status||"unknown"})]})]}),a.jsxs(hr.Col,{span:2,p:"md",children:[x&&!b&&a.jsx(ke,{onClick:()=>e.onStart(g,x),children:"Start"}),x&&b&&a.jsx(ke,{onClick:()=>e.onEdit(g,x,b),children:"Edit"})]})]},`action-${m}`)})});function d(p){const m=[];if(p.action)for(const g of p.action)g.resource?.reference&&m.push({request:{method:"GET",url:g.resource.reference}});return{resourceType:"Bundle",type:"batch",entry:m}}function f(p){for(const m of l?.entry??[])if(m.resource&&p.reference===_t(m.resource))return m.resource}}function BP(e,t){const n=OX(e,t);return MX(n,e,t)}function OX(e,t){const n=e.length,r=t.length,o=n+r+1,l=1+2*o,c=l/2|0,d=new Array(l);d[c+1]={i:0,j:-1,prev:void 0,snake:!0};for(let f=0;f<o;f++){for(let p=-f;p<=f;p+=2){const m=c+p,g=m+1,x=m-1,b=d[g],w=d[x];let j,C=0;p===-f||p!==f&&w.i<b.i?(C=b.i,j=b):(C=w.i+1,j=w),d[x]=void 0;let T=C-p,E={i:C,j:T,prev:LX(j),snake:!1};for(;C<n&&T<r&&e[C]===t[T];)C++,T++;if(C>E.i&&(E={i:C,j:T,prev:E,snake:!0}),d[m]=E,C>=n&&T>=r)return d[m]}d[c+f-1]=void 0}}function MX(e,t,n){const r=[];let o=e;for(o.snake&&(o=o.prev);o?.prev&&o.prev.j>=0;){const l=o.i,c=o.j;o=o.prev;const d=o.i,f=o.j,p={position:d,lines:t.slice(d,l)},m={position:f,lines:n.slice(f,c)};let g;p.lines.length===0&&m.lines.length>0?g="insert":p.lines.length>0&&m.lines.length===0?g="delete":g="change",r.push({original:p,revised:m,type:g}),o.snake&&(o=o.prev)}return r}function LX(e){return e&&!e.snake&&e.prev?e.prev:e}function IX(e){const t=(e.entry??[]).filter(r=>!!r.resource).map(r=>({meta:r.resource?.meta,lines:Ki(r.resource,!0).match(/[^\r\n]+/g)})).sort((r,o)=>r.meta.lastUpdated.localeCompare(o.meta.lastUpdated));if(!t.length)return[];const n=t[0].lines.map(r=>({id:t[0].meta.versionId,meta:t[0].meta,value:r,span:1}));return zX(n,t),$X(n),n}function zX(e,t){for(let n=1;n<t.length;n++){const r=BP(t[n-1].lines,t[n].lines);for(const o of r){const l=o.original.position,c=o.original.lines,d=o.revised.lines;if((o.type==="delete"||o.type==="change")&&e.splice(l,c.length),o.type==="insert"||o.type==="change")for(let f=0;f<o.revised.lines.length;f++)e.splice(l+f,0,{id:t[n].meta.versionId,meta:t[n].meta,value:d[f],span:1})}}}function $X(e){let t=0;for(;t<e.length;){let n=t;for(;n<e.length&&e[n].id===e[t].id;)e[n].span=-1,n++;e[t].span=n-t,t=n}}const UX="_container_1tyf3_1",BX="_root_1tyf3_5",VX="_startRow_1tyf3_20",FX="_normalRow_1tyf3_25",HX="_author_1tyf3_30",qX="_dateTime_1tyf3_34",GX="_lineNumber_1tyf3_40",QX="_line_1tyf3_40",WX="_pre_1tyf3_55",ta={container:UX,root:BX,startRow:VX,normalRow:FX,author:HX,dateTime:qX,lineNumber:GX,line:QX,pre:WX};function YX(e,t){return`/${e.resourceType}/${e.id}/_history/${t}`}function KX(e){const t=Math.floor((Date.now()-Date.parse(e))/1e3),n=Math.floor(t/31536e3);if(n>0)return yc(n,"year");const r=Math.floor(t/2592e3);if(r>0)return yc(r,"month");const o=Math.floor(t/86400);if(o>0)return yc(o,"day");const l=Math.floor(t/3600);if(l>0)return yc(l,"hour");const c=Math.floor(t/60);return c>0?yc(c,"minute"):yc(t,"second")}function yc(e,t){return`${e} ${e===1?t:t+"s"} ago`}function XX(e){const t=Re(),[n,r]=v.useState(e.history);if(v.useEffect(()=>{!e.history&&e.resourceType&&e.id&&t.readHistory(e.resourceType,e.id).then(r).catch(console.log)},[t,e.history,e.resourceType,e.id]),!n)return a.jsx("div",{children:"Loading..."});const o=n.entry?.[0]?.resource;if(!o)return null;const l=IX(n);return a.jsx("div",{className:ta.container,children:a.jsx("table",{className:ta.root,children:a.jsx("tbody",{children:l.map((c,d)=>a.jsxs("tr",{className:c.span>0?ta.startRow:ta.normalRow,children:[c.span>0&&a.jsxs(a.Fragment,{children:[a.jsx("td",{className:ta.author,rowSpan:c.span,children:a.jsx(jl,{value:c.meta.author,link:!0,fz:"xs"})}),a.jsx("td",{className:ta.dateTime,rowSpan:c.span,children:a.jsx(mt,{to:YX(o,c.meta.versionId),fz:"xs",children:KX(c.meta.lastUpdated)})})]}),a.jsx("td",{className:ta.lineNumber,children:d+1}),a.jsx("td",{className:ta.line,children:a.jsx("pre",{className:ta.pre,children:c.value})})]},"row-"+d))})})})}const ZX="_removed_el5zk_1",JX="_added_el5zk_6",LT={removed:ZX,added:JX};function eZ(e){let t=e.original,n=e.revised;e.ignoreMeta&&(t={...t,meta:void 0},n={...n,meta:void 0});const r=Ki(t,!0).match(/[^\r\n]+/g),o=Ki(n,!0).match(/[^\r\n]+/g),l=BP(r,o);return a.jsx("pre",{style:{color:"gray"},children:l.map((c,d)=>a.jsx(tZ,{delta:c},"delta"+d))})}function tZ(e){return a.jsxs(a.Fragment,{children:["...",a.jsx("br",{}),e.delta.original.lines.length>0&&a.jsx("div",{className:LT.removed,children:e.delta.original.lines.join(`
|
|
@@ -604,4 +604,4 @@ Please change the parent <Route path="${E}"> to <Route path="${E==="/"?"*":`${E}
|
|
|
604
604
|
}
|
|
605
605
|
]
|
|
606
606
|
}`,kne="MSH|^~\\&|ADT1|MCM|LABADT|MCM|198808181126|SECURITY|ADT|MSG00001|P|2.1\rPID|||PATID1234^5^M11||JONES^WILLIAM^A^III||19610615|M-||C|1200 N ELM STREET^^GREENSBORO^NC^27401-1020|GL|(919)379-1212|(919)271-3434||S||PATID12345001^2^M10|123456789|987654^NC\rNK1|1|JONES^BARBARA^K|SPO|||||20011105\rPV1|1|I|2000^2012^01||||004777^LEBAUER^SIDNEY^J.|||SUR||-||1|A0-";function Nne(){const e=Re(),{id:t}=Ut(),[n,r]=v.useState(),[o,l]=v.useState(),[c,d]=v.useState(Pne),[f,p]=v.useState(kne),[m,g]=v.useState(ln.FHIR_JSON),x=v.useRef(null),b=v.useRef(null),[w,j]=v.useState(!1);v.useEffect(()=>{e.readResource("Bot",t).then(async A=>{r(A),l(await One(e,A))}).catch(A=>Ne({color:"red",message:Ye(A),autoClose:!1}))},[e,t]);const C=v.useCallback(async()=>id(x.current,{command:"getValue"}),[]),T=v.useCallback(async()=>id(x.current,{command:"getOutput"}),[]),E=v.useCallback(async()=>m===ln.FHIR_JSON?JSON.parse(c):f,[m,c,f]),R=v.useCallback(async A=>{A.preventDefault(),A.stopPropagation(),j(!0);try{const k=await C(),M=await T(),$=await e.createAttachment({data:k,filename:"index.ts",contentType:"text/typescript"}),U=await e.createAttachment({data:M,filename:"index.js",contentType:"text/typescript"}),J=[{op:"add",path:"/sourceCode",value:$},{op:"add",path:"/executableCode",value:U}];await e.patchResource("Bot",t,J),Ne({color:"green",message:"Saved"})}catch(k){Ne({color:"red",message:Ye(k),autoClose:!1})}finally{j(!1)}},[e,t,C,T]),D=v.useCallback(async A=>{A.preventDefault(),A.stopPropagation(),j(!0);try{await e.post(e.fhirUrl("Bot",t,"$deploy")),Ne({color:"green",message:"Deployed"})}catch(k){Ne({color:"red",message:Ye(k),autoClose:!1})}finally{j(!1)}},[e,t]),P=v.useCallback(async A=>{A.preventDefault(),A.stopPropagation(),j(!0);try{const k=await E(),M=await e.post(e.fhirUrl("Bot",t,"$execute"),k,m);await id(b.current,{command:"setValue",value:M}),Ne({color:"green",message:"Success"})}catch(k){Ne({color:"red",message:Ye(k),autoClose:!1})}finally{j(!1)}},[e,t,E,m]);return!n||o===void 0?null:a.jsxs(hr,{m:0,gutter:0,style:{overflow:"hidden"},children:[a.jsx(hr.Col,{span:8,children:a.jsxs(Tr,{m:2,pb:"xs",pr:"xs",pt:"xs",shadow:"md",mih:400,children:[a.jsx(Ane,{iframeRef:x,language:"typescript",module:"commonjs",testId:"code-frame",defaultValue:o,minHeight:"528px"}),a.jsxs(ye,{justify:"flex-end",gap:"xs",children:[a.jsx(ke,{type:"button",onClick:R,loading:w,leftSection:a.jsx(FH,{size:"1rem"}),children:"Save"}),a.jsx(ke,{type:"button",onClick:D,loading:w,leftSection:a.jsx($b,{size:"1rem"}),children:"Deploy"}),a.jsx(ke,{type:"button",onClick:P,loading:w,leftSection:a.jsx(Aq,{size:"1rem"}),children:"Execute"})]})]})}),a.jsxs(hr.Col,{span:4,children:[a.jsxs(Tr,{m:2,pb:"xs",pr:"xs",pt:"xs",shadow:"md",children:[a.jsx(on,{data:[{label:"FHIR",value:ln.FHIR_JSON},{label:"HL7",value:ln.HL7_V2}],onChange:A=>g(A.currentTarget.value)}),m===ln.FHIR_JSON?a.jsx(Wc,{value:c,onChange:A=>d(A),autosize:!0,minRows:15}):a.jsx("textarea",{className:_ne.hl7Input,value:f,onChange:A=>p(A.currentTarget.value),rows:15})]}),a.jsx(Tr,{m:2,p:"xs",shadow:"md",children:a.jsx(Dne,{iframeRef:b,className:"medplum-bot-output-frame",testId:"output-frame",minHeight:"200px"})})]})]})}async function One(e,t){if(t.sourceCode?.url){const n=t.sourceCode.url?.split("/")?.find(KD);return(await e.download(e.fhirUrl("Binary",n))).text()}return t.code??""}function Tl(e){let t=e.meta;return t&&(t={...t,lastUpdated:void 0,versionId:void 0,author:void 0}),{...e,meta:t}}function Mne(){const e=Re(),{resourceType:t,id:n}=Ut(),r={reference:t+"/"+n},o=v.useCallback(l=>{e.updateResource(Tl(l)).then(()=>{Ne({color:"green",message:"Success"})}).catch(c=>{Ne({color:"red",message:Ye(c),autoClose:!1})})},[e]);switch(t){case"PlanDefinition":return a.jsx(lt,{children:a.jsx(PK,{value:r,onSubmit:o})});case"Questionnaire":return a.jsx(lt,{children:a.jsx(oX,{questionnaire:r,onSubmit:o})});default:return null}}function Lne(){const{resourceType:e,id:t}=Ut(),n=Gt({reference:e+"/"+t}),r=wn();return n?a.jsx(lt,{children:a.jsx(NX,{value:n,onStart:(o,l)=>r(`/forms/${rl(l)}`)?.catch(console.error),onEdit:(o,l,c)=>r(`/${c.reference}}`)?.catch(console.error)})}):null}function Ine(){const e=Re(),{resourceType:t,id:n}=Ut(),r=wn();return a.jsxs(lt,{children:[a.jsxs("p",{children:["Are you sure you want to delete this ",t,"?"]}),a.jsx(ke,{color:"red",onClick:()=>{e.deleteResource(t,n).then(()=>r(`/${t}`)?.catch(console.error)).catch(o=>Ne({color:"red",message:Ye(o),autoClose:!1}))},children:"Delete"})]})}const zne="_selectProfileBtn_tbaz6_1",$ne="_chevron_tbaz6_13",ER={selectProfileBtn:zne,chevron:$ne};function Une(){const{resourceType:e,id:t}=Ut(),n=Gt({reference:e+"/"+t}),[r,o]=v.useState(),l=gl({onDropdownClose:()=>l.resetSelectedOption()}),c=v.useMemo(()=>{if(Rn(n?.meta?.profile))return[a.jsx(Xe.Option,{value:"",children:"None"},""),...n.meta.profile.map(f=>a.jsx(Xe.Option,{value:f,children:f},f))]},[n?.meta?.profile]);if(v.useEffect(()=>{n?.meta?.profile?.length===1&&o(n.meta.profile[0])},[n?.meta?.profile]),!n)return null;let d;return Rn(c)&&(d=a.jsx(ye,{justify:"flex-end",children:a.jsxs(Be,{align:"flex-end",gap:"xs",children:[a.jsxs(Xe,{store:l,width:250,position:"bottom-end",withinPortal:!1,onOptionSubmit:f=>{o(f),l.closeDropdown()},children:[a.jsx(Xe.Target,{children:a.jsx(sr,{onClick:()=>l.toggleDropdown(),children:a.jsxs(Pd,{fw:"bold",fs:"sm",className:ER.selectProfileBtn,children:[a.jsx("span",{children:"Pick profile"}),a.jsx(zb,{stroke:1.5,className:ER.chevron})]})})}),a.jsx(Xe.Dropdown,{w:"max-content",children:a.jsx(Xe.Options,{children:c})})]}),a.jsx(ce,{children:r?a.jsxs(a.Fragment,{children:[a.jsx(Te,{span:!0,size:"sm",c:"dimmed",children:"Displaying profile: "}),a.jsx(Te,{span:!0,size:"sm",children:r||"Nothing selected"})]}):a.jsx(Te,{span:!0,size:"sm",c:"dimmed",children:"No profile displayed"})})]})})),a.jsx(lt,{children:a.jsxs(Be,{gap:"xl",children:[d,a.jsx(tS,{value:n,profileUrl:r})]})})}function Bne(){const e=Re(),{resourceType:t,id:n}=Ut(),[r,o]=v.useState(),[l,c]=v.useState(),d=wn(),[f,p]=v.useState();v.useEffect(()=>{e.readResource(t,n).then(b=>{o(ii(b)),c(ii(b))}).catch(b=>{p(qt(b)),Ne({color:"red",message:Ye(b),autoClose:!1})})},[e,t,n]);const m=v.useCallback(b=>{p(void 0),e.updateResource(Tl(b)).then(()=>{d(`/${t}/${n}/details`)?.catch(console.error),Ne({id:"succes",color:"green",message:"Success"})}).catch(w=>{p(qt(w)),Ne({color:"red",message:Ye(w),autoClose:!1})})},[e,t,n,d]),g=v.useCallback(b=>{p(void 0);const w=bP.createPatch(r,b);e.patchResource(t,n,w).then(()=>{d(`/${t}/${n}/details`)?.catch(console.error),Ne({id:"succes",color:"green",message:"Success"})}).catch(j=>{p(qt(j)),Ne({color:"red",message:Ye(j),autoClose:!1})})},[e,t,n,r,d]),x=v.useCallback(()=>d(`/${t}/${n}/delete`)?.catch(console.error),[d,t,n]);return l?a.jsx(lt,{children:a.jsx(vp,{defaultValue:l,onSubmit:m,onPatch:g,onDelete:x,outcome:f})}):null}function Vne(){const{resourceType:e,id:t}=Ut(),n=Gt({reference:e+"/"+t});return n?a.jsx(lt,{maw:700,children:n.resourceType==="Patient"?a.jsx(EK,{patient:n}):a.jsx(ya,{icon:a.jsx(bl,{size:16}),title:"Unsupported export type",color:"red",children:"This page is only supported for Patient resources"})}):null}function Pk({resource:e,currentProfile:t,onChange:n}){const r=e.resourceType,o=Re(),[l,c]=v.useState();return v.useEffect(()=>{o.searchResources("StructureDefinition",{type:r,derivation:"constraint",_count:50}).then(d=>{c(d.filter(GQ))}).catch(console.error)},[o,n,r]),a.jsx(Tt,{value:t?.url,onChange:d=>{const f=l?.find(p=>p.url===d);f&&n(f)},children:a.jsx(Tt.List,{children:l?.map(d=>{const f=e.meta?.profile?.includes(d.url),p=f?"This profile is present in this resource's meta.profile property.":"This profile is not included in this resource's meta.profile property.";return a.jsx(Tt.Tab,{value:d.url,title:p,rightSection:f&&a.jsx(pb,{variant:"outline",color:"green",size:"xs",style:{borderStyle:"none"},children:a.jsx(lG,{size:"90%"})}),children:d.title||d.name},d.url)})})})}function kk(e,t){const n=Re(),r=wn();return{defaultValue:{resourceType:e},handleSubmit:c=>{t&&t(void 0),n.createResource(c).then(d=>r("/"+d.resourceType+"/"+d.id)).catch(d=>{t&&t(qt(d)),Ne({color:"red",message:Ye(d),autoClose:!1,styles:{description:{whiteSpace:"pre-line"}}})})}}}function Uy(){const{resourceType:e}=Ut(),t=Gr(),[n,r]=v.useState(),{defaultValue:o,handleSubmit:l}=kk(e,r),[c,d]=v.useState(),f=t.pathname.toLowerCase().endsWith("profiles"),p=v.useCallback(m=>{const g=Tl(m);c&&tA(g,c.url),l(g)},[c,l]);return f?a.jsx(lt,{children:a.jsxs(Be,{children:[a.jsx(Pk,{resource:o,currentProfile:c,onChange:d}),c?a.jsx(vp,{defaultValue:o,onSubmit:p,outcome:n,profileUrl:c.url},c.url):a.jsx(Te,{my:"lg",fz:"lg",fs:"italic",ta:"center",children:"Select a profile above"})]})}):a.jsx(lt,{children:a.jsx(vp,{defaultValue:o,onSubmit:l,outcome:n})})}function TR(){const e=Re(),{resourceType:t,id:n}=Ut(),r=e.readHistory(t,n).read();return a.jsx(lt,{children:a.jsx(iZ,{history:r})})}function Fne(){const{resourceType:e}=Ut(),[t,n]=v.useState(),{defaultValue:r,handleSubmit:o}=kk(e,n),l=v.useCallback(c=>{o(JSON.parse(c["new-resource"]))},[o]);return a.jsxs(lt,{children:[t&&a.jsx(yr,{outcome:t}),a.jsxs(ut,{onSubmit:l,children:[a.jsx(Wc,{name:"new-resource","data-testid":"create-resource-json",autosize:!0,minRows:24,defaultValue:Ki(r,!0),formatOnBlur:!0,deserialize:JSON.parse}),a.jsx(ye,{justify:"flex-end",mt:"xl",wrap:"nowrap",children:a.jsx(ke,{type:"submit",children:"OK"})})]})]})}function Hne(){const e=Re(),{resourceType:t,id:n}=Ut(),r=Gt({reference:t+"/"+n}),o=wn(),[l,c]=v.useState(),d=v.useCallback(f=>{e.updateResource(Tl(JSON.parse(f.resource))).then(()=>{c(void 0),o(`/${t}/${n}/details`)?.catch(console.error),Ne({color:"green",message:"Success"})}).catch(p=>{Ne({color:"red",message:Ye(p),autoClose:!1})})},[e,t,n,o]);return r?a.jsxs(lt,{children:[l&&a.jsx(yr,{outcome:l}),a.jsxs(ut,{onSubmit:d,children:[a.jsx(Wc,{name:"resource","data-testid":"resource-json",autosize:!0,minRows:24,defaultValue:Ki(r,!0),formatOnBlur:!0,deserialize:JSON.parse}),a.jsx(ye,{justify:"flex-end",mt:"xl",wrap:"nowrap",children:a.jsx(ke,{type:"submit",children:"OK"})})]})]}):null}function qne(){const{resourceType:e,id:t}=Ut();return Gt({reference:e+"/"+t})?a.jsxs(lt,{children:[a.jsxs(ya,{icon:a.jsx(bl,{size:16}),mb:"xl",children:["This is just a preview! Access your form here:",a.jsx("br",{}),a.jsx(Dt,{href:`/forms/${t}`,children:`/forms/${t}`})]}),a.jsx(UP,{questionnaire:{reference:e+"/"+t},onSubmit:()=>alert("You submitted the preview")})]}):null}function Gne(){const e=Re(),{resourceType:t,id:n}=Ut(),[r,o]=v.useState(),[l,c]=v.useState();return v.useEffect(()=>{e.readResource(t,n).then(d=>o(ii(d))).catch(d=>{Ne({color:"red",message:Ye(d)})})},[e,t,n]),r?a.jsxs(lt,{children:[a.jsxs(Ie,{order:2,children:["Available ",t," profiles"]}),a.jsx(Be,{children:a.jsxs(a.Fragment,{children:[a.jsx(Pk,{resource:r,currentProfile:l,onChange:c}),l?a.jsx(Qne,{profile:l,resource:r,onResourceUpdated:d=>o(d)},l.url):a.jsx(Te,{my:"lg",fz:"lg",fs:"italic",ta:"center",children:"Select a profile above"})]})})]}):null}const Qne=({profile:e,resource:t,onResourceUpdated:n})=>{const r=Re(),[o,l]=v.useState(),[c,d]=v.useState(()=>t.meta?.profile?.includes(e.url)),f=v.useCallback(p=>{l(void 0);const m=Tl(p);c?tA(m,e.url):FU(m,e.url),r.updateResource(m).then(g=>{n(g),Ne({color:"green",message:"Success"})}).catch(g=>{l(qt(g)),Ne({color:"red",message:Ye(g),autoClose:!1})})},[r,e.url,n,c]);return a.jsxs(Be,{children:[a.jsx(zd,{size:"md",checked:c,label:`Conform resource to ${e.title}`,onChange:p=>d(p.currentTarget.checked),"data-testid":"profile-toggle"}),c?a.jsx(vp,{profileUrl:e.url,defaultValue:t,onSubmit:f,outcome:o}):a.jsx("form",{noValidate:!0,onSubmit:p=>{p.preventDefault(),f(t)},children:a.jsx(ye,{justify:"flex-end",mt:"xl",children:a.jsx(ke,{type:"submit",children:"OK"})})})]})},Nk={"Create Only":"create","Update Only":"update","Delete Only":"delete","All Interactions":void 0},Wne=Object.keys(Nk);function Yne(){const e=Re(),{id:t}=Ut(),n=Gt({reference:`Questionnaire/${t}`}),[r,o]=v.useState(),[l,c]=v.useState("create"),[d,f]=v.useState(0),p=e.searchResources("Subscription","status=active&_count=100").read().filter(g=>Kne(g,n));function m(){r&&n&&e.createResource({resourceType:"Subscription",status:"active",reason:`Connect bot ${r.name} to questionnaire responses`,criteria:`QuestionnaireResponse?questionnaire=${n.url?`${n.url},${_t(n)}`:_t(n)}`,channel:{type:"rest-hook",endpoint:_t(r)},...l?{extension:[{url:"https://medplum.com/fhir/StructureDefinition/subscription-supported-interaction",valueCode:l}]}:void 0}).then(()=>{o(void 0),f(Date.now()),e.invalidateSearches("Subscription"),Ne({color:"green",message:"Success"})}).catch(g=>Ne({color:"red",message:Ye(g),autoClose:!1}))}return a.jsxs(lt,{children:[a.jsx(Ie,{children:"Bots"}),a.jsxs(Be,{children:[p.length===0&&a.jsx("p",{children:"No bots found."}),p.map(g=>a.jsxs("div",{children:[a.jsx("h3",{children:a.jsx(jl,{value:{reference:g.channel?.endpoint},link:!0})}),a.jsxs("p",{children:["Criteria: ",g.criteria]})]},g.id))]}),a.jsx(pn,{}),a.jsxs(Be,{mt:10,children:[a.jsx(Ed,{size:"lg",htmlFor:"bot",children:"Connect to bot"}),a.jsxs(ye,{children:[a.jsx(wl,{name:"bot",resourceType:"Bot",onChange:g=>o(g)}),a.jsx(ke,{onClick:m,children:"Connect"})]}),a.jsx(ye,{children:a.jsx(on,{name:"subscription-trigger-event",defaultValue:"Create Only",label:"Subscription Trigger Event",data:Wne,onChange:g=>c(Nk[g.target.value])})})]}),a.jsx("div",{style:{display:"none"},children:d})]})}function Kne(e,t){if(!t)return!1;const n=e.criteria||"",r=e.channel?.endpoint||"";return n.startsWith("QuestionnaireResponse?")&&r.startsWith("Bot/")&&(n.includes(_t(t))||(t.url?n.includes(t.url):!1))}function Xne(){const{id:e}=Ut(),t=wn(),r=Re().readReference({reference:`Questionnaire/${e}`}).read(),[o,l]=v.useState({resourceType:"QuestionnaireResponse",filters:[{code:"questionnaire",operator:de.EQUALS,value:r.url?`${r.url},Questionnaire/${e}`:`Questionnaire/${e}`}],fields:["id","_lastUpdated"]});return a.jsx(lt,{children:a.jsx(nu,{search:o,onClick:c=>t(`/${c.resource.resourceType}/${c.resource.id}`)?.catch(console.error),onChange:c=>l(c.definition),hideFilters:!0,hideToolbar:!0})})}function Zne(){const e=Re(),{resourceType:t,id:n}=Ut(),r=Gt({reference:t+"/"+n}),o=v.useCallback(l=>{e.updateResource(Tl(l)).then(()=>{Ne({color:"green",message:"Success"})}).catch(c=>{Ne({color:"red",message:Ye(c),autoClose:!1})})},[e]);return r?a.jsx(lt,{children:a.jsx(EX,{onSubmit:o,definition:r})}):null}function Jne(){const{resourceType:e,id:t}=Ut(),n=Gt({reference:e+"/"+t});return n?a.jsx(lt,{children:e==="MeasureReport"?a.jsx(jK,{measureReport:n}):a.jsx(eS,{value:n})}):null}const ere="_container_1ue98_1",tre="_entry_1ue98_14",nre="_active_1ue98_21",By={container:ere,entry:tre,active:nre};function rre(e){const t=Re(),n=Gt(e.value),[r,o]=v.useState();return v.useEffect(()=>{if(!n)return;const l=bS(n);if(!l)return;const c="reference"in l?l.reference:_t(l);t.search("ServiceRequest","subject="+c).then(d=>{const p=(d.entry??[]).map(m=>m.resource);SP(p),p.reverse(),o(p)}).catch(d=>Ne({color:"red",message:Ye(d),autoClose:!1}))},[t,n]),r?a.jsx("div",{"data-testid":"quick-service-requests",className:By.container,children:r.map(l=>a.jsxs("div",{className:Ot(By.entry,{[By.active]:l.id===n?.id}),children:[a.jsx("p",{children:a.jsx(mt,{to:l,children:ire(l)})}),l.category?.[0]?.text&&a.jsx("p",{children:l.category[0]?.text}),l.code?.coding?.[0]?.code&&a.jsx("p",{children:l.code.coding[0]?.code}),a.jsx("p",{children:ore(l)})]},l.id))}):null}function ire(e){if(e.identifier){for(const t of e.identifier)if(t.value)return t.value}return e.id||""}function ore(e){return e.authoredOn?e.authoredOn.substring(0,10):e.meta?.lastUpdated?e.meta.lastUpdated.substring(0,10):""}const are="_container_1l2dh_1",sre={container:are};function lre(e){const t=Gt(e.valueSet);if(!t)return null;const n=[""],r=t.compose?.include?.[0]?.concept?.map(o=>o.code);return r&&n.push(...r),e.defaultValue&&!n.includes(e.defaultValue)&&n.push(e.defaultValue),a.jsx("div",{className:sre.container,children:a.jsx(on,{defaultValue:e.defaultValue,onChange:o=>e.onChange(o.currentTarget.value),data:n})})}function cre(e){const t=Gt(e.specimen);return t?a.jsxs(ht,{children:[a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:"Type"}),a.jsx(ht.Value,{children:"Specimen"})]}),a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:"Collected"}),a.jsx(ht.Value,{children:mr(t.collection?.collectedDateTime)})]}),a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:"Specimen Age"}),a.jsx(ht.Value,{children:ure(t)})]}),t.collection?.collectedDateTime&&t.receivedTime?a.jsxs(ht.Entry,{children:[a.jsx(ht.Key,{children:"Specimen Stability"}),a.jsx(ht.Value,{children:dre(t)})]}):a.jsx(a.Fragment,{})]}):null}function ure(e){const t=e.collection?.collectedDateTime;if(!t)return;const n=new Date(t);return Ok(Mk(n,new Date))}function dre(e){if(!e.collection?.collectedDateTime||!e.receivedTime)return;const t=new Date(e.collection.collectedDateTime),n=new Date(e.receivedTime);return Ok(Mk(t,n))}function Ok(e){return e.toString().padStart(3,"0")+"D"}function Mk(e,t){const n=t.getTime()-e.getTime();return Math.floor(n/(1e3*3600*24))}function fre(e){const t=["Timeline"];return e==="Bot"&&t.push("Editor","Subscriptions"),e==="PlanDefinition"&&t.push("Apply","Builder"),e==="Questionnaire"&&t.push("Preview","Builder","Bots","Responses"),(e==="DiagnosticReport"||e==="MeasureReport")&&t.push("Report"),e==="RequestGroup"&&t.push("Checklist"),e==="ObservationDefinition"&&t.push("Ranges"),e==="Agent"&&t.push("Tools"),t.push("Details","Edit","Event","History","Blame","JSON","Apps","Profiles"),e==="Patient"&&t.push("Export"),t}function hre(){const e=Re(),{resourceType:t,id:n}=Ut(),r={reference:t+"/"+n},o=wn(),[l,c]=v.useState(),d=Gt(r,c),f=fre(t),[p,m]=v.useState(()=>{const E=window.location.pathname.split("/").pop();return E&&f.map(R=>R.toLowerCase()).includes(E)?E:f[0].toLowerCase()});async function g(){const R=(await e.readHistory(t,n)).entry?.find(D=>!!D.resource)?.resource;R?x(R):Ne({color:"red",message:"No history to restore",autoClose:!1})}function x(E){e.updateResource(Tl(E)).then(()=>{c(void 0),Ne({color:"green",message:"Success"})}).catch(R=>{Ne({color:"red",message:Ye(R),autoClose:!1})})}if(l)return Z$(l)?a.jsxs(lt,{children:[a.jsx(Ie,{children:"Deleted"}),a.jsx("p",{children:"The resource was deleted."}),a.jsx(ke,{color:"red",onClick:g,children:"Restore"})]}):a.jsx(yr,{outcome:l});function b(E){E||(E=f[0].toLowerCase()),m(E),o(`/${t}/${n}/${E}`)?.catch(console.error)}function w(E){const R=d,D=R.orderDetail||[];D.length===0&&D.push({}),D[0].text!==E&&(D[0].text=E,x({...R,orderDetail:D}))}const j=d&&bS(d),C=d&&Tee(d),T=e.getUserConfiguration()?.option?.find(E=>E.id==="statusValueSet")?.valueString;return a.jsxs(a.Fragment,{children:[d?.resourceType==="ServiceRequest"&&T&&a.jsx(lre,{valueSet:{reference:T},defaultValue:d.orderDetail?.[0]?.text,onChange:w},_t(d)+"-"+d.orderDetail?.[0]?.text),d&&a.jsx(rre,{value:d}),d&&a.jsxs(Tr,{children:[j&&a.jsx(AP,{patient:j}),C&&a.jsx(cre,{specimen:C}),t!=="Patient"&&a.jsx(Rk,{resource:r}),a.jsx(ai,{children:a.jsx(Tt,{value:p.toLowerCase(),onChange:b,children:a.jsx(Tt.List,{style:{whiteSpace:"nowrap",flexWrap:"nowrap"},children:f.map(E=>a.jsx(Tt.Tab,{value:E.toLowerCase(),children:E},E))})})})]}),a.jsx(gS,{})]})}function Ah(){const e=wn(),{resourceType:t,id:n,versionId:r,tab:o}=Ut(),l=Re(),[c,d]=v.useState(!0),[f,p]=v.useState(),[m,g]=v.useState();if(v.useEffect(()=>{g(void 0),d(!0),l.readHistory(t,n).then(R=>p(R)).then(()=>d(!1)).catch(R=>{g(R),d(!1)})},[l,t,n]),c)return a.jsx(Di,{});const x=f?.entry??[],b=x.findIndex(R=>R.resource?.meta?.versionId===r);if(b===-1)return a.jsxs(lt,{children:[a.jsx(Ie,{children:"Version not found"}),a.jsx(mt,{to:`/${t}/${n}`,children:"Return to resource"})]});const w=x[b].resource,j=b<x.length-1?x[b+1].resource:void 0,C="diff",T=o||C,E=x.length-b;return a.jsx(kd,{maw:1200,children:a.jsx(Sl,{children:a.jsxs(Be,{gap:"lg",children:[m&&a.jsx("pre",{"data-testid":"error",children:JSON.stringify(m,void 0,2)}),a.jsxs(lm,{cols:2,mb:"lg",children:[a.jsx(Oi,{total:x.length,value:E,getControlProps:TP,onChange:R=>e(`/${t}/${n}/_history/${x[x.length-R]?.resource?.meta?.versionId}/${T}`)?.catch(console.error)}),a.jsx(ye,{justify:"right",children:a.jsx(Id,{data:[{value:"diff",label:"Diff"},{value:"raw",label:"Raw"}],value:T,onChange:R=>e(`/${t}/${n}/_history/${r}/${R||C}`)?.catch(console.error)})})]}),a.jsx(ce,{mb:"lg",children:a.jsxs(Cm,{compact:!0,children:[a.jsx(Ti,{term:"Version ID",children:w.meta?.versionId}),a.jsx(Ti,{term:"Author",children:a.jsx(Tc,{value:w.meta?.author,link:!0},w.meta?.author?.reference)}),a.jsx(Ti,{term:"Date/Time",children:mr(w.meta?.lastUpdated)})]})}),T==="diff"&&a.jsx(eZ,{original:j??{resourceType:t,id:n},revised:w}),T==="raw"&&a.jsx("pre",{style:{fontSize:"9pt"},children:JSON.stringify(w,void 0,2)})]})})})}function pre(){const{resourceType:e,id:t}=Ut(),n=wn(),[r,o]=v.useState({resourceType:"Subscription",filters:[{code:"url",operator:de.EQUALS,value:`${e}/${t}`}],fields:["id","criteria","status","_lastUpdated"]});return a.jsx(lt,{children:a.jsx(sK,{search:r,onClick:l=>n(`/${l.resource.resourceType}/${l.resource.id}`)?.catch(console.error),onChange:l=>o(l.definition),hideFilters:!0})})}function mre(e){const t=Re(),{resource:n,opened:r,onClose:o}=e,[l,c]=v.useState(!1),[d,f]=v.useState(),[p,m]=v.useState(!1),g=v.useCallback(async()=>{if(n?.id)try{await t.post(t.fhirUrl(n.resourceType,n.id,"$resend"),{subscription:l&&d?_t(d):void 0,verbose:p}),Ne({color:"green",message:"Done"}),o()}catch(x){Ne({color:"red",message:Ye(x),autoClose:!1})}},[t,n,o,l,d,p]);return a.jsx(Un,{opened:r,onClose:o,title:"Resend Subscriptions",children:a.jsx(ut,{onSubmit:g,children:a.jsxs(Be,{children:[a.jsx(Pn,{label:"Choose subscription (all subscriptions by default)",onChange:x=>c(x.currentTarget.checked)}),l&&a.jsx(wl,{name:"subscription",resourceType:"Subscription",placeholder:"Subscription",onChange:f}),a.jsx(Pn,{label:"Verbose mode",onChange:x=>m(x.currentTarget.checked)}),a.jsx(ye,{justify:"flex-end",children:a.jsx(ke,{type:"submit",children:"Resend"})})]})})})}function RR(){const e=Re(),t=bm(),{resourceType:n,id:r}=Ut(),o={reference:n+"/"+r},[l,c]=v.useState(),d=wd(!1);function f(E,R){return e.updateResource({...E,priority:R})}function p(E,R){f(E,"stat").then(R).catch(console.error)}function m(E,R){f(E,"routine").then(R).catch(console.error)}function g(E){t(`/${E.resourceType}/${E.id}`)}function x(E){t(`/${E.resourceType}/${E.id}/edit`)}function b(E){t(`/${E.resourceType}/${E.id}/delete`)}function w(E){c(E),d[1].open()}function j(E){t(`/${E.resourceType}/${E.id}/_history/${E.meta?.versionId}`)}function C(E,R){const D="aws-textract";Ne({id:D,title:"AWS Textract in Progress",message:"Extracting text... This may take a moment...",loading:!0,autoClose:!1}),e.post(e.fhirUrl(E.resourceType,E.id,"$aws-textract"),{}).then(()=>{R(),Qs({id:D,title:"AWS Textract Successful",message:"Text successfully extracted.",color:"green",icon:a.jsx(Po,{size:"1rem"}),loading:!1,withCloseButton:!0})}).catch(P=>Qs({id:D,title:"AWS Textract Error",color:"red",message:Ye(P),icon:a.jsx(sl,{size:"1rem"}),loading:!1,withCloseButton:!0}))}function T(E){const{primaryResource:R,currentResource:D,reloadTimeline:P}=E,A=D.resourceType===R.resourceType&&D.id===R.id,k=D.resourceType==="Communication"&&D.priority!=="stat",M=D.resourceType==="Communication"&&D.priority==="stat",$=A,U=!A,J=!A,Z=!A,Y=e.getProjectMembership()?.admin,H=Y,Q=vne()&&(D.resourceType==="DocumentReference"||D.resourceType==="Media");return a.jsxs(je.Dropdown,{children:[a.jsx(je.Label,{children:"Resource"}),k&&a.jsx(je.Item,{leftSection:a.jsx(Tq,{size:14}),onClick:()=>p(D,P),"aria-label":`Pin ${_t(D)}`,children:"Pin"}),M&&a.jsx(je.Item,{leftSection:a.jsx(_q,{size:14}),onClick:()=>m(D,P),"aria-label":`Unpin ${_t(D)}`,children:"Unpin"}),U&&a.jsx(je.Item,{leftSection:a.jsx(dT,{size:14}),onClick:()=>g(D),"aria-label":`Details ${_t(D)}`,children:"Details"}),$&&a.jsx(je.Item,{leftSection:a.jsx(dT,{size:14}),onClick:()=>j(D),"aria-label":`Details ${_t(D)}`,children:"Details"}),J&&a.jsx(je.Item,{leftSection:a.jsx(IA,{size:14}),onClick:()=>x(D),"aria-label":`Edit ${_t(D)}`,children:"Edit"}),Y&&a.jsxs(a.Fragment,{children:[a.jsx(je.Divider,{}),a.jsx(je.Label,{children:"Admin"}),H&&a.jsx(je.Item,{leftSection:a.jsx(Lq,{size:14}),onClick:()=>w(D),"aria-label":`Resend Subscriptions ${_t(D)}`,children:"Resend Subscriptions"})]}),Q&&a.jsxs(a.Fragment,{children:[a.jsx(je.Divider,{}),a.jsx(je.Label,{children:"AWS AI"}),a.jsx(je.Item,{leftSection:a.jsx(tG,{size:14}),onClick:()=>C(D,P),"aria-label":`AWS Textract ${_t(D)}`,children:"AWS Textract"})]}),Z&&a.jsxs(a.Fragment,{children:[a.jsx(je.Divider,{}),a.jsx(je.Label,{children:"Danger zone"}),a.jsx(je.Item,{color:"red",leftSection:a.jsx(wm,{size:14}),onClick:()=>b(D),"aria-label":`Delete ${_t(D)}`,children:"Delete"})]})]})}return a.jsxs(a.Fragment,{children:[n==="Encounter"&&a.jsx(mY,{encounter:o,getMenu:T}),n==="Patient"&&a.jsx(_K,{patient:o,getMenu:T}),n==="ServiceRequest"&&a.jsx(sZ,{serviceRequest:o,getMenu:T}),n!=="Encounter"&&n!=="Patient"&&n!=="ServiceRequest"&&a.jsx(pY,{resource:o,getMenu:T}),a.jsx(mre,{resource:l,opened:d[0],onClose:d[1].close},`resend-subscriptions-${l?.id}`)]})}function gre(e){const{opened:t,close:n,version:r,loadingStatus:o,handleStatus:l,handleUpgrade:c}=e,[d,f]=v.useState(),[p,m]=v.useState(!1);return v.useEffect(()=>{t&&(d||SF("app-tools-page").then(f).catch(console.error),l())},[t,d,l]),d&&r&&!o?r==="unknown"?a.jsx("p",{children:"Unable to determine the current version of the agent. Check the network connectivity of the agent."}):r.startsWith(d)?a.jsxs("p",{children:["This agent is already on the latest version (",d,")."]}):a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["Are you sure you want to upgrade this agent from version ",r," to version ",d,"?"]}),a.jsxs(ye,{children:[a.jsx(ke,{onClick:()=>{c(p),n()},"aria-label":"Confirm upgrade",children:"Confirm Upgrade"}),a.jsx(Pn,{label:"Force",onChange:g=>m(g.currentTarget.checked)})]})]}):a.jsx(Di,{})}function vre(){const e=Re(),{id:t}=Ut(),n=v.useMemo(()=>({reference:"Agent/"+t}),[t]),[r,o]=v.useState(!1),[l,c]=v.useState(!1),[d,f]=v.useState(!1),[p,m]=v.useState(!1),[g,x]=v.useState(),[b,w]=v.useState(),[j,C]=v.useState(),[T,E]=v.useState(),[R,D]=v.useState(!1),[P,A]=v.useState(!1),[k,M]=v.useState(),[$,{open:U,close:J}]=wd(!1);v.useEffect(()=>{if(r||l||d||R){A(!0);return}A(!1)},[r,l,d,R]);const Z=v.useCallback(()=>{o(!0),e.get(e.fhirUrl("Agent",t,"$status"),{cache:"reload"}).then(F=>{x(F.parameter?.find(K=>K.name==="status")?.valueCode),w(F.parameter?.find(K=>K.name==="version")?.valueString),C(F.parameter?.find(K=>K.name==="lastUpdated")?.valueInstant)}).catch(F=>z(Ye(F))).finally(()=>o(!1))},[e,t]),Y=v.useCallback(F=>{const K=F.host,L=F.pingCount||1;K&&(D(!0),e.pushToAgent(n,K,`PING ${L}`,ln.PING,!0).then(q=>E(q)).catch(q=>z(Ye(q))).finally(()=>D(!1)))},[e,n]),H=v.useCallback(()=>{c(!0),e.get(e.fhirUrl("Agent",t,"$reload-config"),{cache:"reload"}).then(F=>{I("Agent config reloaded successfully.")}).catch(F=>z(Ye(F))).finally(()=>c(!1))},[e,t]),Q=v.useCallback(F=>{f(!0);const K=e.fhirUrl("Agent",t,"$upgrade");K.searchParams.set("force",String(F)),e.get(K,{cache:"reload"}).then(L=>{I("Agent upgraded successfully.")}).catch(L=>z(Ye(L))).finally(()=>f(!1))},[e,t]),O=v.useCallback(F=>{m(!0);const K=F.logLimit||20;e.get(e.fhirUrl("Agent",t,`$fetch-logs${K!==void 0?`?limit=${K}`:""}`),{cache:"reload"}).then(L=>{const q=L?.parameter?.find(ie=>ie.name==="logs");q&&M(q?.valueString)}).catch(L=>z(Ye(L))).finally(()=>m(!1))},[e,t]);function I(F){Ne({color:"green",title:"Success",icon:a.jsx(Po,{size:"1rem"}),message:F})}function z(F){Ne({color:"red",title:"Error",message:F,autoClose:!1})}return a.jsxs(lt,{children:[a.jsx(Un,{opened:$,onClose:J,title:"Upgrade Agent",centered:!0,children:a.jsx(gre,{opened:$,close:J,version:b,loadingStatus:r,handleStatus:Z,handleUpgrade:Q})}),a.jsx(Ie,{order:1,children:"Agent Tools"}),a.jsxs("div",{style:{marginBottom:10},children:["Agent: ",a.jsx(jl,{value:n,link:!0})]}),a.jsx(pn,{my:"lg"}),a.jsx(Ie,{order:2,children:"Agent Status"}),a.jsx("p",{children:"Retrieve the status of the agent. This tests whether the agent is connected to the Medplum server, and the last time it was able to communicate."}),a.jsx(ke,{onClick:Z,loading:r,disabled:P&&!r,children:"Get Status"}),!r&&g&&a.jsx(fe,{children:a.jsxs(fe.Tbody,{children:[a.jsxs(fe.Tr,{children:[a.jsx(fe.Td,{children:"Status"}),a.jsx(fe.Td,{children:a.jsx(Rm,{status:g})})]}),a.jsxs(fe.Tr,{children:[a.jsx(fe.Td,{children:"Version"}),a.jsx(fe.Td,{children:b})]}),a.jsxs(fe.Tr,{children:[a.jsx(fe.Td,{children:"Last Updated"}),a.jsx(fe.Td,{children:mr(j,void 0,{timeZoneName:"longOffset"})})]})]})}),a.jsx(pn,{my:"lg"}),a.jsx(Ie,{order:2,children:"Reload Config"}),a.jsx("p",{children:"Reload the configuration of this agent, syncing it with the current version of the Agent resource on the Medplum server."}),a.jsx(ke,{onClick:H,loading:l,disabled:P&&!l,"aria-label":"Reload config",children:"Reload Config"}),a.jsx(pn,{my:"lg"}),a.jsx(Ie,{order:2,children:"Upgrade Agent"}),a.jsx("p",{children:"Upgrade the version of this agent, to either the latest (default) or a specified version."}),a.jsx(ke,{onClick:U,loading:d,disabled:P&&!d,"aria-label":"Upgrade agent",children:"Upgrade"}),a.jsx(pn,{my:"lg"}),a.jsxs(ut,{onSubmit:O,children:[a.jsx(Ie,{order:2,children:"Fetch Logs"}),a.jsx("p",{children:"Fetch logs from the agent."}),k?.length?a.jsx(Pd,{block:!0,mb:15,children:k}):null,a.jsxs(ye,{children:[a.jsx(Oc,{w:100,id:"logLimit",name:"logLimit",placeholder:"20",label:"Log Limit"}),a.jsx(ke,{mt:22,loading:p,disabled:P&&!p,"aria-label":"Fetch logs",type:"submit",children:"Fetch Logs"})]})]}),a.jsx(pn,{my:"lg"}),a.jsx(Ie,{order:2,children:"Ping from Agent"}),a.jsx("p",{children:"Send a ping command from the agent to a valid IP address or hostname. Use this tool to troubleshoot local network connectivity."}),a.jsx(ut,{onSubmit:Y,children:a.jsxs(ye,{children:[a.jsx(Ve,{id:"host",name:"host",placeholder:"ex. 127.0.0.1",label:"IP Address / Hostname",rightSection:a.jsx(bn,{size:24,radius:"xl",variant:"filled",type:"submit","aria-label":"Ping",loading:R,disabled:P&&!R,children:a.jsx(Uq,{style:{width:"1rem",height:"1rem"},stroke:1.5})})}),a.jsx(Oc,{id:"pingCount",name:"pingCount",placeholder:"1",label:"Ping Count"})]})}),!R&&T&&a.jsxs(a.Fragment,{children:[a.jsx(Ie,{order:5,mt:"sm",mb:0,children:"Last Ping"}),a.jsx("pre",{children:T})]})]})}function yre(){const e=wn(),t=Re(),[n,r]=v.useState();v.useEffect(()=>{t.get("auth/me",{cache:"no-cache"}).then(r).catch(l=>Ne({color:"red",message:Ye(l),autoClose:!1}))},[t]);function o(l){t.post("auth/revoke",{loginId:l}).then(()=>t.get("auth/me",{cache:"no-cache"})).then(r).then(()=>Ne({color:"green",message:"Login revoked"})).catch(c=>Ne({color:"red",message:Ye(c),autoClose:!1}))}return n?a.jsxs(a.Fragment,{children:[a.jsxs(lt,{children:[a.jsx(Ie,{children:"Security"}),a.jsxs(Cm,{children:[a.jsx(Ti,{term:"ID",children:a.jsx(Dt,{href:`/${_t(n.profile)}`,children:n.profile.id})}),a.jsx(Ti,{term:"Resource Type",children:n.profile.resourceType}),a.jsx(Ti,{term:"Name",children:Jc(n.profile.name?.[0])})]})]}),a.jsxs(lt,{children:[a.jsx(Ie,{children:"Sessions"}),a.jsxs(fe,{children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"OS"}),a.jsx("th",{children:"Browser"}),a.jsx("th",{children:"IP Address"}),a.jsx("th",{children:"Auth Method"}),a.jsx("th",{children:"Last Updated"}),a.jsx("th",{})]})}),a.jsx("tbody",{children:n.security.sessions.map(l=>a.jsxs("tr",{children:[a.jsx("td",{children:l.os}),a.jsx("td",{children:l.browser}),a.jsx("td",{children:l.remoteAddress}),a.jsx("td",{children:l.authMethod}),a.jsx("td",{children:mr(l.lastUpdated)}),a.jsx("td",{children:a.jsx(Dt,{href:"#",onClick:()=>o(l.id),children:"Revoke"})})]},l.id))})]})]}),a.jsxs(lt,{children:[a.jsx(Ie,{children:"Password"}),a.jsx(ke,{onClick:()=>e("/changepassword")?.catch(console.error),children:"Change password"})]}),a.jsxs(lt,{children:[a.jsx(Ie,{children:"Multi Factor Auth"}),a.jsxs("p",{children:["Enrolled: ",n.security.mfaEnrolled.toString()]}),!n.security.mfaEnrolled&&a.jsx(ke,{onClick:()=>e("/mfa")?.catch(console.error),children:"Enroll"})]})]}):null}function xre(){const{id:e,secret:t}=Ut(),n=Re(),[r,o]=v.useState(),[l,c]=v.useState(!1),d=tu(r,void 0);return a.jsxs(lt,{width:450,children:[a.jsx(yr,{issues:d}),a.jsxs(ut,{onSubmit:f=>{if(f.password!==f.confirmPassword){o(xo("Passwords do not match","confirmPassword"));return}o(void 0);const p={id:e,secret:t,password:f.password};n.post("auth/setpassword",p).then(()=>c(!0)).catch(m=>o(qt(m)))},children:[a.jsxs(ar,{style:{flexDirection:"column"},children:[a.jsx(Mi,{size:32}),a.jsx(Ie,{children:"Set password"})]}),!l&&a.jsxs(Be,{children:[a.jsx(Qi,{name:"password",label:"New password",required:!0,error:At(r,"password")}),a.jsx(Qi,{name:"confirmPassword",label:"Confirm new password",required:!0,error:At(r,"confirmPassword")}),a.jsx(ye,{justify:"flex-end",mt:"xl",children:a.jsx(ke,{type:"submit",children:"Set password"})})]}),l&&a.jsxs("div",{"data-testid":"success",children:["Password set. You can now ",a.jsx(mt,{to:"/signin",children:"sign in"}),"."]})]})]})}function bre(){const e=Sm(),t=wn(),[n]=xS(),r=ef(),o=v.useCallback(()=>{const l=n.get("next");t(l?.startsWith("/")?l:"/")?.catch(console.error)},[n,t]);return v.useEffect(()=>{e&&n.has("next")&&o()},[e,n,o]),a.jsxs(rP,{onSuccess:()=>o(),onForgotPassword:()=>t("/resetpassword")?.catch(console.error),onRegister:Dk()?()=>t("/register")?.catch(console.error):void 0,googleClientId:r.googleClientId,login:n.get("login")||void 0,projectId:n.get("project")||void 0,children:[a.jsx(Mi,{size:32}),a.jsxs(Ie,{children:["Sign in to ",GA()]}),n.get("project")==="new"&&a.jsx("div",{children:"Sign in again to create a new project"})]})}function Sre(){const e=wn(),t=Gr(),[n,r]=v.useState(),[o,l]=v.useState(),[c,d]=v.useState();return v.useEffect(()=>{const f=Object.fromEntries(new URLSearchParams(t.search).entries());r(f.resourceType),l(f.query),d(JSON.parse(f.fields))},[t]),!n||!o||!c?null:a.jsx(hK,{resourceType:n,checkboxesEnabled:!0,query:o,fields:c,onClick:f=>e(`/${n}/${f.resource.id}`)?.catch(console.error),onAuxClick:f=>window.open(`/${n}/${f.resource.id}`,"_blank"),onBulk:f=>{e(`/bulk/${n}?ids=${f.join(",")}`)?.catch(console.error)}})}function wre(){const{id:e,secret:t}=Ut(),n=Re(),[r,o]=v.useState(),[l,c]=v.useState(!1),d=tu(r,void 0);return a.jsxs(lt,{width:450,children:[a.jsx(yr,{issues:d}),a.jsxs(ut,{onSubmit:()=>{o(void 0);const f={id:e,secret:t};n.post("auth/verifyemail",f).then(()=>c(!0)).catch(p=>o(qt(p)))},children:[a.jsxs(ar,{style:{flexDirection:"column"},children:[a.jsx(Mi,{size:32}),a.jsx(Ie,{children:"Email address verification required"})]}),!l&&a.jsxs(Be,{children:[a.jsx("p",{children:"In order to sign in, click the button below to verify your ability to receive email at the address this link was sent to."}),a.jsx(ye,{justify:"flex-end",mt:"xl",children:a.jsx(ke,{type:"submit",children:"Verify email"})})]}),l&&a.jsxs("div",{"data-testid":"success",children:["Email verified. You can now ",a.jsx(mt,{to:"/signin",children:"sign in"}),"."]})]})]})}function jre(){return a.jsx(HJ,{children:a.jsxs(Ue,{errorElement:a.jsx(nne,{}),children:[a.jsx(Ue,{path:"/signin",element:a.jsx(bre,{})}),a.jsx(Ue,{path:"/oauth",element:a.jsx(yne,{})}),a.jsx(Ue,{path:"/resetpassword",element:a.jsx(bne,{})}),a.jsx(Ue,{path:"/setpassword/:id/:secret",element:a.jsx(xre,{})}),a.jsx(Ue,{path:"/verifyemail/:id/:secret",element:a.jsx(wre,{})}),a.jsx(Ue,{path:"/register",element:a.jsx(xne,{})}),a.jsx(Ue,{path:"/changepassword",element:a.jsx(Jte,{})}),a.jsx(Ue,{path:"/security",element:a.jsx(yre,{})}),a.jsx(Ue,{path:"/mfa",element:a.jsx(mne,{})}),a.jsx(Ue,{path:"/batch",element:a.jsx(Xte,{})}),a.jsx(Ue,{path:"/bulk/:resourceType",element:a.jsx(Zte,{})}),a.jsx(Ue,{path:"/smart",element:a.jsx(Sre,{})}),a.jsx(Ue,{path:"/forms/:id",element:a.jsx(rne,{})}),a.jsx(Ue,{path:"/admin/super",element:a.jsx(Jee,{})}),a.jsx(Ue,{path:"/admin/super/asyncjob",element:a.jsx(Qee,{})}),a.jsx(Ue,{path:"/admin/super/db",element:a.jsx(zee,{})}),a.jsx(Ue,{path:"/admin/config",element:a.jsx(Fee,{})}),a.jsxs(Ue,{path:"/admin",element:a.jsx(Hee,{}),children:[a.jsx(Ue,{path:"patients",element:a.jsx(Vee,{})}),a.jsx(Ue,{path:"bots/new",element:a.jsx(Dee,{})}),a.jsx(Ue,{path:"bots",element:a.jsx(Ree,{})}),a.jsx(Ue,{path:"clients/new",element:a.jsx(Aee,{})}),a.jsx(Ue,{path:"clients",element:a.jsx(_ee,{})}),a.jsx(Ue,{path:"details",element:a.jsx(cR,{})}),a.jsx(Ue,{path:"invite",element:a.jsx(Bee,{})}),a.jsx(Ue,{path:"users",element:a.jsx(nte,{})}),a.jsx(Ue,{path:"project",element:a.jsx(cR,{})}),a.jsx(Ue,{path:"secrets",element:a.jsx(qee,{})}),a.jsx(Ue,{path:"sites",element:a.jsx(Gee,{})}),a.jsx(Ue,{path:"members/:membershipId",element:a.jsx(Uee,{})})]}),a.jsx(Ue,{path:"/lab/assays",element:a.jsx(hne,{})}),a.jsx(Ue,{path:"/lab/panels",element:a.jsx(pne,{})}),a.jsxs(Ue,{path:"/:resourceType/new",element:a.jsx(tne,{}),children:[a.jsx(Ue,{index:!0,element:a.jsx(Uy,{})}),a.jsx(Ue,{path:"form",element:a.jsx(Uy,{})}),a.jsx(Ue,{path:"json",element:a.jsx(Fne,{})}),a.jsx(Ue,{path:"profiles",element:a.jsx(Uy,{})})]}),a.jsxs(Ue,{path:"/:resourceType/:id",element:a.jsx(hre,{}),children:[a.jsx(Ue,{index:!0,element:a.jsx(RR,{})}),a.jsx(Ue,{path:"apply",element:a.jsx(wne,{})}),a.jsx(Ue,{path:"apps",element:a.jsx(jne,{})}),a.jsx(Ue,{path:"event",element:a.jsx(Ene,{})}),a.jsx(Ue,{path:"blame",element:a.jsx(Tne,{})}),a.jsx(Ue,{path:"bots",element:a.jsx(Yne,{})}),a.jsx(Ue,{path:"builder",element:a.jsx(Mne,{})}),a.jsx(Ue,{path:"checklist",element:a.jsx(Lne,{})}),a.jsx(Ue,{path:"delete",element:a.jsx(Ine,{})}),a.jsx(Ue,{path:"details",element:a.jsx(Une,{})}),a.jsx(Ue,{path:"edit",element:a.jsx(Bne,{})}),a.jsx(Ue,{path:"editor",element:a.jsx(Nne,{})}),a.jsxs(Ue,{path:"history",children:[a.jsx(Ue,{index:!0,element:a.jsx(TR,{})}),a.jsx(Ue,{path:":versionId/:tab",element:a.jsx(Ah,{})}),a.jsx(Ue,{path:":versionId",element:a.jsx(Ah,{})})]}),a.jsxs(Ue,{path:"_history",children:[a.jsx(Ue,{index:!0,element:a.jsx(TR,{})}),a.jsx(Ue,{path:":versionId/:tab",element:a.jsx(Ah,{})}),a.jsx(Ue,{path:":versionId",element:a.jsx(Ah,{})})]}),a.jsx(Ue,{path:"json",element:a.jsx(Hne,{})}),a.jsx(Ue,{path:"preview",element:a.jsx(qne,{})}),a.jsx(Ue,{path:"responses",element:a.jsx(Xne,{})}),a.jsx(Ue,{path:"report",element:a.jsx(Jne,{})}),a.jsx(Ue,{path:"ranges",element:a.jsx(Zne,{})}),a.jsx(Ue,{path:"subscriptions",element:a.jsx(pre,{})}),a.jsx(Ue,{path:"timeline",element:a.jsx(RR,{})}),a.jsx(Ue,{path:"tools",element:a.jsx(vre,{})}),a.jsx(Ue,{path:"profiles",element:a.jsx(Gne,{})}),a.jsx(Ue,{path:"export",element:a.jsx(Vne,{})})]}),a.jsx(Ue,{path:"/:resourceType",element:a.jsx(jR,{})}),a.jsx(Ue,{path:"/",element:a.jsx(jR,{})})]})})}function Cre(){const e=Re(),t=e.getUserConfiguration(),n=Gr(),[r]=xS();return e.isLoading()?a.jsx(Di,{}):a.jsx(eQ,{logo:a.jsx(Mi,{size:24}),pathname:n.pathname,searchParams:r,version:xA,menus:Ere(t),displayAddBookmark:!!t?.id,children:a.jsx(v.Suspense,{fallback:a.jsx(Di,{}),children:a.jsx(jre,{})})})}function Ere(e){const t=e?.menu?.map(n=>({title:n.title,links:n.link?.map(r=>({label:r.name,href:r.target,icon:Tre(r.target)}))||[]}))||[];return t.push({title:"Settings",links:[{label:"Security",href:"/security",icon:a.jsx(fq,{})}]}),t}const _R={Patient:Yq,Practitioner:sq,Organization:CH,ServiceRequest:Nq,DiagnosticReport:zq,Questionnaire:oq,admin:yH,AccessPolicy:uq,Subscription:oG,batch:Cq,Observation:bq};function Tre(e){if(e.includes("admin/super/db"))return a.jsx(BH,{});try{const t=new URL(e,"https://app.medplum.com").pathname.split("/")[1];if(t in _R){const n=_R[t];return a.jsx(n,{})}}catch{}return a.jsx(cm,{w:30})}async function Rre(){const e=ef(),t=new bA({baseUrl:e.baseUrl,clientId:e.clientId,cacheTime:6e4,autoBatchTime:100,onUnauthenticated:()=>{window.location.pathname!=="/signin"&&window.location.pathname!=="/oauth"&&(window.location.href="/signin?next="+encodeURIComponent(window.location.pathname+window.location.search))}}),n={headings:{sizes:{h1:{fontSize:"1.125rem",fontWeight:"500",lineHeight:"2.0"}}},fontSizes:{xs:"0.6875rem",sm:"0.875rem",md:"0.875rem",lg:"1.0rem",xl:"1.125rem"}},r=pee([{path:"*",element:a.jsx(Cre,{})}]),o=c=>r.navigate(c);hZ.createRoot(document.getElementById("root")).render(a.jsx(v.StrictMode,{children:a.jsx(wF,{medplum:t,navigate:o,children:a.jsxs(JR,{theme:n,children:[a.jsx(Sa,{position:"bottom-right"}),a.jsx(UJ,{router:r})]})})}))}Rre().catch(console.error);
|
|
607
|
-
//# sourceMappingURL=index-
|
|
607
|
+
//# sourceMappingURL=index-CqVoJmTZ.js.map
|