@medplum/app 5.1.14 → 5.1.15

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.
@@ -50,10 +50,10 @@ ${o?`${s(`light`)}{${o}}`:``}`}function Er({color:e,theme:t,autoContrast:n}){ret
50
50
  Prefix can't start with '-' when allowNegative is true.
51
51
  prefix: `+i+`
52
52
  allowNegative: `+a+`
53
- `),a=!1),Object.assign(Object.assign({},e),{allowNegative:a})}function __(e){e=g_(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,n=e.allowNegative,r=e.allowLeadingZeros,i=e.onKeyDown;i===void 0&&(i=Mg);var a=e.onBlur;a===void 0&&(a=Mg);var o=e.thousandSeparator,s=e.decimalScale,c=e.fixedDecimalScale,l=e.prefix;l===void 0&&(l=``);var u=e.defaultValue,d=e.value,f=e.valueIsNumericString,p=e.onValueChange,m=Ag(e,[`decimalSeparator`,`allowedDecimalSeparators`,`thousandsGroupStyle`,`suffix`,`allowNegative`,`allowLeadingZeros`,`onKeyDown`,`onBlur`,`thousandSeparator`,`decimalScale`,`fixedDecimalScale`,`prefix`,`defaultValue`,`value`,`valueIsNumericString`,`onValueChange`]),h=u_(e),g=h.decimalSeparator,_=h.allowedDecimalSeparators,v=function(t){return l_(t,e)},y=function(t,n){return m_(t,n,e)},b=Fg(d)?u:d,x=f??p_(b,l,t);Fg(d)?Fg(u)||(x||=typeof u==`number`):x||=typeof d==`number`;var S=function(e){return Lg(e)?e:(typeof e==`number`&&(e=Kg(e)),x&&typeof s==`number`?qg(e,s,!!c):e)},C=a_(S(d),S(u),!!x,v,y,p),w=C[0],T=w.numAsString,E=w.formattedValue,D=C[1];return Object.assign(Object.assign({},m),{value:E,valueIsNumericString:!1,isValidInputCharacter:function(e){return e===g?!0:Pg(e)},isCharacterSame:function(e){var t=e.currentValue,n=e.lastValue,r=e.formattedValue,i=e.currentValueIndex,a=e.formattedValueIndex,o=t[i],u=r[a],f=Yg(n,t).to,p=function(e){return y(e).indexOf(`.`)+l.length};return d===0&&c&&s&&t[f.start]===g&&p(t)<i&&p(r)>a?!1:i>=f.start&&i<f.end&&_&&_.includes(o)&&u===g?!0:o===u},onValueChange:D,format:v,removeFormatting:y,getCaretBoundary:function(t){return h_(t,e)},onKeyDown:function(e){var t=e.target,r=e.key,a=t.selectionStart,u=t.selectionEnd,d=t.value;if(d===void 0&&(d=``),(r===`Backspace`||r===`Delete`)&&u<l.length&&d!==`-`){e.preventDefault();return}if(a!==u){i(e);return}r===`Backspace`&&d[0]===`-`&&a===l.length+1&&n&&Jg(t,1),s&&c&&(r===`Backspace`&&d[a-1]===g?(Jg(t,a-1),e.preventDefault()):r===`Delete`&&d[a]===g&&e.preventDefault()),_?.includes(r)&&d[a]===g&&Jg(t,a+1);var f=o===!0?`,`:o;r===`Backspace`&&d[a-1]===f&&Jg(t,a-1),r===`Delete`&&d[a]===f&&Jg(t,a+1),i(e)},onBlur:function(t){var n=T;n.match(/\d/g)||(n=``),r||(n=Ug(n)),c&&s&&(n=qg(n,s,c)),n!==T&&D({formattedValue:l_(n,e),value:n,floatValue:parseFloat(n)},{event:t,source:jg.event}),a(t)}})}function v_(e){var t=__(e);return b.createElement(c_,Object.assign({},t))}var y_={root:`m_e2f5cd4e`,controls:`m_95e17d22`,control:`m_80b4b171`};function b_({direction:e,style:t,...n}){return(0,L.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:(0,L.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 x_=/^(0\.0*|-0(\.0*)?)$/,S_=/^-?0\d+(\.\d+)?\.?$/,C_=/\.\d*0$/,w_=/^-?\d+\.$/;function T_(e){return typeof e==`string`&&e!==``&&!Number.isNaN(Number(e))}function E_(e){return typeof e==`number`?e<2**53-1:e===``||T_(e)&&Number(e)<2**53-1}function D_(e){return e.toString().replace(`.`,``).length}function O_(e,t){return(typeof e==`number`?e<2**53-1:!Number.isNaN(Number(e)))&&!Number.isNaN(e)&&D_(t)<14&&t!==``}function k_(e,t,n){return e===void 0?!0:(t===void 0||e>=t)&&(n===void 0||e<=n)}var A_={step:1,clampBehavior:`blur`,allowDecimal:!0,allowNegative:!0,withKeyboardEvents:!0,allowLeadingZeros:!0,trimLeadingZeroesOnBlur:!0,startValue:0,allowedDecimalSeparators:[`.`,`,`]},j_=kn((e,{size:t})=>({controls:{"--ni-chevron-size":dt(t,`ni-chevron-size`)}}));function M_(e,t,n){let r=e.toString(),i=w_.test(r),a=r.replace(/^0+(?=\d)/,``),o=parseFloat(a);if(Number.isNaN(o))return a;if(o>2**53-1)return t===void 0?a:t;let s=St(o,n,t);return i?`${s.toString().replace(/^0+(?=\d)/,``)}.`:s}var N_=V((e,t)=>{let n=z(`NumberInput`,A_,e),{className:r,classNames:i,styles:a,unstyled:o,vars:s,onChange:c,onValueChange:l,value:u,defaultValue:d,max:f,min:p,step:m,hideControls:h,rightSection:g,isAllowed:_,clampBehavior:v,onBlur:y,allowDecimal:x,decimalScale:S,onKeyDown:C,onKeyDownCapture:w,handlersRef:T,startValue:E,disabled:D,rightSectionPointerEvents:O,allowNegative:k,readOnly:A,size:j,rightSectionWidth:M,stepHoldInterval:N,stepHoldDelay:P,allowLeadingZeros:F,withKeyboardEvents:ee,trimLeadingZeroesOnBlur:te,allowedDecimalSeparators:ne,attributes:re,...ie}=n,ae=R({name:`NumberInput`,classes:y_,props:n,classNames:i,styles:a,unstyled:o,attributes:re,vars:s,varsResolver:j_}),{resolvedClassNames:oe,resolvedStyles:se}=Hr({classNames:i,styles:a,props:n}),[ce,le]=rn({value:u,defaultValue:d,finalValue:``,onChange:c}),ue=P!==void 0&&N!==void 0,de=(0,b.useRef)(null),fe=(0,b.useRef)(null),pe=(0,b.useRef)(0),me=(e,t)=>{t.source===`event`&&le(O_(e.floatValue,e.value)&&!x_.test(e.value)&&!(F&&S_.test(e.value))&&!C_.test(e.value)&&!w_.test(e.value)?e.floatValue:e.value),l?.(e,t)},he=e=>{let t=String(e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0},ge=e=>{de.current&&e!==void 0&&de.current.setSelectionRange(e,e)},_e=(0,b.useRef)(lt);_e.current=()=>{if(!E_(ce))return;let e,t=he(ce),n=he(m),r=Math.max(t,n),i=10**r;if(!T_(ce)&&(typeof ce!=`number`||Number.isNaN(ce)))e=St(E,p,f);else if(f!==void 0){let t=(Math.round(Number(ce)*i)+Math.round(m*i))/i;e=t<=f?t:f}else e=(Math.round(Number(ce)*i)+Math.round(m*i))/i;let a=e.toFixed(r);le(parseFloat(a)),l?.({floatValue:parseFloat(a),formattedValue:a,value:a},{source:`increment`}),setTimeout(()=>ge(de.current?.value.length),0)};let ve=(0,b.useRef)(lt);ve.current=()=>{if(!E_(ce))return;let e,t=p===void 0?k?-(2**53-1):0:p,n=he(ce),r=he(m),i=Math.max(n,r),a=10**i;if(!T_(ce)&&typeof ce!=`number`||Number.isNaN(ce))e=St(E,t,f);else{let n=(Math.round(Number(ce)*a)-Math.round(m*a))/a;e=t!==void 0&&n<t?t:n}let o=e.toFixed(i);le(parseFloat(o)),l?.({floatValue:parseFloat(o),formattedValue:o,value:o},{source:`decrement`}),setTimeout(()=>ge(de.current?.value.length),0)};let ye=e=>{let t=e.clipboardData.getData(`text`),n=ie.decimalSeparator||`.`,r=(ne||[`.`,`,`]).filter(e=>e!==n);if(r.some(e=>t.includes(e))){e.preventDefault();let i=t;r.forEach(e=>{i=i.split(e).join(n)});let a=de.current;if(a){let e=a.selectionStart??0,t=a.selectionEnd??0,n=a.value,r=n.substring(0,e)+i+n.substring(t);(Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,`value`)?.set)?.call(a,r),a.dispatchEvent(new Event(`change`,{bubbles:!0}));let o=e+i.length;setTimeout(()=>ge(o),0)}}ie.onPaste?.(e)},be=e=>{C?.(e),!(A||!ee)&&(e.key===`ArrowUp`&&(e.preventDefault(),_e.current?.()),e.key===`ArrowDown`&&(e.preventDefault(),ve.current?.()))},xe=e=>{if(w?.(e),e.key===`Backspace`){let t=de.current;t&&t.selectionStart===0&&t.selectionStart===t.selectionEnd&&(e.preventDefault(),window.setTimeout(()=>ge(0),0))}},Se=e=>{let t=ce;v===`blur`&&typeof t==`number`&&(t=St(t,p,f)),te&&typeof t==`string`&&he(t)<15&&(t=M_(t,f,p)),ce!==t&&le(t),y?.(e)};en(T,{increment:_e.current,decrement:ve.current});let Ce=e=>{e?_e.current?.():ve.current?.(),pe.current+=1},we=e=>{if(Ce(e),ue){let t=typeof N==`number`?N:N(pe.current);fe.current=window.setTimeout(()=>we(e),t)}},Te=(e,t)=>{e.preventDefault(),de.current?.focus(),Ce(t),ue&&(fe.current=window.setTimeout(()=>we(t),P))},Ee=()=>{fe.current&&window.clearTimeout(fe.current),fe.current=null,pe.current=0},De=(0,L.jsxs)(`div`,{...ae(`controls`),children:[(0,L.jsx)(pl,{...ae(`control`),tabIndex:-1,"aria-hidden":!0,disabled:D||typeof ce==`number`&&f!==void 0&&ce>=f,mod:{direction:`up`},onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{Te(e,!0)},onPointerUp:Ee,onPointerLeave:Ee,children:(0,L.jsx)(b_,{direction:`up`})}),(0,L.jsx)(pl,{...ae(`control`),tabIndex:-1,"aria-hidden":!0,disabled:D||typeof ce==`number`&&p!==void 0&&ce<=p,mod:{direction:`down`},onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{Te(e,!1)},onPointerUp:Ee,onPointerLeave:Ee,children:(0,L.jsx)(b_,{direction:`down`})})]});return(0,L.jsx)(pd,{component:v_,allowNegative:k,className:jn(y_.root,r),size:j,inputMode:`decimal`,...ie,readOnly:A,disabled:D,value:ce,getInputRef:nn(t,de),onValueChange:me,rightSection:h||A||!E_(ce)?g:g||De,classNames:oe,styles:se,unstyled:o,__staticSelector:`NumberInput`,decimalScale:x?S:0,onPaste:ye,onKeyDown:be,onKeyDownCapture:xe,rightSectionPointerEvents:O??(D?`none`:void 0),rightSectionWidth:M??`var(--ni-right-section-width-${j||`sm`})`,allowLeadingZeros:F,allowedDecimalSeparators:ne,onBlur:Se,attributes:re,isAllowed:e=>v===`strict`?_?_(e)&&k_(e.floatValue,p,f):k_(e.floatValue,p,f):_?_(e):!0})});N_.classes={...pd.classes,...y_},N_.displayName=`@mantine/core/NumberInput`;var P_={root:`m_4addd315`,control:`m_326d024a`,dots:`m_4ad7767d`},[F_,I_]=$e(`Pagination.Root component was not found in tree`),L_={withPadding:!0},R_=V((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,active:s,disabled:c,withPadding:l,mod:u,...d}=z(`PaginationControl`,L_,e),f=I_(),p=c||f.disabled;return(0,L.jsx)(pl,{ref:t,disabled:p,mod:[{active:s,disabled:p,"with-padding":l},u],...f.getStyles(`control`,{className:r,style:i,classNames:n,styles:a,active:!p}),...d})});R_.classes=P_,R_.displayName=`@mantine/core/PaginationControl`;function z_({style:e,children:t,path:n,...r}){return(0,L.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:(0,L.jsx)(`path`,{d:n,fill:`currentColor`})})}var B_=e=>(0,L.jsx)(z_,{...e,path:`M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z`}),V_=e=>(0,L.jsx)(z_,{...e,path:`M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z`}),H_=e=>(0,L.jsx)(z_,{...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`}),U_=e=>(0,L.jsx)(z_,{...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`}),W_={icon:e=>(0,L.jsx)(z_,{...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`})},G_=V((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,icon:s,...c}=z(`PaginationDots`,W_,e);return(0,L.jsx)(B,{ref:t,...I_().getStyles(`dots`,{className:r,style:i,styles:a,classNames:n}),...c,children:(0,L.jsx)(s,{style:{width:`calc(var(--pagination-control-size) / 1.8)`,height:`calc(var(--pagination-control-size) / 1.8)`}})})});G_.classes=P_,G_.displayName=`@mantine/core/PaginationDots`;function K_({icon:e,name:t,action:n,type:r}){let i={icon:e},a=(0,b.forwardRef)((e,a)=>{let{icon:o,...s}=z(t,i,e),c=I_(),l=r===`next`?c.active===c.total:c.active===1;return(0,L.jsx)(R_,{disabled:c.disabled||l,ref:a,onClick:c[n],withPadding:!1,...s,children:(0,L.jsx)(o,{className:`mantine-rotate-rtl`,style:{width:`calc(var(--pagination-control-size) / 1.8)`,height:`calc(var(--pagination-control-size) / 1.8)`}})})});return a.displayName=`@mantine/core/${t}`,Li(a)}var q_=K_({icon:B_,name:`PaginationNext`,action:`onNext`,type:`next`}),J_=K_({icon:V_,name:`PaginationPrevious`,action:`onPrevious`,type:`previous`}),Y_=K_({icon:H_,name:`PaginationFirst`,action:`onFirst`,type:`previous`}),X_=K_({icon:U_,name:`PaginationLast`,action:`onLast`,type:`next`});function Z_({dotsIcon:e}){let t=I_();return(0,L.jsx)(L.Fragment,{children:t.range.map((n,r)=>n===`dots`?(0,L.jsx)(G_,{icon:e},r):(0,L.jsx)(R_,{active:n===t.active,"aria-current":n===t.active?`page`:void 0,onClick:()=>t.onChange(n),disabled:t.disabled,...t.getItemProps?.(n),children:t.getItemProps?.(n)?.children??n},r))})}Z_.displayName=`@mantine/core/PaginationItems`;var Q_={siblings:1,boundaries:1},$_=kn((e,{size:t,radius:n,color:r,autoContrast:i})=>({root:{"--pagination-control-radius":n===void 0?void 0:pt(n),"--pagination-control-size":dt(t,`pagination-control-size`),"--pagination-control-fz":mt(t),"--pagination-active-bg":r?ir(r,e):void 0,"--pagination-active-color":ai(i,e)?Er({color:r,theme:e,autoContrast:i}):void 0}})),ev=V((e,t)=>{let n=z(`PaginationRoot`,Q_,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,total:l,value:u,defaultValue:d,onChange:f,disabled:p,siblings:m,boundaries:h,color:g,radius:_,onNextPage:v,onPreviousPage:y,onFirstPage:b,onLastPage:x,getItemProps:S,autoContrast:C,attributes:w,...T}=n,E=R({name:`Pagination`,classes:P_,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:w,vars:c,varsResolver:$_}),{range:D,setPage:O,next:k,previous:A,active:j,first:M,last:N}=sn({page:u,initialPage:d,onChange:f,total:l,siblings:m,boundaries:h});return(0,L.jsx)(F_,{value:{total:l,range:D,active:j,disabled:p,getItemProps:S,onChange:O,onNext:_t(v,k),onPrevious:_t(y,A),onFirst:_t(b,M),onLast:_t(x,N),getStyles:E},children:(0,L.jsx)(B,{ref:t,...E(`root`),...T})})});ev.classes=P_,ev.displayName=`@mantine/core/PaginationRoot`;var tv={withControls:!0,withPages:!0,siblings:1,boundaries:1,gap:8},nv=V((e,t)=>{let{withEdges:n,withControls:r,getControlProps:i,nextIcon:a,previousIcon:o,lastIcon:s,firstIcon:c,dotsIcon:l,total:u,gap:d,hideWithOnePage:f,withPages:p,...m}=z(`Pagination`,tv,e);return u<=0||f&&u===1?null:(0,L.jsx)(ev,{ref:t,total:u,...m,children:(0,L.jsxs)(H,{gap:d,children:[n&&(0,L.jsx)(Y_,{icon:c,...i?.(`first`)}),r&&(0,L.jsx)(J_,{icon:o,...i?.(`previous`)}),p&&(0,L.jsx)(Z_,{dotsIcon:l}),r&&(0,L.jsx)(q_,{icon:a,...i?.(`next`)}),n&&(0,L.jsx)(X_,{icon:s,...i?.(`last`)})]})})});nv.classes=P_,nv.displayName=`@mantine/core/Pagination`,nv.Root=ev,nv.Control=R_,nv.Dots=G_,nv.First=Y_,nv.Last=X_,nv.Next=q_,nv.Previous=J_,nv.Items=Z_;var rv={root:`m_f61ca620`,input:`m_ccf8da4c`,innerInput:`m_f2d85dd2`,visibilityToggle:`m_b1072d44`},iv={visibilityToggleIcon:({reveal:e})=>(0,L.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:(0,L.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`})})},av=kn((e,{size:t})=>({root:{"--psi-icon-size":dt(t,`psi-icon-size`),"--psi-button-size":dt(t,`psi-button-size`)}})),ov=V((e,t)=>{let n=z(`PasswordInput`,iv,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,required:l,error:u,leftSection:d,disabled:f,id:p,variant:m,inputContainer:h,description:g,label:_,size:v,errorProps:y,descriptionProps:b,labelProps:x,withAsterisk:S,inputWrapperOrder:C,wrapperProps:w,radius:T,rightSection:E,rightSectionWidth:D,rightSectionPointerEvents:O,leftSectionWidth:k,visible:A,defaultVisible:j,onVisibilityChange:M,visibilityToggleIcon:N,visibilityToggleButtonProps:P,rightSectionProps:F,leftSectionProps:ee,leftSectionPointerEvents:te,withErrorStyles:ne,mod:re,attributes:ie,...ae}=n,oe=Qt(p),[se,ce]=rn({value:A,defaultValue:j,finalValue:!1,onChange:M}),le=()=>ce(!se),ue=R({name:`PasswordInput`,classes:rv,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:ie,vars:c,varsResolver:av}),{resolvedClassNames:de,resolvedStyles:fe}=Hr({classNames:r,styles:o,props:n}),{styleProps:pe,rest:me}=fi(ae),he=y?.id||`${oe}-error`,ge=b?.id||`${oe}-description`,_e=`${u&&typeof u!=`boolean`?he:``} ${g?ge:``}`,ve=_e.trim().length>0?_e.trim():void 0,ye=(0,L.jsx)(hu,{...ue(`visibilityToggle`),disabled:f,radius:T,"aria-hidden":!P,"aria-pressed":se,tabIndex:-1,...P,variant:P?.variant??`subtle`,color:`gray`,unstyled:s,onTouchEnd:e=>{e.preventDefault(),P?.onTouchEnd?.(e),le()},onMouseDown:e=>{e.preventDefault(),P?.onMouseDown?.(e),le()},onKeyDown:e=>{P?.onKeyDown?.(e),e.key===` `&&(e.preventDefault(),le())},children:(0,L.jsx)(N,{reveal:se})});return(0,L.jsx)(ud.Wrapper,{required:l,id:oe,label:_,error:u,description:g,size:v,classNames:de,styles:fe,__staticSelector:`PasswordInput`,__stylesApiProps:n,unstyled:s,withAsterisk:S,inputWrapperOrder:C,inputContainer:h,variant:m,labelProps:{...x,htmlFor:oe},descriptionProps:{...b,id:ge},errorProps:{...y,id:he},mod:re,attributes:ie,...ue(`root`),...pe,...w,children:(0,L.jsx)(ud,{component:`div`,error:u,leftSection:d,size:v,classNames:{...de,input:jn(rv.input,de.input)},styles:fe,radius:T,disabled:f,__staticSelector:`PasswordInput`,__stylesApiProps:n,rightSectionWidth:D,rightSection:E??ye,variant:m,unstyled:s,leftSectionWidth:k,rightSectionPointerEvents:O||`all`,rightSectionProps:F,leftSectionProps:ee,leftSectionPointerEvents:te,withAria:!1,withErrorStyles:ne,attributes:ie,children:(0,L.jsx)(`input`,{required:l,"data-invalid":!!u||void 0,"data-with-left-section":!!d||void 0,...ue(`innerInput`),disabled:f,id:oe,ref:t,...me,"aria-describedby":ve,autoComplete:me.autoComplete||`off`,type:se?`text`:`password`})})})});ov.classes={...pd.classes,...rv},ov.displayName=`@mantine/core/PasswordInput`;var sv={root:`m_db6d6462`,section:`m_2242eb65`,"stripes-animation":`m_81a374bd`,"stripes-animation-vertical":`m_e0fb7a86`,label:`m_91e40b74`},[cv,lv]=$e(`Progress.Root component was not found in tree`),uv=V((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,...s}=z(`ProgressLabel`,null,e);return(0,L.jsx)(B,{ref:t,...lv().getStyles(`label`,{className:r,style:i,classNames:n,styles:a}),...s})});uv.classes=sv,uv.displayName=`@mantine/core/ProgressLabel`;var dv=kn((e,{size:t,radius:n,transitionDuration:r})=>({root:{"--progress-size":dt(t,`progress-size`),"--progress-radius":n===void 0?void 0:pt(n),"--progress-transition-duration":typeof r==`number`?`${r}ms`:void 0}})),fv=V((e,t)=>{let n=z(`ProgressRoot`,null,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,autoContrast:l,transitionDuration:u,orientation:d,attributes:f,mod:p,...m}=n,h=R({name:`Progress`,classes:sv,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:f,vars:c,varsResolver:dv});return(0,L.jsx)(cv,{value:{getStyles:h,autoContrast:l},children:(0,L.jsx)(B,{ref:t,mod:[{orientation:d},p],...h(`root`),...m})})});fv.classes=sv,fv.displayName=`@mantine/core/ProgressRoot`;var pv={withAria:!0},mv=V((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,value:s,withAria:c,color:l,striped:u,animated:d,mod:f,...p}=z(`ProgressSection`,pv,e),m=lv(),h=xr(),g=c?{role:`progressbar`,"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":s,"aria-valuetext":`${s}%`}:{};return(0,L.jsx)(B,{ref:t,...m.getStyles(`section`,{className:r,classNames:n,styles:a,style:i}),...p,...g,mod:[{striped:u||d,animated:d},f],__vars:{"--progress-section-size":`${s}%`,"--progress-section-color":ir(l,h),"--progress-label-color":ai(m.autoContrast,h)?Er({color:l,theme:h,autoContrast:m.autoContrast}):void 0}})});mv.classes=sv,mv.displayName=`@mantine/core/ProgressSection`;var hv=V((e,t)=>{let n=z(`Progress`,null,e),{value:r,classNames:i,styles:a,vars:o,color:s,striped:c,animated:l,"aria-label":u,...d}=n,{resolvedClassNames:f,resolvedStyles:p}=Hr({classNames:i,styles:a,props:n});return(0,L.jsx)(fv,{ref:t,classNames:f,styles:p,vars:o,...d,children:(0,L.jsx)(mv,{value:r,color:s,striped:c,animated:l,"aria-label":u})})});hv.classes=sv,hv.displayName=`@mantine/core/Progress`,hv.Section=mv,hv.Root=fv,hv.Label=uv;var gv={root:`m_f3f1af94`,inner:`m_89c4f5e4`,icon:`m_f3ed6b2b`,radio:`m_8a3dbb89`,"radio--outline":`m_1bfe9d39`},[_v,vv]=et(),[yv,bv]=et(),xv={card:`m_9dc8ae12`},Sv={withBorder:!0},Cv=kn((e,{radius:t})=>({card:{"--card-radius":pt(t)}})),wv=V((e,t)=>{let n=z(`RadioCard`,Sv,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,checked:l,mod:u,withBorder:d,value:f,onClick:p,name:m,onKeyDown:h,attributes:g,..._}=n,v=R({name:`RadioCard`,classes:xv,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:g,vars:c,varsResolver:Cv,rootSelector:`card`}),{dir:y}=Ji(),b=vv(),x=typeof l==`boolean`?l:b?.value===f||!1,S=m||b?.name,C=e=>{if(h?.(e),[`ArrowDown`,`ArrowUp`,`ArrowLeft`,`ArrowRight`].includes(e.nativeEvent.code)){e.preventDefault();let t=Array.from(document.querySelectorAll(`[role="radio"][name="${S||`__mantine`}"]`)),n=t.findIndex(t=>t===e.target),r=n+1>=t.length?0:n+1,i=n-1<0?t.length-1:n-1;e.nativeEvent.code===`ArrowDown`&&(t[r].focus(),t[r].click()),e.nativeEvent.code===`ArrowUp`&&(t[i].focus(),t[i].click()),e.nativeEvent.code===`ArrowLeft`&&(t[y===`ltr`?i:r].focus(),t[y===`ltr`?i:r].click()),e.nativeEvent.code===`ArrowRight`&&(t[y===`ltr`?r:i].focus(),t[y===`ltr`?r:i].click())}};return(0,L.jsx)(yv,{value:{checked:x},children:(0,L.jsx)(pl,{ref:t,mod:[{"with-border":d,checked:x},u],...v(`card`),..._,role:`radio`,"aria-checked":x,name:S,onClick:e=>{p?.(e),b?.onChange(f||``)},onKeyDown:C})})});wv.displayName=`@mantine/core/RadioCard`,wv.classes=xv;var Tv=V((e,t)=>{let{value:n,defaultValue:r,onChange:i,size:a,wrapperProps:o,children:s,name:c,readOnly:l,disabled:u,...d}=z(`RadioGroup`,null,e),f=Qt(c),[p,m]=rn({value:n,defaultValue:r,finalValue:``,onChange:i});return(0,L.jsx)(_v,{value:{value:p,onChange:e=>!l&&m(typeof e==`string`?e:e.currentTarget.value),size:a,name:f,disabled:u},children:(0,L.jsx)(ud.Wrapper,{size:a,ref:t,...o,...d,labelElement:`div`,__staticSelector:`RadioGroup`,children:(0,L.jsx)(Qf,{role:`radiogroup`,children:s})})})});Tv.classes=ud.Wrapper.classes,Tv.displayName=`@mantine/core/RadioGroup`;function Ev({size:e,style:t,...n}){return(0,L.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 5 5`,style:{width:I(e),height:I(e),...t},"aria-hidden":!0,...n,children:(0,L.jsx)(`circle`,{cx:`2.5`,cy:`2.5`,r:`2.5`,fill:`currentColor`})})}var Dv={indicator:`m_717d7ff6`,icon:`m_3e4da632`,"indicator--outline":`m_2980836c`},Ov={icon:Ev},kv=kn((e,{radius:t,color:n,size:r,iconColor:i,variant:a,autoContrast:o})=>{let s=rr({color:n||e.primaryColor,theme:e}),c=s.isThemeColor&&s.shade===void 0?`var(--mantine-color-${s.color}-outline)`:s.color;return{indicator:{"--radio-size":dt(r,`radio-size`),"--radio-radius":t===void 0?void 0:pt(t),"--radio-color":a===`outline`?c:ir(n,e),"--radio-icon-size":dt(r,`radio-icon-size`),"--radio-icon-color":i?ir(i,e):ai(o,e)?Er({color:n,theme:e,autoContrast:o}):void 0}}}),Av=V((e,t)=>{let n=z(`RadioIndicator`,Ov,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,icon:l,radius:u,color:d,iconColor:f,autoContrast:p,checked:m,mod:h,variant:g,disabled:_,attributes:v,...y}=n,b=R({name:`RadioIndicator`,classes:Dv,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:v,vars:c,varsResolver:kv,rootSelector:`indicator`}),x=bv(),S=typeof m==`boolean`?m:x?.checked||!1;return(0,L.jsx)(B,{ref:t,...b(`indicator`,{variant:g}),variant:g,mod:[{checked:S,disabled:_},h],...y,children:(0,L.jsx)(l,{...b(`icon`)})})});Av.displayName=`@mantine/core/RadioIndicator`,Av.classes=Dv;var jv={labelPosition:`right`},Mv=kn((e,{size:t,radius:n,color:r,iconColor:i,variant:a,autoContrast:o})=>{let s=rr({color:r||e.primaryColor,theme:e}),c=s.isThemeColor&&s.shade===void 0?`var(--mantine-color-${s.color}-outline)`:s.color;return{root:{"--radio-size":dt(t,`radio-size`),"--radio-radius":n===void 0?void 0:pt(n),"--radio-color":a===`outline`?c:ir(r,e),"--radio-icon-color":i?ir(i,e):ai(o,e)?Er({color:r,theme:e,autoContrast:o}):void 0,"--radio-icon-size":dt(t,`radio-icon-size`)}}}),Nv=V((e,t)=>{let n=z(`Radio`,jv,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,id:l,size:u,label:d,labelPosition:f,description:p,error:m,radius:h,color:g,variant:_,disabled:v,wrapperProps:y,icon:b=Ev,rootRef:x,iconColor:S,onChange:C,mod:w,attributes:T,checked:E,...D}=n,O=R({name:`Radio`,classes:gv,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:T,vars:c,varsResolver:Mv}),k=vv(),A=k?.size??u,j=n.size?u:A,{styleProps:M,rest:N}=fi(D),P=Qt(l),F=k?k.value===N.value:void 0,ee={checked:F??E,name:k?.name??N.name,onChange:e=>{k?.onChange(e),C?.(e)},disabled:k?.disabled??v};return(0,L.jsx)(Vf,{...O(`root`),__staticSelector:`Radio`,__stylesApiProps:n,id:P,size:j,labelPosition:f,label:d,description:p,error:m,disabled:ee.disabled,classNames:r,styles:o,unstyled:s,"data-checked":(F??E)||void 0,variant:_,ref:x,mod:w,...M,...y,children:(0,L.jsxs)(B,{...O(`inner`),mod:{"label-position":f},children:[(0,L.jsx)(B,{...O(`radio`,{focusable:!0,variant:_}),...N,...ee,component:`input`,mod:{error:!!m},ref:t,id:P,type:`radio`}),(0,L.jsx)(b,{...O(`icon`),"aria-hidden":!0})]})})});Nv.classes=gv,Nv.displayName=`@mantine/core/Radio`,Nv.Group=Tv,Nv.Card=wv,Nv.Indicator=Av;var Pv={duration:100,transition:`fade`};function Fv(e,t){return{...Pv,...t,...e}}var Iv={tooltip:`m_1b3c8819`,arrow:`m_f898399f`};function Lv({offset:e,position:t,defaultOpened:n}){let[r,i]=(0,b.useState)(n),a=(0,b.useRef)(null),{x:o,y:s,elements:c,refs:l,update:u,placement:d}=Cc({placement:t,middleware:[Ns({crossAxis:!0,padding:5,rootBoundary:`document`})]}),f=d.includes(`right`)?e:t.includes(`left`)?e*-1:0,p=d.includes(`bottom`)?e:t.includes(`top`)?e*-1:0,m=(0,b.useCallback)(({clientX:e,clientY:t})=>{l.setPositionReference({getBoundingClientRect(){return{width:0,height:0,x:e,y:t,left:e+f,top:t+p,right:e,bottom:t}}})},[c.reference]);return(0,b.useEffect)(()=>{if(l.floating.current){let e=a.current;e.addEventListener(`mousemove`,m);let t=ba(l.floating.current);return t.forEach(e=>{e.addEventListener(`scroll`,u)}),()=>{e.removeEventListener(`mousemove`,m),t.forEach(e=>{e.removeEventListener(`scroll`,u)})}}},[c.reference,l.floating.current,u,m,r]),{handleMouseMove:m,x:o,y:s,opened:r,setOpened:i,boundaryRef:a,floating:l.setFloating}}var Rv={refProp:`ref`,withinPortal:!0,offset:10,position:`right`,zIndex:ct(`popover`)},zv=kn((e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:pt(t),"--tooltip-bg":n?ir(n,e):void 0,"--tooltip-color":n?`var(--mantine-color-white)`:void 0}})),Bv=V((e,t)=>{let n=z(`TooltipFloating`,Rv,e),{children:r,refProp:i,withinPortal:a,style:o,className:s,classNames:c,styles:l,unstyled:u,radius:d,color:f,label:p,offset:m,position:h,multiline:g,zIndex:_,disabled:v,defaultOpened:y,variant:x,vars:S,portalProps:C,attributes:w,...T}=n,E=xr(),D=R({name:`TooltipFloating`,props:n,classes:Iv,className:s,style:o,classNames:c,styles:l,unstyled:u,attributes:w,rootSelector:`tooltip`,vars:S,varsResolver:zv}),{handleMouseMove:O,x:k,y:A,opened:j,boundaryRef:M,floating:N,setOpened:P}=Lv({offset:m,position:h,defaultOpened:y}),F=On(r);if(!F)throw 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`);let ee=nn(M,wn(F),t),te=F.props,ne=e=>{te.onMouseEnter?.(e),O(e),P(!0)},re=e=>{te.onMouseLeave?.(e),P(!1)};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Nl,{...C,withinPortal:a,children:(0,L.jsx)(B,{...T,...D(`tooltip`,{style:{...Ii(o,E),zIndex:_,display:!v&&j?`block`:`none`,top:(A&&Math.round(A))??``,left:(k&&Math.round(k))??``}}),variant:x,ref:N,mod:{multiline:g},children:p})}),(0,b.cloneElement)(F,{...te,[i]:ee,onMouseEnter:ne,onMouseLeave:re})]})});Bv.classes=Iv,Bv.displayName=`@mantine/core/TooltipFloating`;var Vv=(0,b.createContext)(!1),Hv=Vv.Provider,Uv=()=>(0,b.useContext)(Vv),Wv={openDelay:0,closeDelay:0};function Gv(e){let{openDelay:t,closeDelay:n,children:r}=z(`TooltipGroup`,Wv,e);return(0,L.jsx)(Hv,{value:!0,children:(0,L.jsx)(gc,{delay:{open:t,close:n},children:r})})}Gv.displayName=`@mantine/core/TooltipGroup`,Gv.extend=e=>e;function Kv(e){if(e===void 0)return{shift:!0,flip:!0};let t={...e};return e.shift===void 0&&(t.shift=!0),e.flip===void 0&&(t.flip=!0),t}function qv(e){let t=Kv(e.middlewares),n=[Ms(e.offset)];return t.shift&&n.push(Ns(typeof t.shift==`boolean`?{padding:8}:{padding:8,...t.shift})),t.flip&&n.push(typeof t.flip==`boolean`?Fs():Fs(t.flip)),n.push(zs({element:e.arrowRef,padding:e.arrowOffset})),t.inline?n.push(typeof t.inline==`boolean`?Rs():Rs(t.inline)):e.inline&&n.push(Rs()),n}function Jv(e){let[t,n]=(0,b.useState)(e.defaultOpened),r=typeof e.opened==`boolean`?e.opened:t,i=Uv(),a=Qt(),o=(0,b.useCallback)(e=>{n(e),e&&g(a)},[a]),{x:s,y:c,context:l,refs:u,placement:d,middlewareData:{arrow:{x:f,y:p}={}}}=Cc({strategy:e.strategy,placement:e.position,open:r,onOpenChange:o,middleware:qv(e),whileElementsMounted:ms}),{delay:m,currentId:h,setCurrentId:g}=_c(l,{id:a}),{getReferenceProps:_,getFloatingProps:v}=Dc([fc(l,{enabled:e.events?.hover,delay:i?m:{open:e.openDelay,close:e.closeDelay},mouseOnly:!e.events?.touch}),Tc(l,{enabled:e.events?.focus,visibleOnly:!0}),kc(l,{role:`tooltip`}),xc(l,{enabled:e.opened===void 0})]);It(()=>{e.onPositionChange?.(d)},[d]);let y=r&&h&&h!==a;return{x:s,y:c,arrowX:f,arrowY:p,reference:u.setReference,floating:u.setFloating,getFloatingProps:v,getReferenceProps:_,isGroupPhase:y,opened:r,placement:d}}var Yv={position:`top`,refProp:`ref`,withinPortal:!0,arrowSize:4,arrowOffset:5,arrowRadius:0,arrowPosition:`side`,offset:5,transitionProps:{duration:100,transition:`fade`},events:{hover:!0,focus:!1,touch:!1},zIndex:ct(`popover`),positionDependencies:[],middlewares:{flip:!0,shift:!0,inline:!1}},Xv=kn((e,{radius:t,color:n,variant:r,autoContrast:i})=>{let a=e.variantColorResolver({theme:e,color:n||e.primaryColor,autoContrast:i,variant:r||`filled`});return{tooltip:{"--tooltip-radius":t===void 0?void 0:pt(t),"--tooltip-bg":n?a.background:void 0,"--tooltip-color":n?a.color:void 0}}}),Zv=V((e,t)=>{let n=z(`Tooltip`,Yv,e),{children:r,position:i,refProp:a,label:o,openDelay:s,closeDelay:c,onPositionChange:l,opened:u,defaultOpened:d,withinPortal:f,radius:p,color:m,classNames:h,styles:g,unstyled:_,style:v,className:y,withArrow:x,arrowSize:S,arrowOffset:C,arrowRadius:w,arrowPosition:T,offset:E,transitionProps:D,multiline:O,events:k,zIndex:A,disabled:j,positionDependencies:M,onClick:N,onMouseEnter:P,onMouseLeave:F,inline:ee,variant:te,keepMounted:ne,vars:re,portalProps:ie,mod:ae,floatingStrategy:oe,middlewares:se,autoContrast:ce,attributes:le,target:ue,...de}=z(`Tooltip`,Yv,n),{dir:fe}=Ji(),pe=(0,b.useRef)(null),me=Jv({position:wl(fe,i),closeDelay:c,openDelay:s,onPositionChange:l,opened:u,defaultOpened:d,events:k,arrowRef:pe,arrowOffset:C,offset:typeof E==`number`?E+(x?S/2:0):E,positionDependencies:[...M,ue??r],inline:ee,strategy:oe,middlewares:se});(0,b.useEffect)(()=>{let e=ue instanceof HTMLElement?ue:typeof ue==`string`?document.querySelector(ue):ue?.current||null;e&&me.reference(e)},[ue,me]);let he=R({name:`Tooltip`,props:n,classes:Iv,className:y,style:v,classNames:h,styles:g,unstyled:_,attributes:le,rootSelector:`tooltip`,vars:re,varsResolver:Xv}),ge=On(r);if(!ue&&!ge)throw 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`);if(ue){let e=Fv(D,{duration:100,transition:`fade`});return(0,L.jsx)(L.Fragment,{children:(0,L.jsx)(Nl,{...ie,withinPortal:f,children:(0,L.jsx)(zl,{...e,keepMounted:ne,mounted:!j&&!!me.opened,duration:me.isGroupPhase?10:e.duration,children:e=>(0,L.jsxs)(B,{...de,"data-fixed":oe===`fixed`||void 0,variant:te,mod:[{multiline:O},ae],...me.getFloatingProps({ref:me.floating,className:he(`tooltip`).className,style:{...he(`tooltip`).style,...e,zIndex:A,top:me.y??0,left:me.x??0}}),children:[o,(0,L.jsx)(Cl,{ref:pe,arrowX:me.arrowX,arrowY:me.arrowY,visible:x,position:me.placement,arrowSize:S,arrowOffset:C,arrowRadius:w,arrowPosition:T,...he(`arrow`)})]})})})})}let _e=ge.props,ve=nn(me.reference,wn(ge),t),ye=Fv(D,{duration:100,transition:`fade`});return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Nl,{...ie,withinPortal:f,children:(0,L.jsx)(zl,{...ye,keepMounted:ne,mounted:!j&&!!me.opened,duration:me.isGroupPhase?10:ye.duration,children:e=>(0,L.jsxs)(B,{...de,"data-fixed":oe===`fixed`||void 0,variant:te,mod:[{multiline:O},ae],...me.getFloatingProps({ref:me.floating,className:he(`tooltip`).className,style:{...he(`tooltip`).style,...e,zIndex:A,top:me.y??0,left:me.x??0}}),children:[o,(0,L.jsx)(Cl,{ref:pe,arrowX:me.arrowX,arrowY:me.arrowY,visible:x,position:me.placement,arrowSize:S,arrowOffset:C,arrowRadius:w,arrowPosition:T,...he(`arrow`)})]})})}),(0,b.cloneElement)(ge,me.getReferenceProps({onClick:N,onMouseEnter:P,onMouseLeave:F,onMouseMove:n.onMouseMove,onPointerDown:n.onPointerDown,onPointerEnter:n.onPointerEnter,..._e,className:jn(y,_e.className),[a]:ve}))]})});Zv.classes=Iv,Zv.displayName=`@mantine/core/Tooltip`,Zv.Floating=Bv,Zv.Group=Gv;function Qv({size:e,thickness:t,sum:n,value:r,root:i,offset:a}){let o=(e*.9-t*2)/2,s=Math.PI*o*2/100,c=i||r===void 0?`${(100-n)*s}, ${n*s}`:`${r*s}, ${(100-r)*s}`;return{strokeWidth:Number.isNaN(t)?12:t,cx:e/2||0,cy:e/2||0,r:o||0,transform:i?`scale(1, -1) translate(0, -${e})`:void 0,strokeDasharray:c,strokeDashoffset:i?0:a||0}}function $v({size:e,value:t,offset:n,sum:r,thickness:i,root:a,color:o,lineRoundCaps:s,tooltip:c,getStyles:l,display:u,...d}){let f=xr();return(0,L.jsx)(Zv.Floating,{disabled:!c,label:c,children:(0,L.jsx)(B,{component:`circle`,...d,...l(`curve`),__vars:{"--curve-color":o?ir(o,f):void 0},fill:`none`,strokeLinecap:s?`round`:`butt`,...Qv({sum:r,size:e,thickness:i,value:t,offset:n,root:a})})})}$v.displayName=`@mantine/core/Curve`;function ey({size:e,thickness:t,sections:n,renderRoundedLineCaps:r,rootColor:i}){let a=n.reduce((e,t)=>e+t.value,0),o=Math.PI*((e*.9-t*2)/2)*2,s=o,c=[],l=[];for(let e=0;e<n.length;e+=1)c.push({sum:a,offset:s,data:n[e],root:!1}),s-=n[e].value/100*o;if(c.push({sum:a,offset:s,data:{color:i},root:!0}),l.push({...c[c.length-1],lineRoundCaps:!1}),c.length>2){l.push({...c[0],lineRoundCaps:r}),l.push({...c[c.length-2],lineRoundCaps:r});for(let e=1;e<=c.length-3;e+=1)l.push({...c[e],lineRoundCaps:!1})}else l.push({...c[0],lineRoundCaps:r});return l}var ty={root:`m_b32e4812`,svg:`m_d43b5134`,curve:`m_b1ca1fbf`,label:`m_b23f9dc4`};function ny(e,t){return Math.min(e||12,(t||120)/4)}var ry={size:120,thickness:12},iy=kn((e,{size:t,thickness:n,transitionDuration:r})=>({root:{"--rp-size":I(t),"--rp-label-offset":I(n*2),"--rp-transition-duration":r?`${r}ms`:void 0}})),ay=V((e,t)=>{let n=z(`RingProgress`,ry,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,label:l,sections:u,size:d,thickness:f,roundCaps:p,rootColor:m,transitionDuration:h,attributes:g,..._}=n,v=R({name:`RingProgress`,classes:ty,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:g,vars:c,varsResolver:iy}),y=ny(f,d),x=ey({size:d,thickness:y,sections:u,renderRoundedLineCaps:p,rootColor:m}).map(({data:e,sum:t,root:n,lineRoundCaps:r,offset:i},a)=>(0,b.createElement)($v,{...e,key:a,size:d,thickness:y,sum:t,offset:i,color:e?.color,root:n,lineRoundCaps:r,getStyles:v}));return(0,L.jsxs)(B,{...v(`root`),size:d,ref:t,..._,children:[(0,L.jsx)(`svg`,{...v(`svg`),children:x}),l&&(0,L.jsx)(`div`,{...v(`label`),children:l})]})});ay.classes=ty,ay.displayName=`@mantine/core/RingProgress`;var oy={root:`m_cf365364`,indicator:`m_9e182ccd`,label:`m_1738fcb2`,input:`m_1714d588`,control:`m_69686b9b`,innerLabel:`m_78882f40`},sy={withItemsBorders:!0},cy=kn((e,{radius:t,color:n,transitionDuration:r,size:i,transitionTimingFunction:a})=>({root:{"--sc-radius":t===void 0?void 0:pt(t),"--sc-color":n?ir(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":a,"--sc-padding":dt(i,`sc-padding`),"--sc-font-size":mt(i)}})),ly=V((e,t)=>{let n=z(`SegmentedControl`,sy,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,data:l,value:u,defaultValue:d,onChange:f,size:p,name:m,disabled:h,readOnly:g,fullWidth:_,orientation:v,radius:y,color:x,transitionDuration:S,transitionTimingFunction:C,variant:w,autoContrast:T,withItemsBorders:E,mod:D,attributes:O,...k}=n,A=R({name:`SegmentedControl`,props:n,classes:oy,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:O,vars:c,varsResolver:cy}),j=xr(),M=l.map(e=>typeof e==`string`?{label:e,value:e}:e),N=Sn(),[P,F]=(0,b.useState)(Ct()),[ee,te]=(0,b.useState)(null),[ne,re]=(0,b.useState)({}),ie=(e,t)=>{ne[t]=e,re(ne)},[ae,oe]=rn({value:u,defaultValue:d,finalValue:Array.isArray(l)?M.find(e=>!e.disabled)?.value??l[0]?.value??null:null,onChange:f}),se=Qt(m),ce=M.map(e=>(0,b.createElement)(B,{...A(`control`),mod:{active:ae===e.value,orientation:v},key:e.value},(0,b.createElement)(`input`,{...A(`input`),disabled:h||e.disabled,type:`radio`,name:se,value:e.value,id:`${se}-${e.value}`,checked:ae===e.value,onChange:()=>!g&&oe(e.value),"data-focus-ring":j.focusRing,key:`${e.value}-input`}),(0,b.createElement)(B,{component:`label`,...A(`label`),mod:{active:ae===e.value&&!(h||e.disabled),disabled:h||e.disabled,"read-only":g},htmlFor:`${se}-${e.value}`,ref:t=>ie(t,e.value),__vars:{"--sc-label-color":x===void 0?void 0:Er({color:x,theme:j,autoContrast:T})},key:`${e.value}-label`},(0,L.jsx)(`span`,{...A(`innerLabel`),children:e.label})))),le=nn(t,e=>te(e));return dn(()=>{F(Ct())},[l.length]),l.length===0?null:(0,L.jsxs)(B,{...A(`root`),variant:w,size:p,ref:le,mod:[{"full-width":_,orientation:v,initialized:N,"with-items-borders":E},D],...k,role:`radiogroup`,"data-disabled":h,children:[typeof ae==`string`&&(0,L.jsx)(xd,{target:ne[ae],parent:ee,component:`span`,transitionDuration:`var(--sc-transition-duration)`,...A(`indicator`)},P),ce]})});ly.classes=oy,ly.displayName=`@mantine/core/SegmentedControl`;var uy={container:`m_925c2d2c`,root:`m_2415a157`};function dy({spacing:e,verticalSpacing:t,cols:n,selector:r}){let i=xr(),a=t===void 0?e:t,o=Ye({"--sg-spacing-x":ft(bt(e)),"--sg-spacing-y":ft(bt(a)),"--sg-cols":bt(n)?.toString()}),s=Be(i.breakpoints).reduce((t,r)=>(t[r]||(t[r]={}),typeof e==`object`&&e[r]!==void 0&&(t[r][`--sg-spacing-x`]=ft(e[r])),typeof a==`object`&&a[r]!==void 0&&(t[r][`--sg-spacing-y`]=ft(a[r])),typeof n==`object`&&n[r]!==void 0&&(t[r][`--sg-cols`]=n[r]),t),{});return(0,L.jsx)(di,{styles:o,media:yt(Be(s),i.breakpoints).filter(e=>Be(s[e.value]).length>0).map(e=>({query:`(min-width: ${i.breakpoints[e.value]})`,styles:s[e.value]})),selector:r})}function fy(e){return typeof e==`object`&&e?Be(e):[]}function py(e){return e.sort((e,t)=>Ge(e)-Ge(t))}function my({spacing:e,verticalSpacing:t,cols:n}){return py(Array.from(new Set([...fy(e),...fy(t),...fy(n)])))}function hy({spacing:e,verticalSpacing:t,cols:n,selector:r}){let i=t===void 0?e:t,a=Ye({"--sg-spacing-x":ft(bt(e)),"--sg-spacing-y":ft(bt(i)),"--sg-cols":bt(n)?.toString()}),o=my({spacing:e,verticalSpacing:t,cols:n}),s=o.reduce((t,r)=>(t[r]||(t[r]={}),typeof e==`object`&&e[r]!==void 0&&(t[r][`--sg-spacing-x`]=ft(e[r])),typeof i==`object`&&i[r]!==void 0&&(t[r][`--sg-spacing-y`]=ft(i[r])),typeof n==`object`&&n[r]!==void 0&&(t[r][`--sg-cols`]=n[r]),t),{});return(0,L.jsx)(di,{styles:a,container:o.map(e=>({query:`simple-grid (min-width: ${e})`,styles:s[e]})),selector:r})}var gy={cols:1,spacing:`md`,type:`media`},_y=V((e,t)=>{let n=z(`SimpleGrid`,gy,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,cols:l,verticalSpacing:u,spacing:d,type:f,attributes:p,...m}=n,h=R({name:`SimpleGrid`,classes:uy,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:p,vars:c}),g=Fi();return f===`container`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(hy,{...n,selector:`.${g}`}),(0,L.jsx)(`div`,{...h(`container`),children:(0,L.jsx)(B,{ref:t,...h(`root`,{className:g}),...m})})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(dy,{...n,selector:`.${g}`}),(0,L.jsx)(B,{ref:t,...h(`root`,{className:g}),...m})]})});_y.classes=uy,_y.displayName=`@mantine/core/SimpleGrid`;var vy={root:`m_18320242`,"skeleton-fade":`m_299c329c`},yy={visible:!0,animate:!0},by=kn((e,{width:t,height:n,radius:r,circle:i})=>({root:{"--skeleton-height":I(n),"--skeleton-width":I(i?n:t),"--skeleton-radius":i?`1000px`:r===void 0?void 0:pt(r)}})),xy=V((e,t)=>{let n=z(`Skeleton`,yy,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,width:l,height:u,circle:d,visible:f,radius:p,animate:m,mod:h,attributes:g,..._}=n;return(0,L.jsx)(B,{ref:t,...R({name:`Skeleton`,classes:vy,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:g,vars:c,varsResolver:by})(`root`),mod:[{visible:f,animate:m},h],..._})});xy.classes=vy,xy.displayName=`@mantine/core/Skeleton`;var Sy=V((e,t)=>{let{w:n,h:r,miw:i,mih:a,...o}=z(`Space`,null,e);return(0,L.jsx)(B,{ref:t,...o,w:n,miw:i??n,h:r,mih:a??r})});Sy.displayName=`@mantine/core/Space`;var Cy={root:`m_6d731127`},wy={gap:`md`,align:`stretch`,justify:`flex-start`},Ty=kn((e,{gap:t,align:n,justify:r})=>({root:{"--stack-gap":ft(t),"--stack-align":n,"--stack-justify":r}})),K=V((e,t)=>{let n=z(`Stack`,wy,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,align:l,justify:u,gap:d,variant:f,attributes:p,...m}=n;return(0,L.jsx)(B,{ref:t,...R({name:`Stack`,props:n,classes:Cy,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:p,vars:c,varsResolver:Ty})(`root`),variant:f,...m})});K.classes=Cy,K.displayName=`@mantine/core/Stack`;var[Ey,Dy]=$e(`Stepper component was not found in tree`),Oy={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`},ky=()=>null;ky.displayName=`@mantine/core/StepperCompleted`;var Ay=(e,t)=>typeof e==`function`?(0,L.jsx)(e,{step:t||0}):e,jy={withIcon:!0,allowStepClick:!0,iconPosition:`left`},My=V((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,step:s,state:c,color:l,icon:u,completedIcon:d,progressIcon:f,label:p,description:m,withIcon:h,iconSize:g,loading:_,allowStepClick:v,allowStepSelect:y,iconPosition:b,orientation:x,mod:S,...C}=z(`StepperStep`,jy,e),w=Dy(),T=xr(),E={classNames:n,styles:a},D=c===`stepCompleted`?null:c===`stepProgress`?f:u,O={"data-progress":c===`stepProgress`||void 0,"data-completed":c===`stepCompleted`||void 0};return(0,L.jsxs)(pl,{...w.getStyles(`step`,{className:r,style:i,variant:w.orientation,...E}),mod:[{"icon-position":b||w.iconPosition,"allow-click":v},S],ref:t,...O,...C,__vars:{"--step-color":l?ir(l,T):void 0},tabIndex:v?0:-1,children:[h&&(0,L.jsxs)(`span`,{...w.getStyles(`stepWrapper`,E),children:[(0,L.jsxs)(`span`,{...w.getStyles(`stepIcon`,E),...O,children:[(0,L.jsx)(zl,{mounted:c===`stepCompleted`,transition:`pop`,duration:200,children:e=>(0,L.jsx)(`span`,{...w.getStyles(`stepCompletedIcon`,{style:e,...E}),children:_?(0,L.jsx)(su,{color:`var(--mantine-color-white)`,size:`calc(var(--stepper-icon-size) / 2)`,...w.getStyles(`stepLoader`,E)}):Ay(d,s)||(0,L.jsx)(ep,{size:`60%`})})}),c===`stepCompleted`?null:(0,L.jsx)(`span`,{children:_?(0,L.jsx)(su,{...w.getStyles(`stepLoader`,E),size:`calc(var(--stepper-icon-size) / 2)`,color:l}):Ay(D||u,s)})]}),x===`vertical`&&(0,L.jsx)(`span`,{...w.getStyles(`verticalSeparator`,E),"data-active":c===`stepCompleted`||void 0})]}),(p||m)&&(0,L.jsxs)(`span`,{...w.getStyles(`stepBody`,E),"data-orientation":w.orientation,"data-icon-position":b||w.iconPosition,children:[p&&(0,L.jsx)(`span`,{...w.getStyles(`stepLabel`,E),children:Ay(p,s)}),m&&(0,L.jsx)(`span`,{...w.getStyles(`stepDescription`,E),children:Ay(m,s)})]})]})});My.classes=Oy,My.displayName=`@mantine/core/StepperStep`;var Ny={orientation:`horizontal`,iconPosition:`left`,allowNextStepsSelect:!0,wrap:!0},Py=kn((e,{color:t,iconSize:n,size:r,contentPadding:i,radius:a,autoContrast:o})=>({root:{"--stepper-color":t?ir(t,e):void 0,"--stepper-icon-color":ai(o,e)?Er({color:t,theme:e,autoContrast:o}):void 0,"--stepper-icon-size":n===void 0?dt(r,`stepper-icon-size`):I(n),"--stepper-content-padding":ft(i),"--stepper-radius":a===void 0?void 0:pt(a),"--stepper-fz":mt(r),"--stepper-spacing":ft(r)}})),Fy=V((e,t)=>{let n=z(`Stepper`,Ny,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,children:l,onStepClick:u,active:d,icon:f,completedIcon:p,progressIcon:m,color:h,iconSize:g,contentPadding:_,orientation:v,iconPosition:y,size:x,radius:S,allowNextStepsSelect:C,wrap:w,autoContrast:T,attributes:E,...D}=n,O=R({name:`Stepper`,classes:Oy,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:E,vars:c,varsResolver:Py}),k=b.Children.toArray(l),A=k.filter(e=>e.type!==ky),j=k.find(e=>e.type===ky),M=A.reduce((e,t,n)=>{let r=d===n?`stepProgress`:d>n?`stepCompleted`:`stepInactive`,i=typeof u==`function`?typeof t.props.allowStepSelect==`boolean`?t.props.allowStepSelect:r===`stepCompleted`||C:!1;return e.push((0,b.cloneElement)(t,{icon:t.props.icon||f||n+1,key:n,step:n,state:r,onClick:()=>i&&u?.(n),allowStepClick:i,completedIcon:t.props.completedIcon||p,progressIcon:t.props.progressIcon||m,color:t.props.color||h,iconSize:g,iconPosition:t.props.iconPosition||y,orientation:v})),v===`horizontal`&&n!==A.length-1&&e.push((0,b.createElement)(`div`,{...O(`separator`),"data-active":n<d||void 0,"data-orientation":v,key:`separator-${n}`})),e},[]),N=A[d]?.props?.children,P=j?.props?.children,F=d>A.length-1?P:N;return(0,L.jsx)(Ey,{value:{getStyles:O,orientation:v,iconPosition:y},children:(0,L.jsxs)(B,{...O(`root`),ref:t,size:x,...D,children:[(0,L.jsx)(B,{...O(`steps`),mod:{orientation:v,"icon-position":y,wrap:w&&v!==`vertical`},children:M}),F&&(0,L.jsx)(`div`,{...O(`content`),children:F})]})})});Fy.classes=Oy,Fy.displayName=`@mantine/core/Stepper`,Fy.Completed=ky,Fy.Step=My;var Iy={root:`m_5f93f3bb`,input:`m_926b4011`,track:`m_9307d992`,thumb:`m_93039a1d`,trackLabel:`m_8277e082`},Ly=(0,b.createContext)(null),Ry=Ly.Provider,zy=()=>(0,b.useContext)(Ly),By=V((e,t)=>{let{value:n,defaultValue:r,onChange:i,size:a,wrapperProps:o,children:s,readOnly:c,disabled:l,...u}=z(`SwitchGroup`,null,e),[d,f]=rn({value:n,defaultValue:r,finalValue:[],onChange:i});return(0,L.jsx)(Ry,{value:{value:d,onChange:e=>{let t=e.currentTarget.value;!c&&f(d.includes(t)?d.filter(e=>e!==t):[...d,t])},size:a,disabled:l},children:(0,L.jsx)(ud.Wrapper,{size:a,ref:t,...o,...u,labelElement:`div`,__staticSelector:`SwitchGroup`,children:(0,L.jsx)(Qf,{role:`group`,children:s})})})});By.classes=ud.Wrapper.classes,By.displayName=`@mantine/core/SwitchGroup`;var Vy={labelPosition:`right`,withThumbIndicator:!0},Hy=kn((e,{radius:t,color:n,size:r})=>({root:{"--switch-radius":t===void 0?void 0:pt(t),"--switch-height":dt(r,`switch-height`),"--switch-width":dt(r,`switch-width`),"--switch-thumb-size":dt(r,`switch-thumb-size`),"--switch-label-font-size":dt(r,`switch-label-font-size`),"--switch-track-label-padding":dt(r,`switch-track-label-padding`),"--switch-color":n?ir(n,e):void 0}})),Uy=V((e,t)=>{let n=z(`Switch`,Vy,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,color:l,label:u,offLabel:d,onLabel:f,id:p,size:m,radius:h,wrapperProps:g,thumbIcon:_,checked:v,defaultChecked:y,onChange:b,labelPosition:x,description:S,error:C,disabled:w,variant:T,rootRef:E,mod:D,withThumbIndicator:O,attributes:k,...A}=n,j=zy(),M=m||j?.size,N=R({name:`Switch`,props:n,classes:Iy,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:k,vars:c,varsResolver:Hy}),{styleProps:P,rest:F}=fi(A),ee=Qt(p),te={checked:j?.value.includes(F.value)??v,onChange:e=>{j?.onChange(e),b?.(e)},disabled:j?.disabled??w},[ne,re]=rn({value:te.checked??v,defaultValue:y,finalValue:!1});return(0,L.jsxs)(Vf,{...N(`root`),__staticSelector:`Switch`,__stylesApiProps:n,id:ee,size:M,labelPosition:x,label:u,description:S,error:C,disabled:te.disabled,bodyElement:`label`,labelElement:`span`,classNames:r,styles:o,unstyled:s,"data-checked":te.checked,variant:T,ref:E,mod:D,inert:F.inert,...P,...g,children:[(0,L.jsx)(`input`,{...F,...te,checked:ne,"data-checked":te.checked,onChange:e=>{te.onChange?.(e),re(e.currentTarget.checked)},id:ee,ref:t,type:`checkbox`,role:`switch`,inert:F.inert,...N(`input`)}),(0,L.jsxs)(B,{"aria-hidden":`true`,component:`span`,mod:{error:C,"label-position":x,"without-labels":!f&&!d},...N(`track`),children:[(0,L.jsx)(B,{component:`span`,mod:{"reduce-motion":!0,"with-thumb-indicator":O&&!_},...N(`thumb`),children:_}),(0,L.jsx)(`span`,{...N(`trackLabel`),children:ne?f:d})]})]})});Uy.classes={...Iy,...Bf},Uy.displayName=`@mantine/core/Switch`,Uy.Group=By;var[Wy,Gy]=$e(`Table component was not found in the tree`),Ky={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 qy(e,t){if(!t)return;let 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 Jy(e,t){let n=`Table${e.charAt(0).toUpperCase()}${e.slice(1)}`,r=V((r,i)=>{let a=z(n,{},r),{classNames:o,className:s,style:c,styles:l,...u}=a,d=Gy();return(0,L.jsx)(B,{component:e,ref:i,...qy(d,t),...d.getStyles(e,{className:s,classNames:o,style:c,styles:l,props:a}),...u})});return r.displayName=`@mantine/core/${n}`,r.classes=Ky,r}var Yy=Jy(`th`,{columnBorder:!0}),Xy=Jy(`td`,{columnBorder:!0}),Zy=Jy(`tr`,{rowBorder:!0,striped:!0,highlightOnHover:!0}),Qy=Jy(`thead`,{stickyHeader:!0}),$y=Jy(`tbody`),eb=Jy(`tfoot`),tb=Jy(`caption`,{captionSide:!0});function nb({data:e}){return(0,L.jsxs)(L.Fragment,{children:[e.caption&&(0,L.jsx)(tb,{children:e.caption}),e.head&&(0,L.jsx)(Qy,{children:(0,L.jsx)(Zy,{children:e.head.map((e,t)=>(0,L.jsx)(Yy,{children:e},t))})}),e.body&&(0,L.jsx)($y,{children:e.body.map((e,t)=>(0,L.jsx)(Zy,{children:e.map((e,t)=>(0,L.jsx)(Xy,{children:e},t))},t))}),e.foot&&(0,L.jsx)(eb,{children:(0,L.jsx)(Zy,{children:e.foot.map((e,t)=>(0,L.jsx)(Yy,{children:e},t))})})]})}nb.displayName=`@mantine/core/TableDataRenderer`;var rb={type:`scrollarea`},ib=kn((e,{minWidth:t,maxHeight:n,type:r})=>({scrollContainer:{"--table-min-width":I(t),"--table-max-height":I(n),"--table-overflow":r===`native`?`auto`:void 0}})),ab=V((e,t)=>{let n=z(`TableScrollContainer`,rb,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,children:l,minWidth:u,maxHeight:d,type:f,scrollAreaProps:p,attributes:m,...h}=n,g=R({name:`TableScrollContainer`,classes:Ky,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:m,vars:c,varsResolver:ib,rootSelector:`scrollContainer`});return(0,L.jsx)(B,{component:f===`scrollarea`?ll:`div`,...f===`scrollarea`?d?{offsetScrollbars:`xy`,...p}:{offsetScrollbars:`x`,...p}:{},ref:t,...g(`scrollContainer`),...h,children:(0,L.jsx)(`div`,{...g(`scrollContainerInner`),children:l})})});ab.classes=Ky,ab.displayName=`@mantine/core/TableScrollContainer`;var ob={withRowBorders:!0,verticalSpacing:7},sb=kn((e,{layout:t,captionSide:n,horizontalSpacing:r,verticalSpacing:i,borderColor:a,stripedColor:o,highlightOnHoverColor:s,striped:c,highlightOnHover:l,stickyHeaderOffset:u,stickyHeader:d})=>({table:{"--table-layout":t,"--table-caption-side":n,"--table-horizontal-spacing":ft(r),"--table-vertical-spacing":ft(i),"--table-border-color":a?ir(a,e):void 0,"--table-striped-color":c&&o?ir(o,e):void 0,"--table-highlight-on-hover-color":l&&s?ir(s,e):void 0,"--table-sticky-header-offset":d?I(u):void 0}})),q=V((e,t)=>{let n=z(`Table`,ob,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,horizontalSpacing:l,verticalSpacing:u,captionSide:d,stripedColor:f,highlightOnHoverColor:p,striped:m,highlightOnHover:h,withColumnBorders:g,withRowBorders:_,withTableBorder:v,borderColor:y,layout:b,variant:x,data:S,children:C,stickyHeader:w,stickyHeaderOffset:T,mod:E,tabularNums:D,attributes:O,...k}=n,A=R({name:`Table`,props:n,className:i,style:a,classes:Ky,classNames:r,styles:o,unstyled:s,attributes:O,rootSelector:`table`,vars:c,varsResolver:sb});return(0,L.jsx)(Wy,{value:{getStyles:A,stickyHeader:w,striped:m===!0?`odd`:m||void 0,highlightOnHover:h,withColumnBorders:g,withRowBorders:_,captionSide:d||`bottom`},children:(0,L.jsx)(B,{component:`table`,variant:x,ref:t,mod:[{"data-with-table-border":v,"data-tabular-nums":D},E],...A(`table`),...k,children:C||!!S&&(0,L.jsx)(nb,{data:S})})})});q.classes=Ky,q.displayName=`@mantine/core/Table`,q.Td=Xy,q.Th=Yy,q.Tr=Zy,q.Thead=Qy,q.Tbody=$y,q.Tfoot=eb,q.Caption=tb,q.ScrollContainer=ab,q.DataRenderer=nb;var[cb,lb]=$e(`Tabs component was not found in the tree`),ub={root:`m_89d60db1`,"list--default":`m_576c9d4`,list:`m_89d33d6d`,tab:`m_4ec4dce6`,panel:`m_b0c91715`,tabSection:`m_fc420b1f`,tabLabel:`m_42bbd1ae`,"tab--default":`m_539e827b`,"list--outline":`m_6772fbd5`,"tab--outline":`m_b59ab47c`,"tab--pills":`m_c3381914`},db=V((e,t)=>{let n=z(`TabsList`,null,e),{children:r,className:i,grow:a,justify:o,classNames:s,styles:c,style:l,mod:u,...d}=n,f=lb();return(0,L.jsx)(B,{...d,...f.getStyles(`list`,{className:i,style:l,classNames:s,styles:c,props:n,variant:f.variant}),ref:t,role:`tablist`,variant:f.variant,mod:[{grow:a,orientation:f.orientation,placement:f.orientation===`vertical`&&f.placement,inverted:f.inverted},u],"aria-orientation":f.orientation,__vars:{"--tabs-justify":o},children:r})});db.classes=ub,db.displayName=`@mantine/core/TabsList`;var fb=V((e,t)=>{let n=z(`TabsPanel`,null,e),{children:r,className:i,value:a,classNames:o,styles:s,style:c,mod:l,keepMounted:u,...d}=n,f=lb(),p=f.value===a,m=f.keepMounted||u||p?r:null;return(0,L.jsx)(B,{...f.getStyles(`panel`,{className:i,classNames:o,styles:s,style:[c,p?void 0:{display:`none`}],props:n}),ref:t,mod:[{orientation:f.orientation},l],role:`tabpanel`,id:f.getPanelId(a),"aria-labelledby":f.getTabId(a),...d,children:m})});fb.classes=ub,fb.displayName=`@mantine/core/TabsPanel`;var pb=V((e,t)=>{let n=z(`TabsTab`,null,e),{className:r,children:i,rightSection:a,leftSection:o,value:s,onClick:c,onKeyDown:l,disabled:u,color:d,style:f,classNames:p,styles:m,vars:h,mod:g,tabIndex:_,...v}=n,y=xr(),{dir:b}=Ji(),x=lb(),S=s===x.value,C=e=>{x.onChange(x.allowTabDeactivation&&s===x.value?null:s),c?.(e)},w={classNames:p,styles:m,props:n};return(0,L.jsxs)(pl,{...x.getStyles(`tab`,{className:r,style:f,variant:x.variant,...w}),disabled:u,unstyled:x.unstyled,variant:x.variant,mod:[{active:S,disabled:u,orientation:x.orientation,inverted:x.inverted,placement:x.orientation===`vertical`&&x.placement},g],ref:t,role:`tab`,id:x.getTabId(s),"aria-selected":S,tabIndex:_===void 0?S||x.value===null?0:-1:_,"aria-controls":x.getPanelId(s),onClick:C,__vars:{"--tabs-color":d?ir(d,y):void 0},onKeyDown:ot({siblingSelector:`[role="tab"]`,parentSelector:`[role="tablist"]`,activateOnFocus:x.activateTabWithKeyboard,loop:x.loop,orientation:x.orientation||`horizontal`,dir:b,onKeyDown:l}),...v,children:[o&&(0,L.jsx)(`span`,{...x.getStyles(`tabSection`,w),"data-position":`left`,children:o}),i&&(0,L.jsx)(`span`,{...x.getStyles(`tabLabel`,w),children:i}),a&&(0,L.jsx)(`span`,{...x.getStyles(`tabSection`,w),"data-position":`right`,children:a})]})});pb.classes=ub,pb.displayName=`@mantine/core/TabsTab`;var mb=`Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value`,hb={keepMounted:!0,orientation:`horizontal`,loop:!0,activateTabWithKeyboard:!0,variant:`default`,placement:`left`},gb=kn((e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":pt(t),"--tabs-color":ir(n,e),"--tabs-text-color":ai(r,e)?Er({color:n,theme:e,autoContrast:r}):void 0}})),_b=V((e,t)=>{let n=z(`Tabs`,hb,e),{defaultValue:r,value:i,onChange:a,orientation:o,children:s,loop:c,id:l,activateTabWithKeyboard:u,allowTabDeactivation:d,variant:f,color:p,radius:m,inverted:h,placement:g,keepMounted:_,classNames:v,styles:y,unstyled:b,className:x,style:S,vars:C,autoContrast:w,mod:T,attributes:E,...D}=n,O=Qt(l),[k,A]=rn({value:i,defaultValue:r,finalValue:null,onChange:a}),j=R({name:`Tabs`,props:n,classes:ub,className:x,style:S,classNames:v,styles:y,unstyled:b,attributes:E,vars:C,varsResolver:gb});return(0,L.jsx)(cb,{value:{placement:g,value:k,orientation:o,id:O,loop:c,activateTabWithKeyboard:u,getTabId:tt(`${O}-tab`,mb),getPanelId:tt(`${O}-panel`,mb),onChange:A,allowTabDeactivation:d,variant:f,color:p,radius:m,inverted:h,keepMounted:_,unstyled:b,getStyles:j},children:(0,L.jsx)(B,{ref:t,id:O,variant:f,mod:[{orientation:o,inverted:o===`horizontal`&&h,placement:o===`vertical`&&g},T],...j(`root`),...D,children:s})})});_b.classes=ub,_b.displayName=`@mantine/core/Tabs`,_b.Tab=pb,_b.Panel=fb,_b.List=db;var vb=V((e,t)=>(0,L.jsx)(pd,{component:`input`,ref:t,...z(`TextInput`,null,e),__staticSelector:`TextInput`}));vb.classes=pd.classes,vb.displayName=`@mantine/core/TextInput`;var yb={root:`m_7341320d`},bb=kn((e,{size:t,radius:n,variant:r,gradient:i,color:a,autoContrast:o})=>{let s=e.variantColorResolver({color:a||e.primaryColor,theme:e,gradient:i,variant:r||`filled`,autoContrast:o});return{root:{"--ti-size":dt(t,`ti-size`),"--ti-radius":n===void 0?void 0:pt(n),"--ti-bg":a||r?s.background:void 0,"--ti-color":a||r?s.color:void 0,"--ti-bd":a||r?s.border:void 0}}}),xb=V((e,t)=>{let n=z(`ThemeIcon`,null,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,autoContrast:l,attributes:u,...d}=n;return(0,L.jsx)(B,{ref:t,...R({name:`ThemeIcon`,classes:yb,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:u,vars:c,varsResolver:bb})(`root`),...d})});xb.classes=yb,xb.displayName=`@mantine/core/ThemeIcon`;var Sb=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],Cb=[`xs`,`sm`,`md`,`lg`,`xl`];function wb(e,t){let n=t===void 0?`h${e}`:t;return Sb.includes(n)?{fontSize:`var(--mantine-${n}-font-size)`,fontWeight:`var(--mantine-${n}-font-weight)`,lineHeight:`var(--mantine-${n}-line-height)`}:Cb.includes(n)?{fontSize:`var(--mantine-font-size-${n})`,fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}:{fontSize:I(n),fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}}var Tb={root:`m_8a5d1357`},Eb={order:1},Db=kn((e,{order:t,size:n,lineClamp:r,textWrap:i})=>{let a=wb(t||1,n);return{root:{"--title-fw":a.fontWeight,"--title-lh":a.lineHeight,"--title-fz":a.fontSize,"--title-line-clamp":typeof r==`number`?r.toString():void 0,"--title-text-wrap":i}}}),J=V((e,t)=>{let n=z(`Title`,Eb,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,order:c,vars:l,size:u,variant:d,lineClamp:f,textWrap:p,mod:m,attributes:h,...g}=n,_=R({name:`Title`,props:n,classes:Tb,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:h,vars:l,varsResolver:Db});return[1,2,3,4,5,6].includes(c)?(0,L.jsx)(B,{..._(`root`),component:`h${c}`,variant:d,ref:t,mod:[{order:c,"data-line-clamp":typeof f==`number`},m],size:u,...g}):null});J.classes=Tb,J.displayName=`@mantine/core/Title`;function Ob(e){let t=e,n=!1,r=new Set;return{getState(){return t},updateState(e){t=typeof e==`function`?e(t):e},setState(e){this.updateState(e),r.forEach(e=>e(t))},initialize(e){n||=(t=e,!0)},subscribe(e){return r.add(e),()=>r.delete(e)}}}function kb(e){return(0,b.useSyncExternalStore)(e.subscribe,()=>e.getState(),()=>e.getState())}function Ab(e,t,n){let r=[],i=[],a={};for(let o of e){let e=o.position||t;a[e]=a[e]||0,a[e]+=1,a[e]<=n?i.push(o):r.push(o)}return{notifications:i,queue:r}}var jb=Ob({notifications:[],queue:[],defaultPosition:`bottom-right`,limit:5}),Mb=(e=jb)=>kb(e);function Nb(e,t){let n=e.getState(),r=Ab(t([...n.notifications,...n.queue]),n.defaultPosition,n.limit);e.setState({notifications:r.notifications,queue:r.queue,limit:n.limit,defaultPosition:n.defaultPosition})}function Y(e,t=jb){let n=e.id||Ct();return Nb(t,t=>e.id&&t.some(t=>t.id===e.id)?t:[...t,{...e,id:n}]),n}function Pb(e,t=jb){return Nb(t,t=>t.filter(t=>t.id===e?(t.onClose?.(t),!1):!0)),e}function Fb(e,t=jb){return Nb(t,t=>t.map(t=>t.id===e.id?{...t,...e}:t)),e.id}function Ib(e=jb){Nb(e,()=>[])}function Lb(e=jb){Nb(e,t=>t.slice(0,e.getState().limit))}var Rb={show:Y,hide:Pb,update:Fb,clean:Ib,cleanQueue:Lb,updateState:Nb};function zb(e,t){return zb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},zb(e,t)}function Bb(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,zb(e,t)}var Vb=o(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Hb=o(((e,t)=>{var n=Vb();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=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 s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Ub=o(((e,t)=>{t.exports=Hb()()})),Wb={disabled:!1},Gb=b.createContext(null),Kb=function(e){return e.scrollTop},qb=`unmounted`,Jb=`exited`,Yb=`entering`,Xb=`entered`,Zb=`exiting`,Qb=function(e){Bb(t,e);function t(t,n){var r=e.call(this,t,n)||this,i=n,a=i&&!i.isMounting?t.enter:t.appear,o;return r.appearStatus=null,t.in?a?(o=Jb,r.appearStatus=Yb):o=Xb:o=t.unmountOnExit||t.mountOnEnter?qb:Jb,r.state={status:o},r.nextCallback=null,r}t.getDerivedStateFromProps=function(e,t){return e.in&&t.status===`unmounted`?{status:Jb}:null};var n=t.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(e){var t=null;if(e!==this.props){var n=this.state.status;this.props.in?n!==`entering`&&n!==`entered`&&(t=Yb):(n===`entering`||n===`entered`)&&(t=Zb)}this.updateStatus(!1,t)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var e=this.props.timeout,t=n=r=e,n,r;return e!=null&&typeof e!=`number`&&(t=e.exit,n=e.enter,r=e.appear===void 0?n:e.appear),{exit:t,enter:n,appear:r}},n.updateStatus=function(e,t){if(e===void 0&&(e=!1),t!==null)if(this.cancelNextCallback(),t===`entering`){if(this.props.unmountOnExit||this.props.mountOnEnter){var n=this.props.nodeRef?this.props.nodeRef.current:ws.default.findDOMNode(this);n&&Kb(n)}this.performEnter(e)}else this.performExit();else this.props.unmountOnExit&&this.state.status===`exited`&&this.setState({status:qb})},n.performEnter=function(e){var t=this,n=this.props.enter,r=this.context?this.context.isMounting:e,i=this.props.nodeRef?[r]:[ws.default.findDOMNode(this),r],a=i[0],o=i[1],s=this.getTimeouts(),c=r?s.appear:s.enter;if(!e&&!n||Wb.disabled){this.safeSetState({status:Xb},function(){t.props.onEntered(a)});return}this.props.onEnter(a,o),this.safeSetState({status:Yb},function(){t.props.onEntering(a,o),t.onTransitionEnd(c,function(){t.safeSetState({status:Xb},function(){t.props.onEntered(a,o)})})})},n.performExit=function(){var e=this,t=this.props.exit,n=this.getTimeouts(),r=this.props.nodeRef?void 0:ws.default.findDOMNode(this);if(!t||Wb.disabled){this.safeSetState({status:Jb},function(){e.props.onExited(r)});return}this.props.onExit(r),this.safeSetState({status:Zb},function(){e.props.onExiting(r),e.onTransitionEnd(n.exit,function(){e.safeSetState({status:Jb},function(){e.props.onExited(r)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(e,t){t=this.setNextCallback(t),this.setState(e,t)},n.setNextCallback=function(e){var t=this,n=!0;return this.nextCallback=function(r){n&&(n=!1,t.nextCallback=null,e(r))},this.nextCallback.cancel=function(){n=!1},this.nextCallback},n.onTransitionEnd=function(e,t){this.setNextCallback(t);var n=this.props.nodeRef?this.props.nodeRef.current:ws.default.findDOMNode(this),r=e==null&&!this.props.addEndListener;if(!n||r){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var i=this.props.nodeRef?[this.nextCallback]:[n,this.nextCallback],a=i[0],o=i[1];this.props.addEndListener(a,o)}e!=null&&setTimeout(this.nextCallback,e)},n.render=function(){var e=this.state.status;if(e===`unmounted`)return null;var t=this.props,n=t.children;t.in,t.mountOnEnter,t.unmountOnExit,t.appear,t.enter,t.exit,t.timeout,t.addEndListener,t.onEnter,t.onEntering,t.onEntered,t.onExit,t.onExiting,t.onExited,t.nodeRef;var r=Lm(t,[`children`,`in`,`mountOnEnter`,`unmountOnExit`,`appear`,`enter`,`exit`,`timeout`,`addEndListener`,`onEnter`,`onEntering`,`onEntered`,`onExit`,`onExiting`,`onExited`,`nodeRef`]);return b.createElement(Gb.Provider,{value:null},typeof n==`function`?n(e,r):b.cloneElement(b.Children.only(n),r))},t}(b.Component);Qb.contextType=Gb,Qb.propTypes={};function $b(){}Qb.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:$b,onEntering:$b,onEntered:$b,onExit:$b,onExiting:$b,onExited:$b},Qb.UNMOUNTED=qb,Qb.EXITED=Jb,Qb.ENTERING=Yb,Qb.ENTERED=Xb,Qb.EXITING=Zb;function ex(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function tx(e,t){var n=function(e){return t&&(0,b.isValidElement)(e)?t(e):e},r=Object.create(null);return e&&b.Children.map(e,function(e){return e}).forEach(function(e){r[e.key]=n(e)}),r}function nx(e,t){e||={},t||={};function n(n){return n in t?t[n]:e[n]}var r=Object.create(null),i=[];for(var a in e)a in t?i.length&&(r[a]=i,i=[]):i.push(a);var o,s={};for(var c in t){if(r[c])for(o=0;o<r[c].length;o++){var l=r[c][o];s[r[c][o]]=n(l)}s[c]=n(c)}for(o=0;o<i.length;o++)s[i[o]]=n(i[o]);return s}function rx(e,t,n){return n[t]==null?e.props[t]:n[t]}function ix(e,t){return tx(e.children,function(n){return(0,b.cloneElement)(n,{onExited:t.bind(null,n),in:!0,appear:rx(n,`appear`,e),enter:rx(n,`enter`,e),exit:rx(n,`exit`,e)})})}function ax(e,t,n){var r=tx(e.children),i=nx(t,r);return Object.keys(i).forEach(function(a){var o=i[a];if((0,b.isValidElement)(o)){var s=a in t,c=a in r,l=t[a],u=(0,b.isValidElement)(l)&&!l.props.in;c&&(!s||u)?i[a]=(0,b.cloneElement)(o,{onExited:n.bind(null,o),in:!0,exit:rx(o,`exit`,e),enter:rx(o,`enter`,e)}):!c&&s&&!u?i[a]=(0,b.cloneElement)(o,{in:!1}):c&&s&&(0,b.isValidElement)(l)&&(i[a]=(0,b.cloneElement)(o,{onExited:n.bind(null,o),in:l.props.in,exit:rx(o,`exit`,e),enter:rx(o,`enter`,e)}))}}),i}var ox=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},sx={component:`div`,childFactory:function(e){return e}},cx=function(e){Bb(t,e);function t(t,n){var r=e.call(this,t,n)||this;return r.state={contextValue:{isMounting:!0},handleExited:r.handleExited.bind(ex(r)),firstRender:!0},r}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(e,t){var n=t.children,r=t.handleExited;return{children:t.firstRender?ix(e,r):ax(e,n,r),firstRender:!1}},n.handleExited=function(e,t){var n=tx(this.props.children);e.key in n||(e.props.onExited&&e.props.onExited(t),this.mounted&&this.setState(function(t){var n=Im({},t.children);return delete n[e.key],{children:n}}))},n.render=function(){var e=this.props,t=e.component,n=e.childFactory,r=Lm(e,[`component`,`childFactory`]),i=this.state.contextValue,a=ox(this.state.children).map(n);return delete r.appear,delete r.enter,delete r.exit,t===null?b.createElement(Gb.Provider,{value:i},a):b.createElement(Gb.Provider,{value:i},b.createElement(t,r,a))},t}(b.Component);cx.propTypes={},cx.defaultProps=sx;var lx=[`bottom-center`,`bottom-left`,`bottom-right`,`top-center`,`top-left`,`top-right`];function ux(e,t){return e.reduce((e,n)=>(e[n.position||t].push(n),e),lx.reduce((e,t)=>(e[t]=[],e),{}))}var dx={left:`translateX(-100%)`,right:`translateX(100%)`,"top-center":`translateY(-100%)`,"bottom-center":`translateY(100%)`},fx={left:`translateX(0)`,right:`translateX(0)`,"top-center":`translateY(0)`,"bottom-center":`translateY(0)`};function px({state:e,maxHeight:t,position:n,transitionDuration:r}){let[i,a]=n.split(`-`),o=a===`center`?`${i}-center`:a,s={opacity:0,maxHeight:t,transform:dx[o],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`},c={opacity:1,transform:fx[o]},l={opacity:0,maxHeight:0,transform:dx[o]},u={entering:c,entered:c,exiting:l,exited:l};return{...s,...u[e]}}function mx(e,t){return typeof t==`number`?t:t===!1||e===!1?!1:e}var hx=(0,b.forwardRef)(({data:e,onHide:t,autoClose:n,...r},i)=>{let{autoClose:a,message:o,...s}=e,c=mx(n,e.autoClose),l=(0,b.useRef)(-1),u=()=>window.clearTimeout(l.current),d=()=>{t(e.id),u()},f=()=>{typeof c==`number`&&(l.current=window.setTimeout(d,c))};return(0,b.useEffect)(()=>{e.onOpen?.(e)},[]),(0,b.useEffect)(()=>(f(),u),[c]),(0,L.jsx)(kg,{...r,...s,onClose:d,ref:i,onMouseEnter:u,onMouseLeave:f,children:o})});hx.displayName=`@mantine/notifications/NotificationContainer`;var gx={root:`m_b37d9ac7`,notification:`m_5ed0edd0`},_x=Qb,vx={position:`bottom-right`,autoClose:4e3,transitionDuration:250,containerWidth:440,notificationMaxHeight:200,limit:5,zIndex:ct(`overlay`),store:jb,withinPortal:!0},yx=kn((e,{zIndex:t,containerWidth:n})=>({root:{"--notifications-z-index":t?.toString(),"--notifications-container-width":I(n)}})),bx=V((e,t)=>{let n=z(`Notifications`,vx,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,position:l,autoClose:u,transitionDuration:d,containerWidth:f,notificationMaxHeight:p,limit:m,zIndex:h,store:g,portalProps:_,withinPortal:v,...y}=n,x=xr(),S=Mb(g),C=Yt(),w=cn(),T=(0,b.useRef)({}),E=(0,b.useRef)(0),D=x.respectReducedMotion&&w?1:d,O=R({name:`Notifications`,classes:gx,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,vars:c,varsResolver:yx});(0,b.useEffect)(()=>{g?.updateState(e=>({...e,limit:m||5,defaultPosition:l}))},[m,l]),It(()=>{S.notifications.length>E.current&&setTimeout(()=>C(),0),E.current=S.notifications.length},[S.notifications]);let k=ux(S.notifications,l),A=lx.reduce((e,t)=>(e[t]=k[t].map(({style:e,...n})=>(0,L.jsx)(_x,{timeout:D,onEnter:()=>T.current[n.id].offsetHeight,nodeRef:{current:T.current[n.id]},children:r=>(0,L.jsx)(hx,{ref:e=>{e&&(T.current[n.id]=e)},data:n,onHide:e=>Pb(e,g),autoClose:u,...O(`notification`,{style:{...px({state:r,position:t,transitionDuration:D,maxHeight:p}),...e}})})},n.id)),e),{});return(0,L.jsxs)(Nl,{withinPortal:v,..._,children:[(0,L.jsx)(B,{...O(`root`),"data-position":`top-center`,ref:t,...y,children:(0,L.jsx)(cx,{children:A[`top-center`]})}),(0,L.jsx)(B,{...O(`root`),"data-position":`top-left`,...y,children:(0,L.jsx)(cx,{children:A[`top-left`]})}),(0,L.jsx)(B,{...O(`root`,{className:ze.classNames.fullWidth}),"data-position":`top-right`,...y,children:(0,L.jsx)(cx,{children:A[`top-right`]})}),(0,L.jsx)(B,{...O(`root`,{className:ze.classNames.fullWidth}),"data-position":`bottom-right`,...y,children:(0,L.jsx)(cx,{children:A[`bottom-right`]})}),(0,L.jsx)(B,{...O(`root`),"data-position":`bottom-left`,...y,children:(0,L.jsx)(cx,{children:A[`bottom-left`]})}),(0,L.jsx)(B,{...O(`root`),"data-position":`bottom-center`,...y,children:(0,L.jsx)(cx,{children:A[`bottom-center`]})})]})});bx.classes=gx,bx.displayName=`@mantine/notifications/Notifications`,bx.show=Rb.show,bx.hide=Rb.hide,bx.update=Rb.update,bx.clean=Rb.clean,bx.cleanQueue=Rb.cleanQueue,bx.updateState=Rb.updateState;var xx=class{max;cache;constructor(e=10){this.max=e,this.cache=new Map}clear(){this.cache.clear()}get(e){let t=this.cache.get(e);return t&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){this.cache.has(e)?this.cache.delete(e):this.cache.size>=this.max&&this.cache.delete(this.first()),this.cache.set(e,t)}delete(e){this.cache.delete(e)}keys(){return this.cache.keys()}first(){return this.cache.keys().next().value}},Sx=class{operator;child;constructor(e,t){this.operator=e,this.child=t}toString(){return`${this.operator}(${this.child.toString()})`}},Cx=class{operator;left;right;constructor(e,t,n){this.operator=e,this.left=t,this.right=n}toString(){return`(${this.left.toString()} ${this.operator} ${this.right.toString()})`}},wx=class{prefixParselets={};infixParselets={};registerInfix(e,t){return this.infixParselets[e]=t,this}registerPrefix(e,t){return this.prefixParselets[e]=t,this}prefix(e,t,n){return this.registerPrefix(e,{parse(e,r){return n(r,e.consumeAndParse(t))}})}infixLeft(e,t,n){return this.registerInfix(e,{parse(e,r,i){return n(r,i,e.consumeAndParse(t))},precedence:t})}construct(e){return new Tx(e,this.prefixParselets,this.infixParselets)}},Tx=class{tokens;prefixParselets;infixParselets;constructor(e,t,n){this.tokens=e,this.prefixParselets=t,this.infixParselets=n}hasMore(){return this.tokens.length>0}match(e){return this.peek()?.id===e?(this.consume(),!0):!1}consumeAndParse(e=1/0){let t=this.consume(),n=this.prefixParselets[t.id];if(!n)throw Error(`Parse error at "${t.value}" (line ${t.line}, column ${t.column}). No matching prefix parselet.`);let r=n.parse(this,t);for(;e>this.getPrecedence();){let e=this.consume();r=this.getInfixParselet(e).parse(this,r,e)}return r}getPrecedence(){let e=this.peek();if(!e)return 1/0;let t=this.getInfixParselet(e);return t?t.precedence:1/0}consume(e,t){if(!this.tokens.length)throw Error(`Cant consume unknown more tokens.`);if(e&&this.peek()?.id!==e){let t=this.peek();throw Error(`Expected ${e} but got "${t.id}" (${t.value}) at line ${t.line} column ${t.column}.`)}if(t&&this.peek()?.value!==t){let e=this.peek();throw Error(`Expected "${t}" but got "${e.value}" at line ${e.line} column ${e.column}.`)}return this.tokens.shift()}peek(){return this.tokens.length>0?this.tokens[0]:void 0}removeComments(){this.tokens=this.tokens.filter(e=>e.id!==`Comment`)}getInfixParselet(e){return this.infixParselets[e.id===`Symbol`?e.value:e.id]}};function Ex(e){if(e!==void 0)return Array.isArray(e)?e:[e]}var Dx=`http://hl7.org`,Ox=`ok`,kx=`created`,Ax=`gone`,jx=`not-modified`,Mx=`not-found`,Nx=`unauthorized`,Px=`forbidden`,Fx=`accepted`,Ix={resourceType:`OperationOutcome`,id:Ox,issue:[{severity:`information`,code:`informational`,details:{text:`All OK`}}]},Lx={resourceType:`OperationOutcome`,id:Mx,issue:[{severity:`error`,code:`not-found`,details:{text:`Not found`}}]},Rx={resourceType:`OperationOutcome`,id:Nx,issue:[{severity:`error`,code:`login`,details:{text:`Unauthorized`}}]},zx={...Rx,issue:[...Rx.issue,{severity:`error`,code:`expired`,details:{text:`Token expired`}}]},Bx={...Rx,issue:[...Rx.issue,{severity:`error`,code:`invalid`,details:{text:`Token not issued for this audience`}}]},Vx={resourceType:`OperationOutcome`,id:Px,issue:[{severity:`error`,code:`forbidden`,details:{text:`Forbidden`}}]};function Hx(e,t){return{resourceType:`OperationOutcome`,issue:[{severity:`error`,code:`invalid`,details:{text:e},...t?{expression:Ex(t)}:void 0}]}}function Ux(e,t,n,r){return{resourceType:`OperationOutcome`,issue:[{severity:`error`,code:n??`structure`,details:{text:e},...t?{expression:t}:void 0,...r?{diagnostics:r}:void 0}]}}function Wx(e){return e?.issue?.[0]?.details?.coding?.find(e=>e.system===`urn:ietf:rfc:3986`)?.code}function Gx(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 Kx(e){return typeof e==`object`&&!!e&&e.resourceType===`OperationOutcome`}function qx(e){return e.id===Ox||e.id===kx||e.id===jx||e.id===Fx}function Jx(e){return e.id===Ax}var Yx=class extends Error{outcome;constructor(e,t){super(Qx(e),t),this.name=`OperationOutcomeError`,this.outcome=e}};function Xx(e){return e instanceof Yx?e.outcome:Kx(e)?e:Hx(Zx(e))}function Zx(e){return e?typeof e==`string`?e:Gx(e)?e.message:Kx(e)?Qx(e):typeof e==`object`&&`code`in e&&typeof e.code==`string`?e.code:JSON.stringify(e):`Unknown error`}function Qx(e){let t=e.issue?.map($x)??[];return t.length>0?t.join(`; `):`Unknown error`}function $x(e){let t;return t=e.details?.text?e.diagnostics?`${e.details.text} (${e.diagnostics})`:e.details.text:e.diagnostics?e.diagnostics:`Unknown error`,e.expression?.length&&(t+=` (${e.expression.join(`, `)})`),t}function eS(e,t){let n=t.max&&t.max===2**53-1?1/0:t.max;return{path:e,description:``,type:t.type??[],min:t.min??0,max:n??1,isArray:!!n&&n>1,constraints:[]}}function tS(e){let t=Object.create(null);for(let[n,r]of Object.entries(e))t[n]={name:n,type:n,path:n,elements:Object.fromEntries(Object.entries(r.elements).map(([e,t])=>[e,eS(e,t)])),constraints:[],innerTypes:[]};return t}var nS={Element:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]}}},BackboneElement:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},modifierExtension:{max:9007199254740991,type:[{code:`Extension`}]}}},Address:{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`}]}}},Age:{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`}]}}},Annotation:{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`}]}}},Attachment:{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`}]}}},CodeableConcept:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},coding:{max:9007199254740991,type:[{code:`Coding`}]},text:{type:[{code:`string`}]}}},Coding:{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`}]}}},ContactDetail:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},name:{type:[{code:`string`}]},telecom:{max:9007199254740991,type:[{code:`ContactPoint`}]}}},ContactPoint:{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`}]}}},Contributor:{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`}]}}},Count:{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`}]}}},DataRequirement:{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`}]}}},DataRequirementCodeFilter:{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`}]}}},DataRequirementDateFilter:{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`}]}}},DataRequirementSort:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},path:{min:1,type:[{code:`string`}]},direction:{min:1,type:[{code:`code`}]}}},Distance:{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`}]}}},Dosage:{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`]}]}}},DosageDoseAndRate:{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`]}]}}},Duration:{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`}]}}},ElementDefinition:{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`}]}}},ElementDefinitionSlicingDiscriminator:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},type:{min:1,type:[{code:`code`}]},path:{min:1,type:[{code:`string`}]}}},ElementDefinitionSlicing:{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`}]}}},ElementDefinitionBase:{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`}]}}},ElementDefinitionType:{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`}]}}},ElementDefinitionExample:{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`}]}}},ElementDefinitionConstraint:{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`]}]}}},ElementDefinitionBinding:{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`]}]}}},ElementDefinitionMapping:{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`}]}}},Expression:{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`}]}}},Extension:{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`}]}}},HumanName:{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`}]}}},Identifier:{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`]}]}}},MarketingStatus:{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`}]}}},Meta:{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`}]}}},Money:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},value:{type:[{code:`decimal`}]},currency:{type:[{code:`code`}]}}},Narrative:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},status:{min:1,type:[{code:`code`}]},div:{min:1,type:[{code:`xhtml`}]}}},ParameterDefinition:{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`]}]}}},Period:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},start:{type:[{code:`dateTime`}]},end:{type:[{code:`dateTime`}]}}},Population:{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`}]}}},ProdCharacteristic:{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`}]}}},ProductShelfLife:{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`}]}}},Quantity:{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`}]}}},Range:{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`]}]}}},Ratio:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},numerator:{type:[{code:`Quantity`}]},denominator:{type:[{code:`Quantity`}]}}},Reference:{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`}]}}},RelatedArtifact:{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`]}]}}},SampledData:{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`}]}}},Signature:{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`}]}}},SubstanceAmount:{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`}]}}},SubstanceAmountReferenceRange:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},lowLimit:{type:[{code:`Quantity`}]},highLimit:{type:[{code:`Quantity`}]}}},Timing:{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`}]}}},TimingRepeat:{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`}]}}},TriggerDefinition:{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`}]}}},UsageContext:{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`]}]}}},MoneyQuantity:{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`}]}}},SimpleQuantity:{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`}]}}},IdentityProvider:{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`}]},identitySource:{type:[{code:`code`}]},identityMappingMode:{type:[{code:`code`}]}}}};function rS(e){return new gS(e).parse()}var iS=tS(nS),aS=Object.create(null),oS=Object.create(null),sS={"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 cS(e){let t;return t=oS[e],t||=oS[e]=Object.create(null),t}function lS(e){let t=(Array.isArray(e)?e:e.entry?.map(e=>e.resource)??[]).filter(e=>e?.resourceType===`StructureDefinition`);Dw(t);for(let e of t)uS(e)}function uS(e){if(!e?.name)throw Error(`Failed loading StructureDefinition from bundle`);if(e.resourceType!==`StructureDefinition`)return;let t=rS(e),n=sS[e.url],r,i;n?(r=iS,i=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=iS,i=e.type):(r=cS(e.url),i=e.type),r[i]=t;for(let e of t.innerTypes)e.parentType=t,r[e.name]=e;aS[e.url]=t}function dS(e){return!!iS[e]}function fS(e,t){if(t){let n=cS(t)[e];if(n)return n}return iS[e]}function pS(e,t){let n=fS(e,t);if(!n)throw new Yx(Hx(`Unknown data type: `+e));return n}function mS(e){return!!aS[e]}function hS(e){return aS[e]}var gS=class{root;elements;elementIndex;index;resourceSchema;slicingContext;innerTypes;backboneContext;constructor(e){if(!e.snapshot?.element||e.snapshot.element.length===0)throw Error(`No snapshot defined for StructureDefinition '${e.name}'`);this.root=e.snapshot.element[0],this.elements=e.snapshot.element.slice(1),this.elementIndex=Object.create(null),this.index=0,this.resourceSchema={name:e.name,path:this.root.path,title:e.title,type:e.type,url:e.url,version:e.version,kind:e.kind,description:CS(e),elements:{},constraints:this.parseElementDefinition(this.root).constraints,innerTypes:[],summaryProperties:new Set,mandatoryProperties:new Set},this.innerTypes=[]}parse(){let e=this.next();for(;e;){if(e.sliceName)this.parseSliceStart(e);else if(e.id?.includes(`:`)){if(this.slicingContext?.current){let t=vS(e,this.slicingContext.path);this.slicingContext.current.elements[t]=this.parseElementDefinition(e)}}else{let t=this.parseElementDefinition(e);this.checkFieldEnter(e,t);let n=this.backboneContext;for(;n;){if(e.path?.startsWith(n.path+`.`)){n.type.elements[vS(e,n.path)]=t;break}n=n.parent}if(!n){let n=vS(e,this.root.path);e.isSummary&&this.resourceSchema.summaryProperties?.add(n.replace(`[x]`,``)),t.min>0&&this.resourceSchema.mandatoryProperties?.add(n.replace(`[x]`,``)),this.resourceSchema.elements[n]=t}this.checkFieldExit(e)}e=this.next()}return this.checkFieldExit(),this.innerTypes.length>0&&(this.resourceSchema.innerTypes=this.innerTypes),this.resourceSchema}checkFieldEnter(e,t){this.isInnerType(e)&&this.enterInnerType(e),this.slicingContext&&!bS(this.slicingContext.path,e?.path)&&(this.slicingContext=void 0),e.slicing&&!this.slicingContext&&this.enterSlice(e,t)}enterInnerType(e){for(;this.backboneContext&&!bS(this.backboneContext?.path,e.path);)this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;let t=Aw(e);this.backboneContext={type:{name:t,type:t,path:e.path,title:e.label,description:e.definition,elements:{},constraints:this.parseElementDefinition(e).constraints,innerTypes:[]},path:e.path,parent:bS(this.backboneContext?.path,e.path)?this.backboneContext:this.backboneContext?.parent}}enterSlice(e,t){SS(e)&&!this.peek()?.sliceName||(t.slicing={discriminator:(e.slicing?.discriminator??[]).map(e=>{if(e.type!==`value`&&e.type!==`pattern`&&e.type!==`type`)throw Error(`Unsupported slicing discriminator type: ${e.type}`);return{path:e.path,type:e.type}}),slices:[],ordered:e.slicing?.ordered??!1,rule:e.slicing?.rules},this.slicingContext={field:t.slicing,path:e.path??``})}checkFieldExit(e=void 0){if(this.backboneContext&&!bS(this.backboneContext.path,e?.path))if(this.backboneContext.parent)do this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;while(this.backboneContext&&!bS(this.backboneContext.path,e?.path));else this.innerTypes.push(this.backboneContext.type),this.backboneContext=void 0}next(){let e=this.peek();if(e)return this.index++,e}peek(){let e=this.elements[this.index];if(e){if(this.elementIndex[e.path??``]=e,e.contentReference){let t=e.contentReference.slice(e.contentReference.indexOf(`#`)+1),n=this.elementIndex[t];return n?{...n,id:e.id,path:e.path,min:e.min??n.min,max:e.max??n.max,base:{path:n.base?.path??t,min:e.base?.min??n.base?.min??n.min,max:e.base?.max??n.base?.max??n.max},contentReference:e.contentReference,definition:e.definition}:void 0}return e}}isInnerType(e){let t=this.peek();return!!(bS(e?.path,t?.path)&&e.type?.some(e=>[`BackboneElement`,`Element`].includes(e.code)))}parseSliceStart(e){if(!this.slicingContext)throw Error(`Invalid slice start before discriminator: ${e.sliceName} (${e.id})`);this.slicingContext.current={...this.parseElementDefinition(e),name:e.sliceName??``,definition:e.definition,elements:{}},this.slicingContext.field.slices.push(this.slicingContext.current)}parseElementDefinitionType(e){return(e.type??[]).map(t=>{let n;return(t.code===`BackboneElement`||t.code===`Element`)&&(n=Aw(e)),n||=gC(t,`http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type`)?.valueUrl,n||=t.code??``,{code:n,targetProfile:t.targetProfile,profile:t.profile}})}parseElementDefinition(e){let t=_S(e.max),n=e.base?.max?_S(e.base.max):t,r={type:`ElementDefinition`,value:e};return{description:e.definition||``,path:e.path||e.base?.path||``,min:e.min??0,max:t,isArray:n>1,constraints:(e.constraint??[]).map(e=>({key:e.key??``,severity:e.severity??`error`,expression:e.expression??``,description:e.human??``})),type:this.parseElementDefinitionType(e),fixed:xS(NS(r,`fixed[x]`)),pattern:xS(NS(r,`pattern[x]`)),binding:e.binding}}};function _S(e){return e===`*`?1/0:Number.parseInt(e,10)}function vS(e,t=``){return yS(e.path,t)}function yS(e,t){return e?t&&e.startsWith(t)?e.substring(t.length+1):e:``}function bS(e,t){return!e||!t?!1:t.startsWith(e+`.`)||t===e}function xS(e){return Array.isArray(e)&&e.length>0?e[0]:xC(e)?void 0:e}function SS(e){let t=e.slicing?.discriminator;return!!(e.type?.some(e=>e.code===`Extension`)&&t?.length===1&&t[0].type===`value`&&t[0].path===`url`)}function CS(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 wS(e,t,n){if(e===void 0)return[void 0];if(t===`$this`)return[e];let r=n?.withPath?TS:NS,[i,...a]=t.split(`.`),o=[r(e,i,n)];for(let e of a){let t=[];for(let i of o)if(Array.isArray(i))for(let a of i)t.push(r(a,e,n));else (n?.withPath&&i?.value!==void 0||!n?.withPath&&i!==void 0)&&t.push(r(i,e,n));o=t}return o}function TS(e,t,n){let r=e.path;return ES(NS(e,t,n),r,t)}function ES(e,t,n){let r=t?t+`.`:``;return e===void 0?{type:`undefined`,value:void 0,path:`${r}${n}`}:Array.isArray(e)?e.map((e,t)=>({...e,path:`${r}${n}[${t}]`})):{...e,path:`${r}${n}`}}new xx(1e3);var DS={canonical:/^\S*$/,code:/^[^\s]+( [^\s]+)*$/,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)?)?)?$/,id:/^[A-Za-z0-9\-.]{1,64}$/,instant:/^(\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))$/,markdown:/^[\r\n\t\u0020-\uFFFF]+$/,oid:/^urn:oid:[0-2](\.(0|[1-9]\d*))+$/,string:/^[\r\n\t\u0020-\uFFFF]+$/,time:/^([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?$/,uri:/^\S*$/,url:/^\S*$/,uuid:/^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,xhtml:/.*/};function OS(e,t,n,r){if(Array.isArray(e))return!1;let i;i=t.path===`$this`?n:(r??n.elements)[t.path];let a=n.type;switch(t.type){case`value`:case`pattern`:if(!e||!i)return!1;if(i.pattern)return DC(e,i.pattern);if(i.fixed)return wC(e,i.fixed);if(i.binding?.strength===`required`&&i.binding.valueSet)return!0;break;case`type`:return!e||!a?.length?!1:a.some(t=>t.code===e.type)}return!1}function kS(e){return[{type:X.boolean,value:e}]}function AS(e){return e==null?{type:`undefined`,value:void 0}:Number.isSafeInteger(e)?{type:X.integer,value:e}:typeof e==`number`?{type:X.decimal,value:e}:typeof e==`boolean`?{type:X.boolean,value:e}:typeof e==`string`?{type:X.string,value:e}:ZS(e)?{type:X.Quantity,value:e}:Bw(e)?{type:e.resourceType,value:e}:FC(e)?{type:X.CodeableConcept,value:e}:PC(e)?{type:X.Coding,value:e}:{type:X.BackboneElement,value:e}}function jS(e){return e.length===0?!1:!!e[0].value}function MS(e,t){if(e.length!==0){if(e.length===1&&(!t||e[0].type===t))return e[0];throw Error(`Expected singleton of type ${t}, but found ${JSON.stringify(e)}`)}}function NS(e,t,n){if(!e.value)return;let r=Rw(e.type,t,n?.profileUrl);return r?PS(e,t,r):IS(e,t)}function PS(e,t,n){let r=e.value,i=n.type;if(!i||i.length===0)return;let a,o=`undefined`,s,c=n.path.lastIndexOf(`.`),l=n.path.substring(c+1),u=l,d=!1;l.endsWith(`[x]`)&&(u=l.substring(0,l.length-3),d=!0);for(let e of i){let t=u;if(d&&(t+=VC(e.code)),a=r[t],s=r[`_`+t],a!==void 0||s!==void 0){o=e.code;break}}if(s)if(Array.isArray(a)){a=a.slice();for(let e=0;e<Math.max(a.length,s.length);e++)a[e]=tC(a[e],s[e])}else if(!a&&Array.isArray(s)){a=s.slice();for(let e=0;e<s.length;e++)a[e]=tC(void 0,s[e])}else a=tC(a,s);if(!xC(a))return(o===`Element`||o===`BackboneElement`)&&(o=n.type[0].code),Array.isArray(a)?a.map(e=>FS(e,o)):FS(a,o)}function FS(e,t){return t===`Resource`&&Bw(e)&&(t=e.resourceType),{type:t,value:e}}function IS(e,t){let n=e.value;if(!n||typeof n!=`object`)return;let r;if(t in n){let e=n[t];r=Array.isArray(e)?e.map(AS):AS(e)}else{let e=t.endsWith(`[x]`)?t.substring(0,t.length-3):t;for(let t of Object.values(X)){let i=e+VC(t);if(i in n){let e=n[i];r=Array.isArray(e)?e.map(e=>({type:t,value:e})):{type:t,value:e};break}}}if(Array.isArray(r)){if(r.length===0||xC(r[0]))return}else if(xC(r))return;return r}function LS(e){let t=[];for(let n of e){let e=!1;for(let r of t)if(jS(VS(n,r))){e=!0;break}e||t.push(n)}return t}function RS(e){return kS(!jS(e))}function zS(e,t){return e.length===0||t.length===0?[]:e.length===t.length?kS(e.every((e,n)=>jS(VS(e,t[n])))):kS(!1)}function BS(e,t){return e.length===0||t.length===0?[]:e.length===t.length?kS(e.some((e,n)=>!jS(VS(e,t[n])))):kS(!0)}function VS(e,t){let n=e.value?.valueOf(),r=t.value?.valueOf();return typeof n==`number`&&typeof r==`number`?kS(Math.abs(n-r)<1e-8):ZS(n)&&ZS(r)?kS(QS(n,r)):kS(typeof n==`object`&&typeof r==`object`?$S(e,t):n===r)}function HS(e,t){return e.length===0&&t.length===0?kS(!0):e.length===t.length?(e.sort(WS),t.sort(WS),kS(e.every((e,n)=>jS(US(e,t[n]))))):kS(!1)}function US(e,t){let{type:n,value:r}=e,{type:i,value:a}=t,o=r?.valueOf(),s=a?.valueOf();return typeof o==`number`&&typeof s==`number`?kS(Math.abs(o-s)<.01):ZS(o)&&ZS(s)?kS(QS(o,s)):kS(n===`Coding`&&i===`Coding`?typeof o!=`object`||typeof s!=`object`?!1:o.code===s.code&&o.system===s.system:typeof o==`object`&&typeof s==`object`?$S({...o,id:void 0},{...s,id:void 0}):typeof o==`string`&&typeof s==`string`?o.toLowerCase()===s.toLowerCase():o===s)}function WS(e,t){let 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 GS(e,t){let{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 KS(n);case`DateTime`:return qS(n);case`Time`:return typeof n==`string`&&!!/^T\d/.exec(n);case`Period`:return JS(n);case`Quantity`:return ZS(n);default:return e.type===r||typeof n==`object`&&n?.resourceType===r}}function KS(e){return typeof e==`string`&&!!DS.date.exec(e)}function qS(e){return typeof e==`string`&&!!DS.dateTime.exec(e)}function JS(e){return!!(e&&typeof e==`object`&&(`start`in e&&qS(e.start)||`end`in e&&qS(e.end)))}function YS(e){if(KS(e)||qS(e))return{start:XS(e,`0000-01-01T00:00:00.000`),end:XS(e,`xxxx-12-31T23:59:59.999`)};if(JS(e))return{start:e.start?XS(e.start,`0000-01-01T00:00:00.000`):void 0,end:e.end?XS(e.end,`xxxx-12-31T23:59:59.999`):void 0}}function XS(e,t){let n=`Z`,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));let i=e+t.substring(e.length)+n;return new Date(i).toISOString()}function ZS(e){return!!(e&&typeof e==`object`&&`value`in e&&typeof e.value==`number`)}function QS(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 $S(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(eC(n)&&eC(i)){if(!$S(n,i))return!1}else if(n!==i)return!1}return!0}function eC(e){return typeof e==`object`&&!!e}function tC(e,t){if(t){if(typeof t!=`object`)throw Error(`Primitive extension must be an object`);return nC(e??{},t)}return e}function nC(e,t){return delete t.__proto__,delete t.constructor,Object.assign(e,t)}function rC(e,t){return Bw(e,t)&&`id`in e&&typeof e.id==`string`}function iC(e){let t=aC(e)??`undefined/undefined`,n=lC(e);return n===t?{reference:t}:{reference:t,display:n}}function aC(e){if(Vw(e))return e.reference;if(rC(e))return`${e.resourceType}/${e.id}`}function oC(e){if(e)return Vw(e)?e.reference.split(`/`)[1]:e.id}function sC(e){if(e)if(e.accounts&&e.account){let t=e.accounts;return t.some(t=>t.reference===e.account?.reference)?t:[e.account,...t]}else return Ex(e.accounts??e.account)}function cC(e){return e.resourceType===`Patient`||e.resourceType===`Practitioner`||e.resourceType===`RelatedPerson`}function lC(e){if(cC(e)){let t=uC(e);if(t)return t}if(e.resourceType===`Device`){let t=dC(e);if(t)return t}if(e.resourceType===`MedicationRequest`&&e.medicationCodeableConcept)return bw(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]),FC(t))return bw(t);if(IC(t))return t.text}return aC(e)??``}function uC(e){let t=e.name;if(t&&t.length>0)return sw(t[0])}function dC(e){let t=e.deviceName;if(t&&t.length>0)return t[0].name}function fC(e){if(!(`photo`in e))return;let t=e.photo;if(t)if(Array.isArray(t))for(let e of t){let t=pC(e);if(t)return t}else return pC(t)}function pC(e){if(e.url&&e.contentType?.startsWith(`image/`))return e.url}function mC(e,t){let n=new Date(e);n.setUTCHours(0,0,0,0);let r=t?new Date(t):new Date;r.setUTCHours(0,0,0,0);let i=n.getUTCFullYear(),a=n.getUTCMonth(),o=n.getUTCDate(),s=r.getUTCFullYear(),c=r.getUTCMonth(),l=r.getUTCDate(),u=s-i;(c<a||c===a&&l<o)&&u--;let d=s*12+c-(i*12+a);l<o&&d--;let f=Math.floor((r.getTime()-n.getTime())/(1e3*60*60*24));return{years:u,months:d,days:f}}function hC(e,t){let{years:n,months:r,days:i}=mC(e,t);return n>=2?n.toString().padStart(3,`0`)+`Y`:r>=1?r.toString().padStart(3,`0`)+`M`:i.toString().padStart(3,`0`)+`D`}function gC(e,...t){let n=e;for(let e=0;e<t.length&&n;e++)n=(n?.extension)?.find(n=>n.url===t[e]);return n}function _C(e,t){let n=vC(e);return JSON.stringify(n,null,t?2:void 0)??``}function vC(e){if(!(e==null||e===``))return typeof e==`object`?Array.isArray(e)?yC(e):bC(e):e}function yC(e){let t=e.length;if(t===0)return;let n,r=0;for(let i=0;i<t;i++){let t=e[i],a=vC(t);a!==t&&!n&&(n=Array.from(e)),a===void 0?n&&(n[i]=null):(n&&(n[i]=a),r++)}if(r!==0)return n??e}function bC(e){let t,n=0;for(let r in e){let i=e[r],a=vC(i);a!==i&&!t&&(t={...e}),a===void 0?t&&delete t[r]:(t&&(t[r]=a),n++)}if(n!==0)return t??e}function xC(e){if(e==null)return!0;let t=typeof e;return t===`string`||t===`object`?!SC(e):!1}function SC(e){if(e==null)return!1;let t=typeof e;return t===`string`&&e!==``||t===`object`&&(`length`in e&&e.length>0||Object.keys(e).length>0)}function CC(e){if(!e)return;let t=e.length-1;for(;t>=0&&xC(e[t]);)t--;return t>=0?e.slice(0,t+1):void 0}function wC(e,t,n){return e===t||xC(e)&&xC(t)?!0:xC(e)||xC(t)?!1:Array.isArray(e)&&Array.isArray(t)?TC(e,t):Array.isArray(e)||Array.isArray(t)?!1:MC(e)&&MC(t)?EC(e,t,n):!1}function TC(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!wC(e[n],t[n]))return!1;return!0}function EC(e,t,n){let r=new Set;for(let t of Object.keys(e))r.add(t);for(let e of Object.keys(t))r.add(e);n===`meta`&&(r.delete(`versionId`),r.delete(`lastUpdated`),r.delete(`author`));for(let n of r){let r=e[n],i=t[n];if(!wC(r,i,n))return!1}return!0}function DC(e,t){return xC(e)?!0:xC(t)?!1:Array.isArray(e)&&Array.isArray(t)?OC(e,t):Array.isArray(e)||Array.isArray(t)?!1:MC(e)&&MC(t)?kC(e,t):MC(e)||MC(t)?!1:e===t}function OC(e,t){return t.every(t=>e.some(e=>DC(e,t)))}function kC(e,t){return Object.entries(t).every(([t,n])=>t in e&&DC(e[t],n))}function AC(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function jC(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 MC(e){return typeof e==`object`&&!!e}function NC(e){return typeof e==`string`}function PC(e){return MC(e)&&`code`in e&&typeof e.code==`string`}function FC(e){return MC(e)&&`coding`in e&&Array.isArray(e.coding)&&e.coding.every(PC)}function IC(e){return MC(e)&&`text`in e&&typeof e.text==`string`}var LC=[];for(let e=0;e<256;e++)LC.push(e.toString(16).padStart(2,`0`));function RC(e){let t=BC(e),n=new Uint8Array(t),r=Array(n.length);for(let e=0;e<n.length;e++)r[e]=LC[n[e]];return r.join(``)}function zC(e){let t=BC(e),n=new Uint8Array(t),r=Array(n.length);for(let e=0;e<n.length;e++)r[e]=String.fromCodePoint(n[e]);return window.btoa(r.join(``))}function BC(e){return ArrayBuffer.isView(e)?e.buffer:e}function VC(e){return e?e.charAt(0).toUpperCase()+e.substring(1):``}function HC(e){return e.length>0&&e.startsWith(e[0].toUpperCase())}function UC(e,t){let n=e+`.`;if(t.startsWith(n))return t.slice(n.length)}function WC(e,t){return e.coding?.find(e=>e.system===t)?.code}var GC=(e,t)=>new Promise((n,r)=>{t?.signal?.throwIfAborted();let i=setTimeout(n,e);t?.signal?.addEventListener(`abort`,()=>{clearTimeout(i),r(t.signal?.reason)},{once:!0})});function KC(e,t,n){let r=[];for(let i=0;i<n-1;i++){let n=e.indexOf(t);if(n<0)break;r.push(e.slice(0,n)),e=e.slice(n+t.length)}return r.push(e),r}function qC(e){let t,n=!1;return function(){return n||=(t=e(),!0),t}}function JC(e,t){return e?(e.push(t),e):[t]}function YC(e){return e.sort((e,t)=>e.localeCompare(t))}function XC(e){return e.endsWith(`/`)?e:e+`/`}function ZC(e){return e.startsWith(`/`)?e.slice(1):e}function QC(e,t){return new URL(ZC(t),XC(e.toString())).toString()}function $C(e,t){return QC(e,t).toString().replace(`http://`,`ws://`).replace(`https://`,`wss://`)}function ew(e){return typeof e==`object`&&!Array.isArray(e)&&!(e instanceof URLSearchParams)&&(e=Object.fromEntries(Object.entries(e).filter(e=>e[1]!==void 0))),new URLSearchParams(e).toString()}function tw(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 nw(e,t){if(e?.meta?.profile?.includes(t)){let n=e.meta.profile.indexOf(t);e.meta.profile.splice(n,1)}return e}var rw=Object.freeze([]);function iw(e){if(!e)return``;switch(e.type){case`Address`:return ow(e.value);case`CodeableConcept`:return bw(e.value);case`Coding`:return xw(e.value);case`ContactPoint`:return e.value.value;case`HumanName`:return sw(e.value);case`Quantity`:return vw(e.value);case`Reference`:return aw(e.value);default:return e.value?.toString()??``}}function aw(e){return e?e.display??e.reference??_C(e):``}function ow(e,t){if(!e)return``;let n=[];if(e.line&&n.push(...e.line),e.city||e.state||e.postalCode){let t=[];e.city&&t.push(e.city),e.state&&t.push(e.state),e.postalCode&&t.push(e.postalCode),n.push(t.join(`, `))}return e.use&&(t?.all||t?.use)&&n.push(`[`+e.use+`]`),n.join(t?.lineSeparator??`, `).trim()}function sw(e,t){if(!e)return``;let 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){let t=Cw(e.text);if(t)return t}return n.join(` `).trim()}function cw(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function lw(e,t,n){if(!e)return``;let[r=0,i=0,a=0]=e.split(`:`).map(Number),o=new Date(Date.UTC(1970,0,1,r,i,a));return cw(o)?new Intl.DateTimeFormat(t,{hour:`numeric`,minute:`2-digit`,second:a===0?void 0:`numeric`,...n,timeZone:`UTC`}).format(o):``}function uw(e,t,n){if(!e)return``;let r=new Date(e);return cw(r)?r.toLocaleString(t,n):``}function dw(e,t,n){return!e||!e.start&&!e.end?``:uw(e.start,t,n)+` - `+uw(e.end,t,n)}var fw={s:`every second`,min:`every minute`,h:`hourly`,d:`daily`,wk:`weekly`,mo:`monthly`,a:`annually`},pw={s:`second`,min:`minute`,h:`hour`,d:`day`,wk:`week`,mo:`month`,a:`year`},mw={s:`seconds`,min:`minutes`,h:`hours`,d:`days`,wk:`weeks`,mo:`months`,a:`years`};function hw(e){if(!e)return``;let t=[];return gw(t,e.repeat),e.event&&t.push(e.event.map(e=>uw(e)).join(`, `)),VC(t.join(` `).trim())}function gw(e,t){if(!t?.periodUnit)return;let n=t.frequency??1,r=t.period??1,i=t.periodUnit;n===1&&r===1?e.push(fw[i]):(n===1?e.push(`once`):e.push(n+` times`),r===1?e.push(`per `+pw[i]):e.push(`per `+r+` `+mw[i])),t.dayOfWeek&&e.push(`on `+t.dayOfWeek.map(VC).join(`, `)),t.timeOfDay&&e.push(`at `+t.timeOfDay.map(e=>lw(e)).join(`, `))}function _w(e,t,n=!1){if(n&&t===void 0)throw Error(`Precision must be specified for exclusive ranges`);let r=e?.low&&{...e.low,comparator:void 0},i=e?.high&&{...e.high,comparator:void 0};return r?.value===void 0&&i?.value===void 0?``:r?.value!==void 0&&i?.value===void 0?n&&t!==void 0?(r.value=Tw(r.value,t),`> ${vw(r,t)}`):`>= ${vw(r,t)}`:r?.value===void 0&&i?.value!==void 0?n&&t!==void 0?(i.value=ww(i.value,t),`< ${vw(i,t)}`):`<= ${vw(i,t)}`:(r?.unit===i?.unit&&delete r?.unit,`${vw(r,t)} - ${vw(i,t)}`)}function vw(e,t){if(!e)return``;let n=[];return e.comparator&&(n.push(e.comparator),n.push(` `)),e.value!==void 0&&(t===void 0?n.push(e.value):n.push(e.value.toFixed(t))),e.unit&&(e.unit!==`%`&&n.at(-1)!==` `&&n.push(` `),n.push(e.unit)),n.join(``).trim()}function yw(e){return e?.value===void 0?``:e.value.toLocaleString(void 0,{style:`currency`,currency:e.currency??`USD`,currencyDisplay:`narrowSymbol`})}function bw(e){return e?Cw(e.text)||(e.coding?e.coding.map(e=>xw(e)).join(`, `):``):``}function xw(e,t){let n=Cw(e?.display);if(n){let r=t?Cw(e?.code):void 0;return`${n}${r?` (`+r+`)`:``}`}return Cw(e?.code)??``}function Sw(e){if(!e)return``;let t=[];if(e.valueQuantity)t.push(vw(e.valueQuantity));else if(e.valueCodeableConcept)t.push(bw(e.valueCodeableConcept));else{let n=Cw(e.valueString);n&&t.push(n)}return`component`in e&&t.push(e.component.map(e=>Sw(e)).join(` / `)),t.join(` / `).trim()}function Cw(e){return typeof e==`string`?e:void 0}function ww(e,t,n=1){return(Ew(e,t)+n)*10**-t}function Tw(e,t,n=1){return(Ew(e,t)-n)*10**-t}function Ew(e,t){return t===void 0?e:Math.round(e*10**t)}var X={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`,Element:`Element`,ElementDefinition:`ElementDefinition`,Expression:`Expression`,Extension:`Extension`,HumanName:`HumanName`,Identifier:`Identifier`,MarketingStatus:`MarketingStatus`,Meta:`Meta`,Money:`Money`,MoneyQuantity:`MoneyQuantity`,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`,SimpleQuantity:`SimpleQuantity`,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`,xhtml:`xhtml`};function Dw(e){let t=Array.isArray(e)?e:e.entry?.map(e=>e.resource)??[];for(let e of t)e?.resourceType===`StructureDefinition`&&e.kind===`resource`&&Ow(e.type)}function Ow(e){let t=Hw.types[e];return t||(t={searchParamsDetails:{}},Hw.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`},_project:{base:[e],code:`_project`,type:`token`,expression:e+`.meta.project`}}),t}function kw(e){for(let t of e.base??rw){let n=Ow(t);n.searchParams||={},n.searchParams[e.code]=e}}function Aw(e){let t=e.type?.[0]?.code;return t===`BackboneElement`||t===`Element`?jw((e.base?.path??e.path)?.split(`.`)):t}function jw(e){return e.length===1?e[0]:e.map(VC).join(``)}function Mw(e){return Hw.types[e]?.searchParams}function Nw(e,t){return Hw.types[e]?.searchParams?.[t]}function Pw(e){return Fw(e.replaceAll(`[x]`,``).split(`.`).pop())}function Fw(e){let t;return t=e.length<100?e.match(/[A-Z]+(?![a-z])|[A-Z]?[a-z]+|\d+/g)??[]:e.split(/(?=[A-Z])/),t.map(Lw).join(` `).replace(`_`,` `).replaceAll(/\s+/g,` `)}var Iw=new Set([`CDS`,`ID`,`IP`,`PKCE`,`JWKS`,`URI`,`URL`,`OMB`,`UDI`]);function Lw(e){let t=e.toUpperCase();return e===t?e:Iw.has(t)?t:t.charAt(0)+e.slice(1)}function Rw(e,t,n){let r=fS(e,n);if(r)return zw(r.elements,t)}function zw(e,t){let n=e[t]??e[t+`[x]`];if(n)return n;for(let n=0;n<t.length;n++){let r=t[n];if(r>=`A`&&r<=`Z`){let r=e[t.slice(0,n)+`[x]`];if(r)return r}}}function Bw(e,t){return!(!e||typeof e!=`object`||!(`resourceType`in e)||t&&e.resourceType!==t)}function Vw(e,t){return e&&typeof e==`object`&&`reference`in e&&typeof e.reference==`string`?t?e.reference.match(RegExp(`^${t}(/|\\?)`))!==null:!0:!1}var Hw={types:{}};function Uw(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}}var Ww=()=>[],Gw={empty:(e,t)=>kS(t.every(e=>xC(e.value))),hasValue:(e,t)=>kS(t.length!==0),exists:(e,t,n)=>kS(n?t.some(t=>jS(n.eval(e,[t]))):t.length>0&&t.every(e=>!xC(e.value))),all:(e,t,n)=>kS(t.every(t=>jS(n.eval(e,[t])))),allTrue:(e,t)=>{for(let e of t)if(!e.value)return kS(!1);return kS(!0)},anyTrue:(e,t)=>{for(let e of t)if(e.value)return kS(!0);return kS(!1)},allFalse:(e,t)=>{for(let e of t)if(e.value)return kS(!1);return kS(!0)},anyFalse:(e,t)=>{for(let e of t)if(!e.value)return kS(!0);return kS(!1)},subsetOf:(e,t,n)=>{if(t.length===0)return kS(!0);let r=n.eval(e,Yw(e));return r.length===0?kS(!1):kS(t.every(e=>r.some(t=>t.value===e.value)))},supersetOf:(e,t,n)=>{let r=n.eval(e,Yw(e));return r.length===0?kS(!0):t.length===0?kS(!1):kS(r.every(e=>t.some(t=>t.value===e.value)))},count:(e,t)=>[{type:X.integer,value:t.length}],distinct:(e,t)=>{let n=[];for(let e of t)n.some(t=>t.value===e.value)||n.push(e);return n},isDistinct:(e,t)=>kS(t.length===Gw.distinct(e,t).length),where:(e,t,n)=>t.filter(t=>jS(n.eval(e,[t]))),select:(e,t,n)=>t.flatMap(t=>n.eval({parent:e,variables:{$this:t}},[t])),repeat:Ww,ofType:(e,t,n)=>t.filter(e=>e.type===n.name),single:(e,t)=>{if(t.length>1)throw 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(-1,t.length),tail:(e,t)=>t.length===0?[]:t.slice(1,t.length),skip:(e,t,n)=>{let r=n.eval(e,t)[0]?.value;if(typeof r!=`number`)throw TypeError(`Expected a number for skip(num)`);return r>=t.length?[]:r<=0?t:t.slice(r,t.length)},take:(e,t,n)=>{let r=n.eval(e,t)[0]?.value;if(typeof r!=`number`)throw TypeError(`Expected a number for take(num)`);return r<=0?[]:t.slice(0,r)},intersect:(e,t,n)=>{if(!n)return t;let r=n.eval(e,Yw(e)),i=[];for(let e of t)!i.some(t=>t.value===e.value)&&r.some(t=>t.value===e.value)&&i.push(e);return i},exclude:(e,t,n)=>{if(!n)return t;let r=n.eval(e,Yw(e)),i=[];for(let e of t)r.some(t=>t.value===e.value)||i.push(e);return i},union:(e,t,n)=>{if(!n)return t;let r=n.eval(e,Yw(e));return LS([...t,...r])},combine:(e,t,n)=>{if(!n)return t;let r=n.eval(e,Yw(e));return[...t,...r]},htmlChecks:(e,t,n)=>[AS(!0)],iif:(e,t,n,r,i)=>{let a=n.eval(e,t);if(a.length>1||a.length===1&&typeof a[0].value!=`boolean`)throw Error(`Expected criterion to evaluate to a Boolean`);return jS(a)?r.eval(e,t):i?i.eval(e,t):[]},toBoolean:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);if(typeof n==`boolean`)return[{type:X.boolean,value:n}];if(typeof n==`number`&&(n===0||n===1))return kS(!!n);if(typeof n==`string`){let e=n.toLowerCase();if([`true`,`t`,`yes`,`y`,`1`,`1.0`].includes(e))return kS(!0);if([`false`,`f`,`no`,`n`,`0`,`0.0`].includes(e))return kS(!1)}return[]},convertsToBoolean:(e,t)=>t.length===0?[]:kS(Gw.toBoolean(e,t).length===1),toInteger:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);return typeof n==`number`?[{type:X.integer,value:n}]:typeof n==`string`&&/^[+-]?\d+$/.exec(n)?[{type:X.integer,value:Number.parseInt(n,10)}]:typeof n==`boolean`?[{type:X.integer,value:+!!n}]:[]},convertsToInteger:(e,t)=>t.length===0?[]:kS(Gw.toInteger(e,t).length===1),toDate:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);return typeof n==`string`&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:X.date,value:Uw(n)}]:[]},convertsToDate:(e,t)=>t.length===0?[]:kS(Gw.toDate(e,t).length===1),toDateTime:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);return typeof n==`string`&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:X.dateTime,value:Uw(n)}]:[]},convertsToDateTime:(e,t)=>t.length===0?[]:kS(Gw.toDateTime(e,t).length===1),toDecimal:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);return typeof n==`number`?[{type:X.decimal,value:n}]:typeof n==`string`&&/^-?\d{1,9}(\.\d{1,9})?$/.exec(n)?[{type:X.decimal,value:Number.parseFloat(n)}]:typeof n==`boolean`?[{type:X.decimal,value:+!!n}]:[]},convertsToDecimal:(e,t)=>t.length===0?[]:kS(Gw.toDecimal(e,t).length===1),toQuantity:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);return ZS(n)?[{type:X.Quantity,value:n}]:typeof n==`number`?[{type:X.Quantity,value:{value:n,unit:`1`}}]:typeof n==`string`&&/^-?\d{1,9}(\.\d{1,9})?/.exec(n)?[{type:X.Quantity,value:{value:Number.parseFloat(n),unit:`1`}}]:typeof n==`boolean`?[{type:X.Quantity,value:{value:+!!n,unit:`1`}}]:[]},convertsToQuantity:(e,t)=>t.length===0?[]:kS(Gw.toQuantity(e,t).length===1),toString:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);return n==null?[]:ZS(n)?[{type:X.string,value:`${n.value} '${n.unit}'`}]:[{type:X.string,value:n.toString()}]},convertsToString:(e,t)=>t.length===0?[]:kS(Gw.toString(e,t).length===1),toTime:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);if(typeof n==`string`){let e=/^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(n);if(e)return[{type:X.time,value:Uw(`T`+e[1])}]}return[]},convertsToTime:(e,t)=>t.length===0?[]:kS(Gw.toTime(e,t).length===1),indexOf:(e,t,n)=>Kw((e,t)=>e.indexOf(t),e,t,n),substring:(e,t,n,r)=>Kw((e,t,n)=>{let r=t,i=n?r+n:e.length;return r<0||r>=e.length?void 0:e.substring(r,i)},e,t,n,r),startsWith:(e,t,n)=>Kw((e,t)=>e.startsWith(t),e,t,n),endsWith:(e,t,n)=>Kw((e,t)=>e.endsWith(t),e,t,n),contains:(e,t,n)=>Kw((e,t)=>e.includes(t),e,t,n),upper:(e,t)=>Kw(e=>e.toUpperCase(),e,t),lower:(e,t)=>Kw(e=>e.toLowerCase(),e,t),replace:(e,t,n,r)=>Kw((e,t,n)=>e.replaceAll(t,n),e,t,n,r),matches:(e,t,n)=>Kw((e,t)=>!!new RegExp(t).exec(e),e,t,n),replaceMatches:(e,t,n,r)=>Kw((e,t,n)=>e.replaceAll(new RegExp(t,`g`),n.replaceAll(/\$\{(\w+)\}/g,`$<$1>`)),e,t,n,r),length:(e,t)=>Kw(e=>e.length,e,t),toChars:(e,t)=>Kw(e=>e?e.split(``):void 0,e,t),encode:Ww,decode:Ww,escape:Ww,unescape:Ww,trim:Ww,split:Ww,join:(e,t,n)=>{let r=n?.eval(e,Yw(e))[0]?.value??``;if(typeof r!=`string`)throw TypeError(`Separator must be a string.`);return[{type:X.string,value:t.map(e=>e.value?.toString()??``).join(r)}]},abs:(e,t)=>qw(Math.abs,e,t),ceiling:(e,t)=>qw(Math.ceil,e,t),exp:(e,t)=>qw(Math.exp,e,t),floor:(e,t)=>qw(Math.floor,e,t),ln:(e,t)=>qw(Math.log,e,t),log:(e,t,n)=>qw((e,t)=>Math.log(e)/Math.log(t),e,t,n),power:(e,t,n)=>qw(Math.pow,e,t,n),round:(e,t,...n)=>qw((e,t=0)=>{if(typeof t!=`number`||t<0)throw Error(`Invalid precision provided to round()`);let n=10**t;return Math.round(e*n)/n},e,t,...n),sqrt:(e,t)=>qw(Math.sqrt,e,t),truncate:(e,t)=>qw(e=>Math.trunc(e),e,t),children:Ww,descendants:Ww,trace:(e,t,n)=>t,now:()=>[{type:X.dateTime,value:new Date().toISOString()}],timeOfDay:()=>[{type:X.time,value:new Date().toISOString().substring(11)}],today:()=>[{type:X.date,value:new Date().toISOString().substring(0,10)}],between:(e,t,n,r,i)=>{let a=Gw.toDateTime(e,n.eval(e,t));if(a.length===0)throw Error(`Invalid start date`);let o=Gw.toDateTime(e,r.eval(e,t));if(o.length===0)throw Error(`Invalid end date`);let s=i.eval(e,t)[0]?.value;if(s!==`years`&&s!==`months`&&s!==`days`)throw Error(`Invalid units`);let c=mC(a[0].value,o[0].value);return[{type:X.Quantity,value:{value:c[s],unit:s}}]},is:(e,t,n)=>{let r=``;return n instanceof Qw?r=n.name:n instanceof sT&&(r=n.left.name+`.`+n.right.name),r?t.map(e=>({type:X.boolean,value:GS(e,r)})):[]},not:(e,t)=>Gw.toBoolean(e,t).map(e=>({type:X.boolean,value:!e.value})),resolve:(e,t)=>t.map(e=>{let t=e.value,n;if(typeof t==`string`)n=t;else if(typeof t==`object`){let e=t;if(e.resource)return AS(e.resource);e.reference?n=e.reference:e.type&&e.identifier&&(n=`${e.type}?identifier=${e.identifier.system}|${e.identifier.value}`)}if(n?.includes(`?`)){let[e]=n.split(`?`);return{type:e,value:{resourceType:e}}}if(n?.includes(`/`)){let[e,t]=n.split(`/`);return{type:e,value:{resourceType:e,id:t}}}return{type:X.BackboneElement,value:void 0}}).filter(e=>!!e.value),as:(e,t,n)=>{let r=n.name,i=MS(t,r);return i?[i]:[]},type:(e,t)=>t.map(({value:e})=>typeof e==`boolean`?{type:X.BackboneElement,value:{namespace:`System`,name:`Boolean`}}:typeof e==`number`?{type:X.BackboneElement,value:{namespace:`System`,name:`Integer`}}:Bw(e)?{type:X.BackboneElement,value:{namespace:`FHIR`,name:e.resourceType}}:{type:X.BackboneElement,value:null}),conformsTo:(e,t,n)=>{let r=n.eval(e,t)[0].value;if(!r.startsWith(`http://hl7.org/fhir/StructureDefinition/`))throw Error(`Expected a StructureDefinition URL`);let i=r.replace(`http://hl7.org/fhir/StructureDefinition/`,``);return t.map(e=>({type:X.boolean,value:e.value?.resourceType===i}))},getResourceKey:(e,t)=>{let n=t[0].value;return n?.id?[{type:X.id,value:n.id}]:[]},getReferenceKey:(e,t,n)=>{let r=t[0].value;if(!r?.reference)return[];let i=``;return n instanceof Qw&&(i=n.name),i&&!r.reference.startsWith(i+`/`)?[]:[{type:X.id,value:oC(r)}]},extension:(e,t,n)=>{let r=n.eval(e,t)[0].value,i=t?.[0]?.value;if(i){let e=gC(i,r);if(e)return[{type:X.Extension,value:e}]}return[]}};function Kw(e,t,n,...r){if(n.length===0)return[];let[{value:i}]=Jw(n,1);if(typeof i!=`string`)throw TypeError(`String function cannot be called with non-string`);let a=e(i,...r.map(e=>e?.eval(t,n)[0]?.value));return a===void 0?[]:Array.isArray(a)?a.map(AS):[AS(a)]}function qw(e,t,n,...r){if(n.length===0)return[];let[{value:i}]=Jw(n,1),a=ZS(i),o=a?i.value:i;if(typeof o!=`number`)throw TypeError(`Math function cannot be called with non-number`);let s=e(o,...r.map(e=>e.eval(t,n)[0]?.value));return[{type:a?X.Quantity:n[0].type,value:a?{...i,value:s}:s}]}function Jw(e,t){if(e.length!==t)throw Error(`Expected ${t} arguments`);for(let t of e)if(t==null)throw Error(`Expected non-null argument`);return e}function Yw(e){let t=e;for(;t.parent?.variables.$this;)t=t.parent;return[t.variables.$this]}var Xw=class{original;child;constructor(e,t){this.original=e,this.child=t}eval(e,t){try{if(t.length>0){let n=[];for(let r of t)n.push(this.child.eval({parent:e,variables:{$this:r}},[r]));return n.flat()}else return this.child.eval(e,[])}catch(e){throw Error(`FhirPathError on "${this.original}": ${e}`,{cause:e})}}toString(){return this.child.toString()}},Zw=class{value;constructor(e){this.value=e}eval(){return[this.value]}toString(){let e=this.value.value;return typeof e==`string`?`'${e}'`:e.toString()}},Qw=class{name;constructor(e){this.name=e}eval(e,t){if(this.name===`$this`)return t;let n=this.getVariable(e);if(n)return[n];if(this.name.startsWith(`%`))throw Error(`Undefined variable ${this.name}`);return t.flatMap(e=>this.evalValue(e)).filter(e=>e?.value!==void 0)}getVariable(e){let t=e.variables[this.name];if(t!==void 0)return t;if(e.parent)return this.getVariable(e.parent)}evalValue(e){let t=e.value;if(!(!t||typeof t!=`object`))return Bw(t,this.name)?e:TS(e,this.name)}toString(){return this.name}},$w=class{eval(){return[]}toString(){return`{}`}},eT=class extends Sx{impl;constructor(e,t,n){super(e,t),this.impl=n}eval(e,t){return this.impl(this.child.eval(e,t))}toString(){return this.operator+this.child.toString()}},tT=class extends Cx{constructor(e,t){super(`as`,e,t)}eval(e,t){return Gw.as(e,this.left.eval(e,t),this.right)}},nT=class extends Cx{impl;constructor(e,t,n,r){super(e,t,n),this.impl=r}eval(e,t){let n=this.left.eval(e,t),r=this.right.eval(e,t);if(n.length<1||r.length<1)return[];let i=MS(n)?.value,a=MS(r)?.value,o=ZS(i)?i.value:i,s=ZS(a)?a.value:a,c=this.impl(o,s);return typeof c==`boolean`?kS(c):ZS(i)?[{type:X.Quantity,value:{...i,value:c}}]:[AS(c)]}},rT=Object.freeze({type:`string`,value:``}),iT=class extends Cx{constructor(e,t){super(`&`,e,t)}eval(e,t){let n=MS(this.left.eval(e,t))??rT,r=MS(this.right.eval(e,t))??rT;if(typeof n.value!=`string`)throw Error(`Expected string operand for &, but got ${n.type}`);if(typeof r.value!=`string`)throw Error(`Expected string operand for &, but got ${r.type}`);return[{type:X.string,value:n.value+r.value}]}},aT=class extends Cx{constructor(e,t){super(`contains`,e,t)}eval(e,t){let n=this.left.eval(e,t),r=this.right.eval(e,t);return kS(n.some(e=>e.value===r[0].value))}},oT=class extends Cx{constructor(e,t){super(`in`,e,t)}eval(e,t){let n=MS(this.left.eval(e,t)),r=this.right.eval(e,t);return n?kS(r.some(e=>VS(n,e)[0].value)):[]}},sT=class extends Cx{constructor(e,t){super(`.`,e,t)}eval(e,t){return this.right.eval(e,this.left.eval(e,t))}toString(){return`${this.left.toString()}.${this.right.toString()}`}},cT=class extends Cx{constructor(e,t){super(`|`,e,t)}eval(e,t){let n=this.left.eval(e,t),r=this.right.eval(e,t);return LS([...n,...r])}},lT=class extends Cx{constructor(e,t){super(`=`,e,t)}eval(e,t){return zS(this.left.eval(e,t),this.right.eval(e,t))}},uT=class extends Cx{constructor(e,t){super(`!=`,e,t)}eval(e,t){return BS(this.left.eval(e,t),this.right.eval(e,t))}},dT=class extends Cx{constructor(e,t){super(`~`,e,t)}eval(e,t){return HS(this.left.eval(e,t),this.right.eval(e,t))}},fT=class extends Cx{constructor(e,t){super(`!~`,e,t)}eval(e,t){return RS(HS(this.left.eval(e,t),this.right.eval(e,t)))}},pT=class extends Cx{constructor(e,t){super(`is`,e,t)}eval(e,t){let n=this.left.eval(e,t);if(n.length!==1)return[];let r=this.right.name;return kS(GS(n[0],r))}},mT=class extends Cx{constructor(e,t){super(`and`,e,t)}eval(e,t){let n=MS(this.left.eval(e,t),`boolean`),r=MS(this.right.eval(e,t),`boolean`);return n?.value===!0&&r?.value===!0?kS(!0):n?.value===!1||r?.value===!1?kS(!1):[]}},hT=class extends Cx{constructor(e,t){super(`or`,e,t)}eval(e,t){let n=MS(this.left.eval(e,t),`boolean`),r=MS(this.right.eval(e,t),`boolean`);return n?.value===!1&&r?.value===!1?kS(!1):n?.value||r?.value?kS(!0):[]}},gT=class extends Cx{constructor(e,t){super(`xor`,e,t)}eval(e,t){let n=MS(this.left.eval(e,t),`boolean`),r=MS(this.right.eval(e,t),`boolean`);return!n||!r?[]:kS(n.value!==r.value)}},_T=class extends Cx{constructor(e,t){super(`implies`,e,t)}eval(e,t){let n=MS(this.left.eval(e,t),`boolean`),r=MS(this.right.eval(e,t),`boolean`);return r?.value===!0||n?.value===!1?kS(!0):!n||!r?[]:kS(!1)}},vT=class{name;args;constructor(e,t){this.name=e,this.args=t}eval(e,t){let n=Gw[this.name];if(!n)throw Error(`Unrecognized function: `+this.name);return n(e,t,...this.args)}toString(){return`${this.name}(${this.args.map(e=>e.toString()).join(`, `)})`}},yT=class{left;expr;constructor(e,t){this.left=e,this.expr=t}eval(e,t){let n=this.expr.eval(e,t);if(n.length!==1)return[];let r=n[0].value;if(typeof r!=`number`)throw Error(`Invalid indexer expression: should return integer}`);let i=this.left.eval(e,t);return r in i?[i[r]]:[]}toString(){return`${this.left.toString()}[${this.expr.toString()}]`}},bT=[`year`,`years`,`month`,`months`,`week`,`weeks`,`day`,`days`,`hour`,`hours`,`minute`,`minutes`,`second`,`seconds`,`millisecond`,`milliseconds`],xT={"'":`'`,'"':`"`,"`":"`",r:`\r`,n:`
53
+ `),a=!1),Object.assign(Object.assign({},e),{allowNegative:a})}function __(e){e=g_(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,n=e.allowNegative,r=e.allowLeadingZeros,i=e.onKeyDown;i===void 0&&(i=Mg);var a=e.onBlur;a===void 0&&(a=Mg);var o=e.thousandSeparator,s=e.decimalScale,c=e.fixedDecimalScale,l=e.prefix;l===void 0&&(l=``);var u=e.defaultValue,d=e.value,f=e.valueIsNumericString,p=e.onValueChange,m=Ag(e,[`decimalSeparator`,`allowedDecimalSeparators`,`thousandsGroupStyle`,`suffix`,`allowNegative`,`allowLeadingZeros`,`onKeyDown`,`onBlur`,`thousandSeparator`,`decimalScale`,`fixedDecimalScale`,`prefix`,`defaultValue`,`value`,`valueIsNumericString`,`onValueChange`]),h=u_(e),g=h.decimalSeparator,_=h.allowedDecimalSeparators,v=function(t){return l_(t,e)},y=function(t,n){return m_(t,n,e)},b=Fg(d)?u:d,x=f??p_(b,l,t);Fg(d)?Fg(u)||(x||=typeof u==`number`):x||=typeof d==`number`;var S=function(e){return Lg(e)?e:(typeof e==`number`&&(e=Kg(e)),x&&typeof s==`number`?qg(e,s,!!c):e)},C=a_(S(d),S(u),!!x,v,y,p),w=C[0],T=w.numAsString,E=w.formattedValue,D=C[1];return Object.assign(Object.assign({},m),{value:E,valueIsNumericString:!1,isValidInputCharacter:function(e){return e===g?!0:Pg(e)},isCharacterSame:function(e){var t=e.currentValue,n=e.lastValue,r=e.formattedValue,i=e.currentValueIndex,a=e.formattedValueIndex,o=t[i],u=r[a],f=Yg(n,t).to,p=function(e){return y(e).indexOf(`.`)+l.length};return d===0&&c&&s&&t[f.start]===g&&p(t)<i&&p(r)>a?!1:i>=f.start&&i<f.end&&_&&_.includes(o)&&u===g?!0:o===u},onValueChange:D,format:v,removeFormatting:y,getCaretBoundary:function(t){return h_(t,e)},onKeyDown:function(e){var t=e.target,r=e.key,a=t.selectionStart,u=t.selectionEnd,d=t.value;if(d===void 0&&(d=``),(r===`Backspace`||r===`Delete`)&&u<l.length&&d!==`-`){e.preventDefault();return}if(a!==u){i(e);return}r===`Backspace`&&d[0]===`-`&&a===l.length+1&&n&&Jg(t,1),s&&c&&(r===`Backspace`&&d[a-1]===g?(Jg(t,a-1),e.preventDefault()):r===`Delete`&&d[a]===g&&e.preventDefault()),_?.includes(r)&&d[a]===g&&Jg(t,a+1);var f=o===!0?`,`:o;r===`Backspace`&&d[a-1]===f&&Jg(t,a-1),r===`Delete`&&d[a]===f&&Jg(t,a+1),i(e)},onBlur:function(t){var n=T;n.match(/\d/g)||(n=``),r||(n=Ug(n)),c&&s&&(n=qg(n,s,c)),n!==T&&D({formattedValue:l_(n,e),value:n,floatValue:parseFloat(n)},{event:t,source:jg.event}),a(t)}})}function v_(e){var t=__(e);return b.createElement(c_,Object.assign({},t))}var y_={root:`m_e2f5cd4e`,controls:`m_95e17d22`,control:`m_80b4b171`};function b_({direction:e,style:t,...n}){return(0,L.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:(0,L.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 x_=/^(0\.0*|-0(\.0*)?)$/,S_=/^-?0\d+(\.\d+)?\.?$/,C_=/\.\d*0$/,w_=/^-?\d+\.$/;function T_(e){return typeof e==`string`&&e!==``&&!Number.isNaN(Number(e))}function E_(e){return typeof e==`number`?e<2**53-1:e===``||T_(e)&&Number(e)<2**53-1}function D_(e){return e.toString().replace(`.`,``).length}function O_(e,t){return(typeof e==`number`?e<2**53-1:!Number.isNaN(Number(e)))&&!Number.isNaN(e)&&D_(t)<14&&t!==``}function k_(e,t,n){return e===void 0?!0:(t===void 0||e>=t)&&(n===void 0||e<=n)}var A_={step:1,clampBehavior:`blur`,allowDecimal:!0,allowNegative:!0,withKeyboardEvents:!0,allowLeadingZeros:!0,trimLeadingZeroesOnBlur:!0,startValue:0,allowedDecimalSeparators:[`.`,`,`]},j_=kn((e,{size:t})=>({controls:{"--ni-chevron-size":dt(t,`ni-chevron-size`)}}));function M_(e,t,n){let r=e.toString(),i=w_.test(r),a=r.replace(/^0+(?=\d)/,``),o=parseFloat(a);if(Number.isNaN(o))return a;if(o>2**53-1)return t===void 0?a:t;let s=St(o,n,t);return i?`${s.toString().replace(/^0+(?=\d)/,``)}.`:s}var N_=V((e,t)=>{let n=z(`NumberInput`,A_,e),{className:r,classNames:i,styles:a,unstyled:o,vars:s,onChange:c,onValueChange:l,value:u,defaultValue:d,max:f,min:p,step:m,hideControls:h,rightSection:g,isAllowed:_,clampBehavior:v,onBlur:y,allowDecimal:x,decimalScale:S,onKeyDown:C,onKeyDownCapture:w,handlersRef:T,startValue:E,disabled:D,rightSectionPointerEvents:O,allowNegative:k,readOnly:A,size:j,rightSectionWidth:M,stepHoldInterval:N,stepHoldDelay:P,allowLeadingZeros:F,withKeyboardEvents:ee,trimLeadingZeroesOnBlur:te,allowedDecimalSeparators:ne,attributes:re,...ie}=n,ae=R({name:`NumberInput`,classes:y_,props:n,classNames:i,styles:a,unstyled:o,attributes:re,vars:s,varsResolver:j_}),{resolvedClassNames:oe,resolvedStyles:se}=Hr({classNames:i,styles:a,props:n}),[ce,le]=rn({value:u,defaultValue:d,finalValue:``,onChange:c}),ue=P!==void 0&&N!==void 0,de=(0,b.useRef)(null),fe=(0,b.useRef)(null),pe=(0,b.useRef)(0),me=(e,t)=>{t.source===`event`&&le(O_(e.floatValue,e.value)&&!x_.test(e.value)&&!(F&&S_.test(e.value))&&!C_.test(e.value)&&!w_.test(e.value)?e.floatValue:e.value),l?.(e,t)},he=e=>{let t=String(e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0},ge=e=>{de.current&&e!==void 0&&de.current.setSelectionRange(e,e)},_e=(0,b.useRef)(lt);_e.current=()=>{if(!E_(ce))return;let e,t=he(ce),n=he(m),r=Math.max(t,n),i=10**r;if(!T_(ce)&&(typeof ce!=`number`||Number.isNaN(ce)))e=St(E,p,f);else if(f!==void 0){let t=(Math.round(Number(ce)*i)+Math.round(m*i))/i;e=t<=f?t:f}else e=(Math.round(Number(ce)*i)+Math.round(m*i))/i;let a=e.toFixed(r);le(parseFloat(a)),l?.({floatValue:parseFloat(a),formattedValue:a,value:a},{source:`increment`}),setTimeout(()=>ge(de.current?.value.length),0)};let ve=(0,b.useRef)(lt);ve.current=()=>{if(!E_(ce))return;let e,t=p===void 0?k?-(2**53-1):0:p,n=he(ce),r=he(m),i=Math.max(n,r),a=10**i;if(!T_(ce)&&typeof ce!=`number`||Number.isNaN(ce))e=St(E,t,f);else{let n=(Math.round(Number(ce)*a)-Math.round(m*a))/a;e=t!==void 0&&n<t?t:n}let o=e.toFixed(i);le(parseFloat(o)),l?.({floatValue:parseFloat(o),formattedValue:o,value:o},{source:`decrement`}),setTimeout(()=>ge(de.current?.value.length),0)};let ye=e=>{let t=e.clipboardData.getData(`text`),n=ie.decimalSeparator||`.`,r=(ne||[`.`,`,`]).filter(e=>e!==n);if(r.some(e=>t.includes(e))){e.preventDefault();let i=t;r.forEach(e=>{i=i.split(e).join(n)});let a=de.current;if(a){let e=a.selectionStart??0,t=a.selectionEnd??0,n=a.value,r=n.substring(0,e)+i+n.substring(t);(Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,`value`)?.set)?.call(a,r),a.dispatchEvent(new Event(`change`,{bubbles:!0}));let o=e+i.length;setTimeout(()=>ge(o),0)}}ie.onPaste?.(e)},be=e=>{C?.(e),!(A||!ee)&&(e.key===`ArrowUp`&&(e.preventDefault(),_e.current?.()),e.key===`ArrowDown`&&(e.preventDefault(),ve.current?.()))},xe=e=>{if(w?.(e),e.key===`Backspace`){let t=de.current;t&&t.selectionStart===0&&t.selectionStart===t.selectionEnd&&(e.preventDefault(),window.setTimeout(()=>ge(0),0))}},Se=e=>{let t=ce;v===`blur`&&typeof t==`number`&&(t=St(t,p,f)),te&&typeof t==`string`&&he(t)<15&&(t=M_(t,f,p)),ce!==t&&le(t),y?.(e)};en(T,{increment:_e.current,decrement:ve.current});let Ce=e=>{e?_e.current?.():ve.current?.(),pe.current+=1},we=e=>{if(Ce(e),ue){let t=typeof N==`number`?N:N(pe.current);fe.current=window.setTimeout(()=>we(e),t)}},Te=(e,t)=>{e.preventDefault(),de.current?.focus(),Ce(t),ue&&(fe.current=window.setTimeout(()=>we(t),P))},Ee=()=>{fe.current&&window.clearTimeout(fe.current),fe.current=null,pe.current=0},De=(0,L.jsxs)(`div`,{...ae(`controls`),children:[(0,L.jsx)(pl,{...ae(`control`),tabIndex:-1,"aria-hidden":!0,disabled:D||typeof ce==`number`&&f!==void 0&&ce>=f,mod:{direction:`up`},onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{Te(e,!0)},onPointerUp:Ee,onPointerLeave:Ee,children:(0,L.jsx)(b_,{direction:`up`})}),(0,L.jsx)(pl,{...ae(`control`),tabIndex:-1,"aria-hidden":!0,disabled:D||typeof ce==`number`&&p!==void 0&&ce<=p,mod:{direction:`down`},onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{Te(e,!1)},onPointerUp:Ee,onPointerLeave:Ee,children:(0,L.jsx)(b_,{direction:`down`})})]});return(0,L.jsx)(pd,{component:v_,allowNegative:k,className:jn(y_.root,r),size:j,inputMode:`decimal`,...ie,readOnly:A,disabled:D,value:ce,getInputRef:nn(t,de),onValueChange:me,rightSection:h||A||!E_(ce)?g:g||De,classNames:oe,styles:se,unstyled:o,__staticSelector:`NumberInput`,decimalScale:x?S:0,onPaste:ye,onKeyDown:be,onKeyDownCapture:xe,rightSectionPointerEvents:O??(D?`none`:void 0),rightSectionWidth:M??`var(--ni-right-section-width-${j||`sm`})`,allowLeadingZeros:F,allowedDecimalSeparators:ne,onBlur:Se,attributes:re,isAllowed:e=>v===`strict`?_?_(e)&&k_(e.floatValue,p,f):k_(e.floatValue,p,f):_?_(e):!0})});N_.classes={...pd.classes,...y_},N_.displayName=`@mantine/core/NumberInput`;var P_={root:`m_4addd315`,control:`m_326d024a`,dots:`m_4ad7767d`},[F_,I_]=$e(`Pagination.Root component was not found in tree`),L_={withPadding:!0},R_=V((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,active:s,disabled:c,withPadding:l,mod:u,...d}=z(`PaginationControl`,L_,e),f=I_(),p=c||f.disabled;return(0,L.jsx)(pl,{ref:t,disabled:p,mod:[{active:s,disabled:p,"with-padding":l},u],...f.getStyles(`control`,{className:r,style:i,classNames:n,styles:a,active:!p}),...d})});R_.classes=P_,R_.displayName=`@mantine/core/PaginationControl`;function z_({style:e,children:t,path:n,...r}){return(0,L.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:(0,L.jsx)(`path`,{d:n,fill:`currentColor`})})}var B_=e=>(0,L.jsx)(z_,{...e,path:`M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z`}),V_=e=>(0,L.jsx)(z_,{...e,path:`M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z`}),H_=e=>(0,L.jsx)(z_,{...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`}),U_=e=>(0,L.jsx)(z_,{...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`}),W_={icon:e=>(0,L.jsx)(z_,{...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`})},G_=V((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,icon:s,...c}=z(`PaginationDots`,W_,e);return(0,L.jsx)(B,{ref:t,...I_().getStyles(`dots`,{className:r,style:i,styles:a,classNames:n}),...c,children:(0,L.jsx)(s,{style:{width:`calc(var(--pagination-control-size) / 1.8)`,height:`calc(var(--pagination-control-size) / 1.8)`}})})});G_.classes=P_,G_.displayName=`@mantine/core/PaginationDots`;function K_({icon:e,name:t,action:n,type:r}){let i={icon:e},a=(0,b.forwardRef)((e,a)=>{let{icon:o,...s}=z(t,i,e),c=I_(),l=r===`next`?c.active===c.total:c.active===1;return(0,L.jsx)(R_,{disabled:c.disabled||l,ref:a,onClick:c[n],withPadding:!1,...s,children:(0,L.jsx)(o,{className:`mantine-rotate-rtl`,style:{width:`calc(var(--pagination-control-size) / 1.8)`,height:`calc(var(--pagination-control-size) / 1.8)`}})})});return a.displayName=`@mantine/core/${t}`,Li(a)}var q_=K_({icon:B_,name:`PaginationNext`,action:`onNext`,type:`next`}),J_=K_({icon:V_,name:`PaginationPrevious`,action:`onPrevious`,type:`previous`}),Y_=K_({icon:H_,name:`PaginationFirst`,action:`onFirst`,type:`previous`}),X_=K_({icon:U_,name:`PaginationLast`,action:`onLast`,type:`next`});function Z_({dotsIcon:e}){let t=I_();return(0,L.jsx)(L.Fragment,{children:t.range.map((n,r)=>n===`dots`?(0,L.jsx)(G_,{icon:e},r):(0,L.jsx)(R_,{active:n===t.active,"aria-current":n===t.active?`page`:void 0,onClick:()=>t.onChange(n),disabled:t.disabled,...t.getItemProps?.(n),children:t.getItemProps?.(n)?.children??n},r))})}Z_.displayName=`@mantine/core/PaginationItems`;var Q_={siblings:1,boundaries:1},$_=kn((e,{size:t,radius:n,color:r,autoContrast:i})=>({root:{"--pagination-control-radius":n===void 0?void 0:pt(n),"--pagination-control-size":dt(t,`pagination-control-size`),"--pagination-control-fz":mt(t),"--pagination-active-bg":r?ir(r,e):void 0,"--pagination-active-color":ai(i,e)?Er({color:r,theme:e,autoContrast:i}):void 0}})),ev=V((e,t)=>{let n=z(`PaginationRoot`,Q_,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,total:l,value:u,defaultValue:d,onChange:f,disabled:p,siblings:m,boundaries:h,color:g,radius:_,onNextPage:v,onPreviousPage:y,onFirstPage:b,onLastPage:x,getItemProps:S,autoContrast:C,attributes:w,...T}=n,E=R({name:`Pagination`,classes:P_,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:w,vars:c,varsResolver:$_}),{range:D,setPage:O,next:k,previous:A,active:j,first:M,last:N}=sn({page:u,initialPage:d,onChange:f,total:l,siblings:m,boundaries:h});return(0,L.jsx)(F_,{value:{total:l,range:D,active:j,disabled:p,getItemProps:S,onChange:O,onNext:_t(v,k),onPrevious:_t(y,A),onFirst:_t(b,M),onLast:_t(x,N),getStyles:E},children:(0,L.jsx)(B,{ref:t,...E(`root`),...T})})});ev.classes=P_,ev.displayName=`@mantine/core/PaginationRoot`;var tv={withControls:!0,withPages:!0,siblings:1,boundaries:1,gap:8},nv=V((e,t)=>{let{withEdges:n,withControls:r,getControlProps:i,nextIcon:a,previousIcon:o,lastIcon:s,firstIcon:c,dotsIcon:l,total:u,gap:d,hideWithOnePage:f,withPages:p,...m}=z(`Pagination`,tv,e);return u<=0||f&&u===1?null:(0,L.jsx)(ev,{ref:t,total:u,...m,children:(0,L.jsxs)(H,{gap:d,children:[n&&(0,L.jsx)(Y_,{icon:c,...i?.(`first`)}),r&&(0,L.jsx)(J_,{icon:o,...i?.(`previous`)}),p&&(0,L.jsx)(Z_,{dotsIcon:l}),r&&(0,L.jsx)(q_,{icon:a,...i?.(`next`)}),n&&(0,L.jsx)(X_,{icon:s,...i?.(`last`)})]})})});nv.classes=P_,nv.displayName=`@mantine/core/Pagination`,nv.Root=ev,nv.Control=R_,nv.Dots=G_,nv.First=Y_,nv.Last=X_,nv.Next=q_,nv.Previous=J_,nv.Items=Z_;var rv={root:`m_f61ca620`,input:`m_ccf8da4c`,innerInput:`m_f2d85dd2`,visibilityToggle:`m_b1072d44`},iv={visibilityToggleIcon:({reveal:e})=>(0,L.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:(0,L.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`})})},av=kn((e,{size:t})=>({root:{"--psi-icon-size":dt(t,`psi-icon-size`),"--psi-button-size":dt(t,`psi-button-size`)}})),ov=V((e,t)=>{let n=z(`PasswordInput`,iv,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,required:l,error:u,leftSection:d,disabled:f,id:p,variant:m,inputContainer:h,description:g,label:_,size:v,errorProps:y,descriptionProps:b,labelProps:x,withAsterisk:S,inputWrapperOrder:C,wrapperProps:w,radius:T,rightSection:E,rightSectionWidth:D,rightSectionPointerEvents:O,leftSectionWidth:k,visible:A,defaultVisible:j,onVisibilityChange:M,visibilityToggleIcon:N,visibilityToggleButtonProps:P,rightSectionProps:F,leftSectionProps:ee,leftSectionPointerEvents:te,withErrorStyles:ne,mod:re,attributes:ie,...ae}=n,oe=Qt(p),[se,ce]=rn({value:A,defaultValue:j,finalValue:!1,onChange:M}),le=()=>ce(!se),ue=R({name:`PasswordInput`,classes:rv,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:ie,vars:c,varsResolver:av}),{resolvedClassNames:de,resolvedStyles:fe}=Hr({classNames:r,styles:o,props:n}),{styleProps:pe,rest:me}=fi(ae),he=y?.id||`${oe}-error`,ge=b?.id||`${oe}-description`,_e=`${u&&typeof u!=`boolean`?he:``} ${g?ge:``}`,ve=_e.trim().length>0?_e.trim():void 0,ye=(0,L.jsx)(hu,{...ue(`visibilityToggle`),disabled:f,radius:T,"aria-hidden":!P,"aria-pressed":se,tabIndex:-1,...P,variant:P?.variant??`subtle`,color:`gray`,unstyled:s,onTouchEnd:e=>{e.preventDefault(),P?.onTouchEnd?.(e),le()},onMouseDown:e=>{e.preventDefault(),P?.onMouseDown?.(e),le()},onKeyDown:e=>{P?.onKeyDown?.(e),e.key===` `&&(e.preventDefault(),le())},children:(0,L.jsx)(N,{reveal:se})});return(0,L.jsx)(ud.Wrapper,{required:l,id:oe,label:_,error:u,description:g,size:v,classNames:de,styles:fe,__staticSelector:`PasswordInput`,__stylesApiProps:n,unstyled:s,withAsterisk:S,inputWrapperOrder:C,inputContainer:h,variant:m,labelProps:{...x,htmlFor:oe},descriptionProps:{...b,id:ge},errorProps:{...y,id:he},mod:re,attributes:ie,...ue(`root`),...pe,...w,children:(0,L.jsx)(ud,{component:`div`,error:u,leftSection:d,size:v,classNames:{...de,input:jn(rv.input,de.input)},styles:fe,radius:T,disabled:f,__staticSelector:`PasswordInput`,__stylesApiProps:n,rightSectionWidth:D,rightSection:E??ye,variant:m,unstyled:s,leftSectionWidth:k,rightSectionPointerEvents:O||`all`,rightSectionProps:F,leftSectionProps:ee,leftSectionPointerEvents:te,withAria:!1,withErrorStyles:ne,attributes:ie,children:(0,L.jsx)(`input`,{required:l,"data-invalid":!!u||void 0,"data-with-left-section":!!d||void 0,...ue(`innerInput`),disabled:f,id:oe,ref:t,...me,"aria-describedby":ve,autoComplete:me.autoComplete||`off`,type:se?`text`:`password`})})})});ov.classes={...pd.classes,...rv},ov.displayName=`@mantine/core/PasswordInput`;var sv={root:`m_db6d6462`,section:`m_2242eb65`,"stripes-animation":`m_81a374bd`,"stripes-animation-vertical":`m_e0fb7a86`,label:`m_91e40b74`},[cv,lv]=$e(`Progress.Root component was not found in tree`),uv=V((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,...s}=z(`ProgressLabel`,null,e);return(0,L.jsx)(B,{ref:t,...lv().getStyles(`label`,{className:r,style:i,classNames:n,styles:a}),...s})});uv.classes=sv,uv.displayName=`@mantine/core/ProgressLabel`;var dv=kn((e,{size:t,radius:n,transitionDuration:r})=>({root:{"--progress-size":dt(t,`progress-size`),"--progress-radius":n===void 0?void 0:pt(n),"--progress-transition-duration":typeof r==`number`?`${r}ms`:void 0}})),fv=V((e,t)=>{let n=z(`ProgressRoot`,null,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,autoContrast:l,transitionDuration:u,orientation:d,attributes:f,mod:p,...m}=n,h=R({name:`Progress`,classes:sv,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:f,vars:c,varsResolver:dv});return(0,L.jsx)(cv,{value:{getStyles:h,autoContrast:l},children:(0,L.jsx)(B,{ref:t,mod:[{orientation:d},p],...h(`root`),...m})})});fv.classes=sv,fv.displayName=`@mantine/core/ProgressRoot`;var pv={withAria:!0},mv=V((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,value:s,withAria:c,color:l,striped:u,animated:d,mod:f,...p}=z(`ProgressSection`,pv,e),m=lv(),h=xr(),g=c?{role:`progressbar`,"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":s,"aria-valuetext":`${s}%`}:{};return(0,L.jsx)(B,{ref:t,...m.getStyles(`section`,{className:r,classNames:n,styles:a,style:i}),...p,...g,mod:[{striped:u||d,animated:d},f],__vars:{"--progress-section-size":`${s}%`,"--progress-section-color":ir(l,h),"--progress-label-color":ai(m.autoContrast,h)?Er({color:l,theme:h,autoContrast:m.autoContrast}):void 0}})});mv.classes=sv,mv.displayName=`@mantine/core/ProgressSection`;var hv=V((e,t)=>{let n=z(`Progress`,null,e),{value:r,classNames:i,styles:a,vars:o,color:s,striped:c,animated:l,"aria-label":u,...d}=n,{resolvedClassNames:f,resolvedStyles:p}=Hr({classNames:i,styles:a,props:n});return(0,L.jsx)(fv,{ref:t,classNames:f,styles:p,vars:o,...d,children:(0,L.jsx)(mv,{value:r,color:s,striped:c,animated:l,"aria-label":u})})});hv.classes=sv,hv.displayName=`@mantine/core/Progress`,hv.Section=mv,hv.Root=fv,hv.Label=uv;var gv={root:`m_f3f1af94`,inner:`m_89c4f5e4`,icon:`m_f3ed6b2b`,radio:`m_8a3dbb89`,"radio--outline":`m_1bfe9d39`},[_v,vv]=et(),[yv,bv]=et(),xv={card:`m_9dc8ae12`},Sv={withBorder:!0},Cv=kn((e,{radius:t})=>({card:{"--card-radius":pt(t)}})),wv=V((e,t)=>{let n=z(`RadioCard`,Sv,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,checked:l,mod:u,withBorder:d,value:f,onClick:p,name:m,onKeyDown:h,attributes:g,..._}=n,v=R({name:`RadioCard`,classes:xv,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:g,vars:c,varsResolver:Cv,rootSelector:`card`}),{dir:y}=Ji(),b=vv(),x=typeof l==`boolean`?l:b?.value===f||!1,S=m||b?.name,C=e=>{if(h?.(e),[`ArrowDown`,`ArrowUp`,`ArrowLeft`,`ArrowRight`].includes(e.nativeEvent.code)){e.preventDefault();let t=Array.from(document.querySelectorAll(`[role="radio"][name="${S||`__mantine`}"]`)),n=t.findIndex(t=>t===e.target),r=n+1>=t.length?0:n+1,i=n-1<0?t.length-1:n-1;e.nativeEvent.code===`ArrowDown`&&(t[r].focus(),t[r].click()),e.nativeEvent.code===`ArrowUp`&&(t[i].focus(),t[i].click()),e.nativeEvent.code===`ArrowLeft`&&(t[y===`ltr`?i:r].focus(),t[y===`ltr`?i:r].click()),e.nativeEvent.code===`ArrowRight`&&(t[y===`ltr`?r:i].focus(),t[y===`ltr`?r:i].click())}};return(0,L.jsx)(yv,{value:{checked:x},children:(0,L.jsx)(pl,{ref:t,mod:[{"with-border":d,checked:x},u],...v(`card`),..._,role:`radio`,"aria-checked":x,name:S,onClick:e=>{p?.(e),b?.onChange(f||``)},onKeyDown:C})})});wv.displayName=`@mantine/core/RadioCard`,wv.classes=xv;var Tv=V((e,t)=>{let{value:n,defaultValue:r,onChange:i,size:a,wrapperProps:o,children:s,name:c,readOnly:l,disabled:u,...d}=z(`RadioGroup`,null,e),f=Qt(c),[p,m]=rn({value:n,defaultValue:r,finalValue:``,onChange:i});return(0,L.jsx)(_v,{value:{value:p,onChange:e=>!l&&m(typeof e==`string`?e:e.currentTarget.value),size:a,name:f,disabled:u},children:(0,L.jsx)(ud.Wrapper,{size:a,ref:t,...o,...d,labelElement:`div`,__staticSelector:`RadioGroup`,children:(0,L.jsx)(Qf,{role:`radiogroup`,children:s})})})});Tv.classes=ud.Wrapper.classes,Tv.displayName=`@mantine/core/RadioGroup`;function Ev({size:e,style:t,...n}){return(0,L.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 5 5`,style:{width:I(e),height:I(e),...t},"aria-hidden":!0,...n,children:(0,L.jsx)(`circle`,{cx:`2.5`,cy:`2.5`,r:`2.5`,fill:`currentColor`})})}var Dv={indicator:`m_717d7ff6`,icon:`m_3e4da632`,"indicator--outline":`m_2980836c`},Ov={icon:Ev},kv=kn((e,{radius:t,color:n,size:r,iconColor:i,variant:a,autoContrast:o})=>{let s=rr({color:n||e.primaryColor,theme:e}),c=s.isThemeColor&&s.shade===void 0?`var(--mantine-color-${s.color}-outline)`:s.color;return{indicator:{"--radio-size":dt(r,`radio-size`),"--radio-radius":t===void 0?void 0:pt(t),"--radio-color":a===`outline`?c:ir(n,e),"--radio-icon-size":dt(r,`radio-icon-size`),"--radio-icon-color":i?ir(i,e):ai(o,e)?Er({color:n,theme:e,autoContrast:o}):void 0}}}),Av=V((e,t)=>{let n=z(`RadioIndicator`,Ov,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,icon:l,radius:u,color:d,iconColor:f,autoContrast:p,checked:m,mod:h,variant:g,disabled:_,attributes:v,...y}=n,b=R({name:`RadioIndicator`,classes:Dv,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:v,vars:c,varsResolver:kv,rootSelector:`indicator`}),x=bv(),S=typeof m==`boolean`?m:x?.checked||!1;return(0,L.jsx)(B,{ref:t,...b(`indicator`,{variant:g}),variant:g,mod:[{checked:S,disabled:_},h],...y,children:(0,L.jsx)(l,{...b(`icon`)})})});Av.displayName=`@mantine/core/RadioIndicator`,Av.classes=Dv;var jv={labelPosition:`right`},Mv=kn((e,{size:t,radius:n,color:r,iconColor:i,variant:a,autoContrast:o})=>{let s=rr({color:r||e.primaryColor,theme:e}),c=s.isThemeColor&&s.shade===void 0?`var(--mantine-color-${s.color}-outline)`:s.color;return{root:{"--radio-size":dt(t,`radio-size`),"--radio-radius":n===void 0?void 0:pt(n),"--radio-color":a===`outline`?c:ir(r,e),"--radio-icon-color":i?ir(i,e):ai(o,e)?Er({color:r,theme:e,autoContrast:o}):void 0,"--radio-icon-size":dt(t,`radio-icon-size`)}}}),Nv=V((e,t)=>{let n=z(`Radio`,jv,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,id:l,size:u,label:d,labelPosition:f,description:p,error:m,radius:h,color:g,variant:_,disabled:v,wrapperProps:y,icon:b=Ev,rootRef:x,iconColor:S,onChange:C,mod:w,attributes:T,checked:E,...D}=n,O=R({name:`Radio`,classes:gv,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:T,vars:c,varsResolver:Mv}),k=vv(),A=k?.size??u,j=n.size?u:A,{styleProps:M,rest:N}=fi(D),P=Qt(l),F=k?k.value===N.value:void 0,ee={checked:F??E,name:k?.name??N.name,onChange:e=>{k?.onChange(e),C?.(e)},disabled:k?.disabled??v};return(0,L.jsx)(Vf,{...O(`root`),__staticSelector:`Radio`,__stylesApiProps:n,id:P,size:j,labelPosition:f,label:d,description:p,error:m,disabled:ee.disabled,classNames:r,styles:o,unstyled:s,"data-checked":(F??E)||void 0,variant:_,ref:x,mod:w,...M,...y,children:(0,L.jsxs)(B,{...O(`inner`),mod:{"label-position":f},children:[(0,L.jsx)(B,{...O(`radio`,{focusable:!0,variant:_}),...N,...ee,component:`input`,mod:{error:!!m},ref:t,id:P,type:`radio`}),(0,L.jsx)(b,{...O(`icon`),"aria-hidden":!0})]})})});Nv.classes=gv,Nv.displayName=`@mantine/core/Radio`,Nv.Group=Tv,Nv.Card=wv,Nv.Indicator=Av;var Pv={duration:100,transition:`fade`};function Fv(e,t){return{...Pv,...t,...e}}var Iv={tooltip:`m_1b3c8819`,arrow:`m_f898399f`};function Lv({offset:e,position:t,defaultOpened:n}){let[r,i]=(0,b.useState)(n),a=(0,b.useRef)(null),{x:o,y:s,elements:c,refs:l,update:u,placement:d}=Cc({placement:t,middleware:[Ns({crossAxis:!0,padding:5,rootBoundary:`document`})]}),f=d.includes(`right`)?e:t.includes(`left`)?e*-1:0,p=d.includes(`bottom`)?e:t.includes(`top`)?e*-1:0,m=(0,b.useCallback)(({clientX:e,clientY:t})=>{l.setPositionReference({getBoundingClientRect(){return{width:0,height:0,x:e,y:t,left:e+f,top:t+p,right:e,bottom:t}}})},[c.reference]);return(0,b.useEffect)(()=>{if(l.floating.current){let e=a.current;e.addEventListener(`mousemove`,m);let t=ba(l.floating.current);return t.forEach(e=>{e.addEventListener(`scroll`,u)}),()=>{e.removeEventListener(`mousemove`,m),t.forEach(e=>{e.removeEventListener(`scroll`,u)})}}},[c.reference,l.floating.current,u,m,r]),{handleMouseMove:m,x:o,y:s,opened:r,setOpened:i,boundaryRef:a,floating:l.setFloating}}var Rv={refProp:`ref`,withinPortal:!0,offset:10,position:`right`,zIndex:ct(`popover`)},zv=kn((e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:pt(t),"--tooltip-bg":n?ir(n,e):void 0,"--tooltip-color":n?`var(--mantine-color-white)`:void 0}})),Bv=V((e,t)=>{let n=z(`TooltipFloating`,Rv,e),{children:r,refProp:i,withinPortal:a,style:o,className:s,classNames:c,styles:l,unstyled:u,radius:d,color:f,label:p,offset:m,position:h,multiline:g,zIndex:_,disabled:v,defaultOpened:y,variant:x,vars:S,portalProps:C,attributes:w,...T}=n,E=xr(),D=R({name:`TooltipFloating`,props:n,classes:Iv,className:s,style:o,classNames:c,styles:l,unstyled:u,attributes:w,rootSelector:`tooltip`,vars:S,varsResolver:zv}),{handleMouseMove:O,x:k,y:A,opened:j,boundaryRef:M,floating:N,setOpened:P}=Lv({offset:m,position:h,defaultOpened:y}),F=On(r);if(!F)throw 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`);let ee=nn(M,wn(F),t),te=F.props,ne=e=>{te.onMouseEnter?.(e),O(e),P(!0)},re=e=>{te.onMouseLeave?.(e),P(!1)};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Nl,{...C,withinPortal:a,children:(0,L.jsx)(B,{...T,...D(`tooltip`,{style:{...Ii(o,E),zIndex:_,display:!v&&j?`block`:`none`,top:(A&&Math.round(A))??``,left:(k&&Math.round(k))??``}}),variant:x,ref:N,mod:{multiline:g},children:p})}),(0,b.cloneElement)(F,{...te,[i]:ee,onMouseEnter:ne,onMouseLeave:re})]})});Bv.classes=Iv,Bv.displayName=`@mantine/core/TooltipFloating`;var Vv=(0,b.createContext)(!1),Hv=Vv.Provider,Uv=()=>(0,b.useContext)(Vv),Wv={openDelay:0,closeDelay:0};function Gv(e){let{openDelay:t,closeDelay:n,children:r}=z(`TooltipGroup`,Wv,e);return(0,L.jsx)(Hv,{value:!0,children:(0,L.jsx)(gc,{delay:{open:t,close:n},children:r})})}Gv.displayName=`@mantine/core/TooltipGroup`,Gv.extend=e=>e;function Kv(e){if(e===void 0)return{shift:!0,flip:!0};let t={...e};return e.shift===void 0&&(t.shift=!0),e.flip===void 0&&(t.flip=!0),t}function qv(e){let t=Kv(e.middlewares),n=[Ms(e.offset)];return t.shift&&n.push(Ns(typeof t.shift==`boolean`?{padding:8}:{padding:8,...t.shift})),t.flip&&n.push(typeof t.flip==`boolean`?Fs():Fs(t.flip)),n.push(zs({element:e.arrowRef,padding:e.arrowOffset})),t.inline?n.push(typeof t.inline==`boolean`?Rs():Rs(t.inline)):e.inline&&n.push(Rs()),n}function Jv(e){let[t,n]=(0,b.useState)(e.defaultOpened),r=typeof e.opened==`boolean`?e.opened:t,i=Uv(),a=Qt(),o=(0,b.useCallback)(e=>{n(e),e&&g(a)},[a]),{x:s,y:c,context:l,refs:u,placement:d,middlewareData:{arrow:{x:f,y:p}={}}}=Cc({strategy:e.strategy,placement:e.position,open:r,onOpenChange:o,middleware:qv(e),whileElementsMounted:ms}),{delay:m,currentId:h,setCurrentId:g}=_c(l,{id:a}),{getReferenceProps:_,getFloatingProps:v}=Dc([fc(l,{enabled:e.events?.hover,delay:i?m:{open:e.openDelay,close:e.closeDelay},mouseOnly:!e.events?.touch}),Tc(l,{enabled:e.events?.focus,visibleOnly:!0}),kc(l,{role:`tooltip`}),xc(l,{enabled:e.opened===void 0})]);It(()=>{e.onPositionChange?.(d)},[d]);let y=r&&h&&h!==a;return{x:s,y:c,arrowX:f,arrowY:p,reference:u.setReference,floating:u.setFloating,getFloatingProps:v,getReferenceProps:_,isGroupPhase:y,opened:r,placement:d}}var Yv={position:`top`,refProp:`ref`,withinPortal:!0,arrowSize:4,arrowOffset:5,arrowRadius:0,arrowPosition:`side`,offset:5,transitionProps:{duration:100,transition:`fade`},events:{hover:!0,focus:!1,touch:!1},zIndex:ct(`popover`),positionDependencies:[],middlewares:{flip:!0,shift:!0,inline:!1}},Xv=kn((e,{radius:t,color:n,variant:r,autoContrast:i})=>{let a=e.variantColorResolver({theme:e,color:n||e.primaryColor,autoContrast:i,variant:r||`filled`});return{tooltip:{"--tooltip-radius":t===void 0?void 0:pt(t),"--tooltip-bg":n?a.background:void 0,"--tooltip-color":n?a.color:void 0}}}),Zv=V((e,t)=>{let n=z(`Tooltip`,Yv,e),{children:r,position:i,refProp:a,label:o,openDelay:s,closeDelay:c,onPositionChange:l,opened:u,defaultOpened:d,withinPortal:f,radius:p,color:m,classNames:h,styles:g,unstyled:_,style:v,className:y,withArrow:x,arrowSize:S,arrowOffset:C,arrowRadius:w,arrowPosition:T,offset:E,transitionProps:D,multiline:O,events:k,zIndex:A,disabled:j,positionDependencies:M,onClick:N,onMouseEnter:P,onMouseLeave:F,inline:ee,variant:te,keepMounted:ne,vars:re,portalProps:ie,mod:ae,floatingStrategy:oe,middlewares:se,autoContrast:ce,attributes:le,target:ue,...de}=z(`Tooltip`,Yv,n),{dir:fe}=Ji(),pe=(0,b.useRef)(null),me=Jv({position:wl(fe,i),closeDelay:c,openDelay:s,onPositionChange:l,opened:u,defaultOpened:d,events:k,arrowRef:pe,arrowOffset:C,offset:typeof E==`number`?E+(x?S/2:0):E,positionDependencies:[...M,ue??r],inline:ee,strategy:oe,middlewares:se});(0,b.useEffect)(()=>{let e=ue instanceof HTMLElement?ue:typeof ue==`string`?document.querySelector(ue):ue?.current||null;e&&me.reference(e)},[ue,me]);let he=R({name:`Tooltip`,props:n,classes:Iv,className:y,style:v,classNames:h,styles:g,unstyled:_,attributes:le,rootSelector:`tooltip`,vars:re,varsResolver:Xv}),ge=On(r);if(!ue&&!ge)throw 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`);if(ue){let e=Fv(D,{duration:100,transition:`fade`});return(0,L.jsx)(L.Fragment,{children:(0,L.jsx)(Nl,{...ie,withinPortal:f,children:(0,L.jsx)(zl,{...e,keepMounted:ne,mounted:!j&&!!me.opened,duration:me.isGroupPhase?10:e.duration,children:e=>(0,L.jsxs)(B,{...de,"data-fixed":oe===`fixed`||void 0,variant:te,mod:[{multiline:O},ae],...me.getFloatingProps({ref:me.floating,className:he(`tooltip`).className,style:{...he(`tooltip`).style,...e,zIndex:A,top:me.y??0,left:me.x??0}}),children:[o,(0,L.jsx)(Cl,{ref:pe,arrowX:me.arrowX,arrowY:me.arrowY,visible:x,position:me.placement,arrowSize:S,arrowOffset:C,arrowRadius:w,arrowPosition:T,...he(`arrow`)})]})})})})}let _e=ge.props,ve=nn(me.reference,wn(ge),t),ye=Fv(D,{duration:100,transition:`fade`});return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Nl,{...ie,withinPortal:f,children:(0,L.jsx)(zl,{...ye,keepMounted:ne,mounted:!j&&!!me.opened,duration:me.isGroupPhase?10:ye.duration,children:e=>(0,L.jsxs)(B,{...de,"data-fixed":oe===`fixed`||void 0,variant:te,mod:[{multiline:O},ae],...me.getFloatingProps({ref:me.floating,className:he(`tooltip`).className,style:{...he(`tooltip`).style,...e,zIndex:A,top:me.y??0,left:me.x??0}}),children:[o,(0,L.jsx)(Cl,{ref:pe,arrowX:me.arrowX,arrowY:me.arrowY,visible:x,position:me.placement,arrowSize:S,arrowOffset:C,arrowRadius:w,arrowPosition:T,...he(`arrow`)})]})})}),(0,b.cloneElement)(ge,me.getReferenceProps({onClick:N,onMouseEnter:P,onMouseLeave:F,onMouseMove:n.onMouseMove,onPointerDown:n.onPointerDown,onPointerEnter:n.onPointerEnter,..._e,className:jn(y,_e.className),[a]:ve}))]})});Zv.classes=Iv,Zv.displayName=`@mantine/core/Tooltip`,Zv.Floating=Bv,Zv.Group=Gv;function Qv({size:e,thickness:t,sum:n,value:r,root:i,offset:a}){let o=(e*.9-t*2)/2,s=Math.PI*o*2/100,c=i||r===void 0?`${(100-n)*s}, ${n*s}`:`${r*s}, ${(100-r)*s}`;return{strokeWidth:Number.isNaN(t)?12:t,cx:e/2||0,cy:e/2||0,r:o||0,transform:i?`scale(1, -1) translate(0, -${e})`:void 0,strokeDasharray:c,strokeDashoffset:i?0:a||0}}function $v({size:e,value:t,offset:n,sum:r,thickness:i,root:a,color:o,lineRoundCaps:s,tooltip:c,getStyles:l,display:u,...d}){let f=xr();return(0,L.jsx)(Zv.Floating,{disabled:!c,label:c,children:(0,L.jsx)(B,{component:`circle`,...d,...l(`curve`),__vars:{"--curve-color":o?ir(o,f):void 0},fill:`none`,strokeLinecap:s?`round`:`butt`,...Qv({sum:r,size:e,thickness:i,value:t,offset:n,root:a})})})}$v.displayName=`@mantine/core/Curve`;function ey({size:e,thickness:t,sections:n,renderRoundedLineCaps:r,rootColor:i}){let a=n.reduce((e,t)=>e+t.value,0),o=Math.PI*((e*.9-t*2)/2)*2,s=o,c=[],l=[];for(let e=0;e<n.length;e+=1)c.push({sum:a,offset:s,data:n[e],root:!1}),s-=n[e].value/100*o;if(c.push({sum:a,offset:s,data:{color:i},root:!0}),l.push({...c[c.length-1],lineRoundCaps:!1}),c.length>2){l.push({...c[0],lineRoundCaps:r}),l.push({...c[c.length-2],lineRoundCaps:r});for(let e=1;e<=c.length-3;e+=1)l.push({...c[e],lineRoundCaps:!1})}else l.push({...c[0],lineRoundCaps:r});return l}var ty={root:`m_b32e4812`,svg:`m_d43b5134`,curve:`m_b1ca1fbf`,label:`m_b23f9dc4`};function ny(e,t){return Math.min(e||12,(t||120)/4)}var ry={size:120,thickness:12},iy=kn((e,{size:t,thickness:n,transitionDuration:r})=>({root:{"--rp-size":I(t),"--rp-label-offset":I(n*2),"--rp-transition-duration":r?`${r}ms`:void 0}})),ay=V((e,t)=>{let n=z(`RingProgress`,ry,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,label:l,sections:u,size:d,thickness:f,roundCaps:p,rootColor:m,transitionDuration:h,attributes:g,..._}=n,v=R({name:`RingProgress`,classes:ty,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:g,vars:c,varsResolver:iy}),y=ny(f,d),x=ey({size:d,thickness:y,sections:u,renderRoundedLineCaps:p,rootColor:m}).map(({data:e,sum:t,root:n,lineRoundCaps:r,offset:i},a)=>(0,b.createElement)($v,{...e,key:a,size:d,thickness:y,sum:t,offset:i,color:e?.color,root:n,lineRoundCaps:r,getStyles:v}));return(0,L.jsxs)(B,{...v(`root`),size:d,ref:t,..._,children:[(0,L.jsx)(`svg`,{...v(`svg`),children:x}),l&&(0,L.jsx)(`div`,{...v(`label`),children:l})]})});ay.classes=ty,ay.displayName=`@mantine/core/RingProgress`;var oy={root:`m_cf365364`,indicator:`m_9e182ccd`,label:`m_1738fcb2`,input:`m_1714d588`,control:`m_69686b9b`,innerLabel:`m_78882f40`},sy={withItemsBorders:!0},cy=kn((e,{radius:t,color:n,transitionDuration:r,size:i,transitionTimingFunction:a})=>({root:{"--sc-radius":t===void 0?void 0:pt(t),"--sc-color":n?ir(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":a,"--sc-padding":dt(i,`sc-padding`),"--sc-font-size":mt(i)}})),ly=V((e,t)=>{let n=z(`SegmentedControl`,sy,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,data:l,value:u,defaultValue:d,onChange:f,size:p,name:m,disabled:h,readOnly:g,fullWidth:_,orientation:v,radius:y,color:x,transitionDuration:S,transitionTimingFunction:C,variant:w,autoContrast:T,withItemsBorders:E,mod:D,attributes:O,...k}=n,A=R({name:`SegmentedControl`,props:n,classes:oy,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:O,vars:c,varsResolver:cy}),j=xr(),M=l.map(e=>typeof e==`string`?{label:e,value:e}:e),N=Sn(),[P,F]=(0,b.useState)(Ct()),[ee,te]=(0,b.useState)(null),[ne,re]=(0,b.useState)({}),ie=(e,t)=>{ne[t]=e,re(ne)},[ae,oe]=rn({value:u,defaultValue:d,finalValue:Array.isArray(l)?M.find(e=>!e.disabled)?.value??l[0]?.value??null:null,onChange:f}),se=Qt(m),ce=M.map(e=>(0,b.createElement)(B,{...A(`control`),mod:{active:ae===e.value,orientation:v},key:e.value},(0,b.createElement)(`input`,{...A(`input`),disabled:h||e.disabled,type:`radio`,name:se,value:e.value,id:`${se}-${e.value}`,checked:ae===e.value,onChange:()=>!g&&oe(e.value),"data-focus-ring":j.focusRing,key:`${e.value}-input`}),(0,b.createElement)(B,{component:`label`,...A(`label`),mod:{active:ae===e.value&&!(h||e.disabled),disabled:h||e.disabled,"read-only":g},htmlFor:`${se}-${e.value}`,ref:t=>ie(t,e.value),__vars:{"--sc-label-color":x===void 0?void 0:Er({color:x,theme:j,autoContrast:T})},key:`${e.value}-label`},(0,L.jsx)(`span`,{...A(`innerLabel`),children:e.label})))),le=nn(t,e=>te(e));return dn(()=>{F(Ct())},[l.length]),l.length===0?null:(0,L.jsxs)(B,{...A(`root`),variant:w,size:p,ref:le,mod:[{"full-width":_,orientation:v,initialized:N,"with-items-borders":E},D],...k,role:`radiogroup`,"data-disabled":h,children:[typeof ae==`string`&&(0,L.jsx)(xd,{target:ne[ae],parent:ee,component:`span`,transitionDuration:`var(--sc-transition-duration)`,...A(`indicator`)},P),ce]})});ly.classes=oy,ly.displayName=`@mantine/core/SegmentedControl`;var uy={container:`m_925c2d2c`,root:`m_2415a157`};function dy({spacing:e,verticalSpacing:t,cols:n,selector:r}){let i=xr(),a=t===void 0?e:t,o=Ye({"--sg-spacing-x":ft(bt(e)),"--sg-spacing-y":ft(bt(a)),"--sg-cols":bt(n)?.toString()}),s=Be(i.breakpoints).reduce((t,r)=>(t[r]||(t[r]={}),typeof e==`object`&&e[r]!==void 0&&(t[r][`--sg-spacing-x`]=ft(e[r])),typeof a==`object`&&a[r]!==void 0&&(t[r][`--sg-spacing-y`]=ft(a[r])),typeof n==`object`&&n[r]!==void 0&&(t[r][`--sg-cols`]=n[r]),t),{});return(0,L.jsx)(di,{styles:o,media:yt(Be(s),i.breakpoints).filter(e=>Be(s[e.value]).length>0).map(e=>({query:`(min-width: ${i.breakpoints[e.value]})`,styles:s[e.value]})),selector:r})}function fy(e){return typeof e==`object`&&e?Be(e):[]}function py(e){return e.sort((e,t)=>Ge(e)-Ge(t))}function my({spacing:e,verticalSpacing:t,cols:n}){return py(Array.from(new Set([...fy(e),...fy(t),...fy(n)])))}function hy({spacing:e,verticalSpacing:t,cols:n,selector:r}){let i=t===void 0?e:t,a=Ye({"--sg-spacing-x":ft(bt(e)),"--sg-spacing-y":ft(bt(i)),"--sg-cols":bt(n)?.toString()}),o=my({spacing:e,verticalSpacing:t,cols:n}),s=o.reduce((t,r)=>(t[r]||(t[r]={}),typeof e==`object`&&e[r]!==void 0&&(t[r][`--sg-spacing-x`]=ft(e[r])),typeof i==`object`&&i[r]!==void 0&&(t[r][`--sg-spacing-y`]=ft(i[r])),typeof n==`object`&&n[r]!==void 0&&(t[r][`--sg-cols`]=n[r]),t),{});return(0,L.jsx)(di,{styles:a,container:o.map(e=>({query:`simple-grid (min-width: ${e})`,styles:s[e]})),selector:r})}var gy={cols:1,spacing:`md`,type:`media`},_y=V((e,t)=>{let n=z(`SimpleGrid`,gy,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,cols:l,verticalSpacing:u,spacing:d,type:f,attributes:p,...m}=n,h=R({name:`SimpleGrid`,classes:uy,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:p,vars:c}),g=Fi();return f===`container`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(hy,{...n,selector:`.${g}`}),(0,L.jsx)(`div`,{...h(`container`),children:(0,L.jsx)(B,{ref:t,...h(`root`,{className:g}),...m})})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(dy,{...n,selector:`.${g}`}),(0,L.jsx)(B,{ref:t,...h(`root`,{className:g}),...m})]})});_y.classes=uy,_y.displayName=`@mantine/core/SimpleGrid`;var vy={root:`m_18320242`,"skeleton-fade":`m_299c329c`},yy={visible:!0,animate:!0},by=kn((e,{width:t,height:n,radius:r,circle:i})=>({root:{"--skeleton-height":I(n),"--skeleton-width":I(i?n:t),"--skeleton-radius":i?`1000px`:r===void 0?void 0:pt(r)}})),xy=V((e,t)=>{let n=z(`Skeleton`,yy,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,width:l,height:u,circle:d,visible:f,radius:p,animate:m,mod:h,attributes:g,..._}=n;return(0,L.jsx)(B,{ref:t,...R({name:`Skeleton`,classes:vy,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:g,vars:c,varsResolver:by})(`root`),mod:[{visible:f,animate:m},h],..._})});xy.classes=vy,xy.displayName=`@mantine/core/Skeleton`;var Sy=V((e,t)=>{let{w:n,h:r,miw:i,mih:a,...o}=z(`Space`,null,e);return(0,L.jsx)(B,{ref:t,...o,w:n,miw:i??n,h:r,mih:a??r})});Sy.displayName=`@mantine/core/Space`;var Cy={root:`m_6d731127`},wy={gap:`md`,align:`stretch`,justify:`flex-start`},Ty=kn((e,{gap:t,align:n,justify:r})=>({root:{"--stack-gap":ft(t),"--stack-align":n,"--stack-justify":r}})),K=V((e,t)=>{let n=z(`Stack`,wy,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,align:l,justify:u,gap:d,variant:f,attributes:p,...m}=n;return(0,L.jsx)(B,{ref:t,...R({name:`Stack`,props:n,classes:Cy,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:p,vars:c,varsResolver:Ty})(`root`),variant:f,...m})});K.classes=Cy,K.displayName=`@mantine/core/Stack`;var[Ey,Dy]=$e(`Stepper component was not found in tree`),Oy={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`},ky=()=>null;ky.displayName=`@mantine/core/StepperCompleted`;var Ay=(e,t)=>typeof e==`function`?(0,L.jsx)(e,{step:t||0}):e,jy={withIcon:!0,allowStepClick:!0,iconPosition:`left`},My=V((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,step:s,state:c,color:l,icon:u,completedIcon:d,progressIcon:f,label:p,description:m,withIcon:h,iconSize:g,loading:_,allowStepClick:v,allowStepSelect:y,iconPosition:b,orientation:x,mod:S,...C}=z(`StepperStep`,jy,e),w=Dy(),T=xr(),E={classNames:n,styles:a},D=c===`stepCompleted`?null:c===`stepProgress`?f:u,O={"data-progress":c===`stepProgress`||void 0,"data-completed":c===`stepCompleted`||void 0};return(0,L.jsxs)(pl,{...w.getStyles(`step`,{className:r,style:i,variant:w.orientation,...E}),mod:[{"icon-position":b||w.iconPosition,"allow-click":v},S],ref:t,...O,...C,__vars:{"--step-color":l?ir(l,T):void 0},tabIndex:v?0:-1,children:[h&&(0,L.jsxs)(`span`,{...w.getStyles(`stepWrapper`,E),children:[(0,L.jsxs)(`span`,{...w.getStyles(`stepIcon`,E),...O,children:[(0,L.jsx)(zl,{mounted:c===`stepCompleted`,transition:`pop`,duration:200,children:e=>(0,L.jsx)(`span`,{...w.getStyles(`stepCompletedIcon`,{style:e,...E}),children:_?(0,L.jsx)(su,{color:`var(--mantine-color-white)`,size:`calc(var(--stepper-icon-size) / 2)`,...w.getStyles(`stepLoader`,E)}):Ay(d,s)||(0,L.jsx)(ep,{size:`60%`})})}),c===`stepCompleted`?null:(0,L.jsx)(`span`,{children:_?(0,L.jsx)(su,{...w.getStyles(`stepLoader`,E),size:`calc(var(--stepper-icon-size) / 2)`,color:l}):Ay(D||u,s)})]}),x===`vertical`&&(0,L.jsx)(`span`,{...w.getStyles(`verticalSeparator`,E),"data-active":c===`stepCompleted`||void 0})]}),(p||m)&&(0,L.jsxs)(`span`,{...w.getStyles(`stepBody`,E),"data-orientation":w.orientation,"data-icon-position":b||w.iconPosition,children:[p&&(0,L.jsx)(`span`,{...w.getStyles(`stepLabel`,E),children:Ay(p,s)}),m&&(0,L.jsx)(`span`,{...w.getStyles(`stepDescription`,E),children:Ay(m,s)})]})]})});My.classes=Oy,My.displayName=`@mantine/core/StepperStep`;var Ny={orientation:`horizontal`,iconPosition:`left`,allowNextStepsSelect:!0,wrap:!0},Py=kn((e,{color:t,iconSize:n,size:r,contentPadding:i,radius:a,autoContrast:o})=>({root:{"--stepper-color":t?ir(t,e):void 0,"--stepper-icon-color":ai(o,e)?Er({color:t,theme:e,autoContrast:o}):void 0,"--stepper-icon-size":n===void 0?dt(r,`stepper-icon-size`):I(n),"--stepper-content-padding":ft(i),"--stepper-radius":a===void 0?void 0:pt(a),"--stepper-fz":mt(r),"--stepper-spacing":ft(r)}})),Fy=V((e,t)=>{let n=z(`Stepper`,Ny,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,children:l,onStepClick:u,active:d,icon:f,completedIcon:p,progressIcon:m,color:h,iconSize:g,contentPadding:_,orientation:v,iconPosition:y,size:x,radius:S,allowNextStepsSelect:C,wrap:w,autoContrast:T,attributes:E,...D}=n,O=R({name:`Stepper`,classes:Oy,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:E,vars:c,varsResolver:Py}),k=b.Children.toArray(l),A=k.filter(e=>e.type!==ky),j=k.find(e=>e.type===ky),M=A.reduce((e,t,n)=>{let r=d===n?`stepProgress`:d>n?`stepCompleted`:`stepInactive`,i=typeof u==`function`?typeof t.props.allowStepSelect==`boolean`?t.props.allowStepSelect:r===`stepCompleted`||C:!1;return e.push((0,b.cloneElement)(t,{icon:t.props.icon||f||n+1,key:n,step:n,state:r,onClick:()=>i&&u?.(n),allowStepClick:i,completedIcon:t.props.completedIcon||p,progressIcon:t.props.progressIcon||m,color:t.props.color||h,iconSize:g,iconPosition:t.props.iconPosition||y,orientation:v})),v===`horizontal`&&n!==A.length-1&&e.push((0,b.createElement)(`div`,{...O(`separator`),"data-active":n<d||void 0,"data-orientation":v,key:`separator-${n}`})),e},[]),N=A[d]?.props?.children,P=j?.props?.children,F=d>A.length-1?P:N;return(0,L.jsx)(Ey,{value:{getStyles:O,orientation:v,iconPosition:y},children:(0,L.jsxs)(B,{...O(`root`),ref:t,size:x,...D,children:[(0,L.jsx)(B,{...O(`steps`),mod:{orientation:v,"icon-position":y,wrap:w&&v!==`vertical`},children:M}),F&&(0,L.jsx)(`div`,{...O(`content`),children:F})]})})});Fy.classes=Oy,Fy.displayName=`@mantine/core/Stepper`,Fy.Completed=ky,Fy.Step=My;var Iy={root:`m_5f93f3bb`,input:`m_926b4011`,track:`m_9307d992`,thumb:`m_93039a1d`,trackLabel:`m_8277e082`},Ly=(0,b.createContext)(null),Ry=Ly.Provider,zy=()=>(0,b.useContext)(Ly),By=V((e,t)=>{let{value:n,defaultValue:r,onChange:i,size:a,wrapperProps:o,children:s,readOnly:c,disabled:l,...u}=z(`SwitchGroup`,null,e),[d,f]=rn({value:n,defaultValue:r,finalValue:[],onChange:i});return(0,L.jsx)(Ry,{value:{value:d,onChange:e=>{let t=e.currentTarget.value;!c&&f(d.includes(t)?d.filter(e=>e!==t):[...d,t])},size:a,disabled:l},children:(0,L.jsx)(ud.Wrapper,{size:a,ref:t,...o,...u,labelElement:`div`,__staticSelector:`SwitchGroup`,children:(0,L.jsx)(Qf,{role:`group`,children:s})})})});By.classes=ud.Wrapper.classes,By.displayName=`@mantine/core/SwitchGroup`;var Vy={labelPosition:`right`,withThumbIndicator:!0},Hy=kn((e,{radius:t,color:n,size:r})=>({root:{"--switch-radius":t===void 0?void 0:pt(t),"--switch-height":dt(r,`switch-height`),"--switch-width":dt(r,`switch-width`),"--switch-thumb-size":dt(r,`switch-thumb-size`),"--switch-label-font-size":dt(r,`switch-label-font-size`),"--switch-track-label-padding":dt(r,`switch-track-label-padding`),"--switch-color":n?ir(n,e):void 0}})),Uy=V((e,t)=>{let n=z(`Switch`,Vy,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,color:l,label:u,offLabel:d,onLabel:f,id:p,size:m,radius:h,wrapperProps:g,thumbIcon:_,checked:v,defaultChecked:y,onChange:b,labelPosition:x,description:S,error:C,disabled:w,variant:T,rootRef:E,mod:D,withThumbIndicator:O,attributes:k,...A}=n,j=zy(),M=m||j?.size,N=R({name:`Switch`,props:n,classes:Iy,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:k,vars:c,varsResolver:Hy}),{styleProps:P,rest:F}=fi(A),ee=Qt(p),te={checked:j?.value.includes(F.value)??v,onChange:e=>{j?.onChange(e),b?.(e)},disabled:j?.disabled??w},[ne,re]=rn({value:te.checked??v,defaultValue:y,finalValue:!1});return(0,L.jsxs)(Vf,{...N(`root`),__staticSelector:`Switch`,__stylesApiProps:n,id:ee,size:M,labelPosition:x,label:u,description:S,error:C,disabled:te.disabled,bodyElement:`label`,labelElement:`span`,classNames:r,styles:o,unstyled:s,"data-checked":te.checked,variant:T,ref:E,mod:D,inert:F.inert,...P,...g,children:[(0,L.jsx)(`input`,{...F,...te,checked:ne,"data-checked":te.checked,onChange:e=>{te.onChange?.(e),re(e.currentTarget.checked)},id:ee,ref:t,type:`checkbox`,role:`switch`,inert:F.inert,...N(`input`)}),(0,L.jsxs)(B,{"aria-hidden":`true`,component:`span`,mod:{error:C,"label-position":x,"without-labels":!f&&!d},...N(`track`),children:[(0,L.jsx)(B,{component:`span`,mod:{"reduce-motion":!0,"with-thumb-indicator":O&&!_},...N(`thumb`),children:_}),(0,L.jsx)(`span`,{...N(`trackLabel`),children:ne?f:d})]})]})});Uy.classes={...Iy,...Bf},Uy.displayName=`@mantine/core/Switch`,Uy.Group=By;var[Wy,Gy]=$e(`Table component was not found in the tree`),Ky={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 qy(e,t){if(!t)return;let 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 Jy(e,t){let n=`Table${e.charAt(0).toUpperCase()}${e.slice(1)}`,r=V((r,i)=>{let a=z(n,{},r),{classNames:o,className:s,style:c,styles:l,...u}=a,d=Gy();return(0,L.jsx)(B,{component:e,ref:i,...qy(d,t),...d.getStyles(e,{className:s,classNames:o,style:c,styles:l,props:a}),...u})});return r.displayName=`@mantine/core/${n}`,r.classes=Ky,r}var Yy=Jy(`th`,{columnBorder:!0}),Xy=Jy(`td`,{columnBorder:!0}),Zy=Jy(`tr`,{rowBorder:!0,striped:!0,highlightOnHover:!0}),Qy=Jy(`thead`,{stickyHeader:!0}),$y=Jy(`tbody`),eb=Jy(`tfoot`),tb=Jy(`caption`,{captionSide:!0});function nb({data:e}){return(0,L.jsxs)(L.Fragment,{children:[e.caption&&(0,L.jsx)(tb,{children:e.caption}),e.head&&(0,L.jsx)(Qy,{children:(0,L.jsx)(Zy,{children:e.head.map((e,t)=>(0,L.jsx)(Yy,{children:e},t))})}),e.body&&(0,L.jsx)($y,{children:e.body.map((e,t)=>(0,L.jsx)(Zy,{children:e.map((e,t)=>(0,L.jsx)(Xy,{children:e},t))},t))}),e.foot&&(0,L.jsx)(eb,{children:(0,L.jsx)(Zy,{children:e.foot.map((e,t)=>(0,L.jsx)(Yy,{children:e},t))})})]})}nb.displayName=`@mantine/core/TableDataRenderer`;var rb={type:`scrollarea`},ib=kn((e,{minWidth:t,maxHeight:n,type:r})=>({scrollContainer:{"--table-min-width":I(t),"--table-max-height":I(n),"--table-overflow":r===`native`?`auto`:void 0}})),ab=V((e,t)=>{let n=z(`TableScrollContainer`,rb,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,children:l,minWidth:u,maxHeight:d,type:f,scrollAreaProps:p,attributes:m,...h}=n,g=R({name:`TableScrollContainer`,classes:Ky,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:m,vars:c,varsResolver:ib,rootSelector:`scrollContainer`});return(0,L.jsx)(B,{component:f===`scrollarea`?ll:`div`,...f===`scrollarea`?d?{offsetScrollbars:`xy`,...p}:{offsetScrollbars:`x`,...p}:{},ref:t,...g(`scrollContainer`),...h,children:(0,L.jsx)(`div`,{...g(`scrollContainerInner`),children:l})})});ab.classes=Ky,ab.displayName=`@mantine/core/TableScrollContainer`;var ob={withRowBorders:!0,verticalSpacing:7},sb=kn((e,{layout:t,captionSide:n,horizontalSpacing:r,verticalSpacing:i,borderColor:a,stripedColor:o,highlightOnHoverColor:s,striped:c,highlightOnHover:l,stickyHeaderOffset:u,stickyHeader:d})=>({table:{"--table-layout":t,"--table-caption-side":n,"--table-horizontal-spacing":ft(r),"--table-vertical-spacing":ft(i),"--table-border-color":a?ir(a,e):void 0,"--table-striped-color":c&&o?ir(o,e):void 0,"--table-highlight-on-hover-color":l&&s?ir(s,e):void 0,"--table-sticky-header-offset":d?I(u):void 0}})),q=V((e,t)=>{let n=z(`Table`,ob,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,horizontalSpacing:l,verticalSpacing:u,captionSide:d,stripedColor:f,highlightOnHoverColor:p,striped:m,highlightOnHover:h,withColumnBorders:g,withRowBorders:_,withTableBorder:v,borderColor:y,layout:b,variant:x,data:S,children:C,stickyHeader:w,stickyHeaderOffset:T,mod:E,tabularNums:D,attributes:O,...k}=n,A=R({name:`Table`,props:n,className:i,style:a,classes:Ky,classNames:r,styles:o,unstyled:s,attributes:O,rootSelector:`table`,vars:c,varsResolver:sb});return(0,L.jsx)(Wy,{value:{getStyles:A,stickyHeader:w,striped:m===!0?`odd`:m||void 0,highlightOnHover:h,withColumnBorders:g,withRowBorders:_,captionSide:d||`bottom`},children:(0,L.jsx)(B,{component:`table`,variant:x,ref:t,mod:[{"data-with-table-border":v,"data-tabular-nums":D},E],...A(`table`),...k,children:C||!!S&&(0,L.jsx)(nb,{data:S})})})});q.classes=Ky,q.displayName=`@mantine/core/Table`,q.Td=Xy,q.Th=Yy,q.Tr=Zy,q.Thead=Qy,q.Tbody=$y,q.Tfoot=eb,q.Caption=tb,q.ScrollContainer=ab,q.DataRenderer=nb;var[cb,lb]=$e(`Tabs component was not found in the tree`),ub={root:`m_89d60db1`,"list--default":`m_576c9d4`,list:`m_89d33d6d`,tab:`m_4ec4dce6`,panel:`m_b0c91715`,tabSection:`m_fc420b1f`,tabLabel:`m_42bbd1ae`,"tab--default":`m_539e827b`,"list--outline":`m_6772fbd5`,"tab--outline":`m_b59ab47c`,"tab--pills":`m_c3381914`},db=V((e,t)=>{let n=z(`TabsList`,null,e),{children:r,className:i,grow:a,justify:o,classNames:s,styles:c,style:l,mod:u,...d}=n,f=lb();return(0,L.jsx)(B,{...d,...f.getStyles(`list`,{className:i,style:l,classNames:s,styles:c,props:n,variant:f.variant}),ref:t,role:`tablist`,variant:f.variant,mod:[{grow:a,orientation:f.orientation,placement:f.orientation===`vertical`&&f.placement,inverted:f.inverted},u],"aria-orientation":f.orientation,__vars:{"--tabs-justify":o},children:r})});db.classes=ub,db.displayName=`@mantine/core/TabsList`;var fb=V((e,t)=>{let n=z(`TabsPanel`,null,e),{children:r,className:i,value:a,classNames:o,styles:s,style:c,mod:l,keepMounted:u,...d}=n,f=lb(),p=f.value===a,m=f.keepMounted||u||p?r:null;return(0,L.jsx)(B,{...f.getStyles(`panel`,{className:i,classNames:o,styles:s,style:[c,p?void 0:{display:`none`}],props:n}),ref:t,mod:[{orientation:f.orientation},l],role:`tabpanel`,id:f.getPanelId(a),"aria-labelledby":f.getTabId(a),...d,children:m})});fb.classes=ub,fb.displayName=`@mantine/core/TabsPanel`;var pb=V((e,t)=>{let n=z(`TabsTab`,null,e),{className:r,children:i,rightSection:a,leftSection:o,value:s,onClick:c,onKeyDown:l,disabled:u,color:d,style:f,classNames:p,styles:m,vars:h,mod:g,tabIndex:_,...v}=n,y=xr(),{dir:b}=Ji(),x=lb(),S=s===x.value,C=e=>{x.onChange(x.allowTabDeactivation&&s===x.value?null:s),c?.(e)},w={classNames:p,styles:m,props:n};return(0,L.jsxs)(pl,{...x.getStyles(`tab`,{className:r,style:f,variant:x.variant,...w}),disabled:u,unstyled:x.unstyled,variant:x.variant,mod:[{active:S,disabled:u,orientation:x.orientation,inverted:x.inverted,placement:x.orientation===`vertical`&&x.placement},g],ref:t,role:`tab`,id:x.getTabId(s),"aria-selected":S,tabIndex:_===void 0?S||x.value===null?0:-1:_,"aria-controls":x.getPanelId(s),onClick:C,__vars:{"--tabs-color":d?ir(d,y):void 0},onKeyDown:ot({siblingSelector:`[role="tab"]`,parentSelector:`[role="tablist"]`,activateOnFocus:x.activateTabWithKeyboard,loop:x.loop,orientation:x.orientation||`horizontal`,dir:b,onKeyDown:l}),...v,children:[o&&(0,L.jsx)(`span`,{...x.getStyles(`tabSection`,w),"data-position":`left`,children:o}),i&&(0,L.jsx)(`span`,{...x.getStyles(`tabLabel`,w),children:i}),a&&(0,L.jsx)(`span`,{...x.getStyles(`tabSection`,w),"data-position":`right`,children:a})]})});pb.classes=ub,pb.displayName=`@mantine/core/TabsTab`;var mb=`Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value`,hb={keepMounted:!0,orientation:`horizontal`,loop:!0,activateTabWithKeyboard:!0,variant:`default`,placement:`left`},gb=kn((e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":pt(t),"--tabs-color":ir(n,e),"--tabs-text-color":ai(r,e)?Er({color:n,theme:e,autoContrast:r}):void 0}})),_b=V((e,t)=>{let n=z(`Tabs`,hb,e),{defaultValue:r,value:i,onChange:a,orientation:o,children:s,loop:c,id:l,activateTabWithKeyboard:u,allowTabDeactivation:d,variant:f,color:p,radius:m,inverted:h,placement:g,keepMounted:_,classNames:v,styles:y,unstyled:b,className:x,style:S,vars:C,autoContrast:w,mod:T,attributes:E,...D}=n,O=Qt(l),[k,A]=rn({value:i,defaultValue:r,finalValue:null,onChange:a}),j=R({name:`Tabs`,props:n,classes:ub,className:x,style:S,classNames:v,styles:y,unstyled:b,attributes:E,vars:C,varsResolver:gb});return(0,L.jsx)(cb,{value:{placement:g,value:k,orientation:o,id:O,loop:c,activateTabWithKeyboard:u,getTabId:tt(`${O}-tab`,mb),getPanelId:tt(`${O}-panel`,mb),onChange:A,allowTabDeactivation:d,variant:f,color:p,radius:m,inverted:h,keepMounted:_,unstyled:b,getStyles:j},children:(0,L.jsx)(B,{ref:t,id:O,variant:f,mod:[{orientation:o,inverted:o===`horizontal`&&h,placement:o===`vertical`&&g},T],...j(`root`),...D,children:s})})});_b.classes=ub,_b.displayName=`@mantine/core/Tabs`,_b.Tab=pb,_b.Panel=fb,_b.List=db;var vb=V((e,t)=>(0,L.jsx)(pd,{component:`input`,ref:t,...z(`TextInput`,null,e),__staticSelector:`TextInput`}));vb.classes=pd.classes,vb.displayName=`@mantine/core/TextInput`;var yb={root:`m_7341320d`},bb=kn((e,{size:t,radius:n,variant:r,gradient:i,color:a,autoContrast:o})=>{let s=e.variantColorResolver({color:a||e.primaryColor,theme:e,gradient:i,variant:r||`filled`,autoContrast:o});return{root:{"--ti-size":dt(t,`ti-size`),"--ti-radius":n===void 0?void 0:pt(n),"--ti-bg":a||r?s.background:void 0,"--ti-color":a||r?s.color:void 0,"--ti-bd":a||r?s.border:void 0}}}),xb=V((e,t)=>{let n=z(`ThemeIcon`,null,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,autoContrast:l,attributes:u,...d}=n;return(0,L.jsx)(B,{ref:t,...R({name:`ThemeIcon`,classes:yb,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:u,vars:c,varsResolver:bb})(`root`),...d})});xb.classes=yb,xb.displayName=`@mantine/core/ThemeIcon`;var Sb=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],Cb=[`xs`,`sm`,`md`,`lg`,`xl`];function wb(e,t){let n=t===void 0?`h${e}`:t;return Sb.includes(n)?{fontSize:`var(--mantine-${n}-font-size)`,fontWeight:`var(--mantine-${n}-font-weight)`,lineHeight:`var(--mantine-${n}-line-height)`}:Cb.includes(n)?{fontSize:`var(--mantine-font-size-${n})`,fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}:{fontSize:I(n),fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}}var Tb={root:`m_8a5d1357`},Eb={order:1},Db=kn((e,{order:t,size:n,lineClamp:r,textWrap:i})=>{let a=wb(t||1,n);return{root:{"--title-fw":a.fontWeight,"--title-lh":a.lineHeight,"--title-fz":a.fontSize,"--title-line-clamp":typeof r==`number`?r.toString():void 0,"--title-text-wrap":i}}}),J=V((e,t)=>{let n=z(`Title`,Eb,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,order:c,vars:l,size:u,variant:d,lineClamp:f,textWrap:p,mod:m,attributes:h,...g}=n,_=R({name:`Title`,props:n,classes:Tb,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:h,vars:l,varsResolver:Db});return[1,2,3,4,5,6].includes(c)?(0,L.jsx)(B,{..._(`root`),component:`h${c}`,variant:d,ref:t,mod:[{order:c,"data-line-clamp":typeof f==`number`},m],size:u,...g}):null});J.classes=Tb,J.displayName=`@mantine/core/Title`;function Ob(e){let t=e,n=!1,r=new Set;return{getState(){return t},updateState(e){t=typeof e==`function`?e(t):e},setState(e){this.updateState(e),r.forEach(e=>e(t))},initialize(e){n||=(t=e,!0)},subscribe(e){return r.add(e),()=>r.delete(e)}}}function kb(e){return(0,b.useSyncExternalStore)(e.subscribe,()=>e.getState(),()=>e.getState())}function Ab(e,t,n){let r=[],i=[],a={};for(let o of e){let e=o.position||t;a[e]=a[e]||0,a[e]+=1,a[e]<=n?i.push(o):r.push(o)}return{notifications:i,queue:r}}var jb=Ob({notifications:[],queue:[],defaultPosition:`bottom-right`,limit:5}),Mb=(e=jb)=>kb(e);function Nb(e,t){let n=e.getState(),r=Ab(t([...n.notifications,...n.queue]),n.defaultPosition,n.limit);e.setState({notifications:r.notifications,queue:r.queue,limit:n.limit,defaultPosition:n.defaultPosition})}function Y(e,t=jb){let n=e.id||Ct();return Nb(t,t=>e.id&&t.some(t=>t.id===e.id)?t:[...t,{...e,id:n}]),n}function Pb(e,t=jb){return Nb(t,t=>t.filter(t=>t.id===e?(t.onClose?.(t),!1):!0)),e}function Fb(e,t=jb){return Nb(t,t=>t.map(t=>t.id===e.id?{...t,...e}:t)),e.id}function Ib(e=jb){Nb(e,()=>[])}function Lb(e=jb){Nb(e,t=>t.slice(0,e.getState().limit))}var Rb={show:Y,hide:Pb,update:Fb,clean:Ib,cleanQueue:Lb,updateState:Nb};function zb(e,t){return zb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},zb(e,t)}function Bb(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,zb(e,t)}var Vb=o(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Hb=o(((e,t)=>{var n=Vb();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=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 s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Ub=o(((e,t)=>{t.exports=Hb()()})),Wb={disabled:!1},Gb=b.createContext(null),Kb=function(e){return e.scrollTop},qb=`unmounted`,Jb=`exited`,Yb=`entering`,Xb=`entered`,Zb=`exiting`,Qb=function(e){Bb(t,e);function t(t,n){var r=e.call(this,t,n)||this,i=n,a=i&&!i.isMounting?t.enter:t.appear,o;return r.appearStatus=null,t.in?a?(o=Jb,r.appearStatus=Yb):o=Xb:o=t.unmountOnExit||t.mountOnEnter?qb:Jb,r.state={status:o},r.nextCallback=null,r}t.getDerivedStateFromProps=function(e,t){return e.in&&t.status===`unmounted`?{status:Jb}:null};var n=t.prototype;return n.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},n.componentDidUpdate=function(e){var t=null;if(e!==this.props){var n=this.state.status;this.props.in?n!==`entering`&&n!==`entered`&&(t=Yb):(n===`entering`||n===`entered`)&&(t=Zb)}this.updateStatus(!1,t)},n.componentWillUnmount=function(){this.cancelNextCallback()},n.getTimeouts=function(){var e=this.props.timeout,t=n=r=e,n,r;return e!=null&&typeof e!=`number`&&(t=e.exit,n=e.enter,r=e.appear===void 0?n:e.appear),{exit:t,enter:n,appear:r}},n.updateStatus=function(e,t){if(e===void 0&&(e=!1),t!==null)if(this.cancelNextCallback(),t===`entering`){if(this.props.unmountOnExit||this.props.mountOnEnter){var n=this.props.nodeRef?this.props.nodeRef.current:ws.default.findDOMNode(this);n&&Kb(n)}this.performEnter(e)}else this.performExit();else this.props.unmountOnExit&&this.state.status===`exited`&&this.setState({status:qb})},n.performEnter=function(e){var t=this,n=this.props.enter,r=this.context?this.context.isMounting:e,i=this.props.nodeRef?[r]:[ws.default.findDOMNode(this),r],a=i[0],o=i[1],s=this.getTimeouts(),c=r?s.appear:s.enter;if(!e&&!n||Wb.disabled){this.safeSetState({status:Xb},function(){t.props.onEntered(a)});return}this.props.onEnter(a,o),this.safeSetState({status:Yb},function(){t.props.onEntering(a,o),t.onTransitionEnd(c,function(){t.safeSetState({status:Xb},function(){t.props.onEntered(a,o)})})})},n.performExit=function(){var e=this,t=this.props.exit,n=this.getTimeouts(),r=this.props.nodeRef?void 0:ws.default.findDOMNode(this);if(!t||Wb.disabled){this.safeSetState({status:Jb},function(){e.props.onExited(r)});return}this.props.onExit(r),this.safeSetState({status:Zb},function(){e.props.onExiting(r),e.onTransitionEnd(n.exit,function(){e.safeSetState({status:Jb},function(){e.props.onExited(r)})})})},n.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},n.safeSetState=function(e,t){t=this.setNextCallback(t),this.setState(e,t)},n.setNextCallback=function(e){var t=this,n=!0;return this.nextCallback=function(r){n&&(n=!1,t.nextCallback=null,e(r))},this.nextCallback.cancel=function(){n=!1},this.nextCallback},n.onTransitionEnd=function(e,t){this.setNextCallback(t);var n=this.props.nodeRef?this.props.nodeRef.current:ws.default.findDOMNode(this),r=e==null&&!this.props.addEndListener;if(!n||r){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var i=this.props.nodeRef?[this.nextCallback]:[n,this.nextCallback],a=i[0],o=i[1];this.props.addEndListener(a,o)}e!=null&&setTimeout(this.nextCallback,e)},n.render=function(){var e=this.state.status;if(e===`unmounted`)return null;var t=this.props,n=t.children;t.in,t.mountOnEnter,t.unmountOnExit,t.appear,t.enter,t.exit,t.timeout,t.addEndListener,t.onEnter,t.onEntering,t.onEntered,t.onExit,t.onExiting,t.onExited,t.nodeRef;var r=Lm(t,[`children`,`in`,`mountOnEnter`,`unmountOnExit`,`appear`,`enter`,`exit`,`timeout`,`addEndListener`,`onEnter`,`onEntering`,`onEntered`,`onExit`,`onExiting`,`onExited`,`nodeRef`]);return b.createElement(Gb.Provider,{value:null},typeof n==`function`?n(e,r):b.cloneElement(b.Children.only(n),r))},t}(b.Component);Qb.contextType=Gb,Qb.propTypes={};function $b(){}Qb.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:$b,onEntering:$b,onEntered:$b,onExit:$b,onExiting:$b,onExited:$b},Qb.UNMOUNTED=qb,Qb.EXITED=Jb,Qb.ENTERING=Yb,Qb.ENTERED=Xb,Qb.EXITING=Zb;function ex(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function tx(e,t){var n=function(e){return t&&(0,b.isValidElement)(e)?t(e):e},r=Object.create(null);return e&&b.Children.map(e,function(e){return e}).forEach(function(e){r[e.key]=n(e)}),r}function nx(e,t){e||={},t||={};function n(n){return n in t?t[n]:e[n]}var r=Object.create(null),i=[];for(var a in e)a in t?i.length&&(r[a]=i,i=[]):i.push(a);var o,s={};for(var c in t){if(r[c])for(o=0;o<r[c].length;o++){var l=r[c][o];s[r[c][o]]=n(l)}s[c]=n(c)}for(o=0;o<i.length;o++)s[i[o]]=n(i[o]);return s}function rx(e,t,n){return n[t]==null?e.props[t]:n[t]}function ix(e,t){return tx(e.children,function(n){return(0,b.cloneElement)(n,{onExited:t.bind(null,n),in:!0,appear:rx(n,`appear`,e),enter:rx(n,`enter`,e),exit:rx(n,`exit`,e)})})}function ax(e,t,n){var r=tx(e.children),i=nx(t,r);return Object.keys(i).forEach(function(a){var o=i[a];if((0,b.isValidElement)(o)){var s=a in t,c=a in r,l=t[a],u=(0,b.isValidElement)(l)&&!l.props.in;c&&(!s||u)?i[a]=(0,b.cloneElement)(o,{onExited:n.bind(null,o),in:!0,exit:rx(o,`exit`,e),enter:rx(o,`enter`,e)}):!c&&s&&!u?i[a]=(0,b.cloneElement)(o,{in:!1}):c&&s&&(0,b.isValidElement)(l)&&(i[a]=(0,b.cloneElement)(o,{onExited:n.bind(null,o),in:l.props.in,exit:rx(o,`exit`,e),enter:rx(o,`enter`,e)}))}}),i}var ox=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},sx={component:`div`,childFactory:function(e){return e}},cx=function(e){Bb(t,e);function t(t,n){var r=e.call(this,t,n)||this;return r.state={contextValue:{isMounting:!0},handleExited:r.handleExited.bind(ex(r)),firstRender:!0},r}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(e,t){var n=t.children,r=t.handleExited;return{children:t.firstRender?ix(e,r):ax(e,n,r),firstRender:!1}},n.handleExited=function(e,t){var n=tx(this.props.children);e.key in n||(e.props.onExited&&e.props.onExited(t),this.mounted&&this.setState(function(t){var n=Im({},t.children);return delete n[e.key],{children:n}}))},n.render=function(){var e=this.props,t=e.component,n=e.childFactory,r=Lm(e,[`component`,`childFactory`]),i=this.state.contextValue,a=ox(this.state.children).map(n);return delete r.appear,delete r.enter,delete r.exit,t===null?b.createElement(Gb.Provider,{value:i},a):b.createElement(Gb.Provider,{value:i},b.createElement(t,r,a))},t}(b.Component);cx.propTypes={},cx.defaultProps=sx;var lx=[`bottom-center`,`bottom-left`,`bottom-right`,`top-center`,`top-left`,`top-right`];function ux(e,t){return e.reduce((e,n)=>(e[n.position||t].push(n),e),lx.reduce((e,t)=>(e[t]=[],e),{}))}var dx={left:`translateX(-100%)`,right:`translateX(100%)`,"top-center":`translateY(-100%)`,"bottom-center":`translateY(100%)`},fx={left:`translateX(0)`,right:`translateX(0)`,"top-center":`translateY(0)`,"bottom-center":`translateY(0)`};function px({state:e,maxHeight:t,position:n,transitionDuration:r}){let[i,a]=n.split(`-`),o=a===`center`?`${i}-center`:a,s={opacity:0,maxHeight:t,transform:dx[o],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`},c={opacity:1,transform:fx[o]},l={opacity:0,maxHeight:0,transform:dx[o]},u={entering:c,entered:c,exiting:l,exited:l};return{...s,...u[e]}}function mx(e,t){return typeof t==`number`?t:t===!1||e===!1?!1:e}var hx=(0,b.forwardRef)(({data:e,onHide:t,autoClose:n,...r},i)=>{let{autoClose:a,message:o,...s}=e,c=mx(n,e.autoClose),l=(0,b.useRef)(-1),u=()=>window.clearTimeout(l.current),d=()=>{t(e.id),u()},f=()=>{typeof c==`number`&&(l.current=window.setTimeout(d,c))};return(0,b.useEffect)(()=>{e.onOpen?.(e)},[]),(0,b.useEffect)(()=>(f(),u),[c]),(0,L.jsx)(kg,{...r,...s,onClose:d,ref:i,onMouseEnter:u,onMouseLeave:f,children:o})});hx.displayName=`@mantine/notifications/NotificationContainer`;var gx={root:`m_b37d9ac7`,notification:`m_5ed0edd0`},_x=Qb,vx={position:`bottom-right`,autoClose:4e3,transitionDuration:250,containerWidth:440,notificationMaxHeight:200,limit:5,zIndex:ct(`overlay`),store:jb,withinPortal:!0},yx=kn((e,{zIndex:t,containerWidth:n})=>({root:{"--notifications-z-index":t?.toString(),"--notifications-container-width":I(n)}})),bx=V((e,t)=>{let n=z(`Notifications`,vx,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,position:l,autoClose:u,transitionDuration:d,containerWidth:f,notificationMaxHeight:p,limit:m,zIndex:h,store:g,portalProps:_,withinPortal:v,...y}=n,x=xr(),S=Mb(g),C=Yt(),w=cn(),T=(0,b.useRef)({}),E=(0,b.useRef)(0),D=x.respectReducedMotion&&w?1:d,O=R({name:`Notifications`,classes:gx,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,vars:c,varsResolver:yx});(0,b.useEffect)(()=>{g?.updateState(e=>({...e,limit:m||5,defaultPosition:l}))},[m,l]),It(()=>{S.notifications.length>E.current&&setTimeout(()=>C(),0),E.current=S.notifications.length},[S.notifications]);let k=ux(S.notifications,l),A=lx.reduce((e,t)=>(e[t]=k[t].map(({style:e,...n})=>(0,L.jsx)(_x,{timeout:D,onEnter:()=>T.current[n.id].offsetHeight,nodeRef:{current:T.current[n.id]},children:r=>(0,L.jsx)(hx,{ref:e=>{e&&(T.current[n.id]=e)},data:n,onHide:e=>Pb(e,g),autoClose:u,...O(`notification`,{style:{...px({state:r,position:t,transitionDuration:D,maxHeight:p}),...e}})})},n.id)),e),{});return(0,L.jsxs)(Nl,{withinPortal:v,..._,children:[(0,L.jsx)(B,{...O(`root`),"data-position":`top-center`,ref:t,...y,children:(0,L.jsx)(cx,{children:A[`top-center`]})}),(0,L.jsx)(B,{...O(`root`),"data-position":`top-left`,...y,children:(0,L.jsx)(cx,{children:A[`top-left`]})}),(0,L.jsx)(B,{...O(`root`,{className:ze.classNames.fullWidth}),"data-position":`top-right`,...y,children:(0,L.jsx)(cx,{children:A[`top-right`]})}),(0,L.jsx)(B,{...O(`root`,{className:ze.classNames.fullWidth}),"data-position":`bottom-right`,...y,children:(0,L.jsx)(cx,{children:A[`bottom-right`]})}),(0,L.jsx)(B,{...O(`root`),"data-position":`bottom-left`,...y,children:(0,L.jsx)(cx,{children:A[`bottom-left`]})}),(0,L.jsx)(B,{...O(`root`),"data-position":`bottom-center`,...y,children:(0,L.jsx)(cx,{children:A[`bottom-center`]})})]})});bx.classes=gx,bx.displayName=`@mantine/notifications/Notifications`,bx.show=Rb.show,bx.hide=Rb.hide,bx.update=Rb.update,bx.clean=Rb.clean,bx.cleanQueue=Rb.cleanQueue,bx.updateState=Rb.updateState;var xx=class{max;cache;constructor(e=10){this.max=e,this.cache=new Map}clear(){this.cache.clear()}get(e){let t=this.cache.get(e);return t&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){this.cache.has(e)?this.cache.delete(e):this.cache.size>=this.max&&this.cache.delete(this.first()),this.cache.set(e,t)}delete(e){this.cache.delete(e)}keys(){return this.cache.keys()}first(){return this.cache.keys().next().value}},Sx=class{operator;child;constructor(e,t){this.operator=e,this.child=t}toString(){return`${this.operator}(${this.child.toString()})`}},Cx=class{operator;left;right;constructor(e,t,n){this.operator=e,this.left=t,this.right=n}toString(){return`(${this.left.toString()} ${this.operator} ${this.right.toString()})`}},wx=class{prefixParselets={};infixParselets={};registerInfix(e,t){return this.infixParselets[e]=t,this}registerPrefix(e,t){return this.prefixParselets[e]=t,this}prefix(e,t,n){return this.registerPrefix(e,{parse(e,r){return n(r,e.consumeAndParse(t))}})}infixLeft(e,t,n){return this.registerInfix(e,{parse(e,r,i){return n(r,i,e.consumeAndParse(t))},precedence:t})}construct(e){return new Tx(e,this.prefixParselets,this.infixParselets)}},Tx=class{tokens;prefixParselets;infixParselets;constructor(e,t,n){this.tokens=e,this.prefixParselets=t,this.infixParselets=n}hasMore(){return this.tokens.length>0}match(e){return this.peek()?.id===e?(this.consume(),!0):!1}consumeAndParse(e=1/0){let t=this.consume(),n=this.prefixParselets[t.id];if(!n)throw Error(`Parse error at "${t.value}" (line ${t.line}, column ${t.column}). No matching prefix parselet.`);let r=n.parse(this,t);for(;e>this.getPrecedence();){let e=this.consume();r=this.getInfixParselet(e).parse(this,r,e)}return r}getPrecedence(){let e=this.peek();if(!e)return 1/0;let t=this.getInfixParselet(e);return t?t.precedence:1/0}consume(e,t){if(!this.tokens.length)throw Error(`Cant consume unknown more tokens.`);if(e&&this.peek()?.id!==e){let t=this.peek();throw Error(`Expected ${e} but got "${t.id}" (${t.value}) at line ${t.line} column ${t.column}.`)}if(t&&this.peek()?.value!==t){let e=this.peek();throw Error(`Expected "${t}" but got "${e.value}" at line ${e.line} column ${e.column}.`)}return this.tokens.shift()}peek(){return this.tokens.length>0?this.tokens[0]:void 0}removeComments(){this.tokens=this.tokens.filter(e=>e.id!==`Comment`)}getInfixParselet(e){return this.infixParselets[e.id===`Symbol`?e.value:e.id]}};function Ex(e){if(e!==void 0)return Array.isArray(e)?e:[e]}var Dx=`http://hl7.org`,Ox=`ok`,kx=`created`,Ax=`gone`,jx=`not-modified`,Mx=`not-found`,Nx=`unauthorized`,Px=`forbidden`,Fx=`accepted`,Ix={resourceType:`OperationOutcome`,id:Ox,issue:[{severity:`information`,code:`informational`,details:{text:`All OK`}}]},Lx={resourceType:`OperationOutcome`,id:Mx,issue:[{severity:`error`,code:`not-found`,details:{text:`Not found`}}]},Rx={resourceType:`OperationOutcome`,id:Nx,issue:[{severity:`error`,code:`login`,details:{text:`Unauthorized`}}]},zx={...Rx,issue:[...Rx.issue,{severity:`error`,code:`expired`,details:{text:`Token expired`}}]},Bx={...Rx,issue:[...Rx.issue,{severity:`error`,code:`invalid`,details:{text:`Token not issued for this audience`}}]},Vx={resourceType:`OperationOutcome`,id:Px,issue:[{severity:`error`,code:`forbidden`,details:{text:`Forbidden`}}]};function Hx(e,t){return{resourceType:`OperationOutcome`,issue:[{severity:`error`,code:`invalid`,details:{text:e},...t?{expression:Ex(t)}:void 0}]}}function Ux(e,t,n,r){return{resourceType:`OperationOutcome`,issue:[{severity:`error`,code:n??`structure`,details:{text:e},...t?{expression:t}:void 0,...r?{diagnostics:r}:void 0}]}}function Wx(e){return e?.issue?.[0]?.details?.coding?.find(e=>e.system===`urn:ietf:rfc:3986`)?.code}function Gx(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 Kx(e){return typeof e==`object`&&!!e&&e.resourceType===`OperationOutcome`}function qx(e){return e.id===Ox||e.id===kx||e.id===jx||e.id===Fx}function Jx(e){return e.id===Ax}var Yx=class extends Error{outcome;constructor(e,t){super(Qx(e),t),this.name=`OperationOutcomeError`,this.outcome=e}};function Xx(e){return e instanceof Yx?e.outcome:Kx(e)?e:Hx(Zx(e))}function Zx(e){return e?typeof e==`string`?e:Gx(e)?e.message:Kx(e)?Qx(e):typeof e==`object`&&`code`in e&&typeof e.code==`string`?e.code:JSON.stringify(e):`Unknown error`}function Qx(e){let t=e.issue?.map($x)??[];return t.length>0?t.join(`; `):`Unknown error`}function $x(e){let t;return t=e.details?.text?e.diagnostics?`${e.details.text} (${e.diagnostics})`:e.details.text:e.diagnostics?e.diagnostics:`Unknown error`,e.expression?.length&&(t+=` (${e.expression.join(`, `)})`),t}function eS(e,t){let n=t.max&&t.max===2**53-1?1/0:t.max;return{path:e,description:``,type:t.type??[],min:t.min??0,max:n??1,isArray:!!n&&n>1,constraints:[]}}function tS(e){let t=Object.create(null);for(let[n,r]of Object.entries(e))t[n]={name:n,type:n,path:n,elements:Object.fromEntries(Object.entries(r.elements).map(([e,t])=>[e,eS(e,t)])),constraints:[],innerTypes:[]};return t}var nS={Element:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]}}},BackboneElement:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},modifierExtension:{max:9007199254740991,type:[{code:`Extension`}]}}},Address:{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`}]}}},Age:{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`}]}}},Annotation:{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`}]}}},Attachment:{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`}]}}},CodeableConcept:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},coding:{max:9007199254740991,type:[{code:`Coding`}]},text:{type:[{code:`string`}]}}},Coding:{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`}]}}},ContactDetail:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},name:{type:[{code:`string`}]},telecom:{max:9007199254740991,type:[{code:`ContactPoint`}]}}},ContactPoint:{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`}]}}},Contributor:{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`}]}}},Count:{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`}]}}},DataRequirement:{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`}]}}},DataRequirementCodeFilter:{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`}]}}},DataRequirementDateFilter:{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`}]}}},DataRequirementSort:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},path:{min:1,type:[{code:`string`}]},direction:{min:1,type:[{code:`code`}]}}},Distance:{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`}]}}},Dosage:{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`]}]}}},DosageDoseAndRate:{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`]}]}}},Duration:{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`}]}}},ElementDefinition:{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`}]}}},ElementDefinitionSlicingDiscriminator:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},type:{min:1,type:[{code:`code`}]},path:{min:1,type:[{code:`string`}]}}},ElementDefinitionSlicing:{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`}]}}},ElementDefinitionBase:{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`}]}}},ElementDefinitionType:{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`}]}}},ElementDefinitionExample:{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`}]}}},ElementDefinitionConstraint:{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`]}]}}},ElementDefinitionBinding:{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`]}]}}},ElementDefinitionMapping:{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`}]}}},Expression:{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`}]}}},Extension:{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`}]}}},HumanName:{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`}]}}},Identifier:{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`]}]}}},MarketingStatus:{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`}]}}},Meta:{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`}]}}},Money:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},value:{type:[{code:`decimal`}]},currency:{type:[{code:`code`}]}}},Narrative:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},status:{min:1,type:[{code:`code`}]},div:{min:1,type:[{code:`xhtml`}]}}},ParameterDefinition:{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`]}]}}},Period:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},start:{type:[{code:`dateTime`}]},end:{type:[{code:`dateTime`}]}}},Population:{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`}]}}},ProdCharacteristic:{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`}]}}},ProductShelfLife:{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`}]}}},Quantity:{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`}]}}},Range:{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`]}]}}},Ratio:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},numerator:{type:[{code:`Quantity`}]},denominator:{type:[{code:`Quantity`}]}}},Reference:{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`}]}}},RelatedArtifact:{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`]}]}}},SampledData:{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`}]}}},Signature:{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`}]}}},SubstanceAmount:{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`}]}}},SubstanceAmountReferenceRange:{elements:{id:{type:[{code:`string`}]},extension:{max:9007199254740991,type:[{code:`Extension`}]},lowLimit:{type:[{code:`Quantity`}]},highLimit:{type:[{code:`Quantity`}]}}},Timing:{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`}]}}},TimingRepeat:{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`}]}}},TriggerDefinition:{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`}]}}},UsageContext:{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`]}]}}},MoneyQuantity:{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`}]}}},SimpleQuantity:{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`}]}}},IdentityProvider:{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`}]},identitySource:{type:[{code:`code`}]},identityMappingMode:{type:[{code:`code`}]}}}};function rS(e){return new gS(e).parse()}var iS=tS(nS),aS=Object.create(null),oS=Object.create(null),sS={"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 cS(e){let t;return t=oS[e],t||=oS[e]=Object.create(null),t}function lS(e){let t=(Array.isArray(e)?e:e.entry?.map(e=>e.resource)??[]).filter(e=>e?.resourceType===`StructureDefinition`);Dw(t);for(let e of t)uS(e)}function uS(e){if(!e?.name)throw Error(`Failed loading StructureDefinition from bundle`);if(e.resourceType!==`StructureDefinition`)return;let t=rS(e),n=sS[e.url],r,i;n?(r=iS,i=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=iS,i=e.type):(r=cS(e.url),i=e.type),r[i]=t;for(let e of t.innerTypes)e.parentType=t,r[e.name]=e;aS[e.url]=t}function dS(e){return!!iS[e]}function fS(e,t){if(t){let n=cS(t)[e];if(n)return n}return iS[e]}function pS(e,t){let n=fS(e,t);if(!n)throw new Yx(Hx(`Unknown data type: `+e));return n}function mS(e){return!!aS[e]}function hS(e){return aS[e]}var gS=class{root;elements;elementIndex;index;resourceSchema;slicingContext;innerTypes;backboneContext;constructor(e){if(!e.snapshot?.element||e.snapshot.element.length===0)throw Error(`No snapshot defined for StructureDefinition '${e.name}'`);this.root=e.snapshot.element[0],this.elements=e.snapshot.element.slice(1),this.elementIndex=Object.create(null),this.index=0,this.resourceSchema={name:e.name,path:this.root.path,title:e.title,type:e.type,url:e.url,version:e.version,kind:e.kind,description:CS(e),elements:{},constraints:this.parseElementDefinition(this.root).constraints,innerTypes:[],summaryProperties:new Set,mandatoryProperties:new Set},this.innerTypes=[]}parse(){let e=this.next();for(;e;){if(e.sliceName)this.parseSliceStart(e);else if(e.id?.includes(`:`)){if(this.slicingContext?.current){let t=vS(e,this.slicingContext.path);this.slicingContext.current.elements[t]=this.parseElementDefinition(e)}}else{let t=this.parseElementDefinition(e);this.checkFieldEnter(e,t);let n=this.backboneContext;for(;n;){if(e.path?.startsWith(n.path+`.`)){n.type.elements[vS(e,n.path)]=t;break}n=n.parent}if(!n){let n=vS(e,this.root.path);e.isSummary&&this.resourceSchema.summaryProperties?.add(n.replace(`[x]`,``)),t.min>0&&this.resourceSchema.mandatoryProperties?.add(n.replace(`[x]`,``)),this.resourceSchema.elements[n]=t}this.checkFieldExit(e)}e=this.next()}return this.checkFieldExit(),this.innerTypes.length>0&&(this.resourceSchema.innerTypes=this.innerTypes),this.resourceSchema}checkFieldEnter(e,t){this.isInnerType(e)&&this.enterInnerType(e),this.slicingContext&&!bS(this.slicingContext.path,e?.path)&&(this.slicingContext=void 0),e.slicing&&!this.slicingContext&&this.enterSlice(e,t)}enterInnerType(e){for(;this.backboneContext&&!bS(this.backboneContext?.path,e.path);)this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;let t=Aw(e);this.backboneContext={type:{name:t,type:t,path:e.path,title:e.label,description:e.definition,elements:{},constraints:this.parseElementDefinition(e).constraints,innerTypes:[]},path:e.path,parent:bS(this.backboneContext?.path,e.path)?this.backboneContext:this.backboneContext?.parent}}enterSlice(e,t){SS(e)&&!this.peek()?.sliceName||(t.slicing={discriminator:(e.slicing?.discriminator??[]).map(e=>{if(e.type!==`value`&&e.type!==`pattern`&&e.type!==`type`)throw Error(`Unsupported slicing discriminator type: ${e.type}`);return{path:e.path,type:e.type}}),slices:[],ordered:e.slicing?.ordered??!1,rule:e.slicing?.rules},this.slicingContext={field:t.slicing,path:e.path??``})}checkFieldExit(e=void 0){if(this.backboneContext&&!bS(this.backboneContext.path,e?.path))if(this.backboneContext.parent)do this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;while(this.backboneContext&&!bS(this.backboneContext.path,e?.path));else this.innerTypes.push(this.backboneContext.type),this.backboneContext=void 0}next(){let e=this.peek();if(e)return this.index++,e}peek(){let e=this.elements[this.index];if(e){if(this.elementIndex[e.path??``]=e,e.contentReference){let t=e.contentReference.slice(e.contentReference.indexOf(`#`)+1),n=this.elementIndex[t];return n?{...n,id:e.id,path:e.path,min:e.min??n.min,max:e.max??n.max,base:{path:n.base?.path??t,min:e.base?.min??n.base?.min??n.min,max:e.base?.max??n.base?.max??n.max},contentReference:e.contentReference,definition:e.definition}:void 0}return e}}isInnerType(e){let t=this.peek();return!!(bS(e?.path,t?.path)&&e.type?.some(e=>[`BackboneElement`,`Element`].includes(e.code)))}parseSliceStart(e){if(!this.slicingContext)throw Error(`Invalid slice start before discriminator: ${e.sliceName} (${e.id})`);this.slicingContext.current={...this.parseElementDefinition(e),name:e.sliceName??``,definition:e.definition,elements:{}},this.slicingContext.field.slices.push(this.slicingContext.current)}parseElementDefinitionType(e){return(e.type??[]).map(t=>{let n;return(t.code===`BackboneElement`||t.code===`Element`)&&(n=Aw(e)),n||=gC(t,`http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type`)?.valueUrl,n||=t.code??``,{code:n,targetProfile:t.targetProfile,profile:t.profile}})}parseElementDefinition(e){let t=_S(e.max),n=e.base?.max?_S(e.base.max):t,r={type:`ElementDefinition`,value:e};return{description:e.definition||``,path:e.path||e.base?.path||``,min:e.min??0,max:t,isArray:n>1,constraints:(e.constraint??[]).map(e=>({key:e.key??``,severity:e.severity??`error`,expression:e.expression??``,description:e.human??``})),type:this.parseElementDefinitionType(e),fixed:xS(NS(r,`fixed[x]`)),pattern:xS(NS(r,`pattern[x]`)),binding:e.binding}}};function _S(e){return e===`*`?1/0:Number.parseInt(e,10)}function vS(e,t=``){return yS(e.path,t)}function yS(e,t){return e?t&&e.startsWith(t)?e.substring(t.length+1):e:``}function bS(e,t){return!e||!t?!1:t.startsWith(e+`.`)||t===e}function xS(e){return Array.isArray(e)&&e.length>0?e[0]:xC(e)?void 0:e}function SS(e){let t=e.slicing?.discriminator;return!!(e.type?.some(e=>e.code===`Extension`)&&t?.length===1&&t[0].type===`value`&&t[0].path===`url`)}function CS(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 wS(e,t,n){if(e===void 0)return[void 0];if(t===`$this`)return[e];let r=n?.withPath?TS:NS,[i,...a]=t.split(`.`),o=[r(e,i,n)];for(let e of a){let t=[];for(let i of o)if(Array.isArray(i))for(let a of i)t.push(r(a,e,n));else (n?.withPath&&i?.value!==void 0||!n?.withPath&&i!==void 0)&&t.push(r(i,e,n));o=t}return o}function TS(e,t,n){let r=e.path;return ES(NS(e,t,n),r,t)}function ES(e,t,n){let r=t?t+`.`:``;return e===void 0?{type:`undefined`,value:void 0,path:`${r}${n}`}:Array.isArray(e)?e.map((e,t)=>({...e,path:`${r}${n}[${t}]`})):{...e,path:`${r}${n}`}}new xx(1e3);var DS={canonical:/^\S*$/,code:/^[^\s]+( [^\s]+)*$/,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)?)?)?$/,id:/^[A-Za-z0-9\-.]{1,64}$/,instant:/^(\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))$/,markdown:/^[\r\n\t\u0020-\uFFFF]+$/,oid:/^urn:oid:[0-2](\.(0|[1-9]\d*))+$/,string:/^[\r\n\t\u0020-\uFFFF]+$/,time:/^([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?$/,uri:/^\S*$/,url:/^\S*$/,uuid:/^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,xhtml:/.*/};function OS(e,t,n,r){if(Array.isArray(e))return!1;let i;i=t.path===`$this`?n:(r??n.elements)[t.path];let a=n.type;switch(t.type){case`value`:case`pattern`:if(!e||!i)return!1;if(i.pattern)return DC(e,i.pattern);if(i.fixed)return wC(e,i.fixed);if(i.binding?.strength===`required`&&i.binding.valueSet)return!0;break;case`type`:return!e||!a?.length?!1:a.some(t=>t.code===e.type)}return!1}function kS(e){return[{type:X.boolean,value:e}]}function AS(e){return e==null?{type:`undefined`,value:void 0}:Number.isSafeInteger(e)?{type:X.integer,value:e}:typeof e==`number`?{type:X.decimal,value:e}:typeof e==`boolean`?{type:X.boolean,value:e}:typeof e==`string`?{type:X.string,value:e}:ZS(e)?{type:X.Quantity,value:e}:Bw(e)?{type:e.resourceType,value:e}:FC(e)?{type:X.CodeableConcept,value:e}:PC(e)?{type:X.Coding,value:e}:{type:X.BackboneElement,value:e}}function jS(e){return e.length===0?!1:!!e[0].value}function MS(e,t){if(e.length!==0){if(e.length===1&&(!t||e[0].type===t))return e[0];throw Error(`Expected singleton of type ${t}, but found ${JSON.stringify(e)}`)}}function NS(e,t,n){if(!e.value)return;let r=Rw(e.type,t,n?.profileUrl);return r?PS(e,t,r):IS(e,t)}function PS(e,t,n){let r=e.value,i=n.type;if(!i||i.length===0)return;let a,o=`undefined`,s,c=n.path.lastIndexOf(`.`),l=n.path.substring(c+1),u=l,d=!1;l.endsWith(`[x]`)&&(u=l.substring(0,l.length-3),d=!0);for(let e of i){let t=u;if(d&&(t+=VC(e.code)),a=r[t],s=r[`_`+t],a!==void 0||s!==void 0){o=e.code;break}}if(s)if(Array.isArray(a)){a=a.slice();for(let e=0;e<Math.max(a.length,s.length);e++)a[e]=tC(a[e],s[e])}else if(!a&&Array.isArray(s)){a=s.slice();for(let e=0;e<s.length;e++)a[e]=tC(void 0,s[e])}else a=tC(a,s);if(!xC(a))return(o===`Element`||o===`BackboneElement`)&&(o=n.type[0].code),Array.isArray(a)?a.map(e=>FS(e,o)):FS(a,o)}function FS(e,t){return t===`Resource`&&Bw(e)&&(t=e.resourceType),{type:t,value:e}}function IS(e,t){let n=e.value;if(!n||typeof n!=`object`)return;let r;if(t in n){let e=n[t];r=Array.isArray(e)?e.map(AS):AS(e)}else{let e=t.endsWith(`[x]`)?t.substring(0,t.length-3):t;for(let t of Object.values(X)){let i=e+VC(t);if(i in n){let e=n[i];r=Array.isArray(e)?e.map(e=>({type:t,value:e})):{type:t,value:e};break}}}if(Array.isArray(r)){if(r.length===0||xC(r[0]))return}else if(xC(r))return;return r}function LS(e){let t=[];for(let n of e){let e=!1;for(let r of t)if(jS(VS(n,r))){e=!0;break}e||t.push(n)}return t}function RS(e){return kS(!jS(e))}function zS(e,t){return e.length===0||t.length===0?[]:e.length===t.length?kS(e.every((e,n)=>jS(VS(e,t[n])))):kS(!1)}function BS(e,t){return e.length===0||t.length===0?[]:e.length===t.length?kS(e.some((e,n)=>!jS(VS(e,t[n])))):kS(!0)}function VS(e,t){let n=e.value?.valueOf(),r=t.value?.valueOf();return typeof n==`number`&&typeof r==`number`?kS(Math.abs(n-r)<1e-8):ZS(n)&&ZS(r)?kS(QS(n,r)):kS(typeof n==`object`&&typeof r==`object`?$S(e,t):n===r)}function HS(e,t){return e.length===0&&t.length===0?kS(!0):e.length===t.length?(e.sort(WS),t.sort(WS),kS(e.every((e,n)=>jS(US(e,t[n]))))):kS(!1)}function US(e,t){let{type:n,value:r}=e,{type:i,value:a}=t,o=r?.valueOf(),s=a?.valueOf();return typeof o==`number`&&typeof s==`number`?kS(Math.abs(o-s)<.01):ZS(o)&&ZS(s)?kS(QS(o,s)):kS(n===`Coding`&&i===`Coding`?typeof o!=`object`||typeof s!=`object`?!1:o.code===s.code&&o.system===s.system:typeof o==`object`&&typeof s==`object`?$S({...o,id:void 0},{...s,id:void 0}):typeof o==`string`&&typeof s==`string`?o.toLowerCase()===s.toLowerCase():o===s)}function WS(e,t){let 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 GS(e,t){let{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 KS(n);case`DateTime`:return qS(n);case`Time`:return typeof n==`string`&&!!/^T\d/.exec(n);case`Period`:return JS(n);case`Quantity`:return ZS(n);default:return e.type===r||typeof n==`object`&&n?.resourceType===r}}function KS(e){return typeof e==`string`&&!!DS.date.exec(e)}function qS(e){return typeof e==`string`&&!!DS.dateTime.exec(e)}function JS(e){return!!(e&&typeof e==`object`&&(`start`in e&&qS(e.start)||`end`in e&&qS(e.end)))}function YS(e){if(KS(e)||qS(e))return{start:XS(e,`0000-01-01T00:00:00.000`),end:XS(e,`xxxx-12-31T23:59:59.999`)};if(JS(e))return{start:e.start?XS(e.start,`0000-01-01T00:00:00.000`):void 0,end:e.end?XS(e.end,`xxxx-12-31T23:59:59.999`):void 0}}function XS(e,t){let n=`Z`,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));let i=e+t.substring(e.length)+n;return new Date(i).toISOString()}function ZS(e){return!!(e&&typeof e==`object`&&`value`in e&&typeof e.value==`number`)}function QS(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 $S(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(eC(n)&&eC(i)){if(!$S(n,i))return!1}else if(n!==i)return!1}return!0}function eC(e){return typeof e==`object`&&!!e}function tC(e,t){if(t){if(typeof t!=`object`)throw Error(`Primitive extension must be an object`);return nC(e??{},t)}return e}function nC(e,t){return delete t.__proto__,delete t.constructor,Object.assign(e,t)}function rC(e,t){return Bw(e,t)&&`id`in e&&typeof e.id==`string`}function iC(e){let t=aC(e)??`undefined/undefined`,n=lC(e);return n===t?{reference:t}:{reference:t,display:n}}function aC(e){if(Vw(e))return e.reference;if(rC(e))return`${e.resourceType}/${e.id}`}function oC(e){if(e)return Vw(e)?e.reference.split(`/`)[1]:e.id}function sC(e){if(e)if(e.accounts&&e.account){let t=e.accounts;return t.some(t=>t.reference===e.account?.reference)?t:[e.account,...t]}else return Ex(e.accounts??e.account)}function cC(e){return e.resourceType===`Patient`||e.resourceType===`Practitioner`||e.resourceType===`RelatedPerson`}function lC(e){if(cC(e)){let t=uC(e);if(t)return t}if(e.resourceType===`Device`){let t=dC(e);if(t)return t}if(e.resourceType===`MedicationRequest`&&e.medicationCodeableConcept)return bw(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]),FC(t))return bw(t);if(IC(t))return t.text}return aC(e)??``}function uC(e){let t=e.name;if(t&&t.length>0)return sw(t[0])}function dC(e){let t=e.deviceName;if(t&&t.length>0)return t[0].name}function fC(e){if(!(`photo`in e))return;let t=e.photo;if(t)if(Array.isArray(t))for(let e of t){let t=pC(e);if(t)return t}else return pC(t)}function pC(e){if(e.url&&e.contentType?.startsWith(`image/`))return e.url}function mC(e,t){let n=new Date(e);n.setUTCHours(0,0,0,0);let r=t?new Date(t):new Date;r.setUTCHours(0,0,0,0);let i=n.getUTCFullYear(),a=n.getUTCMonth(),o=n.getUTCDate(),s=r.getUTCFullYear(),c=r.getUTCMonth(),l=r.getUTCDate(),u=s-i;(c<a||c===a&&l<o)&&u--;let d=s*12+c-(i*12+a);l<o&&d--;let f=Math.floor((r.getTime()-n.getTime())/(1e3*60*60*24));return{years:u,months:d,days:f}}function hC(e,t){let{years:n,months:r,days:i}=mC(e,t);return n>=2?n.toString().padStart(3,`0`)+`Y`:r>=1?r.toString().padStart(3,`0`)+`M`:i.toString().padStart(3,`0`)+`D`}function gC(e,...t){let n=e;for(let e=0;e<t.length&&n;e++)n=(n?.extension)?.find(n=>n.url===t[e]);return n}function _C(e,t){let n=vC(e);return JSON.stringify(n,null,t?2:void 0)??``}function vC(e){if(!(e==null||e===``))return typeof e==`object`?Array.isArray(e)?yC(e):bC(e):e}function yC(e){let t=e.length;if(t===0)return;let n,r=0;for(let i=0;i<t;i++){let t=e[i],a=vC(t);a!==t&&!n&&(n=Array.from(e)),a===void 0?n&&(n[i]=null):(n&&(n[i]=a),r++)}if(r!==0)return n??e}function bC(e){let t,n=0;for(let r in e){let i=e[r],a=vC(i);a!==i&&!t&&(t={...e}),a===void 0?t&&delete t[r]:(t&&(t[r]=a),n++)}if(n!==0)return t??e}function xC(e){if(e==null)return!0;let t=typeof e;return t===`string`||t===`object`?!SC(e):!1}function SC(e){if(e==null)return!1;let t=typeof e;return t===`string`&&e!==``||t===`object`&&(`length`in e&&e.length>0||Object.keys(e).length>0)}function CC(e){if(!e)return;let t=e.length-1;for(;t>=0&&xC(e[t]);)t--;return t>=0?e.slice(0,t+1):void 0}function wC(e,t,n){return e===t||xC(e)&&xC(t)?!0:xC(e)||xC(t)?!1:Array.isArray(e)&&Array.isArray(t)?TC(e,t):Array.isArray(e)||Array.isArray(t)?!1:MC(e)&&MC(t)?EC(e,t,n):!1}function TC(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!wC(e[n],t[n]))return!1;return!0}function EC(e,t,n){let r=new Set;for(let t of Object.keys(e))r.add(t);for(let e of Object.keys(t))r.add(e);n===`meta`&&(r.delete(`versionId`),r.delete(`lastUpdated`),r.delete(`author`));for(let n of r){let r=e[n],i=t[n];if(!wC(r,i,n))return!1}return!0}function DC(e,t){return xC(e)?!0:xC(t)?!1:Array.isArray(e)&&Array.isArray(t)?OC(e,t):Array.isArray(e)||Array.isArray(t)?!1:MC(e)&&MC(t)?kC(e,t):MC(e)||MC(t)?!1:e===t}function OC(e,t){return t.every(t=>e.some(e=>DC(e,t)))}function kC(e,t){return Object.entries(t).every(([t,n])=>t in e&&DC(e[t],n))}function AC(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function jC(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 MC(e){return typeof e==`object`&&!!e}function NC(e){return typeof e==`string`}function PC(e){return MC(e)&&`code`in e&&typeof e.code==`string`}function FC(e){return MC(e)&&`coding`in e&&Array.isArray(e.coding)&&e.coding.every(PC)}function IC(e){return MC(e)&&`text`in e&&typeof e.text==`string`}var LC=[];for(let e=0;e<256;e++)LC.push(e.toString(16).padStart(2,`0`));function RC(e){let t=BC(e),n=new Uint8Array(t),r=Array(n.length);for(let e=0;e<n.length;e++)r[e]=LC[n[e]];return r.join(``)}function zC(e){let t=BC(e),n=new Uint8Array(t),r=Array(n.length);for(let e=0;e<n.length;e++)r[e]=String.fromCodePoint(n[e]);return window.btoa(r.join(``))}function BC(e){return ArrayBuffer.isView(e)?e.buffer:e}function VC(e){return e?e.charAt(0).toUpperCase()+e.substring(1):``}function HC(e){return e.length>0&&e.startsWith(e[0].toUpperCase())}function UC(e,t){let n=e+`.`;if(t.startsWith(n))return t.slice(n.length)}function WC(e,t){return e.coding?.find(e=>e.system===t)?.code}var GC=(e,t)=>new Promise((n,r)=>{t?.signal?.throwIfAborted();let i=setTimeout(n,e);t?.signal?.addEventListener(`abort`,()=>{clearTimeout(i),r(t.signal?.reason)},{once:!0})});function KC(e,t,n){let r=[];for(let i=0;i<n-1;i++){let n=e.indexOf(t);if(n<0)break;r.push(e.slice(0,n)),e=e.slice(n+t.length)}return r.push(e),r}function qC(e){let t,n=!1;return function(){return n||=(t=e(),!0),t}}function JC(e,t){return e?(e.push(t),e):[t]}function YC(e){return e.sort((e,t)=>e.localeCompare(t))}function XC(e){return e.endsWith(`/`)?e:e+`/`}function ZC(e){return e.startsWith(`/`)?e.slice(1):e}function QC(e,t){return new URL(ZC(t),XC(e.toString())).toString()}function $C(e,t){return QC(e,t).toString().replace(`http://`,`ws://`).replace(`https://`,`wss://`)}function ew(e){return typeof e==`object`&&!Array.isArray(e)&&!(e instanceof URLSearchParams)&&(e=Object.fromEntries(Object.entries(e).filter(e=>e[1]!==void 0))),new URLSearchParams(e).toString()}function tw(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 nw(e,t){if(e?.meta?.profile?.includes(t)){let n=e.meta.profile.indexOf(t);e.meta.profile.splice(n,1)}return e}var rw=Object.freeze([]);function iw(e){if(!e)return``;switch(e.type){case`Address`:return ow(e.value);case`CodeableConcept`:return bw(e.value);case`Coding`:return xw(e.value);case`ContactPoint`:return e.value.value;case`HumanName`:return sw(e.value);case`Quantity`:return vw(e.value);case`Reference`:return aw(e.value);default:return e.value?.toString()??``}}function aw(e){return e?e.display??e.reference??_C(e):``}function ow(e,t){if(!e)return``;let n=[];if(e.line&&n.push(...e.line),e.city||e.state||e.postalCode){let t=[];e.city&&t.push(e.city),e.state&&t.push(e.state),e.postalCode&&t.push(e.postalCode),n.push(t.join(`, `))}return e.use&&(t?.all||t?.use)&&n.push(`[`+e.use+`]`),n.join(t?.lineSeparator??`, `).trim()}function sw(e,t){if(!e)return``;let 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){let t=Cw(e.text);if(t)return t}return n.join(` `).trim()}function cw(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function lw(e,t,n){if(!e)return``;let[r=0,i=0,a=0]=e.split(`:`).map(Number),o=new Date(Date.UTC(1970,0,1,r,i,a));return cw(o)?new Intl.DateTimeFormat(t,{hour:`numeric`,minute:`2-digit`,second:a===0?void 0:`numeric`,...n,timeZone:`UTC`}).format(o):``}function uw(e,t,n){if(!e)return``;let r=new Date(e);return cw(r)?r.toLocaleString(t,n):``}function dw(e,t,n){return!e||!e.start&&!e.end?``:uw(e.start,t,n)+` - `+uw(e.end,t,n)}var fw={s:`every second`,min:`every minute`,h:`hourly`,d:`daily`,wk:`weekly`,mo:`monthly`,a:`annually`},pw={s:`second`,min:`minute`,h:`hour`,d:`day`,wk:`week`,mo:`month`,a:`year`},mw={s:`seconds`,min:`minutes`,h:`hours`,d:`days`,wk:`weeks`,mo:`months`,a:`years`};function hw(e){if(!e)return``;let t=[];return gw(t,e.repeat),e.event&&t.push(e.event.map(e=>uw(e)).join(`, `)),VC(t.join(` `).trim())}function gw(e,t){if(!t?.periodUnit)return;let n=t.frequency??1,r=t.period??1,i=t.periodUnit;n===1&&r===1?e.push(fw[i]):(n===1?e.push(`once`):e.push(n+` times`),r===1?e.push(`per `+pw[i]):e.push(`per `+r+` `+mw[i])),t.dayOfWeek&&e.push(`on `+t.dayOfWeek.map(VC).join(`, `)),t.timeOfDay&&e.push(`at `+t.timeOfDay.map(e=>lw(e)).join(`, `))}function _w(e,t,n=!1){if(n&&t===void 0)throw Error(`Precision must be specified for exclusive ranges`);let r=e?.low&&{...e.low,comparator:void 0},i=e?.high&&{...e.high,comparator:void 0};return r?.value===void 0&&i?.value===void 0?``:r?.value!==void 0&&i?.value===void 0?n&&t!==void 0?(r.value=Tw(r.value,t),`> ${vw(r,t)}`):`>= ${vw(r,t)}`:r?.value===void 0&&i?.value!==void 0?n&&t!==void 0?(i.value=ww(i.value,t),`< ${vw(i,t)}`):`<= ${vw(i,t)}`:(r?.unit===i?.unit&&delete r?.unit,`${vw(r,t)} - ${vw(i,t)}`)}function vw(e,t){if(!e)return``;let n=[];return e.comparator&&(n.push(e.comparator),n.push(` `)),e.value!==void 0&&(t===void 0?n.push(e.value):n.push(e.value.toFixed(t))),e.unit&&(e.unit!==`%`&&n.at(-1)!==` `&&n.push(` `),n.push(e.unit)),n.join(``).trim()}function yw(e){return e?.value===void 0?``:e.value.toLocaleString(void 0,{style:`currency`,currency:e.currency??`USD`,currencyDisplay:`narrowSymbol`})}function bw(e){return e?Cw(e.text)||(e.coding?e.coding.map(e=>xw(e)).join(`, `):``):``}function xw(e,t){let n=Cw(e?.display);if(n){let r=t?Cw(e?.code):void 0;return`${n}${r?` (`+r+`)`:``}`}return Cw(e?.code)??``}function Sw(e){if(!e)return``;let t=[];if(e.valueQuantity)t.push(vw(e.valueQuantity));else if(e.valueCodeableConcept)t.push(bw(e.valueCodeableConcept));else{let n=Cw(e.valueString);n&&t.push(n)}return`component`in e&&t.push(e.component.map(e=>Sw(e)).join(` / `)),t.join(` / `).trim()}function Cw(e){return typeof e==`string`?e:void 0}function ww(e,t,n=1){return(Ew(e,t)+n)*10**-t}function Tw(e,t,n=1){return(Ew(e,t)-n)*10**-t}function Ew(e,t){return t===void 0?e:Math.round(e*10**t)}var X={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`,Element:`Element`,ElementDefinition:`ElementDefinition`,Expression:`Expression`,Extension:`Extension`,HumanName:`HumanName`,Identifier:`Identifier`,MarketingStatus:`MarketingStatus`,Meta:`Meta`,Money:`Money`,MoneyQuantity:`MoneyQuantity`,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`,SimpleQuantity:`SimpleQuantity`,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`,xhtml:`xhtml`};function Dw(e){let t=Array.isArray(e)?e:e.entry?.map(e=>e.resource)??[];for(let e of t)e?.resourceType===`StructureDefinition`&&e.kind===`resource`&&Ow(e.type)}function Ow(e){let t=Hw.types[e];return t||(t={searchParamsDetails:{}},Hw.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`},_project:{base:[e],code:`_project`,type:`token`,expression:e+`.meta.project`}}),t}function kw(e){for(let t of e.base??rw){let n=Ow(t);n.searchParams||={},n.searchParams[e.code]=e}}function Aw(e){let t=e.type?.[0]?.code;return t===`BackboneElement`||t===`Element`?jw((e.base?.path??e.path)?.split(`.`)):t}function jw(e){return e.length===1?e[0]:e.map(VC).join(``)}function Mw(e){return Hw.types[e]?.searchParams}function Nw(e,t){return Hw.types[e]?.searchParams?.[t]}function Pw(e){return Fw(e.replaceAll(`[x]`,``).split(`.`).pop())}function Fw(e){let t;return t=e.length<100?e.match(/[A-Z]+(?![a-z])|[A-Z]?[a-z]+|\d+/g)??[]:e.split(/(?=[A-Z])/),t.map(Lw).join(` `).replace(`_`,` `).replaceAll(/\s+/g,` `)}var Iw=new Set([`CDS`,`ID`,`IP`,`PKCE`,`JWKS`,`URI`,`URL`,`OMB`,`UDI`]);function Lw(e){let t=e.toUpperCase();return e===t?e:Iw.has(t)?t:t.charAt(0)+e.slice(1)}function Rw(e,t,n){let r=fS(e,n);if(r)return zw(r.elements,t)}function zw(e,t){let n=e[t]??e[t+`[x]`];if(n)return n;for(let n=0;n<t.length;n++){let r=t[n];if(r>=`A`&&r<=`Z`){let r=e[t.slice(0,n)+`[x]`];if(r)return r}}}function Bw(e,t){return!(!e||typeof e!=`object`||!(`resourceType`in e)||t&&e.resourceType!==t)}function Vw(e,t){return e&&typeof e==`object`&&`reference`in e&&typeof e.reference==`string`?t?e.reference.match(RegExp(`^${t}(/|\\?)`))!==null:!0:!1}var Hw={types:{}};function Uw(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}}var Ww=()=>[],Gw={empty:(e,t)=>kS(t.every(e=>xC(e.value))),hasValue:(e,t)=>kS(t.length!==0),exists:(e,t,n)=>kS(n?t.some(t=>jS(n.eval(e,[t]))):t.length>0&&t.every(e=>!xC(e.value))),all:(e,t,n)=>kS(t.every(t=>jS(n.eval(e,[t])))),allTrue:(e,t)=>{for(let e of t)if(!e.value)return kS(!1);return kS(!0)},anyTrue:(e,t)=>{for(let e of t)if(e.value)return kS(!0);return kS(!1)},allFalse:(e,t)=>{for(let e of t)if(e.value)return kS(!1);return kS(!0)},anyFalse:(e,t)=>{for(let e of t)if(!e.value)return kS(!0);return kS(!1)},subsetOf:(e,t,n)=>{if(t.length===0)return kS(!0);let r=n.eval(e,Yw(e));return r.length===0?kS(!1):kS(t.every(e=>r.some(t=>t.value===e.value)))},supersetOf:(e,t,n)=>{let r=n.eval(e,Yw(e));return r.length===0?kS(!0):t.length===0?kS(!1):kS(r.every(e=>t.some(t=>t.value===e.value)))},count:(e,t)=>[{type:X.integer,value:t.length}],distinct:(e,t)=>{let n=[];for(let e of t)n.some(t=>t.value===e.value)||n.push(e);return n},isDistinct:(e,t)=>kS(t.length===Gw.distinct(e,t).length),where:(e,t,n)=>t.filter(t=>jS(n.eval(e,[t]))),select:(e,t,n)=>t.flatMap(t=>n.eval({parent:e,variables:{$this:t}},[t])),repeat:Ww,ofType:(e,t,n)=>t.filter(e=>e.type===n.name),single:(e,t)=>{if(t.length>1)throw 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(-1,t.length),tail:(e,t)=>t.length===0?[]:t.slice(1,t.length),skip:(e,t,n)=>{let r=n.eval(e,t)[0]?.value;if(typeof r!=`number`)throw TypeError(`Expected a number for skip(num)`);return r>=t.length?[]:r<=0?t:t.slice(r,t.length)},take:(e,t,n)=>{let r=n.eval(e,t)[0]?.value;if(typeof r!=`number`)throw TypeError(`Expected a number for take(num)`);return r<=0?[]:t.slice(0,r)},intersect:(e,t,n)=>{if(!n)return t;let r=n.eval(e,Yw(e)),i=[];for(let e of t)!i.some(t=>t.value===e.value)&&r.some(t=>t.value===e.value)&&i.push(e);return i},exclude:(e,t,n)=>{if(!n)return t;let r=n.eval(e,Yw(e)),i=[];for(let e of t)r.some(t=>t.value===e.value)||i.push(e);return i},union:(e,t,n)=>{if(!n)return t;let r=n.eval(e,Yw(e));return LS([...t,...r])},combine:(e,t,n)=>{if(!n)return t;let r=n.eval(e,Yw(e));return[...t,...r]},htmlChecks:(e,t,n)=>[AS(!0)],iif:(e,t,n,r,i)=>{let a=n.eval(e,t);if(a.length>1||a.length===1&&typeof a[0].value!=`boolean`)throw Error(`Expected criterion to evaluate to a Boolean`);return jS(a)?r.eval(e,t):i?i.eval(e,t):[]},toBoolean:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);if(typeof n==`boolean`)return[{type:X.boolean,value:n}];if(typeof n==`number`&&(n===0||n===1))return kS(!!n);if(typeof n==`string`){let e=n.toLowerCase();if([`true`,`t`,`yes`,`y`,`1`,`1.0`].includes(e))return kS(!0);if([`false`,`f`,`no`,`n`,`0`,`0.0`].includes(e))return kS(!1)}return[]},convertsToBoolean:(e,t)=>t.length===0?[]:kS(Gw.toBoolean(e,t).length===1),toInteger:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);return typeof n==`number`?[{type:X.integer,value:n}]:typeof n==`string`&&/^[+-]?\d+$/.exec(n)?[{type:X.integer,value:Number.parseInt(n,10)}]:typeof n==`boolean`?[{type:X.integer,value:+!!n}]:[]},convertsToInteger:(e,t)=>t.length===0?[]:kS(Gw.toInteger(e,t).length===1),toDate:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);return typeof n==`string`&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:X.date,value:Uw(n)}]:[]},convertsToDate:(e,t)=>t.length===0?[]:kS(Gw.toDate(e,t).length===1),toDateTime:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);return typeof n==`string`&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:X.dateTime,value:Uw(n)}]:[]},convertsToDateTime:(e,t)=>t.length===0?[]:kS(Gw.toDateTime(e,t).length===1),toDecimal:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);return typeof n==`number`?[{type:X.decimal,value:n}]:typeof n==`string`&&/^-?\d{1,9}(\.\d{1,9})?$/.exec(n)?[{type:X.decimal,value:Number.parseFloat(n)}]:typeof n==`boolean`?[{type:X.decimal,value:+!!n}]:[]},convertsToDecimal:(e,t)=>t.length===0?[]:kS(Gw.toDecimal(e,t).length===1),toQuantity:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);return ZS(n)?[{type:X.Quantity,value:n}]:typeof n==`number`?[{type:X.Quantity,value:{value:n,unit:`1`}}]:typeof n==`string`&&/^-?\d{1,9}(\.\d{1,9})?/.exec(n)?[{type:X.Quantity,value:{value:Number.parseFloat(n),unit:`1`}}]:typeof n==`boolean`?[{type:X.Quantity,value:{value:+!!n,unit:`1`}}]:[]},convertsToQuantity:(e,t)=>t.length===0?[]:kS(Gw.toQuantity(e,t).length===1),toString:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);return n==null?[]:ZS(n)?[{type:X.string,value:`${n.value} '${n.unit}'`}]:[{type:X.string,value:n.toString()}]},convertsToString:(e,t)=>t.length===0?[]:kS(Gw.toString(e,t).length===1),toTime:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Jw(t,1);if(typeof n==`string`){let e=/^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(n);if(e)return[{type:X.time,value:Uw(`T`+e[1])}]}return[]},convertsToTime:(e,t)=>t.length===0?[]:kS(Gw.toTime(e,t).length===1),indexOf:(e,t,n)=>Kw((e,t)=>e.indexOf(t),e,t,n),substring:(e,t,n,r)=>Kw((e,t,n)=>{let r=t,i=n?r+n:e.length;return r<0||r>=e.length?void 0:e.substring(r,i)},e,t,n,r),startsWith:(e,t,n)=>Kw((e,t)=>e.startsWith(t),e,t,n),endsWith:(e,t,n)=>Kw((e,t)=>e.endsWith(t),e,t,n),contains:(e,t,n)=>Kw((e,t)=>e.includes(t),e,t,n),upper:(e,t)=>Kw(e=>e.toUpperCase(),e,t),lower:(e,t)=>Kw(e=>e.toLowerCase(),e,t),replace:(e,t,n,r)=>Kw((e,t,n)=>e.replaceAll(t,n),e,t,n,r),matches:(e,t,n)=>Kw((e,t)=>!!new RegExp(t).exec(e),e,t,n),replaceMatches:(e,t,n,r)=>Kw((e,t,n)=>e.replaceAll(new RegExp(t,`g`),n.replaceAll(/\$\{(\w+)\}/g,`$<$1>`)),e,t,n,r),length:(e,t)=>Kw(e=>e.length,e,t),toChars:(e,t)=>Kw(e=>e?e.split(``):void 0,e,t),encode:Ww,decode:Ww,escape:Ww,unescape:Ww,trim:Ww,split:Ww,join:(e,t,n)=>{let r=n?.eval(e,Yw(e))[0]?.value??``;if(typeof r!=`string`)throw TypeError(`Separator must be a string.`);return[{type:X.string,value:t.map(e=>e.value?.toString()??``).join(r)}]},abs:(e,t)=>qw(Math.abs,e,t),ceiling:(e,t)=>qw(Math.ceil,e,t),exp:(e,t)=>qw(Math.exp,e,t),floor:(e,t)=>qw(Math.floor,e,t),ln:(e,t)=>qw(Math.log,e,t),log:(e,t,n)=>qw((e,t)=>Math.log(e)/Math.log(t),e,t,n),power:(e,t,n)=>qw(Math.pow,e,t,n),round:(e,t,...n)=>qw((e,t=0)=>{if(typeof t!=`number`||t<0)throw Error(`Invalid precision provided to round()`);let n=10**t;return Math.round(e*n)/n},e,t,...n),sqrt:(e,t)=>qw(Math.sqrt,e,t),truncate:(e,t)=>qw(e=>Math.trunc(e),e,t),children:Ww,descendants:Ww,trace:(e,t,n)=>t,now:()=>[{type:X.dateTime,value:new Date().toISOString()}],timeOfDay:()=>[{type:X.time,value:new Date().toISOString().substring(11)}],today:()=>[{type:X.date,value:new Date().toISOString().substring(0,10)}],between:(e,t,n,r,i)=>{let a=Gw.toDateTime(e,n.eval(e,t));if(a.length===0)throw Error(`Invalid start date`);let o=Gw.toDateTime(e,r.eval(e,t));if(o.length===0)throw Error(`Invalid end date`);let s=i.eval(e,t)[0]?.value;if(s!==`years`&&s!==`months`&&s!==`days`)throw Error(`Invalid units`);let c=mC(a[0].value,o[0].value);return[{type:X.Quantity,value:{value:c[s],unit:s}}]},is:(e,t,n)=>{let r=``;return n instanceof Qw?r=n.name:n instanceof sT&&(r=n.left.name+`.`+n.right.name),r?t.map(e=>({type:X.boolean,value:GS(e,r)})):[]},not:(e,t)=>Gw.toBoolean(e,t).map(e=>({type:X.boolean,value:!e.value})),resolve:(e,t)=>t.map(e=>{let t=e.value,n;if(typeof t==`string`)n=t;else if(typeof t==`object`){let e=t;if(e.resource)return AS(e.resource);e.reference?n=e.reference:e.type&&e.identifier&&(n=`${e.type}?identifier=${e.identifier.system}|${e.identifier.value}`)}if(n?.includes(`?`)){let[e]=n.split(`?`);return{type:e,value:{resourceType:e}}}if(n?.includes(`/`)){let[e,t]=n.split(`/`);return{type:e,value:{resourceType:e,id:t}}}return{type:X.BackboneElement,value:void 0}}).filter(e=>!!e.value),as:(e,t,n)=>{let r=n.name,i=MS(t,r);return i?[i]:[]},type:(e,t)=>t.map(({value:e})=>typeof e==`boolean`?{type:X.BackboneElement,value:{namespace:`System`,name:`Boolean`}}:typeof e==`number`?{type:X.BackboneElement,value:{namespace:`System`,name:`Integer`}}:Bw(e)?{type:X.BackboneElement,value:{namespace:`FHIR`,name:e.resourceType}}:{type:X.BackboneElement,value:null}),conformsTo:(e,t,n)=>{let r=n.eval(e,t)[0].value;if(!r.startsWith(`http://hl7.org/fhir/StructureDefinition/`))throw Error(`Expected a StructureDefinition URL`);let i=r.replace(`http://hl7.org/fhir/StructureDefinition/`,``);return t.map(e=>({type:X.boolean,value:e.value?.resourceType===i}))},getResourceKey:(e,t)=>{let n=t[0].value;return n?.id?[{type:X.id,value:n.id}]:[]},getReferenceKey:(e,t,n)=>{let r=t[0].value;if(!r?.reference)return[];let i=``;return n instanceof Qw&&(i=n.name),i&&!r.reference.startsWith(i+`/`)?[]:[{type:X.id,value:oC(r)}]},extension:(e,t,n)=>{let r=n.eval(e,t)[0].value,i=t?.[0]?.value;if(i){let e=gC(i,r);if(e)return[{type:X.Extension,value:e}]}return[]}};function Kw(e,t,n,...r){if(n.length===0)return[];let[{value:i}]=Jw(n,1);if(typeof i!=`string`)throw TypeError(`String function cannot be called with non-string`);let a=e(i,...r.map(e=>e?.eval(t,n)[0]?.value));return a===void 0?[]:Array.isArray(a)?a.map(AS):[AS(a)]}function qw(e,t,n,...r){if(n.length===0)return[];let[{value:i}]=Jw(n,1),a=ZS(i),o=a?i.value:i;if(typeof o!=`number`)throw TypeError(`Math function cannot be called with non-number`);let s=e(o,...r.map(e=>e.eval(t,n)[0]?.value));return[{type:a?X.Quantity:n[0].type,value:a?{...i,value:s}:s}]}function Jw(e,t){if(e.length!==t)throw Error(`Expected ${t} arguments`);for(let t of e)if(t==null)throw Error(`Expected non-null argument`);return e}function Yw(e){let t=e;for(;t.parent?.variables.$this;)t=t.parent;return[t.variables.$this]}var Xw=class{original;child;constructor(e,t){this.original=e,this.child=t}eval(e,t){try{if(t.length>0){let n=[];for(let r of t)n.push(this.child.eval({parent:e,variables:{$this:r}},[r]));return n.flat()}else return this.child.eval(e,[])}catch(e){throw Error(`FhirPathError on "${this.original}": ${e}`,{cause:e})}}toString(){return this.child.toString()}},Zw=class{value;constructor(e){this.value=e}eval(){return[this.value]}toString(){let e=this.value.value;return typeof e==`string`?`'${e}'`:e.toString()}},Qw=class{name;constructor(e){this.name=e}eval(e,t){if(this.name===`$this`)return t;let n=this.getVariable(e);if(n)return[n];if(this.name.startsWith(`%`))throw Error(`Undefined variable ${this.name}`);return t.flatMap(e=>this.evalValue(e)).filter(e=>e?.value!==void 0)}getVariable(e){let t=e.variables[this.name];if(t!==void 0)return t;if(e.parent)return this.getVariable(e.parent)}evalValue(e){let t=e.value;if(!(!t||typeof t!=`object`))return Bw(t,this.name)?(`path`in e||(e.path=t.resourceType),e):TS(e,this.name)}toString(){return this.name}},$w=class{eval(){return[]}toString(){return`{}`}},eT=class extends Sx{impl;constructor(e,t,n){super(e,t),this.impl=n}eval(e,t){return this.impl(this.child.eval(e,t))}toString(){return this.operator+this.child.toString()}},tT=class extends Cx{constructor(e,t){super(`as`,e,t)}eval(e,t){return Gw.as(e,this.left.eval(e,t),this.right)}},nT=class extends Cx{impl;constructor(e,t,n,r){super(e,t,n),this.impl=r}eval(e,t){let n=this.left.eval(e,t),r=this.right.eval(e,t);if(n.length<1||r.length<1)return[];let i=MS(n)?.value,a=MS(r)?.value,o=ZS(i)?i.value:i,s=ZS(a)?a.value:a,c=this.impl(o,s);return typeof c==`boolean`?kS(c):ZS(i)?[{type:X.Quantity,value:{...i,value:c}}]:[AS(c)]}},rT=Object.freeze({type:`string`,value:``}),iT=class extends Cx{constructor(e,t){super(`&`,e,t)}eval(e,t){let n=MS(this.left.eval(e,t))??rT,r=MS(this.right.eval(e,t))??rT;if(typeof n.value!=`string`)throw Error(`Expected string operand for &, but got ${n.type}`);if(typeof r.value!=`string`)throw Error(`Expected string operand for &, but got ${r.type}`);return[{type:X.string,value:n.value+r.value}]}},aT=class extends Cx{constructor(e,t){super(`contains`,e,t)}eval(e,t){let n=this.left.eval(e,t),r=this.right.eval(e,t);return kS(n.some(e=>e.value===r[0].value))}},oT=class extends Cx{constructor(e,t){super(`in`,e,t)}eval(e,t){let n=MS(this.left.eval(e,t)),r=this.right.eval(e,t);return n?kS(r.some(e=>VS(n,e)[0].value)):[]}},sT=class extends Cx{constructor(e,t){super(`.`,e,t)}eval(e,t){return this.right.eval(e,this.left.eval(e,t))}toString(){return`${this.left.toString()}.${this.right.toString()}`}},cT=class extends Cx{constructor(e,t){super(`|`,e,t)}eval(e,t){let n=this.left.eval(e,t),r=this.right.eval(e,t);return LS([...n,...r])}},lT=class extends Cx{constructor(e,t){super(`=`,e,t)}eval(e,t){return zS(this.left.eval(e,t),this.right.eval(e,t))}},uT=class extends Cx{constructor(e,t){super(`!=`,e,t)}eval(e,t){return BS(this.left.eval(e,t),this.right.eval(e,t))}},dT=class extends Cx{constructor(e,t){super(`~`,e,t)}eval(e,t){return HS(this.left.eval(e,t),this.right.eval(e,t))}},fT=class extends Cx{constructor(e,t){super(`!~`,e,t)}eval(e,t){return RS(HS(this.left.eval(e,t),this.right.eval(e,t)))}},pT=class extends Cx{constructor(e,t){super(`is`,e,t)}eval(e,t){let n=this.left.eval(e,t);if(n.length!==1)return[];let r=this.right.name;return kS(GS(n[0],r))}},mT=class extends Cx{constructor(e,t){super(`and`,e,t)}eval(e,t){let n=MS(this.left.eval(e,t),`boolean`),r=MS(this.right.eval(e,t),`boolean`);return n?.value===!0&&r?.value===!0?kS(!0):n?.value===!1||r?.value===!1?kS(!1):[]}},hT=class extends Cx{constructor(e,t){super(`or`,e,t)}eval(e,t){let n=MS(this.left.eval(e,t),`boolean`),r=MS(this.right.eval(e,t),`boolean`);return n?.value===!1&&r?.value===!1?kS(!1):n?.value||r?.value?kS(!0):[]}},gT=class extends Cx{constructor(e,t){super(`xor`,e,t)}eval(e,t){let n=MS(this.left.eval(e,t),`boolean`),r=MS(this.right.eval(e,t),`boolean`);return!n||!r?[]:kS(n.value!==r.value)}},_T=class extends Cx{constructor(e,t){super(`implies`,e,t)}eval(e,t){let n=MS(this.left.eval(e,t),`boolean`),r=MS(this.right.eval(e,t),`boolean`);return r?.value===!0||n?.value===!1?kS(!0):!n||!r?[]:kS(!1)}},vT=class{name;args;constructor(e,t){this.name=e,this.args=t}eval(e,t){let n=Gw[this.name];if(!n)throw Error(`Unrecognized function: `+this.name);return n(e,t,...this.args)}toString(){return`${this.name}(${this.args.map(e=>e.toString()).join(`, `)})`}},yT=class{left;expr;constructor(e,t){this.left=e,this.expr=t}eval(e,t){let n=this.expr.eval(e,t);if(n.length!==1)return[];let r=n[0].value;if(typeof r!=`number`)throw Error(`Invalid indexer expression: should return integer}`);let i=this.left.eval(e,t);return r in i?[i[r]]:[]}toString(){return`${this.left.toString()}[${this.expr.toString()}]`}},bT=[`year`,`years`,`month`,`months`,`week`,`weeks`,`day`,`days`,`hour`,`hours`,`minute`,`minutes`,`second`,`seconds`,`millisecond`,`milliseconds`],xT={"'":`'`,'"':`"`,"`":"`",r:`\r`,n:`
54
54
  `,t:` `,f:`\f`,"\\":`\\`},ST=class{str;keywords;operators;dateTimeLiterals;symbolRegex;result=[];pos={index:0,line:1,column:0};markStack=[];constructor(e,t,n,r){this.str=e,this.keywords=t,this.operators=n,this.dateTimeLiterals=!!r?.dateTimeLiterals,this.symbolRegex=r?.symbolRegex??/[$\w%]/}tokenize(){for(;this.pos.index<this.str.length;){let e=this.consumeToken();e&&this.result.push(e)}return this.result}prevToken(){return this.result.slice(-1)[0]}peekToken(){this.mark();let e=this.consumeToken();return this.reset(),e}consumeToken(){this.consumeWhitespace();let e=this.curr();if(!e)return;this.mark();let t=this.peek();return e===`/`&&t===`*`?this.consumeMultiLineComment():e===`/`&&t===`/`?this.consumeSingleLineComment():e===`'`||e===`"`||e==="`"?this.consumeString(e):e===`@`?this.consumeDateTime():/\d/.exec(e)?this.consumeNumber():/\w/.exec(e)||(e===`$`||e===`%`)&&/\w/.exec(t)?this.consumeSymbol():(e===`$`||e===`%`)&&(t===`'`||t===`"`||t==="`")?this.consumeQuotedSymbol(t):this.consumeOperator()}consumeWhitespace(){this.consumeWhile(()=>/\s/.exec(this.curr()))}consumeMultiLineComment(){let e=this.pos.index;return this.consumeWhile(()=>this.curr()!==`*`||this.peek()!==`/`),this.advance(),this.advance(),this.buildToken(`Comment`,this.str.substring(e,this.pos.index))}consumeSingleLineComment(){return this.buildToken(`Comment`,this.consumeWhile(()=>this.curr()!==`
55
55
  `))}consumeString(e){this.advance();let t=``,n;for(;n=this.consumeChar(e);)t+=n;let r=this.buildToken(e==="`"?`Symbol`:`String`,t);return this.advance(),r}consumeChar(e){let t=this.curr();if(t===`\\`){this.advance();let t=this.curr(),n=xT[t];if(n!==void 0)return this.advance(),n;if(t===`u`){this.advance();let e=/^[0-9a-fA-F]{4}$/.exec(this.str.substring(this.pos.index,this.pos.index+4))?.[0];return e?(this.advance(),this.advance(),this.advance(),this.advance(),String.fromCodePoint(Number.parseInt(e,16))):`u`}return this.consumeChar(e)}return t===e||!t?``:(this.advance(),t)}consumeQuotedSymbol(e){this.mark();let t=this.pos.index;this.advance(),this.consumeString(e);let n=this.str.substring(t,this.pos.index);return this.buildToken(`Symbol`,n)}consumeDateTime(){this.advance();let e=this.pos.index;this.consumeWhile(()=>/[\d-]/.exec(this.curr()));let t=!1,n=!1;if(this.curr()===`T`&&(t=!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`?(n=!0,this.advance()):(this.curr()===`+`||this.curr()===`-`)&&(n=!0,this.advance(),this.consumeWhile(()=>/[\d:]/.exec(this.curr())))),this.pos.index===e)throw Error(`Invalid DateTime literal`);let r=this.str.substring(e,this.pos.index);return r.endsWith(`T`)?r=r.substring(0,r.length-1):!r.startsWith(`T`)&&t&&!n&&(r+=`Z`),this.buildToken(`DateTime`,r)}consumeNumber(){let e=this.pos.index,t=`Number`;this.consumeWhile(()=>/\d/.exec(this.curr())),this.curr()===`.`&&/\d/.exec(this.peek())&&(this.advance(),this.consumeWhile(()=>/\d/.exec(this.curr())));let n=this.curr();if(n===`-`&&this.dateTimeLiterals)return this.pos.index=e-1,this.consumeDateTime();if(n===` `)CT(this.peekToken())&&(t=`Quantity`,this.consumeToken());else if(n&&/[a-zA-Z_$]/.exec(n))return this.pos.index=e-1,this.consumeString(` `);return this.buildToken(t,this.str.substring(e,this.pos.index))}consumeSymbol(){let e=this.consumeWhile(()=>this.symbolRegex.exec(this.curr()));return this.prevToken()?.value!==`.`&&this.keywords.includes(e)?this.buildToken(e,e):this.buildToken(`Symbol`,e)}consumeOperator(){let e=this.curr(),t=e+this.peek();return this.operators.includes(t)?(this.advance(),this.advance(),this.buildToken(t,t)):(this.advance(),this.buildToken(e,e))}consumeWhile(e){let t=this.pos.index;for(;this.pos.index<this.str.length&&e();)this.advance();return this.str.substring(t,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(){let e=this.markStack.pop();if(!e)throw Error(`No mark to reset to`);this.pos.index=e.index,this.pos.line=e.line,this.pos.column=e.column}advance(){this.pos.index++,this.curr()===`
56
- `?(this.pos.line++,this.pos.column=0):this.pos.column++}buildToken(e,t){let n=this.markStack.pop();if(!n)throw Error(`No mark for token`);return{id:e,value:t,...n}}};function CT(e){return!!(e&&(e.id===`String`||e.id===`Symbol`&&bT.includes(e.value)))}var wT=[`true`,`false`],TT=[`!=`,`!~`,`<=`,`>=`,`{}`,`->`];function ET(e){return new ST(e,wT,TT).tokenize()}var DT={FunctionCall:0,Dot:1,Indexer:2,UnaryAdd:3,UnarySubtract:3,Multiply:4,Divide:4,IntegerDivide: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,Arrow:100,Semicolon:200},OT={parse(e){let t=e.consumeAndParse();if(!e.match(`)`))throw Error("Parse error: expected `)` got `"+e.peek()?.value+"`");return t}},kT={parse(e,t){let n=e.consumeAndParse();if(!e.match(`]`))throw Error("Parse error: expected `]`");return new yT(t,n)},precedence:DT.Indexer},AT={parse(e,t){if(!(t instanceof Qw))throw Error(`Unexpected parentheses`);let n=[];for(;!e.match(`)`);)n.push(e.consumeAndParse()),e.match(`,`);return new vT(t.name,n)},precedence:DT.FunctionCall};function jT(e){let t=e.split(` `),n=Number.parseFloat(t[0]),r=t[1];return r=r?.startsWith(`'`)&&r.endsWith(`'`)?r.substring(1,r.length-1):`{`+r+`}`,{value:n,unit:r}}function MT(){return new wx().registerPrefix(`String`,{parse:(e,t)=>new Zw({type:X.string,value:t.value})}).registerPrefix(`DateTime`,{parse:(e,t)=>new Zw({type:X.dateTime,value:Uw(t.value)})}).registerPrefix(`Quantity`,{parse:(e,t)=>new Zw({type:X.Quantity,value:jT(t.value)})}).registerPrefix(`Number`,{parse:(e,t)=>new Zw({type:t.value.includes(`.`)?X.decimal:X.integer,value:Number.parseFloat(t.value)})}).registerPrefix(`true`,{parse:()=>new Zw({type:X.boolean,value:!0})}).registerPrefix(`false`,{parse:()=>new Zw({type:X.boolean,value:!1})}).registerPrefix(`Symbol`,{parse:(e,t)=>new Qw(t.value)}).registerPrefix(`{}`,{parse:()=>new $w}).registerPrefix(`(`,OT).registerInfix(`[`,kT).registerInfix(`(`,AT).prefix(`+`,DT.UnaryAdd,(e,t)=>new eT(`+`,t,e=>e)).prefix(`-`,DT.UnarySubtract,(e,t)=>new nT(`-`,t,t,(e,t)=>-t)).infixLeft(`.`,DT.Dot,(e,t,n)=>new sT(e,n)).infixLeft(`/`,DT.Divide,(e,t,n)=>new nT(`/`,e,n,(e,t)=>e/t)).infixLeft(`*`,DT.Multiply,(e,t,n)=>new nT(`*`,e,n,(e,t)=>e*t)).infixLeft(`+`,DT.Add,(e,t,n)=>new nT(`+`,e,n,(e,t)=>e+t)).infixLeft(`-`,DT.Subtract,(e,t,n)=>new nT(`-`,e,n,(e,t)=>e-t)).infixLeft(`|`,DT.Union,(e,t,n)=>new cT(e,n)).infixLeft(`=`,DT.Equals,(e,t,n)=>new lT(e,n)).infixLeft(`!=`,DT.NotEquals,(e,t,n)=>new uT(e,n)).infixLeft(`~`,DT.Equivalent,(e,t,n)=>new dT(e,n)).infixLeft(`!~`,DT.NotEquivalent,(e,t,n)=>new fT(e,n)).infixLeft(`<`,DT.LessThan,(e,t,n)=>new nT(`<`,e,n,(e,t)=>e<t)).infixLeft(`<=`,DT.LessThanOrEquals,(e,t,n)=>new nT(`<=`,e,n,(e,t)=>e<=t)).infixLeft(`>`,DT.GreaterThan,(e,t,n)=>new nT(`>`,e,n,(e,t)=>e>t)).infixLeft(`>=`,DT.GreaterThanOrEquals,(e,t,n)=>new nT(`>=`,e,n,(e,t)=>e>=t)).infixLeft(`&`,DT.Ampersand,(e,t,n)=>new iT(e,n)).infixLeft(`and`,DT.And,(e,t,n)=>new mT(e,n)).infixLeft(`as`,DT.As,(e,t,n)=>new tT(e,n)).infixLeft(`contains`,DT.Contains,(e,t,n)=>new aT(e,n)).infixLeft(`div`,DT.Divide,(e,t,n)=>new nT(`div`,e,n,(e,t)=>Math.trunc(e/t))).infixLeft(`in`,DT.In,(e,t,n)=>new oT(e,n)).infixLeft(`is`,DT.Is,(e,t,n)=>new pT(e,n)).infixLeft(`mod`,DT.Modulo,(e,t,n)=>new nT(`mod`,e,n,(e,t)=>e%t)).infixLeft(`or`,DT.Or,(e,t,n)=>new hT(e,n)).infixLeft(`xor`,DT.Xor,(e,t,n)=>new gT(e,n)).infixLeft(`implies`,DT.Implies,(e,t,n)=>new _T(e,n))}var NT=MT();function PT(e){return new Xw(e,NT.construct(ET(e)).consumeAndParse())}function FT(e,t){let n=Array.isArray(t)?t:[t];for(let e=0;e<n.length;e++){let t=n[e];typeof t==`object`&&`type`in t&&`value`in t||(n[e]=AS(n[e]))}return IT(e,n).map(e=>e.value)}function IT(e,t,n={},r=void 0){let i;if(typeof e==`string`){let t=r?.get(e);i=t??PT(e),r&&!t&&r.set(e,i)}else i=e;return i.eval({variables:n},t).map(e=>{let t={type:e.type,value:e.value?.valueOf()};return`path`in e&&(t.path=e.path),t})}function LT(e){let t=[];for(let n of e){let e=YS(n.value);e&&t.push(e)}return t}function RT(e){let t=new Set;for(let n of e){let e=iw(n);e&&t.add(e)}return Array.from(t)}function zT(e){let t=new Set;for(let n of e){let{value:e}=n;e&&(NC(e)?t.add(e):Vw(e)?t.add(e.reference):rC(e)?t.add(aC(e)):typeof e.identifier==`object`&&t.add(`identifier:${e.identifier.system}|${e.identifier.value}`))}return Array.from(t)}function BT(e,t={}){let n=[];for(let r of e)VT(t,n,r);return n}function VT(e,t,n){let{type:r,value:i}=n;switch(r){case X.Identifier:HT(t,e,i);break;case X.CodeableConcept:UT(t,e,i);break;case X.Coding:WT(t,e,i);break;case X.ContactPoint:GT(t,e,i);break;default:KT(t,e,void 0,i?.toString())}}function HT(e,t,n){n?.type?.text&&KT(e,t,t.textSearchSystem,n.type.text),KT(e,t,n?.system,n?.value)}function UT(e,t,n){n?.text&&KT(e,t,t.textSearchSystem,n.text);for(let r of n?.coding??rw)WT(e,t,r)}function WT(e,t,n){n&&(n.display&&KT(e,t,t.textSearchSystem,n.display),KT(e,t,n.system,n.code))}function GT(e,t,n){n&&KT(e,t,n.system,n.value?.toLocaleLowerCase())}function KT(e,t,n,r){(n||r)&&!e.some(e=>e.system===n&&e.value===r)&&e.push({system:n,value:r&&t.caseInsensitive?r.toLocaleLowerCase():r})}var Z={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`},qT={contains:Z.CONTAINS,exact:Z.EXACT,above:Z.ABOVE,below:Z.BELOW,text:Z.TEXT,not:Z.NOT,in:Z.IN,"not-in":Z.NOT_IN,"of-type":Z.OF_TYPE,missing:Z.MISSING,identifier:Z.IDENTIFIER,iterate:Z.ITERATE},JT={eq:Z.EQUALS,ne:Z.NOT_EQUALS,lt:Z.LESS_THAN,le:Z.LESS_THAN_OR_EQUALS,gt:Z.GREATER_THAN,ge:Z.GREATER_THAN_OR_EQUALS,sa:Z.STARTS_AFTER,eb:Z.ENDS_BEFORE,ap:Z.APPROXIMATELY,sw:Z.STARTS_WITH};function YT(e,t){if(!e)throw Error(`Invalid search URL`);let n=``,r;if(typeof e==`string`)if(e.includes(`?`)){let[t,i]=e.split(`?`);n=t,r=new URLSearchParams(i)}else n=e;else typeof e==`object`&&(n=e.pathname,r=e.searchParams);let i;i=n.includes(`/`)?n.split(`/`).filter(Boolean).pop():n;let a=[];if(r&&a.push(...r.entries()),t)for(let[e,n]of Object.entries(t))if(Array.isArray(n))for(let t of n)a.push([e,t]);else a.push([e,n??``]);return XT(i,a)}function XT(e,t){let n={resourceType:e};for(let[e,r]of t)ZT(n,e,r);return n}function ZT(e,t,n){let r,i,a=t.indexOf(`:`);if(a>=0?(r=t.substring(0,a),i=t.substring(a+1)):(r=t,i=``),r!==`_`){if(r===`_has`||t.includes(`.`)){e.filters=JC(e.filters,{code:t,operator:Z.EQUALS,value:n});return}switch(r){case`_sort`:QT(e,n);break;case`_cursor`:e.cursor=n;break;case`_count`:e.count=Number.parseInt(n,10);break;case`_offset`:e.offset=Number.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`:{let t=iE(n);i===`iterate`&&(t.modifier=Z.ITERATE),e.include=JC(e.include,t);break}case`_revinclude`:{let t=iE(n);i===`iterate`&&(t.modifier=Z.ITERATE),e.revInclude=JC(e.revInclude,t);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:{let t=Hw.types[e.resourceType]?.searchParams?.[r];t?e.filters=JC(e.filters,eE(t,Z.EQUALS,i,n)):e.filters=JC(e.filters,tE(r,i,n))}}}}function QT(e,t){for(let n of t.split(`,`)){let t,r=!1;n.startsWith(`-`)?(t=n.substring(1),r=!0):t=n,e.sortRules||=[],e.sortRules.push({code:t,descending:r})}}var $T=[Z.MISSING,Z.PRESENT];function eE(e,t,n,r){if($T.includes(n||t))return{code:e.code,operator:n||t,value:r};switch(e.type){case`number`:case`date`:case`quantity`:{let{operator:t,value:i}=nE(r,n||Z.EQUALS);if(!aE(e,i))throw new Yx(Hx(`Invalid format for ${e.type} search parameter: ${i}`));return{code:e.code,operator:t,value:i}}case`reference`:case`string`:case`token`:case`uri`:if(!aE(e,r))throw new Yx(Hx(`Invalid format for ${e.type} search parameter: ${r}`));return{code:e.code,operator:rE(n)??t,value:r};default:throw Error(`Unrecognized search parameter type: `+e.type)}}function tE(e,t,n){let r=Z.EQUALS;if(t)r=t;else if(n.length>=2){let e=n.substring(0,2);e in JT&&(n.length===2||n.at(2)?.match(/\d/))&&(r=e,n=n.substring(e.length))}return{code:e,operator:r,value:n}}function nE(e,t){let n=JT[e.substring(0,2)];return n?{operator:n,value:e.substring(2)}:{operator:t,value:e}}function rE(e){return qT[e]}function iE(e){let t=e.split(`:`);if(t.includes(`*`))throw new Yx(Hx(`'*' is not supported as a value for search inclusion parameters`));if(t.length===1)throw new Yx(Hx(`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 Yx(Hx(`Invalid include value '${e}'`))}function aE(e,t){switch(e.type){case`date`:return qS(t);default:return!0}}function oE(e){let t=[];e.fields&&t.push(`_fields=`+e.fields.join(`,`));for(let n of e.filters??rw)t.push(sE(n));e.sortRules&&e.sortRules.length>0&&t.push(cE(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(`,`));for(let n of e.include??rw)t.push(lE(`_include`,n));for(let n of e.revInclude??rw)t.push(lE(`_revinclude`,n));return t.length===0?``:(YC(t),`?`+t.join(`&`))}function sE(e){let t=e.operator in qT?`:`+e.operator:``,n=e.operator!==Z.EQUALS&&e.operator in JT?e.operator:``;return`${e.code}${t}=${n}${encodeURIComponent(e.value)}`}function cE(e){return`_sort=`+e.map(e=>e.descending?`-`+e.code:e.code).join(`,`)}function lE(e,t){return e+(t.modifier?`:`+t.modifier:``)+`=`+t.resourceType+`:`+t.searchParam+(t.targetType?`:`+t.targetType:``)}function uE(e){let t=[],n=``,r=!1;for(let i of e)r?(n+=i,r=!1):i===`\\`?r=!0:i===`,`?(t.push(n),n=``):n+=i;return t.push(n),t}function dE(e,t){if(t.resourceType!==e.resourceType)return!1;for(let n of t.filters??rw)if(!pE(e,t,n))return!1;return!0}var fE=new xx(1e3);function pE(e,t,n){let r=Hw.types[t.resourceType]?.searchParams?.[n.code];if(!r)return!1;let i=IT(r.expression,[AS(e)],void 0,fE);if(n.operator===Z.MISSING||n.operator===Z.PRESENT)return mE(i,n);switch(r.type){case`reference`:return hE(r,i,n);case`string`:case`uri`:return vE(i,n);case`token`:return gE(i,n);case`date`:return bE(i,n);default:return!1}}function mE(e,t){let n=e.length>0;return(t.operator===Z.MISSING&&t.value===`false`||t.operator===Z.PRESENT&&t.value===`true`)===n}function hE(e,t,n){let r=SE(n.operator);if(n.value===``&&t.length===0)return n.operator===Z.EQUALS;let i=zT(t);for(let t of uE(n.value)){let a=!1;if(t.includes(`/`)?a=i.includes(t):(e.target?.length===1||n.code===`_compartment`)&&(a=i.some(e=>e?.endsWith(`/`+t))),a)return!r}return r}function gE(e,t){let n=BT(e),r=uE(t.value),i=SE(t.operator);for(let e of n)for(let t of r)if(_E(e,t))return!i;return i}function _E(e,t){if(t.includes(`|`)){let[n,r]=t.split(`|`).map(e=>e.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 vE(e,t){let n=RT(e),r=uE(t.value),i=SE(t.operator);for(let e of n)for(let t of r)if(yE(e,t))return!i;return i}function yE(e,t){return e.toLowerCase().includes(t.toLowerCase())}function bE(e,t){let n=LT(e),r=uE(t.value),i=SE(t.operator);for(let e of n)for(let n of r)if(xE(e,t.operator,n))return!i;return i}function xE(e,t,n){if(!e)return!1;let r=YS(n);if(!r)return!1;let i=e.start??`0000`,a=e.end??`9999`,o=r.start,s=r.end;switch(t){case Z.APPROXIMATELY:case Z.EQUALS:case Z.NOT_EQUALS:return i<s&&a>o;case Z.LESS_THAN:return i<o;case Z.GREATER_THAN:return a>s;case Z.LESS_THAN_OR_EQUALS:return i<=s;case Z.GREATER_THAN_OR_EQUALS:return a>=o;case Z.STARTS_AFTER:return i>s;case Z.ENDS_BEFORE:return a<o;default:return!1}}function SE(e){return e===Z.NOT_EQUALS||e===Z.NOT}var CE={resourceType:`*`},wE=[`DomainConfiguration`,`JsonWebKey`,`Login`],TE=[`Package`,`PackageRelease`,`PackageInstallation`,`Project`,`ProjectMembership`,`User`,`UserSecurityRequest`],EE={READ:`read`,VREAD:`vread`,UPDATE:`update`,DELETE:`delete`,HISTORY:`history`,CREATE:`create`,SEARCH:`search`},DE=[EE.READ,EE.VREAD,EE.HISTORY,EE.SEARCH];function OE(e,t){return wE.includes(t)?!1:kE(e,EE.UPDATE,t)}function kE(e,t,n){return!!e.resource?.some(e=>ME(e,n,t))}function AE(e,t,n){return n?n.resource?.find(n=>jE(e,t,n)):CE}function jE(e,t,n){let r=e.resourceType;return ME(n,r,t)?r===`Binary`?!0:!(n.compartment&&!e.meta?.compartment?.some(e=>e.reference===n.compartment?.reference)||n.criteria&&!dE(e,YT(n.criteria))):!1}function ME(e,t,n){return e.resourceType!==t&&(e.resourceType!==`*`||TE.includes(t))?!1:e.interaction?e.interaction.includes(n):!e.readonly||DE.includes(n)}function NE(){return typeof window<`u`}function PE(){return typeof Buffer<`u`?Buffer:void 0}var FE={assign(e){NE()&&globalThis.location.assign(e)},reload(){NE()&&globalThis.location.reload()},getSearch(){return NE()?globalThis.location.search:``},getPathname(){return NE()?globalThis.location.pathname:``},getLocation(){return NE()?globalThis.location.toString():``},getOrigin(){return NE()?globalThis.location.protocol+`//`+globalThis.location.host+`/`:``}};function IE(e){if(NE()){let t=window.atob(e),n=Uint8Array.from(t,e=>e.codePointAt(0));return new window.TextDecoder().decode(n)}let t=PE();if(t)return t.from(e,`base64`).toString(`utf-8`);throw Error(`Unable to decode base64`)}function LE(e){if(NE()){let t=new window.TextEncoder().encode(e),n=String.fromCodePoint.apply(null,t);return window.btoa(n)}let t=PE();if(t)return t.from(e,`utf8`).toString(`base64`);throw Error(`Unable to encode base64`)}function RE(e){return e=e.padEnd(e.length+(4-e.length%4)%4,`=`),IE(e.replaceAll(`-`,`+`).replaceAll(`_`,`/`))}function zE(){let e=new Uint32Array(28);return crypto.getRandomValues(e),RC(e.buffer)}async function BE(e){return crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e))}function VE(){return typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replaceAll(/[xy]/g,e=>{let t=Math.trunc(Math.random()*16);return(e===`x`?t:t&3|8).toString(16)})}function HE(e){let t={};e=AC(e);for(let n of e.entry??rw){let e=n.resource;if(!e)continue;e.meta!==void 0&&(delete e.meta.author,delete e.meta.compartment,delete e.meta.lastUpdated,delete e.meta.project,delete e.meta.versionId,Object.keys(e.meta).length===0&&delete e.meta);let r=e?.id;if(r)t[r]=VE(),n.fullUrl=`urn:uuid:`+t[r],delete n.resource?.id;else if(n.fullUrl?.startsWith(`resource:`)){let e=n.fullUrl.slice(9);t[e]=VE(),n.fullUrl=`urn:uuid:`+t[e]}}let n=e.entry,r=JSON.stringify({resourceType:`Bundle`,type:`transaction`,entry:n?.map(e=>({fullUrl:e.fullUrl,request:{method:`POST`,url:e.resource?.resourceType},resource:e.resource}))},(e,n)=>UE(e,n,t),2);return WE(JSON.parse(r))}function UE(e,t,n){if((e===`reference`||e===`url`)&&typeof t==`string`){let e;if(t.includes(`/`)?e=t.split(`/`)[1]:t.startsWith(`urn:uuid:`)||t.startsWith(`resource:`)?e=t.slice(9):t.startsWith(`#`)&&(e=t.slice(1)),e){let t=n[e];if(t)return`urn:uuid:`+t}}return t}function WE(e){let{sorted:t,cycles:n}=KE(JE(e)),r={},i=[];for(let t of e.entry??rw)t.fullUrl?r[t.fullUrl]=t:i.push(t);let a=t.map(e=>r[e]);for(let e of n)for(let t of e){let e=r[t],n={...e,request:{...e.request,method:`PUT`}};a.push(n)}return a.push(...i),{...e,entry:a}}var GE={NotVisited:`NotVisited`,Visiting:`Visiting`,Visited:`Visited`};function KE(e){let t=[],n={},r=[];for(let t of Object.keys(e))n[t]=GE.NotVisited;function i(a,o){if(n[a]===GE.Visited)return!0;if(n[a]===GE.Visiting){let e=o.lastIndexOf(a);return e!==-1&&r.push(o.slice(e)),!0}n[a]=GE.Visiting,o.push(a);let s=!1;for(let t of e[a]??rw)i(t,o)||(s=!0);return n[a]=GE.Visited,o.pop(),t.unshift(a),!s}for(let t in e)n[t]===GE.NotVisited&&i(t,[]);return{sorted:t,cycles:r}}function qE(e,t){for(let n in e)if(e[n]&&typeof e[n]==`object`){let r=e[n];if(Vw(r)){let e=r.reference;(e.startsWith(`urn:uuid:`)||e.startsWith(`resource:`))&&t(e)}else qE(r,t)}}function JE(e){let t={};for(let n of e.entry??rw)n.fullUrl&&(t[n.fullUrl]=[]);for(let n of e.entry??rw){let e=n.fullUrl;e&&n.resource&&qE(n.resource,n=>{t[n]&&t[n].push(e)})}return t}var YE={CSS:`text/css`,DICOM:`application/dicom`,FAVICON:`image/vnd.microsoft.icon`,FHIR_JSON:`application/fhir+json`,FORM_URL_ENCODED:`application/x-www-form-urlencoded`,HL7_V2:`x-application/hl7-v2+er7`,HTML:`text/html`,JAVASCRIPT:`text/javascript`,JSON:`application/json`,JSON_PATCH:`application/json-patch+json`,JWT:`application/jwt`,MULTIPART_FORM_DATA:`multipart/form-data`,PNG:`image/png`,SCIM_JSON:`application/scim+json`,SVG:`image/svg+xml`,TEXT:`text/plain`,TYPESCRIPT:`text/typescript`,PING:`x-application/ping`,XML:`text/xml`,CDA_XML:`application/cda+xml`,OCTET_STREAM:`application/octet-stream`},XE=class{listeners;constructor(){this.listeners={}}addEventListener(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)}removeEventListener(e,t){let n=this.listeners[e];if(n){for(let e=0;e<n.length;e++)if(n[e]===t){n.splice(e,1);return}}}dispatchEvent(e){let t=this.listeners[e.type];for(let n of t??rw)n.call(this,e);return!e.defaultPrevented}removeAllListeners(){this.listeners={}}listenerCount(e){return this.listeners[e]?.length??0}},ZE=class{emitter=new XE;dispatchEvent(e){this.emitter.dispatchEvent(e)}addEventListener(e,t){this.emitter.addEventListener(e,t)}removeEventListener(e,t){this.emitter.removeEventListener(e,t)}removeAllListeners(){this.emitter.removeAllListeners()}listenerCount(e){return this.emitter.listenerCount(e)}},QE={"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`},$E=[`Patient`,`Encounter`,`ImagingStudy`,`DiagnosticReport`,`OperationOutcome`,`Bundle`],eD=[`DiagnosticReport-update`];function tD(e){return eD.includes(e)}function nD(e){if(eD.includes(e))throw new Yx(Ux(`'context.version' is required for '${e}'.`))}var rD={"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 iD(e){return $E.includes(e)}function aD(e){return!!e.endpoint}function oD(e){if(!sD(e))throw new Yx(Ux(`subscriptionRequest must be an object conforming to SubscriptionRequest type.`));let{channelType:t,mode:n,topic:r,events:i}=e,a={"hub.channel.type":t,"hub.mode":n,"hub.topic":r,"hub.events":i.join(`,`)};return aD(e)&&(a.endpoint=e.endpoint),new URLSearchParams(a).toString()}function sD(e){if(typeof e!=`object`)return!1;let{channelType:t,mode:n,topic:r,events:i}=e;if(!(t&&n&&r&&i)||typeof r!=`string`||typeof i!=`object`||!Array.isArray(i)||i.length<1||t!==`websocket`||n!==`subscribe`&&n!==`unsubscribe`)return!1;for(let e of i)if(!QE[e])return!1;return!(aD(e)&&!(typeof e.endpoint==`string`&&e.endpoint.startsWith(`ws`)))}function cD(e,t,n,r){if(typeof t!=`object`)throw new Yx(Ux(`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 Yx(Ux(`context[${n}] is invalid. Resource must contain a valid string ID.`));if(!t.resourceType)throw new Yx(Ux(`context[${n}] is invalid. Resource must contain a resource type. No resource type found.`));let i=r.resourceType;if(i!==`*`){if(!iD(t.resourceType))throw new Yx(Ux(`context[${n}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));if(i&&t.resourceType!==i)throw new Yx(Ux(`context[${n}] is invalid. context[${n}] for the '${e}' event should contain resource of type ${i}.`))}}function lD(e,t,n,r,i){if(i.set(t.key,(i.get(t.key)??0)+1),r.reference){if(!Vw(t.reference))throw new Yx(Ux(`context[${n}] is invalid. Expected key '${t.key}' to be a reference.`))}else cD(e,t.resource,n,r)}function uD(e,t){let n=new Map,r=rD[e];for(let i=0;i<t.length;i++){let a=t[i].key;if(!r[a])throw new Yx(Ux(`Key '${a}' not found for event '${e}'. Make sure to add only valid keys.`));lD(e,t[i],i,r[a],n)}for(let[t,i]of Object.entries(r)){if(!(i.optional||n.has(t)))throw new Yx(Ux(`Missing required key '${t}' on context for '${e}' event.`));if(!i.manyAllowed&&(n.get(t)??0)>1)throw new Yx(Ux(`${n.get(t)} context entries with key '${t}' found for the '${e}' event when schema only allows for 1.`))}}function dD(e,t,n,r){if(!(e&&typeof e==`string`))throw new Yx(Ux(`Must provide a topic.`));if(!QE[t])throw new Yx(Ux(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(QE).join(`, `)}`));if(typeof n!=`object`)throw new Yx(Ux(`context must be a context object or array of context objects.`));if(eD.includes(t)&&!r)throw new Yx(Ux(`The '${t}' event must contain a 'context.versionId'.`));let i=Array.isArray(n)?n:[n];return uD(t,i),{timestamp:new Date().toISOString(),id:VE(),event:{"hub.topic":e,"hub.event":t,context:i,...r?{"context.versionId":r}:{}}}}var fD=class extends ZE{subRequest;websocket;constructor(e){if(super(),this.subRequest=e,!e.endpoint)throw new Yx(Ux(`Subscription request should contain an endpoint.`));if(!sD(e))throw new Yx(Ux(`Subscription request failed validation.`));let t=new WebSocket(e.endpoint);t.addEventListener(`open`,()=>{this.dispatchEvent({type:`connect`}),t.addEventListener(`message`,e=>{let n=JSON.parse(e.data);if(n[`hub.topic`])return;let r=n;r.event[`hub.event`]!==`heartbeat`&&(this.dispatchEvent({type:`message`,payload:r}),t.send(JSON.stringify({id:n?.id,timestamp:new Date().toISOString()})))}),t.addEventListener(`close`,()=>{this.dispatchEvent({type:`disconnect`})})}),this.websocket=t}disconnect(){this.websocket.close()}};function pD(e){return JSON.parse(RE(e))}function mD(e){return e.split(`.`).length===3}function hD(e){let[t,n,r]=e.split(`.`);return pD(n)}function gD(e){try{return typeof hD(e).login_id==`string`}catch{return!1}}function _D(e){try{let t=hD(e).exp;return typeof t==`number`?t*1e3:void 0}catch{return}}var vD=class{medplum;constructor(e){this.medplum=e}async get(e){return this.medplum.get(`keyvalue/v1/${e}`)}async set(e,t){await this.medplum.put(`keyvalue/v1/${e}`,t,YE.TEXT)}async delete(e){await this.medplum.delete(`keyvalue/v1/${e}`)}},yD=class{[Symbol.toStringTag]=`ReadablePromise`;suspender;status=`pending`;response;error;constructor(e){this.suspender=e.then(e=>(this.status=`success`,this.response=e,e),e=>{throw this.status=`error`,this.error=e,e})}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(e,t){return this.suspender.then(e,t)}catch(e){return this.suspender.catch(e)}finally(e){return this.suspender.finally(e)}},bD=class{storage;prefix=``;constructor(e,t=``){this.storage=e??globalThis.localStorage??new xD,this.prefix=t}makeKey(e){return this.prefix+e}clear(){this.storage===globalThis.localStorage&&this.prefix?Object.keys(this.storage).filter(e=>e.startsWith(this.prefix)).forEach(e=>{this.storage.removeItem(e)}):this.storage.clear()}getString(e){return this.storage.getItem(this.makeKey(e))??void 0}setString(e,t){t?this.storage.setItem(this.makeKey(e),t):this.storage.removeItem(this.makeKey(e))}getObject(e){let t=this.getString(e);return t?JSON.parse(t):void 0}setObject(e,t){this.setString(e,t?_C(t):void 0)}},xD=class{data;constructor(){this.data=new Map}get length(){return this.data.size}clear(){this.data.clear()}getItem(e){return this.data.get(e)??null}setItem(e,t){t?this.data.set(e,t):this.data.delete(e)}removeItem(e){this.data.delete(e)}key(e){return Array.from(this.data.keys())[e]}},SD={Event:globalThis.Event===void 0?void 0:globalThis.Event,ErrorEvent:void 0,CloseEvent:void 0},CD=!1;function wD(){if(globalThis.Event===void 0)throw Error(`Unable to lazy init events for ReconnectingWebSocket. globalThis.Event is not defined yet`);SD.Event=globalThis.Event,SD.ErrorEvent=class extends Event{message;error;constructor(e,t){super(`error`,t),this.message=e.message,this.error=e}},SD.CloseEvent=class extends Event{code;reason;wasClean=!0;constructor(e=1e3,t=``,n){super(`close`,n),this.code=e,this.reason=t}}}function TD(e,t){if(!e)throw Error(t)}function ED(e){return new e.constructor(e.type,e)}var DD={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1},OD=!1,kD=class e extends ZE{_ws;_retryCount=-1;_uptimeTimeout;_connectTimeout;_shouldReconnect=!0;_connectLock=!1;_binaryType;_closeCalled=!1;_messageQueue=[];_debugLogger=console.log.bind(console);_url;_protocols;_options;constructor(e,t,n={}){CD||=(wD(),!0),super(),this._url=e,this._protocols=t,this._options=n,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 e.CONNECTING}get OPEN(){return e.OPEN}get CLOSING(){return e.CLOSING}get CLOSED(){return e.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((e,t)=>(typeof t==`string`?e+=t.length:t instanceof Blob?e+=t.size:e+=t.byteLength,e),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?e.CLOSED:e.CONNECTING}get url(){return this._ws?this._ws.url:``}get shouldReconnect(){return this._shouldReconnect}onclose=null;onerror=null;onmessage=null;onopen=null;close(e=1e3,t){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(e,t)}reconnect(e,t){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED||this._disconnect(e,t),this._connect()}send(e){if(this._ws?.readyState===this.OPEN)this._debug(`send`,e),this._ws.send(e);else{let{maxEnqueuedMessages:t=DD.maxEnqueuedMessages}=this._options;this._messageQueue.length<t&&(this._debug(`enqueue`,e),this._messageQueue.push(e))}}_debug(...e){this._options.debug&&this._debugLogger(`RWS>`,...e)}_getNextDelay(){let{reconnectionDelayGrowFactor:e=DD.reconnectionDelayGrowFactor,minReconnectionDelay:t=DD.minReconnectionDelay,maxReconnectionDelay:n=DD.maxReconnectionDelay}=this._options,r=0;return this._retryCount>0&&(r=t*e**(this._retryCount-1),r>n&&(r=n)),this._debug(`next delay`,r),r}_wait(){return new Promise(e=>{setTimeout(e,this._getNextDelay())})}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;let{maxRetries:e=DD.maxRetries,connectionTimeout:t=DD.connectionTimeout}=this._options;if(this._retryCount>=e){this._debug(`max retries reached`,this._retryCount,`>=`,e);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`&&!OD&&(console.error(`‼️ No WebSocket implementation available. You should define options.WebSocket.`),OD=!0);let e=this._options.WebSocket||WebSocket;this._debug(`connect`,{url:this._url,protocols:this._protocols}),this._ws=this._protocols?new e(this._url,this._protocols):new e(this._url),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),t)}).catch(e=>{this._connectLock=!1,this._handleError(new SD.ErrorEvent(Error(e.message),this))})}_handleTimeout(){this._debug(`timeout event`),this._handleError(new SD.ErrorEvent(Error(`TIMEOUT`),this))}_disconnect(e=1e3,t){if(this._clearTimeouts(),this._ws){this._removeListeners();try{this._ws.close(e,t),this._handleClose(new SD.CloseEvent(e,t,this))}catch{}}}_acceptOpen(){this._debug(`accept open`),this._retryCount=0}_handleOpen=e=>{this._debug(`open event`);let{minUptime:t=DD.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),t),TD(this._ws,`WebSocket is not defined`),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(e=>this._ws?.send(e)),this._messageQueue=[],this.onopen&&this.onopen(e),this.dispatchEvent(ED(e))};_handleMessage=e=>{this._debug(`message event`),this.onmessage&&this.onmessage(e),this.dispatchEvent(ED(e))};_handleError=e=>{this._debug(`error event`,e.message),this._disconnect(void 0,e.message===`TIMEOUT`?`timeout`:void 0),this.onerror&&this.onerror(e),this._debug(`exec error listeners`),this.dispatchEvent(ED(e)),this._connect()};_handleClose=e=>{this._debug(`close event`),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(e),this.dispatchEvent(ED(e))};_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)}},AD=6e4,jD=[WebSocket.CLOSING,WebSocket.CLOSED],MD=class extends ZE{criteria;constructor(...e){super(),this.criteria=new Set(e)}getCriteria(){return this.criteria}_addCriteria(e){this.criteria.add(e)}_removeCriteria(e){this.criteria.delete(e)}},ND=class{criteria;emitter;refCount;subscriptionProps;subscriptionId;token;tokenExpiry;state=`idle`;generation=0;lastUnrefTime;constructor(e,t){this.criteria=e,this.emitter=new MD(e),this.refCount=1,this.subscriptionProps=t?{...t}:void 0}nextGeneration(){return++this.generation}},PD=class{medplum;ws;masterSubEmitter;criteriaEntries;criteriaEntriesBySubscriptionId;wsClosed;pingTimer=void 0;tokenRefreshTimer=void 0;pingIntervalMs;waitingForPong=!1;currentProfile;constructor(e,t,n){if(!(e instanceof JD))throw new Yx(Ux("First arg of constructor should be a `MedplumClient`"));let r;try{r=new URL(t).toString()}catch{throw new Yx(Ux(`Not a valid URL`))}let i=n?.ReconnectingWebSocket?new n.ReconnectingWebSocket(r,void 0,{debug:n?.debug,debugLogger:n?.debugLogger}):new kD(r,void 0,{debug:n?.debug,debugLogger:n?.debugLogger});this.medplum=e,this.ws=i,this.masterSubEmitter=new MD,this.criteriaEntries=new Map,this.criteriaEntriesBySubscriptionId=new Map,this.wsClosed=!1,this.pingIntervalMs=n?.pingIntervalMs??5e3,this.currentProfile=e.getProfile(),this.setupListeners()}setupListeners(){let e=this.ws;e.addEventListener(`message`,e=>{try{let t=JSON.parse(e.data);if(t.type===`pong`){this.waitingForPong=!1;return}let n=t,r=n?.entry?.[0]?.resource;if(r.type===`heartbeat`){this.masterSubEmitter?.dispatchEvent({type:`heartbeat`,payload:n});return}if(r.type===`handshake`){let e=oC(r.subscription),t={type:`connect`,payload:{subscriptionId:e}};this.masterSubEmitter?.dispatchEvent(t);let n=this.criteriaEntriesBySubscriptionId.get(e);if(!n){console.warn(`Received handshake for criteria the SubscriptionManager is not listening for yet`);return}(n.state===`connecting`||n.state===`refreshing`)&&(n.state=`active`),n.emitter.dispatchEvent({...t});return}this.masterSubEmitter?.dispatchEvent({type:`message`,payload:n});let i=this.criteriaEntriesBySubscriptionId.get(oC(r.subscription));if(!i){console.warn(`Received notification for criteria the SubscriptionManager is not listening for`);return}i.emitter.dispatchEvent({type:`message`,payload:n})}catch(e){console.error(e);let t={type:`error`,payload:e};this.masterSubEmitter?.dispatchEvent(t);for(let e of this.getAllCriteriaEmitters())e.dispatchEvent({...t})}}),e.addEventListener(`error`,e=>{let t={type:`error`,payload:new Yx({resourceType:`OperationOutcome`,issue:[{severity:`error`,code:`exception`,details:{text:`WebSocket connection closed due to an error`},diagnostics:e.error.toString()}]})};this.masterSubEmitter?.dispatchEvent(t);for(let e of this.getAllCriteriaEmitters())e.dispatchEvent({...t})}),e.addEventListener(`close`,()=>{let e={type:`close`};this.masterSubEmitter?.dispatchEvent(e);for(let t of this.getAllCriteriaEmitters())t.dispatchEvent({...e});this.pingTimer&&(clearInterval(this.pingTimer),this.pingTimer=void 0,this.waitingForPong=!1),this.tokenRefreshTimer&&=(clearInterval(this.tokenRefreshTimer),void 0),this.wsClosed&&(this.criteriaEntries.clear(),this.criteriaEntriesBySubscriptionId.clear(),this.masterSubEmitter?.removeAllListeners())}),e.addEventListener(`open`,()=>{let t={type:`open`};this.masterSubEmitter?.dispatchEvent(t);for(let e of this.getAllCriteriaEmitters())e.dispatchEvent({...t});this.refreshAllSubscriptions().catch(console.error),this.pingTimer??=setInterval(()=>{this.waitingForPong?(this.waitingForPong=!1,e.reconnect()):(e.send(JSON.stringify({type:`ping`})),this.waitingForPong=!0),this.gcUnrefEntries()},this.pingIntervalMs),this.tokenRefreshTimer??=setInterval(()=>{this.checkTokenExpirations(),this.gcUnrefEntries()},AD)}),this.medplum.addEventListener(`change`,()=>{let e=this.medplum.getProfile();this.currentProfile&&e===void 0?this.ws.close():e&&this.currentProfile?.id!==e.id&&this.ws.reconnect(),this.currentProfile=e})}sendBind(e){this.ws.send(JSON.stringify({type:`bind-with-token`,payload:{token:e}}))}sendUnbind(e){this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:`unbind-from-token`,payload:{token:e}}))}emitError(e,t){let n={type:`error`,payload:t};this.masterSubEmitter?.dispatchEvent(n),e.emitter.dispatchEvent({...n})}maybeEmitDisconnect(e){let{subscriptionId:t}=e;if(t){let n={type:`disconnect`,payload:{subscriptionId:t}};this.masterSubEmitter?.dispatchEvent(n),e.emitter.dispatchEvent({...n})}else console.warn("Called disconnect for `CriteriaEntry` before `subscriptionId` was present.")}isStale(e,t){return this.isEntryGettingRemoved(e)||e.generation!==t}maybeGetCriteriaEntry(e,t){let n=this.criteriaEntries.get(e);if(n){if(!t)return n.bareCriteria;for(let e of n.criteriaWithProps)if(wC(t,e.subscriptionProps))return e}}getAllCriteriaEmitters(){let e=[];for(let t of this.criteriaEntries.values())for(let n of FD(t))n.refCount>0&&e.push(n.emitter);return e}addCriteriaEntry(e){let{criteria:t,subscriptionProps:n}=e,r;this.criteriaEntries.has(t)?r=this.criteriaEntries.get(t):(r={criteriaWithProps:[]},this.criteriaEntries.set(t,r)),n?r.criteriaWithProps.push(e):r.bareCriteria=e}removeCriteriaEntry(e){e.state=`removed`,e.generation++;let{criteria:t,subscriptionProps:n,subscriptionId:r,token:i}=e;if(!this.criteriaEntries.has(t))return;let a=this.criteriaEntries.get(t);n?a.criteriaWithProps=a.criteriaWithProps.filter(e=>{let t=e.subscriptionProps;return!wC(n,t)}):a.bareCriteria=void 0,!a.bareCriteria&&a.criteriaWithProps.length===0&&(this.criteriaEntries.delete(t),this.masterSubEmitter?._removeCriteria(t)),r&&this.criteriaEntriesBySubscriptionId.delete(r),i&&this.sendUnbind(i)}async subscribeToCriteria(e){this.wsClosed&&await this.reconnectIfNeeded(),this.ws.readyState===WebSocket.OPEN&&this.medplum.getProfile()&&e.state===`idle`&&(e.state=`connecting`,await this.rebindCriteriaEntry(e))}async refreshAllSubscriptions(){this.criteriaEntriesBySubscriptionId.clear();let e=[],t=[];for(let n of this.criteriaEntries.values())for(let r of FD(n))r.refCount===0?t.push(r):e.push(r);for(let e of t)this.removeCriteriaEntry(e);for(let t of e)t.token&&this.sendUnbind(t.token),t.token=void 0,t.tokenExpiry=void 0,t.state=`idle`,t.generation++,await this.subscribeToCriteria(t)}async rebindCriteriaEntry(e){let t=e.nextGeneration();try{if(!e.subscriptionId){let n=await this.medplum.createResource({...e.subscriptionProps,resourceType:`Subscription`,status:`active`,reason:`WebSocket subscription for ${aC(this.medplum.getProfile())}`,channel:{type:`websocket`},criteria:e.criteria});if(e.subscriptionId??=n.id,this.isStale(e,t))return}let{parameter:n}=await this.medplum.get(`fhir/R4/Subscription/${e.subscriptionId}/$get-ws-binding-token`,{cache:`no-cache`}),r=n?.find(e=>e.name===`token`)?.valueString,i=n?.find(e=>e.name===`websocket-url`)?.valueUrl,a=n?.find(e=>e.name===`expiration`)?.valueDateTime;if(!r)throw new Yx(Ux(`Failed to get token`));if(!i)throw new Yx(Ux(`Failed to get URL from $get-ws-binding-token`));if(!a)throw new Yx(Ux(`Failed to get expiration from $get-ws-binding-token`));if(this.isStale(e,t))return;e.token=r,e.tokenExpiry=new Date(a).getTime(),this.criteriaEntriesBySubscriptionId.set(e.subscriptionId,e),this.sendBind(r)}catch(n){console.error(Zx(n)),e.generation===t&&!this.isEntryGettingRemoved(e)&&(e.state=e.state===`refreshing`?`active`:`idle`),this.emitError(e,n)}}checkTokenExpirations(){if(!this.medplum.getProfile())return;let e=Date.now();for(let t of this.criteriaEntries.values())for(let n of FD(t))n.refCount===0||!n.tokenExpiry||n.tokenExpiry-e<=3e5&&n.state===`active`&&this.ws.readyState===WebSocket.OPEN&&(n.state=`refreshing`,this.rebindCriteriaEntry(n).catch(e=>{this.masterSubEmitter?.dispatchEvent({type:`error`,payload:e})}))}addCriteria(e,t){this.masterSubEmitter&&this.masterSubEmitter._addCriteria(e);let n=this.maybeGetCriteriaEntry(e,t);if(n)return n.refCount===0&&(n.lastUnrefTime=void 0,n.generation++,n.state!==`active`&&(n.state=n.token?`active`:`idle`)),n.refCount+=1,n.state===`idle`&&this.subscribeToCriteria(n).catch(console.error),n.emitter;let r=new ND(e,t);return this.addCriteriaEntry(r),this.subscribeToCriteria(r).catch(console.error),r.emitter}removeCriteria(e,t){let n=this.maybeGetCriteriaEntry(e,t);if(!n||this.isEntryGettingRemoved(n)){console.warn("Criteria not known to `SubscriptionManager`. Possibly called remove too many times.");return}--n.refCount,n.refCount===0&&(n.lastUnrefTime=Date.now(),n.generation++)}gcUnrefEntries(){let e=Date.now(),t=[];for(let n of this.criteriaEntries.values())for(let r of FD(n))r.refCount===0&&r.lastUnrefTime!==void 0&&e-r.lastUnrefTime>=1e4&&t.push(r);for(let e of t)this.maybeEmitDisconnect(e),this.removeCriteriaEntry(e);t.length>0&&this.criteriaEntries.size===0&&this.closeWebSocket()}isEntryGettingRemoved(e){return e.refCount===0||e.state===`removed`}getWebSocket(){return this.ws}closeWebSocket(){if(!this.wsClosed){if(this.ws.readyState===WebSocket.OPEN)for(let e of this.criteriaEntries.values())for(let t of FD(e))t.token&&this.sendUnbind(t.token);this.wsClosed=!0,this.ws.close()}}reconnectWebSocket(){this.ws.reconnect(),this.wsClosed=!1}getCriteriaCount(){return this.getAllCriteriaEmitters().length}getMasterEmitter(){return this.masterSubEmitter||=new MD(...Array.from(this.criteriaEntries.keys())),this.masterSubEmitter}async reconnectIfNeeded(){jD.includes(this.getWebSocket().readyState)&&await new Promise(e=>{let t=()=>{this.getWebSocket().removeEventListener(`open`,t),e()};this.getWebSocket().addEventListener(`open`,t),this.reconnectWebSocket()})}};function FD(e){return e.bareCriteria?[e.bareCriteria,...e.criteriaWithProps]:e.criteriaWithProps}new xx(1e3);var ID=`5.1.14-776e611`,LD=YE.FHIR_JSON+`, */*; q=0.1`,RD=`https://api.medplum.com/`,zD=1e3,BD=6e4,VD=0,HD=3e5,UD=`Binary/`,WD={resourceType:`Device`,id:`system`,deviceName:[{type:`model-name`,name:`System`}]},GD={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`,PreAuthorizedCode:`urn:ietf:params:oauth:grant-type:pre-authorized_code`},KD={AccessToken:`urn:ietf:params:oauth:token-type:access_token`,RefreshToken:`urn:ietf:params:oauth:token-type:refresh_token`,IdToken:`urn:ietf:params:oauth:token-type:id_token`,Saml1Token:`urn:ietf:params:oauth:token-type:saml1`,Saml2Token:`urn:ietf:params:oauth:token-type:saml2`},qD={JwtBearer:`urn:ietf:params:oauth:client-assertion-type:jwt-bearer`},JD=class extends ZE{options;fetch;createPdfImpl;storage;requestCache;cacheTime;baseUrl;fhirBaseUrl;authorizeUrl;tokenUrl;logoutUrl;fhircastHubUrl;cdsServicesUrl;defaultHeaders;onUnauthenticated;autoBatchTime;autoBatchQueue;maxRetries;maxRetryTime;refreshGracePeriod;subscriptionManager;medplumServer;clientId;clientSecret;credentialsInHeader;autoBatchTimerId;accessToken;accessTokenExpires;refreshToken;refreshPromise;profilePromise;sessionDetails;currentRateLimits;basicAuth;initPromise;initComplete=!0;keyValueClient;logLevel;constructor(e){if(super(),e?.baseUrl&&!e.baseUrl.startsWith(`http`))throw Error(`Base URL must start with http or https`);this.options=e??{},this.fetch=e?.fetch??YD(),this.storage=e?.storage??new bD(void 0,e?.storagePrefix),this.createPdfImpl=e?.createPdf,this.baseUrl=XC(e?.baseUrl??RD),this.fhirBaseUrl=QC(this.baseUrl,e?.fhirUrlPath??`fhir/R4`),this.authorizeUrl=QC(this.baseUrl,e?.authorizeUrl??`oauth2/authorize`),this.tokenUrl=QC(this.baseUrl,e?.tokenUrl??`oauth2/token`),this.logoutUrl=QC(this.baseUrl,e?.logoutUrl??`oauth2/logout`),this.fhircastHubUrl=QC(this.baseUrl,e?.fhircastHubUrl??`fhircast/STU3`),this.cdsServicesUrl=QC(this.baseUrl,e?.cdsServicesUrl??`cds-services`),this.clientId=e?.clientId??``,this.clientSecret=e?.clientSecret??``,this.credentialsInHeader=e?.authCredentialsMethod===`header`,this.defaultHeaders=e?.defaultHeaders??{},this.onUnauthenticated=e?.onUnauthenticated,this.refreshGracePeriod=e?.refreshGracePeriod??HD,this.logLevel=this.initializeLogLevel(e),this.maxRetries=e?.maxRetries??2,this.maxRetryTime=e?.maxRetryTime??2e3,this.cacheTime=e?.cacheTime??(NE()?BD:VD),this.cacheTime>0?this.requestCache=new xx(e?.resourceCacheSize??zD):this.requestCache=void 0,e?.autoBatchTime?(this.autoBatchTime=e.autoBatchTime,this.autoBatchQueue=[]):(this.autoBatchTime=0,this.autoBatchQueue=void 0),e?.accessToken&&this.setAccessToken(e.accessToken),this.storage.getInitPromise===void 0?(e?.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(()=>{e?.accessToken||this.attemptResumeActiveLogin().catch(console.error),this.initComplete=!0,this.dispatchEvent({type:`storageInitialized`})}).catch(e=>{console.error(e),this.initComplete=!0,this.dispatchEvent({type:`storageInitFailed`,payload:{error:e}})})),this.setupStorageListener()}get isInitialized(){return this.initComplete}getInitPromise(){return this.initPromise}initializeLogLevel(e){return e?.logLevel?e.logLevel:e?.verbose===void 0?`none`:e.verbose?`verbose`:`none`}async attemptResumeActiveLogin(){let e=this.getActiveLogin();e&&(this.setAccessToken(e.accessToken,e.refreshToken),await this.refreshProfile())}getBaseUrl(){return this.baseUrl}getAuthorizeUrl(){return this.authorizeUrl}getTokenUrl(){return this.tokenUrl}getLogoutUrl(){return this.logoutUrl}getFhircastHubUrl(){return this.fhircastHubUrl}getCdsServicesUrl(){return this.cdsServicesUrl}getDefaultHeaders(){return this.defaultHeaders}clear(){this.storage.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(e){e=e.toString(),this.requestCache?.delete(e)}invalidateAll(){this.requestCache?.clear()}invalidateSearches(e){let t=QC(this.fhirBaseUrl,e);for(let e of this.requestCache?.keys()??rw)(e.endsWith(t)||e.includes(t+`?`))&&this.requestCache?.delete(e)}get(e,t={}){e=e.toString();let n=this.getCacheEntry(e,t);if(n)return n.value;let r;e.startsWith(this.fhirBaseUrl)&&this.autoBatchQueue&&!t.disableAutoBatch?r=new Promise((n,r)=>{this.autoBatchQueue.push({method:`GET`,url:e.replace(this.fhirBaseUrl,``),options:t,resolve:n,reject:r}),this.autoBatchTimerId||=setTimeout(()=>this.executeAutoBatch(),this.autoBatchTime)}):(t.method=`GET`,r=this.request(e,t));let i=new yD(r);return this.setCacheEntry(e,i,t),i}post(e,t,n,r={}){return e=e.toString(),this.setRequestBody(r,t),n&&this.setRequestContentType(r,n),this.invalidateUrl(e),r.method=`POST`,this.request(e,r)}put(e,t,n,r={}){return e=e.toString(),this.setRequestBody(r,t),n&&this.setRequestContentType(r,n),this.invalidateUrl(e),r.method=`PUT`,this.request(e,r)}patch(e,t,n={}){return e=e.toString(),this.setRequestBody(n,t),this.setRequestContentType(n,YE.JSON_PATCH),this.invalidateUrl(e),n.method=`PATCH`,this.request(e,n)}delete(e,t={}){return e=e.toString(),this.invalidateUrl(e),t.method=`DELETE`,this.request(e,t)}async startNewUser(e,t){let{codeChallengeMethod:n,codeChallenge:r}=await this.startPkce();return this.post(`auth/newuser`,{...e,clientId:e.clientId??this.clientId,codeChallengeMethod:n,codeChallenge:r},void 0,t)}async startNewProject(e,t){return this.post(`auth/newproject`,e,void 0,t)}async startNewPatient(e,t){return this.post(`auth/newpatient`,e,void 0,t)}async startLogin(e,t){return this.post(`auth/login`,{...await this.ensureCodeChallenge(e),clientId:e.clientId??this.clientId,scope:e.scope},void 0,t)}async startGoogleLogin(e,t){return this.post(`auth/google`,{...await this.ensureCodeChallenge(e),clientId:e.clientId??this.clientId,scope:e.scope},void 0,t)}async ensureCodeChallenge(e){return e.codeChallenge?e:{...e,...await this.startPkce()}}async signOut(){await this.post(this.logoutUrl,{}),this.clear()}async signInWithRedirect(e){let t=new URLSearchParams(FE.getSearch()).get(`code`);if(!t){await this.requestAuthorization(e);return}return this.processCode(t)}signOutWithRedirect(){FE.assign(this.logoutUrl)}async signInWithExternalAuth(e,t,n,r,i=!0){let a=r;i&&(a=await this.ensureCodeChallenge(r)),FE.assign(this.getExternalAuthRedirectUri(e,t,n,a,i))}async exchangeExternalAccessToken(e,t,n){if(t??=this.clientId,!t)throw Error(`MedplumClient is missing clientId`);let r={grant_type:GD.TokenExchange,subject_token_type:KD.AccessToken,client_id:t,subject_token:e};return n&&(r.membership_id=n),this.fetchTokens(r)}getExternalAuthRedirectUri(e,t,n,r,i=!0){let a=new URL(e);if(a.searchParams.set(`response_type`,`code`),a.searchParams.set(`client_id`,t),a.searchParams.set(`redirect_uri`,n),a.searchParams.set(`scope`,r.scope??`openid profile email`),a.searchParams.set(`state`,JSON.stringify(r)),i){let{codeChallenge:e,codeChallengeMethod:t}=r;if(!t)throw Error("`LoginRequest` for external auth must include a `codeChallengeMethod`.");if(!e)throw Error("`LoginRequest` for external auth must include a `codeChallenge`.");a.searchParams.set(`code_challenge_method`,t),a.searchParams.set(`code_challenge`,e)}return a.toString()}fhirUrl(...e){return new URL(QC(this.fhirBaseUrl,e.join(`/`)))}fhirSearchUrl(e,t){let n=this.fhirUrl(e);return t&&(n.search=ew(t)),n}search(e,t,n){let r=this.fhirSearchUrl(e,t),i=`search-`+r.toString(),a=this.getCacheEntry(i,n);if(a)return a.value;let o=this.getBundle(r,n);return this.setCacheEntry(i,o,n),o}searchOne(e,t,n){let r=this.fhirSearchUrl(e,t);r.searchParams.set(`_count`,`1`),r.searchParams.sort();let i=`searchOne-`+r.toString(),a=this.getCacheEntry(i,n);if(a)return a.value;let o=new yD(this.search(e,r.searchParams,n).then(e=>e.entry?.[0]?.resource));return this.setCacheEntry(i,o,n),o}searchResources(e,t,n){let r=`searchResources-`+this.fhirSearchUrl(e,t).toString(),i=this.getCacheEntry(r,n);if(i)return i.value;let a=new yD(this.search(e,t,n).then(ZD));return this.setCacheEntry(r,a,n),a}async*searchResourcePages(e,t,n){let r=this.fhirSearchUrl(e,t);for(;r;){let t=new URL(r).searchParams;t.has(`_count`)||t.set(`_count`,`1000`);let i=await this.search(e,t,n),a=i.link?.find(e=>e.relation===`next`);if(!i.entry?.length&&!a)break;yield ZD(i),r=a?.url?new URL(a.url):void 0}}valueSetExpand(e,t){let n=this.fhirUrl(`ValueSet`,`$expand`);return n.search=new URLSearchParams(e).toString(),this.get(n.toString(),t)}getCached(e,t){let n=this.requestCache?.get(this.fhirUrl(e,t).toString())?.value;return n?.isOk()?n.read():void 0}getCachedReference(e){let t=e.reference;if(!t)return;if(t===`system`)return WD;let[n,r]=t.split(`/`);if(!(!n||!r))return this.getCached(n,r)}readResource(e,t,n){if(!t)throw Error(`The "id" parameter cannot be null, undefined, or an empty string.`);return this.get(this.fhirUrl(e,t),n)}readReference(e,t){let n=e.reference;if(!n)return new yD(Promise.reject(Error(`Missing reference`)));if(n===`system`)return new yD(Promise.resolve(WD));let[r,i]=n.split(`/`);return!r||!i?new yD(Promise.reject(Error(`Invalid reference`))):this.readResource(r,i,t)}readCanonical(e,t,n){return Array.isArray(e)?this.searchOne(``,{_type:e.join(`,`),url:t},n):this.searchOne(e,`url=`+t,n)}requestSchema(e,t){if(dS(e))return Promise.resolve();let n=e+`-requestSchema`,r=this.getCacheEntry(n,void 0);if(r)return r.value;let i=new yD((async()=>{let t=`{
56
+ `?(this.pos.line++,this.pos.column=0):this.pos.column++}buildToken(e,t){let n=this.markStack.pop();if(!n)throw Error(`No mark for token`);return{id:e,value:t,...n}}};function CT(e){return!!(e&&(e.id===`String`||e.id===`Symbol`&&bT.includes(e.value)))}var wT=[`true`,`false`],TT=[`!=`,`!~`,`<=`,`>=`,`{}`,`->`];function ET(e){return new ST(e,wT,TT).tokenize()}var DT={FunctionCall:0,Dot:1,Indexer:2,UnaryAdd:3,UnarySubtract:3,Multiply:4,Divide:4,IntegerDivide: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,Arrow:100,Semicolon:200},OT={parse(e){let t=e.consumeAndParse();if(!e.match(`)`))throw Error("Parse error: expected `)` got `"+e.peek()?.value+"`");return t}},kT={parse(e,t){let n=e.consumeAndParse();if(!e.match(`]`))throw Error("Parse error: expected `]`");return new yT(t,n)},precedence:DT.Indexer},AT={parse(e,t){if(!(t instanceof Qw))throw Error(`Unexpected parentheses`);let n=[];for(;!e.match(`)`);)n.push(e.consumeAndParse()),e.match(`,`);return new vT(t.name,n)},precedence:DT.FunctionCall};function jT(e){let t=e.split(` `),n=Number.parseFloat(t[0]),r=t[1];return r=r?.startsWith(`'`)&&r.endsWith(`'`)?r.substring(1,r.length-1):`{`+r+`}`,{value:n,unit:r}}function MT(){return new wx().registerPrefix(`String`,{parse:(e,t)=>new Zw({type:X.string,value:t.value})}).registerPrefix(`DateTime`,{parse:(e,t)=>new Zw({type:X.dateTime,value:Uw(t.value)})}).registerPrefix(`Quantity`,{parse:(e,t)=>new Zw({type:X.Quantity,value:jT(t.value)})}).registerPrefix(`Number`,{parse:(e,t)=>new Zw({type:t.value.includes(`.`)?X.decimal:X.integer,value:Number.parseFloat(t.value)})}).registerPrefix(`true`,{parse:()=>new Zw({type:X.boolean,value:!0})}).registerPrefix(`false`,{parse:()=>new Zw({type:X.boolean,value:!1})}).registerPrefix(`Symbol`,{parse:(e,t)=>new Qw(t.value)}).registerPrefix(`{}`,{parse:()=>new $w}).registerPrefix(`(`,OT).registerInfix(`[`,kT).registerInfix(`(`,AT).prefix(`+`,DT.UnaryAdd,(e,t)=>new eT(`+`,t,e=>e)).prefix(`-`,DT.UnarySubtract,(e,t)=>new nT(`-`,t,t,(e,t)=>-t)).infixLeft(`.`,DT.Dot,(e,t,n)=>new sT(e,n)).infixLeft(`/`,DT.Divide,(e,t,n)=>new nT(`/`,e,n,(e,t)=>e/t)).infixLeft(`*`,DT.Multiply,(e,t,n)=>new nT(`*`,e,n,(e,t)=>e*t)).infixLeft(`+`,DT.Add,(e,t,n)=>new nT(`+`,e,n,(e,t)=>e+t)).infixLeft(`-`,DT.Subtract,(e,t,n)=>new nT(`-`,e,n,(e,t)=>e-t)).infixLeft(`|`,DT.Union,(e,t,n)=>new cT(e,n)).infixLeft(`=`,DT.Equals,(e,t,n)=>new lT(e,n)).infixLeft(`!=`,DT.NotEquals,(e,t,n)=>new uT(e,n)).infixLeft(`~`,DT.Equivalent,(e,t,n)=>new dT(e,n)).infixLeft(`!~`,DT.NotEquivalent,(e,t,n)=>new fT(e,n)).infixLeft(`<`,DT.LessThan,(e,t,n)=>new nT(`<`,e,n,(e,t)=>e<t)).infixLeft(`<=`,DT.LessThanOrEquals,(e,t,n)=>new nT(`<=`,e,n,(e,t)=>e<=t)).infixLeft(`>`,DT.GreaterThan,(e,t,n)=>new nT(`>`,e,n,(e,t)=>e>t)).infixLeft(`>=`,DT.GreaterThanOrEquals,(e,t,n)=>new nT(`>=`,e,n,(e,t)=>e>=t)).infixLeft(`&`,DT.Ampersand,(e,t,n)=>new iT(e,n)).infixLeft(`and`,DT.And,(e,t,n)=>new mT(e,n)).infixLeft(`as`,DT.As,(e,t,n)=>new tT(e,n)).infixLeft(`contains`,DT.Contains,(e,t,n)=>new aT(e,n)).infixLeft(`div`,DT.Divide,(e,t,n)=>new nT(`div`,e,n,(e,t)=>Math.trunc(e/t))).infixLeft(`in`,DT.In,(e,t,n)=>new oT(e,n)).infixLeft(`is`,DT.Is,(e,t,n)=>new pT(e,n)).infixLeft(`mod`,DT.Modulo,(e,t,n)=>new nT(`mod`,e,n,(e,t)=>e%t)).infixLeft(`or`,DT.Or,(e,t,n)=>new hT(e,n)).infixLeft(`xor`,DT.Xor,(e,t,n)=>new gT(e,n)).infixLeft(`implies`,DT.Implies,(e,t,n)=>new _T(e,n))}var NT=MT();function PT(e){return new Xw(e,NT.construct(ET(e)).consumeAndParse())}function FT(e,t){let n=Array.isArray(t)?t:[t];for(let e=0;e<n.length;e++){let t=n[e];typeof t==`object`&&`type`in t&&`value`in t||(n[e]=AS(n[e]))}return IT(e,n).map(e=>e.value)}function IT(e,t,n={},r=void 0){let i;if(typeof e==`string`){let t=r?.get(e);i=t??PT(e),r&&!t&&r.set(e,i)}else i=e;return i.eval({variables:n},t).map(e=>{let t={type:e.type,value:e.value?.valueOf()};return`path`in e&&(t.path=e.path),t})}function LT(e){let t=[];for(let n of e){let e=YS(n.value);e&&t.push(e)}return t}function RT(e){let t=new Set;for(let n of e){let e=iw(n);e&&t.add(e)}return Array.from(t)}function zT(e){let t=new Set;for(let n of e){let{value:e}=n;e&&(NC(e)?t.add(e):Vw(e)?t.add(e.reference):rC(e)?t.add(aC(e)):typeof e.identifier==`object`&&t.add(`identifier:${e.identifier.system}|${e.identifier.value}`))}return Array.from(t)}function BT(e,t={}){let n=[];for(let r of e)VT(t,n,r);return n}function VT(e,t,n){let{type:r,value:i}=n;switch(r){case X.Identifier:HT(t,e,i);break;case X.CodeableConcept:UT(t,e,i);break;case X.Coding:WT(t,e,i);break;case X.ContactPoint:GT(t,e,i);break;default:KT(t,e,void 0,i?.toString())}}function HT(e,t,n){n?.type?.text&&KT(e,t,t.textSearchSystem,n.type.text),KT(e,t,n?.system,n?.value)}function UT(e,t,n){n?.text&&KT(e,t,t.textSearchSystem,n.text);for(let r of n?.coding??rw)WT(e,t,r)}function WT(e,t,n){n&&(n.display&&KT(e,t,t.textSearchSystem,n.display),KT(e,t,n.system,n.code))}function GT(e,t,n){n&&KT(e,t,n.system,n.value?.toLocaleLowerCase())}function KT(e,t,n,r){(n||r)&&!e.some(e=>e.system===n&&e.value===r)&&e.push({system:n,value:r&&t.caseInsensitive?r.toLocaleLowerCase():r})}var Z={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`},qT={contains:Z.CONTAINS,exact:Z.EXACT,above:Z.ABOVE,below:Z.BELOW,text:Z.TEXT,not:Z.NOT,in:Z.IN,"not-in":Z.NOT_IN,"of-type":Z.OF_TYPE,missing:Z.MISSING,identifier:Z.IDENTIFIER,iterate:Z.ITERATE},JT={eq:Z.EQUALS,ne:Z.NOT_EQUALS,lt:Z.LESS_THAN,le:Z.LESS_THAN_OR_EQUALS,gt:Z.GREATER_THAN,ge:Z.GREATER_THAN_OR_EQUALS,sa:Z.STARTS_AFTER,eb:Z.ENDS_BEFORE,ap:Z.APPROXIMATELY,sw:Z.STARTS_WITH};function YT(e,t){if(!e)throw Error(`Invalid search URL`);let n=``,r;if(typeof e==`string`)if(e.includes(`?`)){let[t,i]=e.split(`?`);n=t,r=new URLSearchParams(i)}else n=e;else typeof e==`object`&&(n=e.pathname,r=e.searchParams);let i;i=n.includes(`/`)?n.split(`/`).filter(Boolean).pop():n;let a=[];if(r&&a.push(...r.entries()),t)for(let[e,n]of Object.entries(t))if(Array.isArray(n))for(let t of n)a.push([e,t]);else a.push([e,n??``]);return XT(i,a)}function XT(e,t){let n={resourceType:e};for(let[e,r]of t)ZT(n,e,r);return n}function ZT(e,t,n){let r,i,a=t.indexOf(`:`);if(a>=0?(r=t.substring(0,a),i=t.substring(a+1)):(r=t,i=``),r!==`_`){if(r===`_has`||t.includes(`.`)){e.filters=JC(e.filters,{code:t,operator:Z.EQUALS,value:n});return}switch(r){case`_sort`:QT(e,n);break;case`_cursor`:e.cursor=n;break;case`_count`:e.count=Number.parseInt(n,10);break;case`_offset`:e.offset=Number.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`:{let t=iE(n);i===`iterate`&&(t.modifier=Z.ITERATE),e.include=JC(e.include,t);break}case`_revinclude`:{let t=iE(n);i===`iterate`&&(t.modifier=Z.ITERATE),e.revInclude=JC(e.revInclude,t);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:{let t=Hw.types[e.resourceType]?.searchParams?.[r];t?e.filters=JC(e.filters,eE(t,Z.EQUALS,i,n)):e.filters=JC(e.filters,tE(r,i,n))}}}}function QT(e,t){for(let n of t.split(`,`)){let t,r=!1;n.startsWith(`-`)?(t=n.substring(1),r=!0):t=n,e.sortRules||=[],e.sortRules.push({code:t,descending:r})}}var $T=[Z.MISSING,Z.PRESENT];function eE(e,t,n,r){if($T.includes(n||t))return{code:e.code,operator:n||t,value:r};switch(e.type){case`number`:case`date`:case`quantity`:{let{operator:t,value:i}=nE(r,n||Z.EQUALS);if(!aE(e,i))throw new Yx(Hx(`Invalid format for ${e.type} search parameter: ${i}`));return{code:e.code,operator:t,value:i}}case`reference`:case`string`:case`token`:case`uri`:if(!aE(e,r))throw new Yx(Hx(`Invalid format for ${e.type} search parameter: ${r}`));return{code:e.code,operator:rE(n)??t,value:r};default:throw Error(`Unrecognized search parameter type: `+e.type)}}function tE(e,t,n){let r=Z.EQUALS;if(t)r=t;else if(n.length>=2){let e=n.substring(0,2);e in JT&&(n.length===2||n.at(2)?.match(/\d/))&&(r=e,n=n.substring(e.length))}return{code:e,operator:r,value:n}}function nE(e,t){let n=JT[e.substring(0,2)];return n?{operator:n,value:e.substring(2)}:{operator:t,value:e}}function rE(e){return qT[e]}function iE(e){let t=e.split(`:`);if(t.includes(`*`))throw new Yx(Hx(`'*' is not supported as a value for search inclusion parameters`));if(t.length===1)throw new Yx(Hx(`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 Yx(Hx(`Invalid include value '${e}'`))}function aE(e,t){switch(e.type){case`date`:return qS(t);default:return!0}}function oE(e){let t=[];e.fields&&t.push(`_fields=`+e.fields.join(`,`));for(let n of e.filters??rw)t.push(sE(n));e.sortRules&&e.sortRules.length>0&&t.push(cE(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(`,`));for(let n of e.include??rw)t.push(lE(`_include`,n));for(let n of e.revInclude??rw)t.push(lE(`_revinclude`,n));return t.length===0?``:(YC(t),`?`+t.join(`&`))}function sE(e){let t=e.operator in qT?`:`+e.operator:``,n=e.operator!==Z.EQUALS&&e.operator in JT?e.operator:``;return`${e.code}${t}=${n}${encodeURIComponent(e.value)}`}function cE(e){return`_sort=`+e.map(e=>e.descending?`-`+e.code:e.code).join(`,`)}function lE(e,t){return e+(t.modifier?`:`+t.modifier:``)+`=`+t.resourceType+`:`+t.searchParam+(t.targetType?`:`+t.targetType:``)}function uE(e){let t=[],n=``,r=!1;for(let i of e)r?(n+=i,r=!1):i===`\\`?r=!0:i===`,`?(t.push(n),n=``):n+=i;return t.push(n),t}function dE(e,t){if(t.resourceType!==e.resourceType)return!1;for(let n of t.filters??rw)if(!pE(e,t,n))return!1;return!0}var fE=new xx(1e3);function pE(e,t,n){let r=Hw.types[t.resourceType]?.searchParams?.[n.code];if(!r)return!1;let i=IT(r.expression,[AS(e)],void 0,fE);if(n.operator===Z.MISSING||n.operator===Z.PRESENT)return mE(i,n);switch(r.type){case`reference`:return hE(r,i,n);case`string`:case`uri`:return vE(i,n);case`token`:return gE(i,n);case`date`:return bE(i,n);default:return!1}}function mE(e,t){let n=e.length>0;return(t.operator===Z.MISSING&&t.value===`false`||t.operator===Z.PRESENT&&t.value===`true`)===n}function hE(e,t,n){let r=SE(n.operator);if(n.value===``&&t.length===0)return n.operator===Z.EQUALS;let i=zT(t);for(let t of uE(n.value)){let a=!1;if(t.includes(`/`)?a=i.includes(t):(e.target?.length===1||n.code===`_compartment`)&&(a=i.some(e=>e?.endsWith(`/`+t))),a)return!r}return r}function gE(e,t){let n=BT(e),r=uE(t.value),i=SE(t.operator);for(let e of n)for(let t of r)if(_E(e,t))return!i;return i}function _E(e,t){if(t.includes(`|`)){let[n,r]=t.split(`|`).map(e=>e.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 vE(e,t){let n=RT(e),r=uE(t.value),i=SE(t.operator);for(let e of n)for(let t of r)if(yE(e,t))return!i;return i}function yE(e,t){return e.toLowerCase().includes(t.toLowerCase())}function bE(e,t){let n=LT(e),r=uE(t.value),i=SE(t.operator);for(let e of n)for(let n of r)if(xE(e,t.operator,n))return!i;return i}function xE(e,t,n){if(!e)return!1;let r=YS(n);if(!r)return!1;let i=e.start??`0000`,a=e.end??`9999`,o=r.start,s=r.end;switch(t){case Z.APPROXIMATELY:case Z.EQUALS:case Z.NOT_EQUALS:return i<s&&a>o;case Z.LESS_THAN:return i<o;case Z.GREATER_THAN:return a>s;case Z.LESS_THAN_OR_EQUALS:return i<=s;case Z.GREATER_THAN_OR_EQUALS:return a>=o;case Z.STARTS_AFTER:return i>s;case Z.ENDS_BEFORE:return a<o;default:return!1}}function SE(e){return e===Z.NOT_EQUALS||e===Z.NOT}var CE={resourceType:`*`},wE=[`DomainConfiguration`,`JsonWebKey`,`Login`],TE=[`Package`,`PackageRelease`,`PackageInstallation`,`Project`,`ProjectMembership`,`User`,`UserSecurityRequest`],EE={READ:`read`,VREAD:`vread`,UPDATE:`update`,DELETE:`delete`,HISTORY:`history`,CREATE:`create`,SEARCH:`search`},DE=[EE.READ,EE.VREAD,EE.HISTORY,EE.SEARCH];function OE(e,t){return wE.includes(t)?!1:kE(e,EE.UPDATE,t)}function kE(e,t,n){return!!e.resource?.some(e=>ME(e,n,t))}function AE(e,t,n){return n?n.resource?.find(n=>jE(e,t,n)):CE}function jE(e,t,n){let r=e.resourceType;return ME(n,r,t)?r===`Binary`?!0:!(n.compartment&&!e.meta?.compartment?.some(e=>e.reference===n.compartment?.reference)||n.criteria&&!dE(e,YT(n.criteria))):!1}function ME(e,t,n){return e.resourceType!==t&&(e.resourceType!==`*`||TE.includes(t))?!1:e.interaction?e.interaction.includes(n):!e.readonly||DE.includes(n)}function NE(){return typeof window<`u`}function PE(){return typeof Buffer<`u`?Buffer:void 0}var FE={assign(e){NE()&&globalThis.location.assign(e)},reload(){NE()&&globalThis.location.reload()},getSearch(){return NE()?globalThis.location.search:``},getPathname(){return NE()?globalThis.location.pathname:``},getLocation(){return NE()?globalThis.location.toString():``},getOrigin(){return NE()?globalThis.location.protocol+`//`+globalThis.location.host+`/`:``}};function IE(e){if(NE()){let t=window.atob(e),n=Uint8Array.from(t,e=>e.codePointAt(0));return new window.TextDecoder().decode(n)}let t=PE();if(t)return t.from(e,`base64`).toString(`utf-8`);throw Error(`Unable to decode base64`)}function LE(e){if(NE()){let t=new window.TextEncoder().encode(e),n=String.fromCodePoint.apply(null,t);return window.btoa(n)}let t=PE();if(t)return t.from(e,`utf8`).toString(`base64`);throw Error(`Unable to encode base64`)}function RE(e){return e=e.padEnd(e.length+(4-e.length%4)%4,`=`),IE(e.replaceAll(`-`,`+`).replaceAll(`_`,`/`))}function zE(){let e=new Uint32Array(28);return crypto.getRandomValues(e),RC(e.buffer)}async function BE(e){return crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e))}function VE(){return typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replaceAll(/[xy]/g,e=>{let t=Math.trunc(Math.random()*16);return(e===`x`?t:t&3|8).toString(16)})}function HE(e){let t={};e=AC(e);for(let n of e.entry??rw){let e=n.resource;if(!e)continue;e.meta!==void 0&&(delete e.meta.author,delete e.meta.compartment,delete e.meta.lastUpdated,delete e.meta.project,delete e.meta.versionId,Object.keys(e.meta).length===0&&delete e.meta);let r=e?.id;if(r)t[r]=VE(),n.fullUrl=`urn:uuid:`+t[r],delete n.resource?.id;else if(n.fullUrl?.startsWith(`resource:`)){let e=n.fullUrl.slice(9);t[e]=VE(),n.fullUrl=`urn:uuid:`+t[e]}}let n=e.entry,r=JSON.stringify({resourceType:`Bundle`,type:`transaction`,entry:n?.map(e=>({fullUrl:e.fullUrl,request:{method:`POST`,url:e.resource?.resourceType},resource:e.resource}))},(e,n)=>UE(e,n,t),2);return WE(JSON.parse(r))}function UE(e,t,n){if((e===`reference`||e===`url`)&&typeof t==`string`){let e;if(t.includes(`/`)?e=t.split(`/`)[1]:t.startsWith(`urn:uuid:`)||t.startsWith(`resource:`)?e=t.slice(9):t.startsWith(`#`)&&(e=t.slice(1)),e){let t=n[e];if(t)return`urn:uuid:`+t}}return t}function WE(e){let{sorted:t,cycles:n}=KE(JE(e)),r={},i=[];for(let t of e.entry??rw)t.fullUrl?r[t.fullUrl]=t:i.push(t);let a=t.map(e=>r[e]);for(let e of n)for(let t of e){let e=r[t],n={...e,request:{...e.request,method:`PUT`}};a.push(n)}return a.push(...i),{...e,entry:a}}var GE={NotVisited:`NotVisited`,Visiting:`Visiting`,Visited:`Visited`};function KE(e){let t=[],n={},r=[];for(let t of Object.keys(e))n[t]=GE.NotVisited;function i(a,o){if(n[a]===GE.Visited)return!0;if(n[a]===GE.Visiting){let e=o.lastIndexOf(a);return e!==-1&&r.push(o.slice(e)),!0}n[a]=GE.Visiting,o.push(a);let s=!1;for(let t of e[a]??rw)i(t,o)||(s=!0);return n[a]=GE.Visited,o.pop(),t.unshift(a),!s}for(let t in e)n[t]===GE.NotVisited&&i(t,[]);return{sorted:t,cycles:r}}function qE(e,t){for(let n in e)if(e[n]&&typeof e[n]==`object`){let r=e[n];if(Vw(r)){let e=r.reference;(e.startsWith(`urn:uuid:`)||e.startsWith(`resource:`))&&t(e)}else qE(r,t)}}function JE(e){let t={};for(let n of e.entry??rw)n.fullUrl&&(t[n.fullUrl]=[]);for(let n of e.entry??rw){let e=n.fullUrl;e&&n.resource&&qE(n.resource,n=>{n!==e&&t[n]&&t[n].push(e)})}return t}var YE={CSS:`text/css`,DICOM:`application/dicom`,FAVICON:`image/vnd.microsoft.icon`,FHIR_JSON:`application/fhir+json`,FORM_URL_ENCODED:`application/x-www-form-urlencoded`,HL7_V2:`x-application/hl7-v2+er7`,HTML:`text/html`,JAVASCRIPT:`text/javascript`,JSON:`application/json`,JSON_PATCH:`application/json-patch+json`,JWT:`application/jwt`,MULTIPART_FORM_DATA:`multipart/form-data`,PNG:`image/png`,SCIM_JSON:`application/scim+json`,SVG:`image/svg+xml`,TEXT:`text/plain`,TYPESCRIPT:`text/typescript`,PING:`x-application/ping`,XML:`text/xml`,CDA_XML:`application/cda+xml`,OCTET_STREAM:`application/octet-stream`},XE=class{listeners;constructor(){this.listeners={}}addEventListener(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)}removeEventListener(e,t){let n=this.listeners[e];if(n){for(let e=0;e<n.length;e++)if(n[e]===t){n.splice(e,1);return}}}dispatchEvent(e){let t=this.listeners[e.type];for(let n of t??rw)n.call(this,e);return!e.defaultPrevented}removeAllListeners(){this.listeners={}}listenerCount(e){return this.listeners[e]?.length??0}},ZE=class{emitter=new XE;dispatchEvent(e){this.emitter.dispatchEvent(e)}addEventListener(e,t){this.emitter.addEventListener(e,t)}removeEventListener(e,t){this.emitter.removeEventListener(e,t)}removeAllListeners(){this.emitter.removeAllListeners()}listenerCount(e){return this.emitter.listenerCount(e)}},QE={"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`},$E=[`Patient`,`Encounter`,`ImagingStudy`,`DiagnosticReport`,`OperationOutcome`,`Bundle`],eD=[`DiagnosticReport-update`];function tD(e){return eD.includes(e)}function nD(e){if(eD.includes(e))throw new Yx(Ux(`'context.version' is required for '${e}'.`))}var rD={"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 iD(e){return $E.includes(e)}function aD(e){return!!e.endpoint}function oD(e){if(!sD(e))throw new Yx(Ux(`subscriptionRequest must be an object conforming to SubscriptionRequest type.`));let{channelType:t,mode:n,topic:r,events:i}=e,a={"hub.channel.type":t,"hub.mode":n,"hub.topic":r,"hub.events":i.join(`,`)};return aD(e)&&(a.endpoint=e.endpoint),new URLSearchParams(a).toString()}function sD(e){if(typeof e!=`object`)return!1;let{channelType:t,mode:n,topic:r,events:i}=e;if(!(t&&n&&r&&i)||typeof r!=`string`||typeof i!=`object`||!Array.isArray(i)||i.length<1||t!==`websocket`||n!==`subscribe`&&n!==`unsubscribe`)return!1;for(let e of i)if(!QE[e])return!1;return!(aD(e)&&!(typeof e.endpoint==`string`&&e.endpoint.startsWith(`ws`)))}function cD(e,t,n,r){if(typeof t!=`object`)throw new Yx(Ux(`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 Yx(Ux(`context[${n}] is invalid. Resource must contain a valid string ID.`));if(!t.resourceType)throw new Yx(Ux(`context[${n}] is invalid. Resource must contain a resource type. No resource type found.`));let i=r.resourceType;if(i!==`*`){if(!iD(t.resourceType))throw new Yx(Ux(`context[${n}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));if(i&&t.resourceType!==i)throw new Yx(Ux(`context[${n}] is invalid. context[${n}] for the '${e}' event should contain resource of type ${i}.`))}}function lD(e,t,n,r,i){if(i.set(t.key,(i.get(t.key)??0)+1),r.reference){if(!Vw(t.reference))throw new Yx(Ux(`context[${n}] is invalid. Expected key '${t.key}' to be a reference.`))}else cD(e,t.resource,n,r)}function uD(e,t){let n=new Map,r=rD[e];for(let i=0;i<t.length;i++){let a=t[i].key;if(!r[a])throw new Yx(Ux(`Key '${a}' not found for event '${e}'. Make sure to add only valid keys.`));lD(e,t[i],i,r[a],n)}for(let[t,i]of Object.entries(r)){if(!(i.optional||n.has(t)))throw new Yx(Ux(`Missing required key '${t}' on context for '${e}' event.`));if(!i.manyAllowed&&(n.get(t)??0)>1)throw new Yx(Ux(`${n.get(t)} context entries with key '${t}' found for the '${e}' event when schema only allows for 1.`))}}function dD(e,t,n,r){if(!(e&&typeof e==`string`))throw new Yx(Ux(`Must provide a topic.`));if(!QE[t])throw new Yx(Ux(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(QE).join(`, `)}`));if(typeof n!=`object`)throw new Yx(Ux(`context must be a context object or array of context objects.`));if(eD.includes(t)&&!r)throw new Yx(Ux(`The '${t}' event must contain a 'context.versionId'.`));let i=Array.isArray(n)?n:[n];return uD(t,i),{timestamp:new Date().toISOString(),id:VE(),event:{"hub.topic":e,"hub.event":t,context:i,...r?{"context.versionId":r}:{}}}}var fD=class extends ZE{subRequest;websocket;constructor(e){if(super(),this.subRequest=e,!e.endpoint)throw new Yx(Ux(`Subscription request should contain an endpoint.`));if(!sD(e))throw new Yx(Ux(`Subscription request failed validation.`));let t=new WebSocket(e.endpoint);t.addEventListener(`open`,()=>{this.dispatchEvent({type:`connect`}),t.addEventListener(`message`,e=>{let n=JSON.parse(e.data);if(n[`hub.topic`])return;let r=n;r.event[`hub.event`]!==`heartbeat`&&(this.dispatchEvent({type:`message`,payload:r}),t.send(JSON.stringify({id:n?.id,timestamp:new Date().toISOString()})))}),t.addEventListener(`close`,()=>{this.dispatchEvent({type:`disconnect`})})}),this.websocket=t}disconnect(){this.websocket.close()}};function pD(e){return JSON.parse(RE(e))}function mD(e){return e.split(`.`).length===3}function hD(e){let[t,n,r]=e.split(`.`);return pD(n)}function gD(e){try{return typeof hD(e).login_id==`string`}catch{return!1}}function _D(e){try{let t=hD(e).exp;return typeof t==`number`?t*1e3:void 0}catch{return}}var vD=class{medplum;constructor(e){this.medplum=e}async get(e){return this.medplum.get(`keyvalue/v1/${e}`)}async set(e,t){await this.medplum.put(`keyvalue/v1/${e}`,t,YE.TEXT)}async delete(e){await this.medplum.delete(`keyvalue/v1/${e}`)}},yD=class{[Symbol.toStringTag]=`ReadablePromise`;suspender;status=`pending`;response;error;constructor(e){this.suspender=e.then(e=>(this.status=`success`,this.response=e,e),e=>{throw this.status=`error`,this.error=e,e})}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(e,t){return this.suspender.then(e,t)}catch(e){return this.suspender.catch(e)}finally(e){return this.suspender.finally(e)}},bD=class{storage;prefix=``;constructor(e,t=``){this.storage=e??globalThis.localStorage??new xD,this.prefix=t}makeKey(e){return this.prefix+e}clear(){this.storage===globalThis.localStorage&&this.prefix?Object.keys(this.storage).filter(e=>e.startsWith(this.prefix)).forEach(e=>{this.storage.removeItem(e)}):this.storage.clear()}getString(e){return this.storage.getItem(this.makeKey(e))??void 0}setString(e,t){t?this.storage.setItem(this.makeKey(e),t):this.storage.removeItem(this.makeKey(e))}getObject(e){let t=this.getString(e);return t?JSON.parse(t):void 0}setObject(e,t){this.setString(e,t?_C(t):void 0)}},xD=class{data;constructor(){this.data=new Map}get length(){return this.data.size}clear(){this.data.clear()}getItem(e){return this.data.get(e)??null}setItem(e,t){t?this.data.set(e,t):this.data.delete(e)}removeItem(e){this.data.delete(e)}key(e){return Array.from(this.data.keys())[e]}},SD={Event:globalThis.Event===void 0?void 0:globalThis.Event,ErrorEvent:void 0,CloseEvent:void 0},CD=!1;function wD(){if(globalThis.Event===void 0)throw Error(`Unable to lazy init events for ReconnectingWebSocket. globalThis.Event is not defined yet`);SD.Event=globalThis.Event,SD.ErrorEvent=class extends Event{message;error;constructor(e,t){super(`error`,t),this.message=e.message,this.error=e}},SD.CloseEvent=class extends Event{code;reason;wasClean=!0;constructor(e=1e3,t=``,n){super(`close`,n),this.code=e,this.reason=t}}}function TD(e,t){if(!e)throw Error(t)}function ED(e){return new e.constructor(e.type,e)}var DD={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1},OD=!1,kD=class e extends ZE{_ws;_retryCount=-1;_uptimeTimeout;_connectTimeout;_shouldReconnect=!0;_connectLock=!1;_binaryType;_closeCalled=!1;_messageQueue=[];_debugLogger=console.log.bind(console);_url;_protocols;_options;constructor(e,t,n={}){CD||=(wD(),!0),super(),this._url=e,this._protocols=t,this._options=n,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 e.CONNECTING}get OPEN(){return e.OPEN}get CLOSING(){return e.CLOSING}get CLOSED(){return e.CLOSED}get binaryType(){return this._ws?this._ws.binaryType:this._binaryType}set binaryType(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e)}get retryCount(){return Math.max(this._retryCount,0)}get bufferedAmount(){return this._messageQueue.reduce((e,t)=>(typeof t==`string`?e+=t.length:t instanceof Blob?e+=t.size:e+=t.byteLength,e),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?e.CLOSED:e.CONNECTING}get url(){return this._ws?this._ws.url:``}get shouldReconnect(){return this._shouldReconnect}onclose=null;onerror=null;onmessage=null;onopen=null;close(e=1e3,t){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(e,t)}reconnect(e,t){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED||this._disconnect(e,t),this._connect()}send(e){if(this._ws?.readyState===this.OPEN)this._debug(`send`,e),this._ws.send(e);else{let{maxEnqueuedMessages:t=DD.maxEnqueuedMessages}=this._options;this._messageQueue.length<t&&(this._debug(`enqueue`,e),this._messageQueue.push(e))}}_debug(...e){this._options.debug&&this._debugLogger(`RWS>`,...e)}_getNextDelay(){let{reconnectionDelayGrowFactor:e=DD.reconnectionDelayGrowFactor,minReconnectionDelay:t=DD.minReconnectionDelay,maxReconnectionDelay:n=DD.maxReconnectionDelay}=this._options,r=0;return this._retryCount>0&&(r=t*e**(this._retryCount-1),r>n&&(r=n)),this._debug(`next delay`,r),r}_wait(){return new Promise(e=>{setTimeout(e,this._getNextDelay())})}_connect(){if(this._connectLock||!this._shouldReconnect)return;this._connectLock=!0;let{maxRetries:e=DD.maxRetries,connectionTimeout:t=DD.connectionTimeout}=this._options;if(this._retryCount>=e){this._debug(`max retries reached`,this._retryCount,`>=`,e);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`&&!OD&&(console.error(`‼️ No WebSocket implementation available. You should define options.WebSocket.`),OD=!0);let e=this._options.WebSocket||WebSocket;this._debug(`connect`,{url:this._url,protocols:this._protocols}),this._ws=this._protocols?new e(this._url,this._protocols):new e(this._url),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),t)}).catch(e=>{this._connectLock=!1,this._handleError(new SD.ErrorEvent(Error(e.message),this))})}_handleTimeout(){this._debug(`timeout event`),this._handleError(new SD.ErrorEvent(Error(`TIMEOUT`),this))}_disconnect(e=1e3,t){if(this._clearTimeouts(),this._ws){this._removeListeners();try{this._ws.close(e,t),this._handleClose(new SD.CloseEvent(e,t,this))}catch{}}}_acceptOpen(){this._debug(`accept open`),this._retryCount=0}_handleOpen=e=>{this._debug(`open event`);let{minUptime:t=DD.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),t),TD(this._ws,`WebSocket is not defined`),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(e=>this._ws?.send(e)),this._messageQueue=[],this.onopen&&this.onopen(e),this.dispatchEvent(ED(e))};_handleMessage=e=>{this._debug(`message event`),this.onmessage&&this.onmessage(e),this.dispatchEvent(ED(e))};_handleError=e=>{this._debug(`error event`,e.message),this._disconnect(void 0,e.message===`TIMEOUT`?`timeout`:void 0),this.onerror&&this.onerror(e),this._debug(`exec error listeners`),this.dispatchEvent(ED(e)),this._connect()};_handleClose=e=>{this._debug(`close event`),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(e),this.dispatchEvent(ED(e))};_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)}},AD=6e4,jD=[WebSocket.CLOSING,WebSocket.CLOSED],MD=class extends ZE{criteria;constructor(...e){super(),this.criteria=new Set(e)}getCriteria(){return this.criteria}_addCriteria(e){this.criteria.add(e)}_removeCriteria(e){this.criteria.delete(e)}},ND=class{criteria;emitter;refCount;subscriptionProps;subscriptionId;token;tokenExpiry;state=`idle`;generation=0;lastUnrefTime;constructor(e,t){this.criteria=e,this.emitter=new MD(e),this.refCount=1,this.subscriptionProps=t?{...t}:void 0}nextGeneration(){return++this.generation}},PD=class{medplum;ws;masterSubEmitter;criteriaEntries;criteriaEntriesBySubscriptionId;wsClosed;pingTimer=void 0;tokenRefreshTimer=void 0;pingIntervalMs;waitingForPong=!1;currentProfile;constructor(e,t,n){if(!(e instanceof JD))throw new Yx(Ux("First arg of constructor should be a `MedplumClient`"));let r;try{r=new URL(t).toString()}catch{throw new Yx(Ux(`Not a valid URL`))}let i=n?.ReconnectingWebSocket?new n.ReconnectingWebSocket(r,void 0,{debug:n?.debug,debugLogger:n?.debugLogger}):new kD(r,void 0,{debug:n?.debug,debugLogger:n?.debugLogger});this.medplum=e,this.ws=i,this.masterSubEmitter=new MD,this.criteriaEntries=new Map,this.criteriaEntriesBySubscriptionId=new Map,this.wsClosed=!1,this.pingIntervalMs=n?.pingIntervalMs??5e3,this.currentProfile=e.getProfile(),this.setupListeners()}setupListeners(){let e=this.ws;e.addEventListener(`message`,e=>{try{let t=JSON.parse(e.data);if(t.type===`pong`){this.waitingForPong=!1;return}let n=t,r=n?.entry?.[0]?.resource;if(r.type===`heartbeat`){this.masterSubEmitter?.dispatchEvent({type:`heartbeat`,payload:n});return}if(r.type===`handshake`){let e=oC(r.subscription),t={type:`connect`,payload:{subscriptionId:e}};this.masterSubEmitter?.dispatchEvent(t);let n=this.criteriaEntriesBySubscriptionId.get(e);if(!n){console.warn(`Received handshake for criteria the SubscriptionManager is not listening for yet`);return}(n.state===`connecting`||n.state===`refreshing`)&&(n.state=`active`),n.emitter.dispatchEvent({...t});return}this.masterSubEmitter?.dispatchEvent({type:`message`,payload:n});let i=this.criteriaEntriesBySubscriptionId.get(oC(r.subscription));if(!i){console.warn(`Received notification for criteria the SubscriptionManager is not listening for`);return}i.emitter.dispatchEvent({type:`message`,payload:n})}catch(e){console.error(e);let t={type:`error`,payload:e};this.masterSubEmitter?.dispatchEvent(t);for(let e of this.getAllCriteriaEmitters())e.dispatchEvent({...t})}}),e.addEventListener(`error`,e=>{let t={type:`error`,payload:new Yx({resourceType:`OperationOutcome`,issue:[{severity:`error`,code:`exception`,details:{text:`WebSocket connection closed due to an error`},diagnostics:e.error.toString()}]})};this.masterSubEmitter?.dispatchEvent(t);for(let e of this.getAllCriteriaEmitters())e.dispatchEvent({...t})}),e.addEventListener(`close`,()=>{let e={type:`close`};this.masterSubEmitter?.dispatchEvent(e);for(let t of this.getAllCriteriaEmitters())t.dispatchEvent({...e});this.pingTimer&&(clearInterval(this.pingTimer),this.pingTimer=void 0,this.waitingForPong=!1),this.tokenRefreshTimer&&=(clearInterval(this.tokenRefreshTimer),void 0),this.wsClosed&&(this.criteriaEntries.clear(),this.criteriaEntriesBySubscriptionId.clear(),this.masterSubEmitter?.removeAllListeners())}),e.addEventListener(`open`,()=>{let t={type:`open`};this.masterSubEmitter?.dispatchEvent(t);for(let e of this.getAllCriteriaEmitters())e.dispatchEvent({...t});this.refreshAllSubscriptions().catch(console.error),this.pingTimer??=setInterval(()=>{this.waitingForPong?(this.waitingForPong=!1,e.reconnect()):(e.send(JSON.stringify({type:`ping`})),this.waitingForPong=!0),this.gcUnrefEntries()},this.pingIntervalMs),this.tokenRefreshTimer??=setInterval(()=>{this.checkTokenExpirations(),this.gcUnrefEntries()},AD)}),this.medplum.addEventListener(`change`,()=>{let e=this.medplum.getProfile();this.currentProfile&&e===void 0?this.ws.close():e&&this.currentProfile?.id!==e.id&&this.ws.reconnect(),this.currentProfile=e})}sendBind(e){this.ws.send(JSON.stringify({type:`bind-with-token`,payload:{token:e}}))}sendUnbind(e){this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:`unbind-from-token`,payload:{token:e}}))}emitError(e,t){let n={type:`error`,payload:t};this.masterSubEmitter?.dispatchEvent(n),e.emitter.dispatchEvent({...n})}maybeEmitDisconnect(e){let{subscriptionId:t}=e;if(t){let n={type:`disconnect`,payload:{subscriptionId:t}};this.masterSubEmitter?.dispatchEvent(n),e.emitter.dispatchEvent({...n})}else console.warn("Called disconnect for `CriteriaEntry` before `subscriptionId` was present.")}isStale(e,t){return this.isEntryGettingRemoved(e)||e.generation!==t}maybeGetCriteriaEntry(e,t){let n=this.criteriaEntries.get(e);if(n){if(!t)return n.bareCriteria;for(let e of n.criteriaWithProps)if(wC(t,e.subscriptionProps))return e}}getAllCriteriaEmitters(){let e=[];for(let t of this.criteriaEntries.values())for(let n of FD(t))n.refCount>0&&e.push(n.emitter);return e}addCriteriaEntry(e){let{criteria:t,subscriptionProps:n}=e,r;this.criteriaEntries.has(t)?r=this.criteriaEntries.get(t):(r={criteriaWithProps:[]},this.criteriaEntries.set(t,r)),n?r.criteriaWithProps.push(e):r.bareCriteria=e}removeCriteriaEntry(e){e.state=`removed`,e.generation++;let{criteria:t,subscriptionProps:n,subscriptionId:r,token:i}=e;if(!this.criteriaEntries.has(t))return;let a=this.criteriaEntries.get(t);n?a.criteriaWithProps=a.criteriaWithProps.filter(e=>{let t=e.subscriptionProps;return!wC(n,t)}):a.bareCriteria=void 0,!a.bareCriteria&&a.criteriaWithProps.length===0&&(this.criteriaEntries.delete(t),this.masterSubEmitter?._removeCriteria(t)),r&&this.criteriaEntriesBySubscriptionId.delete(r),i&&this.sendUnbind(i)}async subscribeToCriteria(e){this.wsClosed&&await this.reconnectIfNeeded(),this.ws.readyState===WebSocket.OPEN&&this.medplum.getProfile()&&e.state===`idle`&&(e.state=`connecting`,await this.rebindCriteriaEntry(e))}async refreshAllSubscriptions(){this.criteriaEntriesBySubscriptionId.clear();let e=[],t=[];for(let n of this.criteriaEntries.values())for(let r of FD(n))r.refCount===0?t.push(r):e.push(r);for(let e of t)this.removeCriteriaEntry(e);for(let t of e)t.token&&this.sendUnbind(t.token),t.token=void 0,t.tokenExpiry=void 0,t.state=`idle`,t.generation++,await this.subscribeToCriteria(t)}async rebindCriteriaEntry(e){let t=e.nextGeneration();try{if(!e.subscriptionId){let n=await this.medplum.createResource({...e.subscriptionProps,resourceType:`Subscription`,status:`active`,reason:`WebSocket subscription for ${aC(this.medplum.getProfile())}`,channel:{type:`websocket`},criteria:e.criteria});if(e.subscriptionId??=n.id,this.isStale(e,t))return}let{parameter:n}=await this.medplum.get(`fhir/R4/Subscription/${e.subscriptionId}/$get-ws-binding-token`,{cache:`no-cache`}),r=n?.find(e=>e.name===`token`)?.valueString,i=n?.find(e=>e.name===`websocket-url`)?.valueUrl,a=n?.find(e=>e.name===`expiration`)?.valueDateTime;if(!r)throw new Yx(Ux(`Failed to get token`));if(!i)throw new Yx(Ux(`Failed to get URL from $get-ws-binding-token`));if(!a)throw new Yx(Ux(`Failed to get expiration from $get-ws-binding-token`));if(this.isStale(e,t))return;e.token=r,e.tokenExpiry=new Date(a).getTime(),this.criteriaEntriesBySubscriptionId.set(e.subscriptionId,e),this.sendBind(r)}catch(n){console.error(Zx(n)),e.generation===t&&!this.isEntryGettingRemoved(e)&&(e.state=e.state===`refreshing`?`active`:`idle`),this.emitError(e,n)}}checkTokenExpirations(){if(!this.medplum.getProfile())return;let e=Date.now();for(let t of this.criteriaEntries.values())for(let n of FD(t))n.refCount===0||!n.tokenExpiry||n.tokenExpiry-e<=3e5&&n.state===`active`&&this.ws.readyState===WebSocket.OPEN&&(n.state=`refreshing`,this.rebindCriteriaEntry(n).catch(e=>{this.masterSubEmitter?.dispatchEvent({type:`error`,payload:e})}))}addCriteria(e,t){this.masterSubEmitter&&this.masterSubEmitter._addCriteria(e);let n=this.maybeGetCriteriaEntry(e,t);if(n)return n.refCount===0&&(n.lastUnrefTime=void 0,n.generation++,n.state!==`active`&&(n.state=n.token?`active`:`idle`)),n.refCount+=1,n.state===`idle`&&this.subscribeToCriteria(n).catch(console.error),n.emitter;let r=new ND(e,t);return this.addCriteriaEntry(r),this.subscribeToCriteria(r).catch(console.error),r.emitter}removeCriteria(e,t){let n=this.maybeGetCriteriaEntry(e,t);if(!n||this.isEntryGettingRemoved(n)){console.warn("Criteria not known to `SubscriptionManager`. Possibly called remove too many times.");return}--n.refCount,n.refCount===0&&(n.lastUnrefTime=Date.now(),n.generation++)}gcUnrefEntries(){let e=Date.now(),t=[];for(let n of this.criteriaEntries.values())for(let r of FD(n))r.refCount===0&&r.lastUnrefTime!==void 0&&e-r.lastUnrefTime>=1e4&&t.push(r);for(let e of t)this.maybeEmitDisconnect(e),this.removeCriteriaEntry(e);t.length>0&&this.criteriaEntries.size===0&&this.closeWebSocket()}isEntryGettingRemoved(e){return e.refCount===0||e.state===`removed`}getWebSocket(){return this.ws}closeWebSocket(){if(!this.wsClosed){if(this.ws.readyState===WebSocket.OPEN)for(let e of this.criteriaEntries.values())for(let t of FD(e))t.token&&this.sendUnbind(t.token);this.wsClosed=!0,this.ws.close()}}reconnectWebSocket(){this.ws.reconnect(),this.wsClosed=!1}getCriteriaCount(){return this.getAllCriteriaEmitters().length}getMasterEmitter(){return this.masterSubEmitter||=new MD(...Array.from(this.criteriaEntries.keys())),this.masterSubEmitter}async reconnectIfNeeded(){jD.includes(this.getWebSocket().readyState)&&await new Promise(e=>{let t=()=>{this.getWebSocket().removeEventListener(`open`,t),e()};this.getWebSocket().addEventListener(`open`,t),this.reconnectWebSocket()})}};function FD(e){return e.bareCriteria?[e.bareCriteria,...e.criteriaWithProps]:e.criteriaWithProps}new xx(1e3);var ID=`5.1.15-088bfde`,LD=YE.FHIR_JSON+`, */*; q=0.1`,RD=`https://api.medplum.com/`,zD=1e3,BD=6e4,VD=0,HD=3e5,UD=`Binary/`,WD={resourceType:`Device`,id:`system`,deviceName:[{type:`model-name`,name:`System`}]},GD={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`,PreAuthorizedCode:`urn:ietf:params:oauth:grant-type:pre-authorized_code`},KD={AccessToken:`urn:ietf:params:oauth:token-type:access_token`,RefreshToken:`urn:ietf:params:oauth:token-type:refresh_token`,IdToken:`urn:ietf:params:oauth:token-type:id_token`,Saml1Token:`urn:ietf:params:oauth:token-type:saml1`,Saml2Token:`urn:ietf:params:oauth:token-type:saml2`},qD={JwtBearer:`urn:ietf:params:oauth:client-assertion-type:jwt-bearer`},JD=class extends ZE{options;fetch;createPdfImpl;storage;requestCache;cacheTime;baseUrl;fhirBaseUrl;authorizeUrl;tokenUrl;logoutUrl;fhircastHubUrl;cdsServicesUrl;defaultHeaders;onUnauthenticated;autoBatchTime;autoBatchQueue;maxRetries;maxRetryTime;refreshGracePeriod;subscriptionManager;medplumServer;clientId;clientSecret;credentialsInHeader;autoBatchTimerId;accessToken;accessTokenExpires;refreshToken;refreshPromise;profilePromise;sessionDetails;currentRateLimits;basicAuth;initPromise;initComplete=!0;keyValueClient;logLevel;constructor(e){if(super(),e?.baseUrl&&!e.baseUrl.startsWith(`http`))throw Error(`Base URL must start with http or https`);this.options=e??{},this.fetch=e?.fetch??YD(),this.storage=e?.storage??new bD(void 0,e?.storagePrefix),this.createPdfImpl=e?.createPdf,this.baseUrl=XC(e?.baseUrl??RD),this.fhirBaseUrl=QC(this.baseUrl,e?.fhirUrlPath??`fhir/R4`),this.authorizeUrl=QC(this.baseUrl,e?.authorizeUrl??`oauth2/authorize`),this.tokenUrl=QC(this.baseUrl,e?.tokenUrl??`oauth2/token`),this.logoutUrl=QC(this.baseUrl,e?.logoutUrl??`oauth2/logout`),this.fhircastHubUrl=QC(this.baseUrl,e?.fhircastHubUrl??`fhircast/STU3`),this.cdsServicesUrl=QC(this.baseUrl,e?.cdsServicesUrl??`cds-services`),this.clientId=e?.clientId??``,this.clientSecret=e?.clientSecret??``,this.credentialsInHeader=e?.authCredentialsMethod===`header`,this.defaultHeaders=e?.defaultHeaders??{},this.onUnauthenticated=e?.onUnauthenticated,this.refreshGracePeriod=e?.refreshGracePeriod??HD,this.logLevel=this.initializeLogLevel(e),this.maxRetries=e?.maxRetries??2,this.maxRetryTime=e?.maxRetryTime??2e3,this.cacheTime=e?.cacheTime??(NE()?BD:VD),this.cacheTime>0?this.requestCache=new xx(e?.resourceCacheSize??zD):this.requestCache=void 0,e?.autoBatchTime?(this.autoBatchTime=e.autoBatchTime,this.autoBatchQueue=[]):(this.autoBatchTime=0,this.autoBatchQueue=void 0),e?.accessToken&&this.setAccessToken(e.accessToken),this.storage.getInitPromise===void 0?(e?.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(()=>{e?.accessToken||this.attemptResumeActiveLogin().catch(console.error),this.initComplete=!0,this.dispatchEvent({type:`storageInitialized`})}).catch(e=>{console.error(e),this.initComplete=!0,this.dispatchEvent({type:`storageInitFailed`,payload:{error:e}})})),this.setupStorageListener()}get isInitialized(){return this.initComplete}getInitPromise(){return this.initPromise}initializeLogLevel(e){return e?.logLevel?e.logLevel:e?.verbose===void 0?`none`:e.verbose?`verbose`:`none`}async attemptResumeActiveLogin(){let e=this.getActiveLogin();e&&(this.setAccessToken(e.accessToken,e.refreshToken),await this.refreshProfile())}getBaseUrl(){return this.baseUrl}getAuthorizeUrl(){return this.authorizeUrl}getTokenUrl(){return this.tokenUrl}getLogoutUrl(){return this.logoutUrl}getFhircastHubUrl(){return this.fhircastHubUrl}getCdsServicesUrl(){return this.cdsServicesUrl}getDefaultHeaders(){return this.defaultHeaders}clear(){this.storage.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(e){e=e.toString(),this.requestCache?.delete(e)}invalidateAll(){this.requestCache?.clear()}invalidateSearches(e){let t=QC(this.fhirBaseUrl,e);for(let e of this.requestCache?.keys()??rw)(e.endsWith(t)||e.includes(t+`?`))&&this.requestCache?.delete(e)}get(e,t={}){e=e.toString();let n=this.getCacheEntry(e,t);if(n)return n.value;let r;e.startsWith(this.fhirBaseUrl)&&this.autoBatchQueue&&!t.disableAutoBatch?r=new Promise((n,r)=>{this.autoBatchQueue.push({method:`GET`,url:e.replace(this.fhirBaseUrl,``),options:t,resolve:n,reject:r}),this.autoBatchTimerId||=setTimeout(()=>this.executeAutoBatch(),this.autoBatchTime)}):(t.method=`GET`,r=this.request(e,t));let i=new yD(r);return this.setCacheEntry(e,i,t),i}post(e,t,n,r={}){return e=e.toString(),this.setRequestBody(r,t),n&&this.setRequestContentType(r,n),this.invalidateUrl(e),r.method=`POST`,this.request(e,r)}put(e,t,n,r={}){return e=e.toString(),this.setRequestBody(r,t),n&&this.setRequestContentType(r,n),this.invalidateUrl(e),r.method=`PUT`,this.request(e,r)}patch(e,t,n={}){return e=e.toString(),this.setRequestBody(n,t),this.setRequestContentType(n,YE.JSON_PATCH),this.invalidateUrl(e),n.method=`PATCH`,this.request(e,n)}delete(e,t={}){return e=e.toString(),this.invalidateUrl(e),t.method=`DELETE`,this.request(e,t)}async startNewUser(e,t){let{codeChallengeMethod:n,codeChallenge:r}=await this.startPkce();return this.post(`auth/newuser`,{...e,clientId:e.clientId??this.clientId,codeChallengeMethod:n,codeChallenge:r},void 0,t)}async startNewProject(e,t){return this.post(`auth/newproject`,e,void 0,t)}async startNewPatient(e,t){return this.post(`auth/newpatient`,e,void 0,t)}async startLogin(e,t){return this.post(`auth/login`,{...await this.ensureCodeChallenge(e),clientId:e.clientId??this.clientId,scope:e.scope},void 0,t)}async startGoogleLogin(e,t){return this.post(`auth/google`,{...await this.ensureCodeChallenge(e),clientId:e.clientId??this.clientId,scope:e.scope},void 0,t)}async ensureCodeChallenge(e){return e.codeChallenge?e:{...e,...await this.startPkce()}}async signOut(){await this.post(this.logoutUrl,{}),this.clear()}async signInWithRedirect(e){let t=new URLSearchParams(FE.getSearch()).get(`code`);if(!t){await this.requestAuthorization(e);return}return this.processCode(t)}signOutWithRedirect(){FE.assign(this.logoutUrl)}async signInWithExternalAuth(e,t,n,r,i=!0){let a=r;i&&(a=await this.ensureCodeChallenge(r)),FE.assign(this.getExternalAuthRedirectUri(e,t,n,a,i))}async exchangeExternalAccessToken(e,t,n){if(t??=this.clientId,!t)throw Error(`MedplumClient is missing clientId`);let r={grant_type:GD.TokenExchange,subject_token_type:KD.AccessToken,client_id:t,subject_token:e};return n&&(r.membership_id=n),this.fetchTokens(r)}getExternalAuthRedirectUri(e,t,n,r,i=!0){let a=new URL(e);if(a.searchParams.set(`response_type`,`code`),a.searchParams.set(`client_id`,t),a.searchParams.set(`redirect_uri`,n),a.searchParams.set(`scope`,r.scope??`openid profile email`),a.searchParams.set(`state`,JSON.stringify(r)),i){let{codeChallenge:e,codeChallengeMethod:t}=r;if(!t)throw Error("`LoginRequest` for external auth must include a `codeChallengeMethod`.");if(!e)throw Error("`LoginRequest` for external auth must include a `codeChallenge`.");a.searchParams.set(`code_challenge_method`,t),a.searchParams.set(`code_challenge`,e)}return a.toString()}fhirUrl(...e){return new URL(QC(this.fhirBaseUrl,e.join(`/`)))}fhirSearchUrl(e,t){let n=this.fhirUrl(e);return t&&(n.search=ew(t)),n}search(e,t,n){let r=this.fhirSearchUrl(e,t),i=`search-`+r.toString(),a=this.getCacheEntry(i,n);if(a)return a.value;let o=this.getBundle(r,n);return this.setCacheEntry(i,o,n),o}searchOne(e,t,n){let r=this.fhirSearchUrl(e,t);r.searchParams.set(`_count`,`1`),r.searchParams.sort();let i=`searchOne-`+r.toString(),a=this.getCacheEntry(i,n);if(a)return a.value;let o=new yD(this.search(e,r.searchParams,n).then(e=>e.entry?.[0]?.resource));return this.setCacheEntry(i,o,n),o}searchResources(e,t,n){let r=`searchResources-`+this.fhirSearchUrl(e,t).toString(),i=this.getCacheEntry(r,n);if(i)return i.value;let a=new yD(this.search(e,t,n).then(ZD));return this.setCacheEntry(r,a,n),a}async*searchResourcePages(e,t,n){let r=this.fhirSearchUrl(e,t);for(;r;){let t=new URL(r).searchParams;t.has(`_count`)||t.set(`_count`,`1000`);let i=await this.search(e,t,n),a=i.link?.find(e=>e.relation===`next`);if(!i.entry?.length&&!a)break;yield ZD(i),r=a?.url?new URL(a.url):void 0}}valueSetExpand(e,t){let n=this.fhirUrl(`ValueSet`,`$expand`);return n.search=new URLSearchParams(e).toString(),this.get(n.toString(),t)}getCached(e,t){let n=this.requestCache?.get(this.fhirUrl(e,t).toString())?.value;return n?.isOk()?n.read():void 0}getCachedReference(e){let t=e.reference;if(!t)return;if(t===`system`)return WD;let[n,r]=t.split(`/`);if(!(!n||!r))return this.getCached(n,r)}readResource(e,t,n){if(!t)throw Error(`The "id" parameter cannot be null, undefined, or an empty string.`);return this.get(this.fhirUrl(e,t),n)}readReference(e,t){let n=e.reference;if(!n)return new yD(Promise.reject(Error(`Missing reference`)));if(n===`system`)return new yD(Promise.resolve(WD));let[r,i]=n.split(`/`);return!r||!i?new yD(Promise.reject(Error(`Invalid reference`))):this.readResource(r,i,t)}readCanonical(e,t,n){return Array.isArray(e)?this.searchOne(``,{_type:e.join(`,`),url:t},n):this.searchOne(e,`url=`+t,n)}requestSchema(e,t){if(dS(e))return Promise.resolve();let n=e+`-requestSchema`,r=this.getCacheEntry(n,void 0);if(r)return r.value;let i=new yD((async()=>{let t=`{
57
57
  StructureDefinitionList(_filter: "name eq ${e}") {
58
58
  resourceType,
59
59
  name,
@@ -223,7 +223,7 @@ Error generating stack: `+e.message+`
223
223
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sJ(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function cJ(e){if(Array.isArray(e))return hJ(e)}function lJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function uJ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?lJ(Object(n),!0).forEach(function(t){dJ(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lJ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function dJ(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function fJ(e,t){return _J(e)||gJ(e,t)||mJ(e,t)||pJ()}function pJ(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
224
224
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mJ(e,t){if(e){if(typeof e==`string`)return hJ(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return hJ(e,t)}}function hJ(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function gJ(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function _J(e){if(Array.isArray(e))return e}var vJ=typeof iJ.default==`function`?iJ.default:iJ.default.default,yJ=`file-invalid-type`,bJ=`file-too-large`,xJ=`file-too-small`,SJ=`too-many-files`,CJ=function(){var e=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:``).split(`,`);return{code:yJ,message:`File type must be ${e.length>1?`one of ${e.join(`, `)}`:e[0]}`}},wJ=function(e){return{code:bJ,message:`File is larger than ${e} ${e===1?`byte`:`bytes`}`}},TJ=function(e){return{code:xJ,message:`File is smaller than ${e} ${e===1?`byte`:`bytes`}`}},EJ={code:SJ,message:`Too many files`};function DJ(e){return e.type===``&&typeof e.getAsFile==`function`}function OJ(e,t){var n=e.type===`application/x-moz-file`||vJ(e,t)||DJ(e);return[n,n?null:CJ(t)]}function kJ(e,t,n){if(AJ(e.size)){if(AJ(t)&&AJ(n)){if(e.size>n)return[!1,wJ(n)];if(e.size<t)return[!1,TJ(t)]}else if(AJ(t)&&e.size<t)return[!1,TJ(t)];else if(AJ(n)&&e.size>n)return[!1,wJ(n)]}return[!0,null]}function AJ(e){return e!=null}function jJ(e){var t=e.files,n=e.accept,r=e.minSize,i=e.maxSize,a=e.multiple,o=e.maxFiles,s=e.validator;return!a&&t.length>1||a&&o>=1&&t.length>o?!1:t.every(function(e){var t=fJ(OJ(e,n),1)[0],a=fJ(kJ(e,r,i),1)[0],o=s?s(e):null;return t&&a&&!o})}function MJ(e){return typeof e.isPropagationStopped==`function`?e.isPropagationStopped():e.cancelBubble===void 0?!1:e.cancelBubble}function NJ(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(e){return e===`Files`||e===`application/x-moz-file`}):!!e.target&&!!e.target.files}function PJ(e){e.preventDefault()}function FJ(e){return e.indexOf(`MSIE`)!==-1||e.indexOf(`Trident/`)!==-1}function IJ(e){return e.indexOf(`Edge/`)!==-1}function LJ(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return FJ(e)||IJ(e)}function RJ(){var e=[...arguments];return function(t){var n=[...arguments].slice(1);return e.some(function(e){return!MJ(t)&&e&&e.apply(void 0,[t].concat(n)),MJ(t)})}}function zJ(){return`showOpenFilePicker`in window}function BJ(e){return AJ(e)?[{description:`Files`,accept:Object.entries(e).filter(function(e){var t=fJ(e,2),n=t[0],r=t[1],i=!0;return WJ(n)||(console.warn(`Skipped "${n}" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.`),i=!1),(!Array.isArray(r)||!r.every(GJ))&&(console.warn(`Skipped "${n}" because an invalid file extension was provided.`),i=!1),i}).reduce(function(e,t){var n=fJ(t,2),r=n[0],i=n[1];return uJ(uJ({},e),{},dJ({},r,i))},{})}]:e}function VJ(e){if(AJ(e))return Object.entries(e).reduce(function(e,t){var n=fJ(t,2),r=n[0],i=n[1];return[].concat(aJ(e),[r],aJ(i))},[]).filter(function(e){return WJ(e)||GJ(e)}).join(`,`)}function HJ(e){return e instanceof DOMException&&(e.name===`AbortError`||e.code===e.ABORT_ERR)}function UJ(e){return e instanceof DOMException&&(e.name===`SecurityError`||e.code===e.SECURITY_ERR)}function WJ(e){return e===`audio/*`||e===`video/*`||e===`image/*`||e===`text/*`||e===`application/*`||/\w+\/[-+.\w]+/g.test(e)}function GJ(e){return/^.*\.[\w]+$/.test(e)}var KJ=c(Ub()),qJ=[`children`],JJ=[`open`],YJ=[`refKey`,`role`,`onKeyDown`,`onFocus`,`onBlur`,`onClick`,`onDragEnter`,`onDragOver`,`onDragLeave`,`onDrop`],XJ=[`refKey`,`onChange`,`onClick`];function ZJ(e){return eY(e)||$J(e)||rY(e)||QJ()}function QJ(){throw TypeError(`Invalid attempt to spread non-iterable instance.
225
225
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function $J(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function eY(e){if(Array.isArray(e))return iY(e)}function tY(e,t){return oY(e)||aY(e,t)||rY(e,t)||nY()}function nY(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
226
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rY(e,t){if(e){if(typeof e==`string`)return iY(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return iY(e,t)}}function iY(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function aY(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function oY(e){if(Array.isArray(e))return e}function sY(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function cY(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?sY(Object(n),!0).forEach(function(t){lY(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sY(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function lY(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function uY(e,t){if(e==null)return{};var n=dY(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function dY(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}var fY=(0,b.forwardRef)(function(e,t){var n=e.children,r=hY(uY(e,qJ)),i=r.open,a=uY(r,JJ);return(0,b.useImperativeHandle)(t,function(){return{open:i}},[i]),b.createElement(b.Fragment,null,n(cY(cY({},a),{},{open:i})))});fY.displayName=`Dropzone`;var pY={disabled:!1,getFilesFromEvent:Uq,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};fY.defaultProps=pY,fY.propTypes={children:KJ.default.func,accept:KJ.default.objectOf(KJ.default.arrayOf(KJ.default.string)),multiple:KJ.default.bool,preventDropOnDocument:KJ.default.bool,noClick:KJ.default.bool,noKeyboard:KJ.default.bool,noDrag:KJ.default.bool,noDragEventsBubbling:KJ.default.bool,minSize:KJ.default.number,maxSize:KJ.default.number,maxFiles:KJ.default.number,disabled:KJ.default.bool,getFilesFromEvent:KJ.default.func,onFileDialogCancel:KJ.default.func,onFileDialogOpen:KJ.default.func,useFsAccessApi:KJ.default.bool,autoFocus:KJ.default.bool,onDragEnter:KJ.default.func,onDragLeave:KJ.default.func,onDragOver:KJ.default.func,onDrop:KJ.default.func,onDropAccepted:KJ.default.func,onDropRejected:KJ.default.func,onError:KJ.default.func,validator:KJ.default.func};var mY={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragGlobal:!1,acceptedFiles:[],fileRejections:[]};function hY(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=cY(cY({},pY),e),n=t.accept,r=t.disabled,i=t.getFilesFromEvent,a=t.maxSize,o=t.minSize,s=t.multiple,c=t.maxFiles,l=t.onDragEnter,u=t.onDragLeave,d=t.onDragOver,f=t.onDrop,p=t.onDropAccepted,m=t.onDropRejected,h=t.onFileDialogCancel,g=t.onFileDialogOpen,_=t.useFsAccessApi,v=t.autoFocus,y=t.preventDropOnDocument,x=t.noClick,S=t.noKeyboard,C=t.noDrag,w=t.noDragEventsBubbling,T=t.onError,E=t.validator,D=(0,b.useMemo)(function(){return VJ(n)},[n]),O=(0,b.useMemo)(function(){return BJ(n)},[n]),k=(0,b.useMemo)(function(){return typeof g==`function`?g:_Y},[g]),A=(0,b.useMemo)(function(){return typeof h==`function`?h:_Y},[h]),j=(0,b.useRef)(null),M=(0,b.useRef)(null),N=tY((0,b.useReducer)(gY,mY),2),P=N[0],F=N[1],ee=P.isFocused,te=P.isFileDialogActive,ne=(0,b.useRef)(typeof window<`u`&&window.isSecureContext&&_&&zJ()),re=function(){!ne.current&&te&&setTimeout(function(){M.current&&(M.current.files.length||(F({type:`closeDialog`}),A()))},300)};(0,b.useEffect)(function(){return window.addEventListener(`focus`,re,!1),function(){window.removeEventListener(`focus`,re,!1)}},[M,te,A,ne]);var ie=(0,b.useRef)([]),ae=(0,b.useRef)([]),oe=function(e){j.current&&j.current.contains(e.target)||(e.preventDefault(),ie.current=[])};(0,b.useEffect)(function(){return y&&(document.addEventListener(`dragover`,PJ,!1),document.addEventListener(`drop`,oe,!1)),function(){y&&(document.removeEventListener(`dragover`,PJ),document.removeEventListener(`drop`,oe))}},[j,y]),(0,b.useEffect)(function(){var e=function(e){ae.current=[].concat(ZJ(ae.current),[e.target]),NJ(e)&&F({isDragGlobal:!0,type:`setDragGlobal`})},t=function(e){ae.current=ae.current.filter(function(t){return t!==e.target&&t!==null}),!(ae.current.length>0)&&F({isDragGlobal:!1,type:`setDragGlobal`})},n=function(){ae.current=[],F({isDragGlobal:!1,type:`setDragGlobal`})},r=function(){ae.current=[],F({isDragGlobal:!1,type:`setDragGlobal`})};return document.addEventListener(`dragenter`,e,!1),document.addEventListener(`dragleave`,t,!1),document.addEventListener(`dragend`,n,!1),document.addEventListener(`drop`,r,!1),function(){document.removeEventListener(`dragenter`,e),document.removeEventListener(`dragleave`,t),document.removeEventListener(`dragend`,n),document.removeEventListener(`drop`,r)}},[j]),(0,b.useEffect)(function(){return!r&&v&&j.current&&j.current.focus(),function(){}},[j,v,r]);var se=(0,b.useCallback)(function(e){T?T(e):console.error(e)},[T]),ce=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),xe(e),ie.current=[].concat(ZJ(ie.current),[e.target]),NJ(e)&&Promise.resolve(i(e)).then(function(t){if(!(MJ(e)&&!w)){var n=t.length,r=n>0&&jJ({files:t,accept:D,minSize:o,maxSize:a,multiple:s,maxFiles:c,validator:E});F({isDragAccept:r,isDragReject:n>0&&!r,isDragActive:!0,type:`setDraggedFiles`}),l&&l(e)}}).catch(function(e){return se(e)})},[i,l,se,w,D,o,a,s,c,E]),le=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),xe(e);var t=NJ(e);if(t&&e.dataTransfer)try{e.dataTransfer.dropEffect=`copy`}catch{}return t&&d&&d(e),!1},[d,w]),ue=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),xe(e);var t=ie.current.filter(function(e){return j.current&&j.current.contains(e)}),n=t.indexOf(e.target);n!==-1&&t.splice(n,1),ie.current=t,!(t.length>0)&&(F({type:`setDraggedFiles`,isDragActive:!1,isDragAccept:!1,isDragReject:!1}),NJ(e)&&u&&u(e))},[j,u,w]),de=(0,b.useCallback)(function(e,t){var n=[],r=[];e.forEach(function(e){var t=tY(OJ(e,D),2),i=t[0],s=t[1],c=tY(kJ(e,o,a),2),l=c[0],u=c[1],d=E?E(e):null;if(i&&l&&!d)n.push(e);else{var f=[s,u];d&&(f=f.concat(d)),r.push({file:e,errors:f.filter(function(e){return e})})}}),(!s&&n.length>1||s&&c>=1&&n.length>c)&&(n.forEach(function(e){r.push({file:e,errors:[EJ]})}),n.splice(0)),F({acceptedFiles:n,fileRejections:r,type:`setFiles`}),f&&f(n,r,t),r.length>0&&m&&m(r,t),n.length>0&&p&&p(n,t)},[F,s,D,o,a,c,f,p,m,E]),fe=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),xe(e),ie.current=[],NJ(e)&&Promise.resolve(i(e)).then(function(t){MJ(e)&&!w||de(t,e)}).catch(function(e){return se(e)}),F({type:`reset`})},[i,de,se,w]),pe=(0,b.useCallback)(function(){if(ne.current){F({type:`openDialog`}),k();var e={multiple:s,types:O};window.showOpenFilePicker(e).then(function(e){return i(e)}).then(function(e){de(e,null),F({type:`closeDialog`})}).catch(function(e){HJ(e)?(A(e),F({type:`closeDialog`})):UJ(e)?(ne.current=!1,M.current?(M.current.value=null,M.current.click()):se(Error(`Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided.`))):se(e)});return}M.current&&(F({type:`openDialog`}),k(),M.current.value=null,M.current.click())},[F,k,A,_,de,se,O,s]),me=(0,b.useCallback)(function(e){!j.current||!j.current.isEqualNode(e.target)||(e.key===` `||e.key===`Enter`||e.keyCode===32||e.keyCode===13)&&(e.preventDefault(),pe())},[j,pe]),he=(0,b.useCallback)(function(){F({type:`focus`})},[]),ge=(0,b.useCallback)(function(){F({type:`blur`})},[]),_e=(0,b.useCallback)(function(){x||(LJ()?setTimeout(pe,0):pe())},[x,pe]),ve=function(e){return r?null:e},ye=function(e){return S?null:ve(e)},be=function(e){return C?null:ve(e)},xe=function(e){w&&e.stopPropagation()},Se=(0,b.useMemo)(function(){return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.refKey,n=t===void 0?`ref`:t,i=e.role,a=e.onKeyDown,o=e.onFocus,s=e.onBlur,c=e.onClick,l=e.onDragEnter,u=e.onDragOver,d=e.onDragLeave,f=e.onDrop,p=uY(e,YJ);return cY(cY(lY({onKeyDown:ye(RJ(a,me)),onFocus:ye(RJ(o,he)),onBlur:ye(RJ(s,ge)),onClick:ve(RJ(c,_e)),onDragEnter:be(RJ(l,ce)),onDragOver:be(RJ(u,le)),onDragLeave:be(RJ(d,ue)),onDrop:be(RJ(f,fe)),role:typeof i==`string`&&i!==``?i:`presentation`},n,j),!r&&!S?{tabIndex:0}:{}),p)}},[j,me,he,ge,_e,ce,le,ue,fe,S,C,r]),Ce=(0,b.useCallback)(function(e){e.stopPropagation()},[]),we=(0,b.useMemo)(function(){return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.refKey,n=t===void 0?`ref`:t,r=e.onChange,i=e.onClick,a=uY(e,XJ);return cY(cY({},lY({accept:D,multiple:s,type:`file`,style:{border:0,clip:`rect(0, 0, 0, 0)`,clipPath:`inset(50%)`,height:`1px`,margin:`0 -1px -1px 0`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`},onChange:ve(RJ(r,fe)),onClick:ve(RJ(i,Ce)),tabIndex:-1},n,M)),a)}},[M,n,s,fe,r]);return cY(cY({},P),{},{isFocused:ee&&!r,getRootProps:Se,getInputProps:we,rootRef:j,inputRef:M,open:ve(pe)})}function gY(e,t){switch(t.type){case`focus`:return cY(cY({},e),{},{isFocused:!0});case`blur`:return cY(cY({},e),{},{isFocused:!1});case`openDialog`:return cY(cY({},mY),{},{isFileDialogActive:!0});case`closeDialog`:return cY(cY({},e),{},{isFileDialogActive:!1});case`setDraggedFiles`:return cY(cY({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case`setFiles`:return cY(cY({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:!1});case`setDragGlobal`:return cY(cY({},e),{},{isDragGlobal:t.isDragGlobal});case`reset`:return cY({},mY);default:return e}}function _Y(){}var[vY,yY]=$e(`Dropzone component was not found in tree`),bY={root:`m_d46a4834`,inner:`m_b85f7144`,fullScreen:`m_96f6e9ad`,dropzone:`m_7946116d`};function xY(e){let t=t=>{let{children:n,...r}=z(`Dropzone${Tt(e)}`,{},t),i=yY(),a=Ze(n)?n:(0,L.jsx)(`span`,{children:n});return i[e]?(0,b.cloneElement)(a,r):null};return t.displayName=`@mantine/dropzone/${Tt(e)}`,t}var SY=xY(`accept`),CY=xY(`reject`),wY=xY(`idle`),TY={multiple:!0,maxSize:1/0,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,useFsAccessApi:!0,variant:`light`,rejectColor:`red`},EY=kn((e,{radius:t,variant:n,acceptColor:r,rejectColor:i})=>{let a=e.variantColorResolver({color:r||e.primaryColor,theme:e,variant:n}),o=e.variantColorResolver({color:i||`red`,theme:e,variant:n});return{root:{"--dropzone-radius":pt(t),"--dropzone-accept-color":a.color,"--dropzone-accept-bg":a.background,"--dropzone-reject-color":o.color,"--dropzone-reject-bg":o.background}}}),DY=V((e,t)=>{let n=z(`Dropzone`,TY,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,radius:l,disabled:u,loading:d,multiple:f,maxSize:p,accept:m,children:h,onDropAny:g,onDrop:_,onReject:v,openRef:y,name:b,maxFiles:x,autoFocus:S,activateOnClick:C,activateOnDrag:w,dragEventsBubbling:T,activateOnKeyboard:E,onDragEnter:D,onDragLeave:O,onDragOver:k,onFileDialogCancel:A,onFileDialogOpen:j,preventDropOnDocument:M,useFsAccessApi:N,getFilesFromEvent:P,validator:F,rejectColor:ee,acceptColor:te,enablePointerEvents:ne,loaderProps:re,inputProps:ie,mod:ae,attributes:oe,...se}=n,ce=R({name:`Dropzone`,classes:bY,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:oe,vars:c,varsResolver:EY}),{getRootProps:le,getInputProps:ue,isDragAccept:de,isDragReject:fe,isDragActive:pe,open:me}=hY({onDrop:g,onDropAccepted:_,onDropRejected:v,disabled:u||d,accept:Array.isArray(m)?m.reduce((e,t)=>({...e,[t]:[]}),{}):m,multiple:f,maxSize:p,maxFiles:x,autoFocus:S,noClick:!C,noDrag:!w,noDragEventsBubbling:!T,noKeyboard:!E,onDragEnter:D,onDragLeave:O,onDragOver:k,onFileDialogCancel:A,onFileDialogOpen:j,preventDropOnDocument:M,useFsAccessApi:N,validator:F,...P?{getFilesFromEvent:P}:null});en(y,me);let he=pe&&de,ge=pe&&fe,_e=!he&&!ge;return(0,L.jsx)(vY,{value:{accept:he,reject:ge,idle:_e},children:(0,L.jsxs)(B,{...le(),...ce(`root`,{focusable:!0}),...se,mod:[{accept:he,reject:ge,idle:_e,disabled:u,loading:d,"activate-on-click":C},ae],children:[(0,L.jsx)(Sh,{visible:d,overlayProps:{radius:l},unstyled:s,loaderProps:re}),(0,L.jsx)(`input`,{...ue(ie),name:b}),(0,L.jsx)(`div`,{...ce(`inner`),ref:t,"data-enable-pointer-events":ne||void 0,children:h})]})})});DY.classes=bY,DY.displayName=`@mantine/dropzone/Dropzone`,DY.Accept=SY,DY.Idle=wY,DY.Reject=CY;var OY={maxSize:1/0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,active:!0,zIndex:ct(`max`),withinPortal:!0},kY=V((e,t)=>{let n=z(`DropzoneFullScreen`,OY,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,active:l,onDrop:u,onReject:d,zIndex:f,withinPortal:p,portalProps:m,attributes:h,...g}=n,_=R({name:`DropzoneFullScreen`,classes:bY,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:h,rootSelector:`fullScreen`}),{resolvedClassNames:v,resolvedStyles:y}=Hr({classNames:r,styles:o,props:n}),[x,S]=(0,b.useState)(0),[C,{open:w,close:T}]=yn(!1),E=e=>{e.dataTransfer?.types.includes(`Files`)&&(S(e=>e+1),w())},D=()=>{S(e=>e-1)};return(0,b.useEffect)(()=>{x===0&&T()},[x]),(0,b.useEffect)(()=>{if(l)return document.addEventListener(`dragenter`,E,!1),document.addEventListener(`dragleave`,D,!1),()=>{document.removeEventListener(`dragenter`,E,!1),document.removeEventListener(`dragleave`,D,!1)}},[l]),(0,L.jsx)(Nl,{...m,withinPortal:p,children:(0,L.jsx)(B,{ref:t,..._(`fullScreen`,{style:{opacity:+!!C,pointerEvents:C?`all`:`none`,zIndex:f}}),children:(0,L.jsx)(DY,{activateOnClick:!1,...g,classNames:v,styles:y,unstyled:s,className:bY.dropzone,onDrop:e=>{u?.(e),T(),S(0)},onReject:e=>{d?.(e),T(),S(0)}})})})});kY.classes=bY,kY.displayName=`@mantine/dropzone/DropzoneFullScreen`,DY.FullScreen=kY;var AY=DY,jY=`{"resourceType": "Bundle"}`;function MY({id:e,title:t,message:n,color:r,icon:i,withCloseButton:a=!1,method:o=`show`,loading:s}){Rb[o]({id:e,loading:s,title:t,message:n,color:r,icon:i,withCloseButton:a,autoClose:!1})}function NY(){let e=xr(),t=Q(),[n,r]=(0,b.useState)({}),i=(0,b.useCallback)(async(e,n)=>{let i=`batch-upload`;MY({id:i,title:`Batch Upload in Progress`,message:`Your batch data is being uploaded. This may take a moment...`,method:`show`,loading:!0});try{r({});let a=JSON.parse(e);a.type!==`batch`&&a.type!==`transaction`&&(a=HE(a));let o=await t.executeBatch(a);r(e=>({...e,[n]:o})),MY({id:i,title:`Batch Upload Successful`,message:`Your batch data was successfully uploaded.`,color:`green`,method:`update`,icon:(0,L.jsx)(CA,{size:`1rem`}),withCloseButton:!0})}catch(e){MY({id:i,title:`Batch Upload Failed`,color:`red`,message:Zx(e),method:`update`,icon:(0,L.jsx)(Dj,{size:`1rem`}),withCloseButton:!0})}},[t]),a=(0,b.useCallback)(async e=>{for(let t of e){let e=new FileReader;e.onload=e=>i(e.target?.result,t.name),e.readAsText(t)}},[i]),o=(0,b.useCallback)(async e=>{await i(e.input,`JSON Data`)},[i]);return(0,L.jsxs)(nP,{children:[(0,L.jsx)(J,{children:`Batch Create`}),(0,L.jsxs)(U,{children:[`Use this page to create, read, or update multiple resources. For more details, see`,` `,(0,L.jsx)(Nd,{href:`https://www.hl7.org/fhir/http.html#transaction`,children:`FHIR Batch and Transaction`}),`.`]}),Object.keys(n).length===0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`h3`,{children:`Input`}),(0,L.jsxs)(_b,{defaultValue:`upload`,children:[(0,L.jsxs)(_b.List,{children:[(0,L.jsx)(_b.Tab,{value:`upload`,children:`File Upload`}),(0,L.jsx)(_b.Tab,{value:`json`,children:`JSON`})]}),(0,L.jsx)(_b.Panel,{value:`upload`,pt:`xs`,children:(0,L.jsx)(AY,{onDrop:a,accept:[`application/json`],children:(0,L.jsxs)(H,{justify:`center`,gap:`xl`,style:{minHeight:220,pointerEvents:`none`},children:[(0,L.jsx)(AY.Accept,{children:(0,L.jsx)(wj,{size:50,stroke:1.5,color:e.colors[e.primaryColor][5]})}),(0,L.jsx)(AY.Reject,{children:(0,L.jsx)(Dj,{size:50,stroke:1.5,color:e.colors.red[5]})}),(0,L.jsx)(AY.Idle,{children:(0,L.jsx)(wj,{size:50,stroke:1.5})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(U,{size:`xl`,inline:!0,children:`Drag files here or click to select files`}),(0,L.jsx)(U,{size:`sm`,color:`dimmed`,inline:!0,mt:7,children:`Attach as many files as you like`})]})]})})}),(0,L.jsx)(_b.Panel,{value:`json`,pt:`xs`,children:(0,L.jsxs)(sN,{onSubmit:o,children:[(0,L.jsx)(ch,{"data-testid":`batch-input`,name:`input`,autosize:!0,minRows:20,defaultValue:jY,deserialize:JSON.parse}),(0,L.jsx)(H,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,children:(0,L.jsx)(W,{type:`submit`,children:`Submit`})})]})})]})]}),Object.keys(n).length>0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`h3`,{children:`Output`}),(0,L.jsxs)(_b,{defaultValue:Object.keys(n)[0],children:[(0,L.jsx)(_b.List,{children:Object.keys(n).map(e=>(0,L.jsx)(_b.Tab,{value:e,children:e},e))}),Object.keys(n).map(e=>(0,L.jsx)(_b.Panel,{value:e,children:(0,L.jsx)(`pre`,{style:{border:`1px solid #888`},children:JSON.stringify(n[e],void 0,2)})},e))]}),(0,L.jsx)(H,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,children:(0,L.jsx)(W,{onClick:()=>r({}),children:`Start over`})})]})]})}function PY(){let{resourceType:e}=sW(),t=(Object.fromEntries(new URLSearchParams(location.search).entries()).ids||``).split(`,`).filter(e=>!!e),[n]=qk(`Questionnaire`,`subject-type=${e}`);return n?n.length===0?(0,L.jsxs)(nP,{children:[(0,L.jsxs)(J,{children:[`No apps for `,e]}),(0,L.jsx)(Rj,{to:`/${e}`,children:`Return to search page`})]}):(0,L.jsx)(nP,{children:(0,L.jsx)(`div`,{children:n.map(n=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{children:(0,L.jsx)(Rj,{to:`/forms/${n.id}?subject=`+t.map(t=>`${e}/${t}`).join(`,`),children:n.name})}),(0,L.jsx)(`p`,{children:n.description})]},n.id))})}):(0,L.jsx)(Aj,{})}function FY(){return(0,L.jsx)(cP,{})}var IY=[`Form`,`JSON`,`Profiles`];function LY(){let{resourceType:e}=sW();return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(vl,{children:[(0,L.jsxs)(U,{p:`md`,fw:500,children:[`New\xA0`,e]}),(0,L.jsx)(ll,{children:(0,L.jsx)(iz,{baseUrl:`/${e}/new`,tabs:IY})})]}),(0,L.jsx)(UW,{})]})}function RY(){return(0,L.jsx)(nP,{children:(0,L.jsxs)(K,{children:[(0,L.jsx)(J,{order:1,children:`Unexpected Error`}),(0,L.jsx)(U,{children:`We're sorry, something went wrong.`}),(0,L.jsxs)(U,{children:[`Please contact `,(0,L.jsx)(Nd,{href:`mailto:support@medplum.com`,children:`support`}),` for assistance.`]})]})})}function zY(e){let t=ek(e.resource);if(!t)return null;let n=[{key:`Type`,value:(0,L.jsx)(Rj,{to:`/${t.resourceType}`,children:t.resourceType})}];function r(e,t){e&&t&&n.push({key:e,value:t})}function i(e){e&&r(e.system,e.value)}function a(e,t){Array.isArray(t)?t.forEach(t=>a(e,t)):typeof t==`string`?r(e,t):t&&(Array.isArray(t.coding)?r(e,t.coding.map(e=>e.display||e.code).join(`, `)):r(e,t.text))}if(`name`in t){let e=lC(t);e!==aC(t)&&r(`Name`,e)}return`category`in t&&a(`Category`,t.category),t.resourceType!==`Bot`&&`code`in t&&a(`Code`,t.code),`identifier`in t&&(Array.isArray(t.identifier)?t.identifier.forEach(i):i(t.identifier)),n.length===1&&n.push({key:`ID`,value:t.id}),(0,L.jsx)(nz,{children:n.map((e,t)=>(0,L.jsxs)(nz.Entry,{children:[(0,L.jsx)(nz.Key,{children:e.key}),(0,L.jsx)(nz.Value,{children:e.value})]},`${e.key}-${t}`))})}function BY(){let{id:e}=sW(),t=eW(),n=Object.fromEntries(new URLSearchParams(t.search).entries()).subject,r=Q(),[i,a]=(0,b.useState)(!0),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)(),[f,p]=(0,b.useState)(),[m,h]=(0,b.useState)();if((0,b.useEffect)(()=>{let t={resourceType:`Bundle`,type:`batch`,entry:[{request:{method:`GET`,url:`Questionnaire/${e}`}}]};if(n){let e=n.split(`,`).filter(e=>!!e);e.length===1&&t.entry.push({request:{method:`GET`,url:e[0]}}),l(e)}r.executeBatch(t).then(e=>{e.entry?.[0]?.response?.status===`200`?(s(e.entry[0]?.resource),d(e.entry[1]?.resource)):p(e.entry?.[0]?.response?.outcome),a(!1)}).catch(e=>{p(e),a(!1)})},[r,e,n]),f)return(0,L.jsx)(nP,{children:(0,L.jsx)(`pre`,{"data-testid":`error`,children:JSON.stringify(f,void 0,2)})});if(m)return(0,L.jsxs)(nP,{children:[(0,L.jsx)(J,{children:o?.title}),(0,L.jsx)(`p`,{children:`Your response has been recorded.`}),(0,L.jsxs)(`ul`,{children:[m.length===1&&(0,L.jsx)(`li`,{children:(0,L.jsx)(Rj,{to:m[0],children:`Review your answers`})}),m.length>1&&(0,L.jsxs)(`li`,{children:[`Review your answers:`,(0,L.jsx)(`ul`,{children:m.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(Rj,{to:e,children:aC(e)})},e.id))})]}),u&&(0,L.jsx)(`li`,{children:(0,L.jsxs)(Rj,{to:u,children:[`Back to\xA0`,lC(u)]})}),(0,L.jsx)(`li`,{children:(0,L.jsx)(Rj,{to:`/`,children:`Go back home`})})]})]});if(i||!o)return(0,L.jsx)(Aj,{});let g=u&&dK(u);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(vl,{shadow:`xs`,radius:0,children:[g&&(0,L.jsx)(Tz,{patient:g}),u&&u.resourceType!==`Patient`&&(0,L.jsx)(zY,{resource:u}),(0,L.jsx)(B,{px:`xl`,py:`md`,children:(0,L.jsxs)(U,{children:[lC(o),c&&c.length>1&&(0,L.jsxs)(L.Fragment,{children:[`\xA0(for `,c.length,` resources)`]})]})})]}),(0,L.jsx)(nP,{children:(0,L.jsx)(GI,{questionnaire:o,subject:u&&iC(u),onSubmit:_})})]});async function _(e){let t=[];if(!c||c.length===0)t.push(await r.createResource(e));else for(let n of c)t.push(await r.createResource({...e,subject:{reference:n}}));h(t)}}var VY={paper:`_paper_unw9o_1`},HY={Bot:`/admin/bots/new`,ClientApplication:`/admin/clients/new`};function UY(e,t){let n=e.resourceType||WY(t),r=e.fields??GY(n),i=e.filters??(e.resourceType?void 0:KY(n)),a=e.sortRules??qY(n),o=e.offset??0,s=e.count??20;return{...e,resourceType:n,fields:r,filters:i,sortRules:a,offset:o,count:s}}function WY(e){return localStorage.getItem(`defaultResourceType`)??e?.option?.find(e=>e.id===`defaultResourceType`)?.valueString??`Patient`}function GY(e){let t=JY(e);if(t?.fields)return t.fields;let n=[`id`,`_lastUpdated`];switch(e){case`Patient`:n.push(`name`,`birthDate`,`gender`);break;case`AsyncJob`:n.push(`status`,`dataVersion`);break;case`AccessPolicy`:case`Bot`:case`ClientApplication`:case`Practitioner`:case`Project`:case`Organization`:case`Questionnaire`:case`UserConfiguration`:n.push(`name`);break;case`CodeSystem`:case`ValueSet`:n.push(`name`,`title`,`status`);break;case`Condition`:n.push(`subject`,`code`,`clinicalStatus`);break;case`Device`:n.push(`manufacturer`,`deviceName`,`patient`);break;case`DeviceDefinition`:n.push(`manufacturer[x]`,`deviceName`);break;case`DeviceRequest`:n.push(`code[x]`,`subject`);break;case`DiagnosticReport`:case`Observation`:n.push(`subject`,`code`,`status`);break;case`Encounter`:n.push(`subject`);break;case`ServiceRequest`:n.push(`subject`,`code`,`status`,`orderDetail`);break;case`Subscription`:n.push(`criteria`);break;case`User`:n.push(`email`);break}return n}function KY(e){return JY(e)?.filters}function qY(e){let t=JY(e);return t?.sortRules?t.sortRules:[{code:`_lastUpdated`,descending:!0}]}function JY(e){let t=localStorage.getItem(e+`-defaultSearch`);return t?JSON.parse(t):void 0}function YY(e){localStorage.setItem(`defaultResourceType`,e.resourceType),localStorage.setItem(e.resourceType+`-defaultSearch`,JSON.stringify(e))}async function XY(e,t){let n=UY({...e,count:1e3,offset:0},t.getUserConfiguration());return HE(await t.search(n.resourceType,oE({...n,total:`accurate`,fields:void 0})))}function ZY(){let e=Q(),t=rW(),n=eW(),[r,i]=(0,b.useState)();return(0,b.useEffect)(()=>{let r=UY(YT(n.pathname+n.search),e.getUserConfiguration());n.pathname===`/${r.resourceType}`&&n.search===oE(r)?(YY(r),i(r)):t(`/${r.resourceType}${oE(r)}`)?.catch(console.error)},[e,t,n]),!r?.resourceType||!r.fields||r.fields.length===0?(0,L.jsx)(Aj,{}):(0,L.jsx)(vl,{shadow:`xs`,m:`md`,p:`xs`,className:VY.paper,children:(0,L.jsx)(KR,{checkboxesEnabled:!0,search:r,onClick:e=>t(`/${e.resource.resourceType}/${e.resource.id}`)?.catch(console.error),onAuxClick:e=>window.open(`/${e.resource.resourceType}/${e.resource.id}`,`_blank`),onChange:e=>{t(`/${r.resourceType}${oE(e.definition)}`)?.catch(console.error)},onNew:()=>{t(HY[r.resourceType]??`/${r.resourceType}/new`)?.catch(console.error)},onExportCsv:()=>{let t=e.fhirUrl(r.resourceType,`$csv`)+oE(r);e.download(t).then(e=>{window.open(window.URL.createObjectURL(e),`_blank`)}).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1}))},onExportTransactionBundle:async()=>{XY(r,e).then(e=>Lj(JSON.stringify(e,void 0,2))).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1}))},onDelete:t=>{window.confirm(`Are you sure you want to delete these resources?`)&&(e.invalidateSearches(r.resourceType),e.executeBatch({resourceType:`Bundle`,type:`batch`,entry:t.map(e=>({request:{method:`DELETE`,url:`${r.resourceType}/${e}`}}))}).then(()=>i({...r})).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1})))},onBulk:e=>{t(`/bulk/${r.resourceType}?ids=${e.join(`,`)}`)?.catch(console.error)}})})}function QY(){let[e]=qk(`ObservationDefinition`,`_count=100`);return e?(0,L.jsxs)(q,{withTableBorder:!0,withRowBorders:!0,withColumnBorders:!0,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{children:`Category`}),(0,L.jsx)(`th`,{children:`Code`}),(0,L.jsx)(`th`,{children:`Method`}),(0,L.jsx)(`th`,{children:`Unit`}),(0,L.jsx)(`th`,{children:`Precision`}),(0,L.jsx)(`th`,{children:`Ranges`})]})}),(0,L.jsx)(`tbody`,{children:e.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{children:(0,L.jsx)(VP,{value:e.category?.[0]})}),(0,L.jsx)(`td`,{children:(0,L.jsx)(VP,{value:e.code})}),(0,L.jsx)(`td`,{children:(0,L.jsx)(VP,{value:e.method})}),(0,L.jsx)(`td`,{children:e.quantitativeDetails?.unit?.text}),(0,L.jsx)(`td`,{children:e.quantitativeDetails?.decimalPrecision}),(0,L.jsx)(`td`,{children:(0,L.jsx)($Y,{ranges:e.qualifiedInterval})})]},e.id))})]}):(0,L.jsx)(Aj,{})}function $Y(e){let{ranges:t}=e;if(!t)return null;let n=eX(t.map(e=>e.gender));if(n.length>1)return YC(n),(0,L.jsx)(L.Fragment,{children:n.map(t=>(0,L.jsxs)(b.Fragment,{children:[(0,L.jsx)(`div`,{children:(0,L.jsx)(`strong`,{children:VC(t)})}),(0,L.jsx)($Y,{ranges:e.ranges?.filter(e=>e.gender===t)})]},t))});let r=eX(t.map(e=>e.age&&_w(e.age)));return r.length>1?(YC(r),(0,L.jsx)(L.Fragment,{children:r.map(t=>(0,L.jsxs)(b.Fragment,{children:[(0,L.jsx)(`div`,{children:(0,L.jsx)(`strong`,{children:VC(t)})}),(0,L.jsx)($Y,{ranges:e.ranges?.filter(e=>_w(e.age)===t)})]},t))})):(0,L.jsx)(L.Fragment,{children:t.map(e=>(0,L.jsx)(`table`,{children:(0,L.jsx)(`tbody`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{children:e.condition}),(0,L.jsx)(`td`,{children:(0,L.jsx)(ZP,{value:e.range})})]})})},`range-${e.condition}`))})}function eX(e){return[...new Set(e.filter(e=>!!e))]}function tX(){let[e]=qk(`ActivityDefinition`,`_count=100`),[t]=qk(`ObservationDefinition`,`_count=100`);return!e||!t?(0,L.jsx)(Aj,{}):(0,L.jsxs)(q,{withTableBorder:!0,withRowBorders:!0,withColumnBorders:!0,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{children:`Category`}),(0,L.jsx)(`th`,{children:`Assay`}),e.map(e=>(0,L.jsx)(`th`,{children:e.name},e.id))]})}),(0,L.jsx)(`tbody`,{children:t.map(t=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{children:(0,L.jsx)(VP,{value:t.category?.[0]})}),(0,L.jsx)(`td`,{children:(0,L.jsx)(VP,{value:t.code})}),e.map(e=>(0,L.jsx)(`td`,{children:e.observationResultRequirement?.find(e=>e.reference?.includes(t.id))?`✅`:``},e.id))]},t.id))})]})}function nX(){let e=Q(),[t,n]=(0,b.useState)(),[r,i]=(0,b.useState)(void 0),[a,o]=(0,b.useState)(!1),s=(0,b.useCallback)(()=>{e.get(`auth/mfa/status`,{cache:`no-cache`}).then(e=>{n(e.enrollQrCode),i(e.enrolled)}).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1}))},[e]);(0,b.useEffect)(()=>{s()},[s]);let c=(0,b.useCallback)(t=>{e.post(`auth/mfa/enroll`,t).then(()=>{i(!0),Y({color:`green`,message:`Success`})}).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1}))},[e]),l=(0,b.useCallback)(async t=>e.post(`auth/mfa/disable`,{token:t.token}),[e]);return r===void 0?null:r?(0,L.jsxs)(nP,{children:[(0,L.jsx)(ng,{title:`Disable MFA`,opened:a,onClose:()=>o(!1),children:(0,L.jsx)(lP,{title:`Disable MFA`,buttonText:`Submit code`,onSubmit:async e=>{await l(e),o(!1),i(!1),Y({id:`mfa-disabled`,color:`green`,title:`Success`,message:`MFA disabled`,icon:(0,L.jsx)(EA,{})}),s()}})}),(0,L.jsxs)(H,{children:[(0,L.jsx)(J,{children:`MFA is enabled`}),(0,L.jsx)(W,{onClick:()=>o(!0),children:`Disable MFA`})]})]}):(0,L.jsx)(nP,{width:400,children:(0,L.jsx)(lP,{title:`Multi Factor Auth Setup`,buttonText:`Enroll`,qrCodeUrl:t,onSubmit:c})})}var rX={baseUrl:`__MEDPLUM_BASE_URL__`,clientId:`__MEDPLUM_CLIENT_ID__`,googleClientId:`__GOOGLE_CLIENT_ID__`,recaptchaSiteKey:`__RECAPTCHA_SITE_KEY__`,registerEnabled:`__MEDPLUM_REGISTER_ENABLED__`,awsTextractEnabled:void 0};function iX(){return rX}function aX(){return sX(`registerEnabled`)}function oX(){return sX(`awsTextractEnabled`)}function sX(e){try{return rX[e]!==!1&&rX[e]!==`false`}catch{return!0}}function cX(){let e=rW(),[t]=qG(),n=Q(),r=t.get(`scope`)||`openid`,[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)(!0),c=t.get(`client_id`),l=t.get(`login`);if((0,b.useEffect)(()=>{if(!c||c===`medplum-cli`)return;async function e(){try{a(await n.get(`/auth/clientinfo/${c}`))}catch(e){Y({id:`clientinfofail`,title:`Failed to retrieve client information.`,color:`red`,message:Zx(e),withCloseButton:!0})}finally{s(!1)}}e().catch(console.error)},[n,c]),!c)return null;function u(e){let n=new URL(t.get(`redirect_uri`));for(let e of[`scope`,`state`,`nonce`])t.has(e)&&n.searchParams.set(e,t.get(e));n.searchParams.set(`code`,e),FE.assign(n.toString())}return(0,L.jsx)(BP,{onCode:u,onForgotPassword:()=>e(`/resetpassword`)?.catch(console.error),onRegister:()=>e(`/register`)?.catch(console.error),googleClientId:iX().googleClientId,clientId:c||void 0,redirectUri:t.get(`redirect_uri`)||void 0,scope:r,nonce:t.get(`nonce`)||void 0,launch:t.get(`launch`)||void 0,codeChallenge:t.get(`code_challenge`)||void 0,codeChallengeMethod:t.get(`code_challenge_method`)||void 0,chooseScopes:r!==`openid`,login:l||void 0,children:!o&&(0,L.jsxs)(L.Fragment,{children:[i?.logo?.url?(0,L.jsx)(`img`,{src:i?.logo?.url,alt:`Welcome Logo`,height:60,style:{width:`auto`}}):(0,L.jsx)(rP,{size:32}),(0,L.jsx)(J,{children:i?.welcomeString??`Sign in to Medplum`})]})})}function lX(){let e=Q(),t=rW(),[n]=qG(),r=iX();return(0,b.useEffect)(()=>{e.getProfile()&&t(`/signin?project=new`)?.catch(console.error)},[e,t]),aX()?(0,L.jsxs)(vP,{type:`project`,projectId:`new`,onSuccess:()=>{window.location.href=`/`},googleClientId:r.googleClientId,recaptchaSiteKey:r.recaptchaSiteKey,login:n.get(`login`)||void 0,children:[(0,L.jsx)(rP,{size:32}),(0,L.jsx)(J,{order:3,py:`lg`,children:`Register a new account`})]}):(0,L.jsx)(nP,{width:450,children:(0,L.jsx)(Ed,{icon:(0,L.jsx)(lA,{size:16}),title:`New projects disabled`,color:`red`,children:`New projects are disabled on this server.`})})}function uX(){let e=rW(),[t]=qG(),n=iX();return(0,L.jsx)(yP,{projectId:t.get(`project`)||void 0,recaptchaSiteKey:n.recaptchaSiteKey,onSignIn:()=>e(`/signin`)?.catch(console.error),onRegister:aX()?()=>e(`/register`)?.catch(console.error):void 0})}function dX(){let{resourceType:e,id:t}=sW(),n=ek({reference:e+`/`+t}),r=rW(),i=(0,b.useCallback)(()=>{r(0)?.catch(console.error)},[r]);return n?(0,L.jsx)(nP,{maw:700,children:n.resourceType===`Patient`?(0,L.jsx)(_z,{patient:n,onSaved:i}):(0,L.jsx)(Ed,{icon:(0,L.jsx)(lA,{size:16}),title:`Unsupported resource type`,color:`red`,children:`Account management is only supported for Patient resources`})}):null}function fX(e){let t=Q(),[n,r]=(0,b.useState)(),[i,a]=(0,b.useState)();return i?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{children:`Request group created successfully.`}),(0,L.jsxs)(`ul`,{children:[(0,L.jsxs)(`li`,{children:[`Go to the`,` `,(0,L.jsx)(Rj,{to:i,suffix:`checklist`,children:`Request Group`})]}),(0,L.jsxs)(`li`,{children:[`Back to the `,(0,L.jsx)(Rj,{to:e.planDefinition,children:`Plan Definition`})]})]})]}):(0,L.jsx)(sN,{onSubmit:()=>{t.post(t.fhirUrl(`PlanDefinition`,e.planDefinition.id,`$apply`),{resourceType:`Parameters`,parameter:[{name:`subject`,valueString:n?.reference}]}).then(a).catch(console.log)},children:(0,L.jsxs)(K,{children:[(0,L.jsxs)(J,{children:[`Start "`,e.planDefinition.title,`"`]}),(0,L.jsxs)(U,{children:[`Use the `,(0,L.jsx)(`strong`,{children:`Apply`}),` operation to create a group of tasks for a workflow.`]}),(0,L.jsx)(U,{children:`The following tasks will be created:`}),(0,L.jsx)(`ul`,{children:e.planDefinition.action?.map((e,t)=>(0,L.jsxs)(`li`,{children:[e.definitionCanonical?.startsWith(`Questionnaire/`)&&`Questionnaire request: `,e.title&&(0,L.jsx)(L.Fragment,{children:e.title}),e.code&&(0,L.jsx)(VP,{value:e.code[0]})]},`action-${t}`))}),(0,L.jsx)(hF,{title:`Subject`,children:(0,L.jsx)(qF,{name:`subject`,targetTypes:[`Patient`,`Practitioner`],defaultValue:n,onChange:r})}),(0,L.jsx)(H,{justify:`flex-end`,mt:`xl`,children:(0,L.jsx)(W,{type:`submit`,children:`Go`})})]})})}function pX(){let{resourceType:e,id:t}=sW(),n=ek({reference:e+`/`+t});return n?(0,L.jsx)(nP,{children:(0,L.jsx)(fX,{planDefinition:n})}):null}function mX(){let{resourceType:e,id:t}=sW(),n=ek({reference:e+`/`+t}),[r,i]=qk(`Questionnaire`,`subject-type=`+e),[a,o]=qk(`ClientApplication`,{_count:1e3});if(!n||i||o)return(0,L.jsx)(Aj,{});let s=a?.filter(t=>hX(e)&&!!t.launchUri);if((!r||r.length===0)&&(!s||s.length===0))return(0,L.jsxs)(nP,{children:[(0,L.jsx)(J,{children:`Apps`}),(0,L.jsxs)(`p`,{children:[`No apps found. Contact your administrator or `,(0,L.jsx)(`a`,{href:`mailto:support@medplum.com`,children:`Medplum Support`}),` to add automation here.`]})]});let c,l;return n.resourceType===`Patient`?c=iC(n):n.resourceType===`Encounter`&&(c=n.subject,l=iC(n)),(0,L.jsxs)(nP,{children:[r?.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(J,{order:3,children:(0,L.jsx)(Rj,{to:`/forms/${e.id}?subject=${aC(n)}`,children:e.title||e.name})}),(0,L.jsx)(U,{children:e.description})]},e.id)),s?.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(J,{order:3,children:(0,L.jsx)(oK,{client:e,patient:c,encounter:l,children:e.name})}),(0,L.jsx)(U,{children:e.description})]},e.id))]})}function hX(e){return e===`Patient`||e===`Encounter`}function gX(){let{resourceType:e,id:t}=sW(),n=rW(),[r,i]=(0,b.useState)({resourceType:`AuditEvent`,filters:[{code:`entity`,operator:Z.EQUALS,value:`${e}/${t}`}],fields:[`id`,`outcome`,`outcomeDesc`,`_lastUpdated`],sortRules:[{code:`-_lastUpdated`}],count:20});return(0,L.jsx)(nP,{children:(0,L.jsx)(KR,{search:r,onClick:e=>n(`/${e.resource.resourceType}/${e.resource.id}`)?.catch(console.error),onChange:e=>i(e.definition),hideFilters:!0})})}function _X(){let e=Q(),{resourceType:t,id:n}=sW();return(0,L.jsx)(im,{maw:1200,children:(0,L.jsx)(tP,{children:(0,L.jsx)(SB,{history:e.readHistory(t,n).read()})})})}var vX={hl7Input:`_hl7Input_k5xm3_1`};function yX(e){return(0,L.jsx)(`iframe`,{title:`Bot Runner`,frameBorder:`0`,src:`https://codeeditor.medplum.com/bot-runner.html`,className:e.className,ref:e.iframeRef,"data-testid":e.testId,style:{width:`100%`,height:`100%`,minHeight:e.minHeight}})}function bX(e){let t=e.defaultValue,n=new URL(`https://codeeditor.medplum.com/${e.language}-editor.html`);return e.module&&n.searchParams.set(`module`,e.module),(0,L.jsx)(`iframe`,{title:`Code Editor`,frameBorder:`0`,src:n.toString(),style:{width:`100%`,height:`100%`,minHeight:e.minHeight},ref:e.iframeRef,"data-testid":e.testId,onLoad:e=>{Ij(e.currentTarget,{command:`setValue`,value:t}).catch(console.error)}})}var xX=`{
226
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rY(e,t){if(e){if(typeof e==`string`)return iY(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return iY(e,t)}}function iY(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function aY(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function oY(e){if(Array.isArray(e))return e}function sY(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function cY(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?sY(Object(n),!0).forEach(function(t){lY(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sY(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function lY(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function uY(e,t){if(e==null)return{};var n=dY(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function dY(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}var fY=(0,b.forwardRef)(function(e,t){var n=e.children,r=hY(uY(e,qJ)),i=r.open,a=uY(r,JJ);return(0,b.useImperativeHandle)(t,function(){return{open:i}},[i]),b.createElement(b.Fragment,null,n(cY(cY({},a),{},{open:i})))});fY.displayName=`Dropzone`;var pY={disabled:!1,getFilesFromEvent:Uq,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};fY.defaultProps=pY,fY.propTypes={children:KJ.default.func,accept:KJ.default.objectOf(KJ.default.arrayOf(KJ.default.string)),multiple:KJ.default.bool,preventDropOnDocument:KJ.default.bool,noClick:KJ.default.bool,noKeyboard:KJ.default.bool,noDrag:KJ.default.bool,noDragEventsBubbling:KJ.default.bool,minSize:KJ.default.number,maxSize:KJ.default.number,maxFiles:KJ.default.number,disabled:KJ.default.bool,getFilesFromEvent:KJ.default.func,onFileDialogCancel:KJ.default.func,onFileDialogOpen:KJ.default.func,useFsAccessApi:KJ.default.bool,autoFocus:KJ.default.bool,onDragEnter:KJ.default.func,onDragLeave:KJ.default.func,onDragOver:KJ.default.func,onDrop:KJ.default.func,onDropAccepted:KJ.default.func,onDropRejected:KJ.default.func,onError:KJ.default.func,validator:KJ.default.func};var mY={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragGlobal:!1,acceptedFiles:[],fileRejections:[]};function hY(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=cY(cY({},pY),e),n=t.accept,r=t.disabled,i=t.getFilesFromEvent,a=t.maxSize,o=t.minSize,s=t.multiple,c=t.maxFiles,l=t.onDragEnter,u=t.onDragLeave,d=t.onDragOver,f=t.onDrop,p=t.onDropAccepted,m=t.onDropRejected,h=t.onFileDialogCancel,g=t.onFileDialogOpen,_=t.useFsAccessApi,v=t.autoFocus,y=t.preventDropOnDocument,x=t.noClick,S=t.noKeyboard,C=t.noDrag,w=t.noDragEventsBubbling,T=t.onError,E=t.validator,D=(0,b.useMemo)(function(){return VJ(n)},[n]),O=(0,b.useMemo)(function(){return BJ(n)},[n]),k=(0,b.useMemo)(function(){return typeof g==`function`?g:_Y},[g]),A=(0,b.useMemo)(function(){return typeof h==`function`?h:_Y},[h]),j=(0,b.useRef)(null),M=(0,b.useRef)(null),N=tY((0,b.useReducer)(gY,mY),2),P=N[0],F=N[1],ee=P.isFocused,te=P.isFileDialogActive,ne=(0,b.useRef)(typeof window<`u`&&window.isSecureContext&&_&&zJ()),re=function(){!ne.current&&te&&setTimeout(function(){M.current&&(M.current.files.length||(F({type:`closeDialog`}),A()))},300)};(0,b.useEffect)(function(){return window.addEventListener(`focus`,re,!1),function(){window.removeEventListener(`focus`,re,!1)}},[M,te,A,ne]);var ie=(0,b.useRef)([]),ae=(0,b.useRef)([]),oe=function(e){j.current&&j.current.contains(e.target)||(e.preventDefault(),ie.current=[])};(0,b.useEffect)(function(){return y&&(document.addEventListener(`dragover`,PJ,!1),document.addEventListener(`drop`,oe,!1)),function(){y&&(document.removeEventListener(`dragover`,PJ),document.removeEventListener(`drop`,oe))}},[j,y]),(0,b.useEffect)(function(){var e=function(e){ae.current=[].concat(ZJ(ae.current),[e.target]),NJ(e)&&F({isDragGlobal:!0,type:`setDragGlobal`})},t=function(e){ae.current=ae.current.filter(function(t){return t!==e.target&&t!==null}),!(ae.current.length>0)&&F({isDragGlobal:!1,type:`setDragGlobal`})},n=function(){ae.current=[],F({isDragGlobal:!1,type:`setDragGlobal`})},r=function(){ae.current=[],F({isDragGlobal:!1,type:`setDragGlobal`})};return document.addEventListener(`dragenter`,e,!1),document.addEventListener(`dragleave`,t,!1),document.addEventListener(`dragend`,n,!1),document.addEventListener(`drop`,r,!1),function(){document.removeEventListener(`dragenter`,e),document.removeEventListener(`dragleave`,t),document.removeEventListener(`dragend`,n),document.removeEventListener(`drop`,r)}},[j]),(0,b.useEffect)(function(){return!r&&v&&j.current&&j.current.focus(),function(){}},[j,v,r]);var se=(0,b.useCallback)(function(e){T?T(e):console.error(e)},[T]),ce=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),xe(e),ie.current=[].concat(ZJ(ie.current),[e.target]),NJ(e)&&Promise.resolve(i(e)).then(function(t){if(!(MJ(e)&&!w)){var n=t.length,r=n>0&&jJ({files:t,accept:D,minSize:o,maxSize:a,multiple:s,maxFiles:c,validator:E});F({isDragAccept:r,isDragReject:n>0&&!r,isDragActive:!0,type:`setDraggedFiles`}),l&&l(e)}}).catch(function(e){return se(e)})},[i,l,se,w,D,o,a,s,c,E]),le=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),xe(e);var t=NJ(e);if(t&&e.dataTransfer)try{e.dataTransfer.dropEffect=`copy`}catch{}return t&&d&&d(e),!1},[d,w]),ue=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),xe(e);var t=ie.current.filter(function(e){return j.current&&j.current.contains(e)}),n=t.indexOf(e.target);n!==-1&&t.splice(n,1),ie.current=t,!(t.length>0)&&(F({type:`setDraggedFiles`,isDragActive:!1,isDragAccept:!1,isDragReject:!1}),NJ(e)&&u&&u(e))},[j,u,w]),de=(0,b.useCallback)(function(e,t){var n=[],r=[];e.forEach(function(e){var t=tY(OJ(e,D),2),i=t[0],s=t[1],c=tY(kJ(e,o,a),2),l=c[0],u=c[1],d=E?E(e):null;if(i&&l&&!d)n.push(e);else{var f=[s,u];d&&(f=f.concat(d)),r.push({file:e,errors:f.filter(function(e){return e})})}}),(!s&&n.length>1||s&&c>=1&&n.length>c)&&(n.forEach(function(e){r.push({file:e,errors:[EJ]})}),n.splice(0)),F({acceptedFiles:n,fileRejections:r,type:`setFiles`}),f&&f(n,r,t),r.length>0&&m&&m(r,t),n.length>0&&p&&p(n,t)},[F,s,D,o,a,c,f,p,m,E]),fe=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),xe(e),ie.current=[],NJ(e)&&Promise.resolve(i(e)).then(function(t){MJ(e)&&!w||de(t,e)}).catch(function(e){return se(e)}),F({type:`reset`})},[i,de,se,w]),pe=(0,b.useCallback)(function(){if(ne.current){F({type:`openDialog`}),k();var e={multiple:s,types:O};window.showOpenFilePicker(e).then(function(e){return i(e)}).then(function(e){de(e,null),F({type:`closeDialog`})}).catch(function(e){HJ(e)?(A(e),F({type:`closeDialog`})):UJ(e)?(ne.current=!1,M.current?(M.current.value=null,M.current.click()):se(Error(`Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided.`))):se(e)});return}M.current&&(F({type:`openDialog`}),k(),M.current.value=null,M.current.click())},[F,k,A,_,de,se,O,s]),me=(0,b.useCallback)(function(e){!j.current||!j.current.isEqualNode(e.target)||(e.key===` `||e.key===`Enter`||e.keyCode===32||e.keyCode===13)&&(e.preventDefault(),pe())},[j,pe]),he=(0,b.useCallback)(function(){F({type:`focus`})},[]),ge=(0,b.useCallback)(function(){F({type:`blur`})},[]),_e=(0,b.useCallback)(function(){x||(LJ()?setTimeout(pe,0):pe())},[x,pe]),ve=function(e){return r?null:e},ye=function(e){return S?null:ve(e)},be=function(e){return C?null:ve(e)},xe=function(e){w&&e.stopPropagation()},Se=(0,b.useMemo)(function(){return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.refKey,n=t===void 0?`ref`:t,i=e.role,a=e.onKeyDown,o=e.onFocus,s=e.onBlur,c=e.onClick,l=e.onDragEnter,u=e.onDragOver,d=e.onDragLeave,f=e.onDrop,p=uY(e,YJ);return cY(cY(lY({onKeyDown:ye(RJ(a,me)),onFocus:ye(RJ(o,he)),onBlur:ye(RJ(s,ge)),onClick:ve(RJ(c,_e)),onDragEnter:be(RJ(l,ce)),onDragOver:be(RJ(u,le)),onDragLeave:be(RJ(d,ue)),onDrop:be(RJ(f,fe)),role:typeof i==`string`&&i!==``?i:`presentation`},n,j),!r&&!S?{tabIndex:0}:{}),p)}},[j,me,he,ge,_e,ce,le,ue,fe,S,C,r]),Ce=(0,b.useCallback)(function(e){e.stopPropagation()},[]),we=(0,b.useMemo)(function(){return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.refKey,n=t===void 0?`ref`:t,r=e.onChange,i=e.onClick,a=uY(e,XJ);return cY(cY({},lY({accept:D,multiple:s,type:`file`,style:{border:0,clip:`rect(0, 0, 0, 0)`,clipPath:`inset(50%)`,height:`1px`,margin:`0 -1px -1px 0`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`},onChange:ve(RJ(r,fe)),onClick:ve(RJ(i,Ce)),tabIndex:-1},n,M)),a)}},[M,n,s,fe,r]);return cY(cY({},P),{},{isFocused:ee&&!r,getRootProps:Se,getInputProps:we,rootRef:j,inputRef:M,open:ve(pe)})}function gY(e,t){switch(t.type){case`focus`:return cY(cY({},e),{},{isFocused:!0});case`blur`:return cY(cY({},e),{},{isFocused:!1});case`openDialog`:return cY(cY({},mY),{},{isFileDialogActive:!0});case`closeDialog`:return cY(cY({},e),{},{isFileDialogActive:!1});case`setDraggedFiles`:return cY(cY({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case`setFiles`:return cY(cY({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:!1});case`setDragGlobal`:return cY(cY({},e),{},{isDragGlobal:t.isDragGlobal});case`reset`:return cY({},mY);default:return e}}function _Y(){}var[vY,yY]=$e(`Dropzone component was not found in tree`),bY={root:`m_d46a4834`,inner:`m_b85f7144`,fullScreen:`m_96f6e9ad`,dropzone:`m_7946116d`};function xY(e){let t=t=>{let{children:n,...r}=z(`Dropzone${Tt(e)}`,{},t),i=yY(),a=Ze(n)?n:(0,L.jsx)(`span`,{children:n});return i[e]?(0,b.cloneElement)(a,r):null};return t.displayName=`@mantine/dropzone/${Tt(e)}`,t}var SY=xY(`accept`),CY=xY(`reject`),wY=xY(`idle`),TY={multiple:!0,maxSize:1/0,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,useFsAccessApi:!0,variant:`light`,rejectColor:`red`},EY=kn((e,{radius:t,variant:n,acceptColor:r,rejectColor:i})=>{let a=e.variantColorResolver({color:r||e.primaryColor,theme:e,variant:n}),o=e.variantColorResolver({color:i||`red`,theme:e,variant:n});return{root:{"--dropzone-radius":pt(t),"--dropzone-accept-color":a.color,"--dropzone-accept-bg":a.background,"--dropzone-reject-color":o.color,"--dropzone-reject-bg":o.background}}}),DY=V((e,t)=>{let n=z(`Dropzone`,TY,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,radius:l,disabled:u,loading:d,multiple:f,maxSize:p,accept:m,children:h,onDropAny:g,onDrop:_,onReject:v,openRef:y,name:b,maxFiles:x,autoFocus:S,activateOnClick:C,activateOnDrag:w,dragEventsBubbling:T,activateOnKeyboard:E,onDragEnter:D,onDragLeave:O,onDragOver:k,onFileDialogCancel:A,onFileDialogOpen:j,preventDropOnDocument:M,useFsAccessApi:N,getFilesFromEvent:P,validator:F,rejectColor:ee,acceptColor:te,enablePointerEvents:ne,loaderProps:re,inputProps:ie,mod:ae,attributes:oe,...se}=n,ce=R({name:`Dropzone`,classes:bY,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:oe,vars:c,varsResolver:EY}),{getRootProps:le,getInputProps:ue,isDragAccept:de,isDragReject:fe,isDragActive:pe,open:me}=hY({onDrop:g,onDropAccepted:_,onDropRejected:v,disabled:u||d,accept:Array.isArray(m)?m.reduce((e,t)=>({...e,[t]:[]}),{}):m,multiple:f,maxSize:p,maxFiles:x,autoFocus:S,noClick:!C,noDrag:!w,noDragEventsBubbling:!T,noKeyboard:!E,onDragEnter:D,onDragLeave:O,onDragOver:k,onFileDialogCancel:A,onFileDialogOpen:j,preventDropOnDocument:M,useFsAccessApi:N,validator:F,...P?{getFilesFromEvent:P}:null});en(y,me);let he=pe&&de,ge=pe&&fe,_e=!he&&!ge;return(0,L.jsx)(vY,{value:{accept:he,reject:ge,idle:_e},children:(0,L.jsxs)(B,{...le(),...ce(`root`,{focusable:!0}),...se,mod:[{accept:he,reject:ge,idle:_e,disabled:u,loading:d,"activate-on-click":C},ae],children:[(0,L.jsx)(Sh,{visible:d,overlayProps:{radius:l},unstyled:s,loaderProps:re}),(0,L.jsx)(`input`,{...ue(ie),name:b}),(0,L.jsx)(`div`,{...ce(`inner`),ref:t,"data-enable-pointer-events":ne||void 0,children:h})]})})});DY.classes=bY,DY.displayName=`@mantine/dropzone/Dropzone`,DY.Accept=SY,DY.Idle=wY,DY.Reject=CY;var OY={maxSize:1/0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,active:!0,zIndex:ct(`max`),withinPortal:!0},kY=V((e,t)=>{let n=z(`DropzoneFullScreen`,OY,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,active:l,onDrop:u,onReject:d,zIndex:f,withinPortal:p,portalProps:m,attributes:h,...g}=n,_=R({name:`DropzoneFullScreen`,classes:bY,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:h,rootSelector:`fullScreen`}),{resolvedClassNames:v,resolvedStyles:y}=Hr({classNames:r,styles:o,props:n}),[x,S]=(0,b.useState)(0),[C,{open:w,close:T}]=yn(!1),E=e=>{e.dataTransfer?.types.includes(`Files`)&&(S(e=>e+1),w())},D=()=>{S(e=>e-1)};return(0,b.useEffect)(()=>{x===0&&T()},[x]),(0,b.useEffect)(()=>{if(l)return document.addEventListener(`dragenter`,E,!1),document.addEventListener(`dragleave`,D,!1),()=>{document.removeEventListener(`dragenter`,E,!1),document.removeEventListener(`dragleave`,D,!1)}},[l]),(0,L.jsx)(Nl,{...m,withinPortal:p,children:(0,L.jsx)(B,{ref:t,..._(`fullScreen`,{style:{opacity:+!!C,pointerEvents:C?`all`:`none`,zIndex:f}}),children:(0,L.jsx)(DY,{activateOnClick:!1,...g,classNames:v,styles:y,unstyled:s,className:bY.dropzone,onDrop:e=>{u?.(e),T(),S(0)},onReject:e=>{d?.(e),T(),S(0)}})})})});kY.classes=bY,kY.displayName=`@mantine/dropzone/DropzoneFullScreen`,DY.FullScreen=kY;var AY=DY,jY=`{"resourceType": "Bundle"}`;function MY({id:e,title:t,message:n,color:r,icon:i,withCloseButton:a=!1,method:o=`show`,loading:s}){Rb[o]({id:e,loading:s,title:t,message:n,color:r,icon:i,withCloseButton:a,autoClose:!1})}function NY(){let e=xr(),t=Q(),[n,r]=(0,b.useState)({}),i=(0,b.useCallback)(async(e,n)=>{let i=`batch-upload`;MY({id:i,title:`Batch Upload in Progress`,message:`Your batch data is being uploaded. This may take a moment...`,method:`show`,loading:!0});try{r({});let a=JSON.parse(e);a.type!==`batch`&&a.type!==`transaction`&&(a=HE(a));let o=await t.executeBatch(a);r(e=>({...e,[n]:o})),MY({id:i,title:`Batch Upload Successful`,message:`Your batch data was successfully uploaded.`,color:`green`,method:`update`,icon:(0,L.jsx)(CA,{size:`1rem`}),withCloseButton:!0})}catch(e){MY({id:i,title:`Batch Upload Failed`,color:`red`,message:Zx(e),method:`update`,icon:(0,L.jsx)(Dj,{size:`1rem`}),withCloseButton:!0})}},[t]),a=(0,b.useCallback)(async e=>{for(let t of e){let e=new FileReader;e.onload=e=>i(e.target?.result,t.name),e.readAsText(t)}},[i]),o=(0,b.useCallback)(async e=>{await i(e.input,`JSON Data`)},[i]);return(0,L.jsxs)(nP,{children:[(0,L.jsx)(J,{children:`Batch Create`}),(0,L.jsxs)(U,{children:[`Use this page to create, read, or update multiple resources. For more details, see`,` `,(0,L.jsx)(Nd,{href:`https://www.hl7.org/fhir/http.html#transaction`,children:`FHIR Batch and Transaction`}),`.`]}),Object.keys(n).length===0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`h3`,{children:`Input`}),(0,L.jsxs)(_b,{defaultValue:`upload`,children:[(0,L.jsxs)(_b.List,{children:[(0,L.jsx)(_b.Tab,{value:`upload`,children:`File Upload`}),(0,L.jsx)(_b.Tab,{value:`json`,children:`JSON`})]}),(0,L.jsx)(_b.Panel,{value:`upload`,pt:`xs`,children:(0,L.jsx)(AY,{onDrop:a,accept:[`application/json`],children:(0,L.jsxs)(H,{justify:`center`,gap:`xl`,style:{minHeight:220,pointerEvents:`none`},children:[(0,L.jsx)(AY.Accept,{children:(0,L.jsx)(wj,{size:50,stroke:1.5,color:e.colors[e.primaryColor][5]})}),(0,L.jsx)(AY.Reject,{children:(0,L.jsx)(Dj,{size:50,stroke:1.5,color:e.colors.red[5]})}),(0,L.jsx)(AY.Idle,{children:(0,L.jsx)(wj,{size:50,stroke:1.5})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(U,{size:`xl`,inline:!0,children:`Drag files here or click to select files`}),(0,L.jsx)(U,{size:`sm`,color:`dimmed`,inline:!0,mt:7,children:`Attach as many files as you like`})]})]})})}),(0,L.jsx)(_b.Panel,{value:`json`,pt:`xs`,children:(0,L.jsxs)(sN,{onSubmit:o,children:[(0,L.jsx)(ch,{"data-testid":`batch-input`,name:`input`,autosize:!0,minRows:20,defaultValue:jY,deserialize:JSON.parse}),(0,L.jsx)(H,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,children:(0,L.jsx)(W,{type:`submit`,children:`Submit`})})]})})]})]}),Object.keys(n).length>0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`h3`,{children:`Output`}),(0,L.jsxs)(_b,{defaultValue:Object.keys(n)[0],children:[(0,L.jsx)(_b.List,{children:Object.keys(n).map(e=>(0,L.jsx)(_b.Tab,{value:e,children:e},e))}),Object.keys(n).map(e=>(0,L.jsx)(_b.Panel,{value:e,children:(0,L.jsx)(`pre`,{style:{border:`1px solid #888`},children:JSON.stringify(n[e],void 0,2)})},e))]}),(0,L.jsx)(H,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,children:(0,L.jsx)(W,{onClick:()=>r({}),children:`Start over`})})]})]})}function PY(){let{resourceType:e}=sW(),t=(Object.fromEntries(new URLSearchParams(location.search).entries()).ids||``).split(`,`).filter(e=>!!e),[n]=qk(`Questionnaire`,`subject-type=${e}`);return n?n.length===0?(0,L.jsxs)(nP,{children:[(0,L.jsxs)(J,{children:[`No apps for `,e]}),(0,L.jsx)(Rj,{to:`/${e}`,children:`Return to search page`})]}):(0,L.jsx)(nP,{children:(0,L.jsx)(`div`,{children:n.map(n=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{children:(0,L.jsx)(Rj,{to:`/forms/${n.id}?subject=`+t.map(t=>`${e}/${t}`).join(`,`),children:n.name})}),(0,L.jsx)(`p`,{children:n.description})]},n.id))})}):(0,L.jsx)(Aj,{})}function FY(){return(0,L.jsx)(cP,{})}var IY=[`Form`,`JSON`,`Profiles`];function LY(){let{resourceType:e}=sW();return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(vl,{children:[(0,L.jsxs)(U,{p:`md`,fw:500,children:[`New\xA0`,e]}),(0,L.jsx)(ll,{children:(0,L.jsx)(iz,{baseUrl:`/${e}/new`,tabs:IY})})]}),(0,L.jsx)(UW,{})]})}function RY(){return(0,L.jsx)(nP,{children:(0,L.jsxs)(K,{children:[(0,L.jsx)(J,{order:1,children:`Unexpected Error`}),(0,L.jsx)(U,{children:`We're sorry, something went wrong.`}),(0,L.jsxs)(U,{children:[`Please contact `,(0,L.jsx)(Nd,{href:`mailto:support@medplum.com`,children:`support`}),` for assistance.`]})]})})}function zY(e){let t=ek(e.resource);if(!t)return null;let n=[{key:`Type`,value:(0,L.jsx)(Rj,{to:`/${t.resourceType}`,children:t.resourceType})}];function r(e,t){e&&t&&n.push({key:e,value:t})}function i(e){e&&r(e.system,e.value)}function a(e,t){Array.isArray(t)?t.forEach(t=>a(e,t)):typeof t==`string`?r(e,t):t&&(Array.isArray(t.coding)?r(e,t.coding.map(e=>e.display||e.code).join(`, `)):r(e,t.text))}if(`name`in t){let e=lC(t);e!==aC(t)&&r(`Name`,e)}return`category`in t&&a(`Category`,t.category),t.resourceType!==`Bot`&&`code`in t&&a(`Code`,t.code),`identifier`in t&&(Array.isArray(t.identifier)?t.identifier.forEach(i):i(t.identifier)),n.length===1&&n.push({key:`ID`,value:t.id}),(0,L.jsx)(nz,{children:n.map((e,t)=>(0,L.jsxs)(nz.Entry,{children:[(0,L.jsx)(nz.Key,{children:e.key}),(0,L.jsx)(nz.Value,{children:e.value})]},`${e.key}-${t}`))})}function BY(){let{id:e}=sW(),t=eW(),n=Object.fromEntries(new URLSearchParams(t.search).entries()).subject,r=Q(),[i,a]=(0,b.useState)(!0),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)(),[f,p]=(0,b.useState)(),[m,h]=(0,b.useState)();if((0,b.useEffect)(()=>{let t={resourceType:`Bundle`,type:`batch`,entry:[{request:{method:`GET`,url:`Questionnaire/${e}`}}]};if(n){let e=n.split(`,`).filter(e=>!!e);e.length===1&&t.entry.push({request:{method:`GET`,url:e[0]}}),l(e)}r.executeBatch(t).then(e=>{e.entry?.[0]?.response?.status===`200`?(s(e.entry[0]?.resource),d(e.entry[1]?.resource)):p(e.entry?.[0]?.response?.outcome),a(!1)}).catch(e=>{p(e),a(!1)})},[r,e,n]),f)return(0,L.jsx)(nP,{children:(0,L.jsx)(`pre`,{"data-testid":`error`,children:JSON.stringify(f,void 0,2)})});if(m)return(0,L.jsxs)(nP,{children:[(0,L.jsx)(J,{children:o?.title}),(0,L.jsx)(`p`,{children:`Your response has been recorded.`}),(0,L.jsxs)(`ul`,{children:[m.length===1&&(0,L.jsx)(`li`,{children:(0,L.jsx)(Rj,{to:m[0],children:`Review your answers`})}),m.length>1&&(0,L.jsxs)(`li`,{children:[`Review your answers:`,(0,L.jsx)(`ul`,{children:m.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(Rj,{to:e,children:aC(e)})},e.id))})]}),u&&(0,L.jsx)(`li`,{children:(0,L.jsxs)(Rj,{to:u,children:[`Back to\xA0`,lC(u)]})}),(0,L.jsx)(`li`,{children:(0,L.jsx)(Rj,{to:`/`,children:`Go back home`})})]})]});if(i||!o)return(0,L.jsx)(Aj,{});let g=u&&dK(u);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(vl,{shadow:`xs`,radius:0,children:[g&&(0,L.jsx)(Tz,{patient:g}),u&&u.resourceType!==`Patient`&&(0,L.jsx)(zY,{resource:u}),(0,L.jsx)(B,{px:`xl`,py:`md`,children:(0,L.jsxs)(U,{children:[lC(o),c&&c.length>1&&(0,L.jsxs)(L.Fragment,{children:[`\xA0(for `,c.length,` resources)`]})]})})]}),(0,L.jsx)(nP,{children:(0,L.jsx)(GI,{questionnaire:o,subject:u&&iC(u),onSubmit:_})})]});async function _(e){let t=[];if(!c||c.length===0)t.push(await r.createResource(e));else for(let n of c)t.push(await r.createResource({...e,subject:{reference:n}}));h(t)}}var VY={paper:`_paper_unw9o_1`},HY={Bot:`/admin/bots/new`,ClientApplication:`/admin/clients/new`};function UY(e,t){let n=e.resourceType||WY(t),r=e.fields??GY(n),i=e.filters??(e.resourceType?void 0:KY(n)),a=e.sortRules??qY(n),o=e.offset??0,s=e.count??20;return{...e,resourceType:n,fields:r,filters:i,sortRules:a,offset:o,count:s}}function WY(e){return localStorage.getItem(`defaultResourceType`)??e?.option?.find(e=>e.id===`defaultResourceType`)?.valueString??`Patient`}function GY(e){let t=JY(e);if(t?.fields)return t.fields;let n=[`id`,`_lastUpdated`];switch(e){case`Patient`:n.push(`name`,`birthDate`,`gender`);break;case`AsyncJob`:n.push(`status`,`dataVersion`);break;case`AccessPolicy`:case`Bot`:case`ClientApplication`:case`Practitioner`:case`Project`:case`Organization`:case`Questionnaire`:case`UserConfiguration`:n.push(`name`);break;case`CodeSystem`:case`ValueSet`:n.push(`name`,`title`,`status`);break;case`Condition`:n.push(`subject`,`code`,`clinicalStatus`);break;case`Device`:n.push(`manufacturer`,`deviceName`,`patient`);break;case`DeviceDefinition`:n.push(`manufacturer[x]`,`deviceName`);break;case`DeviceRequest`:n.push(`code[x]`,`subject`);break;case`DiagnosticReport`:case`Observation`:n.push(`subject`,`code`,`status`);break;case`Encounter`:n.push(`subject`);break;case`ServiceRequest`:n.push(`subject`,`code`,`status`,`orderDetail`);break;case`Subscription`:n.push(`criteria`);break;case`User`:n.push(`email`);break}return n}function KY(e){return JY(e)?.filters}function qY(e){let t=JY(e);return t?.sortRules?t.sortRules:[{code:`_lastUpdated`,descending:!0}]}function JY(e){let t=localStorage.getItem(e+`-defaultSearch`);return t?JSON.parse(t):void 0}function YY(e){localStorage.setItem(`defaultResourceType`,e.resourceType),localStorage.setItem(e.resourceType+`-defaultSearch`,JSON.stringify(e))}async function XY(e,t){let n=UY({...e,count:1e3,offset:0},t.getUserConfiguration());return HE(await t.search(n.resourceType,oE({...n,total:`accurate`,fields:void 0})))}function ZY(){let e=Q(),t=rW(),n=eW(),[r,i]=(0,b.useState)();return(0,b.useEffect)(()=>{let r=UY(YT(n.pathname+n.search),e.getUserConfiguration());n.pathname===`/${r.resourceType}`&&n.search===oE(r)?(YY(r),i(r)):t(`/${r.resourceType}${oE(r)}`,{replace:!0})?.catch(console.error)},[e,t,n]),!r?.resourceType||!r.fields||r.fields.length===0?(0,L.jsx)(Aj,{}):(0,L.jsx)(vl,{shadow:`xs`,m:`md`,p:`xs`,className:VY.paper,children:(0,L.jsx)(KR,{checkboxesEnabled:!0,search:r,onClick:e=>t(`/${e.resource.resourceType}/${e.resource.id}`)?.catch(console.error),onAuxClick:e=>window.open(`/${e.resource.resourceType}/${e.resource.id}`,`_blank`),onChange:e=>{t(`/${r.resourceType}${oE(e.definition)}`)?.catch(console.error)},onNew:()=>{t(HY[r.resourceType]??`/${r.resourceType}/new`)?.catch(console.error)},onExportCsv:()=>{let t=e.fhirUrl(r.resourceType,`$csv`)+oE(r);e.download(t).then(e=>{window.open(window.URL.createObjectURL(e),`_blank`)}).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1}))},onExportTransactionBundle:async()=>{XY(r,e).then(e=>Lj(JSON.stringify(e,void 0,2))).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1}))},onDelete:t=>{window.confirm(`Are you sure you want to delete these resources?`)&&(e.invalidateSearches(r.resourceType),e.executeBatch({resourceType:`Bundle`,type:`batch`,entry:t.map(e=>({request:{method:`DELETE`,url:`${r.resourceType}/${e}`}}))}).then(()=>i({...r})).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1})))},onBulk:e=>{t(`/bulk/${r.resourceType}?ids=${e.join(`,`)}`)?.catch(console.error)}})})}function QY(){let[e]=qk(`ObservationDefinition`,`_count=100`);return e?(0,L.jsxs)(q,{withTableBorder:!0,withRowBorders:!0,withColumnBorders:!0,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{children:`Category`}),(0,L.jsx)(`th`,{children:`Code`}),(0,L.jsx)(`th`,{children:`Method`}),(0,L.jsx)(`th`,{children:`Unit`}),(0,L.jsx)(`th`,{children:`Precision`}),(0,L.jsx)(`th`,{children:`Ranges`})]})}),(0,L.jsx)(`tbody`,{children:e.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{children:(0,L.jsx)(VP,{value:e.category?.[0]})}),(0,L.jsx)(`td`,{children:(0,L.jsx)(VP,{value:e.code})}),(0,L.jsx)(`td`,{children:(0,L.jsx)(VP,{value:e.method})}),(0,L.jsx)(`td`,{children:e.quantitativeDetails?.unit?.text}),(0,L.jsx)(`td`,{children:e.quantitativeDetails?.decimalPrecision}),(0,L.jsx)(`td`,{children:(0,L.jsx)($Y,{ranges:e.qualifiedInterval})})]},e.id))})]}):(0,L.jsx)(Aj,{})}function $Y(e){let{ranges:t}=e;if(!t)return null;let n=eX(t.map(e=>e.gender));if(n.length>1)return YC(n),(0,L.jsx)(L.Fragment,{children:n.map(t=>(0,L.jsxs)(b.Fragment,{children:[(0,L.jsx)(`div`,{children:(0,L.jsx)(`strong`,{children:VC(t)})}),(0,L.jsx)($Y,{ranges:e.ranges?.filter(e=>e.gender===t)})]},t))});let r=eX(t.map(e=>e.age&&_w(e.age)));return r.length>1?(YC(r),(0,L.jsx)(L.Fragment,{children:r.map(t=>(0,L.jsxs)(b.Fragment,{children:[(0,L.jsx)(`div`,{children:(0,L.jsx)(`strong`,{children:VC(t)})}),(0,L.jsx)($Y,{ranges:e.ranges?.filter(e=>_w(e.age)===t)})]},t))})):(0,L.jsx)(L.Fragment,{children:t.map(e=>(0,L.jsx)(`table`,{children:(0,L.jsx)(`tbody`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{children:e.condition}),(0,L.jsx)(`td`,{children:(0,L.jsx)(ZP,{value:e.range})})]})})},`range-${e.condition}`))})}function eX(e){return[...new Set(e.filter(e=>!!e))]}function tX(){let[e]=qk(`ActivityDefinition`,`_count=100`),[t]=qk(`ObservationDefinition`,`_count=100`);return!e||!t?(0,L.jsx)(Aj,{}):(0,L.jsxs)(q,{withTableBorder:!0,withRowBorders:!0,withColumnBorders:!0,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{children:`Category`}),(0,L.jsx)(`th`,{children:`Assay`}),e.map(e=>(0,L.jsx)(`th`,{children:e.name},e.id))]})}),(0,L.jsx)(`tbody`,{children:t.map(t=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{children:(0,L.jsx)(VP,{value:t.category?.[0]})}),(0,L.jsx)(`td`,{children:(0,L.jsx)(VP,{value:t.code})}),e.map(e=>(0,L.jsx)(`td`,{children:e.observationResultRequirement?.find(e=>e.reference?.includes(t.id))?`✅`:``},e.id))]},t.id))})]})}function nX(){let e=Q(),[t,n]=(0,b.useState)(),[r,i]=(0,b.useState)(void 0),[a,o]=(0,b.useState)(!1),s=(0,b.useCallback)(()=>{e.get(`auth/mfa/status`,{cache:`no-cache`}).then(e=>{n(e.enrollQrCode),i(e.enrolled)}).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1}))},[e]);(0,b.useEffect)(()=>{s()},[s]);let c=(0,b.useCallback)(t=>{e.post(`auth/mfa/enroll`,t).then(()=>{i(!0),Y({color:`green`,message:`Success`})}).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1}))},[e]),l=(0,b.useCallback)(async t=>e.post(`auth/mfa/disable`,{token:t.token}),[e]);return r===void 0?null:r?(0,L.jsxs)(nP,{children:[(0,L.jsx)(ng,{title:`Disable MFA`,opened:a,onClose:()=>o(!1),children:(0,L.jsx)(lP,{title:`Disable MFA`,buttonText:`Submit code`,onSubmit:async e=>{await l(e),o(!1),i(!1),Y({id:`mfa-disabled`,color:`green`,title:`Success`,message:`MFA disabled`,icon:(0,L.jsx)(EA,{})}),s()}})}),(0,L.jsxs)(H,{children:[(0,L.jsx)(J,{children:`MFA is enabled`}),(0,L.jsx)(W,{onClick:()=>o(!0),children:`Disable MFA`})]})]}):(0,L.jsx)(nP,{width:400,children:(0,L.jsx)(lP,{title:`Multi Factor Auth Setup`,buttonText:`Enroll`,qrCodeUrl:t,onSubmit:c})})}var rX={baseUrl:`__MEDPLUM_BASE_URL__`,clientId:`__MEDPLUM_CLIENT_ID__`,googleClientId:`__GOOGLE_CLIENT_ID__`,recaptchaSiteKey:`__RECAPTCHA_SITE_KEY__`,registerEnabled:`__MEDPLUM_REGISTER_ENABLED__`,awsTextractEnabled:void 0};function iX(){return rX}function aX(){return sX(`registerEnabled`)}function oX(){return sX(`awsTextractEnabled`)}function sX(e){try{return rX[e]!==!1&&rX[e]!==`false`}catch{return!0}}function cX(){let e=rW(),[t]=qG(),n=Q(),r=t.get(`scope`)||`openid`,[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)(!0),c=t.get(`client_id`),l=t.get(`login`);if((0,b.useEffect)(()=>{if(!c||c===`medplum-cli`)return;async function e(){try{a(await n.get(`/auth/clientinfo/${c}`))}catch(e){Y({id:`clientinfofail`,title:`Failed to retrieve client information.`,color:`red`,message:Zx(e),withCloseButton:!0})}finally{s(!1)}}e().catch(console.error)},[n,c]),!c)return null;function u(e){let n=new URL(t.get(`redirect_uri`));for(let e of[`scope`,`state`,`nonce`])t.has(e)&&n.searchParams.set(e,t.get(e));n.searchParams.set(`code`,e),FE.assign(n.toString())}return(0,L.jsx)(BP,{onCode:u,onForgotPassword:()=>e(`/resetpassword`)?.catch(console.error),onRegister:()=>e(`/register`)?.catch(console.error),googleClientId:iX().googleClientId,clientId:c||void 0,redirectUri:t.get(`redirect_uri`)||void 0,scope:r,nonce:t.get(`nonce`)||void 0,launch:t.get(`launch`)||void 0,codeChallenge:t.get(`code_challenge`)||void 0,codeChallengeMethod:t.get(`code_challenge_method`)||void 0,chooseScopes:r!==`openid`,login:l||void 0,children:!o&&(0,L.jsxs)(L.Fragment,{children:[i?.logo?.url?(0,L.jsx)(`img`,{src:i?.logo?.url,alt:`Welcome Logo`,height:60,style:{width:`auto`}}):(0,L.jsx)(rP,{size:32}),(0,L.jsx)(J,{children:i?.welcomeString??`Sign in to Medplum`})]})})}function lX(){let e=Q(),t=rW(),[n]=qG(),r=iX();return(0,b.useEffect)(()=>{e.getProfile()&&t(`/signin?project=new`)?.catch(console.error)},[e,t]),aX()?(0,L.jsxs)(vP,{type:`project`,projectId:`new`,onSuccess:()=>{window.location.href=`/`},googleClientId:r.googleClientId,recaptchaSiteKey:r.recaptchaSiteKey,login:n.get(`login`)||void 0,children:[(0,L.jsx)(rP,{size:32}),(0,L.jsx)(J,{order:3,py:`lg`,children:`Register a new account`})]}):(0,L.jsx)(nP,{width:450,children:(0,L.jsx)(Ed,{icon:(0,L.jsx)(lA,{size:16}),title:`New projects disabled`,color:`red`,children:`New projects are disabled on this server.`})})}function uX(){let e=rW(),[t]=qG(),n=iX();return(0,L.jsx)(yP,{projectId:t.get(`project`)||void 0,recaptchaSiteKey:n.recaptchaSiteKey,onSignIn:()=>e(`/signin`)?.catch(console.error),onRegister:aX()?()=>e(`/register`)?.catch(console.error):void 0})}function dX(){let{resourceType:e,id:t}=sW(),n=ek({reference:e+`/`+t}),r=rW(),i=(0,b.useCallback)(()=>{r(0)?.catch(console.error)},[r]);return n?(0,L.jsx)(nP,{maw:700,children:n.resourceType===`Patient`?(0,L.jsx)(_z,{patient:n,onSaved:i}):(0,L.jsx)(Ed,{icon:(0,L.jsx)(lA,{size:16}),title:`Unsupported resource type`,color:`red`,children:`Account management is only supported for Patient resources`})}):null}function fX(e){let t=Q(),[n,r]=(0,b.useState)(),[i,a]=(0,b.useState)();return i?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{children:`Request group created successfully.`}),(0,L.jsxs)(`ul`,{children:[(0,L.jsxs)(`li`,{children:[`Go to the`,` `,(0,L.jsx)(Rj,{to:i,suffix:`checklist`,children:`Request Group`})]}),(0,L.jsxs)(`li`,{children:[`Back to the `,(0,L.jsx)(Rj,{to:e.planDefinition,children:`Plan Definition`})]})]})]}):(0,L.jsx)(sN,{onSubmit:()=>{t.post(t.fhirUrl(`PlanDefinition`,e.planDefinition.id,`$apply`),{resourceType:`Parameters`,parameter:[{name:`subject`,valueString:n?.reference}]}).then(a).catch(console.log)},children:(0,L.jsxs)(K,{children:[(0,L.jsxs)(J,{children:[`Start "`,e.planDefinition.title,`"`]}),(0,L.jsxs)(U,{children:[`Use the `,(0,L.jsx)(`strong`,{children:`Apply`}),` operation to create a group of tasks for a workflow.`]}),(0,L.jsx)(U,{children:`The following tasks will be created:`}),(0,L.jsx)(`ul`,{children:e.planDefinition.action?.map((e,t)=>(0,L.jsxs)(`li`,{children:[e.definitionCanonical?.startsWith(`Questionnaire/`)&&`Questionnaire request: `,e.title&&(0,L.jsx)(L.Fragment,{children:e.title}),e.code&&(0,L.jsx)(VP,{value:e.code[0]})]},`action-${t}`))}),(0,L.jsx)(hF,{title:`Subject`,children:(0,L.jsx)(qF,{name:`subject`,targetTypes:[`Patient`,`Practitioner`],defaultValue:n,onChange:r})}),(0,L.jsx)(H,{justify:`flex-end`,mt:`xl`,children:(0,L.jsx)(W,{type:`submit`,children:`Go`})})]})})}function pX(){let{resourceType:e,id:t}=sW(),n=ek({reference:e+`/`+t});return n?(0,L.jsx)(nP,{children:(0,L.jsx)(fX,{planDefinition:n})}):null}function mX(){let{resourceType:e,id:t}=sW(),n=ek({reference:e+`/`+t}),[r,i]=qk(`Questionnaire`,`subject-type=`+e),[a,o]=qk(`ClientApplication`,{_count:1e3});if(!n||i||o)return(0,L.jsx)(Aj,{});let s=a?.filter(t=>hX(e)&&!!t.launchUri);if((!r||r.length===0)&&(!s||s.length===0))return(0,L.jsxs)(nP,{children:[(0,L.jsx)(J,{children:`Apps`}),(0,L.jsxs)(`p`,{children:[`No apps found. Contact your administrator or `,(0,L.jsx)(`a`,{href:`mailto:support@medplum.com`,children:`Medplum Support`}),` to add automation here.`]})]});let c,l;return n.resourceType===`Patient`?c=iC(n):n.resourceType===`Encounter`&&(c=n.subject,l=iC(n)),(0,L.jsxs)(nP,{children:[r?.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(J,{order:3,children:(0,L.jsx)(Rj,{to:`/forms/${e.id}?subject=${aC(n)}`,children:e.title||e.name})}),(0,L.jsx)(U,{children:e.description})]},e.id)),s?.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(J,{order:3,children:(0,L.jsx)(oK,{client:e,patient:c,encounter:l,children:e.name})}),(0,L.jsx)(U,{children:e.description})]},e.id))]})}function hX(e){return e===`Patient`||e===`Encounter`}function gX(){let{resourceType:e,id:t}=sW(),n=rW(),[r,i]=(0,b.useState)({resourceType:`AuditEvent`,filters:[{code:`entity`,operator:Z.EQUALS,value:`${e}/${t}`}],fields:[`id`,`outcome`,`outcomeDesc`,`_lastUpdated`],sortRules:[{code:`-_lastUpdated`}],count:20});return(0,L.jsx)(nP,{children:(0,L.jsx)(KR,{search:r,onClick:e=>n(`/${e.resource.resourceType}/${e.resource.id}`)?.catch(console.error),onChange:e=>i(e.definition),hideFilters:!0})})}function _X(){let e=Q(),{resourceType:t,id:n}=sW();return(0,L.jsx)(im,{maw:1200,children:(0,L.jsx)(tP,{children:(0,L.jsx)(SB,{history:e.readHistory(t,n).read()})})})}var vX={hl7Input:`_hl7Input_k5xm3_1`};function yX(e){return(0,L.jsx)(`iframe`,{title:`Bot Runner`,frameBorder:`0`,src:`https://codeeditor.medplum.com/bot-runner.html`,className:e.className,ref:e.iframeRef,"data-testid":e.testId,style:{width:`100%`,height:`100%`,minHeight:e.minHeight}})}function bX(e){let t=e.defaultValue,n=new URL(`https://codeeditor.medplum.com/${e.language}-editor.html`);return e.module&&n.searchParams.set(`module`,e.module),(0,L.jsx)(`iframe`,{title:`Code Editor`,frameBorder:`0`,src:n.toString(),style:{width:`100%`,height:`100%`,minHeight:e.minHeight},ref:e.iframeRef,"data-testid":e.testId,onLoad:e=>{Ij(e.currentTarget,{command:`setValue`,value:t}).catch(console.error)}})}var xX=`{
227
227
  "resourceType": "Patient",
228
228
  "name": [
229
229
  {
@@ -234,4 +234,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
234
234
  }
235
235
  ]
236
236
  }`,SX=`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 CX(){let e=Q(),{id:t}=sW(),[n,r]=(0,b.useState)(),[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(xX),[u,d]=(0,b.useState)(SX),[f,p]=(0,b.useState)(YE.FHIR_JSON),m=(0,b.useRef)(null),h=(0,b.useRef)(null),[g,_]=(0,b.useState)(!1);(0,b.useEffect)(()=>{e.readResource(`Bot`,t).then(async t=>{r(t),a(t.runtimeVersion===`vmcontext`?`commonjs`:`esnext`),s(await wX(e,t))}).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1}))},[e,t]);let v=(0,b.useCallback)(async()=>Ij(m.current,{command:`getValue`}),[]),y=(0,b.useCallback)(async()=>Ij(m.current,{command:`getOutput`}),[]),x=(0,b.useCallback)(async()=>f===YE.FHIR_JSON?JSON.parse(c):u,[f,c,u]),S=(0,b.useCallback)(async n=>{n.preventDefault(),n.stopPropagation(),_(!0);try{let n=await v(),r=await y(),a=await e.createAttachment({data:n,filename:`index.ts`,contentType:YE.TYPESCRIPT}),o=await e.createAttachment({data:r,filename:i===`commonjs`?`index.cjs`:`index.mjs`,contentType:YE.JAVASCRIPT}),s=[{op:`add`,path:`/sourceCode`,value:a},{op:`add`,path:`/executableCode`,value:o}];await e.patchResource(`Bot`,t,s),Y({color:`green`,message:`Saved`})}catch(e){Y({color:`red`,message:Zx(e),autoClose:!1})}finally{_(!1)}},[e,t,i,v,y]),C=(0,b.useCallback)(async n=>{n.preventDefault(),n.stopPropagation(),_(!0);try{await e.post(e.fhirUrl(`Bot`,t,`$deploy`)),Y({color:`green`,message:`Deployed`})}catch(e){Y({color:`red`,message:Zx(e),autoClose:!1})}finally{_(!1)}},[e,t]),w=(0,b.useCallback)(async n=>{n.preventDefault(),n.stopPropagation(),_(!0);try{let n=await x(),r=await e.post(e.fhirUrl(`Bot`,t,`$execute`),n,f);await Ij(h.current,{command:`setValue`,value:r}),Y({color:`green`,message:`Success`})}catch(e){Y({color:`red`,message:Zx(e),autoClose:!1})}finally{_(!1)}},[e,t,x,f]);return!n||o===void 0?null:(0,L.jsxs)(wm,{m:0,gutter:0,style:{overflow:`hidden`},children:[(0,L.jsx)(wm.Col,{span:8,children:(0,L.jsxs)(vl,{m:2,pb:`xs`,pr:`xs`,pt:`xs`,shadow:`md`,mih:400,children:[(0,L.jsx)(bX,{iframeRef:m,language:`typescript`,module:i,testId:`code-frame`,defaultValue:o,minHeight:`528px`}),(0,L.jsxs)(H,{justify:`flex-end`,gap:`xs`,children:[(0,L.jsx)(W,{type:`button`,onClick:S,loading:g,leftSection:(0,L.jsx)(PA,{size:`1rem`}),children:`Save`}),(0,L.jsx)(W,{type:`button`,onClick:C,loading:g,leftSection:(0,L.jsx)(kA,{size:`1rem`}),children:`Deploy`}),(0,L.jsx)(W,{type:`button`,onClick:w,loading:g,leftSection:(0,L.jsx)(sj,{size:`1rem`}),children:`Execute`})]})]})}),(0,L.jsxs)(wm.Col,{span:4,children:[(0,L.jsxs)(vl,{m:2,pb:`xs`,pr:`xs`,pt:`xs`,shadow:`md`,children:[(0,L.jsx)(Tg,{data:[{label:`FHIR`,value:YE.FHIR_JSON},{label:`HL7`,value:YE.HL7_V2}],onChange:e=>p(e.currentTarget.value)}),f===YE.FHIR_JSON?(0,L.jsx)(ch,{value:c,onChange:e=>l(e),autosize:!0,minRows:15}):(0,L.jsx)(`textarea`,{className:vX.hl7Input,value:u,onChange:e=>d(e.currentTarget.value),rows:15})]}),(0,L.jsx)(vl,{m:2,p:`xs`,shadow:`md`,children:(0,L.jsx)(yX,{iframeRef:h,className:`medplum-bot-output-frame`,testId:`output-frame`,minHeight:`200px`})})]})]})}async function wX(e,t){if(t.sourceCode?.url){let n=t.sourceCode.url?.split(`/`)?.find(jC);return(await e.download(e.fhirUrl(`Binary`,n))).text()}return t.code??``}function TX(e){let t=e.meta;return t&&={...t,lastUpdated:void 0,versionId:void 0,author:void 0},{...e,meta:t}}function EX(){let e=Q(),{resourceType:t,id:n}=sW(),r={reference:t+`/`+n},i=(0,b.useCallback)(t=>{e.updateResource(TX(t)).then(()=>{Y({color:`green`,message:`Success`})}).catch(e=>{Y({color:`red`,message:Zx(e),autoClose:!1})})},[e]);switch(t){case`PlanDefinition`:return(0,L.jsx)(nP,{children:(0,L.jsx)(Oz,{value:r,onSubmit:i})});case`Questionnaire`:return(0,L.jsx)(nP,{children:(0,L.jsx)(zz,{questionnaire:r,onSubmit:i})});default:return null}}function DX(){let{resourceType:e,id:t}=sW(),n=ek({reference:e+`/`+t}),r=rW();return n?(0,L.jsx)(nP,{children:(0,L.jsx)(uB,{value:n,onStart:(e,t)=>r(`/forms/${oC(t)}`)?.catch(console.error),onEdit:(e,t,n)=>r(`/${n.reference}}`)?.catch(console.error)})}):null}function OX(){let e=Q(),{resourceType:t,id:n}=sW(),r=ek({reference:t+`/`+n}),i=(0,b.useRef)(0),[a,o]=(0,b.useState)([]);(0,b.useEffect)(()=>{r&&o((r.payload??rw).map(e=>({key:i.current++,item:e})))},[r]);let s=(0,b.useCallback)((e,t)=>{o(n=>n.map(n=>n.key===e?{...n,item:{...n.item,contentString:t}}:n))},[]),c=(0,b.useCallback)(()=>{o(e=>[...e,{key:i.current++,item:{contentString:``}}])},[]),l=(0,b.useCallback)(()=>{r&&e.updateResource(TX({...r,payload:a.map(e=>e.item)})).then(()=>Y({color:`green`,message:`Saved`})).catch(e=>Y({color:`red`,message:Zx(e)}))},[e,r,a]);return r?(0,L.jsx)(nP,{children:(0,L.jsxs)(K,{children:[a.filter(({item:e})=>`contentString`in e).map(({key:e,item:t})=>(0,L.jsx)(ah,{autosize:!0,minRows:3,maxRows:20,value:t.contentString??``,onChange:t=>s(e,t.currentTarget.value),placeholder:`Enter content...`},e)),(0,L.jsxs)(H,{justify:`flex-end`,children:[(0,L.jsx)(W,{variant:`outline`,onClick:c,children:`Add payload`}),(0,L.jsx)(W,{onClick:l,children:`Save`})]}),(0,L.jsx)(U,{size:`xs`,c:`dimmed`,children:`This tab manages string payloads only. Attachments and References can be managed in the Edit tab.`})]})}):null}function kX(){let e=Q(),{resourceType:t,id:n}=sW(),r=rW();return(0,L.jsxs)(nP,{children:[(0,L.jsxs)(`p`,{children:[`Are you sure you want to delete this `,t,`?`]}),(0,L.jsx)(W,{color:`red`,onClick:()=>{e.deleteResource(t,n).then(()=>r(`/${t}`)?.catch(console.error)).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1}))},children:`Delete`})]})}var AX={selectProfileBtn:`_selectProfileBtn_tbaz6_1`,chevron:`_chevron_tbaz6_13`};function jX(){let{resourceType:e,id:t}=sW(),n=ek({reference:e+`/`+t}),[r,i]=(0,b.useState)(),a=Ff({onDropdownClose:()=>a.resetSelectedOption()}),o=(0,b.useMemo)(()=>{if(SC(n?.meta?.profile))return[(0,L.jsx)(Rf.Option,{value:``,children:`None`},``),...n.meta.profile.map(e=>(0,L.jsx)(Rf.Option,{value:e,children:e},e))]},[n?.meta?.profile]);if((0,b.useEffect)(()=>{n?.meta?.profile?.length===1&&i(n.meta.profile[0])},[n?.meta?.profile]),!n)return null;let s;return SC(o)&&(s=(0,L.jsx)(H,{justify:`flex-end`,children:(0,L.jsxs)(K,{align:`flex-end`,gap:`xs`,children:[(0,L.jsxs)(Rf,{store:a,width:250,position:`bottom-end`,withinPortal:!1,onOptionSubmit:e=>{i(e),a.closeDropdown()},children:[(0,L.jsx)(Rf.Target,{children:(0,L.jsx)(pl,{onClick:()=>a.toggleDropdown(),children:(0,L.jsxs)(tm,{fw:`bold`,fs:`sm`,className:AX.selectProfileBtn,children:[(0,L.jsx)(`span`,{children:`Pick profile`}),(0,L.jsx)(TA,{stroke:1.5,className:AX.chevron})]})})}),(0,L.jsx)(Rf.Dropdown,{w:`max-content`,children:(0,L.jsx)(Rf.Options,{children:o})})]}),(0,L.jsx)(B,{children:r?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(U,{span:!0,size:`sm`,c:`dimmed`,children:`Displaying profile:\xA0`}),(0,L.jsx)(U,{span:!0,size:`sm`,children:r||`Nothing selected`})]}):(0,L.jsx)(U,{span:!0,size:`sm`,c:`dimmed`,children:`No profile displayed`})})]})})),(0,L.jsx)(nP,{children:(0,L.jsxs)(K,{gap:`xl`,children:[s,(0,L.jsx)(CL,{value:n,profileUrl:r})]})})}function MX(){let e=Q(),{resourceType:t,id:n}=sW(),[r,i]=(0,b.useState)(),[a,o]=(0,b.useState)(),s=rW(),[c,l]=(0,b.useState)();(0,b.useEffect)(()=>{e.readResource(t,n).then(e=>{i(AC(e)),o(AC(e))}).catch(e=>{l(Xx(e)),Y({color:`red`,message:Zx(e),autoClose:!1})})},[e,t,n]);let u=(0,b.useCallback)(r=>{l(void 0),e.updateResource(TX(r)).then(()=>{s(`/${t}/${n}/details`)?.catch(console.error),Y({id:`succes`,color:`green`,message:`Success`})}).catch(e=>{l(Xx(e)),Y({color:`red`,message:Zx(e),autoClose:!1})})},[e,t,n,s]),d=(0,b.useCallback)(i=>{l(void 0);let a=(0,gL.createPatch)(r,TX(i));e.patchResource(t,n,a).then(()=>{s(`/${t}/${n}/details`)?.catch(console.error),Y({id:`succes`,color:`green`,message:`Success`})}).catch(e=>{l(Xx(e)),Y({color:`red`,message:Zx(e),autoClose:!1})})},[e,t,n,r,s]),f=(0,b.useCallback)(()=>s(`/${t}/${n}/delete`)?.catch(console.error),[s,t,n]);return a?(0,L.jsx)(nP,{children:(0,L.jsx)(DB,{defaultValue:a,onSubmit:u,onPatch:d,onDelete:f,outcome:c})}):null}function NX(){let{resourceType:e,id:t}=sW(),n=ek({reference:e+`/`+t});return n?(0,L.jsx)(nP,{maw:700,children:n.resourceType===`Patient`?(0,L.jsx)(Sz,{patient:n}):(0,L.jsx)(Ed,{icon:(0,L.jsx)(lA,{size:16}),title:`Unsupported export type`,color:`red`,children:`This page is only supported for Patient resources`})}):null}function PX({resource:e,currentProfile:t,onChange:n}){let r=e.resourceType,i=Q(),[a,o]=(0,b.useState)();return(0,b.useEffect)(()=>{i.searchResources(`StructureDefinition`,{type:r,derivation:`constraint`,_count:50}).then(e=>{o(e.filter(_F))}).catch(console.error)},[i,n,r]),(0,L.jsx)(_b,{value:t?.url,onChange:e=>{let t=a?.find(t=>t.url===e);t&&n(t)},children:(0,L.jsx)(_b.List,{children:a?.map(t=>{let n=e.meta?.profile?.includes(t.url),r=n?`This profile is present in this resource's meta.profile property.`:`This profile is not included in this resource's meta.profile property.`;return(0,L.jsx)(_b.Tab,{value:t.url,title:r,rightSection:n&&(0,L.jsx)(xb,{variant:`outline`,color:`green`,size:`xs`,style:{borderStyle:`none`},children:(0,L.jsx)(Oj,{size:`90%`})}),children:t.title||t.name},t.url)})})})}function FX(e,t){let n=Q(),r=rW();return{defaultValue:{resourceType:e},handleSubmit:e=>{t&&t(void 0),n.createResource(e).then(e=>r(`/`+e.resourceType+`/`+e.id)).catch(e=>{t&&t(Xx(e)),Y({color:`red`,message:Zx(e),autoClose:!1,styles:{description:{whiteSpace:`pre-line`}}})})}}}function IX(){let{resourceType:e}=sW(),t=eW(),[n,r]=(0,b.useState)(),{defaultValue:i,handleSubmit:a}=FX(e,r),[o,s]=(0,b.useState)(),c=t.pathname.toLowerCase().endsWith(`profiles`),l=(0,b.useCallback)(e=>{let t=TX(e);o&&tw(t,o.url),a(t)},[o,a]);return c?(0,L.jsx)(nP,{children:(0,L.jsxs)(K,{children:[(0,L.jsx)(PX,{resource:i,currentProfile:o,onChange:s}),o?(0,L.jsx)(DB,{defaultValue:i,onSubmit:l,outcome:n,profileUrl:o.url},o.url):(0,L.jsx)(U,{my:`lg`,fz:`lg`,fs:`italic`,ta:`center`,children:`Select a profile above`})]})}):(0,L.jsx)(nP,{children:(0,L.jsx)(DB,{defaultValue:i,onSubmit:a,outcome:n})})}function LX(){let e=Q(),{resourceType:t,id:n}=sW();return(0,L.jsx)(nP,{children:(0,L.jsx)(OB,{history:e.readHistory(t,n).read()})})}function RX(){let{resourceType:e}=sW(),[t,n]=(0,b.useState)(),{defaultValue:r,handleSubmit:i}=FX(e,n),a=(0,b.useCallback)(e=>{i(JSON.parse(e[`new-resource`]))},[i]);return(0,L.jsxs)(nP,{children:[t&&(0,L.jsx)(uP,{outcome:t}),(0,L.jsxs)(sN,{onSubmit:a,children:[(0,L.jsx)(ch,{name:`new-resource`,"data-testid":`create-resource-json`,autosize:!0,minRows:24,defaultValue:_C(r,!0),formatOnBlur:!0,deserialize:JSON.parse}),(0,L.jsx)(H,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,children:(0,L.jsx)(W,{type:`submit`,children:`OK`})})]})]})}function zX(){let e=Q(),{resourceType:t,id:n}=sW(),r=ek({reference:t+`/`+n}),i=rW(),[a,o]=(0,b.useState)(),s=(0,b.useCallback)(r=>{e.updateResource(TX(JSON.parse(r.resource))).then(()=>{o(void 0),i(`/${t}/${n}/details`)?.catch(console.error),Y({color:`green`,message:`Success`})}).catch(e=>{Y({color:`red`,message:Zx(e),autoClose:!1})})},[e,t,n,i]);return r?(0,L.jsxs)(nP,{children:[a&&(0,L.jsx)(uP,{outcome:a}),(0,L.jsxs)(sN,{onSubmit:s,children:[(0,L.jsx)(ch,{name:`resource`,"data-testid":`resource-json`,autosize:!0,minRows:24,defaultValue:_C(r,!0),formatOnBlur:!0,deserialize:JSON.parse}),(0,L.jsx)(H,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,children:(0,L.jsx)(W,{type:`submit`,children:`OK`})})]})]}):null}function BX(e){let{resourceType:t,id:n}=e;return(0,L.jsxs)(nP,{children:[(0,L.jsxs)(Ed,{icon:(0,L.jsx)(lA,{size:16}),mb:`xl`,children:[`This is just a preview! Access your form here:`,(0,L.jsx)(`br`,{}),(0,L.jsx)(Nd,{href:`/forms/${n}`,children:`/forms/${n}`})]}),(0,L.jsx)(GI,{questionnaire:{reference:t+`/`+n},onSubmit:()=>alert(`You submitted the preview`)})]})}var VX={propertyTable:`_propertyTable_1xts4_1`,propertiesTitle:`_propertiesTitle_1xts4_17`};function HX(e){return e.valueCode||e.valueString||(e.valueBoolean===void 0?void 0:String(e.valueBoolean))||(e.valueInteger===void 0?void 0:String(e.valueInteger))||(e.valueDecimal===void 0?void 0:String(e.valueDecimal))||e.valueDate||e.valueDateTime||`N/A`}function UX(e){let{properties:t}=e,n=t.map(e=>{let t=``,n=``,r=``;return e.part?.forEach(e=>{e.name===`code`?t=e.valueCode||``:e.name===`description`?n=e.valueString||``:e.name===`value`&&(r=HX(e))}),{code:t,description:n,value:r}});return(0,L.jsxs)(q,{className:VX.propertyTable,children:[(0,L.jsx)(q.Thead,{children:(0,L.jsxs)(q.Tr,{children:[(0,L.jsx)(q.Th,{children:`Code`}),(0,L.jsx)(q.Th,{children:`Description`}),(0,L.jsx)(q.Th,{children:`Value`})]})}),(0,L.jsx)(q.Tbody,{children:n.map((e,t)=>(0,L.jsxs)(q.Tr,{children:[(0,L.jsx)(q.Td,{children:e.code}),(0,L.jsx)(q.Td,{children:e.description}),(0,L.jsx)(q.Td,{children:e.value})]},`property-${t}`))})]})}function WX(e){let{valueSet:t}=e,n=Q(),r=t.url,[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(),f=(0,b.useCallback)(async e=>{if(a(e),s(void 0),d(void 0),!e?.code||!e?.system){l(!1);return}l(!0);try{let t=new URLSearchParams({system:e.system,code:e.code}),r=n.fhirUrl(`CodeSystem`,`$lookup`)+`?`+t.toString();s(await n.get(r))}catch(e){d(e instanceof Error?e:Error(String(e)))}finally{l(!1)}},[n]),p=(0,b.useMemo)(()=>o?.parameter?.filter(e=>e.name===`property`&&e.part)??[],[o]),m=p.length>0;return(0,L.jsx)(nP,{children:(0,L.jsxs)(K,{gap:`xl`,children:[(0,L.jsx)(hN,{binding:r,placeholder:`Select a value from the ValueSet`,onChange:e=>f(e[0]),defaultValue:i,maxValues:1}),i?(0,L.jsxs)(K,{gap:`md`,children:[(0,L.jsxs)(KN,{children:[(0,L.jsx)(qN,{term:`Code`,children:i.code}),i.system&&(0,L.jsx)(qN,{term:`System`,children:i.system}),i.display&&(0,L.jsx)(qN,{term:`Display`,children:i.display})]}),c&&(0,L.jsxs)(H,{gap:`xs`,children:[(0,L.jsx)(su,{size:`sm`}),(0,L.jsx)(U,{size:`sm`,c:`dimmed`,children:`Loading properties...`})]}),!c&&u&&(0,L.jsxs)(Ed,{icon:(0,L.jsx)(lA,{size:16}),title:`Lookup Failed`,color:`red`,children:[`Failed to retrieve code information: `,Zx(u)]}),!c&&!u&&m&&(0,L.jsx)(kj,{children:(0,L.jsxs)(K,{gap:`xs`,mt:`lg`,children:[(0,L.jsx)(U,{fw:500,size:`sm`,c:`dimmed`,className:VX.propertiesTitle,children:`Properties`}),(0,L.jsx)(UX,{properties:p})]})})]}):null]})})}function GX(){let{resourceType:e,id:t}=sW(),n=ek({reference:e+`/`+t});return n?n.resourceType===`Questionnaire`?(0,L.jsx)(BX,{resourceType:e,id:t}):n.resourceType===`ValueSet`?(0,L.jsx)(WX,{valueSet:n}):null:null}function KX(){let e=Q(),{resourceType:t,id:n}=sW(),[r,i]=(0,b.useState)(),[a,o]=(0,b.useState)();return(0,b.useEffect)(()=>{e.readResource(t,n).then(e=>i(AC(e))).catch(e=>{Y({color:`red`,message:Zx(e)})})},[e,t,n]),r?(0,L.jsxs)(nP,{children:[(0,L.jsxs)(J,{order:2,children:[`Available `,t,` profiles`]}),(0,L.jsx)(K,{children:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(PX,{resource:r,currentProfile:a,onChange:o}),a?(0,L.jsx)(qX,{profile:a,resource:r,onResourceUpdated:e=>i(e)},a.url):(0,L.jsx)(U,{my:`lg`,fz:`lg`,fs:`italic`,ta:`center`,children:`Select a profile above`})]})})]}):null}var qX=({profile:e,resource:t,onResourceUpdated:n})=>{let r=Q(),[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)(()=>t.meta?.profile?.includes(e.url)),c=(0,b.useCallback)(t=>{a(void 0);let i=TX(t);o?tw(i,e.url):nw(i,e.url),r.updateResource(i).then(e=>{n(e),Y({color:`green`,message:`Success`})}).catch(e=>{a(Xx(e)),Y({color:`red`,message:Zx(e),autoClose:!1})})},[r,e.url,n,o]);return(0,L.jsxs)(K,{children:[(0,L.jsx)(Uy,{size:`md`,checked:o,label:`Conform resource to ${e.title}`,onChange:e=>s(e.currentTarget.checked),"data-testid":`profile-toggle`}),o?(0,L.jsx)(DB,{profileUrl:e.url,defaultValue:t,onSubmit:c,outcome:i}):(0,L.jsx)(`form`,{noValidate:!0,onSubmit:e=>{e.preventDefault(),c(t)},children:(0,L.jsx)(H,{justify:`flex-end`,mt:`xl`,children:(0,L.jsx)(W,{type:`submit`,children:`OK`})})})]})},JX={"Create Only":`create`,"Update Only":`update`,"Delete Only":`delete`,"All Interactions":void 0},YX=Object.keys(JX);function XX(){let e=Q(),{id:t}=sW(),n=ek({reference:`Questionnaire/${t}`}),[r,i]=(0,b.useState)(),[a,o]=(0,b.useState)(`create`),[s,c]=(0,b.useState)(0),l=e.searchResources(`Subscription`,`status=active&_count=100`).read().filter(e=>ZX(e,n));function u(){r&&n&&e.createResource({resourceType:`Subscription`,status:`active`,reason:`Connect bot ${r.name} to questionnaire responses`,criteria:`QuestionnaireResponse?questionnaire=${n.url?`${n.url},${aC(n)}`:aC(n)}`,channel:{type:`rest-hook`,endpoint:aC(r)},...a?{extension:[{url:`https://medplum.com/fhir/StructureDefinition/subscription-supported-interaction`,valueCode:a}]}:void 0}).then(()=>{i(void 0),c(Date.now()),e.invalidateSearches(`Subscription`),Y({color:`green`,message:`Success`})}).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1}))}return(0,L.jsxs)(nP,{children:[(0,L.jsx)(J,{children:`Bots`}),(0,L.jsxs)(K,{children:[l.length===0&&(0,L.jsx)(`p`,{children:`No bots found.`}),l.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{children:(0,L.jsx)(XI,{value:{reference:e.channel?.endpoint},link:!0})}),(0,L.jsxs)(`p`,{children:[`Criteria: `,e.criteria]})]},e.id))]}),(0,L.jsx)(um,{}),(0,L.jsxs)(K,{mt:10,children:[(0,L.jsx)(nd,{size:`lg`,htmlFor:`bot`,children:`Connect to bot`}),(0,L.jsxs)(H,{children:[(0,L.jsx)(KF,{name:`bot`,resourceType:`Bot`,onChange:e=>i(e)}),(0,L.jsx)(W,{onClick:u,children:`Connect`})]}),(0,L.jsx)(H,{children:(0,L.jsx)(Tg,{name:`subscription-trigger-event`,defaultValue:`Create Only`,label:`Subscription Trigger Event`,data:YX,onChange:e=>o(JX[e.target.value])})})]}),(0,L.jsx)(`div`,{style:{display:`none`},children:s})]})}function ZX(e,t){if(!t)return!1;let n=e.criteria||``,r=e.channel?.endpoint||``;return n.startsWith(`QuestionnaireResponse?`)&&r.startsWith(`Bot/`)&&(n.includes(aC(t))||(t.url?n.includes(t.url):!1))}function QX(){let{id:e}=sW(),t=rW(),n=Q().readReference({reference:`Questionnaire/${e}`}).read(),[r,i]=(0,b.useState)({resourceType:`QuestionnaireResponse`,filters:[{code:`questionnaire`,operator:Z.EQUALS,value:n.url?`${n.url},Questionnaire/${e}`:`Questionnaire/${e}`}],fields:[`id`,`_lastUpdated`]});return(0,L.jsx)(nP,{children:(0,L.jsx)(KR,{search:r,onClick:e=>t(`/${e.resource.resourceType}/${e.resource.id}`)?.catch(console.error),onChange:e=>i(e.definition),hideFilters:!0,hideToolbar:!0})})}function $X(){let e=Q(),{resourceType:t,id:n}=sW(),r=ek({reference:t+`/`+n}),i=(0,b.useCallback)(t=>{e.updateResource(TX(t)).then(()=>{Y({color:`green`,message:`Success`})}).catch(e=>{Y({color:`red`,message:Zx(e),autoClose:!1})})},[e]);return r?(0,L.jsx)(nP,{children:(0,L.jsx)(nB,{onSubmit:i,definition:r})}):null}function eZ(){let{resourceType:e,id:t}=sW(),n=ek({reference:e+`/`+t});return n?(0,L.jsx)(nP,{children:e===`MeasureReport`?(0,L.jsx)(pz,{measureReport:n}):(0,L.jsx)($I,{value:n})}):null}var tZ={container:`_container_1ue98_1`,entry:`_entry_1ue98_14`,active:`_active_1ue98_21`};function nZ(e){let t=Q(),n=ek(e.value),[r,i]=(0,b.useState)();return(0,b.useEffect)(()=>{if(!n)return;let e=dK(n);if(!e)return;let r=`reference`in e?e.reference:aC(e);t.search(`ServiceRequest`,`subject=`+r).then(e=>{let t=(e.entry??[]).map(e=>e.resource);DL(t),t.reverse(),i(t)}).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1}))},[t,n]),r?(0,L.jsx)(`div`,{"data-testid":`quick-service-requests`,className:tZ.container,children:r.map(e=>(0,L.jsxs)(`div`,{className:jn(tZ.entry,{[tZ.active]:e.id===n?.id}),children:[(0,L.jsx)(`p`,{children:(0,L.jsx)(Rj,{to:e,children:rZ(e)})}),e.category?.[0]?.text&&(0,L.jsx)(`p`,{children:e.category[0]?.text}),e.code?.coding?.[0]?.code&&(0,L.jsx)(`p`,{children:e.code.coding[0]?.code}),(0,L.jsx)(`p`,{children:iZ(e)})]},e.id))}):null}function rZ(e){if(e.identifier){for(let t of e.identifier)if(t.value)return t.value}return e.id||``}function iZ(e){return e.authoredOn?e.authoredOn.substring(0,10):e.meta?.lastUpdated?e.meta.lastUpdated.substring(0,10):``}var aZ={container:`_container_1l2dh_1`};function oZ(e){let t=ek(e.valueSet);if(!t)return null;let n=[``],r=t.compose?.include?.[0]?.concept?.map(e=>e.code);return r&&n.push(...r),e.defaultValue&&!n.includes(e.defaultValue)&&n.push(e.defaultValue),(0,L.jsx)(`div`,{className:aZ.container,children:(0,L.jsx)(Tg,{defaultValue:e.defaultValue,onChange:t=>e.onChange(t.currentTarget.value),data:n})})}function sZ(e){let t=ek(e.specimen);return t?(0,L.jsxs)(nz,{children:[(0,L.jsxs)(nz.Entry,{children:[(0,L.jsx)(nz.Key,{children:`Type`}),(0,L.jsx)(nz.Value,{children:`Specimen`})]}),(0,L.jsxs)(nz.Entry,{children:[(0,L.jsx)(nz.Key,{children:`Collected`}),(0,L.jsx)(nz.Value,{children:uw(t.collection?.collectedDateTime)})]}),(0,L.jsxs)(nz.Entry,{children:[(0,L.jsx)(nz.Key,{children:`Specimen Age`}),(0,L.jsx)(nz.Value,{children:cZ(t)})]}),t.collection?.collectedDateTime&&t.receivedTime?(0,L.jsxs)(nz.Entry,{children:[(0,L.jsx)(nz.Key,{children:`Specimen Stability`}),(0,L.jsx)(nz.Value,{children:lZ(t)})]}):(0,L.jsx)(L.Fragment,{})]}):null}function cZ(e){let t=e.collection?.collectedDateTime;if(t)return uZ(dZ(new Date(t),new Date))}function lZ(e){if(!(!e.collection?.collectedDateTime||!e.receivedTime))return uZ(dZ(new Date(e.collection.collectedDateTime),new Date(e.receivedTime)))}function uZ(e){return e.toString().padStart(3,`0`)+`D`}function dZ(e,t){let n=t.getTime()-e.getTime();return Math.floor(n/(1e3*3600*24))}function fZ(e){let t=[`Timeline`];return e===`Bot`&&t.push(`Editor`,`Subscriptions`),e===`PlanDefinition`&&t.push(`Apply`,`Builder`),e===`Questionnaire`&&t.push(`Preview`,`Builder`,`Bots`,`Responses`),e===`ValueSet`&&t.push(`Preview`),(e===`DiagnosticReport`||e===`MeasureReport`)&&t.push(`Report`),e===`RequestGroup`&&t.push(`Checklist`),e===`ObservationDefinition`&&t.push(`Ranges`),e===`Agent`&&t.push(`Tools`),e===`Communication`&&t.push(`Payload`),t.push(`Details`,`Edit`,`Event`,`History`,`Blame`,`JSON`,`Apps`,`Profiles`),e===`Patient`&&t.push(`Accounts`,`Export`),t}function pZ(){let e=Q(),{resourceType:t,id:n}=sW(),r={reference:t+`/`+n},[i,a]=(0,b.useState)(),o=ek(r,a),s=fZ(t);async function c(){let r=(await e.readHistory(t,n)).entry?.find(e=>!!e.resource)?.resource;r?l(r):Y({color:`red`,message:`No history to restore`,autoClose:!1})}function l(t){e.updateResource(TX(t)).then(()=>{a(void 0),Y({color:`green`,message:`Success`})}).catch(e=>{Y({color:`red`,message:Zx(e),autoClose:!1})})}if(i)return Jx(i)?(0,L.jsxs)(nP,{children:[(0,L.jsx)(J,{children:`Deleted`}),(0,L.jsx)(`p`,{children:`The resource was deleted.`}),(0,L.jsx)(W,{color:`red`,onClick:c,children:`Restore`})]}):(0,L.jsx)(uP,{outcome:i});function u(e){let t=o,n=t.orderDetail||[];n.length===0&&n.push({}),n[0].text!==e&&(n[0].text=e,l({...t,orderDetail:n}))}let d=o&&dK(o),f=o&&fK(o),p=e.getUserConfiguration()?.option?.find(e=>e.id===`statusValueSet`)?.valueString;return(0,L.jsxs)(L.Fragment,{children:[o?.resourceType===`ServiceRequest`&&p&&(0,L.jsx)(oZ,{valueSet:{reference:p},defaultValue:o.orderDetail?.[0]?.text,onChange:u},aC(o)+`-`+o.orderDetail?.[0]?.text),o&&(0,L.jsx)(nZ,{value:o}),o&&(0,L.jsxs)(vl,{children:[d&&(0,L.jsx)(Tz,{patient:d}),f&&(0,L.jsx)(sZ,{specimen:f}),t!==`Patient`&&(0,L.jsx)(zY,{resource:r}),(0,L.jsx)(ll,{children:(0,L.jsx)(iz,{baseUrl:`/${t}/${n}`,tabs:s})})]}),(0,L.jsx)(UW,{})]})}function mZ(){let e=rW(),{resourceType:t,id:n,versionId:r,tab:i}=sW(),a=Q(),[o,s]=(0,b.useState)(!0),[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)();if((0,b.useEffect)(()=>{d(void 0),s(!0),a.readHistory(t,n).then(e=>l(e)).then(()=>s(!1)).catch(e=>{d(e),s(!1)})},[a,t,n]),o)return(0,L.jsx)(Aj,{});let f=c?.entry??[],p=f.findIndex(e=>e.resource?.meta?.versionId===r);if(p===-1)return(0,L.jsxs)(nP,{children:[(0,L.jsx)(J,{children:`Version not found`}),(0,L.jsx)(Rj,{to:`/${t}/${n}`,children:`Return to resource`})]});let m=f[p].resource,h=p<f.length-1?f[p+1].resource:void 0,g=`diff`,_=i||g,v=f.length-p;return(0,L.jsx)(im,{maw:1200,children:(0,L.jsx)(tP,{children:(0,L.jsxs)(K,{gap:`lg`,children:[u&&(0,L.jsx)(`pre`,{"data-testid":`error`,children:JSON.stringify(u,void 0,2)}),(0,L.jsxs)(_y,{cols:2,mb:`lg`,children:[(0,L.jsx)(nv,{total:f.length,value:v,getControlProps:zR,onChange:r=>e(`/${t}/${n}/_history/${f[f.length-r]?.resource?.meta?.versionId}/${_}`)?.catch(console.error)}),(0,L.jsx)(H,{justify:`right`,children:(0,L.jsx)(ly,{data:[{value:`diff`,label:`Diff`},{value:`raw`,label:`Raw`}],value:_,onChange:i=>e(`/${t}/${n}/_history/${r}/${i||g}`)?.catch(console.error)})})]}),(0,L.jsx)(B,{mb:`lg`,children:(0,L.jsxs)(KN,{compact:!0,children:[(0,L.jsx)(qN,{term:`Version ID`,children:m.meta?.versionId}),(0,L.jsx)(qN,{term:`Author`,children:(0,L.jsx)(ZI,{value:m.meta?.author,link:!0},m.meta?.author?.reference)}),(0,L.jsx)(qN,{term:`Date/Time`,children:uw(m.meta?.lastUpdated)})]})}),_===`diff`&&(0,L.jsx)(wB,{original:h??{},revised:m}),_===`raw`&&(0,L.jsx)(`pre`,{style:{fontSize:`9pt`},children:JSON.stringify(m,void 0,2)})]})})})}function hZ(){let{resourceType:e,id:t}=sW(),n=rW(),[r,i]=(0,b.useState)({resourceType:`Subscription`,filters:[{code:`url`,operator:Z.EQUALS,value:`${e}/${t}`}],fields:[`id`,`criteria`,`status`,`_lastUpdated`]});return(0,L.jsx)(nP,{children:(0,L.jsx)(KR,{search:r,onClick:e=>n(`/${e.resource.resourceType}/${e.resource.id}`)?.catch(console.error),onChange:e=>i(e.definition),hideFilters:!0})})}function gZ(e){let t=Q(),{resource:n,opened:r,onClose:i}=e,[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(),[l,u]=(0,b.useState)(!1);return(0,L.jsx)(ng,{opened:r,onClose:i,title:`Resend Subscriptions`,children:(0,L.jsx)(sN,{onSubmit:(0,b.useCallback)(async()=>{if(n?.id)try{await t.post(t.fhirUrl(n.resourceType,n.id,`$resend`),{subscription:a&&s?aC(s):void 0,verbose:l}),Y({color:`green`,message:`Done`}),i()}catch(e){Y({color:`red`,message:Zx(e),autoClose:!1})}},[t,n,i,a,s,l]),children:(0,L.jsxs)(K,{children:[(0,L.jsx)(cp,{label:`Choose subscription (all subscriptions by default)`,onChange:e=>o(e.currentTarget.checked)}),a&&(0,L.jsx)(KF,{name:`subscription`,resourceType:`Subscription`,placeholder:`Subscription`,onChange:c}),(0,L.jsx)(cp,{label:`Verbose mode`,onChange:e=>u(e.currentTarget.checked)}),(0,L.jsx)(H,{justify:`flex-end`,children:(0,L.jsx)(W,{type:`submit`,children:`Resend`})})]})})})}function _Z(){let e=Q(),t=WO(),{resourceType:n,id:r}=sW(),i={reference:n+`/`+r},[a,o]=(0,b.useState)(),s=yn(!1);function c(t,n){return e.updateResource({...t,priority:n})}function l(e,t){c(e,`stat`).then(t).catch(console.error)}function u(e,t){c(e,`routine`).then(t).catch(console.error)}function d(e){t(`/${e.resourceType}/${e.id}`)}function f(e){t(`/${e.resourceType}/${e.id}/edit`)}function p(e){t(`/${e.resourceType}/${e.id}/delete`)}function m(e){o(e),s[1].open()}function h(e){t(`/${e.resourceType}/${e.id}/_history/${e.meta?.versionId}`)}function g(t,n){let r=`aws-textract`;Y({id:r,title:`AWS Textract in Progress`,message:`Extracting text... This may take a moment...`,loading:!0,autoClose:!1}),e.post(e.fhirUrl(t.resourceType,t.id,`$aws-textract`),{}).then(()=>{n(),Fb({id:r,title:`AWS Textract Successful`,message:`Text successfully extracted.`,color:`green`,icon:(0,L.jsx)(CA,{size:`1rem`}),loading:!1,withCloseButton:!0})}).catch(e=>Fb({id:r,title:`AWS Textract Error`,color:`red`,message:Zx(e),icon:(0,L.jsx)(Dj,{size:`1rem`}),loading:!1,withCloseButton:!0}))}function _(t){let{primaryResource:n,currentResource:r,reloadTimeline:i}=t,a=r.resourceType===n.resourceType&&r.id===n.id,o=r.resourceType===`Communication`&&r.priority!==`stat`,s=r.resourceType===`Communication`&&r.priority===`stat`,c=a,_=!a,v=!a,y=!a,b=e.getProjectMembership()?.admin,x=b,S=oX()&&(r.resourceType===`DocumentReference`||r.resourceType===`Media`);return(0,L.jsxs)(G.Dropdown,{children:[(0,L.jsx)(G.Label,{children:`Resource`}),o&&(0,L.jsx)(G.Item,{leftSection:(0,L.jsx)(aj,{size:14}),onClick:()=>l(r,i),"aria-label":`Pin ${aC(r)}`,children:`Pin`}),s&&(0,L.jsx)(G.Item,{leftSection:(0,L.jsx)(oj,{size:14}),onClick:()=>u(r,i),"aria-label":`Unpin ${aC(r)}`,children:`Unpin`}),_&&(0,L.jsx)(G.Item,{leftSection:(0,L.jsx)(JA,{size:14}),onClick:()=>d(r),"aria-label":`Details ${aC(r)}`,children:`Details`}),c&&(0,L.jsx)(G.Item,{leftSection:(0,L.jsx)(JA,{size:14}),onClick:()=>h(r),"aria-label":`Details ${aC(r)}`,children:`Details`}),v&&(0,L.jsx)(G.Item,{leftSection:(0,L.jsx)(IA,{size:14}),onClick:()=>f(r),"aria-label":`Edit ${aC(r)}`,children:`Edit`}),b&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(G.Divider,{}),(0,L.jsx)(G.Label,{children:`Admin`}),x&&(0,L.jsx)(G.Item,{leftSection:(0,L.jsx)(dj,{size:14}),onClick:()=>m(r),"aria-label":`Resend Subscriptions ${aC(r)}`,children:`Resend Subscriptions`})]}),S&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(G.Divider,{}),(0,L.jsx)(G.Label,{children:`AWS AI`}),(0,L.jsx)(G.Item,{leftSection:(0,L.jsx)(Sj,{size:14}),onClick:()=>g(r,i),"aria-label":`AWS Textract ${aC(r)}`,children:`AWS Textract`})]}),y&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(G.Divider,{}),(0,L.jsx)(G.Label,{children:`Danger zone`}),(0,L.jsx)(G.Item,{color:`red`,leftSection:(0,L.jsx)(Cj,{size:14}),onClick:()=>p(r),"aria-label":`Delete ${aC(r)}`,children:`Delete`})]})]})}return(0,L.jsxs)(L.Fragment,{children:[n===`Encounter`&&(0,L.jsx)(HL,{encounter:i,getMenu:_}),n===`Patient`&&(0,L.jsx)(Ez,{patient:i,getMenu:_}),n===`ServiceRequest`&&(0,L.jsx)(aK,{serviceRequest:i,getMenu:_}),n!==`Encounter`&&n!==`Patient`&&n!==`ServiceRequest`&&(0,L.jsx)(VL,{resource:i,getMenu:_}),(0,L.jsx)(gZ,{resource:a,opened:s[0],onClose:s[1].close},`resend-subscriptions-${a?.id}`)]})}function vZ(e){let{opened:t,close:n,version:r,loadingStatus:i,handleStatus:a,handleUpgrade:o}=e,[s,c]=(0,b.useState)(),[l,u]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{t&&(s||VO(`app-tools-page`).then(c).catch(console.error),a())},[t,s,a]),s&&r&&!i?r===`unknown`?(0,L.jsx)(`p`,{children:`Unable to determine the current version of the agent. Check the network connectivity of the agent.`}):r.startsWith(s)?(0,L.jsxs)(`p`,{children:[`This agent is already on the latest version (`,s,`).`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{children:[`Are you sure you want to upgrade this agent from version `,r,` to version `,s,`?`]}),(0,L.jsxs)(H,{children:[(0,L.jsx)(W,{onClick:()=>{o(l),n()},"aria-label":`Confirm upgrade`,children:`Confirm Upgrade`}),(0,L.jsx)(cp,{label:`Force`,onChange:e=>u(e.currentTarget.checked)})]})]}):(0,L.jsx)(Aj,{})}var yZ=[`live`,`ping`,`hl7ConnectionsOpen`,`hl7ClientCount`,`hl7QueueDepth`,`webSocketQueueDepth`,`outstandingHeartbeats`];function bZ(e){return e==null?``:typeof e==`object`?JSON.stringify(e):typeof e==`number`?e.toLocaleString():e.toString()}function xZ(e){let t=Object.keys(e.entries).filter(t=>e.entries[t]?.rtt);return t.length?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(J,{order:3,mt:`md`,children:e.title}),(0,L.jsxs)(q,{children:[(0,L.jsx)(q.Thead,{children:(0,L.jsxs)(q.Tr,{children:[(0,L.jsx)(q.Th,{children:`Name`}),(0,L.jsx)(q.Th,{children:`Count`}),(0,L.jsx)(q.Th,{children:`Pending`}),(0,L.jsx)(q.Th,{children:`Min (ms)`}),(0,L.jsx)(q.Th,{children:`Avg (ms)`}),(0,L.jsx)(q.Th,{children:`Max (ms)`}),(0,L.jsx)(q.Th,{children:`p50 (ms)`}),(0,L.jsx)(q.Th,{children:`p95 (ms)`}),(0,L.jsx)(q.Th,{children:`p99 (ms)`})]})}),(0,L.jsx)(q.Tbody,{children:t.map(t=>{let n=e.entries[t].rtt;return(0,L.jsxs)(q.Tr,{children:[(0,L.jsx)(q.Td,{children:t}),(0,L.jsx)(q.Td,{children:n.count}),(0,L.jsx)(q.Td,{children:n.pendingCount}),(0,L.jsx)(q.Td,{children:n.min}),(0,L.jsx)(q.Td,{children:n.average}),(0,L.jsx)(q.Td,{children:n.max}),(0,L.jsx)(q.Td,{children:n.p50}),(0,L.jsx)(q.Td,{children:n.p95}),(0,L.jsx)(q.Td,{children:n.p99})]},t)})})]})]}):null}function SZ(e){let{stats:t}=e,n=new Set([...yZ,`channelStats`,`clientStats`]),r=Object.entries(t).filter(([e])=>!n.has(e));return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(q,{mt:`sm`,children:(0,L.jsxs)(q.Tbody,{children:[yZ.map(e=>(0,L.jsxs)(q.Tr,{children:[(0,L.jsx)(q.Td,{children:e}),(0,L.jsx)(q.Td,{children:bZ(t[e])})]},e)),r.map(([e,t])=>(0,L.jsxs)(q.Tr,{children:[(0,L.jsx)(q.Td,{children:e}),(0,L.jsx)(q.Td,{children:bZ(t)})]},e))]})}),(0,L.jsx)(xZ,{title:`Channel Stats`,entries:t.channelStats}),(0,L.jsx)(xZ,{title:`Client Stats`,entries:t.clientStats})]})}function CZ(){let e=Q(),{id:t}=sW(),n=(0,b.useMemo)(()=>({reference:`Agent/`+t}),[t]),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),[p,m]=(0,b.useState)(),[h,g]=(0,b.useState)(),[_,v]=(0,b.useState)(),[y,x]=(0,b.useState)(),[S,C]=(0,b.useState)(!1),[w,T]=(0,b.useState)(),[E,D]=(0,b.useState)(),[O,{open:k,close:A}]=yn(!1),j=r||a||s||S||l||d,M=(0,b.useCallback)(()=>{i(!0),e.get(e.fhirUrl(`Agent`,t,`$status`),{cache:`reload`}).then(e=>{m(e.parameter?.find(e=>e.name===`status`)?.valueCode),g(e.parameter?.find(e=>e.name===`version`)?.valueString),v(e.parameter?.find(e=>e.name===`lastUpdated`)?.valueInstant)}).catch(e=>re(Zx(e))).finally(()=>i(!1))},[e,t]),N=(0,b.useCallback)(t=>{let r=t.host,i=t.pingCount||1;r&&(C(!0),e.pushToAgent(n,r,`PING ${i}`,YE.PING,!0).then(e=>x(e)).catch(e=>re(Zx(e))).finally(()=>C(!1)))},[e,n]),P=(0,b.useCallback)(()=>{o(!0),e.get(e.fhirUrl(`Agent`,t,`$reload-config`),{cache:`reload`}).then(e=>{ne(`Agent config reloaded successfully.`)}).catch(e=>re(Zx(e))).finally(()=>o(!1))},[e,t]),F=(0,b.useCallback)(n=>{c(!0);let r=e.fhirUrl(`Agent`,t,`$upgrade`);r.searchParams.set(`force`,String(n)),e.get(r,{cache:`reload`}).then(e=>{ne(`Agent upgraded successfully.`)}).catch(e=>re(Zx(e))).finally(()=>c(!1))},[e,t]),ee=(0,b.useCallback)(n=>{u(!0);let r=n.logLimit||20;e.get(e.fhirUrl(`Agent`,t,`$fetch-logs${r===void 0?``:`?limit=${r}`}`),{cache:`reload`}).then(e=>{let t=e?.parameter?.find(e=>e.name===`logs`);t&&T(t?.valueString)}).catch(e=>re(Zx(e))).finally(()=>u(!1))},[e,t]),te=(0,b.useCallback)(()=>{f(!0),e.get(e.fhirUrl(`Agent`,t,`$stats`),{cache:`reload`}).then(e=>{let t=e.parameter?.find(e=>e.name===`stats`)?.valueString;if(t)try{D(JSON.parse(t))}catch(e){re(Zx(e))}}).catch(e=>re(Zx(e))).finally(()=>f(!1))},[e,t]);function ne(e){Y({color:`green`,title:`Success`,icon:(0,L.jsx)(CA,{size:`1rem`}),message:e})}function re(e){Y({color:`red`,title:`Error`,message:e,autoClose:!1})}return(0,L.jsxs)(nP,{children:[(0,L.jsx)(ng,{opened:O,onClose:A,title:`Upgrade Agent`,centered:!0,children:(0,L.jsx)(vZ,{opened:O,close:A,version:h,loadingStatus:r,handleStatus:M,handleUpgrade:F})}),(0,L.jsx)(J,{order:1,children:`Agent Tools`}),(0,L.jsxs)(`div`,{style:{marginBottom:10},children:[`Agent: `,(0,L.jsx)(XI,{value:n,link:!0})]}),(0,L.jsx)(um,{my:`lg`}),(0,L.jsx)(J,{order:2,children:`Agent Status`}),(0,L.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.`}),(0,L.jsx)(W,{onClick:M,loading:r,disabled:j&&!r,children:`Get Status`}),!r&&p&&(0,L.jsx)(q,{children:(0,L.jsxs)(q.Tbody,{children:[(0,L.jsxs)(q.Tr,{children:[(0,L.jsx)(q.Td,{children:`Status`}),(0,L.jsx)(q.Td,{children:(0,L.jsx)(qI,{status:p})})]}),(0,L.jsxs)(q.Tr,{children:[(0,L.jsx)(q.Td,{children:`Version`}),(0,L.jsx)(q.Td,{children:h})]}),(0,L.jsxs)(q.Tr,{children:[(0,L.jsx)(q.Td,{children:`Last Updated`}),(0,L.jsx)(q.Td,{children:uw(_,void 0,{timeZoneName:`longOffset`})})]})]})}),(0,L.jsx)(um,{my:`lg`}),(0,L.jsx)(J,{order:2,children:`Reload Config`}),(0,L.jsx)(`p`,{children:`Reload the configuration of this agent, syncing it with the current version of the Agent resource on the Medplum server.`}),(0,L.jsx)(W,{onClick:P,loading:a,disabled:j&&!a,"aria-label":`Reload config`,children:`Reload Config`}),(0,L.jsx)(um,{my:`lg`}),(0,L.jsx)(J,{order:2,children:`Upgrade Agent`}),(0,L.jsx)(`p`,{children:`Upgrade the version of this agent, to either the latest (default) or a specified version.`}),(0,L.jsx)(W,{onClick:k,loading:s,disabled:j&&!s,"aria-label":`Upgrade agent`,children:`Upgrade`}),(0,L.jsx)(um,{my:`lg`}),(0,L.jsxs)(sN,{onSubmit:ee,children:[(0,L.jsx)(J,{order:2,children:`Fetch Logs`}),(0,L.jsx)(`p`,{children:`Fetch logs from the agent.`}),w?.length?(0,L.jsx)(tm,{block:!0,mb:15,children:w}):null,(0,L.jsxs)(H,{children:[(0,L.jsx)(N_,{w:100,id:`logLimit`,name:`logLimit`,placeholder:`20`,label:`Log Limit`}),(0,L.jsx)(W,{mt:22,loading:l,disabled:j&&!l,"aria-label":`Fetch logs`,type:`submit`,children:`Fetch Logs`})]})]}),(0,L.jsx)(um,{my:`lg`}),(0,L.jsx)(J,{order:2,children:`Agent Stats`}),(0,L.jsx)(`p`,{children:`Fetch runtime statistics from the agent, including connection counts, queue depths, RTT metrics, and overall agent health.`}),(0,L.jsx)(W,{onClick:te,loading:d,disabled:j&&!d,"aria-label":`Get stats`,children:`Get Stats`}),!d&&E&&(0,L.jsx)(SZ,{stats:E}),(0,L.jsx)(um,{my:`lg`}),(0,L.jsx)(J,{order:2,children:`Ping from Agent`}),(0,L.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.`}),(0,L.jsx)(sN,{onSubmit:N,children:(0,L.jsxs)(H,{children:[(0,L.jsx)(vb,{id:`host`,name:`host`,placeholder:`ex. 127.0.0.1`,label:`IP Address / Hostname`,rightSection:(0,L.jsx)(hu,{size:24,radius:`xl`,variant:`filled`,type:`submit`,"aria-label":`Ping`,loading:S,disabled:j&&!S,children:(0,L.jsx)(pj,{style:{width:`1rem`,height:`1rem`},stroke:1.5})})}),(0,L.jsx)(N_,{id:`pingCount`,name:`pingCount`,placeholder:`1`,label:`Ping Count`})]})}),!S&&y&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(J,{order:5,mt:`sm`,mb:0,children:`Last Ping`}),(0,L.jsx)(`pre`,{children:y})]})]})}function wZ(){let e=rW(),t=Q(),[n,r]=(0,b.useState)();(0,b.useEffect)(()=>{t.get(`auth/me`,{cache:`no-cache`}).then(r).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1}))},[t]);function i(e){t.post(`auth/revoke`,{loginId:e}).then(()=>t.get(`auth/me`,{cache:`no-cache`})).then(r).then(()=>Y({color:`green`,message:`Login revoked`})).catch(e=>Y({color:`red`,message:Zx(e),autoClose:!1}))}return n?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(nP,{children:[(0,L.jsx)(J,{children:`Security`}),(0,L.jsxs)(KN,{children:[(0,L.jsx)(qN,{term:`ID`,children:(0,L.jsx)(Nd,{href:`/${aC(n.profile)}`,children:n.profile.id})}),(0,L.jsx)(qN,{term:`Resource Type`,children:n.profile.resourceType}),(0,L.jsx)(qN,{term:`Name`,children:sw(n.profile.name?.[0])})]})]}),(0,L.jsxs)(nP,{children:[(0,L.jsx)(J,{children:`Sessions`}),(0,L.jsxs)(q,{children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{children:`OS`}),(0,L.jsx)(`th`,{children:`Browser`}),(0,L.jsx)(`th`,{children:`IP Address`}),(0,L.jsx)(`th`,{children:`Auth Method`}),(0,L.jsx)(`th`,{children:`Last Updated`}),(0,L.jsx)(`th`,{})]})}),(0,L.jsx)(`tbody`,{children:n.security.sessions.map(e=>(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`td`,{children:e.os}),(0,L.jsx)(`td`,{children:e.browser}),(0,L.jsx)(`td`,{children:e.remoteAddress}),(0,L.jsx)(`td`,{children:e.authMethod}),(0,L.jsx)(`td`,{children:uw(e.lastUpdated)}),(0,L.jsx)(`td`,{children:(0,L.jsx)(Nd,{href:`#`,onClick:()=>i(e.id),children:`Revoke`})})]},e.id))})]})]}),(0,L.jsxs)(nP,{children:[(0,L.jsx)(J,{children:`Password`}),(0,L.jsx)(W,{onClick:()=>e(`/changepassword`)?.catch(console.error),children:`Change password`})]}),(0,L.jsxs)(nP,{children:[(0,L.jsx)(J,{children:`Multi Factor Auth`}),(0,L.jsxs)(`p`,{children:[`Enrolled: `,n.security.mfaEnrolled.toString()]}),!n.security.mfaEnrolled&&(0,L.jsx)(W,{onClick:()=>e(`/mfa`)?.catch(console.error),children:`Enroll`})]})]}):null}function TZ(){let{id:e,secret:t}=sW(),n=rW();return(0,L.jsx)(bP,{id:e,secret:t,onSignIn:()=>n(`/signin`)?.catch(console.error)})}function EZ(){let e=GO(),t=rW(),[n]=qG(),r=iX(),i=(0,b.useCallback)(()=>{let e=n.get(`next`);t(e?.startsWith(`/`)?e:`/`)?.catch(console.error)},[n,t]);return(0,b.useEffect)(()=>{e&&n.has(`next`)&&i()},[e,n,i]),(0,L.jsxs)(BP,{onSuccess:()=>i(),onForgotPassword:()=>t(`/resetpassword`)?.catch(console.error),onRegister:aX()?()=>t(`/register`)?.catch(console.error):void 0,googleClientId:r.googleClientId,login:n.get(`login`)||void 0,projectId:n.get(`project`)||void 0,children:[(0,L.jsx)(rP,{size:32}),n.get(`project`)!==`new`&&(0,L.jsxs)(J,{order:3,py:`lg`,ta:`center`,children:[`Sign in to `,qj()]}),n.get(`project`)===`new`&&(0,L.jsx)(J,{order:3,py:`lg`,ta:`center`,children:`Sign in again to create a new project`})]})}function DZ(){let e=rW(),t=eW(),[n,r]=(0,b.useState)(),[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)();return(0,b.useEffect)(()=>{let e=Object.fromEntries(new URLSearchParams(t.search).entries());r(e.resourceType),a(e.query),s(JSON.parse(e.fields))},[t]),!n||!i||!o?null:(0,L.jsx)(ez,{resourceType:n,checkboxesEnabled:!0,query:i,fields:o,onClick:t=>e(`/${n}/${t.resource.id}`)?.catch(console.error),onAuxClick:e=>window.open(`/${n}/${e.resource.id}`,`_blank`),onBulk:t=>{e(`/bulk/${n}?ids=${t.join(`,`)}`)?.catch(console.error)}})}function OZ(){let{id:e,secret:t}=sW(),n=Q(),[r,i]=(0,b.useState)(),[a,o]=(0,b.useState)(!1);return(0,L.jsxs)(nP,{width:450,children:[(0,L.jsx)(uP,{issues:aP(r,void 0)}),(0,L.jsxs)(sN,{onSubmit:async()=>{i(void 0);try{let r=Wx(await n.post(`auth/verifyemail`,{id:e,secret:t}));r?FE.assign(r):o(!0)}catch(e){i(Xx(e))}},children:[(0,L.jsxs)(gd,{direction:`column`,align:`center`,justify:`center`,children:[(0,L.jsx)(rP,{size:32}),(0,L.jsx)(J,{children:`Email address verification required`})]}),!a&&(0,L.jsxs)(K,{children:[(0,L.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.`}),(0,L.jsx)(H,{justify:`center`,mt:`xl`,children:(0,L.jsx)(cN,{children:`Verify email`})})]}),a&&(0,L.jsxs)(`div`,{"data-testid":`success`,children:[`Email verified. You can now\xA0`,(0,L.jsx)(Rj,{to:`/signin`,children:`sign in`}),`.`]})]})]})}function kZ(){return(0,L.jsx)(GW,{children:(0,L.jsxs)($,{errorElement:(0,L.jsx)(RY,{}),children:[(0,L.jsx)($,{path:`/signin`,element:(0,L.jsx)(EZ,{})}),(0,L.jsx)($,{path:`/oauth`,element:(0,L.jsx)(cX,{})}),(0,L.jsx)($,{path:`/resetpassword`,element:(0,L.jsx)(uX,{})}),(0,L.jsx)($,{path:`/setpassword/:id/:secret`,element:(0,L.jsx)(TZ,{})}),(0,L.jsx)($,{path:`/verifyemail/:id/:secret`,element:(0,L.jsx)(OZ,{})}),(0,L.jsx)($,{path:`/register`,element:(0,L.jsx)(lX,{})}),(0,L.jsx)($,{path:`/changepassword`,element:(0,L.jsx)(FY,{})}),(0,L.jsx)($,{path:`/security`,element:(0,L.jsx)(wZ,{})}),(0,L.jsx)($,{path:`/mfa`,element:(0,L.jsx)(nX,{})}),(0,L.jsx)($,{path:`/batch`,element:(0,L.jsx)(NY,{})}),(0,L.jsx)($,{path:`/bulk/:resourceType`,element:(0,L.jsx)(PY,{})}),(0,L.jsx)($,{path:`/smart`,element:(0,L.jsx)(DZ,{})}),(0,L.jsx)($,{path:`/forms/:id`,element:(0,L.jsx)(BY,{})}),(0,L.jsx)($,{path:`/admin/super`,element:(0,L.jsx)(Mq,{})}),(0,L.jsx)($,{path:`/admin/super/asyncjob/:tab`,element:(0,L.jsx)(vq,{})}),(0,L.jsx)($,{path:`/admin/super/asyncjob`,element:(0,L.jsx)(vq,{})}),(0,L.jsx)($,{path:`/admin/super/db/:tab`,element:(0,L.jsx)(GK,{})}),(0,L.jsx)($,{path:`/admin/super/db`,element:(0,L.jsx)(GK,{})}),(0,L.jsx)($,{path:`/admin/config`,element:(0,L.jsx)(ZK,{})}),(0,L.jsxs)($,{path:`/admin`,element:(0,L.jsx)(eq,{}),children:[(0,L.jsx)($,{path:`bots/:membershipId`,element:(0,L.jsx)(qK,{})}),(0,L.jsx)($,{path:`bots/new`,element:(0,L.jsx)(vK,{})}),(0,L.jsx)($,{path:`bots`,element:(0,L.jsx)(hK,{})}),(0,L.jsx)($,{path:`clients/:membershipId`,element:(0,L.jsx)(qK,{})}),(0,L.jsx)($,{path:`clients/new`,element:(0,L.jsx)(yK,{})}),(0,L.jsx)($,{path:`clients`,element:(0,L.jsx)(gK,{})}),(0,L.jsx)($,{path:`details`,element:(0,L.jsx)(QK,{})}),(0,L.jsx)($,{path:`invite`,element:(0,L.jsx)(KK,{})}),(0,L.jsx)($,{path:`patients`,element:(0,L.jsx)(HW,{to:`/admin/users`,replace:!0})}),(0,L.jsx)($,{path:`users/:membershipId`,element:(0,L.jsx)(qK,{})}),(0,L.jsx)($,{path:`users`,element:(0,L.jsx)(Lq,{})}),(0,L.jsx)($,{path:`project`,element:(0,L.jsx)(QK,{})}),(0,L.jsx)($,{path:`secrets`,element:(0,L.jsx)(hq,{})}),(0,L.jsx)($,{path:`sites`,element:(0,L.jsx)(gq,{})}),(0,L.jsx)($,{path:`rate-limits`,element:(0,L.jsx)(dq,{})})]}),(0,L.jsx)($,{path:`/lab/assays`,element:(0,L.jsx)(QY,{})}),(0,L.jsx)($,{path:`/lab/panels`,element:(0,L.jsx)(tX,{})}),(0,L.jsxs)($,{path:`/:resourceType/new`,element:(0,L.jsx)(LY,{}),children:[(0,L.jsx)($,{index:!0,element:(0,L.jsx)(IX,{})}),(0,L.jsx)($,{path:`form`,element:(0,L.jsx)(IX,{})}),(0,L.jsx)($,{path:`json`,element:(0,L.jsx)(RX,{})}),(0,L.jsx)($,{path:`profiles`,element:(0,L.jsx)(IX,{})})]}),(0,L.jsxs)($,{path:`/:resourceType/:id`,element:(0,L.jsx)(pZ,{}),children:[(0,L.jsx)($,{index:!0,element:(0,L.jsx)(_Z,{})}),(0,L.jsx)($,{path:`apply`,element:(0,L.jsx)(pX,{})}),(0,L.jsx)($,{path:`apps`,element:(0,L.jsx)(mX,{})}),(0,L.jsx)($,{path:`event`,element:(0,L.jsx)(gX,{})}),(0,L.jsx)($,{path:`blame`,element:(0,L.jsx)(_X,{})}),(0,L.jsx)($,{path:`bots`,element:(0,L.jsx)(XX,{})}),(0,L.jsx)($,{path:`builder`,element:(0,L.jsx)(EX,{})}),(0,L.jsx)($,{path:`checklist`,element:(0,L.jsx)(DX,{})}),(0,L.jsx)($,{path:`delete`,element:(0,L.jsx)(kX,{})}),(0,L.jsx)($,{path:`details`,element:(0,L.jsx)(jX,{})}),(0,L.jsx)($,{path:`edit`,element:(0,L.jsx)(MX,{})}),(0,L.jsx)($,{path:`editor`,element:(0,L.jsx)(CX,{})}),(0,L.jsxs)($,{path:`history`,children:[(0,L.jsx)($,{index:!0,element:(0,L.jsx)(LX,{})}),(0,L.jsx)($,{path:`:versionId/:tab`,element:(0,L.jsx)(mZ,{})}),(0,L.jsx)($,{path:`:versionId`,element:(0,L.jsx)(mZ,{})})]}),(0,L.jsxs)($,{path:`_history`,children:[(0,L.jsx)($,{index:!0,element:(0,L.jsx)(LX,{})}),(0,L.jsx)($,{path:`:versionId/:tab`,element:(0,L.jsx)(mZ,{})}),(0,L.jsx)($,{path:`:versionId`,element:(0,L.jsx)(mZ,{})})]}),(0,L.jsx)($,{path:`json`,element:(0,L.jsx)(zX,{})}),(0,L.jsx)($,{path:`preview`,element:(0,L.jsx)(GX,{})}),(0,L.jsx)($,{path:`responses`,element:(0,L.jsx)(QX,{})}),(0,L.jsx)($,{path:`report`,element:(0,L.jsx)(eZ,{})}),(0,L.jsx)($,{path:`ranges`,element:(0,L.jsx)($X,{})}),(0,L.jsx)($,{path:`subscriptions`,element:(0,L.jsx)(hZ,{})}),(0,L.jsx)($,{path:`timeline`,element:(0,L.jsx)(_Z,{})}),(0,L.jsx)($,{path:`tools`,element:(0,L.jsx)(CZ,{})}),(0,L.jsx)($,{path:`payload`,element:(0,L.jsx)(OX,{})}),(0,L.jsx)($,{path:`profiles`,element:(0,L.jsx)(KX,{})}),(0,L.jsx)($,{path:`accounts`,element:(0,L.jsx)(dX,{})}),(0,L.jsx)($,{path:`export`,element:(0,L.jsx)(NX,{})})]}),(0,L.jsx)($,{path:`/:resourceType`,element:(0,L.jsx)(ZY,{})}),(0,L.jsx)($,{path:`/`,element:(0,L.jsx)(ZY,{})})]})})}function AZ(){let e=Q(),t=e.getUserConfiguration(),n=eW(),[r]=qG();return e.isLoading()?(0,L.jsx)(Aj,{}):(0,L.jsxs)(RN,{logo:(0,L.jsx)(rP,{size:24}),pathname:n.pathname,searchParams:r,version:ID,menus:jZ(t),displayAddBookmark:!!t?.id,children:[(0,L.jsx)(iK,{}),(0,L.jsx)(b.Suspense,{fallback:(0,L.jsx)(Aj,{}),children:(0,L.jsx)(kZ,{})})]})}function jZ(e){let t=e?.menu?.map(e=>({title:e.title,links:e.link?.map(e=>({label:e.name,href:e.target,icon:NZ(e.target)}))||[]}))||[];return t.push({title:`Settings`,links:[{label:`Security`,href:`/security`,icon:(0,L.jsx)(XA,{})}]}),t}var MZ={Patient:yj,Practitioner:KA,Organization:xA,ServiceRequest:lj,DiagnosticReport:fj,Questionnaire:GA,Project:WA,admin:_A,AccessPolicy:YA,Subscription:Ej,batch:rj,Observation:tj};function NZ(e){if(e.includes(`admin/super/db`))return(0,L.jsx)(NA,{});try{let t=new URL(e,`https://app.medplum.com`).pathname.split(`/`)[1];if(t in MZ){let e=MZ[t];return(0,L.jsx)(e,{})}}catch{}}async function PZ(){let e=iX(),t=new JD({baseUrl:e.baseUrl,clientId:e.clientId,storagePrefix:`@medplum:`,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=ci({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=PG([{path:`*`,element:(0,L.jsx)(AZ,{})}]);(0,uK.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(b.StrictMode,{children:(0,L.jsx)(qO,{medplum:t,navigate:e=>r.navigate(e),children:(0,L.jsxs)(Br,{theme:n,children:[(0,L.jsx)(bx,{position:`bottom-right`}),(0,L.jsx)(RW,{router:r})]})})}))}PZ().catch(console.error);
237
- //# sourceMappingURL=index-D2cmDYW7.js.map
237
+ //# sourceMappingURL=index-88p4ji_G.js.map