@medplum/app 5.1.16 → 5.1.17

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.
@@ -53,7 +53,7 @@ ${o?`${s(`light`)}{${o}}`:``}`}function Dr({color:e,theme:t,autoContrast:n}){ret
53
53
  `),a=!1),Object.assign(Object.assign({},e),{allowNegative:a})}function v_(e){e=__(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,n=e.allowNegative,r=e.allowLeadingZeros,i=e.onKeyDown;i===void 0&&(i=Ng);var a=e.onBlur;a===void 0&&(a=Ng);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=jg(e,[`decimalSeparator`,`allowedDecimalSeparators`,`thousandsGroupStyle`,`suffix`,`allowNegative`,`allowLeadingZeros`,`onKeyDown`,`onBlur`,`thousandSeparator`,`decimalScale`,`fixedDecimalScale`,`prefix`,`defaultValue`,`value`,`valueIsNumericString`,`onValueChange`]),h=d_(e),g=h.decimalSeparator,_=h.allowedDecimalSeparators,v=function(t){return u_(t,e)},y=function(t,n){return h_(t,n,e)},b=Ig(d)?u:d,x=f??m_(b,l,t);Ig(d)?Ig(u)||(x||=typeof u==`number`):x||=typeof d==`number`;var S=function(e){return Rg(e)?e:(typeof e==`number`&&(e=qg(e)),x&&typeof s==`number`?Jg(e,s,!!c):e)},C=o_(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:Fg(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=Xg(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 g_(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&&Yg(t,1),s&&c&&(r===`Backspace`&&d[a-1]===g?(Yg(t,a-1),e.preventDefault()):r===`Delete`&&d[a]===g&&e.preventDefault()),_?.includes(r)&&d[a]===g&&Yg(t,a+1);var f=o===!0?`,`:o;r===`Backspace`&&d[a-1]===f&&Yg(t,a-1),r===`Delete`&&d[a]===f&&Yg(t,a+1),i(e)},onBlur:function(t){var n=T;n.match(/\d/g)||(n=``),r||(n=Wg(n)),c&&s&&(n=Jg(n,s,c)),n!==T&&D({formattedValue:u_(n,e),value:n,floatValue:parseFloat(n)},{event:t,source:Mg.event}),a(t)}})}function y_(e){var t=v_(e);return b.createElement(l_,Object.assign({},t))}var b_={root:`m_e2f5cd4e`,controls:`m_95e17d22`,control:`m_80b4b171`};function x_({direction:e,style:t,...n}){return(0,I.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,I.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 S_=/^(0\.0*|-0(\.0*)?)$/,C_=/^-?0\d+(\.\d+)?\.?$/,w_=/\.\d*0$/,T_=/^-?\d+\.$/;function E_(e){return typeof e==`string`&&e!==``&&!Number.isNaN(Number(e))}function D_(e){return typeof e==`number`?e<2**53-1:e===``||E_(e)&&Number(e)<2**53-1}function O_(e){return e.toString().replace(`.`,``).length}function k_(e,t){return(typeof e==`number`?e<2**53-1:!Number.isNaN(Number(e)))&&!Number.isNaN(e)&&O_(t)<14&&t!==``}function A_(e,t,n){return e===void 0?!0:(t===void 0||e>=t)&&(n===void 0||e<=n)}var j_={step:1,clampBehavior:`blur`,allowDecimal:!0,allowNegative:!0,withKeyboardEvents:!0,allowLeadingZeros:!0,trimLeadingZeroesOnBlur:!0,startValue:0,allowedDecimalSeparators:[`.`,`,`]},M_=An((e,{size:t})=>({controls:{"--ni-chevron-size":ft(t,`ni-chevron-size`)}}));function N_(e,t,n){let r=e.toString(),i=T_.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=Ct(o,n,t);return i?`${s.toString().replace(/^0+(?=\d)/,``)}.`:s}var P_=B((e,t)=>{let n=R(`NumberInput`,j_,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:ee,stepHoldDelay:N,allowLeadingZeros:P,withKeyboardEvents:te,trimLeadingZeroesOnBlur:ne,allowedDecimalSeparators:re,attributes:ie,...ae}=n,oe=L({name:`NumberInput`,classes:b_,props:n,classNames:i,styles:a,unstyled:o,attributes:ie,vars:s,varsResolver:M_}),{resolvedClassNames:se,resolvedStyles:ce}=Ur({classNames:i,styles:a,props:n}),[le,ue]=an({value:u,defaultValue:d,finalValue:``,onChange:c}),de=N!==void 0&&ee!==void 0,fe=(0,b.useRef)(null),pe=(0,b.useRef)(null),me=(0,b.useRef)(0),he=(e,t)=>{t.source===`event`&&ue(k_(e.floatValue,e.value)&&!S_.test(e.value)&&!(P&&C_.test(e.value))&&!w_.test(e.value)&&!T_.test(e.value)?e.floatValue:e.value),l?.(e,t)},ge=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},_e=e=>{fe.current&&e!==void 0&&fe.current.setSelectionRange(e,e)},ve=(0,b.useRef)(ut);ve.current=()=>{if(!D_(le))return;let e,t=ge(le),n=ge(m),r=Math.max(t,n),i=10**r;if(!E_(le)&&(typeof le!=`number`||Number.isNaN(le)))e=Ct(E,p,f);else if(f!==void 0){let t=(Math.round(Number(le)*i)+Math.round(m*i))/i;e=t<=f?t:f}else e=(Math.round(Number(le)*i)+Math.round(m*i))/i;let a=e.toFixed(r);ue(parseFloat(a)),l?.({floatValue:parseFloat(a),formattedValue:a,value:a},{source:`increment`}),setTimeout(()=>_e(fe.current?.value.length),0)};let ye=(0,b.useRef)(ut);ye.current=()=>{if(!D_(le))return;let e,t=p===void 0?k?-(2**53-1):0:p,n=ge(le),r=ge(m),i=Math.max(n,r),a=10**i;if(!E_(le)&&typeof le!=`number`||Number.isNaN(le))e=Ct(E,t,f);else{let n=(Math.round(Number(le)*a)-Math.round(m*a))/a;e=t!==void 0&&n<t?t:n}let o=e.toFixed(i);ue(parseFloat(o)),l?.({floatValue:parseFloat(o),formattedValue:o,value:o},{source:`decrement`}),setTimeout(()=>_e(fe.current?.value.length),0)};let be=e=>{let t=e.clipboardData.getData(`text`),n=ae.decimalSeparator||`.`,r=(re||[`.`,`,`]).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=fe.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(()=>_e(o),0)}}ae.onPaste?.(e)},xe=e=>{C?.(e),!(A||!te)&&(e.key===`ArrowUp`&&(e.preventDefault(),ve.current?.()),e.key===`ArrowDown`&&(e.preventDefault(),ye.current?.()))},Se=e=>{if(w?.(e),e.key===`Backspace`){let t=fe.current;t&&t.selectionStart===0&&t.selectionStart===t.selectionEnd&&(e.preventDefault(),window.setTimeout(()=>_e(0),0))}},Ce=e=>{let t=le;v===`blur`&&typeof t==`number`&&(t=Ct(t,p,f)),ne&&typeof t==`string`&&ge(t)<15&&(t=N_(t,f,p)),le!==t&&ue(t),y?.(e)};tn(T,{increment:ve.current,decrement:ye.current});let we=e=>{e?ve.current?.():ye.current?.(),me.current+=1},Te=e=>{if(we(e),de){let t=typeof ee==`number`?ee:ee(me.current);pe.current=window.setTimeout(()=>Te(e),t)}},Ee=(e,t)=>{e.preventDefault(),fe.current?.focus(),we(t),de&&(pe.current=window.setTimeout(()=>Te(t),N))},De=()=>{pe.current&&window.clearTimeout(pe.current),pe.current=null,me.current=0},Oe=(0,I.jsxs)(`div`,{...oe(`controls`),children:[(0,I.jsx)(ml,{...oe(`control`),tabIndex:-1,"aria-hidden":!0,disabled:D||typeof le==`number`&&f!==void 0&&le>=f,mod:{direction:`up`},onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{Ee(e,!0)},onPointerUp:De,onPointerLeave:De,children:(0,I.jsx)(x_,{direction:`up`})}),(0,I.jsx)(ml,{...oe(`control`),tabIndex:-1,"aria-hidden":!0,disabled:D||typeof le==`number`&&p!==void 0&&le<=p,mod:{direction:`down`},onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{Ee(e,!1)},onPointerUp:De,onPointerLeave:De,children:(0,I.jsx)(x_,{direction:`down`})})]});return(0,I.jsx)(md,{component:y_,allowNegative:k,className:Mn(b_.root,r),size:j,inputMode:`decimal`,...ae,readOnly:A,disabled:D,value:le,getInputRef:rn(t,fe),onValueChange:he,rightSection:h||A||!D_(le)?g:g||Oe,classNames:se,styles:ce,unstyled:o,__staticSelector:`NumberInput`,decimalScale:x?S:0,onPaste:be,onKeyDown:xe,onKeyDownCapture:Se,rightSectionPointerEvents:O??(D?`none`:void 0),rightSectionWidth:M??`var(--ni-right-section-width-${j||`sm`})`,allowLeadingZeros:P,allowedDecimalSeparators:re,onBlur:Ce,attributes:ie,isAllowed:e=>v===`strict`?_?_(e)&&A_(e.floatValue,p,f):A_(e.floatValue,p,f):_?_(e):!0})});P_.classes={...md.classes,...b_},P_.displayName=`@mantine/core/NumberInput`;var F_={root:`m_4addd315`,control:`m_326d024a`,dots:`m_4ad7767d`},[I_,L_]=et(`Pagination.Root component was not found in tree`),R_={withPadding:!0},z_=B((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,active:s,disabled:c,withPadding:l,mod:u,...d}=R(`PaginationControl`,R_,e),f=L_(),p=c||f.disabled;return(0,I.jsx)(ml,{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})});z_.classes=F_,z_.displayName=`@mantine/core/PaginationControl`;function B_({style:e,children:t,path:n,...r}){return(0,I.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,I.jsx)(`path`,{d:n,fill:`currentColor`})})}var V_=e=>(0,I.jsx)(B_,{...e,path:`M8.781 8l-3.3-3.3.943-.943L10.667 8l-4.243 4.243-.943-.943 3.3-3.3z`}),H_=e=>(0,I.jsx)(B_,{...e,path:`M7.219 8l3.3 3.3-.943.943L5.333 8l4.243-4.243.943.943-3.3 3.3z`}),U_=e=>(0,I.jsx)(B_,{...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`}),W_=e=>(0,I.jsx)(B_,{...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`}),G_={icon:e=>(0,I.jsx)(B_,{...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`})},K_=B((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,icon:s,...c}=R(`PaginationDots`,G_,e);return(0,I.jsx)(z,{ref:t,...L_().getStyles(`dots`,{className:r,style:i,styles:a,classNames:n}),...c,children:(0,I.jsx)(s,{style:{width:`calc(var(--pagination-control-size) / 1.8)`,height:`calc(var(--pagination-control-size) / 1.8)`}})})});K_.classes=F_,K_.displayName=`@mantine/core/PaginationDots`;function q_({icon:e,name:t,action:n,type:r}){let i={icon:e},a=(0,b.forwardRef)((e,a)=>{let{icon:o,...s}=R(t,i,e),c=L_(),l=r===`next`?c.active===c.total:c.active===1;return(0,I.jsx)(z_,{disabled:c.disabled||l,ref:a,onClick:c[n],withPadding:!1,...s,children:(0,I.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}`,Ri(a)}var J_=q_({icon:V_,name:`PaginationNext`,action:`onNext`,type:`next`}),Y_=q_({icon:H_,name:`PaginationPrevious`,action:`onPrevious`,type:`previous`}),X_=q_({icon:U_,name:`PaginationFirst`,action:`onFirst`,type:`previous`}),Z_=q_({icon:W_,name:`PaginationLast`,action:`onLast`,type:`next`});function Q_({dotsIcon:e}){let t=L_();return(0,I.jsx)(I.Fragment,{children:t.range.map((n,r)=>n===`dots`?(0,I.jsx)(K_,{icon:e},r):(0,I.jsx)(z_,{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))})}Q_.displayName=`@mantine/core/PaginationItems`;var $_={siblings:1,boundaries:1},ev=An((e,{size:t,radius:n,color:r,autoContrast:i})=>({root:{"--pagination-control-radius":n===void 0?void 0:mt(n),"--pagination-control-size":ft(t,`pagination-control-size`),"--pagination-control-fz":ht(t),"--pagination-active-bg":r?ar(r,e):void 0,"--pagination-active-color":oi(i,e)?Dr({color:r,theme:e,autoContrast:i}):void 0}})),tv=B((e,t)=>{let n=R(`PaginationRoot`,$_,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=L({name:`Pagination`,classes:F_,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:w,vars:c,varsResolver:ev}),{range:D,setPage:O,next:k,previous:A,active:j,first:M,last:ee}=cn({page:u,initialPage:d,onChange:f,total:l,siblings:m,boundaries:h});return(0,I.jsx)(I_,{value:{total:l,range:D,active:j,disabled:p,getItemProps:S,onChange:O,onNext:vt(v,k),onPrevious:vt(y,A),onFirst:vt(b,M),onLast:vt(x,ee),getStyles:E},children:(0,I.jsx)(z,{ref:t,...E(`root`),...T})})});tv.classes=F_,tv.displayName=`@mantine/core/PaginationRoot`;var nv={withControls:!0,withPages:!0,siblings:1,boundaries:1,gap:8},rv=B((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}=R(`Pagination`,nv,e);return u<=0||f&&u===1?null:(0,I.jsx)(tv,{ref:t,total:u,...m,children:(0,I.jsxs)(V,{gap:d,children:[n&&(0,I.jsx)(X_,{icon:c,...i?.(`first`)}),r&&(0,I.jsx)(Y_,{icon:o,...i?.(`previous`)}),p&&(0,I.jsx)(Q_,{dotsIcon:l}),r&&(0,I.jsx)(J_,{icon:a,...i?.(`next`)}),n&&(0,I.jsx)(Z_,{icon:s,...i?.(`last`)})]})})});rv.classes=F_,rv.displayName=`@mantine/core/Pagination`,rv.Root=tv,rv.Control=z_,rv.Dots=K_,rv.First=X_,rv.Last=Z_,rv.Next=J_,rv.Previous=Y_,rv.Items=Q_;var iv={root:`m_f61ca620`,input:`m_ccf8da4c`,innerInput:`m_f2d85dd2`,visibilityToggle:`m_b1072d44`},av={visibilityToggleIcon:({reveal:e})=>(0,I.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,I.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`})})},ov=An((e,{size:t})=>({root:{"--psi-icon-size":ft(t,`psi-icon-size`),"--psi-button-size":ft(t,`psi-button-size`)}})),sv=B((e,t)=>{let n=R(`PasswordInput`,av,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:ee,visibilityToggleButtonProps:N,rightSectionProps:P,leftSectionProps:te,leftSectionPointerEvents:ne,withErrorStyles:re,mod:ie,attributes:ae,...oe}=n,se=$t(p),[ce,le]=an({value:A,defaultValue:j,finalValue:!1,onChange:M}),ue=()=>le(!ce),de=L({name:`PasswordInput`,classes:iv,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:ae,vars:c,varsResolver:ov}),{resolvedClassNames:fe,resolvedStyles:pe}=Ur({classNames:r,styles:o,props:n}),{styleProps:me,rest:he}=pi(oe),ge=y?.id||`${se}-error`,_e=b?.id||`${se}-description`,ve=`${u&&typeof u!=`boolean`?ge:``} ${g?_e:``}`,ye=ve.trim().length>0?ve.trim():void 0,be=(0,I.jsx)(gu,{...de(`visibilityToggle`),disabled:f,radius:T,"aria-hidden":!N,"aria-pressed":ce,tabIndex:-1,...N,variant:N?.variant??`subtle`,color:`gray`,unstyled:s,onTouchEnd:e=>{e.preventDefault(),N?.onTouchEnd?.(e),ue()},onMouseDown:e=>{e.preventDefault(),N?.onMouseDown?.(e),ue()},onKeyDown:e=>{N?.onKeyDown?.(e),e.key===` `&&(e.preventDefault(),ue())},children:(0,I.jsx)(ee,{reveal:ce})});return(0,I.jsx)(dd.Wrapper,{required:l,id:se,label:_,error:u,description:g,size:v,classNames:fe,styles:pe,__staticSelector:`PasswordInput`,__stylesApiProps:n,unstyled:s,withAsterisk:S,inputWrapperOrder:C,inputContainer:h,variant:m,labelProps:{...x,htmlFor:se},descriptionProps:{...b,id:_e},errorProps:{...y,id:ge},mod:ie,attributes:ae,...de(`root`),...me,...w,children:(0,I.jsx)(dd,{component:`div`,error:u,leftSection:d,size:v,classNames:{...fe,input:Mn(iv.input,fe.input)},styles:pe,radius:T,disabled:f,__staticSelector:`PasswordInput`,__stylesApiProps:n,rightSectionWidth:D,rightSection:E??be,variant:m,unstyled:s,leftSectionWidth:k,rightSectionPointerEvents:O||`all`,rightSectionProps:P,leftSectionProps:te,leftSectionPointerEvents:ne,withAria:!1,withErrorStyles:re,attributes:ae,children:(0,I.jsx)(`input`,{required:l,"data-invalid":!!u||void 0,"data-with-left-section":!!d||void 0,...de(`innerInput`),disabled:f,id:se,ref:t,...he,"aria-describedby":ye,autoComplete:he.autoComplete||`off`,type:ce?`text`:`password`})})})});sv.classes={...md.classes,...iv},sv.displayName=`@mantine/core/PasswordInput`;var cv={root:`m_db6d6462`,section:`m_2242eb65`,"stripes-animation":`m_81a374bd`,"stripes-animation-vertical":`m_e0fb7a86`,label:`m_91e40b74`},[lv,uv]=et(`Progress.Root component was not found in tree`),dv=B((e,t)=>{let{classNames:n,className:r,style:i,styles:a,vars:o,...s}=R(`ProgressLabel`,null,e);return(0,I.jsx)(z,{ref:t,...uv().getStyles(`label`,{className:r,style:i,classNames:n,styles:a}),...s})});dv.classes=cv,dv.displayName=`@mantine/core/ProgressLabel`;var fv=An((e,{size:t,radius:n,transitionDuration:r})=>({root:{"--progress-size":ft(t,`progress-size`),"--progress-radius":n===void 0?void 0:mt(n),"--progress-transition-duration":typeof r==`number`?`${r}ms`:void 0}})),pv=B((e,t)=>{let n=R(`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=L({name:`Progress`,classes:cv,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:f,vars:c,varsResolver:fv});return(0,I.jsx)(lv,{value:{getStyles:h,autoContrast:l},children:(0,I.jsx)(z,{ref:t,mod:[{orientation:d},p],...h(`root`),...m})})});pv.classes=cv,pv.displayName=`@mantine/core/ProgressRoot`;var mv={withAria:!0},hv=B((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}=R(`ProgressSection`,mv,e),m=uv(),h=Sr(),g=c?{role:`progressbar`,"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":s,"aria-valuetext":`${s}%`}:{};return(0,I.jsx)(z,{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":ar(l,h),"--progress-label-color":oi(m.autoContrast,h)?Dr({color:l,theme:h,autoContrast:m.autoContrast}):void 0}})});hv.classes=cv,hv.displayName=`@mantine/core/ProgressSection`;var gv=B((e,t)=>{let n=R(`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}=Ur({classNames:i,styles:a,props:n});return(0,I.jsx)(pv,{ref:t,classNames:f,styles:p,vars:o,...d,children:(0,I.jsx)(hv,{value:r,color:s,striped:c,animated:l,"aria-label":u})})});gv.classes=cv,gv.displayName=`@mantine/core/Progress`,gv.Section=hv,gv.Root=pv,gv.Label=dv;var _v={root:`m_f3f1af94`,inner:`m_89c4f5e4`,icon:`m_f3ed6b2b`,radio:`m_8a3dbb89`,"radio--outline":`m_1bfe9d39`},[vv,yv]=tt(),[bv,xv]=tt(),Sv={card:`m_9dc8ae12`},Cv={withBorder:!0},wv=An((e,{radius:t})=>({card:{"--card-radius":mt(t)}})),Tv=B((e,t)=>{let n=R(`RadioCard`,Cv,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=L({name:`RadioCard`,classes:Sv,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:g,vars:c,varsResolver:wv,rootSelector:`card`}),{dir:y}=Yi(),b=yv(),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,I.jsx)(bv,{value:{checked:x},children:(0,I.jsx)(ml,{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})})});Tv.displayName=`@mantine/core/RadioCard`,Tv.classes=Sv;var Ev=B((e,t)=>{let{value:n,defaultValue:r,onChange:i,size:a,wrapperProps:o,children:s,name:c,readOnly:l,disabled:u,...d}=R(`RadioGroup`,null,e),f=$t(c),[p,m]=an({value:n,defaultValue:r,finalValue:``,onChange:i});return(0,I.jsx)(vv,{value:{value:p,onChange:e=>!l&&m(typeof e==`string`?e:e.currentTarget.value),size:a,name:f,disabled:u},children:(0,I.jsx)(dd.Wrapper,{size:a,ref:t,...o,...d,labelElement:`div`,__staticSelector:`RadioGroup`,children:(0,I.jsx)($f,{role:`radiogroup`,children:s})})})});Ev.classes=dd.Wrapper.classes,Ev.displayName=`@mantine/core/RadioGroup`;function Dv({size:e,style:t,...n}){return(0,I.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 5 5`,style:{width:F(e),height:F(e),...t},"aria-hidden":!0,...n,children:(0,I.jsx)(`circle`,{cx:`2.5`,cy:`2.5`,r:`2.5`,fill:`currentColor`})})}var Ov={indicator:`m_717d7ff6`,icon:`m_3e4da632`,"indicator--outline":`m_2980836c`},kv={icon:Dv},Av=An((e,{radius:t,color:n,size:r,iconColor:i,variant:a,autoContrast:o})=>{let s=ir({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":ft(r,`radio-size`),"--radio-radius":t===void 0?void 0:mt(t),"--radio-color":a===`outline`?c:ar(n,e),"--radio-icon-size":ft(r,`radio-icon-size`),"--radio-icon-color":i?ar(i,e):oi(o,e)?Dr({color:n,theme:e,autoContrast:o}):void 0}}}),jv=B((e,t)=>{let n=R(`RadioIndicator`,kv,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=L({name:`RadioIndicator`,classes:Ov,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:v,vars:c,varsResolver:Av,rootSelector:`indicator`}),x=xv(),S=typeof m==`boolean`?m:x?.checked||!1;return(0,I.jsx)(z,{ref:t,...b(`indicator`,{variant:g}),variant:g,mod:[{checked:S,disabled:_},h],...y,children:(0,I.jsx)(l,{...b(`icon`)})})});jv.displayName=`@mantine/core/RadioIndicator`,jv.classes=Ov;var Mv={labelPosition:`right`},Nv=An((e,{size:t,radius:n,color:r,iconColor:i,variant:a,autoContrast:o})=>{let s=ir({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":ft(t,`radio-size`),"--radio-radius":n===void 0?void 0:mt(n),"--radio-color":a===`outline`?c:ar(r,e),"--radio-icon-color":i?ar(i,e):oi(o,e)?Dr({color:r,theme:e,autoContrast:o}):void 0,"--radio-icon-size":ft(t,`radio-icon-size`)}}}),Pv=B((e,t)=>{let n=R(`Radio`,Mv,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=Dv,rootRef:x,iconColor:S,onChange:C,mod:w,attributes:T,checked:E,...D}=n,O=L({name:`Radio`,classes:_v,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:T,vars:c,varsResolver:Nv}),k=yv(),A=k?.size??u,j=n.size?u:A,{styleProps:M,rest:ee}=pi(D),N=$t(l),P=k?k.value===ee.value:void 0,te={checked:P??E,name:k?.name??ee.name,onChange:e=>{k?.onChange(e),C?.(e)},disabled:k?.disabled??v};return(0,I.jsx)(Hf,{...O(`root`),__staticSelector:`Radio`,__stylesApiProps:n,id:N,size:j,labelPosition:f,label:d,description:p,error:m,disabled:te.disabled,classNames:r,styles:o,unstyled:s,"data-checked":(P??E)||void 0,variant:_,ref:x,mod:w,...M,...y,children:(0,I.jsxs)(z,{...O(`inner`),mod:{"label-position":f},children:[(0,I.jsx)(z,{...O(`radio`,{focusable:!0,variant:_}),...ee,...te,component:`input`,mod:{error:!!m},ref:t,id:N,type:`radio`}),(0,I.jsx)(b,{...O(`icon`),"aria-hidden":!0})]})})});Pv.classes=_v,Pv.displayName=`@mantine/core/Radio`,Pv.Group=Ev,Pv.Card=Tv,Pv.Indicator=jv;var Fv={duration:100,transition:`fade`};function Iv(e,t){return{...Fv,...t,...e}}var Lv={tooltip:`m_1b3c8819`,arrow:`m_f898399f`};function Rv({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}=wc({placement:t,middleware:[Ps({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=xa(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 zv={refProp:`ref`,withinPortal:!0,offset:10,position:`right`,zIndex:lt(`popover`)},Bv=An((e,{radius:t,color:n})=>({tooltip:{"--tooltip-radius":t===void 0?void 0:mt(t),"--tooltip-bg":n?ar(n,e):void 0,"--tooltip-color":n?`var(--mantine-color-white)`:void 0}})),Vv=B((e,t)=>{let n=R(`TooltipFloating`,zv,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=Sr(),D=L({name:`TooltipFloating`,props:n,classes:Lv,className:s,style:o,classNames:c,styles:l,unstyled:u,attributes:w,rootSelector:`tooltip`,vars:S,varsResolver:Bv}),{handleMouseMove:O,x:k,y:A,opened:j,boundaryRef:M,floating:ee,setOpened:N}=Rv({offset:m,position:h,defaultOpened:y}),P=kn(r);if(!P)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 te=rn(M,Tn(P),t),ne=P.props,re=e=>{ne.onMouseEnter?.(e),O(e),N(!0)},ie=e=>{ne.onMouseLeave?.(e),N(!1)};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Pl,{...C,withinPortal:a,children:(0,I.jsx)(z,{...T,...D(`tooltip`,{style:{...Li(o,E),zIndex:_,display:!v&&j?`block`:`none`,top:(A&&Math.round(A))??``,left:(k&&Math.round(k))??``}}),variant:x,ref:ee,mod:{multiline:g},children:p})}),(0,b.cloneElement)(P,{...ne,[i]:te,onMouseEnter:re,onMouseLeave:ie})]})});Vv.classes=Lv,Vv.displayName=`@mantine/core/TooltipFloating`;var Hv=(0,b.createContext)(!1),Uv=Hv.Provider,Wv=()=>(0,b.useContext)(Hv),Gv={openDelay:0,closeDelay:0};function Kv(e){let{openDelay:t,closeDelay:n,children:r}=R(`TooltipGroup`,Gv,e);return(0,I.jsx)(Uv,{value:!0,children:(0,I.jsx)(_c,{delay:{open:t,close:n},children:r})})}Kv.displayName=`@mantine/core/TooltipGroup`,Kv.extend=e=>e;function qv(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 Jv(e){let t=qv(e.middlewares),n=[Ns(e.offset)];return t.shift&&n.push(Ps(typeof t.shift==`boolean`?{padding:8}:{padding:8,...t.shift})),t.flip&&n.push(typeof t.flip==`boolean`?Is():Is(t.flip)),n.push(Bs({element:e.arrowRef,padding:e.arrowOffset})),t.inline?n.push(typeof t.inline==`boolean`?zs():zs(t.inline)):e.inline&&n.push(zs()),n}function Yv(e){let[t,n]=(0,b.useState)(e.defaultOpened),r=typeof e.opened==`boolean`?e.opened:t,i=Wv(),a=$t(),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}={}}}=wc({strategy:e.strategy,placement:e.position,open:r,onOpenChange:o,middleware:Jv(e),whileElementsMounted:hs}),{delay:m,currentId:h,setCurrentId:g}=vc(l,{id:a}),{getReferenceProps:_,getFloatingProps:v}=Oc([pc(l,{enabled:e.events?.hover,delay:i?m:{open:e.openDelay,close:e.closeDelay},mouseOnly:!e.events?.touch}),Ec(l,{enabled:e.events?.focus,visibleOnly:!0}),Ac(l,{role:`tooltip`}),Sc(l,{enabled:e.opened===void 0})]);Lt(()=>{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 Xv={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:lt(`popover`),positionDependencies:[],middlewares:{flip:!0,shift:!0,inline:!1}},Zv=An((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:mt(t),"--tooltip-bg":n?a.background:void 0,"--tooltip-color":n?a.color:void 0}}}),Qv=B((e,t)=>{let n=R(`Tooltip`,Xv,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:ee,onMouseEnter:N,onMouseLeave:P,inline:te,variant:ne,keepMounted:re,vars:ie,portalProps:ae,mod:oe,floatingStrategy:se,middlewares:ce,autoContrast:le,attributes:ue,target:de,...fe}=R(`Tooltip`,Xv,n),{dir:pe}=Yi(),me=(0,b.useRef)(null),he=Yv({position:Tl(pe,i),closeDelay:c,openDelay:s,onPositionChange:l,opened:u,defaultOpened:d,events:k,arrowRef:me,arrowOffset:C,offset:typeof E==`number`?E+(x?S/2:0):E,positionDependencies:[...M,de??r],inline:te,strategy:se,middlewares:ce});(0,b.useEffect)(()=>{let e=de instanceof HTMLElement?de:typeof de==`string`?document.querySelector(de):de?.current||null;e&&he.reference(e)},[de,he]);let ge=L({name:`Tooltip`,props:n,classes:Lv,className:y,style:v,classNames:h,styles:g,unstyled:_,attributes:ue,rootSelector:`tooltip`,vars:ie,varsResolver:Zv}),_e=kn(r);if(!de&&!_e)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(de){let e=Iv(D,{duration:100,transition:`fade`});return(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(Pl,{...ae,withinPortal:f,children:(0,I.jsx)(Bl,{...e,keepMounted:re,mounted:!j&&!!he.opened,duration:he.isGroupPhase?10:e.duration,children:e=>(0,I.jsxs)(z,{...fe,"data-fixed":se===`fixed`||void 0,variant:ne,mod:[{multiline:O},oe],...he.getFloatingProps({ref:he.floating,className:ge(`tooltip`).className,style:{...ge(`tooltip`).style,...e,zIndex:A,top:he.y??0,left:he.x??0}}),children:[o,(0,I.jsx)(wl,{ref:me,arrowX:he.arrowX,arrowY:he.arrowY,visible:x,position:he.placement,arrowSize:S,arrowOffset:C,arrowRadius:w,arrowPosition:T,...ge(`arrow`)})]})})})})}let ve=_e.props,ye=rn(he.reference,Tn(_e),t),be=Iv(D,{duration:100,transition:`fade`});return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Pl,{...ae,withinPortal:f,children:(0,I.jsx)(Bl,{...be,keepMounted:re,mounted:!j&&!!he.opened,duration:he.isGroupPhase?10:be.duration,children:e=>(0,I.jsxs)(z,{...fe,"data-fixed":se===`fixed`||void 0,variant:ne,mod:[{multiline:O},oe],...he.getFloatingProps({ref:he.floating,className:ge(`tooltip`).className,style:{...ge(`tooltip`).style,...e,zIndex:A,top:he.y??0,left:he.x??0}}),children:[o,(0,I.jsx)(wl,{ref:me,arrowX:he.arrowX,arrowY:he.arrowY,visible:x,position:he.placement,arrowSize:S,arrowOffset:C,arrowRadius:w,arrowPosition:T,...ge(`arrow`)})]})})}),(0,b.cloneElement)(_e,he.getReferenceProps({onClick:ee,onMouseEnter:N,onMouseLeave:P,onMouseMove:n.onMouseMove,onPointerDown:n.onPointerDown,onPointerEnter:n.onPointerEnter,...ve,className:Mn(y,ve.className),[a]:ye}))]})});Qv.classes=Lv,Qv.displayName=`@mantine/core/Tooltip`,Qv.Floating=Vv,Qv.Group=Kv;function $v({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 ey({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=Sr();return(0,I.jsx)(Qv.Floating,{disabled:!c,label:c,children:(0,I.jsx)(z,{component:`circle`,...d,...l(`curve`),__vars:{"--curve-color":o?ar(o,f):void 0},fill:`none`,strokeLinecap:s?`round`:`butt`,...$v({sum:r,size:e,thickness:i,value:t,offset:n,root:a})})})}ey.displayName=`@mantine/core/Curve`;function ty({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 ny={root:`m_b32e4812`,svg:`m_d43b5134`,curve:`m_b1ca1fbf`,label:`m_b23f9dc4`};function ry(e,t){return Math.min(e||12,(t||120)/4)}var iy={size:120,thickness:12},ay=An((e,{size:t,thickness:n,transitionDuration:r})=>({root:{"--rp-size":F(t),"--rp-label-offset":F(n*2),"--rp-transition-duration":r?`${r}ms`:void 0}})),oy=B((e,t)=>{let n=R(`RingProgress`,iy,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=L({name:`RingProgress`,classes:ny,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:g,vars:c,varsResolver:ay}),y=ry(f,d),x=ty({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)(ey,{...e,key:a,size:d,thickness:y,sum:t,offset:i,color:e?.color,root:n,lineRoundCaps:r,getStyles:v}));return(0,I.jsxs)(z,{...v(`root`),size:d,ref:t,..._,children:[(0,I.jsx)(`svg`,{...v(`svg`),children:x}),l&&(0,I.jsx)(`div`,{...v(`label`),children:l})]})});oy.classes=ny,oy.displayName=`@mantine/core/RingProgress`;var sy={root:`m_cf365364`,indicator:`m_9e182ccd`,label:`m_1738fcb2`,input:`m_1714d588`,control:`m_69686b9b`,innerLabel:`m_78882f40`},cy={withItemsBorders:!0},ly=An((e,{radius:t,color:n,transitionDuration:r,size:i,transitionTimingFunction:a})=>({root:{"--sc-radius":t===void 0?void 0:mt(t),"--sc-color":n?ar(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":ft(i,`sc-padding`),"--sc-font-size":ht(i)}})),uy=B((e,t)=>{let n=R(`SegmentedControl`,cy,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=L({name:`SegmentedControl`,props:n,classes:sy,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:O,vars:c,varsResolver:ly}),j=Sr(),M=l.map(e=>typeof e==`string`?{label:e,value:e}:e),ee=Cn(),[N,P]=(0,b.useState)(wt()),[te,ne]=(0,b.useState)(null),[re,ie]=(0,b.useState)({}),ae=(e,t)=>{re[t]=e,ie(re)},[oe,se]=an({value:u,defaultValue:d,finalValue:Array.isArray(l)?M.find(e=>!e.disabled)?.value??l[0]?.value??null:null,onChange:f}),ce=$t(m),le=M.map(e=>(0,b.createElement)(z,{...A(`control`),mod:{active:oe===e.value,orientation:v},key:e.value},(0,b.createElement)(`input`,{...A(`input`),disabled:h||e.disabled,type:`radio`,name:ce,value:e.value,id:`${ce}-${e.value}`,checked:oe===e.value,onChange:()=>!g&&se(e.value),"data-focus-ring":j.focusRing,key:`${e.value}-input`}),(0,b.createElement)(z,{component:`label`,...A(`label`),mod:{active:oe===e.value&&!(h||e.disabled),disabled:h||e.disabled,"read-only":g},htmlFor:`${ce}-${e.value}`,ref:t=>ae(t,e.value),__vars:{"--sc-label-color":x===void 0?void 0:Dr({color:x,theme:j,autoContrast:T})},key:`${e.value}-label`},(0,I.jsx)(`span`,{...A(`innerLabel`),children:e.label})))),ue=rn(t,e=>ne(e));return fn(()=>{P(wt())},[l.length]),l.length===0?null:(0,I.jsxs)(z,{...A(`root`),variant:w,size:p,ref:ue,mod:[{"full-width":_,orientation:v,initialized:ee,"with-items-borders":E},D],...k,role:`radiogroup`,"data-disabled":h,children:[typeof oe==`string`&&(0,I.jsx)(Sd,{target:re[oe],parent:te,component:`span`,transitionDuration:`var(--sc-transition-duration)`,...A(`indicator`)},N),le]})});uy.classes=sy,uy.displayName=`@mantine/core/SegmentedControl`;var dy={container:`m_925c2d2c`,root:`m_2415a157`};function fy({spacing:e,verticalSpacing:t,cols:n,selector:r}){let i=Sr(),a=t===void 0?e:t,o=Xe({"--sg-spacing-x":pt(xt(e)),"--sg-spacing-y":pt(xt(a)),"--sg-cols":xt(n)?.toString()}),s=Ve(i.breakpoints).reduce((t,r)=>(t[r]||(t[r]={}),typeof e==`object`&&e[r]!==void 0&&(t[r][`--sg-spacing-x`]=pt(e[r])),typeof a==`object`&&a[r]!==void 0&&(t[r][`--sg-spacing-y`]=pt(a[r])),typeof n==`object`&&n[r]!==void 0&&(t[r][`--sg-cols`]=n[r]),t),{});return(0,I.jsx)(fi,{styles:o,media:bt(Ve(s),i.breakpoints).filter(e=>Ve(s[e.value]).length>0).map(e=>({query:`(min-width: ${i.breakpoints[e.value]})`,styles:s[e.value]})),selector:r})}function py(e){return typeof e==`object`&&e?Ve(e):[]}function my(e){return e.sort((e,t)=>Ke(e)-Ke(t))}function hy({spacing:e,verticalSpacing:t,cols:n}){return my(Array.from(new Set([...py(e),...py(t),...py(n)])))}function gy({spacing:e,verticalSpacing:t,cols:n,selector:r}){let i=t===void 0?e:t,a=Xe({"--sg-spacing-x":pt(xt(e)),"--sg-spacing-y":pt(xt(i)),"--sg-cols":xt(n)?.toString()}),o=hy({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`]=pt(e[r])),typeof i==`object`&&i[r]!==void 0&&(t[r][`--sg-spacing-y`]=pt(i[r])),typeof n==`object`&&n[r]!==void 0&&(t[r][`--sg-cols`]=n[r]),t),{});return(0,I.jsx)(fi,{styles:a,container:o.map(e=>({query:`simple-grid (min-width: ${e})`,styles:s[e]})),selector:r})}var _y={cols:1,spacing:`md`,type:`media`},vy=B((e,t)=>{let n=R(`SimpleGrid`,_y,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=L({name:`SimpleGrid`,classes:dy,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:p,vars:c}),g=Ii();return f===`container`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(gy,{...n,selector:`.${g}`}),(0,I.jsx)(`div`,{...h(`container`),children:(0,I.jsx)(z,{ref:t,...h(`root`,{className:g}),...m})})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(fy,{...n,selector:`.${g}`}),(0,I.jsx)(z,{ref:t,...h(`root`,{className:g}),...m})]})});vy.classes=dy,vy.displayName=`@mantine/core/SimpleGrid`;var yy={root:`m_18320242`,"skeleton-fade":`m_299c329c`},by={visible:!0,animate:!0},xy=An((e,{width:t,height:n,radius:r,circle:i})=>({root:{"--skeleton-height":F(n),"--skeleton-width":F(i?n:t),"--skeleton-radius":i?`1000px`:r===void 0?void 0:mt(r)}})),Sy=B((e,t)=>{let n=R(`Skeleton`,by,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,I.jsx)(z,{ref:t,...L({name:`Skeleton`,classes:yy,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:g,vars:c,varsResolver:xy})(`root`),mod:[{visible:f,animate:m},h],..._})});Sy.classes=yy,Sy.displayName=`@mantine/core/Skeleton`;var Cy=B((e,t)=>{let{w:n,h:r,miw:i,mih:a,...o}=R(`Space`,null,e);return(0,I.jsx)(z,{ref:t,...o,w:n,miw:i??n,h:r,mih:a??r})});Cy.displayName=`@mantine/core/Space`;var wy={root:`m_6d731127`},Ty={gap:`md`,align:`stretch`,justify:`flex-start`},Ey=An((e,{gap:t,align:n,justify:r})=>({root:{"--stack-gap":pt(t),"--stack-align":n,"--stack-justify":r}})),G=B((e,t)=>{let n=R(`Stack`,Ty,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,I.jsx)(z,{ref:t,...L({name:`Stack`,props:n,classes:wy,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:p,vars:c,varsResolver:Ey})(`root`),variant:f,...m})});G.classes=wy,G.displayName=`@mantine/core/Stack`;var[Dy,Oy]=et(`Stepper component was not found in tree`),ky={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`},Ay=()=>null;Ay.displayName=`@mantine/core/StepperCompleted`;var jy=(e,t)=>typeof e==`function`?(0,I.jsx)(e,{step:t||0}):e,My={withIcon:!0,allowStepClick:!0,iconPosition:`left`},Ny=B((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}=R(`StepperStep`,My,e),w=Oy(),T=Sr(),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,I.jsxs)(ml,{...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?ar(l,T):void 0},tabIndex:v?0:-1,children:[h&&(0,I.jsxs)(`span`,{...w.getStyles(`stepWrapper`,E),children:[(0,I.jsxs)(`span`,{...w.getStyles(`stepIcon`,E),...O,children:[(0,I.jsx)(Bl,{mounted:c===`stepCompleted`,transition:`pop`,duration:200,children:e=>(0,I.jsx)(`span`,{...w.getStyles(`stepCompletedIcon`,{style:e,...E}),children:_?(0,I.jsx)(cu,{color:`var(--mantine-color-white)`,size:`calc(var(--stepper-icon-size) / 2)`,...w.getStyles(`stepLoader`,E)}):jy(d,s)||(0,I.jsx)(tp,{size:`60%`})})}),c===`stepCompleted`?null:(0,I.jsx)(`span`,{children:_?(0,I.jsx)(cu,{...w.getStyles(`stepLoader`,E),size:`calc(var(--stepper-icon-size) / 2)`,color:l}):jy(D||u,s)})]}),x===`vertical`&&(0,I.jsx)(`span`,{...w.getStyles(`verticalSeparator`,E),"data-active":c===`stepCompleted`||void 0})]}),(p||m)&&(0,I.jsxs)(`span`,{...w.getStyles(`stepBody`,E),"data-orientation":w.orientation,"data-icon-position":b||w.iconPosition,children:[p&&(0,I.jsx)(`span`,{...w.getStyles(`stepLabel`,E),children:jy(p,s)}),m&&(0,I.jsx)(`span`,{...w.getStyles(`stepDescription`,E),children:jy(m,s)})]})]})});Ny.classes=ky,Ny.displayName=`@mantine/core/StepperStep`;var Py={orientation:`horizontal`,iconPosition:`left`,allowNextStepsSelect:!0,wrap:!0},Fy=An((e,{color:t,iconSize:n,size:r,contentPadding:i,radius:a,autoContrast:o})=>({root:{"--stepper-color":t?ar(t,e):void 0,"--stepper-icon-color":oi(o,e)?Dr({color:t,theme:e,autoContrast:o}):void 0,"--stepper-icon-size":n===void 0?ft(r,`stepper-icon-size`):F(n),"--stepper-content-padding":pt(i),"--stepper-radius":a===void 0?void 0:mt(a),"--stepper-fz":ht(r),"--stepper-spacing":pt(r)}})),Iy=B((e,t)=>{let n=R(`Stepper`,Py,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=L({name:`Stepper`,classes:ky,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:E,vars:c,varsResolver:Fy}),k=b.Children.toArray(l),A=k.filter(e=>e.type!==Ay),j=k.find(e=>e.type===Ay),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},[]),ee=A[d]?.props?.children,N=j?.props?.children,P=d>A.length-1?N:ee;return(0,I.jsx)(Dy,{value:{getStyles:O,orientation:v,iconPosition:y},children:(0,I.jsxs)(z,{...O(`root`),ref:t,size:x,...D,children:[(0,I.jsx)(z,{...O(`steps`),mod:{orientation:v,"icon-position":y,wrap:w&&v!==`vertical`},children:M}),P&&(0,I.jsx)(`div`,{...O(`content`),children:P})]})})});Iy.classes=ky,Iy.displayName=`@mantine/core/Stepper`,Iy.Completed=Ay,Iy.Step=Ny;var Ly={root:`m_5f93f3bb`,input:`m_926b4011`,track:`m_9307d992`,thumb:`m_93039a1d`,trackLabel:`m_8277e082`},Ry=(0,b.createContext)(null),zy=Ry.Provider,By=()=>(0,b.useContext)(Ry),Vy=B((e,t)=>{let{value:n,defaultValue:r,onChange:i,size:a,wrapperProps:o,children:s,readOnly:c,disabled:l,...u}=R(`SwitchGroup`,null,e),[d,f]=an({value:n,defaultValue:r,finalValue:[],onChange:i});return(0,I.jsx)(zy,{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,I.jsx)(dd.Wrapper,{size:a,ref:t,...o,...u,labelElement:`div`,__staticSelector:`SwitchGroup`,children:(0,I.jsx)($f,{role:`group`,children:s})})})});Vy.classes=dd.Wrapper.classes,Vy.displayName=`@mantine/core/SwitchGroup`;var Hy={labelPosition:`right`,withThumbIndicator:!0},Uy=An((e,{radius:t,color:n,size:r})=>({root:{"--switch-radius":t===void 0?void 0:mt(t),"--switch-height":ft(r,`switch-height`),"--switch-width":ft(r,`switch-width`),"--switch-thumb-size":ft(r,`switch-thumb-size`),"--switch-label-font-size":ft(r,`switch-label-font-size`),"--switch-track-label-padding":ft(r,`switch-track-label-padding`),"--switch-color":n?ar(n,e):void 0}})),Wy=B((e,t)=>{let n=R(`Switch`,Hy,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=By(),M=m||j?.size,ee=L({name:`Switch`,props:n,classes:Ly,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:k,vars:c,varsResolver:Uy}),{styleProps:N,rest:P}=pi(A),te=$t(p),ne={checked:j?.value.includes(P.value)??v,onChange:e=>{j?.onChange(e),b?.(e)},disabled:j?.disabled??w},[re,ie]=an({value:ne.checked??v,defaultValue:y,finalValue:!1});return(0,I.jsxs)(Hf,{...ee(`root`),__staticSelector:`Switch`,__stylesApiProps:n,id:te,size:M,labelPosition:x,label:u,description:S,error:C,disabled:ne.disabled,bodyElement:`label`,labelElement:`span`,classNames:r,styles:o,unstyled:s,"data-checked":ne.checked,variant:T,ref:E,mod:D,inert:P.inert,...N,...g,children:[(0,I.jsx)(`input`,{...P,...ne,checked:re,"data-checked":ne.checked,onChange:e=>{ne.onChange?.(e),ie(e.currentTarget.checked)},id:te,ref:t,type:`checkbox`,role:`switch`,inert:P.inert,...ee(`input`)}),(0,I.jsxs)(z,{"aria-hidden":`true`,component:`span`,mod:{error:C,"label-position":x,"without-labels":!f&&!d},...ee(`track`),children:[(0,I.jsx)(z,{component:`span`,mod:{"reduce-motion":!0,"with-thumb-indicator":O&&!_},...ee(`thumb`),children:_}),(0,I.jsx)(`span`,{...ee(`trackLabel`),children:re?f:d})]})]})});Wy.classes={...Ly,...Vf},Wy.displayName=`@mantine/core/Switch`,Wy.Group=Vy;var[Gy,Ky]=et(`Table component was not found in the tree`),qy={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 Jy(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 Yy(e,t){let n=`Table${e.charAt(0).toUpperCase()}${e.slice(1)}`,r=B((r,i)=>{let a=R(n,{},r),{classNames:o,className:s,style:c,styles:l,...u}=a,d=Ky();return(0,I.jsx)(z,{component:e,ref:i,...Jy(d,t),...d.getStyles(e,{className:s,classNames:o,style:c,styles:l,props:a}),...u})});return r.displayName=`@mantine/core/${n}`,r.classes=qy,r}var Xy=Yy(`th`,{columnBorder:!0}),Zy=Yy(`td`,{columnBorder:!0}),Qy=Yy(`tr`,{rowBorder:!0,striped:!0,highlightOnHover:!0}),$y=Yy(`thead`,{stickyHeader:!0}),eb=Yy(`tbody`),tb=Yy(`tfoot`),nb=Yy(`caption`,{captionSide:!0});function rb({data:e}){return(0,I.jsxs)(I.Fragment,{children:[e.caption&&(0,I.jsx)(nb,{children:e.caption}),e.head&&(0,I.jsx)($y,{children:(0,I.jsx)(Qy,{children:e.head.map((e,t)=>(0,I.jsx)(Xy,{children:e},t))})}),e.body&&(0,I.jsx)(eb,{children:e.body.map((e,t)=>(0,I.jsx)(Qy,{children:e.map((e,t)=>(0,I.jsx)(Zy,{children:e},t))},t))}),e.foot&&(0,I.jsx)(tb,{children:(0,I.jsx)(Qy,{children:e.foot.map((e,t)=>(0,I.jsx)(Xy,{children:e},t))})})]})}rb.displayName=`@mantine/core/TableDataRenderer`;var ib={type:`scrollarea`},ab=An((e,{minWidth:t,maxHeight:n,type:r})=>({scrollContainer:{"--table-min-width":F(t),"--table-max-height":F(n),"--table-overflow":r===`native`?`auto`:void 0}})),ob=B((e,t)=>{let n=R(`TableScrollContainer`,ib,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=L({name:`TableScrollContainer`,classes:qy,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:m,vars:c,varsResolver:ab,rootSelector:`scrollContainer`});return(0,I.jsx)(z,{component:f===`scrollarea`?ul:`div`,...f===`scrollarea`?d?{offsetScrollbars:`xy`,...p}:{offsetScrollbars:`x`,...p}:{},ref:t,...g(`scrollContainer`),...h,children:(0,I.jsx)(`div`,{...g(`scrollContainerInner`),children:l})})});ob.classes=qy,ob.displayName=`@mantine/core/TableScrollContainer`;var sb={withRowBorders:!0,verticalSpacing:7},cb=An((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":pt(r),"--table-vertical-spacing":pt(i),"--table-border-color":a?ar(a,e):void 0,"--table-striped-color":c&&o?ar(o,e):void 0,"--table-highlight-on-hover-color":l&&s?ar(s,e):void 0,"--table-sticky-header-offset":d?F(u):void 0}})),K=B((e,t)=>{let n=R(`Table`,sb,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=L({name:`Table`,props:n,className:i,style:a,classes:qy,classNames:r,styles:o,unstyled:s,attributes:O,rootSelector:`table`,vars:c,varsResolver:cb});return(0,I.jsx)(Gy,{value:{getStyles:A,stickyHeader:w,striped:m===!0?`odd`:m||void 0,highlightOnHover:h,withColumnBorders:g,withRowBorders:_,captionSide:d||`bottom`},children:(0,I.jsx)(z,{component:`table`,variant:x,ref:t,mod:[{"data-with-table-border":v,"data-tabular-nums":D},E],...A(`table`),...k,children:C||!!S&&(0,I.jsx)(rb,{data:S})})})});K.classes=qy,K.displayName=`@mantine/core/Table`,K.Td=Zy,K.Th=Xy,K.Tr=Qy,K.Thead=$y,K.Tbody=eb,K.Tfoot=tb,K.Caption=nb,K.ScrollContainer=ob,K.DataRenderer=rb;var[lb,ub]=et(`Tabs component was not found in the tree`),db={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`},fb=B((e,t)=>{let n=R(`TabsList`,null,e),{children:r,className:i,grow:a,justify:o,classNames:s,styles:c,style:l,mod:u,...d}=n,f=ub();return(0,I.jsx)(z,{...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})});fb.classes=db,fb.displayName=`@mantine/core/TabsList`;var pb=B((e,t)=>{let n=R(`TabsPanel`,null,e),{children:r,className:i,value:a,classNames:o,styles:s,style:c,mod:l,keepMounted:u,...d}=n,f=ub(),p=f.value===a,m=f.keepMounted||u||p?r:null;return(0,I.jsx)(z,{...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})});pb.classes=db,pb.displayName=`@mantine/core/TabsPanel`;var mb=B((e,t)=>{let n=R(`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=Sr(),{dir:b}=Yi(),x=ub(),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,I.jsxs)(ml,{...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?ar(d,y):void 0},onKeyDown:st({siblingSelector:`[role="tab"]`,parentSelector:`[role="tablist"]`,activateOnFocus:x.activateTabWithKeyboard,loop:x.loop,orientation:x.orientation||`horizontal`,dir:b,onKeyDown:l}),...v,children:[o&&(0,I.jsx)(`span`,{...x.getStyles(`tabSection`,w),"data-position":`left`,children:o}),i&&(0,I.jsx)(`span`,{...x.getStyles(`tabLabel`,w),children:i}),a&&(0,I.jsx)(`span`,{...x.getStyles(`tabSection`,w),"data-position":`right`,children:a})]})});mb.classes=db,mb.displayName=`@mantine/core/TabsTab`;var hb=`Tabs.Tab or Tabs.Panel component was rendered with invalid value or without value`,gb={keepMounted:!0,orientation:`horizontal`,loop:!0,activateTabWithKeyboard:!0,variant:`default`,placement:`left`},_b=An((e,{radius:t,color:n,autoContrast:r})=>({root:{"--tabs-radius":mt(t),"--tabs-color":ar(n,e),"--tabs-text-color":oi(r,e)?Dr({color:n,theme:e,autoContrast:r}):void 0}})),vb=B((e,t)=>{let n=R(`Tabs`,gb,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=$t(l),[k,A]=an({value:i,defaultValue:r,finalValue:null,onChange:a}),j=L({name:`Tabs`,props:n,classes:db,className:x,style:S,classNames:v,styles:y,unstyled:b,attributes:E,vars:C,varsResolver:_b});return(0,I.jsx)(lb,{value:{placement:g,value:k,orientation:o,id:O,loop:c,activateTabWithKeyboard:u,getTabId:nt(`${O}-tab`,hb),getPanelId:nt(`${O}-panel`,hb),onChange:A,allowTabDeactivation:d,variant:f,color:p,radius:m,inverted:h,keepMounted:_,unstyled:b,getStyles:j},children:(0,I.jsx)(z,{ref:t,id:O,variant:f,mod:[{orientation:o,inverted:o===`horizontal`&&h,placement:o===`vertical`&&g},T],...j(`root`),...D,children:s})})});vb.classes=db,vb.displayName=`@mantine/core/Tabs`,vb.Tab=mb,vb.Panel=pb,vb.List=fb;var yb=B((e,t)=>(0,I.jsx)(md,{component:`input`,ref:t,...R(`TextInput`,null,e),__staticSelector:`TextInput`}));yb.classes=md.classes,yb.displayName=`@mantine/core/TextInput`;var bb={root:`m_7341320d`},xb=An((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":ft(t,`ti-size`),"--ti-radius":n===void 0?void 0:mt(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}}}),Sb=B((e,t)=>{let n=R(`ThemeIcon`,null,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,autoContrast:l,attributes:u,...d}=n;return(0,I.jsx)(z,{ref:t,...L({name:`ThemeIcon`,classes:bb,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:u,vars:c,varsResolver:xb})(`root`),...d})});Sb.classes=bb,Sb.displayName=`@mantine/core/ThemeIcon`;var Cb=[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],wb=[`xs`,`sm`,`md`,`lg`,`xl`];function Tb(e,t){let n=t===void 0?`h${e}`:t;return Cb.includes(n)?{fontSize:`var(--mantine-${n}-font-size)`,fontWeight:`var(--mantine-${n}-font-weight)`,lineHeight:`var(--mantine-${n}-line-height)`}:wb.includes(n)?{fontSize:`var(--mantine-font-size-${n})`,fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}:{fontSize:F(n),fontWeight:`var(--mantine-h${e}-font-weight)`,lineHeight:`var(--mantine-h${e}-line-height)`}}var Eb={root:`m_8a5d1357`},Db={order:1},Ob=An((e,{order:t,size:n,lineClamp:r,textWrap:i})=>{let a=Tb(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}}}),q=B((e,t)=>{let n=R(`Title`,Db,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,_=L({name:`Title`,props:n,classes:Eb,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:h,vars:l,varsResolver:Ob});return[1,2,3,4,5,6].includes(c)?(0,I.jsx)(z,{..._(`root`),component:`h${c}`,variant:d,ref:t,mod:[{order:c,"data-line-clamp":typeof f==`number`},m],size:u,...g}):null});q.classes=Eb,q.displayName=`@mantine/core/Title`;function kb(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 Ab(e){return(0,b.useSyncExternalStore)(e.subscribe,()=>e.getState(),()=>e.getState())}function jb(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 Mb=kb({notifications:[],queue:[],defaultPosition:`bottom-right`,limit:5}),Nb=(e=Mb)=>Ab(e);function Pb(e,t){let n=e.getState(),r=jb(t([...n.notifications,...n.queue]),n.defaultPosition,n.limit);e.setState({notifications:r.notifications,queue:r.queue,limit:n.limit,defaultPosition:n.defaultPosition})}function J(e,t=Mb){let n=e.id||wt();return Pb(t,t=>e.id&&t.some(t=>t.id===e.id)?t:[...t,{...e,id:n}]),n}function Fb(e,t=Mb){return Pb(t,t=>t.filter(t=>t.id===e?(t.onClose?.(t),!1):!0)),e}function Ib(e,t=Mb){return Pb(t,t=>t.map(t=>t.id===e.id?{...t,...e}:t)),e.id}function Lb(e=Mb){Pb(e,()=>[])}function Rb(e=Mb){Pb(e,t=>t.slice(0,e.getState().limit))}var zb={show:J,hide:Fb,update:Ib,clean:Lb,cleanQueue:Rb,updateState:Pb};function Bb(e,t){return Bb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Bb(e,t)}function Vb(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Bb(e,t)}var Hb=o(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Ub=o(((e,t)=>{var n=Hb();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}})),Wb=o(((e,t)=>{t.exports=Ub()()})),Gb={disabled:!1},Kb=b.createContext(null),qb=function(e){return e.scrollTop},Jb=`unmounted`,Yb=`exited`,Xb=`entering`,Zb=`entered`,Qb=`exiting`,$b=function(e){Vb(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=Yb,r.appearStatus=Xb):o=Zb:o=t.unmountOnExit||t.mountOnEnter?Jb:Yb,r.state={status:o},r.nextCallback=null,r}t.getDerivedStateFromProps=function(e,t){return e.in&&t.status===`unmounted`?{status:Yb}: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=Xb):(n===`entering`||n===`entered`)&&(t=Qb)}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:Ts.default.findDOMNode(this);n&&qb(n)}this.performEnter(e)}else this.performExit();else this.props.unmountOnExit&&this.state.status===`exited`&&this.setState({status:Jb})},n.performEnter=function(e){var t=this,n=this.props.enter,r=this.context?this.context.isMounting:e,i=this.props.nodeRef?[r]:[Ts.default.findDOMNode(this),r],a=i[0],o=i[1],s=this.getTimeouts(),c=r?s.appear:s.enter;if(!e&&!n||Gb.disabled){this.safeSetState({status:Zb},function(){t.props.onEntered(a)});return}this.props.onEnter(a,o),this.safeSetState({status:Xb},function(){t.props.onEntering(a,o),t.onTransitionEnd(c,function(){t.safeSetState({status:Zb},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:Ts.default.findDOMNode(this);if(!t||Gb.disabled){this.safeSetState({status:Yb},function(){e.props.onExited(r)});return}this.props.onExit(r),this.safeSetState({status:Qb},function(){e.props.onExiting(r),e.onTransitionEnd(n.exit,function(){e.safeSetState({status:Yb},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:Ts.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=Rm(t,[`children`,`in`,`mountOnEnter`,`unmountOnExit`,`appear`,`enter`,`exit`,`timeout`,`addEndListener`,`onEnter`,`onEntering`,`onEntered`,`onExit`,`onExiting`,`onExited`,`nodeRef`]);return b.createElement(Kb.Provider,{value:null},typeof n==`function`?n(e,r):b.cloneElement(b.Children.only(n),r))},t}(b.Component);$b.contextType=Kb,$b.propTypes={};function ex(){}$b.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:ex,onEntering:ex,onEntered:ex,onExit:ex,onExiting:ex,onExited:ex},$b.UNMOUNTED=Jb,$b.EXITED=Yb,$b.ENTERING=Xb,$b.ENTERED=Zb,$b.EXITING=Qb;function tx(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function nx(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 rx(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 ix(e,t,n){return n[t]==null?e.props[t]:n[t]}function ax(e,t){return nx(e.children,function(n){return(0,b.cloneElement)(n,{onExited:t.bind(null,n),in:!0,appear:ix(n,`appear`,e),enter:ix(n,`enter`,e),exit:ix(n,`exit`,e)})})}function ox(e,t,n){var r=nx(e.children),i=rx(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:ix(o,`exit`,e),enter:ix(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:ix(o,`exit`,e),enter:ix(o,`enter`,e)}))}}),i}var sx=Object.values||function(e){return Object.keys(e).map(function(t){return e[t]})},cx={component:`div`,childFactory:function(e){return e}},lx=function(e){Vb(t,e);function t(t,n){var r=e.call(this,t,n)||this;return r.state={contextValue:{isMounting:!0},handleExited:r.handleExited.bind(tx(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?ax(e,r):ox(e,n,r),firstRender:!1}},n.handleExited=function(e,t){var n=nx(this.props.children);e.key in n||(e.props.onExited&&e.props.onExited(t),this.mounted&&this.setState(function(t){var n=Lm({},t.children);return delete n[e.key],{children:n}}))},n.render=function(){var e=this.props,t=e.component,n=e.childFactory,r=Rm(e,[`component`,`childFactory`]),i=this.state.contextValue,a=sx(this.state.children).map(n);return delete r.appear,delete r.enter,delete r.exit,t===null?b.createElement(Kb.Provider,{value:i},a):b.createElement(Kb.Provider,{value:i},b.createElement(t,r,a))},t}(b.Component);lx.propTypes={},lx.defaultProps=cx;var ux=[`bottom-center`,`bottom-left`,`bottom-right`,`top-center`,`top-left`,`top-right`];function dx(e,t){return e.reduce((e,n)=>(e[n.position||t].push(n),e),ux.reduce((e,t)=>(e[t]=[],e),{}))}var fx={left:`translateX(-100%)`,right:`translateX(100%)`,"top-center":`translateY(-100%)`,"bottom-center":`translateY(100%)`},px={left:`translateX(0)`,right:`translateX(0)`,"top-center":`translateY(0)`,"bottom-center":`translateY(0)`};function mx({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:fx[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:px[o]},l={opacity:0,maxHeight:0,transform:fx[o]},u={entering:c,entered:c,exiting:l,exited:l};return{...s,...u[e]}}function hx(e,t){return typeof t==`number`?t:t===!1||e===!1?!1:e}var gx=(0,b.forwardRef)(({data:e,onHide:t,autoClose:n,...r},i)=>{let{autoClose:a,message:o,...s}=e,c=hx(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,I.jsx)(Ag,{...r,...s,onClose:d,ref:i,onMouseEnter:u,onMouseLeave:f,children:o})});gx.displayName=`@mantine/notifications/NotificationContainer`;var _x={root:`m_b37d9ac7`,notification:`m_5ed0edd0`},vx=$b,yx={position:`bottom-right`,autoClose:4e3,transitionDuration:250,containerWidth:440,notificationMaxHeight:200,limit:5,zIndex:lt(`overlay`),store:Mb,withinPortal:!0},bx=An((e,{zIndex:t,containerWidth:n})=>({root:{"--notifications-z-index":t?.toString(),"--notifications-container-width":F(n)}})),xx=B((e,t)=>{let n=R(`Notifications`,yx,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=Sr(),S=Nb(g),C=Xt(),w=ln(),T=(0,b.useRef)({}),E=(0,b.useRef)(0),D=x.respectReducedMotion&&w?1:d,O=L({name:`Notifications`,classes:_x,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,vars:c,varsResolver:bx});(0,b.useEffect)(()=>{g?.updateState(e=>({...e,limit:m||5,defaultPosition:l}))},[m,l]),Lt(()=>{S.notifications.length>E.current&&setTimeout(()=>C(),0),E.current=S.notifications.length},[S.notifications]);let k=dx(S.notifications,l),A=ux.reduce((e,t)=>(e[t]=k[t].map(({style:e,...n})=>(0,I.jsx)(vx,{timeout:D,onEnter:()=>T.current[n.id].offsetHeight,nodeRef:{current:T.current[n.id]},children:r=>(0,I.jsx)(gx,{ref:e=>{e&&(T.current[n.id]=e)},data:n,onHide:e=>Fb(e,g),autoClose:u,...O(`notification`,{style:{...mx({state:r,position:t,transitionDuration:D,maxHeight:p}),...e}})})},n.id)),e),{});return(0,I.jsxs)(Pl,{withinPortal:v,..._,children:[(0,I.jsx)(z,{...O(`root`),"data-position":`top-center`,ref:t,...y,children:(0,I.jsx)(lx,{children:A[`top-center`]})}),(0,I.jsx)(z,{...O(`root`),"data-position":`top-left`,...y,children:(0,I.jsx)(lx,{children:A[`top-left`]})}),(0,I.jsx)(z,{...O(`root`,{className:Be.classNames.fullWidth}),"data-position":`top-right`,...y,children:(0,I.jsx)(lx,{children:A[`top-right`]})}),(0,I.jsx)(z,{...O(`root`,{className:Be.classNames.fullWidth}),"data-position":`bottom-right`,...y,children:(0,I.jsx)(lx,{children:A[`bottom-right`]})}),(0,I.jsx)(z,{...O(`root`),"data-position":`bottom-left`,...y,children:(0,I.jsx)(lx,{children:A[`bottom-left`]})}),(0,I.jsx)(z,{...O(`root`),"data-position":`bottom-center`,...y,children:(0,I.jsx)(lx,{children:A[`bottom-center`]})})]})});xx.classes=_x,xx.displayName=`@mantine/notifications/Notifications`,xx.show=zb.show,xx.hide=zb.hide,xx.update=zb.update,xx.clean=zb.clean,xx.cleanQueue=zb.cleanQueue,xx.updateState=zb.updateState;var Sx=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}},Cx=class{operator;child;constructor(e,t){this.operator=e,this.child=t}toString(){return`${this.operator}(${this.child.toString()})`}},wx=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()})`}},Tx=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 Ex(e,this.prefixParselets,this.infixParselets)}},Ex=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 Dx(e){if(e!==void 0)return Array.isArray(e)?e:[e]}var Ox=`http://hl7.org`,kx=`ok`,Ax=`created`,jx=`gone`,Mx=`not-modified`,Nx=`not-found`,Px=`unauthorized`,Fx=`forbidden`,Ix=`accepted`,Lx={resourceType:`OperationOutcome`,id:kx,issue:[{severity:`information`,code:`informational`,details:{text:`All OK`}}]},Rx={resourceType:`OperationOutcome`,id:Nx,issue:[{severity:`error`,code:`not-found`,details:{text:`Not found`}}]},zx={resourceType:`OperationOutcome`,id:Px,issue:[{severity:`error`,code:`login`,details:{text:`Unauthorized`}}]},Bx={...zx,issue:[...zx.issue,{severity:`error`,code:`expired`,details:{text:`Token expired`}}]},Vx={...zx,issue:[...zx.issue,{severity:`error`,code:`invalid`,details:{text:`Token not issued for this audience`}}]},Hx={resourceType:`OperationOutcome`,id:Fx,issue:[{severity:`error`,code:`forbidden`,details:{text:`Forbidden`}}]};function Ux(e,t){return{resourceType:`OperationOutcome`,issue:[{severity:`error`,code:`invalid`,details:{text:e},...t?{expression:Dx(t)}:void 0}]}}function Wx(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 Gx(e){return e?.issue?.[0]?.details?.coding?.find(e=>e.system===`urn:ietf:rfc:3986`)?.code}function Kx(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 qx(e){return typeof e==`object`&&!!e&&e.resourceType===`OperationOutcome`}function Jx(e){return e.id===kx||e.id===Ax||e.id===Mx||e.id===Ix}function Yx(e){return e.id===jx}var Xx=class extends Error{outcome;constructor(e,t){super($x(e),t),this.name=`OperationOutcomeError`,this.outcome=e}};function Zx(e){return e instanceof Xx?e.outcome:qx(e)?e:Ux(Qx(e))}function Qx(e){return e?typeof e==`string`?e:Kx(e)?e.message:qx(e)?$x(e):typeof e==`object`&&`code`in e&&typeof e.code==`string`?e.code:JSON.stringify(e):`Unknown error`}function $x(e){let t=e.issue?.map(eS)??[];return t.length>0?t.join(`; `):`Unknown error`}function eS(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 tS(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 nS(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,tS(e,t)])),constraints:[],innerTypes:[]};return t}var rS={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 iS(e){return new _S(e).parse()}var aS=nS(rS),oS=Object.create(null),sS=Object.create(null),cS={"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 lS(e){let t;return t=sS[e],t||=sS[e]=Object.create(null),t}function uS(e){let t=(Array.isArray(e)?e:e.entry?.map(e=>e.resource)??[]).filter(e=>e?.resourceType===`StructureDefinition`);kw(t);for(let e of t)dS(e)}function dS(e){if(!e?.name)throw Error(`Failed loading StructureDefinition from bundle`);if(e.resourceType!==`StructureDefinition`)return;let t=iS(e),n=cS[e.url],r,i;n?(r=aS,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=aS,i=e.type):(r=lS(e.url),i=e.type),r[i]=t;for(let e of t.innerTypes)e.parentType=t,r[e.name]=e;oS[e.url]=t}function fS(e){return!!aS[e]}function pS(e,t){if(t){let n=lS(t)[e];if(n)return n}return aS[e]}function mS(e,t){let n=pS(e,t);if(!n)throw new Xx(Ux(`Unknown data type: `+e));return n}function hS(e){return!!oS[e]}function gS(e){return oS[e]}var _S=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:wS(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=yS(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[yS(e,n.path)]=t;break}n=n.parent}if(!n){let n=yS(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&&!xS(this.slicingContext.path,e?.path)&&(this.slicingContext=void 0),e.slicing&&!this.slicingContext&&this.enterSlice(e,t)}enterInnerType(e){for(;this.backboneContext&&!xS(this.backboneContext?.path,e.path);)this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;let t=Mw(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:xS(this.backboneContext?.path,e.path)?this.backboneContext:this.backboneContext?.parent}}enterSlice(e,t){CS(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&&!xS(this.backboneContext.path,e?.path))if(this.backboneContext.parent)do this.innerTypes.push(this.backboneContext.type),this.backboneContext=this.backboneContext.parent;while(this.backboneContext&&!xS(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!!(xS(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=Mw(e)),n||=vC(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=vS(e.max),n=e.base?.max?vS(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:SS(PS(r,`fixed[x]`)),pattern:SS(PS(r,`pattern[x]`)),binding:e.binding}}};function vS(e){return e===`*`?1/0:Number.parseInt(e,10)}function yS(e,t=``){return bS(e.path,t)}function bS(e,t){return e?t&&e.startsWith(t)?e.substring(t.length+1):e:``}function xS(e,t){return!e||!t?!1:t.startsWith(e+`.`)||t===e}function SS(e){return Array.isArray(e)&&e.length>0?e[0]:CC(e)?void 0:e}function CS(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 wS(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 TS(e,t,n){if(e===void 0)return[void 0];if(t===`$this`)return[e];let r=n?.withPath?ES:PS,[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 ES(e,t,n){let r=e.path;return DS(PS(e,t,n),r,t)}function DS(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 Sx(1e3);var OS={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 kS(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 kC(e,i.pattern);if(i.fixed)return EC(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 AS(e){return[{type:Y.boolean,value:e}]}function jS(e){return e==null?{type:`undefined`,value:void 0}:Number.isSafeInteger(e)?{type:Y.integer,value:e}:typeof e==`number`?{type:Y.decimal,value:e}:typeof e==`boolean`?{type:Y.boolean,value:e}:typeof e==`string`?{type:Y.string,value:e}:QS(e)?{type:Y.Quantity,value:e}:Hw(e)?{type:e.resourceType,value:e}:LC(e)?{type:Y.CodeableConcept,value:e}:IC(e)?{type:Y.Coding,value:e}:{type:Y.BackboneElement,value:e}}function MS(e){return e.length===0?!1:!!e[0].value}function NS(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 PS(e,t,n){if(!e.value)return;let r=Bw(e.type,t,n?.profileUrl);return r?FS(e,t,r):LS(e,t)}function FS(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+=UC(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]=nC(a[e],s[e])}else if(!a&&Array.isArray(s)){a=s.slice();for(let e=0;e<s.length;e++)a[e]=nC(void 0,s[e])}else a=nC(a,s);if(!CC(a))return(o===`Element`||o===`BackboneElement`)&&(o=n.type[0].code),Array.isArray(a)?a.map(e=>IS(e,o)):IS(a,o)}function IS(e,t){return t===`Resource`&&Hw(e)&&(t=e.resourceType),{type:t,value:e}}function LS(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(jS):jS(e)}else{let e=t.endsWith(`[x]`)?t.substring(0,t.length-3):t;for(let t of Object.values(Y)){let i=e+UC(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||CC(r[0]))return}else if(CC(r))return;return r}function RS(e){let t=[];for(let n of e){let e=!1;for(let r of t)if(MS(HS(n,r))){e=!0;break}e||t.push(n)}return t}function zS(e){return AS(!MS(e))}function BS(e,t){return e.length===0||t.length===0?[]:e.length===t.length?AS(e.every((e,n)=>MS(HS(e,t[n])))):AS(!1)}function VS(e,t){return e.length===0||t.length===0?[]:e.length===t.length?AS(e.some((e,n)=>!MS(HS(e,t[n])))):AS(!0)}function HS(e,t){let n=e.value?.valueOf(),r=t.value?.valueOf();return typeof n==`number`&&typeof r==`number`?AS(Math.abs(n-r)<1e-8):QS(n)&&QS(r)?AS($S(n,r)):AS(typeof n==`object`&&typeof r==`object`?eC(e,t):n===r)}function US(e,t){return e.length===0&&t.length===0?AS(!0):e.length===t.length?(e.sort(GS),t.sort(GS),AS(e.every((e,n)=>MS(WS(e,t[n]))))):AS(!1)}function WS(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`?AS(Math.abs(o-s)<.01):QS(o)&&QS(s)?AS($S(o,s)):AS(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`?eC({...o,id:void 0},{...s,id:void 0}):typeof o==`string`&&typeof s==`string`?o.toLowerCase()===s.toLowerCase():o===s)}function GS(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 KS(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 qS(n);case`DateTime`:return JS(n);case`Time`:return typeof n==`string`&&!!/^T\d/.exec(n);case`Period`:return YS(n);case`Quantity`:return QS(n);default:return e.type===r||typeof n==`object`&&n?.resourceType===r}}function qS(e){return typeof e==`string`&&!!OS.date.exec(e)}function JS(e){return typeof e==`string`&&!!OS.dateTime.exec(e)}function YS(e){return!!(e&&typeof e==`object`&&(`start`in e&&JS(e.start)||`end`in e&&JS(e.end)))}function XS(e){if(qS(e)||JS(e))return{start:ZS(e,`0000-01-01T00:00:00.000`),end:ZS(e,`xxxx-12-31T23:59:59.999`)};if(YS(e))return{start:e.start?ZS(e.start,`0000-01-01T00:00:00.000`):void 0,end:e.end?ZS(e.end,`xxxx-12-31T23:59:59.999`):void 0}}function ZS(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 QS(e){return!!(e&&typeof e==`object`&&`value`in e&&typeof e.value==`number`)}function $S(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 eC(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(tC(n)&&tC(i)){if(!eC(n,i))return!1}else if(n!==i)return!1}return!0}function tC(e){return typeof e==`object`&&!!e}function nC(e,t){if(t){if(typeof t!=`object`)throw Error(`Primitive extension must be an object`);return rC(e??{},t)}return e}function rC(e,t){return delete t.__proto__,delete t.constructor,Object.assign(e,t)}function iC(e,t){return Hw(e,t)&&`id`in e&&typeof e.id==`string`}function aC(e){let t=oC(e)??`undefined/undefined`,n=uC(e);return n===t?{reference:t}:{reference:t,display:n}}function oC(e){if(Uw(e))return e.reference;if(iC(e))return`${e.resourceType}/${e.id}`}function sC(e){if(e)return Uw(e)?e.reference.split(`/`)[1]:e.id}function cC(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 Dx(e.accounts??e.account)}function lC(e){return e.resourceType===`Patient`||e.resourceType===`Practitioner`||e.resourceType===`RelatedPerson`}function uC(e){if(lC(e)){let t=dC(e);if(t)return t}if(e.resourceType===`Device`){let t=fC(e);if(t)return t}if(e.resourceType===`MedicationRequest`&&e.medicationCodeableConcept)return Sw(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]),LC(t))return Sw(t);if(RC(t))return t.text}return oC(e)??``}function dC(e){let t=e.name;if(t&&t.length>0)return lw(t[0])}function fC(e){let t=e.deviceName;if(t&&t.length>0)return t[0].name}function pC(e){if(!(`photo`in e))return;let t=e.photo;if(t)if(Array.isArray(t))for(let e of t){let t=mC(e);if(t)return t}else return mC(t)}function mC(e){if(e.url&&e.contentType?.startsWith(`image/`))return e.url}function hC(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 gC(e,t){let{years:n,months:r,days:i}=hC(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 _C(e,t){let n=e.identifier;if(!n)return;let r=Array.isArray(n)?n:[n];for(let e of r)if(e.system===t)return e.value}function vC(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 yC(e,t){let n=bC(e);return JSON.stringify(n,null,t?2:void 0)??``}function bC(e){if(!(e==null||e===``))return typeof e==`object`?Array.isArray(e)?xC(e):SC(e):e}function xC(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=bC(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 SC(e){let t,n=0;for(let r in e){let i=e[r],a=bC(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 CC(e){if(e==null)return!0;let t=typeof e;return t===`string`||t===`object`?!wC(e):!1}function wC(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 TC(e){if(!e)return;let t=e.length-1;for(;t>=0&&CC(e[t]);)t--;return t>=0?e.slice(0,t+1):void 0}function EC(e,t,n){return e===t||CC(e)&&CC(t)?!0:CC(e)||CC(t)?!1:Array.isArray(e)&&Array.isArray(t)?DC(e,t):Array.isArray(e)||Array.isArray(t)?!1:PC(e)&&PC(t)?OC(e,t,n):!1}function DC(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!EC(e[n],t[n]))return!1;return!0}function OC(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(!EC(r,i,n))return!1}return!0}function kC(e,t){return CC(e)?!0:CC(t)?!1:Array.isArray(e)&&Array.isArray(t)?AC(e,t):Array.isArray(e)||Array.isArray(t)?!1:PC(e)&&PC(t)?jC(e,t):PC(e)||PC(t)?!1:e===t}function AC(e,t){return t.every(t=>e.some(e=>kC(e,t)))}function jC(e,t){return Object.entries(t).every(([t,n])=>t in e&&kC(e[t],n))}function MC(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function NC(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 PC(e){return typeof e==`object`&&!!e}function FC(e){return typeof e==`string`}function IC(e){return PC(e)&&`code`in e&&typeof e.code==`string`}function LC(e){return PC(e)&&`coding`in e&&Array.isArray(e.coding)&&e.coding.every(IC)}function RC(e){return PC(e)&&`text`in e&&typeof e.text==`string`}var zC=[];for(let e=0;e<256;e++)zC.push(e.toString(16).padStart(2,`0`));function BC(e){let t=HC(e),n=new Uint8Array(t),r=Array(n.length);for(let e=0;e<n.length;e++)r[e]=zC[n[e]];return r.join(``)}function VC(e){let t=HC(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 HC(e){return ArrayBuffer.isView(e)?e.buffer:e}function UC(e){return e?e.charAt(0).toUpperCase()+e.substring(1):``}function WC(e){return e.length>0&&e.startsWith(e[0].toUpperCase())}function GC(e,t){let n=e+`.`;if(t.startsWith(n))return t.slice(n.length)}function KC(e,t){return e.coding?.find(e=>e.system===t)?.code}var qC=(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 JC(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 YC(e){let t,n=!1;return function(){return n||=(t=e(),!0),t}}function XC(e,t){return e?(e.push(t),e):[t]}function ZC(e){return e.sort((e,t)=>e.localeCompare(t))}function QC(e){return e.endsWith(`/`)?e:e+`/`}function $C(e){return e.startsWith(`/`)?e.slice(1):e}function ew(e,t){return new URL($C(t),QC(e.toString())).toString()}function tw(e,t){return ew(e,t).toString().replace(`http://`,`ws://`).replace(`https://`,`wss://`)}function nw(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 rw(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 iw(e,t){if(e?.meta?.profile?.includes(t)){let n=e.meta.profile.indexOf(t);e.meta.profile.splice(n,1)}return e}var aw=Object.freeze([]);function ow(e){if(!e)return``;switch(e.type){case`Address`:return cw(e.value);case`CodeableConcept`:return Sw(e.value);case`Coding`:return Cw(e.value);case`ContactPoint`:return e.value.value;case`HumanName`:return lw(e.value);case`Quantity`:return bw(e.value);case`Reference`:return sw(e.value);default:return e.value?.toString()??``}}function sw(e){return e?e.display??e.reference??yC(e):``}function cw(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 lw(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=Tw(e.text);if(t)return t}return n.join(` `).trim()}function uw(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function dw(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 uw(o)?new Intl.DateTimeFormat(t,{hour:`numeric`,minute:`2-digit`,second:a===0?void 0:`numeric`,...n,timeZone:`UTC`}).format(o):``}function fw(e,t,n){if(!e)return``;let r=new Date(e);return uw(r)?r.toLocaleString(t,n):``}function pw(e,t,n){return!e||!e.start&&!e.end?``:fw(e.start,t,n)+` - `+fw(e.end,t,n)}var mw={s:`every second`,min:`every minute`,h:`hourly`,d:`daily`,wk:`weekly`,mo:`monthly`,a:`annually`},hw={s:`second`,min:`minute`,h:`hour`,d:`day`,wk:`week`,mo:`month`,a:`year`},gw={s:`seconds`,min:`minutes`,h:`hours`,d:`days`,wk:`weeks`,mo:`months`,a:`years`};function _w(e){if(!e)return``;let t=[];return vw(t,e.repeat),e.event&&t.push(e.event.map(e=>fw(e)).join(`, `)),UC(t.join(` `).trim())}function vw(e,t){if(!t?.periodUnit)return;let n=t.frequency??1,r=t.period??1,i=t.periodUnit;n===1&&r===1?e.push(mw[i]):(n===1?e.push(`once`):e.push(n+` times`),r===1?e.push(`per `+hw[i]):e.push(`per `+r+` `+gw[i])),t.dayOfWeek&&e.push(`on `+t.dayOfWeek.map(UC).join(`, `)),t.timeOfDay&&e.push(`at `+t.timeOfDay.map(e=>dw(e)).join(`, `))}function yw(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=Dw(r.value,t),`> ${bw(r,t)}`):`>= ${bw(r,t)}`:r?.value===void 0&&i?.value!==void 0?n&&t!==void 0?(i.value=Ew(i.value,t),`< ${bw(i,t)}`):`<= ${bw(i,t)}`:(r?.unit===i?.unit&&delete r?.unit,`${bw(r,t)} - ${bw(i,t)}`)}function bw(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 xw(e){return e?.value===void 0?``:e.value.toLocaleString(void 0,{style:`currency`,currency:e.currency??`USD`,currencyDisplay:`narrowSymbol`})}function Sw(e){return e?Tw(e.text)||(e.coding?e.coding.map(e=>Cw(e)).join(`, `):``):``}function Cw(e,t){let n=Tw(e?.display);if(n){let r=t?Tw(e?.code):void 0;return`${n}${r?` (`+r+`)`:``}`}return Tw(e?.code)??``}function ww(e){if(!e)return``;let t=[];if(e.valueQuantity)t.push(bw(e.valueQuantity));else if(e.valueCodeableConcept)t.push(Sw(e.valueCodeableConcept));else{let n=Tw(e.valueString);n&&t.push(n)}return`component`in e&&t.push(e.component.map(e=>ww(e)).join(` / `)),t.join(` / `).trim()}function Tw(e){return typeof e==`string`?e:void 0}function Ew(e,t,n=1){return(Ow(e,t)+n)*10**-t}function Dw(e,t,n=1){return(Ow(e,t)-n)*10**-t}function Ow(e,t){return t===void 0?e:Math.round(e*10**t)}var Y={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 kw(e){let t=Array.isArray(e)?e:e.entry?.map(e=>e.resource)??[];for(let e of t)e?.resourceType===`StructureDefinition`&&e.kind===`resource`&&Aw(e.type)}function Aw(e){let t=Ww.types[e];return t||(t={searchParamsDetails:{}},Ww.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 jw(e){for(let t of e.base??aw){let n=Aw(t);n.searchParams||={},n.searchParams[e.code]=e}}function Mw(e){let t=e.type?.[0]?.code;return t===`BackboneElement`||t===`Element`?Nw((e.base?.path??e.path)?.split(`.`)):t}function Nw(e){return e.length===1?e[0]:e.map(UC).join(``)}function Pw(e){return Ww.types[e]?.searchParams}function Fw(e,t){return Ww.types[e]?.searchParams?.[t]}function Iw(e){return Lw(e.replaceAll(`[x]`,``).split(`.`).pop())}function Lw(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(zw).join(` `).replace(`_`,` `).replaceAll(/\s+/g,` `)}var Rw=new Set([`CDS`,`ID`,`IP`,`PKCE`,`JWKS`,`URI`,`URL`,`OMB`,`UDI`]);function zw(e){let t=e.toUpperCase();return e===t?e:Rw.has(t)?t:t.charAt(0)+e.slice(1)}function Bw(e,t,n){let r=pS(e,n);if(r)return Vw(r.elements,t)}function Vw(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 Hw(e,t){return!(!e||typeof e!=`object`||!(`resourceType`in e)||t&&e.resourceType!==t)}function Uw(e,t){return e&&typeof e==`object`&&`reference`in e&&typeof e.reference==`string`?t?e.reference.match(RegExp(`^${t}(/|\\?)`))!==null:!0:!1}var Ww={types:{}};function Gw(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 Kw=()=>[],qw={empty:(e,t)=>AS(t.every(e=>CC(e.value))),hasValue:(e,t)=>AS(t.length!==0),exists:(e,t,n)=>AS(n?t.some(t=>MS(n.eval(e,[t]))):t.length>0&&t.every(e=>!CC(e.value))),all:(e,t,n)=>AS(t.every(t=>MS(n.eval(e,[t])))),allTrue:(e,t)=>{for(let e of t)if(!e.value)return AS(!1);return AS(!0)},anyTrue:(e,t)=>{for(let e of t)if(e.value)return AS(!0);return AS(!1)},allFalse:(e,t)=>{for(let e of t)if(e.value)return AS(!1);return AS(!0)},anyFalse:(e,t)=>{for(let e of t)if(!e.value)return AS(!0);return AS(!1)},subsetOf:(e,t,n)=>{if(t.length===0)return AS(!0);let r=n.eval(e,Zw(e));return r.length===0?AS(!1):AS(t.every(e=>r.some(t=>t.value===e.value)))},supersetOf:(e,t,n)=>{let r=n.eval(e,Zw(e));return r.length===0?AS(!0):t.length===0?AS(!1):AS(r.every(e=>t.some(t=>t.value===e.value)))},count:(e,t)=>[{type:Y.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)=>AS(t.length===qw.distinct(e,t).length),where:(e,t,n)=>t.filter(t=>MS(n.eval(e,[t]))),select:(e,t,n)=>t.flatMap(t=>n.eval({parent:e,variables:{$this:t}},[t])),repeat:Kw,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,Zw(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,Zw(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,Zw(e));return RS([...t,...r])},combine:(e,t,n)=>{if(!n)return t;let r=n.eval(e,Zw(e));return[...t,...r]},htmlChecks:(e,t,n)=>[jS(!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 MS(a)?r.eval(e,t):i?i.eval(e,t):[]},toBoolean:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Xw(t,1);if(typeof n==`boolean`)return[{type:Y.boolean,value:n}];if(typeof n==`number`&&(n===0||n===1))return AS(!!n);if(typeof n==`string`){let e=n.toLowerCase();if([`true`,`t`,`yes`,`y`,`1`,`1.0`].includes(e))return AS(!0);if([`false`,`f`,`no`,`n`,`0`,`0.0`].includes(e))return AS(!1)}return[]},convertsToBoolean:(e,t)=>t.length===0?[]:AS(qw.toBoolean(e,t).length===1),toInteger:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Xw(t,1);return typeof n==`number`?[{type:Y.integer,value:n}]:typeof n==`string`&&/^[+-]?\d+$/.exec(n)?[{type:Y.integer,value:Number.parseInt(n,10)}]:typeof n==`boolean`?[{type:Y.integer,value:+!!n}]:[]},convertsToInteger:(e,t)=>t.length===0?[]:AS(qw.toInteger(e,t).length===1),toDate:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Xw(t,1);return typeof n==`string`&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:Y.date,value:Gw(n)}]:[]},convertsToDate:(e,t)=>t.length===0?[]:AS(qw.toDate(e,t).length===1),toDateTime:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Xw(t,1);return typeof n==`string`&&/^\d{4}(-\d{2}(-\d{2})?)?/.exec(n)?[{type:Y.dateTime,value:Gw(n)}]:[]},convertsToDateTime:(e,t)=>t.length===0?[]:AS(qw.toDateTime(e,t).length===1),toDecimal:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Xw(t,1);return typeof n==`number`?[{type:Y.decimal,value:n}]:typeof n==`string`&&/^-?\d{1,9}(\.\d{1,9})?$/.exec(n)?[{type:Y.decimal,value:Number.parseFloat(n)}]:typeof n==`boolean`?[{type:Y.decimal,value:+!!n}]:[]},convertsToDecimal:(e,t)=>t.length===0?[]:AS(qw.toDecimal(e,t).length===1),toQuantity:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Xw(t,1);return QS(n)?[{type:Y.Quantity,value:n}]:typeof n==`number`?[{type:Y.Quantity,value:{value:n,unit:`1`}}]:typeof n==`string`&&/^-?\d{1,9}(\.\d{1,9})?/.exec(n)?[{type:Y.Quantity,value:{value:Number.parseFloat(n),unit:`1`}}]:typeof n==`boolean`?[{type:Y.Quantity,value:{value:+!!n,unit:`1`}}]:[]},convertsToQuantity:(e,t)=>t.length===0?[]:AS(qw.toQuantity(e,t).length===1),toString:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Xw(t,1);return n==null?[]:QS(n)?[{type:Y.string,value:`${n.value} '${n.unit}'`}]:[{type:Y.string,value:n.toString()}]},convertsToString:(e,t)=>t.length===0?[]:AS(qw.toString(e,t).length===1),toTime:(e,t)=>{if(t.length===0)return[];let[{value:n}]=Xw(t,1);if(typeof n==`string`){let e=/^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(n);if(e)return[{type:Y.time,value:Gw(`T`+e[1])}]}return[]},convertsToTime:(e,t)=>t.length===0?[]:AS(qw.toTime(e,t).length===1),indexOf:(e,t,n)=>Jw((e,t)=>e.indexOf(t),e,t,n),substring:(e,t,n,r)=>Jw((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)=>Jw((e,t)=>e.startsWith(t),e,t,n),endsWith:(e,t,n)=>Jw((e,t)=>e.endsWith(t),e,t,n),contains:(e,t,n)=>Jw((e,t)=>e.includes(t),e,t,n),upper:(e,t)=>Jw(e=>e.toUpperCase(),e,t),lower:(e,t)=>Jw(e=>e.toLowerCase(),e,t),replace:(e,t,n,r)=>Jw((e,t,n)=>e.replaceAll(t,n),e,t,n,r),matches:(e,t,n)=>Jw((e,t)=>!!new RegExp(t).exec(e),e,t,n),replaceMatches:(e,t,n,r)=>Jw((e,t,n)=>e.replaceAll(new RegExp(t,`g`),n.replaceAll(/\$\{(\w+)\}/g,`$<$1>`)),e,t,n,r),length:(e,t)=>Jw(e=>e.length,e,t),toChars:(e,t)=>Jw(e=>e?e.split(``):void 0,e,t),encode:Kw,decode:Kw,escape:Kw,unescape:Kw,trim:Kw,split:Kw,join:(e,t,n)=>{let r=n?.eval(e,Zw(e))[0]?.value??``;if(typeof r!=`string`)throw TypeError(`Separator must be a string.`);return[{type:Y.string,value:t.map(e=>e.value?.toString()??``).join(r)}]},abs:(e,t)=>Yw(Math.abs,e,t),ceiling:(e,t)=>Yw(Math.ceil,e,t),exp:(e,t)=>Yw(Math.exp,e,t),floor:(e,t)=>Yw(Math.floor,e,t),ln:(e,t)=>Yw(Math.log,e,t),log:(e,t,n)=>Yw((e,t)=>Math.log(e)/Math.log(t),e,t,n),power:(e,t,n)=>Yw(Math.pow,e,t,n),round:(e,t,...n)=>Yw((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)=>Yw(Math.sqrt,e,t),truncate:(e,t)=>Yw(e=>Math.trunc(e),e,t),children:Kw,descendants:Kw,trace:(e,t,n)=>t,now:()=>[{type:Y.dateTime,value:new Date().toISOString()}],timeOfDay:()=>[{type:Y.time,value:new Date().toISOString().substring(11)}],today:()=>[{type:Y.date,value:new Date().toISOString().substring(0,10)}],between:(e,t,n,r,i)=>{let a=qw.toDateTime(e,n.eval(e,t));if(a.length===0)throw Error(`Invalid start date`);let o=qw.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=hC(a[0].value,o[0].value);return[{type:Y.Quantity,value:{value:c[s],unit:s}}]},is:(e,t,n)=>{let r=``;return n instanceof eT?r=n.name:n instanceof lT&&(r=n.left.name+`.`+n.right.name),r?t.map(e=>({type:Y.boolean,value:KS(e,r)})):[]},not:(e,t)=>qw.toBoolean(e,t).map(e=>({type:Y.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 jS(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:Y.BackboneElement,value:void 0}}).filter(e=>!!e.value),as:(e,t,n)=>{let r=n.name,i=NS(t,r);return i?[i]:[]},type:(e,t)=>t.map(({value:e})=>typeof e==`boolean`?{type:Y.BackboneElement,value:{namespace:`System`,name:`Boolean`}}:typeof e==`number`?{type:Y.BackboneElement,value:{namespace:`System`,name:`Integer`}}:Hw(e)?{type:Y.BackboneElement,value:{namespace:`FHIR`,name:e.resourceType}}:{type:Y.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:Y.boolean,value:e.value?.resourceType===i}))},getResourceKey:(e,t)=>{let n=t[0].value;return n?.id?[{type:Y.id,value:n.id}]:[]},getReferenceKey:(e,t,n)=>{let r=t[0].value;if(!r?.reference)return[];let i=``;return n instanceof eT&&(i=n.name),i&&!r.reference.startsWith(i+`/`)?[]:[{type:Y.id,value:sC(r)}]},extension:(e,t,n)=>{let r=n.eval(e,t)[0].value,i=t?.[0]?.value;if(i){let e=vC(i,r);if(e)return[{type:Y.Extension,value:e}]}return[]}};function Jw(e,t,n,...r){if(n.length===0)return[];let[{value:i}]=Xw(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(jS):[jS(a)]}function Yw(e,t,n,...r){if(n.length===0)return[];let[{value:i}]=Xw(n,1),a=QS(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?Y.Quantity:n[0].type,value:a?{...i,value:s}:s}]}function Xw(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 Zw(e){let t=e;for(;t.parent?.variables.$this;)t=t.parent;return[t.variables.$this]}var Qw=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()}},$w=class{value;constructor(e){this.value=e}eval(){return[this.value]}toString(){let e=this.value.value;return typeof e==`string`?`'${e}'`:e.toString()}},eT=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 Hw(t,this.name)?(`path`in e||(e.path=t.resourceType),e):ES(e,this.name)}toString(){return this.name}},tT=class{eval(){return[]}toString(){return`{}`}},nT=class extends Cx{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()}},rT=class extends wx{constructor(e,t){super(`as`,e,t)}eval(e,t){return qw.as(e,this.left.eval(e,t),this.right)}},iT=class extends wx{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=NS(n)?.value,a=NS(r)?.value,o=QS(i)?i.value:i,s=QS(a)?a.value:a,c=this.impl(o,s);return typeof c==`boolean`?AS(c):QS(i)?[{type:Y.Quantity,value:{...i,value:c}}]:[jS(c)]}},aT=Object.freeze({type:`string`,value:``}),oT=class extends wx{constructor(e,t){super(`&`,e,t)}eval(e,t){let n=NS(this.left.eval(e,t))??aT,r=NS(this.right.eval(e,t))??aT;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:Y.string,value:n.value+r.value}]}},sT=class extends wx{constructor(e,t){super(`contains`,e,t)}eval(e,t){let n=this.left.eval(e,t),r=this.right.eval(e,t);return AS(n.some(e=>e.value===r[0].value))}},cT=class extends wx{constructor(e,t){super(`in`,e,t)}eval(e,t){let n=NS(this.left.eval(e,t)),r=this.right.eval(e,t);return n?AS(r.some(e=>HS(n,e)[0].value)):[]}},lT=class extends wx{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()}`}},uT=class extends wx{constructor(e,t){super(`|`,e,t)}eval(e,t){let n=this.left.eval(e,t),r=this.right.eval(e,t);return RS([...n,...r])}},dT=class extends wx{constructor(e,t){super(`=`,e,t)}eval(e,t){return BS(this.left.eval(e,t),this.right.eval(e,t))}},fT=class extends wx{constructor(e,t){super(`!=`,e,t)}eval(e,t){return VS(this.left.eval(e,t),this.right.eval(e,t))}},pT=class extends wx{constructor(e,t){super(`~`,e,t)}eval(e,t){return US(this.left.eval(e,t),this.right.eval(e,t))}},mT=class extends wx{constructor(e,t){super(`!~`,e,t)}eval(e,t){return zS(US(this.left.eval(e,t),this.right.eval(e,t)))}},hT=class extends wx{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 AS(KS(n[0],r))}},gT=class extends wx{constructor(e,t){super(`and`,e,t)}eval(e,t){let n=NS(this.left.eval(e,t),`boolean`),r=NS(this.right.eval(e,t),`boolean`);return n?.value===!0&&r?.value===!0?AS(!0):n?.value===!1||r?.value===!1?AS(!1):[]}},_T=class extends wx{constructor(e,t){super(`or`,e,t)}eval(e,t){let n=NS(this.left.eval(e,t),`boolean`),r=NS(this.right.eval(e,t),`boolean`);return n?.value===!1&&r?.value===!1?AS(!1):n?.value||r?.value?AS(!0):[]}},vT=class extends wx{constructor(e,t){super(`xor`,e,t)}eval(e,t){let n=NS(this.left.eval(e,t),`boolean`),r=NS(this.right.eval(e,t),`boolean`);return!n||!r?[]:AS(n.value!==r.value)}},yT=class extends wx{constructor(e,t){super(`implies`,e,t)}eval(e,t){let n=NS(this.left.eval(e,t),`boolean`),r=NS(this.right.eval(e,t),`boolean`);return r?.value===!0||n?.value===!1?AS(!0):!n||!r?[]:AS(!1)}},bT=class{name;args;constructor(e,t){this.name=e,this.args=t}eval(e,t){let n=qw[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(`, `)})`}},xT=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()}]`}},ST=[`year`,`years`,`month`,`months`,`week`,`weeks`,`day`,`days`,`hour`,`hours`,`minute`,`minutes`,`second`,`seconds`,`millisecond`,`milliseconds`],CT={"'":`'`,'"':`"`,"`":"`",r:`\r`,n:`
54
54
  `,t:` `,f:`\f`,"\\":`\\`},wT=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=CT[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===` `)TT(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 TT(e){return!!(e&&(e.id===`String`||e.id===`Symbol`&&ST.includes(e.value)))}var ET=[`true`,`false`],DT=[`!=`,`!~`,`<=`,`>=`,`{}`,`->`];function OT(e){return new wT(e,ET,DT).tokenize()}var kT={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},AT={parse(e){let t=e.consumeAndParse();if(!e.match(`)`))throw Error("Parse error: expected `)` got `"+e.peek()?.value+"`");return t}},jT={parse(e,t){let n=e.consumeAndParse();if(!e.match(`]`))throw Error("Parse error: expected `]`");return new xT(t,n)},precedence:kT.Indexer},MT={parse(e,t){if(!(t instanceof eT))throw Error(`Unexpected parentheses`);let n=[];for(;!e.match(`)`);)n.push(e.consumeAndParse()),e.match(`,`);return new bT(t.name,n)},precedence:kT.FunctionCall};function NT(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 PT(){return new Tx().registerPrefix(`String`,{parse:(e,t)=>new $w({type:Y.string,value:t.value})}).registerPrefix(`DateTime`,{parse:(e,t)=>new $w({type:Y.dateTime,value:Gw(t.value)})}).registerPrefix(`Quantity`,{parse:(e,t)=>new $w({type:Y.Quantity,value:NT(t.value)})}).registerPrefix(`Number`,{parse:(e,t)=>new $w({type:t.value.includes(`.`)?Y.decimal:Y.integer,value:Number.parseFloat(t.value)})}).registerPrefix(`true`,{parse:()=>new $w({type:Y.boolean,value:!0})}).registerPrefix(`false`,{parse:()=>new $w({type:Y.boolean,value:!1})}).registerPrefix(`Symbol`,{parse:(e,t)=>new eT(t.value)}).registerPrefix(`{}`,{parse:()=>new tT}).registerPrefix(`(`,AT).registerInfix(`[`,jT).registerInfix(`(`,MT).prefix(`+`,kT.UnaryAdd,(e,t)=>new nT(`+`,t,e=>e)).prefix(`-`,kT.UnarySubtract,(e,t)=>new iT(`-`,t,t,(e,t)=>-t)).infixLeft(`.`,kT.Dot,(e,t,n)=>new lT(e,n)).infixLeft(`/`,kT.Divide,(e,t,n)=>new iT(`/`,e,n,(e,t)=>e/t)).infixLeft(`*`,kT.Multiply,(e,t,n)=>new iT(`*`,e,n,(e,t)=>e*t)).infixLeft(`+`,kT.Add,(e,t,n)=>new iT(`+`,e,n,(e,t)=>e+t)).infixLeft(`-`,kT.Subtract,(e,t,n)=>new iT(`-`,e,n,(e,t)=>e-t)).infixLeft(`|`,kT.Union,(e,t,n)=>new uT(e,n)).infixLeft(`=`,kT.Equals,(e,t,n)=>new dT(e,n)).infixLeft(`!=`,kT.NotEquals,(e,t,n)=>new fT(e,n)).infixLeft(`~`,kT.Equivalent,(e,t,n)=>new pT(e,n)).infixLeft(`!~`,kT.NotEquivalent,(e,t,n)=>new mT(e,n)).infixLeft(`<`,kT.LessThan,(e,t,n)=>new iT(`<`,e,n,(e,t)=>e<t)).infixLeft(`<=`,kT.LessThanOrEquals,(e,t,n)=>new iT(`<=`,e,n,(e,t)=>e<=t)).infixLeft(`>`,kT.GreaterThan,(e,t,n)=>new iT(`>`,e,n,(e,t)=>e>t)).infixLeft(`>=`,kT.GreaterThanOrEquals,(e,t,n)=>new iT(`>=`,e,n,(e,t)=>e>=t)).infixLeft(`&`,kT.Ampersand,(e,t,n)=>new oT(e,n)).infixLeft(`and`,kT.And,(e,t,n)=>new gT(e,n)).infixLeft(`as`,kT.As,(e,t,n)=>new rT(e,n)).infixLeft(`contains`,kT.Contains,(e,t,n)=>new sT(e,n)).infixLeft(`div`,kT.Divide,(e,t,n)=>new iT(`div`,e,n,(e,t)=>Math.trunc(e/t))).infixLeft(`in`,kT.In,(e,t,n)=>new cT(e,n)).infixLeft(`is`,kT.Is,(e,t,n)=>new hT(e,n)).infixLeft(`mod`,kT.Modulo,(e,t,n)=>new iT(`mod`,e,n,(e,t)=>e%t)).infixLeft(`or`,kT.Or,(e,t,n)=>new _T(e,n)).infixLeft(`xor`,kT.Xor,(e,t,n)=>new vT(e,n)).infixLeft(`implies`,kT.Implies,(e,t,n)=>new yT(e,n))}var FT=PT();function IT(e){return new Qw(e,FT.construct(OT(e)).consumeAndParse())}function LT(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]=jS(n[e]))}return RT(e,n).map(e=>e.value)}function RT(e,t,n={},r=void 0){let i;if(typeof e==`string`){let t=r?.get(e);i=t??IT(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 zT(e){let t=[];for(let n of e){let e=XS(n.value);e&&t.push(e)}return t}function BT(e){let t=new Set;for(let n of e){let e=ow(n);e&&t.add(e)}return Array.from(t)}function VT(e){let t=new Set;for(let n of e){let{value:e}=n;e&&(FC(e)?t.add(e):Uw(e)?t.add(e.reference):iC(e)?t.add(oC(e)):typeof e.identifier==`object`&&t.add(`identifier:${e.identifier.system}|${e.identifier.value}`))}return Array.from(t)}function HT(e,t={}){let n=[];for(let r of e)UT(t,n,r);return n}function UT(e,t,n){let{type:r,value:i}=n;switch(r){case Y.Identifier:WT(t,e,i);break;case Y.CodeableConcept:GT(t,e,i);break;case Y.Coding:KT(t,e,i);break;case Y.ContactPoint:qT(t,e,i);break;default:JT(t,e,void 0,i?.toString())}}function WT(e,t,n){n?.type?.text&&JT(e,t,t.textSearchSystem,n.type.text),JT(e,t,n?.system,n?.value)}function GT(e,t,n){n?.text&&JT(e,t,t.textSearchSystem,n.text);for(let r of n?.coding??aw)KT(e,t,r)}function KT(e,t,n){n&&(n.display&&JT(e,t,t.textSearchSystem,n.display),JT(e,t,n.system,n.code))}function qT(e,t,n){n&&JT(e,t,n.system,n.value?.toLocaleLowerCase())}function JT(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 X={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`},YT={contains:X.CONTAINS,exact:X.EXACT,above:X.ABOVE,below:X.BELOW,text:X.TEXT,not:X.NOT,in:X.IN,"not-in":X.NOT_IN,"of-type":X.OF_TYPE,missing:X.MISSING,identifier:X.IDENTIFIER,iterate:X.ITERATE},XT={eq:X.EQUALS,ne:X.NOT_EQUALS,lt:X.LESS_THAN,le:X.LESS_THAN_OR_EQUALS,gt:X.GREATER_THAN,ge:X.GREATER_THAN_OR_EQUALS,sa:X.STARTS_AFTER,eb:X.ENDS_BEFORE,ap:X.APPROXIMATELY,sw:X.STARTS_WITH};function ZT(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 QT(i,a)}function QT(e,t){let n={resourceType:e};for(let[e,r]of t)$T(n,e,r);return n}function $T(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=XC(e.filters,{code:t,operator:X.EQUALS,value:n});return}switch(r){case`_sort`:eE(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=oE(n);i===`iterate`&&(t.modifier=X.ITERATE),e.include=XC(e.include,t);break}case`_revinclude`:{let t=oE(n);i===`iterate`&&(t.modifier=X.ITERATE),e.revInclude=XC(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=Ww.types[e.resourceType]?.searchParams?.[r];t?e.filters=XC(e.filters,nE(t,X.EQUALS,i,n)):e.filters=XC(e.filters,rE(r,i,n))}}}}function eE(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 tE=[X.MISSING,X.PRESENT];function nE(e,t,n,r){if(tE.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}=iE(r,n||X.EQUALS);if(!sE(e,i))throw new Xx(Ux(`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(!sE(e,r))throw new Xx(Ux(`Invalid format for ${e.type} search parameter: ${r}`));return{code:e.code,operator:aE(n)??t,value:r};default:throw Error(`Unrecognized search parameter type: `+e.type)}}function rE(e,t,n){let r=X.EQUALS;if(t)r=t;else if(n.length>=2){let e=n.substring(0,2);e in XT&&(n.length===2||n.at(2)?.match(/\d/))&&(r=e,n=n.substring(e.length))}return{code:e,operator:r,value:n}}function iE(e,t){let n=XT[e.substring(0,2)];return n?{operator:n,value:e.substring(2)}:{operator:t,value:e}}function aE(e){return YT[e]}function oE(e){let t=e.split(`:`);if(t.includes(`*`))throw new Xx(Ux(`'*' is not supported as a value for search inclusion parameters`));if(t.length===1)throw new Xx(Ux(`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 Xx(Ux(`Invalid include value '${e}'`))}function sE(e,t){switch(e.type){case`date`:return JS(t);default:return!0}}function cE(e){let t=[];e.fields&&t.push(`_fields=`+e.fields.join(`,`));for(let n of e.filters??aw)t.push(lE(n));e.sortRules&&e.sortRules.length>0&&t.push(uE(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??aw)t.push(dE(`_include`,n));for(let n of e.revInclude??aw)t.push(dE(`_revinclude`,n));return t.length===0?``:(ZC(t),`?`+t.join(`&`))}function lE(e){let t=e.operator in YT?`:`+e.operator:``,n=e.operator!==X.EQUALS&&e.operator in XT?e.operator:``;return`${e.code}${t}=${n}${encodeURIComponent(e.value)}`}function uE(e){return`_sort=`+e.map(e=>e.descending?`-`+e.code:e.code).join(`,`)}function dE(e,t){return e+(t.modifier?`:`+t.modifier:``)+`=`+t.resourceType+`:`+t.searchParam+(t.targetType?`:`+t.targetType:``)}function fE(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 pE(e,t){if(t.resourceType!==e.resourceType)return!1;for(let n of t.filters??aw)if(!hE(e,t,n))return!1;return!0}var mE=new Sx(1e3);function hE(e,t,n){let r=Ww.types[t.resourceType]?.searchParams?.[n.code];if(!r)return!1;let i=RT(r.expression,[jS(e)],void 0,mE);if(n.operator===X.MISSING||n.operator===X.PRESENT)return gE(i,n);switch(r.type){case`reference`:return _E(r,i,n);case`string`:case`uri`:return bE(i,n);case`token`:return vE(i,n);case`date`:return SE(i,n);default:return!1}}function gE(e,t){let n=e.length>0;return(t.operator===X.MISSING&&t.value===`false`||t.operator===X.PRESENT&&t.value===`true`)===n}function _E(e,t,n){let r=wE(n.operator);if(n.value===``&&t.length===0)return n.operator===X.EQUALS;let i=VT(t);for(let t of fE(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 vE(e,t){let n=HT(e),r=fE(t.value),i=wE(t.operator);for(let e of n)for(let t of r)if(yE(e,t))return!i;return i}function yE(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 bE(e,t){let n=BT(e),r=fE(t.value),i=wE(t.operator);for(let e of n)for(let t of r)if(xE(e,t))return!i;return i}function xE(e,t){return e.toLowerCase().includes(t.toLowerCase())}function SE(e,t){let n=zT(e),r=fE(t.value),i=wE(t.operator);for(let e of n)for(let n of r)if(CE(e,t.operator,n))return!i;return i}function CE(e,t,n){if(!e)return!1;let r=XS(n);if(!r)return!1;let i=e.start??`0000`,a=e.end??`9999`,o=r.start,s=r.end;switch(t){case X.APPROXIMATELY:case X.EQUALS:case X.NOT_EQUALS:return i<s&&a>o;case X.LESS_THAN:return i<o;case X.GREATER_THAN:return a>s;case X.LESS_THAN_OR_EQUALS:return i<=s;case X.GREATER_THAN_OR_EQUALS:return a>=o;case X.STARTS_AFTER:return i>s;case X.ENDS_BEFORE:return a<o;default:return!1}}function wE(e){return e===X.NOT_EQUALS||e===X.NOT}var TE={resourceType:`*`},EE=[`DomainConfiguration`,`JsonWebKey`,`Login`],DE=[`Package`,`PackageRelease`,`PackageInstallation`,`Project`,`ProjectMembership`,`User`,`UserSecurityRequest`],OE={READ:`read`,VREAD:`vread`,UPDATE:`update`,DELETE:`delete`,HISTORY:`history`,CREATE:`create`,SEARCH:`search`},kE=[OE.READ,OE.VREAD,OE.HISTORY,OE.SEARCH];function AE(e,t){return EE.includes(t)?!1:jE(e,OE.UPDATE,t)}function jE(e,t,n){return!!e.resource?.some(e=>PE(e,n,t))}function ME(e,t,n){return n?n.resource?.find(n=>NE(e,t,n)):TE}function NE(e,t,n){let r=e.resourceType;return PE(n,r,t)?r===`Binary`?!0:!(n.compartment&&!e.meta?.compartment?.some(e=>e.reference===n.compartment?.reference)||n.criteria&&!pE(e,ZT(n.criteria))):!1}function PE(e,t,n){return e.resourceType!==t&&(e.resourceType!==`*`||DE.includes(t))?!1:e.interaction?e.interaction.includes(n):!e.readonly||kE.includes(n)}function FE(){return typeof window<`u`}function IE(){return typeof Buffer<`u`?Buffer:void 0}var LE={assign(e){FE()&&globalThis.location.assign(e)},reload(){FE()&&globalThis.location.reload()},getSearch(){return FE()?globalThis.location.search:``},getPathname(){return FE()?globalThis.location.pathname:``},getLocation(){return FE()?globalThis.location.toString():``},getOrigin(){return FE()?globalThis.location.protocol+`//`+globalThis.location.host+`/`:``}};function RE(e){if(FE()){let t=window.atob(e),n=Uint8Array.from(t,e=>e.codePointAt(0));return new window.TextDecoder().decode(n)}let t=IE();if(t)return t.from(e,`base64`).toString(`utf-8`);throw Error(`Unable to decode base64`)}function zE(e){if(FE()){let t=new window.TextEncoder().encode(e),n=String.fromCodePoint.apply(null,t);return window.btoa(n)}let t=IE();if(t)return t.from(e,`utf8`).toString(`base64`);throw Error(`Unable to encode base64`)}function BE(e){return e=e.padEnd(e.length+(4-e.length%4)%4,`=`),RE(e.replaceAll(`-`,`+`).replaceAll(`_`,`/`))}function VE(){let e=new Uint32Array(28);return crypto.getRandomValues(e),BC(e.buffer)}async function HE(e){return crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e))}function UE(){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 WE(e){let t={};e=MC(e);for(let n of e.entry??aw){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]=UE(),n.fullUrl=`urn:uuid:`+t[r],delete n.resource?.id;else if(n.fullUrl?.startsWith(`resource:`)){let e=n.fullUrl.slice(9);t[e]=UE(),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)=>GE(e,n,t),2);return KE(JSON.parse(r))}function GE(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 KE(e){let{sorted:t,cycles:n}=JE(XE(e)),r={},i=[];for(let t of e.entry??aw)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 qE={NotVisited:`NotVisited`,Visiting:`Visiting`,Visited:`Visited`};function JE(e){let t=[],n={},r=[];for(let t of Object.keys(e))n[t]=qE.NotVisited;function i(a,o){if(n[a]===qE.Visited)return!0;if(n[a]===qE.Visiting){let e=o.lastIndexOf(a);return e!==-1&&r.push(o.slice(e)),!0}n[a]=qE.Visiting,o.push(a);let s=!1;for(let t of e[a]??aw)i(t,o)||(s=!0);return n[a]=qE.Visited,o.pop(),t.unshift(a),!s}for(let t in e)n[t]===qE.NotVisited&&i(t,[]);return{sorted:t,cycles:r}}function YE(e,t){for(let n in e)if(e[n]&&typeof e[n]==`object`){let r=e[n];if(Uw(r)){let e=r.reference;(e.startsWith(`urn:uuid:`)||e.startsWith(`resource:`))&&t(e)}else YE(r,t)}}function XE(e){let t={};for(let n of e.entry??aw)n.fullUrl&&(t[n.fullUrl]=[]);for(let n of e.entry??aw){let e=n.fullUrl;e&&n.resource&&YE(n.resource,n=>{n!==e&&t[n]&&t[n].push(e)})}return t}var ZE={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`},QE=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??aw)n.call(this,e);return!e.defaultPrevented}removeAllListeners(){this.listeners={}}listenerCount(e){return this.listeners[e]?.length??0}},$E=class{emitter=new QE;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)}},eD={"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`},tD=[`Patient`,`Encounter`,`ImagingStudy`,`DiagnosticReport`,`OperationOutcome`,`Bundle`],nD=[`DiagnosticReport-update`];function rD(e){return nD.includes(e)}function iD(e){if(nD.includes(e))throw new Xx(Wx(`'context.version' is required for '${e}'.`))}var aD={"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 oD(e){return tD.includes(e)}function sD(e){return!!e.endpoint}function cD(e){if(!lD(e))throw new Xx(Wx(`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 sD(e)&&(a.endpoint=e.endpoint),new URLSearchParams(a).toString()}function lD(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(!eD[e])return!1;return!(sD(e)&&!(typeof e.endpoint==`string`&&e.endpoint.startsWith(`ws`)))}function uD(e,t,n,r){if(typeof t!=`object`)throw new Xx(Wx(`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 Xx(Wx(`context[${n}] is invalid. Resource must contain a valid string ID.`));if(!t.resourceType)throw new Xx(Wx(`context[${n}] is invalid. Resource must contain a resource type. No resource type found.`));let i=r.resourceType;if(i!==`*`){if(!oD(t.resourceType))throw new Xx(Wx(`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 Xx(Wx(`context[${n}] is invalid. context[${n}] for the '${e}' event should contain resource of type ${i}.`))}}function dD(e,t,n,r,i){if(i.set(t.key,(i.get(t.key)??0)+1),r.reference){if(!Uw(t.reference))throw new Xx(Wx(`context[${n}] is invalid. Expected key '${t.key}' to be a reference.`))}else uD(e,t.resource,n,r)}function fD(e,t){let n=new Map,r=aD[e];for(let i=0;i<t.length;i++){let a=t[i].key;if(!r[a])throw new Xx(Wx(`Key '${a}' not found for event '${e}'. Make sure to add only valid keys.`));dD(e,t[i],i,r[a],n)}for(let[t,i]of Object.entries(r)){if(!(i.optional||n.has(t)))throw new Xx(Wx(`Missing required key '${t}' on context for '${e}' event.`));if(!i.manyAllowed&&(n.get(t)??0)>1)throw new Xx(Wx(`${n.get(t)} context entries with key '${t}' found for the '${e}' event when schema only allows for 1.`))}}function pD(e,t,n,r){if(!(e&&typeof e==`string`))throw new Xx(Wx(`Must provide a topic.`));if(!eD[t])throw new Xx(Wx(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(eD).join(`, `)}`));if(typeof n!=`object`)throw new Xx(Wx(`context must be a context object or array of context objects.`));if(nD.includes(t)&&!r)throw new Xx(Wx(`The '${t}' event must contain a 'context.versionId'.`));let i=Array.isArray(n)?n:[n];return fD(t,i),{timestamp:new Date().toISOString(),id:UE(),event:{"hub.topic":e,"hub.event":t,context:i,...r?{"context.versionId":r}:{}}}}var mD=class extends $E{subRequest;websocket;constructor(e){if(super(),this.subRequest=e,!e.endpoint)throw new Xx(Wx(`Subscription request should contain an endpoint.`));if(!lD(e))throw new Xx(Wx(`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 hD(e){return JSON.parse(BE(e))}function gD(e){return e.split(`.`).length===3}function _D(e){let[t,n,r]=e.split(`.`);return hD(n)}function vD(e){try{return typeof _D(e).login_id==`string`}catch{return!1}}function yD(e){try{let t=_D(e).exp;return typeof t==`number`?t*1e3:void 0}catch{return}}var bD=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,ZE.TEXT)}async delete(e){await this.medplum.delete(`keyvalue/v1/${e}`)}},xD=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)}},SD=class{storage;prefix=``;constructor(e,t=``){this.storage=e??globalThis.localStorage??new CD,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?yC(t):void 0)}},CD=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]}},wD={Event:globalThis.Event===void 0?void 0:globalThis.Event,ErrorEvent:void 0,CloseEvent:void 0},TD=!1;function ED(){if(globalThis.Event===void 0)throw Error(`Unable to lazy init events for ReconnectingWebSocket. globalThis.Event is not defined yet`);wD.Event=globalThis.Event,wD.ErrorEvent=class extends Event{message;error;constructor(e,t){super(`error`,t),this.message=e.message,this.error=e}},wD.CloseEvent=class extends Event{code;reason;wasClean=!0;constructor(e=1e3,t=``,n){super(`close`,n),this.code=e,this.reason=t}}}function DD(e,t){if(!e)throw Error(t)}function OD(e){return new e.constructor(e.type,e)}var kD={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1},AD=!1,jD=class e extends $E{_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={}){TD||=(ED(),!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=kD.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=kD.reconnectionDelayGrowFactor,minReconnectionDelay:t=kD.minReconnectionDelay,maxReconnectionDelay:n=kD.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=kD.maxRetries,connectionTimeout:t=kD.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`&&!AD&&(console.error(`‼️ No WebSocket implementation available. You should define options.WebSocket.`),AD=!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 wD.ErrorEvent(Error(e.message),this))})}_handleTimeout(){this._debug(`timeout event`),this._handleError(new wD.ErrorEvent(Error(`TIMEOUT`),this))}_disconnect(e=1e3,t){if(this._clearTimeouts(),this._ws){this._removeListeners();try{this._ws.close(e,t),this._handleClose(new wD.CloseEvent(e,t,this))}catch{}}}_acceptOpen(){this._debug(`accept open`),this._retryCount=0}_handleOpen=e=>{this._debug(`open event`);let{minUptime:t=kD.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),t),DD(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(OD(e))};_handleMessage=e=>{this._debug(`message event`),this.onmessage&&this.onmessage(e),this.dispatchEvent(OD(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(OD(e)),this._connect()};_handleClose=e=>{this._debug(`close event`),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(e),this.dispatchEvent(OD(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)}},MD=6e4,ND=[WebSocket.CLOSING,WebSocket.CLOSED],PD=class extends $E{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)}},FD=class{criteria;emitter;refCount;subscriptionProps;subscriptionId;token;tokenExpiry;state=`idle`;generation=0;lastUnrefTime;constructor(e,t){this.criteria=e,this.emitter=new PD(e),this.refCount=1,this.subscriptionProps=t?{...t}:void 0}nextGeneration(){return++this.generation}},ID=class{medplum;ws;masterSubEmitter;criteriaEntries;criteriaEntriesBySubscriptionId;wsClosed;pingTimer=void 0;tokenRefreshTimer=void 0;pingIntervalMs;waitingForPong=!1;currentProfile;constructor(e,t,n){if(!(e instanceof XD))throw new Xx(Wx("First arg of constructor should be a `MedplumClient`"));let r;try{r=new URL(t).toString()}catch{throw new Xx(Wx(`Not a valid URL`))}let i=n?.ReconnectingWebSocket?new n.ReconnectingWebSocket(r,void 0,{debug:n?.debug,debugLogger:n?.debugLogger}):new jD(r,void 0,{debug:n?.debug,debugLogger:n?.debugLogger});this.medplum=e,this.ws=i,this.masterSubEmitter=new PD,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=sC(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(sC(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 Xx({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()},MD)}),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(EC(t,e.subscriptionProps))return e}}getAllCriteriaEmitters(){let e=[];for(let t of this.criteriaEntries.values())for(let n of LD(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!EC(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 LD(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 ${oC(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 Xx(Wx(`Failed to get token`));if(!i)throw new Xx(Wx(`Failed to get URL from $get-ws-binding-token`));if(!a)throw new Xx(Wx(`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(Qx(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 LD(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 FD(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 LD(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 LD(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 PD(...Array.from(this.criteriaEntries.keys())),this.masterSubEmitter}async reconnectIfNeeded(){ND.includes(this.getWebSocket().readyState)&&await new Promise(e=>{let t=()=>{this.getWebSocket().removeEventListener(`open`,t),e()};this.getWebSocket().addEventListener(`open`,t),this.reconnectWebSocket()})}};function LD(e){return e.bareCriteria?[e.bareCriteria,...e.criteriaWithProps]:e.criteriaWithProps}new Sx(1e3);var RD=`5.1.16-7280ff4`,zD=ZE.FHIR_JSON+`, */*; q=0.1`,BD=`https://api.medplum.com/`,VD=1e3,HD=6e4,UD=0,WD=3e5,GD=`Binary/`,KD={resourceType:`Device`,id:`system`,deviceName:[{type:`model-name`,name:`System`}]},qD={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`},JD={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`},YD={JwtBearer:`urn:ietf:params:oauth:client-assertion-type:jwt-bearer`},XD=class extends $E{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??ZD(),this.storage=e?.storage??new SD(void 0,e?.storagePrefix),this.createPdfImpl=e?.createPdf,this.baseUrl=QC(e?.baseUrl??BD),this.fhirBaseUrl=ew(this.baseUrl,e?.fhirUrlPath??`fhir/R4`),this.authorizeUrl=ew(this.baseUrl,e?.authorizeUrl??`oauth2/authorize`),this.tokenUrl=ew(this.baseUrl,e?.tokenUrl??`oauth2/token`),this.logoutUrl=ew(this.baseUrl,e?.logoutUrl??`oauth2/logout`),this.fhircastHubUrl=ew(this.baseUrl,e?.fhircastHubUrl??`fhircast/STU3`),this.cdsServicesUrl=ew(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??WD,this.logLevel=this.initializeLogLevel(e),this.maxRetries=e?.maxRetries??2,this.maxRetryTime=e?.maxRetryTime??2e3,this.cacheTime=e?.cacheTime??(FE()?HD:UD),this.cacheTime>0?this.requestCache=new Sx(e?.resourceCacheSize??VD):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=ew(this.fhirBaseUrl,e);for(let e of this.requestCache?.keys()??aw)(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 xD(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,ZE.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(LE.getSearch()).get(`code`);if(!t){await this.requestAuthorization(e);return}return this.processCode(t)}signOutWithRedirect(){LE.assign(this.logoutUrl)}async signInWithExternalAuth(e,t,n,r,i=!0){let a=r;i&&(a=await this.ensureCodeChallenge(r)),LE.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:qD.TokenExchange,subject_token_type:JD.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(ew(this.fhirBaseUrl,e.join(`/`)))}fhirSearchUrl(e,t){let n=this.fhirUrl(e);return t&&(n.search=nw(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 xD(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 xD(this.search(e,t,n).then($D));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 $D(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 KD;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 xD(Promise.reject(Error(`Missing reference`)));if(n===`system`)return new xD(Promise.resolve(KD));let[r,i]=n.split(`/`);return!r||!i?new xD(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(fS(e))return Promise.resolve();let n=e+`-requestSchema`,r=this.getCacheEntry(n,void 0);if(r)return r.value;let i=new xD((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 TT(e){return!!(e&&(e.id===`String`||e.id===`Symbol`&&ST.includes(e.value)))}var ET=[`true`,`false`],DT=[`!=`,`!~`,`<=`,`>=`,`{}`,`->`];function OT(e){return new wT(e,ET,DT).tokenize()}var kT={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},AT={parse(e){let t=e.consumeAndParse();if(!e.match(`)`))throw Error("Parse error: expected `)` got `"+e.peek()?.value+"`");return t}},jT={parse(e,t){let n=e.consumeAndParse();if(!e.match(`]`))throw Error("Parse error: expected `]`");return new xT(t,n)},precedence:kT.Indexer},MT={parse(e,t){if(!(t instanceof eT))throw Error(`Unexpected parentheses`);let n=[];for(;!e.match(`)`);)n.push(e.consumeAndParse()),e.match(`,`);return new bT(t.name,n)},precedence:kT.FunctionCall};function NT(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 PT(){return new Tx().registerPrefix(`String`,{parse:(e,t)=>new $w({type:Y.string,value:t.value})}).registerPrefix(`DateTime`,{parse:(e,t)=>new $w({type:Y.dateTime,value:Gw(t.value)})}).registerPrefix(`Quantity`,{parse:(e,t)=>new $w({type:Y.Quantity,value:NT(t.value)})}).registerPrefix(`Number`,{parse:(e,t)=>new $w({type:t.value.includes(`.`)?Y.decimal:Y.integer,value:Number.parseFloat(t.value)})}).registerPrefix(`true`,{parse:()=>new $w({type:Y.boolean,value:!0})}).registerPrefix(`false`,{parse:()=>new $w({type:Y.boolean,value:!1})}).registerPrefix(`Symbol`,{parse:(e,t)=>new eT(t.value)}).registerPrefix(`{}`,{parse:()=>new tT}).registerPrefix(`(`,AT).registerInfix(`[`,jT).registerInfix(`(`,MT).prefix(`+`,kT.UnaryAdd,(e,t)=>new nT(`+`,t,e=>e)).prefix(`-`,kT.UnarySubtract,(e,t)=>new iT(`-`,t,t,(e,t)=>-t)).infixLeft(`.`,kT.Dot,(e,t,n)=>new lT(e,n)).infixLeft(`/`,kT.Divide,(e,t,n)=>new iT(`/`,e,n,(e,t)=>e/t)).infixLeft(`*`,kT.Multiply,(e,t,n)=>new iT(`*`,e,n,(e,t)=>e*t)).infixLeft(`+`,kT.Add,(e,t,n)=>new iT(`+`,e,n,(e,t)=>e+t)).infixLeft(`-`,kT.Subtract,(e,t,n)=>new iT(`-`,e,n,(e,t)=>e-t)).infixLeft(`|`,kT.Union,(e,t,n)=>new uT(e,n)).infixLeft(`=`,kT.Equals,(e,t,n)=>new dT(e,n)).infixLeft(`!=`,kT.NotEquals,(e,t,n)=>new fT(e,n)).infixLeft(`~`,kT.Equivalent,(e,t,n)=>new pT(e,n)).infixLeft(`!~`,kT.NotEquivalent,(e,t,n)=>new mT(e,n)).infixLeft(`<`,kT.LessThan,(e,t,n)=>new iT(`<`,e,n,(e,t)=>e<t)).infixLeft(`<=`,kT.LessThanOrEquals,(e,t,n)=>new iT(`<=`,e,n,(e,t)=>e<=t)).infixLeft(`>`,kT.GreaterThan,(e,t,n)=>new iT(`>`,e,n,(e,t)=>e>t)).infixLeft(`>=`,kT.GreaterThanOrEquals,(e,t,n)=>new iT(`>=`,e,n,(e,t)=>e>=t)).infixLeft(`&`,kT.Ampersand,(e,t,n)=>new oT(e,n)).infixLeft(`and`,kT.And,(e,t,n)=>new gT(e,n)).infixLeft(`as`,kT.As,(e,t,n)=>new rT(e,n)).infixLeft(`contains`,kT.Contains,(e,t,n)=>new sT(e,n)).infixLeft(`div`,kT.Divide,(e,t,n)=>new iT(`div`,e,n,(e,t)=>Math.trunc(e/t))).infixLeft(`in`,kT.In,(e,t,n)=>new cT(e,n)).infixLeft(`is`,kT.Is,(e,t,n)=>new hT(e,n)).infixLeft(`mod`,kT.Modulo,(e,t,n)=>new iT(`mod`,e,n,(e,t)=>e%t)).infixLeft(`or`,kT.Or,(e,t,n)=>new _T(e,n)).infixLeft(`xor`,kT.Xor,(e,t,n)=>new vT(e,n)).infixLeft(`implies`,kT.Implies,(e,t,n)=>new yT(e,n))}var FT=PT();function IT(e){return new Qw(e,FT.construct(OT(e)).consumeAndParse())}function LT(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]=jS(n[e]))}return RT(e,n).map(e=>e.value)}function RT(e,t,n={},r=void 0){let i;if(typeof e==`string`){let t=r?.get(e);i=t??IT(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 zT(e){let t=[];for(let n of e){let e=XS(n.value);e&&t.push(e)}return t}function BT(e){let t=new Set;for(let n of e){let e=ow(n);e&&t.add(e)}return Array.from(t)}function VT(e){let t=new Set;for(let n of e){let{value:e}=n;e&&(FC(e)?t.add(e):Uw(e)?t.add(e.reference):iC(e)?t.add(oC(e)):typeof e.identifier==`object`&&t.add(`identifier:${e.identifier.system}|${e.identifier.value}`))}return Array.from(t)}function HT(e,t={}){let n=[];for(let r of e)UT(t,n,r);return n}function UT(e,t,n){let{type:r,value:i}=n;switch(r){case Y.Identifier:WT(t,e,i);break;case Y.CodeableConcept:GT(t,e,i);break;case Y.Coding:KT(t,e,i);break;case Y.ContactPoint:qT(t,e,i);break;default:JT(t,e,void 0,i?.toString())}}function WT(e,t,n){n?.type?.text&&JT(e,t,t.textSearchSystem,n.type.text),JT(e,t,n?.system,n?.value)}function GT(e,t,n){n?.text&&JT(e,t,t.textSearchSystem,n.text);for(let r of n?.coding??aw)KT(e,t,r)}function KT(e,t,n){n&&(n.display&&JT(e,t,t.textSearchSystem,n.display),JT(e,t,n.system,n.code))}function qT(e,t,n){n&&JT(e,t,n.system,n.value?.toLocaleLowerCase())}function JT(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 X={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`},YT={contains:X.CONTAINS,exact:X.EXACT,above:X.ABOVE,below:X.BELOW,text:X.TEXT,not:X.NOT,in:X.IN,"not-in":X.NOT_IN,"of-type":X.OF_TYPE,missing:X.MISSING,identifier:X.IDENTIFIER,iterate:X.ITERATE},XT={eq:X.EQUALS,ne:X.NOT_EQUALS,lt:X.LESS_THAN,le:X.LESS_THAN_OR_EQUALS,gt:X.GREATER_THAN,ge:X.GREATER_THAN_OR_EQUALS,sa:X.STARTS_AFTER,eb:X.ENDS_BEFORE,ap:X.APPROXIMATELY,sw:X.STARTS_WITH};function ZT(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 QT(i,a)}function QT(e,t){let n={resourceType:e};for(let[e,r]of t)$T(n,e,r);return n}function $T(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=XC(e.filters,{code:t,operator:X.EQUALS,value:n});return}switch(r){case`_sort`:eE(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=oE(n);i===`iterate`&&(t.modifier=X.ITERATE),e.include=XC(e.include,t);break}case`_revinclude`:{let t=oE(n);i===`iterate`&&(t.modifier=X.ITERATE),e.revInclude=XC(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=Ww.types[e.resourceType]?.searchParams?.[r];t?e.filters=XC(e.filters,nE(t,X.EQUALS,i,n)):e.filters=XC(e.filters,rE(r,i,n))}}}}function eE(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 tE=[X.MISSING,X.PRESENT];function nE(e,t,n,r){if(tE.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}=iE(r,n||X.EQUALS);if(!sE(e,i))throw new Xx(Ux(`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(!sE(e,r))throw new Xx(Ux(`Invalid format for ${e.type} search parameter: ${r}`));return{code:e.code,operator:aE(n)??t,value:r};default:throw Error(`Unrecognized search parameter type: `+e.type)}}function rE(e,t,n){let r=X.EQUALS;if(t)r=t;else if(n.length>=2){let e=n.substring(0,2);e in XT&&(n.length===2||n.at(2)?.match(/\d/))&&(r=e,n=n.substring(e.length))}return{code:e,operator:r,value:n}}function iE(e,t){let n=XT[e.substring(0,2)];return n?{operator:n,value:e.substring(2)}:{operator:t,value:e}}function aE(e){return YT[e]}function oE(e){let t=e.split(`:`);if(t.includes(`*`))throw new Xx(Ux(`'*' is not supported as a value for search inclusion parameters`));if(t.length===1)throw new Xx(Ux(`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 Xx(Ux(`Invalid include value '${e}'`))}function sE(e,t){switch(e.type){case`date`:return JS(t);default:return!0}}function cE(e){let t=[];e.fields&&t.push(`_fields=`+e.fields.join(`,`));for(let n of e.filters??aw)t.push(lE(n));e.sortRules&&e.sortRules.length>0&&t.push(uE(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??aw)t.push(dE(`_include`,n));for(let n of e.revInclude??aw)t.push(dE(`_revinclude`,n));return t.length===0?``:(ZC(t),`?`+t.join(`&`))}function lE(e){let t=e.operator in YT?`:`+e.operator:``,n=e.operator!==X.EQUALS&&e.operator in XT?e.operator:``;return`${e.code}${t}=${n}${encodeURIComponent(e.value)}`}function uE(e){return`_sort=`+e.map(e=>e.descending?`-`+e.code:e.code).join(`,`)}function dE(e,t){return e+(t.modifier?`:`+t.modifier:``)+`=`+t.resourceType+`:`+t.searchParam+(t.targetType?`:`+t.targetType:``)}function fE(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 pE(e,t){if(t.resourceType!==e.resourceType)return!1;for(let n of t.filters??aw)if(!hE(e,t,n))return!1;return!0}var mE=new Sx(1e3);function hE(e,t,n){let r=Ww.types[t.resourceType]?.searchParams?.[n.code];if(!r)return!1;let i=RT(r.expression,[jS(e)],void 0,mE);if(n.operator===X.MISSING||n.operator===X.PRESENT)return gE(i,n);switch(r.type){case`reference`:return _E(r,i,n);case`string`:case`uri`:return bE(i,n);case`token`:return vE(i,n);case`date`:return SE(i,n);default:return!1}}function gE(e,t){let n=e.length>0;return(t.operator===X.MISSING&&t.value===`false`||t.operator===X.PRESENT&&t.value===`true`)===n}function _E(e,t,n){let r=wE(n.operator);if(n.value===``&&t.length===0)return n.operator===X.EQUALS;let i=VT(t);for(let t of fE(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 vE(e,t){let n=HT(e),r=fE(t.value),i=wE(t.operator);for(let e of n)for(let t of r)if(yE(e,t))return!i;return i}function yE(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 bE(e,t){let n=BT(e),r=fE(t.value),i=wE(t.operator);for(let e of n)for(let t of r)if(xE(e,t))return!i;return i}function xE(e,t){return e.toLowerCase().includes(t.toLowerCase())}function SE(e,t){let n=zT(e),r=fE(t.value),i=wE(t.operator);for(let e of n)for(let n of r)if(CE(e,t.operator,n))return!i;return i}function CE(e,t,n){if(!e)return!1;let r=XS(n);if(!r)return!1;let i=e.start??`0000`,a=e.end??`9999`,o=r.start,s=r.end;switch(t){case X.APPROXIMATELY:case X.EQUALS:case X.NOT_EQUALS:return i<s&&a>o;case X.LESS_THAN:return i<o;case X.GREATER_THAN:return a>s;case X.LESS_THAN_OR_EQUALS:return i<=s;case X.GREATER_THAN_OR_EQUALS:return a>=o;case X.STARTS_AFTER:return i>s;case X.ENDS_BEFORE:return a<o;default:return!1}}function wE(e){return e===X.NOT_EQUALS||e===X.NOT}var TE={resourceType:`*`},EE=[`DomainConfiguration`,`JsonWebKey`,`Login`],DE=[`Package`,`PackageRelease`,`PackageInstallation`,`Project`,`ProjectMembership`,`User`,`UserSecurityRequest`],OE={READ:`read`,VREAD:`vread`,UPDATE:`update`,DELETE:`delete`,HISTORY:`history`,CREATE:`create`,SEARCH:`search`},kE=[OE.READ,OE.VREAD,OE.HISTORY,OE.SEARCH];function AE(e,t){return EE.includes(t)?!1:jE(e,OE.UPDATE,t)}function jE(e,t,n){return!!e.resource?.some(e=>PE(e,n,t))}function ME(e,t,n){return n?n.resource?.find(n=>NE(e,t,n)):TE}function NE(e,t,n){let r=e.resourceType;return PE(n,r,t)?r===`Binary`?!0:!(n.compartment&&!e.meta?.compartment?.some(e=>e.reference===n.compartment?.reference)||n.criteria&&!pE(e,ZT(n.criteria))):!1}function PE(e,t,n){return e.resourceType!==t&&(e.resourceType!==`*`||DE.includes(t))?!1:e.interaction?e.interaction.includes(n):!e.readonly||kE.includes(n)}function FE(){return typeof window<`u`}function IE(){return typeof Buffer<`u`?Buffer:void 0}var LE={assign(e){FE()&&globalThis.location.assign(e)},reload(){FE()&&globalThis.location.reload()},getSearch(){return FE()?globalThis.location.search:``},getPathname(){return FE()?globalThis.location.pathname:``},getLocation(){return FE()?globalThis.location.toString():``},getOrigin(){return FE()?globalThis.location.protocol+`//`+globalThis.location.host+`/`:``}};function RE(e){if(FE()){let t=window.atob(e),n=Uint8Array.from(t,e=>e.codePointAt(0));return new window.TextDecoder().decode(n)}let t=IE();if(t)return t.from(e,`base64`).toString(`utf-8`);throw Error(`Unable to decode base64`)}function zE(e){if(FE()){let t=new window.TextEncoder().encode(e),n=String.fromCodePoint.apply(null,t);return window.btoa(n)}let t=IE();if(t)return t.from(e,`utf8`).toString(`base64`);throw Error(`Unable to encode base64`)}function BE(e){return e=e.padEnd(e.length+(4-e.length%4)%4,`=`),RE(e.replaceAll(`-`,`+`).replaceAll(`_`,`/`))}function VE(){let e=new Uint32Array(28);return crypto.getRandomValues(e),BC(e.buffer)}async function HE(e){return crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e))}function UE(){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 WE(e){let t={};e=MC(e);for(let n of e.entry??aw){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]=UE(),n.fullUrl=`urn:uuid:`+t[r],delete n.resource?.id;else if(n.fullUrl?.startsWith(`resource:`)){let e=n.fullUrl.slice(9);t[e]=UE(),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)=>GE(e,n,t),2);return KE(JSON.parse(r))}function GE(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 KE(e){let{sorted:t,cycles:n}=JE(XE(e)),r={},i=[];for(let t of e.entry??aw)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 qE={NotVisited:`NotVisited`,Visiting:`Visiting`,Visited:`Visited`};function JE(e){let t=[],n={},r=[];for(let t of Object.keys(e))n[t]=qE.NotVisited;function i(a,o){if(n[a]===qE.Visited)return!0;if(n[a]===qE.Visiting){let e=o.lastIndexOf(a);return e!==-1&&r.push(o.slice(e)),!0}n[a]=qE.Visiting,o.push(a);let s=!1;for(let t of e[a]??aw)i(t,o)||(s=!0);return n[a]=qE.Visited,o.pop(),t.unshift(a),!s}for(let t in e)n[t]===qE.NotVisited&&i(t,[]);return{sorted:t,cycles:r}}function YE(e,t){for(let n in e)if(e[n]&&typeof e[n]==`object`){let r=e[n];if(Uw(r)){let e=r.reference;(e.startsWith(`urn:uuid:`)||e.startsWith(`resource:`))&&t(e)}else YE(r,t)}}function XE(e){let t={};for(let n of e.entry??aw)n.fullUrl&&(t[n.fullUrl]=[]);for(let n of e.entry??aw){let e=n.fullUrl;e&&n.resource&&YE(n.resource,n=>{n!==e&&t[n]&&t[n].push(e)})}return t}var ZE={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`},QE=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??aw)n.call(this,e);return!e.defaultPrevented}removeAllListeners(){this.listeners={}}listenerCount(e){return this.listeners[e]?.length??0}},$E=class{emitter=new QE;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)}},eD={"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`},tD=[`Patient`,`Encounter`,`ImagingStudy`,`DiagnosticReport`,`OperationOutcome`,`Bundle`],nD=[`DiagnosticReport-update`];function rD(e){return nD.includes(e)}function iD(e){if(nD.includes(e))throw new Xx(Wx(`'context.version' is required for '${e}'.`))}var aD={"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 oD(e){return tD.includes(e)}function sD(e){return!!e.endpoint}function cD(e){if(!lD(e))throw new Xx(Wx(`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 sD(e)&&(a.endpoint=e.endpoint),new URLSearchParams(a).toString()}function lD(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(!eD[e])return!1;return!(sD(e)&&!(typeof e.endpoint==`string`&&e.endpoint.startsWith(`ws`)))}function uD(e,t,n,r){if(typeof t!=`object`)throw new Xx(Wx(`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 Xx(Wx(`context[${n}] is invalid. Resource must contain a valid string ID.`));if(!t.resourceType)throw new Xx(Wx(`context[${n}] is invalid. Resource must contain a resource type. No resource type found.`));let i=r.resourceType;if(i!==`*`){if(!oD(t.resourceType))throw new Xx(Wx(`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 Xx(Wx(`context[${n}] is invalid. context[${n}] for the '${e}' event should contain resource of type ${i}.`))}}function dD(e,t,n,r,i){if(i.set(t.key,(i.get(t.key)??0)+1),r.reference){if(!Uw(t.reference))throw new Xx(Wx(`context[${n}] is invalid. Expected key '${t.key}' to be a reference.`))}else uD(e,t.resource,n,r)}function fD(e,t){let n=new Map,r=aD[e];for(let i=0;i<t.length;i++){let a=t[i].key;if(!r[a])throw new Xx(Wx(`Key '${a}' not found for event '${e}'. Make sure to add only valid keys.`));dD(e,t[i],i,r[a],n)}for(let[t,i]of Object.entries(r)){if(!(i.optional||n.has(t)))throw new Xx(Wx(`Missing required key '${t}' on context for '${e}' event.`));if(!i.manyAllowed&&(n.get(t)??0)>1)throw new Xx(Wx(`${n.get(t)} context entries with key '${t}' found for the '${e}' event when schema only allows for 1.`))}}function pD(e,t,n,r){if(!(e&&typeof e==`string`))throw new Xx(Wx(`Must provide a topic.`));if(!eD[t])throw new Xx(Wx(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(eD).join(`, `)}`));if(typeof n!=`object`)throw new Xx(Wx(`context must be a context object or array of context objects.`));if(nD.includes(t)&&!r)throw new Xx(Wx(`The '${t}' event must contain a 'context.versionId'.`));let i=Array.isArray(n)?n:[n];return fD(t,i),{timestamp:new Date().toISOString(),id:UE(),event:{"hub.topic":e,"hub.event":t,context:i,...r?{"context.versionId":r}:{}}}}var mD=class extends $E{subRequest;websocket;constructor(e){if(super(),this.subRequest=e,!e.endpoint)throw new Xx(Wx(`Subscription request should contain an endpoint.`));if(!lD(e))throw new Xx(Wx(`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 hD(e){return JSON.parse(BE(e))}function gD(e){return e.split(`.`).length===3}function _D(e){let[t,n,r]=e.split(`.`);return hD(n)}function vD(e){try{return typeof _D(e).login_id==`string`}catch{return!1}}function yD(e){try{let t=_D(e).exp;return typeof t==`number`?t*1e3:void 0}catch{return}}var bD=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,ZE.TEXT)}async delete(e){await this.medplum.delete(`keyvalue/v1/${e}`)}},xD=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)}},SD=class{storage;prefix=``;constructor(e,t=``){this.storage=e??globalThis.localStorage??new CD,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?yC(t):void 0)}},CD=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]}},wD={Event:globalThis.Event===void 0?void 0:globalThis.Event,ErrorEvent:void 0,CloseEvent:void 0},TD=!1;function ED(){if(globalThis.Event===void 0)throw Error(`Unable to lazy init events for ReconnectingWebSocket. globalThis.Event is not defined yet`);wD.Event=globalThis.Event,wD.ErrorEvent=class extends Event{message;error;constructor(e,t){super(`error`,t),this.message=e.message,this.error=e}},wD.CloseEvent=class extends Event{code;reason;wasClean=!0;constructor(e=1e3,t=``,n){super(`close`,n),this.code=e,this.reason=t}}}function DD(e,t){if(!e)throw Error(t)}function OD(e){return new e.constructor(e.type,e)}var kD={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1},AD=!1,jD=class e extends $E{_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={}){TD||=(ED(),!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=kD.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=kD.reconnectionDelayGrowFactor,minReconnectionDelay:t=kD.minReconnectionDelay,maxReconnectionDelay:n=kD.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=kD.maxRetries,connectionTimeout:t=kD.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`&&!AD&&(console.error(`‼️ No WebSocket implementation available. You should define options.WebSocket.`),AD=!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 wD.ErrorEvent(Error(e.message),this))})}_handleTimeout(){this._debug(`timeout event`),this._handleError(new wD.ErrorEvent(Error(`TIMEOUT`),this))}_disconnect(e=1e3,t){if(this._clearTimeouts(),this._ws){this._removeListeners();try{this._ws.close(e,t),this._handleClose(new wD.CloseEvent(e,t,this))}catch{}}}_acceptOpen(){this._debug(`accept open`),this._retryCount=0}_handleOpen=e=>{this._debug(`open event`);let{minUptime:t=kD.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),t),DD(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(OD(e))};_handleMessage=e=>{this._debug(`message event`),this.onmessage&&this.onmessage(e),this.dispatchEvent(OD(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(OD(e)),this._connect()};_handleClose=e=>{this._debug(`close event`),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(e),this.dispatchEvent(OD(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)}},MD=6e4,ND=[WebSocket.CLOSING,WebSocket.CLOSED],PD=class extends $E{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)}},FD=class{criteria;emitter;refCount;subscriptionProps;subscriptionId;token;tokenExpiry;state=`idle`;generation=0;lastUnrefTime;constructor(e,t){this.criteria=e,this.emitter=new PD(e),this.refCount=1,this.subscriptionProps=t?{...t}:void 0}nextGeneration(){return++this.generation}},ID=class{medplum;ws;masterSubEmitter;criteriaEntries;criteriaEntriesBySubscriptionId;wsClosed;pingTimer=void 0;tokenRefreshTimer=void 0;pingIntervalMs;waitingForPong=!1;currentProfile;constructor(e,t,n){if(!(e instanceof XD))throw new Xx(Wx("First arg of constructor should be a `MedplumClient`"));let r;try{r=new URL(t).toString()}catch{throw new Xx(Wx(`Not a valid URL`))}let i=n?.ReconnectingWebSocket?new n.ReconnectingWebSocket(r,void 0,{debug:n?.debug,debugLogger:n?.debugLogger}):new jD(r,void 0,{debug:n?.debug,debugLogger:n?.debugLogger});this.medplum=e,this.ws=i,this.masterSubEmitter=new PD,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=sC(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(sC(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 Xx({resourceType:`OperationOutcome`,issue:[{severity:`error`,code:`exception`,details:{text:`WebSocket connection closed due to an error`},diagnostics:e.error?Qx(e.error):e.message}]})};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()},MD)}),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(EC(t,e.subscriptionProps))return e}}getAllCriteriaEmitters(){let e=[];for(let t of this.criteriaEntries.values())for(let n of LD(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!EC(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 LD(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.subscriptionId=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 ${oC(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 Xx(Wx(`Failed to get token`));if(!i)throw new Xx(Wx(`Failed to get URL from $get-ws-binding-token`));if(!a)throw new Xx(Wx(`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(Qx(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 LD(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 FD(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 LD(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 LD(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 PD(...Array.from(this.criteriaEntries.keys())),this.masterSubEmitter}async reconnectIfNeeded(){ND.includes(this.getWebSocket().readyState)&&await new Promise(e=>{let t=()=>{this.getWebSocket().removeEventListener(`open`,t),e()};this.getWebSocket().addEventListener(`open`,t),this.reconnectWebSocket()})}};function LD(e){return e.bareCriteria?[e.bareCriteria,...e.criteriaWithProps]:e.criteriaWithProps}new Sx(1e3);var RD=`5.1.17-7eb2f88`,zD=ZE.FHIR_JSON+`, */*; q=0.1`,BD=`https://api.medplum.com/`,VD=1e3,HD=6e4,UD=0,WD=3e5,GD=`Binary/`,KD={resourceType:`Device`,id:`system`,deviceName:[{type:`model-name`,name:`System`}]},qD={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`},JD={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`},YD={JwtBearer:`urn:ietf:params:oauth:client-assertion-type:jwt-bearer`},XD=class extends $E{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??ZD(),this.storage=e?.storage??new SD(void 0,e?.storagePrefix),this.createPdfImpl=e?.createPdf,this.baseUrl=QC(e?.baseUrl??BD),this.fhirBaseUrl=ew(this.baseUrl,e?.fhirUrlPath??`fhir/R4`),this.authorizeUrl=ew(this.baseUrl,e?.authorizeUrl??`oauth2/authorize`),this.tokenUrl=ew(this.baseUrl,e?.tokenUrl??`oauth2/token`),this.logoutUrl=ew(this.baseUrl,e?.logoutUrl??`oauth2/logout`),this.fhircastHubUrl=ew(this.baseUrl,e?.fhircastHubUrl??`fhircast/STU3`),this.cdsServicesUrl=ew(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??WD,this.logLevel=this.initializeLogLevel(e),this.maxRetries=e?.maxRetries??2,this.maxRetryTime=e?.maxRetryTime??2e3,this.cacheTime=e?.cacheTime??(FE()?HD:UD),this.cacheTime>0?this.requestCache=new Sx(e?.resourceCacheSize??VD):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=ew(this.fhirBaseUrl,e);for(let e of this.requestCache?.keys()??aw)(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 xD(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,ZE.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(LE.getSearch()).get(`code`);if(!t){await this.requestAuthorization(e);return}return this.processCode(t)}signOutWithRedirect(){LE.assign(this.logoutUrl)}async signInWithExternalAuth(e,t,n,r,i=!0){let a=r;i&&(a=await this.ensureCodeChallenge(r)),LE.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:qD.TokenExchange,subject_token_type:JD.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(ew(this.fhirBaseUrl,e.join(`/`)))}fhirSearchUrl(e,t){let n=this.fhirUrl(e);return t&&(n.search=nw(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 xD(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 xD(this.search(e,t,n).then($D));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 $D(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 KD;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 xD(Promise.reject(Error(`Missing reference`)));if(n===`system`)return new xD(Promise.resolve(KD));let[r,i]=n.split(`/`);return!r||!i?new xD(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(fS(e))return Promise.resolve();let n=e+`-requestSchema`,r=this.getCacheEntry(n,void 0);if(r)return r.value;let i=new xD((async()=>{let t=`{
57
57
  StructureDefinitionList(_filter: "name eq ${e}") {
58
58
  resourceType,
59
59
  name,
@@ -234,4 +234,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
234
234
  }
235
235
  ]
236
236
  }`,LX=`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 RX(){let e=Z(),{id:t}=SW(),[n,r]=(0,b.useState)(),[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(IX),[u,d]=(0,b.useState)(LX),[f,p]=(0,b.useState)(ZE.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 zX(e,t))}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},[e,t]);let v=(0,b.useCallback)(async()=>Hj(m.current,{command:`getValue`}),[]),y=(0,b.useCallback)(async()=>Hj(m.current,{command:`getOutput`}),[]),x=(0,b.useCallback)(async()=>f===ZE.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:ZE.TYPESCRIPT}),o=await e.createAttachment({data:r,filename:i===`commonjs`?`index.cjs`:`index.mjs`,contentType:ZE.JAVASCRIPT}),s=[{op:`add`,path:`/sourceCode`,value:a},{op:`add`,path:`/executableCode`,value:o}];await e.patchResource(`Bot`,t,s),J({color:`green`,message:`Saved`})}catch(e){J({color:`red`,message:Qx(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`)),J({color:`green`,message:`Deployed`})}catch(e){J({color:`red`,message:Qx(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 Hj(h.current,{command:`setValue`,value:r}),J({color:`green`,message:`Success`})}catch(e){J({color:`red`,message:Qx(e),autoClose:!1})}finally{_(!1)}},[e,t,x,f]);return!n||o===void 0?null:(0,I.jsxs)(Tm,{m:0,gutter:0,style:{overflow:`hidden`},children:[(0,I.jsx)(Tm.Col,{span:8,children:(0,I.jsxs)(yl,{m:2,pb:`xs`,pr:`xs`,pt:`xs`,shadow:`md`,mih:400,children:[(0,I.jsx)(FX,{iframeRef:m,language:`typescript`,module:i,testId:`code-frame`,defaultValue:o,minHeight:`528px`}),(0,I.jsxs)(V,{justify:`flex-end`,gap:`xs`,children:[(0,I.jsx)(U,{type:`button`,onClick:S,loading:g,leftSection:(0,I.jsx)(IA,{size:`1rem`}),children:`Save`}),(0,I.jsx)(U,{type:`button`,onClick:C,loading:g,leftSection:(0,I.jsx)(AA,{size:`1rem`}),children:`Deploy`}),(0,I.jsx)(U,{type:`button`,onClick:w,loading:g,leftSection:(0,I.jsx)(dj,{size:`1rem`}),children:`Execute`})]})]})}),(0,I.jsxs)(Tm.Col,{span:4,children:[(0,I.jsxs)(yl,{m:2,pb:`xs`,pr:`xs`,pt:`xs`,shadow:`md`,children:[(0,I.jsx)(Eg,{data:[{label:`FHIR`,value:ZE.FHIR_JSON},{label:`HL7`,value:ZE.HL7_V2}],onChange:e=>p(e.currentTarget.value)}),f===ZE.FHIR_JSON?(0,I.jsx)(lh,{value:c,onChange:e=>l(e),autosize:!0,minRows:15}):(0,I.jsx)(`textarea`,{className:NX.hl7Input,value:u,onChange:e=>d(e.currentTarget.value),rows:15})]}),(0,I.jsx)(yl,{m:2,p:`xs`,shadow:`md`,children:(0,I.jsx)(PX,{iframeRef:h,className:`medplum-bot-output-frame`,testId:`output-frame`,minHeight:`200px`})})]})]})}async function zX(e,t){if(t.sourceCode?.url){let n=t.sourceCode.url?.split(`/`)?.find(NC);return(await e.download(e.fhirUrl(`Binary`,n))).text()}return t.code??``}function BX(e){let t=e.meta;return t&&={...t,lastUpdated:void 0,versionId:void 0,author:void 0},{...e,meta:t}}function VX(){let e=Z(),{resourceType:t,id:n}=SW(),r={reference:t+`/`+n},i=(0,b.useCallback)(t=>{e.updateResource(BX(t)).then(()=>{J({color:`green`,message:`Success`})}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1})})},[e]);switch(t){case`PlanDefinition`:return(0,I.jsx)(vP,{children:(0,I.jsx)(Uz,{value:r,onSubmit:i})});case`Questionnaire`:return(0,I.jsx)(vP,{children:(0,I.jsx)(eB,{questionnaire:r,onSubmit:i})});default:return null}}function HX(){let{resourceType:e,id:t}=SW(),n=nk({reference:e+`/`+t}),r=vW();return n?(0,I.jsx)(vP,{children:(0,I.jsx)(TB,{value:n,onStart:(e,t)=>r(`/forms/${sC(t)}`)?.catch(console.error),onEdit:(e,t,n)=>r(`/${n.reference}}`)?.catch(console.error)})}):null}function UX(){let e=Z(),{resourceType:t,id:n}=SW(),r=nk({reference:t+`/`+n}),i=(0,b.useRef)(0),[a,o]=(0,b.useState)([]);(0,b.useEffect)(()=>{r&&o((r.payload??aw).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(BX({...r,payload:a.map(e=>e.item)})).then(()=>J({color:`green`,message:`Saved`})).catch(e=>J({color:`red`,message:Qx(e)}))},[e,r,a]);return r?(0,I.jsx)(vP,{children:(0,I.jsxs)(G,{children:[a.filter(({item:e})=>`contentString`in e).map(({key:e,item:t})=>(0,I.jsx)(oh,{autosize:!0,minRows:3,maxRows:20,value:t.contentString??``,onChange:t=>s(e,t.currentTarget.value),placeholder:`Enter content...`},e)),(0,I.jsxs)(V,{justify:`flex-end`,children:[(0,I.jsx)(U,{variant:`outline`,onClick:c,children:`Add payload`}),(0,I.jsx)(U,{onClick:l,children:`Save`})]}),(0,I.jsx)(H,{size:`xs`,c:`dimmed`,children:`This tab manages string payloads only. Attachments and References can be managed in the Edit tab.`})]})}):null}function WX(){let e=Z(),{resourceType:t,id:n}=SW(),r=vW();return(0,I.jsxs)(vP,{children:[(0,I.jsxs)(`p`,{children:[`Are you sure you want to delete this `,t,`?`]}),(0,I.jsx)(U,{color:`red`,onClick:()=>{e.deleteResource(t,n).then(()=>r(`/${t}`)?.catch(console.error)).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},children:`Delete`})]})}var GX={selectProfileBtn:`_selectProfileBtn_tbaz6_1`,chevron:`_chevron_tbaz6_13`};function KX(){let{resourceType:e,id:t}=SW(),n=nk({reference:e+`/`+t}),[r,i]=(0,b.useState)(),a=If({onDropdownClose:()=>a.resetSelectedOption()}),o=(0,b.useMemo)(()=>{if(wC(n?.meta?.profile))return[(0,I.jsx)(zf.Option,{value:``,children:`None`},``),...n.meta.profile.map(e=>(0,I.jsx)(zf.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 wC(o)&&(s=(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsxs)(G,{align:`flex-end`,gap:`xs`,children:[(0,I.jsxs)(zf,{store:a,width:250,position:`bottom-end`,withinPortal:!1,onOptionSubmit:e=>{i(e),a.closeDropdown()},children:[(0,I.jsx)(zf.Target,{children:(0,I.jsx)(ml,{onClick:()=>a.toggleDropdown(),children:(0,I.jsxs)(nm,{fw:`bold`,fs:`sm`,className:GX.selectProfileBtn,children:[(0,I.jsx)(`span`,{children:`Pick profile`}),(0,I.jsx)(EA,{stroke:1.5,className:GX.chevron})]})})}),(0,I.jsx)(zf.Dropdown,{w:`max-content`,children:(0,I.jsx)(zf.Options,{children:o})})]}),(0,I.jsx)(z,{children:r?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(H,{span:!0,size:`sm`,c:`dimmed`,children:`Displaying profile:\xA0`}),(0,I.jsx)(H,{span:!0,size:`sm`,children:r||`Nothing selected`})]}):(0,I.jsx)(H,{span:!0,size:`sm`,c:`dimmed`,children:`No profile displayed`})})]})})),(0,I.jsx)(vP,{children:(0,I.jsxs)(G,{gap:`xl`,children:[s,(0,I.jsx)(RL,{value:n,profileUrl:r})]})})}function qX(){let e=Z(),{resourceType:t,id:n}=SW(),[r,i]=(0,b.useState)(),[a,o]=(0,b.useState)(),s=vW(),[c,l]=(0,b.useState)();(0,b.useEffect)(()=>{e.readResource(t,n).then(e=>{i(MC(e)),o(MC(e))}).catch(e=>{l(Zx(e)),J({color:`red`,message:Qx(e),autoClose:!1})})},[e,t,n]);let u=(0,b.useCallback)(r=>{l(void 0),e.updateResource(BX(r)).then(()=>{s(`/${t}/${n}/details`)?.catch(console.error),J({id:`succes`,color:`green`,message:`Success`})}).catch(e=>{l(Zx(e)),J({color:`red`,message:Qx(e),autoClose:!1})})},[e,t,n,s]),d=(0,b.useCallback)(i=>{l(void 0);let a=(0,jL.createPatch)(r,BX(i));e.patchResource(t,n,a).then(()=>{s(`/${t}/${n}/details`)?.catch(console.error),J({id:`succes`,color:`green`,message:`Success`})}).catch(e=>{l(Zx(e)),J({color:`red`,message:Qx(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,I.jsx)(vP,{children:(0,I.jsx)(HB,{defaultValue:a,onSubmit:u,onPatch:d,onDelete:f,outcome:c})}):null}function JX(){let{resourceType:e,id:t}=SW(),n=nk({reference:e+`/`+t});return n?(0,I.jsx)(vP,{maw:700,children:n.resourceType===`Patient`?(0,I.jsx)(Lz,{patient:n}):(0,I.jsx)(Dd,{icon:(0,I.jsx)(uA,{size:16}),title:`Unsupported export type`,color:`red`,children:`This page is only supported for Patient resources`})}):null}function YX({resource:e,currentProfile:t,onChange:n}){let r=e.resourceType,i=Z(),[a,o]=(0,b.useState)();return(0,b.useEffect)(()=>{i.searchResources(`StructureDefinition`,{type:r,derivation:`constraint`,_count:50}).then(e=>{o(e.filter(MF))}).catch(console.error)},[i,n,r]),(0,I.jsx)(vb,{value:t?.url,onChange:e=>{let t=a?.find(t=>t.url===e);t&&n(t)},children:(0,I.jsx)(vb.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,I.jsx)(vb.Tab,{value:t.url,title:r,rightSection:n&&(0,I.jsx)(Sb,{variant:`outline`,color:`green`,size:`xs`,style:{borderStyle:`none`},children:(0,I.jsx)(Pj,{size:`90%`})}),children:t.title||t.name},t.url)})})})}function XX(e,t){let n=Z(),r=vW();return{defaultValue:{resourceType:e},handleSubmit:e=>{t&&t(void 0),n.createResource(e).then(e=>r(`/`+e.resourceType+`/`+e.id)).catch(e=>{t&&t(Zx(e)),J({color:`red`,message:Qx(e),autoClose:!1,styles:{description:{whiteSpace:`pre-line`}}})})}}}function ZX(){let{resourceType:e}=SW(),t=hW(),[n,r]=(0,b.useState)(),{defaultValue:i,handleSubmit:a}=XX(e,r),[o,s]=(0,b.useState)(),c=t.pathname.toLowerCase().endsWith(`profiles`),l=(0,b.useCallback)(e=>{let t=BX(e);o&&rw(t,o.url),a(t)},[o,a]);return c?(0,I.jsx)(vP,{children:(0,I.jsxs)(G,{children:[(0,I.jsx)(YX,{resource:i,currentProfile:o,onChange:s}),o?(0,I.jsx)(HB,{defaultValue:i,onSubmit:l,outcome:n,profileUrl:o.url},o.url):(0,I.jsx)(H,{my:`lg`,fz:`lg`,fs:`italic`,ta:`center`,children:`Select a profile above`})]})}):(0,I.jsx)(vP,{children:(0,I.jsx)(HB,{defaultValue:i,onSubmit:a,outcome:n})})}function QX(){let e=Z(),{resourceType:t,id:n}=SW();return(0,I.jsx)(vP,{children:(0,I.jsx)(UB,{history:e.readHistory(t,n).read()})})}function $X(){let{resourceType:e}=SW(),[t,n]=(0,b.useState)(),{defaultValue:r,handleSubmit:i}=XX(e,n),a=(0,b.useCallback)(e=>{i(JSON.parse(e[`new-resource`]))},[i]);return(0,I.jsxs)(vP,{children:[t&&(0,I.jsx)(EP,{outcome:t}),(0,I.jsxs)(CN,{onSubmit:a,children:[(0,I.jsx)(lh,{name:`new-resource`,"data-testid":`create-resource-json`,autosize:!0,minRows:24,defaultValue:yC(r,!0),formatOnBlur:!0,deserialize:JSON.parse}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,children:(0,I.jsx)(U,{type:`submit`,children:`OK`})})]})]})}function eZ(){let e=Z(),{resourceType:t,id:n}=SW(),r=nk({reference:t+`/`+n}),i=vW(),[a,o]=(0,b.useState)(),s=(0,b.useCallback)(r=>{e.updateResource(BX(JSON.parse(r.resource))).then(()=>{o(void 0),i(`/${t}/${n}/details`)?.catch(console.error),J({color:`green`,message:`Success`})}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1})})},[e,t,n,i]);return r?(0,I.jsxs)(vP,{children:[a&&(0,I.jsx)(EP,{outcome:a}),(0,I.jsxs)(CN,{onSubmit:s,children:[(0,I.jsx)(lh,{name:`resource`,"data-testid":`resource-json`,autosize:!0,minRows:24,defaultValue:yC(r,!0),formatOnBlur:!0,deserialize:JSON.parse}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,children:(0,I.jsx)(U,{type:`submit`,children:`OK`})})]})]}):null}function tZ(e){let{resourceType:t,id:n}=e;return(0,I.jsxs)(vP,{children:[(0,I.jsxs)(Dd,{icon:(0,I.jsx)(uA,{size:16}),mb:`xl`,children:[`This is just a preview! Access your form here:`,(0,I.jsx)(`br`,{}),(0,I.jsx)(Pd,{href:`/forms/${n}`,children:`/forms/${n}`})]}),(0,I.jsx)(oL,{questionnaire:{reference:t+`/`+n},onSubmit:()=>alert(`You submitted the preview`)})]})}var nZ={propertyTable:`_propertyTable_1xts4_1`,propertiesTitle:`_propertiesTitle_1xts4_17`};function rZ(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 iZ(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=rZ(e))}),{code:t,description:n,value:r}});return(0,I.jsxs)(K,{className:nZ.propertyTable,children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:`Code`}),(0,I.jsx)(K.Th,{children:`Description`}),(0,I.jsx)(K.Th,{children:`Value`})]})}),(0,I.jsx)(K.Tbody,{children:n.map((e,t)=>(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:e.code}),(0,I.jsx)(K.Td,{children:e.description}),(0,I.jsx)(K.Td,{children:e.value})]},`property-${t}`))})]})}function aZ(e){let{valueSet:t}=e,n=Z(),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,I.jsx)(vP,{children:(0,I.jsxs)(G,{gap:`xl`,children:[(0,I.jsx)(jN,{binding:r,placeholder:`Select a value from the ValueSet`,onChange:e=>f(e[0]),defaultValue:i,maxValues:1}),i?(0,I.jsxs)(G,{gap:`md`,children:[(0,I.jsxs)(cP,{children:[(0,I.jsx)(lP,{term:`Code`,children:i.code}),i.system&&(0,I.jsx)(lP,{term:`System`,children:i.system}),i.display&&(0,I.jsx)(lP,{term:`Display`,children:i.display})]}),c&&(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(cu,{size:`sm`}),(0,I.jsx)(H,{size:`sm`,c:`dimmed`,children:`Loading properties...`})]}),!c&&u&&(0,I.jsxs)(Dd,{icon:(0,I.jsx)(uA,{size:16}),title:`Lookup Failed`,color:`red`,children:[`Failed to retrieve code information: `,Qx(u)]}),!c&&!u&&m&&(0,I.jsx)(Fj,{children:(0,I.jsxs)(G,{gap:`xs`,mt:`lg`,children:[(0,I.jsx)(H,{fw:500,size:`sm`,c:`dimmed`,className:nZ.propertiesTitle,children:`Properties`}),(0,I.jsx)(iZ,{properties:p})]})})]}):null]})})}function oZ(){let{resourceType:e,id:t}=SW(),n=nk({reference:e+`/`+t});return n?n.resourceType===`Questionnaire`?(0,I.jsx)(tZ,{resourceType:e,id:t}):n.resourceType===`ValueSet`?(0,I.jsx)(aZ,{valueSet:n}):null:null}function sZ(){let e=Z(),{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(MC(e))).catch(e=>{J({color:`red`,message:Qx(e)})})},[e,t,n]),r?(0,I.jsxs)(vP,{children:[(0,I.jsxs)(q,{order:2,children:[`Available `,t,` profiles`]}),(0,I.jsx)(G,{children:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(YX,{resource:r,currentProfile:a,onChange:o}),a?(0,I.jsx)(cZ,{profile:a,resource:r,onResourceUpdated:e=>i(e)},a.url):(0,I.jsx)(H,{my:`lg`,fz:`lg`,fs:`italic`,ta:`center`,children:`Select a profile above`})]})})]}):null}var cZ=({profile:e,resource:t,onResourceUpdated:n})=>{let r=Z(),[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=BX(t);o?rw(i,e.url):iw(i,e.url),r.updateResource(i).then(e=>{n(e),J({color:`green`,message:`Success`})}).catch(e=>{a(Zx(e)),J({color:`red`,message:Qx(e),autoClose:!1})})},[r,e.url,n,o]);return(0,I.jsxs)(G,{children:[(0,I.jsx)(Wy,{size:`md`,checked:o,label:`Conform resource to ${e.title}`,onChange:e=>s(e.currentTarget.checked),"data-testid":`profile-toggle`}),o?(0,I.jsx)(HB,{profileUrl:e.url,defaultValue:t,onSubmit:c,outcome:i}):(0,I.jsx)(`form`,{noValidate:!0,onSubmit:e=>{e.preventDefault(),c(t)},children:(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,children:(0,I.jsx)(U,{type:`submit`,children:`OK`})})})]})},lZ={"Create Only":`create`,"Update Only":`update`,"Delete Only":`delete`,"All Interactions":void 0},uZ=Object.keys(lZ);function dZ(){let e=Z(),{id:t}=SW(),n=nk({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=>fZ(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},${oC(n)}`:oC(n)}`,channel:{type:`rest-hook`,endpoint:oC(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`),J({color:`green`,message:`Success`})}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}return(0,I.jsxs)(vP,{children:[(0,I.jsx)(q,{children:`Bots`}),(0,I.jsxs)(G,{children:[l.length===0&&(0,I.jsx)(`p`,{children:`No bots found.`}),l.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{children:(0,I.jsx)(dL,{value:{reference:e.channel?.endpoint},link:!0})}),(0,I.jsxs)(`p`,{children:[`Criteria: `,e.criteria]})]},e.id))]}),(0,I.jsx)(dm,{}),(0,I.jsxs)(G,{mt:10,children:[(0,I.jsx)(rd,{size:`lg`,htmlFor:`bot`,children:`Connect to bot`}),(0,I.jsxs)(V,{children:[(0,I.jsx)(sI,{name:`bot`,resourceType:`Bot`,onChange:e=>i(e)}),(0,I.jsx)(U,{onClick:u,children:`Connect`})]}),(0,I.jsx)(V,{children:(0,I.jsx)(Eg,{name:`subscription-trigger-event`,defaultValue:`Create Only`,label:`Subscription Trigger Event`,data:uZ,onChange:e=>o(lZ[e.target.value])})})]}),(0,I.jsx)(`div`,{style:{display:`none`},children:s})]})}function fZ(e,t){if(!t)return!1;let n=e.criteria||``,r=e.channel?.endpoint||``;return n.startsWith(`QuestionnaireResponse?`)&&r.startsWith(`Bot/`)&&(n.includes(oC(t))||(t.url?n.includes(t.url):!1))}function pZ(){let{id:e}=SW(),t=vW(),n=Z().readReference({reference:`Questionnaire/${e}`}).read(),[r,i]=(0,b.useState)({resourceType:`QuestionnaireResponse`,filters:[{code:`questionnaire`,operator:X.EQUALS,value:n.url?`${n.url},Questionnaire/${e}`:`Questionnaire/${e}`}],fields:[`id`,`_lastUpdated`]});return(0,I.jsx)(vP,{children:(0,I.jsx)(sz,{search:r,onClick:e=>t(`/${e.resource.resourceType}/${e.resource.id}`)?.catch(console.error),onChange:e=>i(e.definition),hideFilters:!0,hideToolbar:!0})})}function mZ(){let e=Z(),{resourceType:t,id:n}=SW(),r=nk({reference:t+`/`+n}),i=(0,b.useCallback)(t=>{e.updateResource(BX(t)).then(()=>{J({color:`green`,message:`Success`})}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1})})},[e]);return r?(0,I.jsx)(vP,{children:(0,I.jsx)(_B,{onSubmit:i,definition:r})}):null}function hZ(){let{resourceType:e,id:t}=SW(),n=nk({reference:e+`/`+t});return n?(0,I.jsx)(vP,{children:e===`MeasureReport`?(0,I.jsx)(Oz,{measureReport:n}):(0,I.jsx)(mL,{value:n})}):null}var gZ={container:`_container_1ue98_1`,entry:`_entry_1ue98_14`,active:`_active_1ue98_21`};function _Z(e){let t=Z(),n=nk(e.value),[r,i]=(0,b.useState)();return(0,b.useEffect)(()=>{if(!n)return;let e=EK(n);if(!e)return;let r=`reference`in e?e.reference:oC(e);t.search(`ServiceRequest`,`subject=`+r).then(e=>{let t=(e.entry??[]).map(e=>e.resource);HL(t),t.reverse(),i(t)}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},[t,n]),r?(0,I.jsx)(`div`,{"data-testid":`quick-service-requests`,className:gZ.container,children:r.map(e=>(0,I.jsxs)(`div`,{className:Mn(gZ.entry,{[gZ.active]:e.id===n?.id}),children:[(0,I.jsx)(`p`,{children:(0,I.jsx)(Wj,{to:e,children:vZ(e)})}),e.category?.[0]?.text&&(0,I.jsx)(`p`,{children:e.category[0]?.text}),e.code?.coding?.[0]?.code&&(0,I.jsx)(`p`,{children:e.code.coding[0]?.code}),(0,I.jsx)(`p`,{children:yZ(e)})]},e.id))}):null}function vZ(e){if(e.identifier){for(let t of e.identifier)if(t.value)return t.value}return e.id||``}function yZ(e){return e.authoredOn?e.authoredOn.substring(0,10):e.meta?.lastUpdated?e.meta.lastUpdated.substring(0,10):``}var bZ={container:`_container_1l2dh_1`};function xZ(e){let t=nk(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,I.jsx)(`div`,{className:bZ.container,children:(0,I.jsx)(Eg,{defaultValue:e.defaultValue,onChange:t=>e.onChange(t.currentTarget.value),data:n})})}function SZ(e){let t=nk(e.specimen);return t?(0,I.jsxs)(_z,{children:[(0,I.jsxs)(_z.Entry,{children:[(0,I.jsx)(_z.Key,{children:`Type`}),(0,I.jsx)(_z.Value,{children:`Specimen`})]}),(0,I.jsxs)(_z.Entry,{children:[(0,I.jsx)(_z.Key,{children:`Collected`}),(0,I.jsx)(_z.Value,{children:fw(t.collection?.collectedDateTime)})]}),(0,I.jsxs)(_z.Entry,{children:[(0,I.jsx)(_z.Key,{children:`Specimen Age`}),(0,I.jsx)(_z.Value,{children:CZ(t)})]}),t.collection?.collectedDateTime&&t.receivedTime?(0,I.jsxs)(_z.Entry,{children:[(0,I.jsx)(_z.Key,{children:`Specimen Stability`}),(0,I.jsx)(_z.Value,{children:wZ(t)})]}):(0,I.jsx)(I.Fragment,{})]}):null}function CZ(e){let t=e.collection?.collectedDateTime;if(t)return TZ(EZ(new Date(t),new Date))}function wZ(e){if(!(!e.collection?.collectedDateTime||!e.receivedTime))return TZ(EZ(new Date(e.collection.collectedDateTime),new Date(e.receivedTime)))}function TZ(e){return e.toString().padStart(3,`0`)+`D`}function EZ(e,t){let n=t.getTime()-e.getTime();return Math.floor(n/(1e3*3600*24))}function DZ(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===`User`&&t.push(`Email`),e===`Communication`&&t.push(`Payload`),t.push(`Details`,`Edit`,`Event`,`History`,`Blame`,`JSON`,`Apps`,`Profiles`),e===`Patient`&&t.push(`Accounts`,`Export`),t}function OZ(){let e=Z(),{resourceType:t,id:n}=SW(),r={reference:t+`/`+n},[i,a]=(0,b.useState)(),o=nk(r,a),s=DZ(t);async function c(){let r=(await e.readHistory(t,n)).entry?.find(e=>!!e.resource)?.resource;r?l(r):J({color:`red`,message:`No history to restore`,autoClose:!1})}function l(t){e.updateResource(BX(t)).then(()=>{a(void 0),J({color:`green`,message:`Success`})}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1})})}if(i)return Yx(i)?(0,I.jsxs)(vP,{children:[(0,I.jsx)(q,{children:`Deleted`}),(0,I.jsx)(`p`,{children:`The resource was deleted.`}),(0,I.jsx)(U,{color:`red`,onClick:c,children:`Restore`})]}):(0,I.jsx)(EP,{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&&EK(o),f=o&&DK(o),p=e.getUserConfiguration()?.option?.find(e=>e.id===`statusValueSet`)?.valueString;return(0,I.jsxs)(I.Fragment,{children:[o?.resourceType===`ServiceRequest`&&p&&(0,I.jsx)(xZ,{valueSet:{reference:p},defaultValue:o.orderDetail?.[0]?.text,onChange:u},oC(o)+`-`+o.orderDetail?.[0]?.text),o&&(0,I.jsx)(_Z,{value:o}),o&&(0,I.jsxs)(yl,{children:[d&&(0,I.jsx)(Bz,{patient:d}),f&&(0,I.jsx)(SZ,{specimen:f}),t!==`Patient`&&(0,I.jsx)(eX,{resource:r}),(0,I.jsx)(ul,{children:(0,I.jsx)(yz,{baseUrl:`/${t}/${n}`,tabs:s})})]}),(0,I.jsx)(iG,{})]})}function kZ(){let e=vW(),{resourceType:t,id:n,versionId:r,tab:i}=SW(),a=Z(),[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,I.jsx)(Ij,{});let f=c?.entry??[],p=f.findIndex(e=>e.resource?.meta?.versionId===r);if(p===-1)return(0,I.jsxs)(vP,{children:[(0,I.jsx)(q,{children:`Version not found`}),(0,I.jsx)(Wj,{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,I.jsx)(am,{maw:1200,children:(0,I.jsx)(_P,{children:(0,I.jsxs)(G,{gap:`lg`,children:[u&&(0,I.jsx)(`pre`,{"data-testid":`error`,children:JSON.stringify(u,void 0,2)}),(0,I.jsxs)(vy,{cols:2,mb:`lg`,children:[(0,I.jsx)(rv,{total:f.length,value:v,getControlProps:ez,onChange:r=>e(`/${t}/${n}/_history/${f[f.length-r]?.resource?.meta?.versionId}/${_}`)?.catch(console.error)}),(0,I.jsx)(V,{justify:`right`,children:(0,I.jsx)(uy,{data:[{value:`diff`,label:`Diff`},{value:`raw`,label:`Raw`}],value:_,onChange:i=>e(`/${t}/${n}/_history/${r}/${i||g}`)?.catch(console.error)})})]}),(0,I.jsx)(z,{mb:`lg`,children:(0,I.jsxs)(cP,{compact:!0,children:[(0,I.jsx)(lP,{term:`Version ID`,children:m.meta?.versionId}),(0,I.jsx)(lP,{term:`Author`,children:(0,I.jsx)(fL,{value:m.meta?.author,link:!0},m.meta?.author?.reference)}),(0,I.jsx)(lP,{term:`Date/Time`,children:fw(m.meta?.lastUpdated)})]})}),_===`diff`&&(0,I.jsx)(zB,{original:h??{},revised:m}),_===`raw`&&(0,I.jsx)(`pre`,{style:{fontSize:`9pt`},children:JSON.stringify(m,void 0,2)})]})})})}function AZ(){let{resourceType:e,id:t}=SW(),n=vW(),[r,i]=(0,b.useState)({resourceType:`Subscription`,filters:[{code:`url`,operator:X.EQUALS,value:`${e}/${t}`}],fields:[`id`,`criteria`,`status`,`_lastUpdated`]});return(0,I.jsx)(vP,{children:(0,I.jsx)(sz,{search:r,onClick:e=>n(`/${e.resource.resourceType}/${e.resource.id}`)?.catch(console.error),onChange:e=>i(e.definition),hideFilters:!0})})}function jZ(e){let t=Z(),{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,I.jsx)(rg,{opened:r,onClose:i,title:`Resend Subscriptions`,children:(0,I.jsx)(CN,{onSubmit:(0,b.useCallback)(async()=>{if(n?.id)try{await t.post(t.fhirUrl(n.resourceType,n.id,`$resend`),{subscription:a&&s?oC(s):void 0,verbose:l}),J({color:`green`,message:`Done`}),i()}catch(e){J({color:`red`,message:Qx(e),autoClose:!1})}},[t,n,i,a,s,l]),children:(0,I.jsxs)(G,{children:[(0,I.jsx)(lp,{label:`Choose subscription (all subscriptions by default)`,onChange:e=>o(e.currentTarget.checked)}),a&&(0,I.jsx)(sI,{name:`subscription`,resourceType:`Subscription`,placeholder:`Subscription`,onChange:c}),(0,I.jsx)(lp,{label:`Verbose mode`,onChange:e=>u(e.currentTarget.checked)}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(U,{type:`submit`,children:`Resend`})})]})})})}function MZ(){let e=Z(),t=KO(),{resourceType:n,id:r}=SW(),i={reference:n+`/`+r},[a,o]=(0,b.useState)(),s=bn(!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`;J({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(),Ib({id:r,title:`AWS Textract Successful`,message:`Text successfully extracted.`,color:`green`,icon:(0,I.jsx)(wA,{size:`1rem`}),loading:!1,withCloseButton:!0})}).catch(e=>Ib({id:r,title:`AWS Textract Error`,color:`red`,message:Qx(e),icon:(0,I.jsx)(Nj,{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=xX()&&(r.resourceType===`DocumentReference`||r.resourceType===`Media`);return(0,I.jsxs)(W.Dropdown,{children:[(0,I.jsx)(W.Label,{children:`Resource`}),o&&(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(lj,{size:14}),onClick:()=>l(r,i),"aria-label":`Pin ${oC(r)}`,children:`Pin`}),s&&(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(uj,{size:14}),onClick:()=>u(r,i),"aria-label":`Unpin ${oC(r)}`,children:`Unpin`}),_&&(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(XA,{size:14}),onClick:()=>d(r),"aria-label":`Details ${oC(r)}`,children:`Details`}),c&&(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(XA,{size:14}),onClick:()=>h(r),"aria-label":`Details ${oC(r)}`,children:`Details`}),v&&(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(RA,{size:14}),onClick:()=>f(r),"aria-label":`Edit ${oC(r)}`,children:`Edit`}),b&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Label,{children:`Admin`}),x&&(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(hj,{size:14}),onClick:()=>m(r),"aria-label":`Resend Subscriptions ${oC(r)}`,children:`Resend Subscriptions`})]}),S&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Label,{children:`AWS AI`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(Oj,{size:14}),onClick:()=>g(r,i),"aria-label":`AWS Textract ${oC(r)}`,children:`AWS Textract`})]}),y&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Label,{children:`Danger zone`}),(0,I.jsx)(W.Item,{color:`red`,leftSection:(0,I.jsx)(kj,{size:14}),onClick:()=>p(r),"aria-label":`Delete ${oC(r)}`,children:`Delete`})]})]})}return(0,I.jsxs)(I.Fragment,{children:[n===`Encounter`&&(0,I.jsx)(rR,{encounter:i,getMenu:_}),n===`Patient`&&(0,I.jsx)(Vz,{patient:i,getMenu:_}),n===`ServiceRequest`&&(0,I.jsx)(bK,{serviceRequest:i,getMenu:_}),n!==`Encounter`&&n!==`Patient`&&n!==`ServiceRequest`&&(0,I.jsx)(nR,{resource:i,getMenu:_}),(0,I.jsx)(jZ,{resource:a,opened:s[0],onClose:s[1].close},`resend-subscriptions-${a?.id}`)]})}function NZ(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||UO(`app-tools-page`).then(c).catch(console.error),a())},[t,s,a]),s&&r&&!i?r===`unknown`?(0,I.jsx)(`p`,{children:`Unable to determine the current version of the agent. Check the network connectivity of the agent.`}):r.startsWith(s)?(0,I.jsxs)(`p`,{children:[`This agent is already on the latest version (`,s,`).`]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{children:[`Are you sure you want to upgrade this agent from version `,r,` to version `,s,`?`]}),(0,I.jsxs)(V,{children:[(0,I.jsx)(U,{onClick:()=>{o(l),n()},"aria-label":`Confirm upgrade`,children:`Confirm Upgrade`}),(0,I.jsx)(lp,{label:`Force`,onChange:e=>u(e.currentTarget.checked)})]})]}):(0,I.jsx)(Ij,{})}var PZ=[`live`,`ping`,`hl7ConnectionsOpen`,`hl7ClientCount`,`hl7QueueDepth`,`webSocketQueueDepth`,`outstandingHeartbeats`];function FZ(e){return e==null?``:typeof e==`object`?JSON.stringify(e):typeof e==`number`?e.toLocaleString():e.toString()}function IZ(e){let t=Object.keys(e.entries).filter(t=>e.entries[t]?.rtt);return t.length?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{order:3,mt:`md`,children:e.title}),(0,I.jsxs)(K,{children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:`Name`}),(0,I.jsx)(K.Th,{children:`Count`}),(0,I.jsx)(K.Th,{children:`Pending`}),(0,I.jsx)(K.Th,{children:`Min (ms)`}),(0,I.jsx)(K.Th,{children:`Avg (ms)`}),(0,I.jsx)(K.Th,{children:`Max (ms)`}),(0,I.jsx)(K.Th,{children:`p50 (ms)`}),(0,I.jsx)(K.Th,{children:`p95 (ms)`}),(0,I.jsx)(K.Th,{children:`p99 (ms)`})]})}),(0,I.jsx)(K.Tbody,{children:t.map(t=>{let n=e.entries[t].rtt;return(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:t}),(0,I.jsx)(K.Td,{children:n.count}),(0,I.jsx)(K.Td,{children:n.pendingCount}),(0,I.jsx)(K.Td,{children:n.min}),(0,I.jsx)(K.Td,{children:n.average}),(0,I.jsx)(K.Td,{children:n.max}),(0,I.jsx)(K.Td,{children:n.p50}),(0,I.jsx)(K.Td,{children:n.p95}),(0,I.jsx)(K.Td,{children:n.p99})]},t)})})]})]}):null}function LZ(e){let{stats:t}=e,n=new Set([...PZ,`channelStats`,`clientStats`]),r=Object.entries(t).filter(([e])=>!n.has(e));return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(K,{mt:`sm`,children:(0,I.jsxs)(K.Tbody,{children:[PZ.map(e=>(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:e}),(0,I.jsx)(K.Td,{children:FZ(t[e])})]},e)),r.map(([e,t])=>(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:e}),(0,I.jsx)(K.Td,{children:FZ(t)})]},e))]})}),(0,I.jsx)(IZ,{title:`Channel Stats`,entries:t.channelStats}),(0,I.jsx)(IZ,{title:`Client Stats`,entries:t.clientStats})]})}function RZ(){let e=Z(),{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}]=bn(!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=>ie(Qx(e))).finally(()=>i(!1))},[e,t]),ee=(0,b.useCallback)(t=>{let r=t.host,i=t.pingCount||1;r&&(C(!0),e.pushToAgent(n,r,`PING ${i}`,ZE.PING,!0).then(e=>x(e)).catch(e=>ie(Qx(e))).finally(()=>C(!1)))},[e,n]),N=(0,b.useCallback)(()=>{o(!0),e.get(e.fhirUrl(`Agent`,t,`$reload-config`),{cache:`reload`}).then(e=>{re(`Agent config reloaded successfully.`)}).catch(e=>ie(Qx(e))).finally(()=>o(!1))},[e,t]),P=(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=>{re(`Agent upgraded successfully.`)}).catch(e=>ie(Qx(e))).finally(()=>c(!1))},[e,t]),te=(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=>ie(Qx(e))).finally(()=>u(!1))},[e,t]),ne=(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){ie(Qx(e))}}).catch(e=>ie(Qx(e))).finally(()=>f(!1))},[e,t]);function re(e){J({color:`green`,title:`Success`,icon:(0,I.jsx)(wA,{size:`1rem`}),message:e})}function ie(e){J({color:`red`,title:`Error`,message:e,autoClose:!1})}return(0,I.jsxs)(vP,{children:[(0,I.jsx)(rg,{opened:O,onClose:A,title:`Upgrade Agent`,centered:!0,children:(0,I.jsx)(NZ,{opened:O,close:A,version:h,loadingStatus:r,handleStatus:M,handleUpgrade:P})}),(0,I.jsx)(q,{order:1,children:`Agent Tools`}),(0,I.jsxs)(`div`,{style:{marginBottom:10},children:[`Agent: `,(0,I.jsx)(dL,{value:n,link:!0})]}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Agent Status`}),(0,I.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,I.jsx)(U,{onClick:M,loading:r,disabled:j&&!r,children:`Get Status`}),!r&&p&&(0,I.jsx)(K,{children:(0,I.jsxs)(K.Tbody,{children:[(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:`Status`}),(0,I.jsx)(K.Td,{children:(0,I.jsx)(cL,{status:p})})]}),(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:`Version`}),(0,I.jsx)(K.Td,{children:h})]}),(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:`Last Updated`}),(0,I.jsx)(K.Td,{children:fw(_,void 0,{timeZoneName:`longOffset`})})]})]})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Reload Config`}),(0,I.jsx)(`p`,{children:`Reload the configuration of this agent, syncing it with the current version of the Agent resource on the Medplum server.`}),(0,I.jsx)(U,{onClick:N,loading:a,disabled:j&&!a,"aria-label":`Reload config`,children:`Reload Config`}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Upgrade Agent`}),(0,I.jsx)(`p`,{children:`Upgrade the version of this agent, to either the latest (default) or a specified version.`}),(0,I.jsx)(U,{onClick:k,loading:s,disabled:j&&!s,"aria-label":`Upgrade agent`,children:`Upgrade`}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsxs)(CN,{onSubmit:te,children:[(0,I.jsx)(q,{order:2,children:`Fetch Logs`}),(0,I.jsx)(`p`,{children:`Fetch logs from the agent.`}),w?.length?(0,I.jsx)(nm,{block:!0,mb:15,children:w}):null,(0,I.jsxs)(V,{children:[(0,I.jsx)(P_,{w:100,id:`logLimit`,name:`logLimit`,placeholder:`20`,label:`Log Limit`}),(0,I.jsx)(U,{mt:22,loading:l,disabled:j&&!l,"aria-label":`Fetch logs`,type:`submit`,children:`Fetch Logs`})]})]}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Agent Stats`}),(0,I.jsx)(`p`,{children:`Fetch runtime statistics from the agent, including connection counts, queue depths, RTT metrics, and overall agent health.`}),(0,I.jsx)(U,{onClick:ne,loading:d,disabled:j&&!d,"aria-label":`Get stats`,children:`Get Stats`}),!d&&E&&(0,I.jsx)(LZ,{stats:E}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Ping from Agent`}),(0,I.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,I.jsx)(CN,{onSubmit:ee,children:(0,I.jsxs)(V,{children:[(0,I.jsx)(yb,{id:`host`,name:`host`,placeholder:`ex. 127.0.0.1`,label:`IP Address / Hostname`,rightSection:(0,I.jsx)(gu,{size:24,radius:`xl`,variant:`filled`,type:`submit`,"aria-label":`Ping`,loading:S,disabled:j&&!S,children:(0,I.jsx)(_j,{style:{width:`1rem`,height:`1rem`},stroke:1.5})})}),(0,I.jsx)(P_,{id:`pingCount`,name:`pingCount`,placeholder:`1`,label:`Ping Count`})]})}),!S&&y&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{order:5,mt:`sm`,mb:0,children:`Last Ping`}),(0,I.jsx)(`pre`,{children:y})]})]})}function zZ(){let e=Z(),{id:t}=SW(),n=nk({reference:`User/${t}`}),[r,i]=(0,b.useState)(``),[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(!1);if(!n)return null;if(!n.project)return(0,I.jsx)(vP,{children:(0,I.jsx)(Dd,{color:`yellow`,children:`Update Email is only available for project-scoped Users.`})});function d(){if(!r)return;u(!0);let n={resourceType:`Parameters`,parameter:[{name:`email`,valueString:r}]};a&&n.parameter?.push({name:`updateProfileTelecom`,valueBoolean:!0}),s&&n.parameter?.push({name:`skipEmailVerification`,valueBoolean:!0}),e.post(e.fhirUrl(`User`,t,`$update-email`),n).then(()=>{J({color:`green`,message:`Email updated successfully`}),i(``)}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1})}).finally(()=>u(!1))}return(0,I.jsxs)(vP,{children:[(0,I.jsx)(q,{order:1,children:`Update Email`}),(0,I.jsxs)(`p`,{children:[`Update the email address for this User. The current email is `,(0,I.jsx)(`strong`,{children:n.email}),`.`]}),(0,I.jsx)(`form`,{onSubmit:e=>{e.preventDefault(),d()},children:(0,I.jsxs)(G,{children:[(0,I.jsx)(yb,{label:`New Email`,type:`email`,required:!0,placeholder:`new@example.com`,value:r,onChange:e=>i(e.currentTarget.value)}),(0,I.jsx)(lp,{label:`Update profile telecom`,description:`Add the new email to the associated profile resource's telecom and mark the old email as old`,checked:a,onChange:e=>o(e.currentTarget.checked)}),(0,I.jsx)(lp,{label:`Skip email verification`,description:`Do not send a verification email to the new address`,checked:s,onChange:e=>c(e.currentTarget.checked)}),(0,I.jsx)(`div`,{children:(0,I.jsx)(U,{type:`submit`,loading:l,disabled:!r,children:`Update Email`})})]})})]})}function BZ(){let e=vW(),t=Z(),[n,r]=(0,b.useState)();(0,b.useEffect)(()=>{t.get(`auth/me`,{cache:`no-cache`}).then(r).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},[t]);function i(e){t.post(`auth/revoke`,{loginId:e}).then(()=>t.get(`auth/me`,{cache:`no-cache`})).then(r).then(()=>J({color:`green`,message:`Login revoked`})).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}return n?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(vP,{children:[(0,I.jsx)(q,{children:`Security`}),(0,I.jsxs)(cP,{children:[(0,I.jsx)(lP,{term:`ID`,children:(0,I.jsx)(Pd,{href:`/${oC(n.profile)}`,children:n.profile.id})}),(0,I.jsx)(lP,{term:`Resource Type`,children:n.profile.resourceType}),(0,I.jsx)(lP,{term:`Name`,children:lw(n.profile.name?.[0])})]})]}),(0,I.jsxs)(vP,{children:[(0,I.jsx)(q,{children:`Sessions`}),(0,I.jsxs)(K,{children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:`OS`}),(0,I.jsx)(`th`,{children:`Browser`}),(0,I.jsx)(`th`,{children:`IP Address`}),(0,I.jsx)(`th`,{children:`Auth Method`}),(0,I.jsx)(`th`,{children:`Last Updated`}),(0,I.jsx)(`th`,{})]})}),(0,I.jsx)(`tbody`,{children:n.security.sessions.map(e=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:e.os}),(0,I.jsx)(`td`,{children:e.browser}),(0,I.jsx)(`td`,{children:e.remoteAddress}),(0,I.jsx)(`td`,{children:e.authMethod}),(0,I.jsx)(`td`,{children:fw(e.lastUpdated)}),(0,I.jsx)(`td`,{children:(0,I.jsx)(Pd,{href:`#`,onClick:()=>i(e.id),children:`Revoke`})})]},e.id))})]})]}),(0,I.jsxs)(vP,{children:[(0,I.jsx)(q,{children:`Password`}),(0,I.jsx)(U,{onClick:()=>e(`/changepassword`)?.catch(console.error),children:`Change password`})]}),(0,I.jsxs)(vP,{children:[(0,I.jsx)(q,{children:`Multi Factor Auth`}),(0,I.jsxs)(`p`,{children:[`Enrolled: `,n.security.mfaEnrolled.toString()]}),!n.security.mfaEnrolled&&(0,I.jsx)(U,{onClick:()=>e(`/mfa`)?.catch(console.error),children:`Enroll`})]})]}):null}function VZ(){let{id:e,secret:t}=SW(),n=vW();return(0,I.jsx)(IP,{id:e,secret:t,onSignIn:()=>n(`/signin`)?.catch(console.error)})}function HZ(){let e=qO(),t=vW(),[n]=cK(),r=yX(),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,I.jsxs)(eF,{onSuccess:()=>i(),onForgotPassword:()=>t(`/resetpassword`)?.catch(console.error),onRegister:bX()?()=>t(`/register`)?.catch(console.error):void 0,googleClientId:r.googleClientId,login:n.get(`login`)||void 0,projectId:n.get(`project`)||void 0,children:[(0,I.jsx)(yP,{size:32}),n.get(`project`)!==`new`&&(0,I.jsxs)(q,{order:3,py:`lg`,ta:`center`,children:[`Sign in to `,tM()]}),n.get(`project`)===`new`&&(0,I.jsx)(q,{order:3,py:`lg`,ta:`center`,children:`Sign in again to create a new project`})]})}function UZ(){let e=vW(),t=hW(),[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,I.jsx)(hz,{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 WZ(){let{id:e,secret:t}=SW(),n=Z(),[r,i]=(0,b.useState)(),[a,o]=(0,b.useState)(!1);return(0,I.jsxs)(vP,{width:450,children:[(0,I.jsx)(EP,{issues:xP(r,void 0)}),(0,I.jsxs)(CN,{onSubmit:async()=>{i(void 0);try{let r=Gx(await n.post(`auth/verifyemail`,{id:e,secret:t}));r?LE.assign(r):o(!0)}catch(e){i(Zx(e))}},children:[(0,I.jsxs)(_d,{direction:`column`,align:`center`,justify:`center`,children:[(0,I.jsx)(yP,{size:32}),(0,I.jsx)(q,{children:`Email address verification required`})]}),!a&&(0,I.jsxs)(G,{children:[(0,I.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,I.jsx)(V,{justify:`center`,mt:`xl`,children:(0,I.jsx)(wN,{children:`Verify email`})})]}),a&&(0,I.jsxs)(`div`,{"data-testid":`success`,children:[`Email verified. You can now\xA0`,(0,I.jsx)(Wj,{to:`/signin`,children:`sign in`}),`.`]})]})]})}function GZ(){return(0,I.jsx)(oG,{children:(0,I.jsxs)($,{errorElement:(0,I.jsx)($Y,{}),children:[(0,I.jsx)($,{path:`/signin`,element:(0,I.jsx)(HZ,{})}),(0,I.jsx)($,{path:`/oauth`,element:(0,I.jsx)(CX,{})}),(0,I.jsx)($,{path:`/resetpassword`,element:(0,I.jsx)(TX,{})}),(0,I.jsx)($,{path:`/setpassword/:id/:secret`,element:(0,I.jsx)(VZ,{})}),(0,I.jsx)($,{path:`/verifyemail/:id/:secret`,element:(0,I.jsx)(WZ,{})}),(0,I.jsx)($,{path:`/register`,element:(0,I.jsx)(wX,{})}),(0,I.jsx)($,{path:`/changepassword`,element:(0,I.jsx)(XY,{})}),(0,I.jsx)($,{path:`/security`,element:(0,I.jsx)(BZ,{})}),(0,I.jsx)($,{path:`/mfa`,element:(0,I.jsx)(_X,{})}),(0,I.jsx)($,{path:`/batch`,element:(0,I.jsx)(JY,{})}),(0,I.jsx)($,{path:`/bulk/:resourceType`,element:(0,I.jsx)(YY,{})}),(0,I.jsx)($,{path:`/smart`,element:(0,I.jsx)(UZ,{})}),(0,I.jsx)($,{path:`/forms/:id`,element:(0,I.jsx)(tX,{})}),(0,I.jsx)($,{path:`/admin/super`,element:(0,I.jsx)(qq,{})}),(0,I.jsx)($,{path:`/admin/super/asyncjob/:tab`,element:(0,I.jsx)(Nq,{})}),(0,I.jsx)($,{path:`/admin/super/asyncjob`,element:(0,I.jsx)(Nq,{})}),(0,I.jsx)($,{path:`/admin/super/db/:tab`,element:(0,I.jsx)(oq,{})}),(0,I.jsx)($,{path:`/admin/super/db`,element:(0,I.jsx)(oq,{})}),(0,I.jsx)($,{path:`/admin/config`,element:(0,I.jsx)(fq,{})}),(0,I.jsxs)($,{path:`/admin`,element:(0,I.jsx)(hq,{}),children:[(0,I.jsx)($,{path:`bots/:membershipId`,element:(0,I.jsx)(cq,{})}),(0,I.jsx)($,{path:`bots/new`,element:(0,I.jsx)(NK,{})}),(0,I.jsx)($,{path:`bots`,element:(0,I.jsx)(AK,{})}),(0,I.jsx)($,{path:`clients/:membershipId`,element:(0,I.jsx)(cq,{})}),(0,I.jsx)($,{path:`clients/new`,element:(0,I.jsx)(PK,{})}),(0,I.jsx)($,{path:`clients`,element:(0,I.jsx)(jK,{})}),(0,I.jsx)($,{path:`details`,element:(0,I.jsx)(pq,{})}),(0,I.jsx)($,{path:`invite`,element:(0,I.jsx)(sq,{})}),(0,I.jsx)($,{path:`patients`,element:(0,I.jsx)(rG,{to:`/admin/users`,replace:!0})}),(0,I.jsx)($,{path:`users/:membershipId`,element:(0,I.jsx)(cq,{})}),(0,I.jsx)($,{path:`users`,element:(0,I.jsx)(Qq,{})}),(0,I.jsx)($,{path:`project`,element:(0,I.jsx)(pq,{})}),(0,I.jsx)($,{path:`secrets`,element:(0,I.jsx)(Aq,{})}),(0,I.jsx)($,{path:`sites`,element:(0,I.jsx)(jq,{})}),(0,I.jsx)($,{path:`rate-limits`,element:(0,I.jsx)(Eq,{})})]}),(0,I.jsx)($,{path:`/lab/assays`,element:(0,I.jsx)(pX,{})}),(0,I.jsx)($,{path:`/lab/panels`,element:(0,I.jsx)(gX,{})}),(0,I.jsxs)($,{path:`/:resourceType/new`,element:(0,I.jsx)(QY,{}),children:[(0,I.jsx)($,{index:!0,element:(0,I.jsx)(ZX,{})}),(0,I.jsx)($,{path:`form`,element:(0,I.jsx)(ZX,{})}),(0,I.jsx)($,{path:`json`,element:(0,I.jsx)($X,{})}),(0,I.jsx)($,{path:`profiles`,element:(0,I.jsx)(ZX,{})})]}),(0,I.jsxs)($,{path:`/:resourceType/:id`,element:(0,I.jsx)(OZ,{}),children:[(0,I.jsx)($,{index:!0,element:(0,I.jsx)(MZ,{})}),(0,I.jsx)($,{path:`apply`,element:(0,I.jsx)(OX,{})}),(0,I.jsx)($,{path:`apps`,element:(0,I.jsx)(kX,{})}),(0,I.jsx)($,{path:`event`,element:(0,I.jsx)(jX,{})}),(0,I.jsx)($,{path:`blame`,element:(0,I.jsx)(MX,{})}),(0,I.jsx)($,{path:`bots`,element:(0,I.jsx)(dZ,{})}),(0,I.jsx)($,{path:`builder`,element:(0,I.jsx)(VX,{})}),(0,I.jsx)($,{path:`checklist`,element:(0,I.jsx)(HX,{})}),(0,I.jsx)($,{path:`delete`,element:(0,I.jsx)(WX,{})}),(0,I.jsx)($,{path:`details`,element:(0,I.jsx)(KX,{})}),(0,I.jsx)($,{path:`edit`,element:(0,I.jsx)(qX,{})}),(0,I.jsx)($,{path:`editor`,element:(0,I.jsx)(RX,{})}),(0,I.jsxs)($,{path:`history`,children:[(0,I.jsx)($,{index:!0,element:(0,I.jsx)(QX,{})}),(0,I.jsx)($,{path:`:versionId/:tab`,element:(0,I.jsx)(kZ,{})}),(0,I.jsx)($,{path:`:versionId`,element:(0,I.jsx)(kZ,{})})]}),(0,I.jsxs)($,{path:`_history`,children:[(0,I.jsx)($,{index:!0,element:(0,I.jsx)(QX,{})}),(0,I.jsx)($,{path:`:versionId/:tab`,element:(0,I.jsx)(kZ,{})}),(0,I.jsx)($,{path:`:versionId`,element:(0,I.jsx)(kZ,{})})]}),(0,I.jsx)($,{path:`json`,element:(0,I.jsx)(eZ,{})}),(0,I.jsx)($,{path:`preview`,element:(0,I.jsx)(oZ,{})}),(0,I.jsx)($,{path:`responses`,element:(0,I.jsx)(pZ,{})}),(0,I.jsx)($,{path:`report`,element:(0,I.jsx)(hZ,{})}),(0,I.jsx)($,{path:`ranges`,element:(0,I.jsx)(mZ,{})}),(0,I.jsx)($,{path:`subscriptions`,element:(0,I.jsx)(AZ,{})}),(0,I.jsx)($,{path:`timeline`,element:(0,I.jsx)(MZ,{})}),(0,I.jsx)($,{path:`tools`,element:(0,I.jsx)(RZ,{})}),(0,I.jsx)($,{path:`email`,element:(0,I.jsx)(zZ,{})}),(0,I.jsx)($,{path:`payload`,element:(0,I.jsx)(UX,{})}),(0,I.jsx)($,{path:`profiles`,element:(0,I.jsx)(sZ,{})}),(0,I.jsx)($,{path:`accounts`,element:(0,I.jsx)(EX,{})}),(0,I.jsx)($,{path:`export`,element:(0,I.jsx)(JX,{})})]}),(0,I.jsx)($,{path:`/:resourceType`,element:(0,I.jsx)(fX,{})}),(0,I.jsx)($,{path:`/`,element:(0,I.jsx)(fX,{})})]})})}function KZ(){let e=Z(),t=e.getUserConfiguration(),n=hW(),[r]=cK();return e.isLoading()?(0,I.jsx)(Ij,{}):(0,I.jsxs)(eP,{logo:(0,I.jsx)(yP,{size:24}),pathname:n.pathname,searchParams:r,version:RD,menus:qZ(t),displayAddBookmark:!!t?.id,children:[(0,I.jsx)(yK,{}),(0,I.jsx)(b.Suspense,{fallback:(0,I.jsx)(Ij,{}),children:(0,I.jsx)(GZ,{})})]})}function qZ(e){let t=e?.menu?.map(e=>({title:e.title,links:e.link?.map(e=>({label:e.name,href:e.target,icon:YZ(e.target)}))||[]}))||[];return t.push({title:`Settings`,links:[{label:`Security`,href:`/security`,icon:(0,I.jsx)(QA,{})}]}),t}var JZ={Patient:Cj,Practitioner:JA,Organization:SA,ServiceRequest:pj,DiagnosticReport:gj,Questionnaire:qA,Project:KA,admin:vA,AccessPolicy:ZA,Subscription:Mj,batch:oj,Observation:rj};function YZ(e){if(e.includes(`admin/super/db`))return(0,I.jsx)(PA,{});try{let t=new URL(e,`https://app.medplum.com`).pathname.split(`/`)[1];if(t in JZ){let e=JZ[t];return(0,I.jsx)(e,{})}}catch{}}async function XZ(){let e=yX(),t=new XD({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=li({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=YG([{path:`*`,element:(0,I.jsx)(KZ,{})}]);(0,TK.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(b.StrictMode,{children:(0,I.jsx)(YO,{medplum:t,navigate:e=>r.navigate(e),children:(0,I.jsxs)(Vr,{theme:n,children:[(0,I.jsx)(xx,{position:`bottom-right`}),(0,I.jsx)($W,{router:r})]})})}))}XZ().catch(console.error);
237
- //# sourceMappingURL=index-Bt4T35gx.js.map
237
+ //# sourceMappingURL=index-BZEDQTgb.js.map