@medplum/app 5.1.17 → 5.1.18

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?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=`{
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(){}function kD(e){if(e instanceof wD.CloseEvent){let t=e;return new wD.CloseEvent(t.code,t.reason,void 0)}if(e instanceof wD.ErrorEvent){let t=e;return new wD.ErrorEvent(t.error??Error(t.message),void 0)}return new e.constructor(e.type,e)}function AD(e,t){let n=e;return n.error instanceof Error?new wD.ErrorEvent(n.error,t):new wD.ErrorEvent(Error(n.message||`WebSocket error`),t)}var jD={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1},MD=!1,ND=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=jD.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=jD.reconnectionDelayGrowFactor,minReconnectionDelay:t=jD.minReconnectionDelay,maxReconnectionDelay:n=jD.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=jD.maxRetries,connectionTimeout:t=jD.connectionTimeout}=this._options;if(this._retryCount>=e){this._connectLock=!1,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`&&!MD&&(console.error(`‼️ No WebSocket implementation available. You should define options.WebSocket.`),MD=!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)return;let n=this._ws;this._removeListeners(),n.addEventListener(`error`,OD);try{n.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=jD.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(kD(e))};_handleMessage=e=>{this._debug(`message event`),this.onmessage&&this.onmessage(e),this.dispatchEvent(kD(e))};_handleError=e=>{let t=AD(e,this);this._debug(`error event`,t.message),this._disconnect(void 0,t.message===`TIMEOUT`?`timeout`:void 0),this.onerror&&this.onerror(t),this._debug(`exec error listeners`),this.dispatchEvent(kD(t)),this._connect()};_handleClose=e=>{this._debug(`close event`),this._clearTimeouts(),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(e),this.dispatchEvent(kD(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)}},PD=6e4,FD=[WebSocket.CLOSING,WebSocket.CLOSED],ID=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)}},LD=class{criteria;emitter;refCount;subscriptionProps;subscriptionId;token;tokenExpiry;state=`idle`;generation=0;lastUnrefTime;constructor(e,t){this.criteria=e,this.emitter=new ID(e),this.refCount=1,this.subscriptionProps=t?{...t}:void 0}nextGeneration(){return++this.generation}},RD=class{medplum;ws;masterSubEmitter;criteriaEntries;criteriaEntriesBySubscriptionId;wsClosed;pingTimer=void 0;tokenRefreshTimer=void 0;pingIntervalMs;waitingForPong=!1;currentProfile;constructor(e,t,n){if(!(e instanceof QD))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 ND(r,void 0,{debug:n?.debug,debugLogger:n?.debugLogger});this.medplum=e,this.ws=i,this.masterSubEmitter=new ID,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()},PD)}),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 zD(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 zD(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 zD(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 LD(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 zD(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 zD(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 ID(...Array.from(this.criteriaEntries.keys())),this.masterSubEmitter}async reconnectIfNeeded(){FD.includes(this.getWebSocket().readyState)&&await new Promise(e=>{let t=()=>{this.getWebSocket().removeEventListener(`open`,t),e()};this.getWebSocket().addEventListener(`open`,t),this.reconnectWebSocket()})}};function zD(e){return e.bareCriteria?[e.bareCriteria,...e.criteriaWithProps]:e.criteriaWithProps}new Sx(1e3);var BD=`5.1.18-728d66a`,VD=ZE.FHIR_JSON+`, */*; q=0.1`,HD=`https://api.medplum.com/`,UD=1e3,WD=6e4,GD=0,KD=3e5,qD=`Binary/`,JD={resourceType:`Device`,id:`system`,deviceName:[{type:`model-name`,name:`System`}]},YD={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`},XD={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`},ZD={JwtBearer:`urn:ietf:params:oauth:client-assertion-type:jwt-bearer`},QD=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??$D(),this.storage=e?.storage??new SD(void 0,e?.storagePrefix),this.createPdfImpl=e?.createPdf,this.baseUrl=QC(e?.baseUrl??HD),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??KD,this.logLevel=this.initializeLogLevel(e),this.maxRetries=e?.maxRetries??2,this.maxRetryTime=e?.maxRetryTime??2e3,this.cacheTime=e?.cacheTime??(FE()?WD:GD),this.cacheTime>0?this.requestCache=new Sx(e?.resourceCacheSize??UD):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:YD.TokenExchange,subject_token_type:XD.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(tO));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 tO(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 JD;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(JD));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,
@@ -93,7 +93,7 @@ ${o?`${s(`light`)}{${o}}`:``}`}function Dr({color:e,theme:t,autoContrast:n}){ret
93
93
  expression,
94
94
  target
95
95
  }
96
- }`.replaceAll(/\s+/g,` `),n=await this.graphql(t);uS(n.data.StructureDefinitionList);for(let e of n.data.SearchParameterList)jw(e)})());return this.setCacheEntry(n,i,t),i}requestProfileSchema(e,t){if(!t?.expandProfile&&hS(e))return Promise.resolve();let n=e+`-requestSchema`+(t?.expandProfile?`-nested`:``),r=this.getCacheEntry(n,void 0);if(r)return r.value;let i=new xD((async()=>{if(t?.expandProfile){let t=this.fhirUrl(`StructureDefinition`,`$expand-profile`);t.search=new URLSearchParams({url:e}).toString(),uS(await this.post(t.toString(),{}))}else{let t=await this.searchOne(`StructureDefinition`,{url:e,_sort:`-_lastUpdated`});if(!t){console.warn(`No StructureDefinition found for ${e}!`);return}dS(t)}})());return this.setCacheEntry(n,i,t),i}readHistory(e,t,n,r){let i=this.fhirUrl(e,t,`_history`);return n?.count&&i.searchParams.set(`_count`,n.count.toString()),n?.offset&&i.searchParams.set(`_offset`,n.offset.toString()),this.get(i.toString(),r)}readVersion(e,t,n,r){return this.get(this.fhirUrl(e,t,`_history`,n),r)}readPatientEverything(e,t){return this.getBundle(this.fhirUrl(`Patient`,e,`$everything`),t)}readPatientSummary(e,t){return this.getBundle(this.fhirUrl(`Patient`,e,`$summary`),t)}createResource(e,t){if(!e.resourceType)throw Error(`Missing resourceType`);return this.invalidateSearches(e.resourceType),this.post(this.fhirUrl(e.resourceType),e,void 0,t)}async createResourceIfNoneExist(e,t,n={}){let r=this.fhirUrl(e.resourceType);this.setRequestHeader(n,`If-None-Exist`,t);let i=await this.post(r,e,void 0,n);return this.cacheResource(i,n),this.invalidateUrl(this.fhirUrl(e.resourceType,e.id,`_history`)),this.invalidateSearches(e.resourceType),i}async upsertResource(e,t,n){let r=this.fhirSearchUrl(e.resourceType,t),i=await this.put(r,e,void 0,n);return i||=e,this.cacheResource(i,n),this.invalidateUrl(this.fhirUrl(e.resourceType,e.id,`_history`)),this.invalidateSearches(e.resourceType),i}async createAttachment(e,t,n,r,i){let a=tO(e,t,n,r);if(a.contentType===ZE.XML){let e=a.data,t;t=e instanceof Blob?await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{if(!r.result){n(Error(`Failed to load file`));return}t(r.result)},r.readAsText(e,`utf-8`)}):ArrayBuffer.isView(e)?new TextDecoder().decode(e):e,t.includes(`<ClinicalDocument`)&&t.includes(`urn:hl7-org:v3`)&&(a={...a,contentType:ZE.CDA_XML})}let o=i??(typeof t==`object`?t:{}),s=await this.createBinary(a,o);return{contentType:a.contentType,url:s.url,title:a.filename}}createBinary(e,t,n,r,i){let a=tO(e,t,n,r),o=i??(typeof t==`object`?t:{}),{data:s,contentType:c,filename:l,securityContext:u,onProgress:d}=a,f=this.fhirUrl(`Binary`);return l&&f.searchParams.set(`_filename`,l),u?.reference&&this.setRequestHeader(o,`X-Security-Context`,u.reference),d?this.uploadwithProgress(f,s,c,d,o):this.post(f,s,c,o)}uploadwithProgress(e,t,n,r,i){return new Promise((a,o)=>{let s=new XMLHttpRequest,c=()=>s.abort();i?.signal?.addEventListener(`abort`,c);let l=e=>{i?.signal?.removeEventListener(`abort`,c),e instanceof Error?o(e):a(e)};if(s.responseType=`json`,s.onabort=()=>l(new DOMException(`Request aborted`,`AbortError`)),s.onerror=()=>l(Error(`Request error`)),r&&(s.upload.onprogress=e=>r(e),s.upload.onload=e=>r(e)),s.onload=()=>{s.status>=200&&s.status<300?l(s.response):l(new Xx(Zx(s.response||s.statusText)))},s.open(`POST`,e),s.withCredentials=!0,s.setRequestHeader(`Authorization`,`Bearer `+this.accessToken),s.setRequestHeader(`Cache-Control`,`no-cache, no-store, max-age=0`),s.setRequestHeader(`Content-Type`,n),this.options.extendedMode!==!1&&s.setRequestHeader(`X-Medplum`,`extended`),i?.headers){let e=i.headers;for(let[t,n]of Object.entries(e))s.setRequestHeader(t,n)}s.send(t)})}async createPdf(e,t,n,r){if(!this.createPdfImpl)throw Error(`PDF creation not enabled`);let i=rO(e,t,n,r),a=typeof t==`object`?t:{},{docDefinition:o,tableLayouts:s,fonts:c,...l}=i,u=await this.createPdfImpl(o,s,c),d={...l,data:u,contentType:`application/pdf`};return this.createBinary(d,a)}createComment(e,t,n){let r=this.getProfile(),i,a;return e.resourceType===`Encounter`&&(i=aC(e),a=e.subject),e.resourceType===`ServiceRequest`&&(i=e.encounter,a=e.subject),e.resourceType===`Patient`&&(a=aC(e)),this.createResource({resourceType:`Communication`,status:`completed`,basedOn:[aC(e)],encounter:i,subject:a,sender:r?aC(r):void 0,sent:new Date().toISOString(),payload:[{contentString:t}]},n)}async updateResource(e,t){if(!e.resourceType)throw Error(`Missing resourceType`);if(!e.id)throw Error(`Missing id`);let n=await this.put(this.fhirUrl(e.resourceType,e.id),e,void 0,t);return n||=e,this.cacheResource(n,t),this.invalidateUrl(this.fhirUrl(e.resourceType,e.id,`_history`)),this.invalidateSearches(e.resourceType),n}async patchResource(e,t,n,r){let i=await this.patch(this.fhirUrl(e,t),n,r);return this.cacheResource(i,r),this.invalidateUrl(this.fhirUrl(e,t,`_history`)),this.invalidateSearches(e),i}deleteResource(e,t,n){return this.deleteCacheEntry(this.fhirUrl(e,t).toString()),this.invalidateSearches(e),this.delete(this.fhirUrl(e,t),n)}validateResource(e,t){return this.post(this.fhirUrl(e.resourceType,`$validate`),e,void 0,t)}executeBot(e,t,n,r){let i;if(typeof e==`string`){let t=e;i=this.fhirUrl(`Bot`,t,`$execute`)}else{let t=e;i=this.fhirUrl(`Bot`,`$execute`),i.searchParams.set(`identifier`,t.system+`|`+t.value)}return this.post(i,t,n,r)}executeBatch(e,t){return this.post(this.fhirBaseUrl,e,void 0,t)}sendEmail(e,t){return this.post(`email/v1/send`,e,ZE.JSON,t)}graphql(e,t,n,r){return this.post(this.fhirUrl(`$graphql`),{query:e,operationName:t,variables:n},ZE.JSON,r)}readResourceGraph(e,t,n,r){return this.get(`${this.fhirUrl(e,t)}/$graph?graph=${n}`,r)}pushToAgent(e,t,n,r,i,a){let{waitTimeout:o,returnAck:s,...c}=a??{};return this.post(this.fhirUrl(`Agent`,sC(e),`$push`),{destination:typeof t==`string`?t:oC(t),body:n,contentType:r,waitForResponse:i,...o===void 0?void 0:{waitTimeout:o},...s===void 0?void 0:{returnAck:s}},ZE.FHIR_JSON,c)}getCdsServices(e){return this.get(this.cdsServicesUrl,e)}callCdsService(e,t,n){return this.post(ew(this.cdsServicesUrl,e),t,ZE.JSON,n)}getActiveLogin(){return this.storage.getObject(`activeLogin`)}async setActiveLogin(e){(!this.sessionDetails?.profile||oC(this.sessionDetails.profile)!==e.profile?.reference)&&this.clearActiveLogin(),this.setAccessToken(e.accessToken,e.refreshToken),this.storage.setObject(`activeLogin`,e),this.addLogin(e),this.refreshPromise=void 0,await this.refreshProfile()}getAccessToken(){return this.accessToken}isAuthenticated(e){return this.accessTokenExpires!==void 0&&Date.now()<this.accessTokenExpires-(e??this.refreshGracePeriod)}setAccessToken(e,t){this.accessToken=e,this.refreshToken=t,this.accessTokenExpires=yD(e),this.medplumServer=vD(e)}getLogins(){return this.storage.getObject(`logins`)??[]}addLogin(e){let t=this.getLogins().filter(t=>t.profile?.reference!==e.profile?.reference);t.push(e),this.storage.setObject(`logins`,t)}async refreshProfile(){if(this.medplumServer)return this.profilePromise=new Promise((e,t)=>{this.get(`auth/me`,{cache:`no-cache`}).then(t=>{this.profilePromise=void 0;let n=this.sessionDetails?.profile?.id!==t.profile.id;this.sessionDetails=t,this.syncStoredLoginProject(),n&&this.dispatchEvent({type:`change`}),e(t.profile),this.dispatchEvent({type:`profileRefreshed`})}).catch(t)}),this.dispatchEvent({type:`profileRefreshing`}),this.profilePromise}syncStoredLoginProject(){let e=this.getActiveLogin(),t=this.sessionDetails?.project?.name;if(!e||!t||e.project.display===t)return;let n={...e,project:{...e.project,display:t}};this.storage.setObject(`activeLogin`,n),this.addLogin(n)}isLoading(){return!this.isInitialized||!!this.profilePromise&&!this.sessionDetails?.profile}isSuperAdmin(){return!!this.sessionDetails?.project.superAdmin}isProjectAdmin(){return!!this.sessionDetails?.membership.admin}getProject(){return this.sessionDetails?.project}getProjectMembership(){return this.sessionDetails?.membership}getProfile(){return this.sessionDetails?.profile}async getProfileAsync(){return this.profilePromise?this.profilePromise:this.sessionDetails?this.sessionDetails.profile:this.refreshProfile()}getUserConfiguration(){return this.sessionDetails?.config}getAccessPolicy(){return this.sessionDetails?.accessPolicy}async download(e,t={}){return(await this.downloadResponse(e,t)).blob()}async downloadResponse(e,t={}){this.refreshPromise&&await this.refreshPromise;let n=e.toString();n.startsWith(GD)&&(e=this.fhirUrl(n));let r=t.headers;return r||(r={},t.headers=r),r.Accept||=`*/*`,this.addFetchOptionsDefaults(t),this.fetchWithRetry(e.toString(),t)}async createMedia(e,t){let{additionalFields:n,...r}=e,i=await this.createResource({resourceType:`Media`,status:`preparation`,content:{contentType:e.contentType},...n});r.securityContext||=aC(i);let a=await this.createAttachment(r,t);return this.updateResource({...i,status:`completed`,content:a})}async uploadMedia(e,t,n,r,i){return this.createMedia({data:e,contentType:t,filename:n,additionalFields:r},i)}async createDocumentReference(e,t){let{additionalFields:n,...r}=e,i=await this.createResource({resourceType:`DocumentReference`,status:`current`,content:[{attachment:{contentType:e.contentType}}],...n});r.securityContext||=aC(i);let a=await this.createAttachment(r,t);return this.updateResource({...i,content:[{attachment:a}]})}async bulkExport(e=``,t,n,r){let i=e&&`${e}/`,a=this.fhirUrl(`${i}$export`);return t&&a.searchParams.set(`_type`,t),n&&a.searchParams.set(`_since`,n),this.startAsyncRequest(a.toString(),r)}async startAsyncRequest(e,t={}){this.addFetchOptionsDefaults(t);let n=t.headers;return n.Prefer=`respond-async`,t.method=`POST`,this.request(e,t)}async wrappedFetch(e,t){return await this.refreshIfExpired(),this.addFetchOptionsDefaults(t),this.fetchWithRetry(e,t)}get keyValue(){return this.keyValueClient||=new bD(this),this.keyValueClient}getBundle(e,t){return new xD((async()=>{let n=await this.get(e,t);for(let e of n.entry??aw)this.cacheResource(e.resource,t);return n})())}isCacheEnabled(e){return!!this.requestCache&&!this.getRequestHeader(e,`x-medplum-on-behalf-of`)}getCacheEntry(e,t){if(!this.isCacheEnabled(t)||t?.cache===`no-cache`||t?.cache===`reload`)return;let n=this.requestCache.get(e);if(!(!n||n.requestTime+this.cacheTime<Date.now()))return n}setCacheEntry(e,t,n){this.isCacheEnabled(n)&&(this.requestCache.set(e,{requestTime:Date.now(),value:t}),n?.signal&&n.signal.addEventListener(`abort`,()=>{this.requestCache.delete(e)}))}cacheResource(e,t){e?.id&&!e.meta?.tag?.some(e=>e.code===`SUBSETTED`)&&this.setCacheEntry(this.fhirUrl(e.resourceType,e.id).toString(),new xD(Promise.resolve(e)),t)}deleteCacheEntry(e){this.requestCache&&this.requestCache.delete(e)}async request(e,t={},n={}){let r=await this.wrappedFetch(e,t);if(r.status===401)return this.handleUnauthenticated(e,t);if(r.status===204||r.status===304)return;let i=r.headers.get(`content-type`)?.includes(`json`);if(r.status===404&&!i)throw new Xx(Rx);let a=await this.parseBody(r,i);if(r.status===200&&t.followRedirectOnOk||r.status===201&&t.followRedirectOnCreated){let e=await QD(r,a);if(e)return this.request(e,{...t,method:`GET`,body:void 0})}if(r.status===202&&t.pollStatusOnAccepted){let e=await QD(r,a)??n.statusUrl;if(e)return this.pollStatus(e,t,n)}if(r.status>=400)throw new Xx(Zx(a));return a}async parseBody(e,t){let n;if(e.headers.get(`content-length`)!==`0`){if(t)try{n=await e.json()}catch(t){throw console.error(`Error parsing response`,e.status,t),t}else n=await e.text();return n}}async fetchWithRetry(e,t){e.startsWith(`http`)||(e=ew(this.baseUrl,e));let n=t?.maxRetries??this.maxRetries;for(let r=0;r<=n;r++)try{this.logLevel!==`none`&&this.logRequest(e,t);let i=await this.fetch(e,t);if(this.logLevel!==`none`&&this.logResponse(i),this.setCurrentRateLimit(i),r>=n||!iO(i))return i;let a=this.getRetryDelay(r);if(a>(t.maxRetryTime??this.maxRetryTime))return i;await qC(a,{signal:t.signal})}catch(e){if(e.message===`Failed to fetch`&&r===0&&this.dispatchEvent({type:`offline`}),e.name===`AbortError`||r===n)throw e}throw Error(`Unreachable`)}logRequest(e,t){if(console.log(`> ${t.method} ${e}`),this.logLevel===`verbose`&&t.headers){let e=t.headers;for(let t of ZC(Object.keys(e)))console.log(`> ${t}: ${e[t]}`)}}logResponse(e){console.log(`< ${e.status} ${e.statusText}`),this.logLevel===`verbose`&&e.headers&&e.headers.forEach((e,t)=>console.log(`< ${t}: ${e}`))}setCurrentRateLimit(e){if(!e?.headers||typeof e.headers.get!=`function`)return;let t=e.headers.get(`ratelimit`);t&&(this.currentRateLimits=t)}rateLimitStatus(){if(!this.currentRateLimits)return[];let e=this.currentRateLimits;return e.split(`,`).map(t=>{let n=t.split(`;`).map(e=>e.trim());if(n.length!==3)throw Error(`Could not parse RateLimit header: `+e);let r=n[0].substring(1,n[0].length-1),i=n.find(e=>e.startsWith(`r=`))?.substring(2),a=i?Number.parseInt(i,10):NaN,o=n.find(e=>e.startsWith(`t=`))?.substring(2),s=o?Number.parseInt(o,10):NaN;if(!r||Number.isNaN(a)||Number.isNaN(s))throw Error(`Could not parse RateLimit header: `+e);return{name:r,remainingUnits:a,secondsUntilReset:s,resetsAfter:Math.ceil((Date.now()+1e3*s)/1e3)}})}getRetryDelay(e){let t=this.rateLimitStatus(),n=500*1.5**e;for(let e of t)e.remainingUnits||(n=Math.max(n,e.secondsUntilReset*1e3));return n}async pollStatus(e,t,n){let r={...t,method:`GET`,body:void 0,redirect:`follow`};return n.pollCount===void 0?(t.headers&&typeof t.headers==`object`&&`Prefer`in t.headers&&(r.headers={...t.headers},delete r.headers.Prefer),n.statusUrl=e,n.pollCount=1):(await qC(t.pollStatusPeriod??1e3,{signal:t.signal}),n.pollCount++),this.request(e,{...t,method:`GET`},n)}async executeAutoBatch(){if(this.autoBatchQueue===void 0)return;let e=[...this.autoBatchQueue];if(this.autoBatchQueue.length=0,this.autoBatchTimerId=void 0,e.length===1){let t=e[0];try{t.options.method=t.method,t.resolve(await this.request(ew(this.fhirBaseUrl,t.url),t.options))}catch(e){t.reject(new Xx(Zx(e)))}return}let t={resourceType:`Bundle`,type:`batch`,entry:e.map(e=>({request:{method:e.method,url:e.url},resource:e.options.body?JSON.parse(e.options.body):void 0}))},n=await this.post(this.fhirBaseUrl,t);for(let t=0;t<e.length;t++){let r=e[t],i=n.entry?.[t];i?.response?.outcome&&!Jx(i.response.outcome)?r.reject(new Xx(i.response.outcome)):r.resolve(i?.resource)}}addFetchOptionsDefaults(e){Object.entries(this.defaultHeaders).forEach(([t,n])=>{this.setRequestHeader(e,t,n)}),this.setRequestHeader(e,`Accept`,zD,!0),this.options.extendedMode!==!1&&this.setRequestHeader(e,`X-Medplum`,`extended`),e.body&&this.setRequestHeader(e,`Content-Type`,ZE.FHIR_JSON,!0),this.accessToken?this.setRequestHeader(e,`Authorization`,`Bearer `+this.accessToken):this.basicAuth&&this.setRequestHeader(e,`Authorization`,`Basic `+this.basicAuth),e.cache||=`no-cache`,e.credentials||=`include`}setRequestContentType(e,t){this.setRequestHeader(e,`Content-Type`,t)}getRequestHeader(e,t){let n=e?.headers;if(n){if(Array.isArray(n)){let e=n.find(([e])=>e.toLowerCase()===t.toLowerCase());return e?e[1]:void 0}else if(n instanceof Headers)return n.get(t)??void 0;else if(PC(n))return n[t]??void 0}}setRequestHeader(e,t,n,r=!1){let i=e.headers;i?Array.isArray(i)?(!r||!i.some(([e])=>e.toLowerCase()===t.toLowerCase()))&&i.push([t,n]):i instanceof Headers?(!r||!i.has(t))&&i.set(t,n):PC(i)&&(!r||!i[t])&&(i[t]=n):e.headers={[t]:n}}setRequestBody(e,t){typeof t==`string`||typeof Blob<`u`&&(t instanceof Blob||t?.constructor.name===`Blob`)||typeof File<`u`&&(t instanceof File||t?.constructor.name===`File`)||typeof Uint8Array<`u`&&(t instanceof Uint8Array||t?.constructor.name===`Uint8Array`)?e.body=t:typeof t==`object`&&t&&(typeof t.getReader==`function`||typeof t.pipe==`function`&&typeof t.on==`function`)?(e.body=t,e.duplex=`half`):t&&(e.body=JSON.stringify(t))}handleUnauthenticated(e,t){if(this.refresh())return this.request(e,t);throw this.clear(),this.onUnauthenticated?.(),new Xx(zx)}async startPkce(){let e=VE();this.storage.setString(`pkceState`,e);let t=VE().slice(0,128);this.storage.setString(`codeVerifier`,t);try{return{codeChallengeMethod:`S256`,codeChallenge:VC(await HE(t)).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replaceAll(`=`,``)}}catch(e){return console.warn(`Failed to hash code verifier. Falling back to 'plain' code challenge method`,e),{codeChallengeMethod:`plain`,codeChallenge:t}}}async requestAuthorization(e){let t=await this.ensureCodeChallenge(e??{}),n=new URL(this.authorizeUrl);n.searchParams.set(`response_type`,`code`),n.searchParams.set(`state`,this.storage.getString(`pkceState`)),n.searchParams.set(`client_id`,t.clientId??this.clientId),n.searchParams.set(`redirect_uri`,t.redirectUri??LE.getOrigin()),n.searchParams.set(`code_challenge_method`,t.codeChallengeMethod),n.searchParams.set(`code_challenge`,t.codeChallenge),n.searchParams.set(`scope`,t.scope??`openid profile`),LE.assign(n.toString())}processCode(e,t){let n={grant_type:qD.AuthorizationCode,code:e,client_id:t?.clientId??this.clientId??``,redirect_uri:t?.redirectUri??LE.getOrigin()},r=this.storage.getString(`codeVerifier`);return r&&(n.code_verifier=r),this.fetchTokens(n)}refreshIfExpired(e){return!this.refreshPromise&&this.accessTokenExpires!==void 0&&!this.isAuthenticated(e)&&this.refresh(e),this.refreshPromise??Promise.resolve()}refresh(e){if(this.refreshPromise)return this.refreshPromise;if(!(!this.refreshToken&&!(this.clientId&&this.clientSecret)))return this.refreshPromise=this.runRefreshWithLock(e),this.refreshPromise}async runRefreshWithLock(e){let t=()=>{let t=this.getActiveLogin();return t?.accessToken&&t.accessToken!==this.accessToken&&this.setAccessToken(t.accessToken,t.refreshToken),this.isAuthenticated(e)?Promise.resolve(this.getProfile()):this.refreshToken?this.fetchTokens({grant_type:qD.RefreshToken,client_id:this.clientId??``,refresh_token:this.refreshToken}):this.clientId&&this.clientSecret?this.startClientLogin(this.clientId,this.clientSecret):Promise.resolve(void 0)},n=typeof navigator<`u`?navigator.locks:void 0;if(!n?.request)return t();let r=`medplum-refresh:${this.storage.makeKey(`activeLogin`)}`;return n.request(r,t)}async startClientLogin(e,t){return this.clientId=e,this.clientSecret=t,this.fetchTokens({grant_type:qD.ClientCredentials,client_id:e,client_secret:t})}async startJwtBearerLogin(e,t,n){return this.clientId=e,this.fetchTokens({grant_type:qD.JwtBearer,client_id:e,assertion:t,scope:n})}async startJwtAssertionLogin(e){return this.fetchTokens({grant_type:qD.ClientCredentials,client_assertion_type:YD.JwtBearer,client_assertion:e})}setBasicAuth(e,t){this.clientId=e,this.clientSecret=t,this.basicAuth=zE(e+`:`+t)}setLogLevel(e){this.logLevel=e,this.options.verbose=e===`verbose`}getLogLevel(){return this.logLevel}setVerbose(e){this.logLevel=e?`verbose`:`none`,this.options.verbose=e}async fhircastSubscribe(e,t){if(!(typeof e==`string`&&e!==``))throw new Xx(Wx(`Invalid topic provided. Topic must be a valid string.`));if(!(typeof t==`object`&&Array.isArray(t)&&t.length>0))throw new Xx(Wx(`Invalid events provided. Events must be an array of event names containing at least one event.`));let n={channelType:`websocket`,mode:`subscribe`,topic:e,events:t},r=(await this.post(this.fhircastHubUrl,cD(n),ZE.FORM_URL_ENCODED))[`hub.channel.endpoint`];if(!r)throw Error(`Invalid response!`);return n.endpoint=r,n}async fhircastUnsubscribe(e){if(!lD(e))throw new Xx(Wx(`Invalid topic or subscriptionRequest. SubscriptionRequest must be an object.`));if(!(e.endpoint&&typeof e.endpoint==`string`&&e.endpoint.startsWith(`ws`)))throw new Xx(Wx(`Provided subscription request must have an endpoint in order to unsubscribe.`));e.mode=`unsubscribe`,await this.post(this.fhircastHubUrl,cD(e),ZE.FORM_URL_ENCODED)}fhircastConnect(e){return new mD(e)}async fhircastPublish(e,t,n,r){return rD(t)?this.post(this.fhircastHubUrl,pD(e,t,n,r),ZE.JSON):(iD(t),this.post(this.fhircastHubUrl,pD(e,t,n),ZE.JSON))}async fhircastGetContext(e){return this.get(`${this.fhircastHubUrl}/${e}`,{cache:`no-cache`})}async invite(e,t){return this.post(`admin/projects/`+e+`/invite`,t)}async handleTokenError(e){try{let t=await e.json();throw qx(t)?new Xx(t):t.error_description?new Xx(Ux(t.error_description)):Error(JSON.stringify(t))}catch(e){throw e instanceof Xx?(e.message=`Failed to fetch tokens: ${e.message}`,e):new Xx(Ux(`Failed to fetch tokens`),{cause:e})}}async fetchTokens(e){let t=new URLSearchParams(e),n={...this.defaultHeaders,"Content-Type":ZE.FORM_URL_ENCODED};this.basicAuth&&(n.Authorization=`Basic ${this.basicAuth}`),this.credentialsInHeader&&(t.delete(`client_id`),t.delete(`client_secret`),!this.basicAuth&&e.client_id&&e.client_secret&&(n.Authorization=`Basic ${zE(e.client_id+`:`+e.client_secret)}`));let r={method:`POST`,headers:n,body:t.toString(),credentials:`include`},i;try{i=await this.fetchWithRetry(this.tokenUrl,r)}catch(e){throw this.refreshPromise=void 0,e}i.ok||(this.clearActiveLogin(),this.onUnauthenticated?.(),await this.handleTokenError(i));let a=await i.json();return await this.verifyTokens(a),this.getProfile()}async verifyTokens(e){let t=e.access_token;if(gD(t)){let e=_D(t);if(Date.now()>=e.exp*1e3)throw this.clearActiveLogin(),new Xx(Bx);if(e.cid){if(e.cid!==this.clientId)throw this.clearActiveLogin(),new Xx(Vx)}else if(this.clientId&&e.client_id!==this.clientId)throw this.clearActiveLogin(),new Xx(Vx)}return this.setActiveLogin({accessToken:t,refreshToken:e.refresh_token,project:e.project,profile:e.profile})}checkSessionDetailsMatchLogin(e){return this.sessionDetails&&e?e.profile?.reference?.endsWith(this.sessionDetails.profile.id)??!1:!0}setupStorageListener(){try{window.addEventListener(`storage`,e=>{if(e.key===null)LE.reload();else if(e.key===this.storage.makeKey(`activeLogin`)){let t=e.oldValue?JSON.parse(e.oldValue):void 0,n=e.newValue?JSON.parse(e.newValue):void 0;t?.profile.reference!==n?.profile.reference||!this.checkSessionDetailsMatchLogin(n)?LE.reload():n?this.setAccessToken(n.accessToken,n.refreshToken):this.clear()}})}catch{}}getSubscriptionManager(){return this.subscriptionManager||=new ID(this,tw(this.baseUrl,`/ws/subscriptions-r4`)),this.subscriptionManager}subscribeToCriteria(e,t){return this.getSubscriptionManager().addCriteria(e,t)}unsubscribeFromCriteria(e,t){this.subscriptionManager&&this.subscriptionManager.removeCriteria(e,t)}getMasterSubscriptionEmitter(){return this.getSubscriptionManager().getMasterEmitter()}};function ZD(){if(!globalThis.fetch)throw Error(`Fetch not available in this environment`);return globalThis.fetch.bind(globalThis)}async function QD(e,t){let n=e.headers.get(`content-location`);if(n)return n;let r=e.headers.get(`location`);if(r)return r;if(qx(t)&&t.issue?.[0]?.diagnostics)return t.issue[0].diagnostics}function $D(e){let t=e.entry?.map(e=>e.resource)??[];return Object.assign(t,{bundle:e})}function eO(e){return PC(e)&&`data`in e&&`contentType`in e}function tO(e,t,n,r){return eO(e)?e:{data:e,filename:t,contentType:n,onProgress:r}}function nO(e){return PC(e)&&`docDefinition`in e}function rO(e,t,n,r){return nO(e)?e:{docDefinition:e,filename:t,tableLayouts:n,fonts:r}}function iO(e){return e.status===429||e.status>=500}function aO({parentContext:e,path:t,elements:n,profileUrl:r,debugMode:i,accessPolicyResource:a}){if(t===e?.path)return;i??=e?.debugMode??!1,a??=e?.accessPolicyResource;let o=oO(t,n,e,!!i),s=JC(t,`.`,2)[1];o=sO(o,a,s),o=cO(o,a,s);let c=Object.create(null);for(let[e,n]of Object.entries(o))c[t+`.`+e]=n;let l;if(e&&!e.isDefaultContext)l=e.getExtendedProps;else{let e=Object.create(null);l=t=>{let n=JC(t,`.`,2)[1];if(n){if(!e[n]){let t=lO(n,a?.hiddenFields);e[n]={hidden:t,readonly:t||lO(n,a?.readonlyFields)}}return e[n]}}}return{path:t,elements:o,elementsByPath:c,profileUrl:r??e?.profileUrl,debugMode:i,getExtendedProps:l,accessPolicyResource:a}}function oO(e,t,n,r){let i=Object.create(null);if(n)for(let[t,r]of Object.entries(n.elementsByPath)){let n=GC(e,t);n!==void 0&&(i[n]=r)}let a=!1;if(t)for(let[e,n]of Object.entries(t))e in i||(i[e]=n,a=!0);return r&&console.assert(a,`Unnecessary ElementsContext; not using any newly provided elements`),i}function sO(e,t,n){if(!t?.hiddenFields?.length)return e;let r=n?n+`.`:``;return Object.fromEntries(Object.entries(e).filter(([e])=>!lO(r+e,t.hiddenFields)))}function cO(e,t,n){if(!t?.readonlyFields?.length)return e;let r=Object.create(null),i=n?n+`.`:``;for(let[n,a]of Object.entries(e))lO(i+n,t.readonlyFields)?r[n]={...a,readonly:!0}:r[n]=a;return r}function lO(e,t){if(!t?.length)return!1;let n=e.split(`.`);for(let e=1;e<=n.length;e++){let r=n.slice(0,e).join(`.`);if(t.includes(r))return!0}return!1}function uO(e){return e.type!==void 0&&e.type.length>0}function dO(e,t,n,r){let i=TS(e,t.path,{profileUrl:r});if(i){let e=n.typeSchema?.elements??n.elements;return i.some(r=>kS(r,t,n,e))??!1}return console.assert(!1,`getNestedProperty[%s] in isDiscriminatorComponentMatch missed`,t.path),!1}function fO(e,t,n,r){if(e)for(let i of t){let t={value:e,type:i.typeSchema?.type??i.type?.[0].code};if(n.every(e=>dO(t,e,i,i.typeSchema?.url??r)))return i.name}}var pO=class{rootSchema;visitor;elementsContextStack;sliceAllowList;constructor(e,t,n){if(e.type===void 0)throw Error(`schema must include a type`);this.rootSchema=e;let r=aO({parentContext:void 0,path:this.rootSchema.type,elements:n??this.rootSchema.elements,profileUrl:this.rootSchema.name===this.rootSchema.type?void 0:this.rootSchema.url});if(r===void 0)throw Error(`Could not create root elements context`);this.elementsContextStack=[r],this.visitor=t}get elementsContext(){return this.elementsContextStack.at(-1)}crawlElement(e,t,n){this.visitor.onEnterSchema&&this.visitor.onEnterSchema(this.rootSchema);let r=Object.fromEntries(Object.entries(this.elementsContext.elements).filter(([e])=>e.startsWith(t)));this.crawlElementsImpl(r,n),this.visitor.onExitSchema&&this.visitor.onExitSchema(this.rootSchema)}crawlSlice(e,t,n){let r=this.prepareSlices(n.slices,n);if(!wC(r.slices))throw Error(`cannot crawl slice ${t.name} since it has no type information`);this.visitor.onEnterSchema&&this.visitor.onEnterSchema(this.rootSchema),this.sliceAllowList=[t],this.crawlSliceImpl(r.slices[0],t.path,r),this.sliceAllowList=void 0,this.visitor.onExitSchema&&this.visitor.onExitSchema(this.rootSchema)}crawlResource(){this.visitor.onEnterSchema&&this.visitor.onEnterSchema(this.rootSchema),this.crawlElementsImpl(this.rootSchema.elements,this.rootSchema.type),this.visitor.onExitSchema&&this.visitor.onExitSchema(this.rootSchema)}crawlElementsImpl(e,t){let n=mO(e);for(let e of n)this.crawlElementNode(e,t)}crawlElementNode(e,t){let n=t+`.`+e.key;this.visitor.onEnterElement&&this.visitor.onEnterElement(n,e.element,this.elementsContext);for(let n of e.children)this.crawlElementNode(n,t);wC(e.element?.slicing?.slices)&&this.crawlSlicingImpl(e.element.slicing,n),this.visitor.onExitElement&&this.visitor.onExitElement(n,e.element,this.elementsContext)}prepareSlices(e,t){let n=[];for(let t of e){if(!uO(t))continue;let e=t.type.find(e=>wC(e.profile))?.profile?.[0];if(wC(e)){let n=gS(e);n&&(t.typeSchema=n)}n.push(t)}return{...t,slices:n}}crawlSlicingImpl(e,t){let n=this.prepareSlices(e.slices,e);for(let e of n.slices)(this.sliceAllowList===void 0||this.sliceAllowList.includes(e))&&this.crawlSliceImpl(e,t,n)}crawlSliceImpl(e,t,n){let r=e.typeSchema;r&&this.visitor.onEnterSchema&&this.visitor.onEnterSchema(r),this.visitor.onEnterSlice&&this.visitor.onEnterSlice(t,e,n);let i,a=r?.elements??e.elements;wC(a)&&(i=aO({path:t,parentContext:this.elementsContext,elements:a})),i&&this.elementsContextStack.push(i),this.crawlElementsImpl(a,t),i&&this.elementsContextStack.pop(),this.visitor.onExitSlice&&this.visitor.onExitSlice(t,e,n),r&&this.visitor.onExitSchema&&this.visitor.onExitSchema(r)}};function mO(e){let t=[];function n(e,t){return t.startsWith(e+`.`)}function r(e,t){for(let i of e.children)if(n(i.key,t.key)){r(i,t);return}e.children.push(t)}let i=Object.entries(e);i.sort((e,t)=>e[0].localeCompare(t[0]));for(let[e,a]of i){let i={key:e,element:a,children:[]},o=!1;for(let a of t)if(n(a.key,e)){r(a,i),o=!0;break}o||t.push(i)}return t}var hO=`__sliceName`;function gO(e,t){let n=new vO(e,e.resourceType,`resource`);return new pO(t,n).crawlResource(),n.getDefaultValue()}function _O(e,t,n){for(let[r,i]of Object.entries(t)){if(n===void 0||n===r){SO(e,r,i,t);continue}let a=GC(n,r);a!==void 0&&SO(e,a,i,t)}return e}var vO=class{rootValue;schemaStack;valueStack;constructor(e,t,n){this.schemaStack=[],this.valueStack=[],this.rootValue=MC(e),this.valueStack.splice(0,this.valueStack.length,{type:n,path:t,values:[this.rootValue]})}get schema(){return this.schemaStack.at(-1)}get value(){return this.valueStack.at(-1)}onEnterSchema(e){this.schemaStack.push(e)}onExitSchema(){this.schemaStack.pop()}onEnterElement(e,t,n){let r=this.value.values,i=this.value.path,a=GC(i,e);if(a===void 0)throw Error(`Expected ${e} to be prefixed by ${i}`);let o=[];for(let e of r){if(e===void 0)continue;let r=GC(n.path,i),s=Array.isArray(e)?e:[e];for(let e of s){yO(e,a,t,n.elements,r),SO(e,a,t,n.elements);let i=xO(e,a,n.elements,r);i!==void 0&&o.push(i)}}this.valueStack.push({type:`element`,path:e,values:o})}onExitElement(e,t,n){if(!this.valueStack.pop())throw Error(`Expected value context to exist when exiting element`);let r=GC(this.value.path,e);if(r===void 0)throw Error(`Expected ${e} to be prefixed by ${this.value.path}`);let i=GC(n.path,this.value.path);for(let e of this.value.values){let a=xO(e,r,n.elements,i);if(Array.isArray(a))for(let e=a.length-1;e>=0;e--){let t=a[e];wC(t)||a.splice(e,1)}CC(a)&&bO(e,void 0,r,t)}}onEnterSlice(e,t,n){let r=this.value.values,i=[];for(let e of r)if(e!==void 0){let r=Array.isArray(e)?e:[e],a=this.getMatchingSliceValues(r,t,n);i.push(a)}this.valueStack.push({type:`slice`,path:e,values:i})}getMatchingSliceValues(e,t,n){let r=[];for(let i of e)(i[hO]??fO(i,[t],n.discriminator,this.schema.url))===t.name&&r.push(i);for(let n=r.length;n<t.min;n++)if(WC(t.type[0].code)){let t=Object.create(null);r.push(t),e.push(t)}return r}onExitSlice(){let e=this.valueStack.pop();if(!e)throw Error(`Expected value context to exist in onExitSlice`);for(let t of e.values)for(let e=t.length-1;e>=0;e--){let n=t[e];hO in n&&delete n[hO]}}getDefaultValue(){return this.rootValue}};function yO(e,t,n,r,i){let a=xO(e,t,r,i);n.min>0&&a===void 0&&WC(n.type[0].code)&&(n.isArray?bO(e,[Object.create(null)],t,n):bO(e,Object.create(null),t,n))}function bO(e,t,n,r){if(n.includes(`.`))throw Error(`key cannot be nested`);let i=n;if(n.includes(`[x]`)){let e=r.type[0].code;i=n.replace(`[x]`,UC(e))}t===void 0?delete e[i]:e[i]=t}function xO(e,t,n,r){let i=t.split(`.`),a=e,o;for(let e=0;e<i.length;e++){let t=i[e];if(t.includes(`[x]`)){let a=n[(r?r+`.`:``)+i.slice(0,e+1).join(`.`)].type[0].code;t=t.replace(`[x]`,UC(a))}if(e===i.length-1){o=Array.isArray(a)?a.map(e=>e[t]):a[t];continue}if(Array.isArray(a))a=a.map(e=>e[t]);else if(PC(a)){if(a[t]===void 0)return;a=a[t]}else return}return o}function SO(e,t,n,r){if(!(n.fixed||n.pattern))return e;if(Array.isArray(e))return e.map(e=>SO(e,t,n,r));e??=Object.create(null);let i=e,a=t.split(`.`),o=i;for(let e=0;e<a.length;e++){let t=a[e];if(t.includes(`[x]`)){let n=r[a.slice(0,e+1).join(`.`)].type[0].code;t=t.replace(`[x]`,UC(n))}if(e===a.length-1){let e=Array.isArray(o)?o:[o];for(let r of e)n.fixed?r[t]??=n.fixed.value:n.pattern&&(r[t]=CO(r[t],n.pattern.value))}else{if(!(t in o)){let n=a.slice(0,e+1).join(`.`);o[t]=r[n].isArray?[Object.create(null)]:Object.create(null)}o=o[t]}}return i}function CO(e,t){if(Array.isArray(t)&&(Array.isArray(e)||e===void 0))return(e?.length??0)>0?e:MC(t);if(PC(t)&&(PC(e)&&!Array.isArray(e)||e===void 0)){let n=MC(e)??Object.create(null);for(let e of Object.keys(t))n[e]=CO(n[e],t[e]);return n}return e}function wO(e){return e.match(/^\((.+)\)\.identifier$/)?.[1]}function TO(e,t){return new Qw(e,new lT(t,new eT(`identifier`)))}var EO={BOOLEAN:`BOOLEAN`,NUMBER:`NUMBER`,QUANTITY:`QUANTITY`,TEXT:`TEXT`,REFERENCE:`REFERENCE`,CANONICAL:`CANONICAL`,DATE:`DATE`,DATETIME:`DATETIME`,PERIOD:`PERIOD`,UUID:`UUID`};function DO(e,t){return Ww.types[e]?.searchParamsDetails?.[t.code]??kO(e,t)}function OO(e,t,n){let r=Ww.types[e];r||(r={},Ww.types[e]=r),r.searchParamsDetails||={},r.searchParamsDetails[t]=n}function kO(e,t){let n=t.code,r=t.expression,i=PO(e,r),a={elementDefinitions:[],propertyTypes:new Set,array:!1};for(let n of i){let r=LO(n),i=YC(()=>r.join(`.`));r.length===1&&r[0]instanceof wx&&r[0].operator!==`.`?a.propertyTypes.add(`boolean`):t.code.endsWith(`:identifier`)?a.propertyTypes.add(`Identifier`):i().endsWith(`extension.value.code`)||i().endsWith(`extension.value.coding.code`)?(a.array=!0,a.propertyTypes.clear(),a.propertyTypes.add(`code`)):AO(a,r,e,1),i().endsWith(`extension.valueDateTime`)&&(a.array=!1,a.propertyTypes.clear(),a.propertyTypes.add(`dateTime`))}let o;if(t.code.endsWith(`:identifier`)){let t=wO(r);if(t===void 0)throw Error(`Unexpected expression for derived identifier search parameter: ${r}`);o=TO(r,FO(e,t))}else o=FO(e,r);let s=a.elementDefinitions.map(e=>({...e,type:e.type?.filter(e=>a.propertyTypes.has(e.code))})).filter(e=>e.type&&e.type.length>0),c={type:NO(t,a.propertyTypes),elementDefinitions:s,parsedExpression:o,array:a.array,referenceTargetTypes:RO(t,s)};return OO(e,n,c),c}function AO(e,t,n,r){let i=t[r];if(i instanceof rT){e.propertyTypes.add(i.right.toString());return}if(i instanceof bT){jO(e,i);return}let a=i.toString(),o=Bw(n,a);if(!o)throw Error(`Element definition not found for ${n} ${a}`);let s=!1,c=r+1;c<t.length&&t[c]instanceof xT&&(s=!0,c++);let l=t[c];if(o.isArray&&!s&&(e.array=!0),c===t.length-1){if(l instanceof rT){e.elementDefinitions.push(o),e.propertyTypes.add(l.right.toString());return}if(l instanceof bT&&l.name===`ofType`){e.elementDefinitions.push(o),e.propertyTypes.add(l.args[0].toString());return}}if(c>=t.length){e.elementDefinitions.push(o);for(let t of o.type??aw)e.propertyTypes.add(t.code);return}for(let n of o.type??aw){let r=n.code;MO(r)&&(r=o.type[0].code),AO(e,t,r,c)}}function jO(e,t){if(t.name===`as`){e.propertyTypes.add(t.args[0].toString());return}if(t.name===`ofType`){e.propertyTypes.add(t.args[0].toString());return}if(t.name===`resolve`){e.propertyTypes.add(`string`);return}if(t.name===`where`&&t.args[0]instanceof hT){e.propertyTypes.add(t.args[0].right.toString());return}throw Error(`Unhandled FHIRPath function: ${t.name}`)}function MO(e){return e===`Element`||e===`BackboneElement`}function NO(e,t){switch(e.type){case`date`:return t.size===1&&t.has(Y.date)?EO.DATE:EO.DATETIME;case`number`:return EO.NUMBER;case`quantity`:return EO.QUANTITY;case`reference`:return t.has(Y.canonical)?EO.CANONICAL:EO.REFERENCE;case`token`:return t.size===1&&t.has(Y.boolean)?EO.BOOLEAN:EO.TEXT;default:return EO.TEXT}}function PO(e,t){let n=[];return IO(e,IT(t).child,n),n}function FO(e,t){let n=[],r=IT(t);if(IO(e,r.child,n),n.length===0)return r;let i=n[0];for(let e=1;e<n.length;e++)i=new uT(i,n[e]);return new Qw(`<original-not-available>`,i)}function IO(e,t,n){t instanceof uT?(IO(e,t.left,n),IO(e,t.right,n)):t.toString().includes(e+`.`)&&n.push(t)}function LO(e){return e instanceof rT||e instanceof xT?[LO(e.left),e].flat():e instanceof wx&&e.operator!==`.`?[e]:e instanceof lT?[LO(e.left),LO(e.right)].flat():e instanceof bT&&(e.name===`where`&&!(e.args[0]instanceof hT)||e.name===`last`)?[]:[e]}function RO(e,t){if(e.target?.length===1)return e.target;if(t){let e=new Set;for(let n of t)for(let t of n.type)if(!(t.code!==`Reference`||!t.targetProfile))for(let n of t.targetProfile){let t=n.split(`/`).at(-1);t&&t!==`Resource`&&e.add(t)}if(e.size>0)return Array.from(e)}}var zO=`https://meta.medplum.com/releases`,BO=new Map;function VO(e){let t=e;if(!t.tag_name?.startsWith(`v`))throw Error(`Manifest missing valid tag_name starting with a 'v' (eg. v5.1.15)`);let n=t.assets;if(!n?.length)throw Error(`Manifest missing assets list`);for(let e of n){if(!e.browser_download_url)throw Error(`Asset missing browser download URL`);if(!e.name)throw Error(`Asset missing name`)}}async function HO(e,t,n){let r=t?BO.get(t):void 0;if(!r){let i=t?`v${t}`:`latest`,a=new URL(`${zO}/${i}.json`);if(a.searchParams.set(`a`,e),a.searchParams.set(`c`,RD),n)for(let[e,t]of Object.entries(n))a.searchParams.set(e,t);let o=await fetch(a.toString());if(o.status!==200){let e;try{e=(await o.json()).message}catch(e){console.error(`Failed to parse message from body: ${Qx(e)}`)}throw Error(`Received status code ${o.status} while fetching manifest for version '${t??`latest`}'. Message: ${e}`)}let s=await o.json();VO(s),r=s,BO.set(r.tag_name.slice(1),r)}return r}async function UO(e){let t=await HO(e);if(!t.tag_name.startsWith(`v`))throw Error(`Invalid release name found. Release tag '${t.tag_name}' did not start with 'v'`);return t.tag_name.slice(1)}var WO=(0,b.createContext)(void 0);function GO(){return(0,b.useContext)(WO)}function Z(){return GO().medplum}function KO(){return GO().navigate}function qO(){return GO().profile}var JO=[`change`,`storageInitialized`,`storageInitFailed`,`profileRefreshing`,`profileRefreshed`];function YO(e){let t=e.medplum,n=e.navigate??XO,[r,i]=(0,b.useState)({profile:t.getProfile(),loading:t.isLoading()});(0,b.useEffect)(()=>{function e(){i(e=>({...e,profile:t.getProfile(),loading:t.isLoading()}))}for(let n of JO)t.addEventListener(n,e);return()=>{for(let n of JO)t.removeEventListener(n,e)}},[t]);let a=(0,b.useMemo)(()=>({...r,medplum:t,navigate:n}),[r,t,n]);return(0,I.jsx)(WO.Provider,{value:a,children:e.children})}function XO(e){window.location.assign(e)}var ZO=new Map,QO=e=>(0,b.useMemo)(()=>{if(!e)return;let t=e.split(`?`)[0];if(!t)return e;let n;try{n=new URLSearchParams(new URL(e).search)}catch{return e}if(!n.has(`Key-Pair-Id`)||!n.has(`Signature`))return e;let r=n.get(`Expires`);if(!r||r.length>13)return e;let i=ZO.get(t);if(i){let e=new URLSearchParams(new URL(i).search).get(`Expires`);if(e&&Number.parseInt(e,10)*1e3-5e3>Date.now())return i}return ZO.set(t,e),e},[e]),$O=3e3;function ek(e,t,n){let r=Z(),i=qO()?e:void 0,[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(n?.subscriptionProps),l=(0,b.useRef)(!1),u=(0,b.useRef)(void 0),d=(0,b.useRef)(void 0),f=(0,b.useRef)(void 0),p=(0,b.useRef)(t);p.current=t;let m=(0,b.useRef)(n?.onWebSocketOpen);m.current=n?.onWebSocketOpen;let h=(0,b.useRef)(n?.onWebSocketClose);h.current=n?.onWebSocketClose;let g=(0,b.useRef)(n?.onSubscriptionConnect);g.current=n?.onSubscriptionConnect;let _=(0,b.useRef)(n?.onSubscriptionDisconnect);_.current=n?.onSubscriptionDisconnect;let v=(0,b.useRef)(n?.onError);v.current=n?.onError,(0,b.useEffect)(()=>{EC(n?.subscriptionProps,s)||c(n?.subscriptionProps)},[s,n]),(0,b.useEffect)(()=>{u.current&&=(clearTimeout(u.current),void 0);let e=!1;return(d.current!==i||!EC(f.current,s))&&(e=!0),e&&d.current&&r.unsubscribeFromCriteria(d.current,f.current),d.current=i,f.current=s,e&&i?o(r.subscribeToCriteria(i,s)):i||o(void 0),()=>{u.current=setTimeout(()=>{o(void 0),i&&r.unsubscribeFromCriteria(i,s)},$O)}},[r,i,s]);let y=(0,b.useCallback)(e=>{p.current?.(e.payload)},[]),x=(0,b.useCallback)(()=>{m.current?.()},[]),S=(0,b.useCallback)(()=>{h.current?.()},[]),C=(0,b.useCallback)(e=>{g.current?.(e.payload.subscriptionId)},[]),w=(0,b.useCallback)(e=>{_.current?.(e.payload.subscriptionId)},[]),T=(0,b.useCallback)(e=>{v.current?.(e.payload)},[]);(0,b.useEffect)(()=>a?(l.current||=(a.addEventListener(`message`,y),a.addEventListener(`open`,x),a.addEventListener(`close`,S),a.addEventListener(`connect`,C),a.addEventListener(`disconnect`,w),a.addEventListener(`error`,T),!0),()=>{l.current=!1,a.removeEventListener(`message`,y),a.removeEventListener(`open`,x),a.removeEventListener(`close`,S),a.removeEventListener(`connect`,C),a.removeEventListener(`disconnect`,w),a.removeEventListener(`error`,T)}):()=>void 0,[a,y,x,S,C,w,T])}function tk(e){let t=Z(),{resourceType:n,countCriteria:r,subscriptionCriteria:i}=e,[a,o]=(0,b.useState)(0),s=(0,b.useCallback)(e=>{t.search(n,r,{cache:e}).then(e=>o(e.total)).catch(console.error)},[t,n,r]);return(0,b.useEffect)(()=>{s(`default`)},[s]),ek(i,()=>{s(`reload`)}),a}function nk(e,t){let n=Z(),[r,i]=(0,b.useState)(()=>rk(n,e)),a=(0,b.useCallback)(e=>{EC(e,r)||i(e)},[r]);return(0,b.useEffect)(()=>{let r=!0,i=rk(n,e);return!i&&Uw(e)?n.readReference(e).then(e=>{r&&a(e)}).catch(e=>{r&&(a(void 0),t&&t(Zx(e)))}):a(i),(()=>r=!1)},[n,e,a,t]),r}function rk(e,t){if(t){if(Hw(t))return t;if(Uw(t))return e.getCachedReference(t)}}var ik={group:`group`,display:`display`,question:`question`,boolean:`boolean`,decimal:`decimal`,integer:`integer`,date:`date`,dateTime:`dateTime`,time:`time`,string:`string`,text:`text`,url:`url`,choice:`choice`,openChoice:`open-choice`,attachment:`attachment`,reference:`reference`,quantity:`quantity`},ak=`${Ox}/fhir/StructureDefinition/questionnaire-itemControl`,ok=`${Ox}/fhir/StructureDefinition/questionnaire-referenceFilter`,sk=`${Ox}/fhir/StructureDefinition/questionnaire-referenceResource`,ck=`${Ox}/fhir/StructureDefinition/questionnaire-validationError`,lk=`${Ox}/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression`,uk=`${Ox}/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression`,dk=`${Ox}/fhir/StructureDefinition/questionnaire-signatureRequired`,fk=`${Ox}/fhir/StructureDefinition/questionnaireresponse-signature`,pk=`${Ox}/fhir/StructureDefinition/questionnaire-hidden`;function mk(e){return e.type===`choice`||e.type===`open-choice`}function hk(e,t){return{...t,item:gk(e.item,t.item,t)}}function gk(e,t,n){if(!t)return t;let r=[];for(let i of t){let t=e?.find(e=>e.linkId===i.linkId);t&&!_k(t,n)||(t?.item&&i.item?r.push({...i,item:gk(t.item,i.item,n)}):r.push(i))}return r}function _k(e,t){if(vC(e,pk)?.valueBoolean===!0)return!1;let n=vk(e,t);return n===void 0?yk(e,t):n}function vk(e,t){let n=vC(e,lk);if(t&&n){let e=n.valueExpression?.expression;if(e){let n=jS(t);return MS(RT(e,[n],{"%resource":n}))}}}function yk(e,t){if(!e.enableWhen)return!0;let n=e.enableBehavior??`any`;for(let r of e.enableWhen){let e=Ek(t?.item,r.question);if(r.operator===`exists`&&!r.answerBoolean&&!e?.length){if(n===`any`)return!0;continue}let{anyMatch:i,allMatch:a}=Ok(r,e,n);if(n===`any`&&i)return!0;if(n===`all`&&!a)return!1}return n!==`any`}function bk(e,t,n=t.item){for(let r of e){let e=n?.find(e=>e.linkId===r.linkId);e&&(xk(t,r,e),r.item&&e.item&&bk(r.item,t,e.item))}}function xk(e,t,n){try{let r=wk(t,e);if(!r)return;let i=Ck(t,r);if(!i)return;n.answer=[i]}catch(e){n.extension=[{url:ck,valueString:`Expression evaluation failed: ${Qx(e)}`}]}}var Sk={[ik.boolean]:[Y.boolean],[ik.date]:[Y.date],[ik.dateTime]:[Y.dateTime],[ik.time]:[Y.time],[ik.url]:[Y.string,Y.uri,Y.url],[ik.attachment]:[Y.Attachment],[ik.reference]:[Y.Reference],[ik.quantity]:[Y.Quantity],[ik.decimal]:[Y.decimal,Y.integer],[ik.integer]:[Y.decimal,Y.integer]};function Ck(e,t){if(e.type){if(e.type===ik.choice||e.type===ik.openChoice)return{[`value${UC(t.type)}`]:t.value};if(e.type===ik.string||e.type===ik.text)return typeof t.value==`string`?{valueString:t.value}:void 0;if(Sk[e.type]?.includes(t.type))return{[`value${UC(e.type)}`]:t.value}}}function wk(e,t){if(!t)return;let n=vC(e,uk);if(n){let e=n.valueExpression?.expression;if(e){let n=jS(t),r=RT(e,[n],{"%resource":n});return r.length===0?void 0:r[0]}}}function Tk(e,t,n){let r=[];for(let i of e){let e=n.answerOption?.find(e=>ow(zk(e))===i);if(e){let n=zk(e);n&&r.push({[t]:n.value})}}return r}function Ek(e,t){for(let n of e??aw){if(n.linkId===t)return n.answer;if(n.item){let e=Ek(n.item,t);if(e)return e}}}function Dk(e,t,n){if(n===`exists`)return!!e===t.value;if(e){let[{value:r}]=RT(`%actualAnswer ${n===`=`||n===`!=`?n?.replace(`=`,`~`):n} %expectedAnswer`,[e],{"%actualAnswer":e,"%expectedAnswer":t});return r}else return!1}function Ok(e,t,n){let r=t||[],i=Bk(e),a=!1,o=!0;for(let t of r){let r=Vk(t),{operator:s}=e;if(Dk(r,i,s)?a=!0:o=!1,n===`any`&&a)break}return{anyMatch:a,allMatch:o}}function kk(e){let t=vC(e,sk);if(t){if(t.valueCode!==void 0)return[t.valueCode];if(t.valueCodeableConcept)return t.valueCodeableConcept?.coding?.map(e=>e.code)}}function Ak(e,t){let n=MC(e),r=vC(n,sk);return!t||t.length===0?(r&&(n.extension=n.extension?.filter(e=>e!==r)),n):(r||(n.extension??=[],r={url:sk},n.extension.push(r)),t.length===1?(r.valueCode=t[0],delete r.valueCodeableConcept):(r.valueCodeableConcept={coding:t.map(e=>({code:e}))},delete r.valueCode),n)}function jk(e,t,n){let r=vC(e,ok);if(!r?.valueString)return;let i=r.valueString;t?.reference&&(i=i.replaceAll(`$subj`,t.reference)),n?.reference&&(i=i.replaceAll(`$encounter`,n.reference));let a={},o=i.split(`&`);for(let e of o){let[t,n]=JC(e,`=`,2);a[t]=n}return a}function Mk(e,t){return{resourceType:`QuestionnaireResponse`,questionnaire:e.url??oC(e),item:Nk(e.item,t?.item),status:`in-progress`}}function Nk(e,t){let n;for(let r of e??aw){if(r.type===ik.display)continue;let e=t?.filter(e=>e.linkId===r.linkId);if(e?.length)for(let t of e)t.id=t.id??Ik(),t.text=t.text??r.text,t.item=Nk(r.item,t.item),t.answer=Lk(r,t),n=XC(n,t);else n=XC(n,Pk(r))}return n}function Pk(e){return{id:Ik(),linkId:e.linkId,text:e.text,item:Nk(e.item,void 0),answer:Lk(e)}}var Fk=1;function Ik(){return`id-`+ Fk++}function Lk(e,t){if(!(e.type===ik.display||e.type===ik.group)){if(t?.answer&&t.answer.length>0)return t.answer;if(e.initial&&e.initial.length>0)return e.initial.map(e=>({...e}));if(e.answerOption)return e.answerOption.filter(e=>e.initialSelected).map(e=>({...e,initialSelected:void 0}))}}function Rk(e){return LS({type:`QuestionnaireItemInitial`,value:e},`value`)}function zk(e){return LS({type:`QuestionnaireItemAnswerOption`,value:e},`value`)}function Bk(e){return LS({type:`QuestionnaireItemEnableWhen`,value:e},`answer`)}function Vk(e){return LS({type:`QuestionnaireResponseItemAnswer`,value:e},`value`)}function Hk(e){let t=nk(e.questionnaire),n=nk(e.defaultValue),[,r]=(0,b.useReducer)(e=>e+1,0),i=(0,b.useRef)({activePage:0});if(!i.current.questionnaire&&t&&(i.current.questionnaire=t,i.current.pages=e.disablePagination?void 0:Uk(t)),t&&e.defaultValue&&n&&!i.current.questionnaireResponse&&(i.current.questionnaireResponse=Mk(t,n),p()),t&&!e.defaultValue&&!i.current.questionnaireResponse&&(i.current.questionnaireResponse=Mk(t),p()),!i.current.questionnaire||!i.current.questionnaireResponse)return{loading:!0};function a(e,t){let n=i.current.questionnaireResponse;for(let t of e)n=n?.item?.find(e=>t.id?e.id===t.id:e.linkId===t.linkId);return t&&(n=n?.item?.find(e=>e.linkId===t.linkId)),n}function o(){i.current.activePage=(i.current.activePage??0)+1,r()}function s(){i.current.activePage=(i.current.activePage??0)-1,r()}function c(e,t){let n=a(e);n&&(n.item??=[],n.item.push(Pk(t)),p())}function l(e,t){let n=a(e,t);n&&(n.answer??=[],n.answer.push({}),p())}function u(e,t,n){let r=a(e,t);r&&(r.answer=n,p())}function d(e){let t=i.current.questionnaireResponse;t&&(e?(t.extension=t.extension??[],t.extension=t.extension.filter(e=>e.url!==fk),t.extension.push({url:fk,valueSignature:e})):t.extension=t.extension?.filter(e=>e.url!==fk),p())}function f(){let e=i.current.questionnaire;if(e?.item){let t=i.current.questionnaireResponse;bk(e.item,t)}}function p(){let t=i.current.questionnaireResponse,n=i.current.questionnaire;!t||!n||(f(),r(),e.onChange?.(hk(n,t)))}return{loading:!1,pagination:!!i.current.pages,questionnaire:i.current.questionnaire,questionnaireResponse:hk(i.current.questionnaire,i.current.questionnaireResponse),subject:e.subject,encounter:e.encounter,activePage:i.current.activePage,pages:i.current.pages,items:Wk(i.current.questionnaire,i.current.pages,i.current.activePage),responseItems:Gk(i.current.questionnaireResponse,i.current.pages,i.current.activePage),onNextPage:o,onPrevPage:s,onAddGroup:c,onAddAnswer:l,onChangeAnswer:u,onChangeSignature:d}}function Uk(e){if(e?.item&&vC(e?.item?.[0],ak)?.valueCodeableConcept?.coding?.[0]?.code===`page`)return e.item.map((e,t)=>({linkId:e.linkId,title:e.text??`Page ${t+1}`,group:e}))}function Wk(e,t,n=0){return t&&e?.item?.[n]?[e.item[n]]:e.item??[]}function Gk(e,t,n=0){return t&&e?.item?.[n]?[e.item[n]]:e.item??[]}function Kk(e,t,n={leading:!1}){let[r,i]=(0,b.useState)(e),a=(0,b.useRef)(!1),o=(0,b.useRef)(void 0),s=(0,b.useRef)(!1),c=(0,b.useCallback)(()=>window.clearTimeout(o.current),[]);return(0,b.useEffect)(()=>{a.current&&(!s.current&&n.leading?(s.current=!0,i(e),o.current=setTimeout(()=>{s.current=!1},t)):(c(),o.current=setTimeout(()=>{s.current=!1,i(e)},t)))},[e,n.leading,t,c]),(0,b.useEffect)(()=>(a.current=!0,c),[c]),[r,c]}var qk=250;function Jk(e,t,n){return Xk(`searchOne`,e,t,n)}function Yk(e,t,n){return Xk(`searchResources`,e,t,n)}function Xk(e,t,n,r){let i=Z(),[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(),[l,u]=(0,b.useState)(),d=(0,b.useMemo)(()=>({resourceType:t,query:n}),[i.fhirSearchUrl(t,n).toString()]),f=r?.enabled??!0,[p]=Kk(d,r?.debounceMs??qk,{leading:!0});return(0,b.useEffect)(()=>{if(!f)return()=>{};o(!0);let t=!0;return i[e](p.resourceType,p.query).then(e=>{t&&(o(!1),c(e),u(Lx))}).catch(e=>{t&&(o(!1),c(void 0),u(Zx(e)))}),()=>{t=!1}},[i,e,p,f]),[s,a,l]}function Zk(e){let t=e.value;return t?(0,I.jsx)(I.Fragment,{children:cw(t,e.options)}):null}var Qk=[`meta`,`implicitRules`,`contained`,`extension`,`modifierExtension`],$k=[`language`,`text`],eA=(0,b.createContext)({path:``,profileUrl:void 0,elements:Object.create(null),elementsByPath:Object.create(null),getExtendedProps:()=>({readonly:!1,hidden:!1}),accessPolicyResource:void 0,debugMode:!1,isDefaultContext:!0});eA.displayName=`ElementsContext`;var tA=[`extension`,`modifierExtension`],nA=[`id`,...Qk].filter(e=>!tA.includes(e));function rA(e){return Object.entries(e).filter(([e,t])=>!wC(t.type)||t.max===0||t.path.toLowerCase().endsWith(`extension.url`)&&t.fixed||tA.includes(e)&&!wC(t.slicing?.slices)||nA.includes(e)?!1:!($k.includes(e)&&t.path.split(`.`).length===2||e.includes(`.`)))}function iA(e,t){return e.line&&e.line.length>t?e.line[t]:``}function aA(e,t,n){let r=e.line||[];for(;r.length<=t;)r.push(``);return r[t]=n,{...e,line:TC(r)}}function oA(e){let[t,n]=(0,b.useState)(e.defaultValue||{}),{getExtendedProps:r}=(0,b.useContext)(eA),[i,a,o,s,c,l,u]=(0,b.useMemo)(()=>[`use`,`type`,`line1`,`line2`,`city`,`state`,`postalCode`].map(t=>r(e.path+`.`+t)),[r,e.path]);function d(r){n(e=>({...e,...r})),e.onChange&&e.onChange({...t,...r})}function f(e){d({use:e})}function p(e){d({type:e})}function m(e){d(aA(t,0,e))}function h(e){d(aA(t,1,e))}function g(e){d({city:e})}function _(e){d({state:e})}function v(e){d({postalCode:e})}return(0,I.jsxs)(V,{gap:`xs`,wrap:`nowrap`,grow:!0,children:[(0,I.jsx)(Eg,{disabled:e.disabled||i?.readonly,"data-testid":`address-use`,defaultValue:t.use,onChange:e=>f(e.currentTarget.value),data:[``,`home`,`work`,`temp`,`old`,`billing`]}),(0,I.jsx)(Eg,{disabled:e.disabled||a?.readonly,"data-testid":`address-type`,defaultValue:t.type,onChange:e=>p(e.currentTarget.value),data:[``,`postal`,`physical`,`both`]}),(0,I.jsx)(yb,{disabled:e.disabled||o?.readonly,placeholder:`Line 1`,defaultValue:iA(t,0),onChange:e=>m(e.currentTarget.value)}),(0,I.jsx)(yb,{disabled:e.disabled||s?.readonly,placeholder:`Line 2`,defaultValue:iA(t,1),onChange:e=>h(e.currentTarget.value)}),(0,I.jsx)(yb,{disabled:e.disabled||c?.readonly,placeholder:`City`,defaultValue:t.city,onChange:e=>g(e.currentTarget.value)}),(0,I.jsx)(yb,{disabled:e.disabled||l?.readonly,placeholder:`State`,defaultValue:t.state,onChange:e=>_(e.currentTarget.value)}),(0,I.jsx)(yb,{disabled:e.disabled||u?.readonly,placeholder:`Postal Code`,defaultValue:t.postalCode,onChange:e=>v(e.currentTarget.value)})]})}function sA(e){let t=qO(),[n,r]=(0,b.useState)(e.defaultValue||{});function i(n){let i=n?{text:n,authorReference:t&&aC(t),time:new Date().toISOString()}:{};r(i),e.onChange&&e.onChange(i)}return(0,I.jsx)(yb,{disabled:e.disabled,name:e.name,placeholder:`Annotation text`,defaultValue:n.text,onChange:e=>i(e.currentTarget.value)})}var cA={outline:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},filled:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`currentColor`,stroke:`none`}},Q=(e,t,n,r)=>{let i=(0,b.forwardRef)(({color:n=`currentColor`,size:i=24,stroke:a=2,title:o,className:s,children:c,...l},u)=>(0,b.createElement)(`svg`,{ref:u,...cA[e],width:i,height:i,className:[`tabler-icon`,`tabler-icon-${t}`,s].join(` `),...e===`filled`?{fill:n}:{strokeWidth:a,stroke:n},...l},[o&&(0,b.createElement)(`title`,{key:`svg-title`},o),...r.map(([e,t])=>(0,b.createElement)(e,t)),...Array.isArray(c)?c:[c]]));return i.displayName=`${n}`,i},lA=Q(`outline`,`adjustments-horizontal`,`AdjustmentsHorizontal`,[[`path`,{d:`M12 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-0`}],[`path`,{d:`M4 6l8 0`,key:`svg-1`}],[`path`,{d:`M16 6l4 0`,key:`svg-2`}],[`path`,{d:`M6 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-3`}],[`path`,{d:`M4 12l2 0`,key:`svg-4`}],[`path`,{d:`M10 12l10 0`,key:`svg-5`}],[`path`,{d:`M15 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-6`}],[`path`,{d:`M4 18l11 0`,key:`svg-7`}],[`path`,{d:`M19 18l1 0`,key:`svg-8`}]]),uA=Q(`outline`,`alert-circle`,`AlertCircle`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0`,key:`svg-0`}],[`path`,{d:`M12 8v4`,key:`svg-1`}],[`path`,{d:`M12 16h.01`,key:`svg-2`}]]),dA=Q(`outline`,`arrow-down`,`ArrowDown`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M18 13l-6 6`,key:`svg-1`}],[`path`,{d:`M6 13l6 6`,key:`svg-2`}]]),fA=Q(`outline`,`arrow-up`,`ArrowUp`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M18 11l-6 -6`,key:`svg-1`}],[`path`,{d:`M6 11l6 -6`,key:`svg-2`}]]),pA=Q(`outline`,`bleach-off`,`BleachOff`,[[`path`,{d:`M5 19h14m1.986 -1.977a2 2 0 0 0 -.146 -.773l-7.1 -12.25a2 2 0 0 0 -3.5 0l-.815 1.405m-1.488 2.568l-4.797 8.277a2 2 0 0 0 1.75 2.75`,key:`svg-0`}],[`path`,{d:`M3 3l18 18`,key:`svg-1`}]]),mA=Q(`outline`,`bleach`,`Bleach`,[[`path`,{d:`M5 19h14a2 2 0 0 0 1.84 -2.75l-7.1 -12.25a2 2 0 0 0 -3.5 0l-7.1 12.25a2 2 0 0 0 1.75 2.75`,key:`svg-0`}]]),hA=Q(`outline`,`bookmark`,`Bookmark`,[[`path`,{d:`M18 7v14l-6 -4l-6 4v-14a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4`,key:`svg-0`}]]),gA=Q(`outline`,`box-multiple`,`BoxMultiple`,[[`path`,{d:`M7 5a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2l0 -10`,key:`svg-0`}],[`path`,{d:`M17 17v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2h2`,key:`svg-1`}]]),_A=Q(`outline`,`brackets-contain`,`BracketsContain`,[[`path`,{d:`M7 4h-4v16h4`,key:`svg-0`}],[`path`,{d:`M17 4h4v16h-4`,key:`svg-1`}],[`path`,{d:`M8 16h.01`,key:`svg-2`}],[`path`,{d:`M12 16h.01`,key:`svg-3`}],[`path`,{d:`M16 16h.01`,key:`svg-4`}]]),vA=Q(`outline`,`brand-asana`,`BrandAsana`,[[`path`,{d:`M9 7a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-0`}],[`path`,{d:`M14 16a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-1`}],[`path`,{d:`M4 16a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-2`}]]),yA=Q(`outline`,`briefcase`,`Briefcase`,[[`path`,{d:`M3 9a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v9a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2l0 -9`,key:`svg-0`}],[`path`,{d:`M8 7v-2a2 2 0 0 1 2 -2h4a2 2 0 0 1 2 2v2`,key:`svg-1`}],[`path`,{d:`M12 12l0 .01`,key:`svg-2`}],[`path`,{d:`M3 13a20 20 0 0 0 18 0`,key:`svg-3`}]]),bA=Q(`outline`,`bucket-off`,`BucketOff`,[[`path`,{d:`M5.029 5.036c-.655 .58 -1.029 1.25 -1.029 1.964c0 2.033 3.033 3.712 6.96 3.967m3.788 -.21c3.064 -.559 5.252 -2.029 5.252 -3.757c0 -2.21 -3.582 -4 -8 -4c-1.605 0 -3.1 .236 -4.352 .643`,key:`svg-0`}],[`path`,{d:`M4 7c0 .664 .088 1.324 .263 1.965l2.737 10.035c.5 1.5 2.239 2 5 2s4.5 -.5 5 -2c.1 -.3 .252 -.812 .457 -1.535m.862 -3.146c.262 -.975 .735 -2.76 1.418 -5.354a7.45 7.45 0 0 0 .263 -1.965`,key:`svg-1`}],[`path`,{d:`M3 3l18 18`,key:`svg-2`}]]),xA=Q(`outline`,`bucket`,`Bucket`,[[`path`,{d:`M4 7a8 4 0 1 0 16 0a8 4 0 1 0 -16 0`,key:`svg-0`}],[`path`,{d:`M4 7c0 .664 .088 1.324 .263 1.965l2.737 10.035c.5 1.5 2.239 2 5 2s4.5 -.5 5 -2c.333 -1 1.246 -4.345 2.737 -10.035a7.45 7.45 0 0 0 .263 -1.965`,key:`svg-1`}]]),SA=Q(`outline`,`building`,`Building`,[[`path`,{d:`M3 21l18 0`,key:`svg-0`}],[`path`,{d:`M9 8l1 0`,key:`svg-1`}],[`path`,{d:`M9 12l1 0`,key:`svg-2`}],[`path`,{d:`M9 16l1 0`,key:`svg-3`}],[`path`,{d:`M14 8l1 0`,key:`svg-4`}],[`path`,{d:`M14 12l1 0`,key:`svg-5`}],[`path`,{d:`M14 16l1 0`,key:`svg-6`}],[`path`,{d:`M5 21v-16a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v16`,key:`svg-7`}]]),CA=Q(`outline`,`calendar`,`Calendar`,[[`path`,{d:`M4 7a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12`,key:`svg-0`}],[`path`,{d:`M16 3v4`,key:`svg-1`}],[`path`,{d:`M8 3v4`,key:`svg-2`}],[`path`,{d:`M4 11h16`,key:`svg-3`}],[`path`,{d:`M11 15h1`,key:`svg-4`}],[`path`,{d:`M12 15v3`,key:`svg-5`}]]),wA=Q(`outline`,`check`,`Check`,[[`path`,{d:`M5 12l5 5l10 -10`,key:`svg-0`}]]),TA=Q(`outline`,`checkbox`,`Checkbox`,[[`path`,{d:`M9 11l3 3l8 -8`,key:`svg-0`}],[`path`,{d:`M20 12v6a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h9`,key:`svg-1`}]]),EA=Q(`outline`,`chevron-down`,`ChevronDown`,[[`path`,{d:`M6 9l6 6l6 -6`,key:`svg-0`}]]),DA=Q(`outline`,`circle-check`,`CircleCheck`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`,key:`svg-0`}],[`path`,{d:`M9 12l2 2l4 -4`,key:`svg-1`}]]),OA=Q(`outline`,`circle-minus`,`CircleMinus`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`,key:`svg-0`}],[`path`,{d:`M9 12l6 0`,key:`svg-1`}]]),kA=Q(`outline`,`circle-plus`,`CirclePlus`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0`,key:`svg-0`}],[`path`,{d:`M9 12h6`,key:`svg-1`}],[`path`,{d:`M12 9v6`,key:`svg-2`}]]),AA=Q(`outline`,`cloud-upload`,`CloudUpload`,[[`path`,{d:`M7 18a4.6 4.4 0 0 1 0 -9a5 4.5 0 0 1 11 2h1a3.5 3.5 0 0 1 0 7h-1`,key:`svg-0`}],[`path`,{d:`M9 15l3 -3l3 3`,key:`svg-1`}],[`path`,{d:`M12 12l0 9`,key:`svg-2`}]]),jA=Q(`outline`,`columns`,`Columns`,[[`path`,{d:`M4 6l5.5 0`,key:`svg-0`}],[`path`,{d:`M4 10l5.5 0`,key:`svg-1`}],[`path`,{d:`M4 14l5.5 0`,key:`svg-2`}],[`path`,{d:`M4 18l5.5 0`,key:`svg-3`}],[`path`,{d:`M14.5 6l5.5 0`,key:`svg-4`}],[`path`,{d:`M14.5 10l5.5 0`,key:`svg-5`}],[`path`,{d:`M14.5 14l5.5 0`,key:`svg-6`}],[`path`,{d:`M14.5 18l5.5 0`,key:`svg-7`}]]),MA=Q(`outline`,`copy`,`Copy`,[[`path`,{d:`M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666`,key:`svg-0`}],[`path`,{d:`M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1`,key:`svg-1`}]]),NA=Q(`outline`,`currency-dollar`,`CurrencyDollar`,[[`path`,{d:`M16.7 8a3 3 0 0 0 -2.7 -2h-4a3 3 0 0 0 0 6h4a3 3 0 0 1 0 6h-4a3 3 0 0 1 -2.7 -2`,key:`svg-0`}],[`path`,{d:`M12 3v3m0 12v3`,key:`svg-1`}]]),PA=Q(`outline`,`database`,`Database`,[[`path`,{d:`M4 6a8 3 0 1 0 16 0a8 3 0 1 0 -16 0`,key:`svg-0`}],[`path`,{d:`M4 6v6a8 3 0 0 0 16 0v-6`,key:`svg-1`}],[`path`,{d:`M4 12v6a8 3 0 0 0 16 0v-6`,key:`svg-2`}]]),FA=Q(`outline`,`device-desktop`,`DeviceDesktop`,[[`path`,{d:`M3 5a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10`,key:`svg-0`}],[`path`,{d:`M7 20h10`,key:`svg-1`}],[`path`,{d:`M9 16v4`,key:`svg-2`}],[`path`,{d:`M15 16v4`,key:`svg-3`}]]),IA=Q(`outline`,`device-floppy`,`DeviceFloppy`,[[`path`,{d:`M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2`,key:`svg-0`}],[`path`,{d:`M10 14a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-1`}],[`path`,{d:`M14 4l0 4l-6 0l0 -4`,key:`svg-2`}]]),LA=Q(`outline`,`dots`,`Dots`,[[`path`,{d:`M4 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-0`}],[`path`,{d:`M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-1`}],[`path`,{d:`M18 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-2`}]]),RA=Q(`outline`,`edit`,`Edit`,[[`path`,{d:`M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1`,key:`svg-0`}],[`path`,{d:`M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415`,key:`svg-1`}],[`path`,{d:`M16 5l3 3`,key:`svg-2`}]]),zA=Q(`outline`,`equal-not`,`EqualNot`,[[`path`,{d:`M5 10h14`,key:`svg-0`}],[`path`,{d:`M5 14h14`,key:`svg-1`}],[`path`,{d:`M5 19l14 -14`,key:`svg-2`}]]),BA=Q(`outline`,`equal`,`Equal`,[[`path`,{d:`M5 10h14`,key:`svg-0`}],[`path`,{d:`M5 14h14`,key:`svg-1`}]]),VA=Q(`outline`,`eye-off`,`EyeOff`,[[`path`,{d:`M10.585 10.587a2 2 0 0 0 2.829 2.828`,key:`svg-0`}],[`path`,{d:`M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87`,key:`svg-1`}],[`path`,{d:`M3 3l18 18`,key:`svg-2`}]]),HA=Q(`outline`,`eye`,`Eye`,[[`path`,{d:`M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0`,key:`svg-0`}],[`path`,{d:`M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6`,key:`svg-1`}]]),UA=Q(`outline`,`file-alert`,`FileAlert`,[[`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`,key:`svg-0`}],[`path`,{d:`M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2`,key:`svg-1`}],[`path`,{d:`M12 17l.01 0`,key:`svg-2`}],[`path`,{d:`M12 11l0 3`,key:`svg-3`}]]),WA=Q(`outline`,`file-plus`,`FilePlus`,[[`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`,key:`svg-0`}],[`path`,{d:`M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2`,key:`svg-1`}],[`path`,{d:`M12 11l0 6`,key:`svg-2`}],[`path`,{d:`M9 14l6 0`,key:`svg-3`}]]),GA=Q(`outline`,`filter`,`Filter`,[[`path`,{d:`M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227`,key:`svg-0`}]]),KA=Q(`outline`,`folder`,`Folder`,[[`path`,{d:`M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2`,key:`svg-0`}]]),qA=Q(`outline`,`forms`,`Forms`,[[`path`,{d:`M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3`,key:`svg-0`}],[`path`,{d:`M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3`,key:`svg-1`}],[`path`,{d:`M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7`,key:`svg-2`}],[`path`,{d:`M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1`,key:`svg-3`}],[`path`,{d:`M17 12h.01`,key:`svg-4`}],[`path`,{d:`M13 12h.01`,key:`svg-5`}]]),JA=Q(`outline`,`id`,`Id`,[[`path`,{d:`M3 7a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v10a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3l0 -10`,key:`svg-0`}],[`path`,{d:`M7 10a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-1`}],[`path`,{d:`M15 8l2 0`,key:`svg-2`}],[`path`,{d:`M15 12l2 0`,key:`svg-3`}],[`path`,{d:`M7 16l10 0`,key:`svg-4`}]]),YA=Q(`outline`,`layout-sidebar`,`LayoutSidebar`,[[`path`,{d:`M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12`,key:`svg-0`}],[`path`,{d:`M9 4l0 16`,key:`svg-1`}]]),XA=Q(`outline`,`list-details`,`ListDetails`,[[`path`,{d:`M13 5h8`,key:`svg-0`}],[`path`,{d:`M13 9h5`,key:`svg-1`}],[`path`,{d:`M13 15h8`,key:`svg-2`}],[`path`,{d:`M13 19h5`,key:`svg-3`}],[`path`,{d:`M3 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4`,key:`svg-4`}],[`path`,{d:`M3 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4`,key:`svg-5`}]]),ZA=Q(`outline`,`lock-access`,`LockAccess`,[[`path`,{d:`M4 8v-2a2 2 0 0 1 2 -2h2`,key:`svg-0`}],[`path`,{d:`M4 16v2a2 2 0 0 0 2 2h2`,key:`svg-1`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v2`,key:`svg-2`}],[`path`,{d:`M16 20h2a2 2 0 0 0 2 -2v-2`,key:`svg-3`}],[`path`,{d:`M8 12a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v3a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1l0 -3`,key:`svg-4`}],[`path`,{d:`M10 11v-2a2 2 0 1 1 4 0v2`,key:`svg-5`}]]),QA=Q(`outline`,`lock`,`Lock`,[[`path`,{d:`M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-6`,key:`svg-0`}],[`path`,{d:`M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0`,key:`svg-1`}],[`path`,{d:`M8 11v-4a4 4 0 1 1 8 0v4`,key:`svg-2`}]]),$A=Q(`outline`,`logout`,`Logout`,[[`path`,{d:`M14 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2`,key:`svg-0`}],[`path`,{d:`M9 12h12l-3 -3`,key:`svg-1`}],[`path`,{d:`M18 15l3 -3`,key:`svg-2`}]]),ej=Q(`outline`,`math-greater`,`MathGreater`,[[`path`,{d:`M5 18l14 -6l-14 -6`,key:`svg-0`}]]),tj=Q(`outline`,`math-lower`,`MathLower`,[[`path`,{d:`M19 18l-14 -6l14 -6`,key:`svg-0`}]]),nj=Q(`outline`,`message`,`Message`,[[`path`,{d:`M8 9h8`,key:`svg-0`}],[`path`,{d:`M8 13h6`,key:`svg-1`}],[`path`,{d:`M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3h12`,key:`svg-2`}]]),rj=Q(`outline`,`microscope`,`Microscope`,[[`path`,{d:`M5 21h14`,key:`svg-0`}],[`path`,{d:`M6 18h2`,key:`svg-1`}],[`path`,{d:`M7 18v3`,key:`svg-2`}],[`path`,{d:`M9 11l3 3l6 -6l-3 -3l-6 6`,key:`svg-3`}],[`path`,{d:`M10.5 12.5l-1.5 1.5`,key:`svg-4`}],[`path`,{d:`M17 3l3 3`,key:`svg-5`}],[`path`,{d:`M12 21a6 6 0 0 0 3.715 -10.712`,key:`svg-6`}]]),ij=Q(`outline`,`minus`,`Minus`,[[`path`,{d:`M5 12l14 0`,key:`svg-0`}]]),aj=Q(`outline`,`moon`,`Moon`,[[`path`,{d:`M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454l0 .008`,key:`svg-0`}]]),oj=Q(`outline`,`packages`,`Packages`,[[`path`,{d:`M7 16.5l-5 -3l5 -3l5 3v5.5l-5 3l0 -5.5`,key:`svg-0`}],[`path`,{d:`M2 13.5v5.5l5 3`,key:`svg-1`}],[`path`,{d:`M7 16.545l5 -3.03`,key:`svg-2`}],[`path`,{d:`M17 16.5l-5 -3l5 -3l5 3v5.5l-5 3l0 -5.5`,key:`svg-3`}],[`path`,{d:`M12 19l5 3`,key:`svg-4`}],[`path`,{d:`M17 16.5l5 -3`,key:`svg-5`}],[`path`,{d:`M12 13.5v-5.5l-5 -3l5 -3l5 3v5.5`,key:`svg-6`}],[`path`,{d:`M7 5.03v5.455`,key:`svg-7`}],[`path`,{d:`M12 8l5 -3`,key:`svg-8`}]]),sj=Q(`outline`,`palette`,`Palette`,[[`path`,{d:`M12 21a9 9 0 0 1 0 -18c4.97 0 9 3.582 9 8c0 1.06 -.474 2.078 -1.318 2.828c-.844 .75 -1.989 1.172 -3.182 1.172h-2.5a2 2 0 0 0 -1 3.75a1.3 1.3 0 0 1 -1 2.25`,key:`svg-0`}],[`path`,{d:`M7.5 10.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-1`}],[`path`,{d:`M11.5 7.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-2`}],[`path`,{d:`M15.5 10.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-3`}]]),cj=Q(`outline`,`pencil`,`Pencil`,[[`path`,{d:`M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4`,key:`svg-0`}],[`path`,{d:`M13.5 6.5l4 4`,key:`svg-1`}]]),lj=Q(`outline`,`pin`,`Pin`,[[`path`,{d:`M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4`,key:`svg-0`}],[`path`,{d:`M9 15l-4.5 4.5`,key:`svg-1`}],[`path`,{d:`M14.5 4l5.5 5.5`,key:`svg-2`}]]),uj=Q(`outline`,`pinned-off`,`PinnedOff`,[[`path`,{d:`M3 3l18 18`,key:`svg-0`}],[`path`,{d:`M15 4.5l-3.249 3.249m-2.57 1.433l-2.181 .818l-1.5 1.5l7 7l1.5 -1.5l.82 -2.186m1.43 -2.563l3.25 -3.251`,key:`svg-1`}],[`path`,{d:`M9 15l-4.5 4.5`,key:`svg-2`}],[`path`,{d:`M14.5 4l5.5 5.5`,key:`svg-3`}]]),dj=Q(`outline`,`player-play`,`PlayerPlay`,[[`path`,{d:`M7 4v16l13 -8l-13 -8`,key:`svg-0`}]]),fj=Q(`outline`,`plus`,`Plus`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M5 12l14 0`,key:`svg-1`}]]),pj=Q(`outline`,`receipt`,`Receipt`,[[`path`,{d:`M5 21v-16a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v16l-3 -2l-2 2l-2 -2l-2 2l-2 -2l-3 2m4 -14h6m-6 4h6m-2 4h2`,key:`svg-0`}]]),mj=Q(`outline`,`refresh`,`Refresh`,[[`path`,{d:`M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4`,key:`svg-0`}],[`path`,{d:`M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4`,key:`svg-1`}]]),hj=Q(`outline`,`repeat`,`Repeat`,[[`path`,{d:`M4 12v-3a3 3 0 0 1 3 -3h13m-3 -3l3 3l-3 3`,key:`svg-0`}],[`path`,{d:`M20 12v3a3 3 0 0 1 -3 3h-13m3 3l-3 -3l3 -3`,key:`svg-1`}]]),gj=Q(`outline`,`report-medical`,`ReportMedical`,[[`path`,{d:`M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2`,key:`svg-0`}],[`path`,{d:`M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2`,key:`svg-1`}],[`path`,{d:`M10 14l4 0`,key:`svg-2`}],[`path`,{d:`M12 12l0 4`,key:`svg-3`}]]),_j=Q(`outline`,`router`,`Router`,[[`path`,{d:`M3 15a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2l0 -4`,key:`svg-0`}],[`path`,{d:`M17 17l0 .01`,key:`svg-1`}],[`path`,{d:`M13 17l0 .01`,key:`svg-2`}],[`path`,{d:`M15 13l0 -2`,key:`svg-3`}],[`path`,{d:`M11.75 8.75a4 4 0 0 1 6.5 0`,key:`svg-4`}],[`path`,{d:`M8.5 6.5a8 8 0 0 1 13 0`,key:`svg-5`}]]),vj=Q(`outline`,`search`,`Search`,[[`path`,{d:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0 -14 0`,key:`svg-0`}],[`path`,{d:`M21 21l-6 -6`,key:`svg-1`}]]),yj=Q(`outline`,`settings`,`Settings`,[[`path`,{d:`M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065`,key:`svg-0`}],[`path`,{d:`M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0`,key:`svg-1`}]]),bj=Q(`outline`,`sort-ascending`,`SortAscending`,[[`path`,{d:`M4 6l7 0`,key:`svg-0`}],[`path`,{d:`M4 12l7 0`,key:`svg-1`}],[`path`,{d:`M4 18l9 0`,key:`svg-2`}],[`path`,{d:`M15 9l3 -3l3 3`,key:`svg-3`}],[`path`,{d:`M18 6l0 12`,key:`svg-4`}]]),xj=Q(`outline`,`sort-descending`,`SortDescending`,[[`path`,{d:`M4 6l9 0`,key:`svg-0`}],[`path`,{d:`M4 12l7 0`,key:`svg-1`}],[`path`,{d:`M4 18l7 0`,key:`svg-2`}],[`path`,{d:`M15 15l3 3l3 -3`,key:`svg-3`}],[`path`,{d:`M18 6l0 12`,key:`svg-4`}]]),Sj=Q(`outline`,`square`,`Square`,[[`path`,{d:`M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14`,key:`svg-0`}]]),Cj=Q(`outline`,`star`,`Star`,[[`path`,{d:`M12 17.75l-6.172 3.245l1.179 -6.873l-5 -4.867l6.9 -1l3.086 -6.253l3.086 6.253l6.9 1l-5 4.867l1.179 6.873l-6.158 -3.245`,key:`svg-0`}]]),wj=Q(`outline`,`sun-high`,`SunHigh`,[[`path`,{d:`M14.828 14.828a4 4 0 1 0 -5.656 -5.656a4 4 0 0 0 5.656 5.656`,key:`svg-0`}],[`path`,{d:`M6.343 17.657l-1.414 1.414`,key:`svg-1`}],[`path`,{d:`M6.343 6.343l-1.414 -1.414`,key:`svg-2`}],[`path`,{d:`M17.657 6.343l1.414 -1.414`,key:`svg-3`}],[`path`,{d:`M17.657 17.657l1.414 1.414`,key:`svg-4`}],[`path`,{d:`M4 12h-2`,key:`svg-5`}],[`path`,{d:`M12 4v-2`,key:`svg-6`}],[`path`,{d:`M20 12h2`,key:`svg-7`}],[`path`,{d:`M12 20v2`,key:`svg-8`}]]),Tj=Q(`outline`,`switch-horizontal`,`SwitchHorizontal`,[[`path`,{d:`M16 3l4 4l-4 4`,key:`svg-0`}],[`path`,{d:`M10 7l10 0`,key:`svg-1`}],[`path`,{d:`M8 13l-4 4l4 4`,key:`svg-2`}],[`path`,{d:`M4 17l9 0`,key:`svg-3`}]]),Ej=Q(`outline`,`table-export`,`TableExport`,[[`path`,{d:`M12.5 21h-7.5a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7.5`,key:`svg-0`}],[`path`,{d:`M3 10h18`,key:`svg-1`}],[`path`,{d:`M10 3v18`,key:`svg-2`}],[`path`,{d:`M16 19h6`,key:`svg-3`}],[`path`,{d:`M19 16l3 3l-3 3`,key:`svg-4`}]]),Dj=Q(`outline`,`table`,`Table`,[[`path`,{d:`M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14`,key:`svg-0`}],[`path`,{d:`M3 10h18`,key:`svg-1`}],[`path`,{d:`M10 3v18`,key:`svg-2`}]]),Oj=Q(`outline`,`text-recognition`,`TextRecognition`,[[`path`,{d:`M4 8v-2a2 2 0 0 1 2 -2h2`,key:`svg-0`}],[`path`,{d:`M4 16v2a2 2 0 0 0 2 2h2`,key:`svg-1`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v2`,key:`svg-2`}],[`path`,{d:`M16 20h2a2 2 0 0 0 2 -2v-2`,key:`svg-3`}],[`path`,{d:`M12 16v-7`,key:`svg-4`}],[`path`,{d:`M9 9h6`,key:`svg-5`}]]),kj=Q(`outline`,`trash`,`Trash`,[[`path`,{d:`M4 7l16 0`,key:`svg-0`}],[`path`,{d:`M10 11l0 6`,key:`svg-1`}],[`path`,{d:`M14 11l0 6`,key:`svg-2`}],[`path`,{d:`M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12`,key:`svg-3`}],[`path`,{d:`M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3`,key:`svg-4`}]]),Aj=Q(`outline`,`upload`,`Upload`,[[`path`,{d:`M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2`,key:`svg-0`}],[`path`,{d:`M7 9l5 -5l5 5`,key:`svg-1`}],[`path`,{d:`M12 4l0 12`,key:`svg-2`}]]),jj=Q(`outline`,`user-plus`,`UserPlus`,[[`path`,{d:`M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0`,key:`svg-0`}],[`path`,{d:`M16 19h6`,key:`svg-1`}],[`path`,{d:`M19 16v6`,key:`svg-2`}],[`path`,{d:`M6 21v-2a4 4 0 0 1 4 -4h4`,key:`svg-3`}]]),Mj=Q(`outline`,`webhook`,`Webhook`,[[`path`,{d:`M4.876 13.61a4 4 0 1 0 6.124 3.39h6`,key:`svg-0`}],[`path`,{d:`M15.066 20.502a4 4 0 1 0 1.934 -7.502c-.706 0 -1.424 .179 -2 .5l-3 -5.5`,key:`svg-1`}],[`path`,{d:`M16 8a4 4 0 1 0 -8 0c0 1.506 .77 2.818 2 3.5l-3 5.5`,key:`svg-2`}]]),Nj=Q(`outline`,`x`,`X`,[[`path`,{d:`M18 6l-12 12`,key:`svg-0`}],[`path`,{d:`M6 6l12 12`,key:`svg-1`}]]),Pj=Q(`filled`,`circle-filled`,`CircleFilled`,[[`path`,{d:`M7 3.34a10 10 0 1 1 -4.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 4.995 -8.336z`,key:`svg-0`}]]),Fj=class extends b.Component{state;constructor(e){super(e),this.state={lastLocation:LE.getLocation()}}static getDerivedStateFromError(e){return{error:e,lastLocation:LE.getLocation()}}componentDidUpdate(e,t){LE.getLocation()!==this.state.lastLocation&&this.setState({lastLocation:LE.getLocation(),error:void 0})}shouldComponentUpdate(e,t){return!!(this.props.children!==e.children||t.error&&!this.state.error||this.state.lastLocation!==LE.getLocation())}componentDidCatch(e,t){console.error(`Uncaught error:`,e,t)}render(){return this.state.error?(0,I.jsx)(Dd,{icon:(0,I.jsx)(uA,{size:16}),title:`Something went wrong`,color:`red`,children:Qx(this.state.error)}):this.props.children}};function Ij(){return(0,I.jsx)(Kp,{style:{width:`100%`,height:`100vh`},children:(0,I.jsx)(cu,{})})}var Lj={main:`_main_6f7o5_1`};function Rj(e){e.preventDefault(),e.stopPropagation()}function zj(e){return e.button===1||e.ctrlKey||e.metaKey}function Bj(e){if(Vj(e))return!0;if(e instanceof HTMLTableCellElement){let t=e.children;if(t.length===1&&Vj(t[0]))return!0}return!1}function Vj(e){return e instanceof HTMLInputElement&&e.type===`checkbox`}async function Hj(e,t){return new Promise((n,r)=>{let i=new MessageChannel;i.port1.onmessage=({data:e})=>{i.port1.close(),e.error?r(e.error):n(e.result)},e.contentWindow?.postMessage(t,new URL(e.src).origin,[i.port2])})}function Uj(e,t){let n=new Blob([e],{type:ZE.JSON}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t??new Date().toISOString().replaceAll(/\D/g,``)}.json`,document.body.appendChild(i),i.click(),URL.revokeObjectURL(r)}function Wj(e){let t=KO(),{to:n,suffix:r,label:i,onClick:a,children:o,...s}=e,c=Gj(n);return r&&(c+=`/`+r),(0,I.jsx)(Pd,{href:c,"aria-label":i,onAuxClick:e=>{e.stopPropagation()},onClick:e=>{e.stopPropagation(),a?(e.preventDefault(),a(e)):n&&(zj(e)||(e.preventDefault(),t(c)))},...s,children:o})}function Gj(e){if(e){if(typeof e==`string`)return Kj(e);if(Hw(e))return qj(e);if(Uw(e))return Jj(e)}return`#`}function Kj(e){return e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)?e:`/`+e}function qj(e){return`/${e.resourceType}/${e.id}`}function Jj(e){return`/${e.reference}`}function Yj(e){let t=e.split(` `).filter(Boolean);return t.length>1?t[0][0]+t.at(-1)?.at(0):t.length===1?t[0][0]:``}function Xj(e){let t=nk(e.value),n=t?uC(t):e.alt??``,r=Yj(n),i=QO((t&&pC(t))??e.src??void 0),a=e.radius??`xl`,o={...e,value:void 0,link:void 0};return e.link?(0,I.jsx)(Wj,{to:t,children:(0,I.jsx)(kp,{src:i,alt:n,radius:a,...o,children:r})}):(0,I.jsx)(kp,{src:i,alt:n,radius:a,...o,children:r})}var Zj={logoButton:`_logoButton_799cf_1`,user:`_user_799cf_11`,userName:`_userName_799cf_25`},Qj={iconBox:`_iconBox_1mfdi_1`,interactive:`_interactive_1mfdi_12`};function $j(e){let{projectDisplay:t,profileDisplay:n,label:r,selected:i}=e,a=r?`${t} - ${r}`:t;return(0,I.jsxs)(V,{gap:`xs`,align:`center`,wrap:`nowrap`,style:{width:`100%`,minWidth:0},children:[(0,I.jsx)(z,{className:Qj.iconBox,children:(0,I.jsx)(yA,{size:16,stroke:2})}),(0,I.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,I.jsx)(H,{size:`sm`,fw:500,truncate:!0,children:a}),(0,I.jsx)(H,{size:`xs`,c:`dimmed`,truncate:!0,children:n})]}),i&&(0,I.jsx)(wA,{size:16,stroke:2,color:`var(--mantine-color-blue-6)`})]})}function eM(e){let{membership:t,label:n}=e;return(0,I.jsx)($j,{projectDisplay:t.project?.display,profileDisplay:t.profile?.display,label:n})}function tM(){return`Medplum`}var nM={divider:`_divider_3o3ui_1`,accountSection:`_accountSection_3o3ui_5`,projectOption:`_projectOption_3o3ui_9`,recentProjectItem:`_recentProjectItem_3o3ui_18`,dropdown:`_dropdown_3o3ui_22`,settingsRow:`_settingsRow_3o3ui_43`,settingsControlWrapper:`_settingsControlWrapper_3o3ui_50`,segmentedControl:`_segmentedControl_3o3ui_57`,appearanceControl:`_appearanceControl_3o3ui_76`,layoutControl:`_layoutControl_3o3ui_93`},rM=`var(--mantine-color-dimmed)`,iM=[{value:`light`,label:(0,I.jsx)(oM,{Icon:wj,label:`Light`})},{value:`auto`,label:(0,I.jsx)(oM,{Icon:FA,label:`System`})},{value:`dark`,label:(0,I.jsx)(oM,{Icon:aj,label:`Dark`})}],aM=[{label:`v1`,value:`v1`},{label:`v2`,value:`v2`}];function oM({Icon:e,label:t}){return(0,I.jsx)(`span`,{"aria-label":t,style:{display:`flex`},children:(0,I.jsx)(e,{size:16,color:rM,"aria-hidden":!0})})}function sM(){return(0,I.jsx)(dm,{my:4,mx:4,className:nM.divider})}function cM(e,t){return t?e.project.reference===t.project.reference&&e.profile.reference===t.profile.reference:!1}function lM(e){return`${e.project.reference}-${e.profile.reference}`}function uM(e){let{medplum:t,profile:n,navigate:r}=GO(),i=t.getActiveLogin(),a=t.getLogins().filter(e=>!cM(e,i)),o=t.getProject(),{colorScheme:s,setColorScheme:c}=ci(),[l]=(0,b.useState)(()=>localStorage.appShellLayoutVersion??`v1`),u=e.showLayoutVersionToggle??!0,d=o?.name??t.getActiveLogin()?.project.display,f=i?.profile.display??(n?lw(n.name?.[0]):void 0);function p(e){t.setActiveLogin(e).then(()=>LE.reload()).catch(console.error)}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(z,{className:nM.accountSection,children:(0,I.jsx)(z,{className:nM.projectOption,children:(0,I.jsx)($j,{projectDisplay:d,profileDisplay:f,selected:!0})})}),a.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(sM,{}),a.map(e=>(0,I.jsx)(W.Item,{className:nM.recentProjectItem,onClick:()=>p(e),children:(0,I.jsx)(z,{className:nM.projectOption,children:(0,I.jsx)($j,{projectDisplay:e.project.display,profileDisplay:e.profile.display})})},lM(e)))]}),(0,I.jsx)(sM,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(Tj,{size:16,color:rM}),onClick:()=>r(`/signin`),children:(0,I.jsx)(H,{size:`sm`,children:`Switch to another project`})}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(yj,{size:16,color:rM}),onClick:()=>r(`/${oC(n)}`),children:(0,I.jsx)(H,{size:`sm`,children:`Account settings`})}),(0,I.jsxs)(_d,{className:nM.settingsRow,align:`center`,pl:`sm`,pr:`xs`,py:`xs`,children:[(0,I.jsxs)(_d,{align:`center`,gap:`xs`,children:[(0,I.jsx)(sj,{size:16,color:rM}),(0,I.jsx)(H,{size:`sm`,children:`Appearance`})]}),(0,I.jsx)(z,{className:nM.settingsControlWrapper,children:(0,I.jsx)(uy,{classNames:{root:Mn(nM.segmentedControl,nM.appearanceControl)},size:`xs`,radius:`xl`,withItemsBorders:!1,value:s,onChange:e=>c(e),data:iM,"aria-label":`Color scheme`})})]}),u&&(0,I.jsxs)(_d,{className:nM.settingsRow,align:`center`,pl:`sm`,pr:`xs`,py:`xs`,children:[(0,I.jsxs)(_d,{align:`center`,gap:`xs`,children:[(0,I.jsx)(Dj,{size:16,color:rM}),(0,I.jsx)(H,{size:`sm`,children:`Layout`})]}),(0,I.jsx)(z,{className:nM.settingsControlWrapper,children:(0,I.jsx)(uy,{classNames:{root:Mn(nM.segmentedControl,nM.layoutControl)},size:`xs`,radius:`xl`,withItemsBorders:!1,value:l,onChange:e=>{localStorage.appShellLayoutVersion=e,LE.reload()},data:aM,"aria-label":`App shell layout version`})})]}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)($A,{size:16,color:rM}),onClick:async()=>{await t.signOut(),r(`/signin`)},children:(0,I.jsx)(H,{size:`sm`,children:`Sign out`})}),(0,I.jsx)(sM,{}),(0,I.jsxs)(H,{size:`xs`,c:`dimmed`,fw:500,my:`sm`,ta:`center`,children:[tM(),` `,e.version]})]})}var dM={selectedItems:`selected-items`,options:`options`};function fM(e){let t=If({onDropdownClose:()=>t.resetSelectedOption(),onDropdownOpen:()=>t.updateSelectedOptionIndex(`active`)}),{name:n,label:r,description:i,error:a,defaultValue:o,toOption:s,loadOptions:c,itemComponent:l,pillComponent:u,emptyComponent:d,onChange:f,onCreate:p,creatable:m,clearable:h,required:g,placeholder:_,leftSection:v,maxValues:y,optionsDropdownMaxHeight:x=320,minInputLength:S=0,...C}=e,w=C.disabled,T=pM(o),[E,D]=(0,b.useState)(``),[O,k]=(0,b.useState)(),[A,j]=(0,b.useState)(),[M,ee]=(0,b.useState)(),[N,P]=(0,b.useState)(T.map(s)),[te,ne]=(0,b.useState)([]),re=l??mM,ie=u??hM,ae=d??gM,oe=(0,b.useRef)(E),se=(0,b.useRef)(void 0),ce=(0,b.useRef)(void 0),le=(0,b.useRef)(O),ue=(0,b.useRef)(A),de=(0,b.useRef)(M);(0,b.useLayoutEffect)(()=>{oe.current=E,le.current=O,ue.current=A,de.current=M});let fe=(0,b.useCallback)(()=>{if(k(void 0),oe.current===ce.current&&c===se.current||(oe.current?.length??0)<S)return;ce.current=oe.current,se.current=c;let e=new AbortController;j(e),c(oe.current??``,e.signal).then(n=>{e.signal.aborted||(ne(n.map(s)),de.current?(n.length>0&&f(n.slice(0,1)),ee(!1)):n.length>0&&t.openDropdown())}).catch(t=>{e.signal.aborted||t.message.includes(`aborted`)||J({color:`red`,message:Qx(t)})}).finally(()=>{e.signal.aborted||j(void 0)})},[t,c,f,s,S]),pe=(0,b.useCallback)(e=>{(te&&te.length>0||m)&&t.openDropdown(),t.updateSelectedOptionIndex(),D(e.currentTarget.value),ue.current&&(ue.current.abort(),j(void 0)),le.current!==void 0&&window.clearTimeout(le.current),k(window.setTimeout(()=>fe(),100))},[t,te,m,fe]),me=(0,b.useCallback)(e=>{let t=N.some(t=>t.value===e),n=t?N.filter(t=>t.value!==e):[...N],r=te?.find(t=>t.value===e);if(!r&&m!==!1&&p&&(r=s(p(e))),r){if(y===0){f([r.resource]),N.length>0&&P([]);return}t||n.push(r)}if(y!==void 0)for(;n.length>y;)n.shift();f(n.map(e=>e.resource)),P(n)},[m,te,N,y,f,p,s]),he=(0,b.useMemo)(()=>{if(!w)return e=>{w||(y===1&&(D(``),ne([]),t.closeDropdown()),ce.current=void 0,e===`$create`?(D(``),me(E)):me(e))}},[me,t,w,y,E]),ge=(0,b.useCallback)(e=>{let t=N.filter(t=>t.value!==e.value);f(t.map(e=>e.resource)),P(t)},[N,f]),_e=(0,b.useCallback)(e=>{e.key===`Enter`?(O||A)&&ee(!0):e.key===`Backspace`&&E.length===0&&(Rj(e),ge(N[N.length-1]))},[A,ge,E.length,N,O]);(0,b.useEffect)(()=>()=>{ue.current&&ue.current.abort()},[]);let ve=!w&&h&&N.length>0&&(0,I.jsx)(zf.ClearButton,{title:`Clear all`,size:`sm`,onClear:()=>{D(``),P([]),f([]),t.closeDropdown()}}),ye=m&&E.trim().length>0,be=te.length>0||ye;return(0,I.jsxs)(zf,{store:t,onOptionSubmit:he,withinPortal:!0,shadow:`xl`,...C,children:[(0,I.jsx)(zf.DropdownTarget,{children:(0,I.jsx)(vg,{label:r,description:i,error:a,className:e.className,leftSection:v,rightSection:A?(0,I.jsx)(cu,{size:16}):ve,required:g,disabled:w,children:(0,I.jsxs)(pg.Group,{"data-testid":dM.selectedItems,children:[N.map(e=>(0,I.jsx)(ie,{item:e,disabled:w,onRemove:()=>ge(e)},e.value)),!w&&(y===void 0||y===0||N.length<y)&&(0,I.jsx)(zf.EventsTarget,{children:(0,I.jsx)(vg.Field,{role:`searchbox`,name:n,value:E,placeholder:_,onFocus:pe,onBlur:()=>{t.closeDropdown(),D(``)},onKeyDown:_e,onChange:pe})})]})})}),(0,I.jsx)(zf.Dropdown,{hidden:!be,"data-testid":dM.options,children:(0,I.jsx)(zf.Options,{children:(0,I.jsxs)(dl,{type:`scroll`,mah:x,children:[te.map(e=>{let t=N.some(t=>t.value===e.value);return(0,I.jsx)(zf.Option,{value:e.value,active:t,children:(0,I.jsx)(re,{...e,active:t})},e.value)}),ye&&(0,I.jsxs)(zf.Option,{value:`$create`,children:[`+ Create `,E]}),!m&&E.trim().length>0&&te.length===0&&(0,I.jsx)(ae,{search:E})]})})})]})}function pM(e){return e?Array.isArray(e)?e:[e]:[]}function mM(e){return(0,I.jsxs)(V,{gap:`xs`,children:[e.active&&(0,I.jsx)(wA,{size:12}),(0,I.jsx)(`span`,{children:e.label})]})}function hM({item:e,disabled:t,onRemove:n}){return(0,I.jsx)(pg,{withRemoveButton:!t,onRemove:n,children:e.label})}function gM(){return(0,I.jsx)(zf.Empty,{children:`Nothing found`})}var _M={searchInput:`_searchInput_dick8_1`};function vM(e){return{value:e.id,label:uC(e),resource:e}}function yM(e){let t=KO(),n=Z(),r=(0,b.useCallback)(async(e,t)=>{let r=xM(e),i={signal:t};return SM(await n.graphql(r,void 0,void 0,i),e)},[n]),i=(0,b.useCallback)(e=>{e.length>0&&t(`/${oC(e[0])}`)},[t]);return(0,I.jsx)(fM,{size:`sm`,radius:`md`,className:_M.searchInput,leftSection:(0,I.jsx)(vj,{size:16}),placeholder:`Search`,itemComponent:bM,toOption:vM,onChange:i,loadOptions:r,maxValues:0,clearable:!1},`${e.pathname}?${e.searchParams}`)}var bM=(0,b.forwardRef)(({resource:e,active:t,...n},r)=>{let i;return e.resourceType===`Patient`?i=e.birthDate:e.resourceType===`ServiceRequest`&&(i=e.subject?.display),(0,I.jsx)(`div`,{ref:r,...n,children:(0,I.jsxs)(V,{wrap:`nowrap`,children:[(0,I.jsx)(Xj,{value:e}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{children:uC(e)}),(0,I.jsx)(H,{size:`xs`,c:`dimmed`,children:i})]})]})})});function xM(e){let t=JSON.stringify(e);return NC(e)?`{
96
+ }`.replaceAll(/\s+/g,` `),n=await this.graphql(t);uS(n.data.StructureDefinitionList);for(let e of n.data.SearchParameterList)jw(e)})());return this.setCacheEntry(n,i,t),i}requestProfileSchema(e,t){if(!t?.expandProfile&&hS(e))return Promise.resolve();let n=e+`-requestSchema`+(t?.expandProfile?`-nested`:``),r=this.getCacheEntry(n,void 0);if(r)return r.value;let i=new xD((async()=>{if(t?.expandProfile){let t=this.fhirUrl(`StructureDefinition`,`$expand-profile`);t.search=new URLSearchParams({url:e}).toString(),uS(await this.post(t.toString(),{}))}else{let t=await this.searchOne(`StructureDefinition`,{url:e,_sort:`-_lastUpdated`});if(!t){console.warn(`No StructureDefinition found for ${e}!`);return}dS(t)}})());return this.setCacheEntry(n,i,t),i}readHistory(e,t,n,r){let i=this.fhirUrl(e,t,`_history`);return n?.count&&i.searchParams.set(`_count`,n.count.toString()),n?.offset&&i.searchParams.set(`_offset`,n.offset.toString()),this.get(i.toString(),r)}readVersion(e,t,n,r){return this.get(this.fhirUrl(e,t,`_history`,n),r)}readPatientEverything(e,t){return this.getBundle(this.fhirUrl(`Patient`,e,`$everything`),t)}readPatientSummary(e,t){return this.getBundle(this.fhirUrl(`Patient`,e,`$summary`),t)}createResource(e,t){if(!e.resourceType)throw Error(`Missing resourceType`);return this.invalidateSearches(e.resourceType),this.post(this.fhirUrl(e.resourceType),e,void 0,t)}async createResourceIfNoneExist(e,t,n={}){let r=this.fhirUrl(e.resourceType);this.setRequestHeader(n,`If-None-Exist`,t);let i=await this.post(r,e,void 0,n);return this.cacheResource(i,n),this.invalidateUrl(this.fhirUrl(e.resourceType,e.id,`_history`)),this.invalidateSearches(e.resourceType),i}async upsertResource(e,t,n){let r=this.fhirSearchUrl(e.resourceType,t),i=await this.put(r,e,void 0,n);return i||=e,this.cacheResource(i,n),this.invalidateUrl(this.fhirUrl(e.resourceType,e.id,`_history`)),this.invalidateSearches(e.resourceType),i}async createAttachment(e,t,n,r,i){let a=rO(e,t,n,r);if(a.contentType===ZE.XML){let e=a.data,t;t=e instanceof Blob?await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{if(!r.result){n(Error(`Failed to load file`));return}t(r.result)},r.readAsText(e,`utf-8`)}):ArrayBuffer.isView(e)?new TextDecoder().decode(e):e,t.includes(`<ClinicalDocument`)&&t.includes(`urn:hl7-org:v3`)&&(a={...a,contentType:ZE.CDA_XML})}let o=i??(typeof t==`object`?t:{}),s=await this.createBinary(a,o);return{contentType:a.contentType,url:s.url,title:a.filename}}createBinary(e,t,n,r,i){let a=rO(e,t,n,r),o=i??(typeof t==`object`?t:{}),{data:s,contentType:c,filename:l,securityContext:u,onProgress:d}=a,f=this.fhirUrl(`Binary`);return l&&f.searchParams.set(`_filename`,l),u?.reference&&this.setRequestHeader(o,`X-Security-Context`,u.reference),d?this.uploadwithProgress(f,s,c,d,o):this.post(f,s,c,o)}uploadwithProgress(e,t,n,r,i){return new Promise((a,o)=>{let s=new XMLHttpRequest,c=()=>s.abort();i?.signal?.addEventListener(`abort`,c);let l=e=>{i?.signal?.removeEventListener(`abort`,c),e instanceof Error?o(e):a(e)};if(s.responseType=`json`,s.onabort=()=>l(new DOMException(`Request aborted`,`AbortError`)),s.onerror=()=>l(Error(`Request error`)),r&&(s.upload.onprogress=e=>r(e),s.upload.onload=e=>r(e)),s.onload=()=>{s.status>=200&&s.status<300?l(s.response):l(new Xx(Zx(s.response||s.statusText)))},s.open(`POST`,e),s.withCredentials=!0,s.setRequestHeader(`Authorization`,`Bearer `+this.accessToken),s.setRequestHeader(`Cache-Control`,`no-cache, no-store, max-age=0`),s.setRequestHeader(`Content-Type`,n),this.options.extendedMode!==!1&&s.setRequestHeader(`X-Medplum`,`extended`),i?.headers){let e=i.headers;for(let[t,n]of Object.entries(e))s.setRequestHeader(t,n)}s.send(t)})}async createPdf(e,t,n,r){if(!this.createPdfImpl)throw Error(`PDF creation not enabled`);let i=aO(e,t,n,r),a=typeof t==`object`?t:{},{docDefinition:o,tableLayouts:s,fonts:c,...l}=i,u=await this.createPdfImpl(o,s,c),d={...l,data:u,contentType:`application/pdf`};return this.createBinary(d,a)}createComment(e,t,n){let r=this.getProfile(),i,a;return e.resourceType===`Encounter`&&(i=aC(e),a=e.subject),e.resourceType===`ServiceRequest`&&(i=e.encounter,a=e.subject),e.resourceType===`Patient`&&(a=aC(e)),this.createResource({resourceType:`Communication`,status:`completed`,basedOn:[aC(e)],encounter:i,subject:a,sender:r?aC(r):void 0,sent:new Date().toISOString(),payload:[{contentString:t}]},n)}async updateResource(e,t){if(!e.resourceType)throw Error(`Missing resourceType`);if(!e.id)throw Error(`Missing id`);let n=await this.put(this.fhirUrl(e.resourceType,e.id),e,void 0,t);return n||=e,this.cacheResource(n,t),this.invalidateUrl(this.fhirUrl(e.resourceType,e.id,`_history`)),this.invalidateSearches(e.resourceType),n}async patchResource(e,t,n,r){let i=await this.patch(this.fhirUrl(e,t),n,r);return this.cacheResource(i,r),this.invalidateUrl(this.fhirUrl(e,t,`_history`)),this.invalidateSearches(e),i}deleteResource(e,t,n){return this.deleteCacheEntry(this.fhirUrl(e,t).toString()),this.invalidateSearches(e),this.delete(this.fhirUrl(e,t),n)}validateResource(e,t){return this.post(this.fhirUrl(e.resourceType,`$validate`),e,void 0,t)}executeBot(e,t,n,r){let i;if(typeof e==`string`){let t=e;i=this.fhirUrl(`Bot`,t,`$execute`)}else{let t=e;i=this.fhirUrl(`Bot`,`$execute`),i.searchParams.set(`identifier`,t.system+`|`+t.value)}return this.post(i,t,n,r)}executeBatch(e,t){return this.post(this.fhirBaseUrl,e,void 0,t)}sendEmail(e,t){return this.post(`email/v1/send`,e,ZE.JSON,t)}graphql(e,t,n,r){return this.post(this.fhirUrl(`$graphql`),{query:e,operationName:t,variables:n},ZE.JSON,r)}readResourceGraph(e,t,n,r){return this.get(`${this.fhirUrl(e,t)}/$graph?graph=${n}`,r)}pushToAgent(e,t,n,r,i,a){let{waitTimeout:o,returnAck:s,...c}=a??{};return this.post(this.fhirUrl(`Agent`,sC(e),`$push`),{destination:typeof t==`string`?t:oC(t),body:n,contentType:r,waitForResponse:i,...o===void 0?void 0:{waitTimeout:o},...s===void 0?void 0:{returnAck:s}},ZE.FHIR_JSON,c)}getCdsServices(e){return this.get(this.cdsServicesUrl,e)}callCdsService(e,t,n){return this.post(ew(this.cdsServicesUrl,e),t,ZE.JSON,n)}getActiveLogin(){return this.storage.getObject(`activeLogin`)}async setActiveLogin(e){(!this.sessionDetails?.profile||oC(this.sessionDetails.profile)!==e.profile?.reference)&&this.clearActiveLogin(),this.setAccessToken(e.accessToken,e.refreshToken),this.storage.setObject(`activeLogin`,e),this.addLogin(e),this.refreshPromise=void 0,await this.refreshProfile()}getAccessToken(){return this.accessToken}isAuthenticated(e){return this.accessTokenExpires!==void 0&&Date.now()<this.accessTokenExpires-(e??this.refreshGracePeriod)}setAccessToken(e,t){this.accessToken=e,this.refreshToken=t,this.accessTokenExpires=yD(e),this.medplumServer=vD(e)}getLogins(){return this.storage.getObject(`logins`)??[]}addLogin(e){let t=this.getLogins().filter(t=>t.profile?.reference!==e.profile?.reference);t.push(e),this.storage.setObject(`logins`,t)}async refreshProfile(){if(this.medplumServer)return this.profilePromise=new Promise((e,t)=>{this.get(`auth/me`,{cache:`no-cache`}).then(t=>{this.profilePromise=void 0;let n=this.sessionDetails?.profile?.id!==t.profile.id;this.sessionDetails=t,this.syncStoredLoginProject(),n&&this.dispatchEvent({type:`change`}),e(t.profile),this.dispatchEvent({type:`profileRefreshed`})}).catch(t)}),this.dispatchEvent({type:`profileRefreshing`}),this.profilePromise}syncStoredLoginProject(){let e=this.getActiveLogin(),t=this.sessionDetails?.project?.name;if(!e||!t||e.project.display===t)return;let n={...e,project:{...e.project,display:t}};this.storage.setObject(`activeLogin`,n),this.addLogin(n)}isLoading(){return!this.isInitialized||!!this.profilePromise&&!this.sessionDetails?.profile}isSuperAdmin(){return!!this.sessionDetails?.project.superAdmin}isProjectAdmin(){return!!this.sessionDetails?.membership.admin}getProject(){return this.sessionDetails?.project}getProjectMembership(){return this.sessionDetails?.membership}getProfile(){return this.sessionDetails?.profile}async getProfileAsync(){return this.profilePromise?this.profilePromise:this.sessionDetails?this.sessionDetails.profile:this.refreshProfile()}getUserConfiguration(){return this.sessionDetails?.config}getAccessPolicy(){return this.sessionDetails?.accessPolicy}async download(e,t={}){return(await this.downloadResponse(e,t)).blob()}async downloadResponse(e,t={}){this.refreshPromise&&await this.refreshPromise;let n=e.toString();n.startsWith(qD)&&(e=this.fhirUrl(n));let r=t.headers;return r||(r={},t.headers=r),r.Accept||=`*/*`,this.addFetchOptionsDefaults(t),this.fetchWithRetry(e.toString(),t)}async createMedia(e,t){let{additionalFields:n,...r}=e,i=await this.createResource({resourceType:`Media`,status:`preparation`,content:{contentType:e.contentType},...n});r.securityContext||=aC(i);let a=await this.createAttachment(r,t);return this.updateResource({...i,status:`completed`,content:a})}async uploadMedia(e,t,n,r,i){return this.createMedia({data:e,contentType:t,filename:n,additionalFields:r},i)}async createDocumentReference(e,t){let{additionalFields:n,...r}=e,i=await this.createResource({resourceType:`DocumentReference`,status:`current`,content:[{attachment:{contentType:e.contentType}}],...n});r.securityContext||=aC(i);let a=await this.createAttachment(r,t);return this.updateResource({...i,content:[{attachment:a}]})}async bulkExport(e=``,t,n,r){let i=e&&`${e}/`,a=this.fhirUrl(`${i}$export`);return t&&a.searchParams.set(`_type`,t),n&&a.searchParams.set(`_since`,n),this.startAsyncRequest(a.toString(),r)}async startAsyncRequest(e,t={}){this.addFetchOptionsDefaults(t);let n=t.headers;return n.Prefer=`respond-async`,t.method=`POST`,this.request(e,t)}async wrappedFetch(e,t){return await this.refreshIfExpired(),this.addFetchOptionsDefaults(t),this.fetchWithRetry(e,t)}get keyValue(){return this.keyValueClient||=new bD(this),this.keyValueClient}getBundle(e,t){return new xD((async()=>{let n=await this.get(e,t);for(let e of n.entry??aw)this.cacheResource(e.resource,t);return n})())}isCacheEnabled(e){return!!this.requestCache&&!this.getRequestHeader(e,`x-medplum-on-behalf-of`)}getCacheEntry(e,t){if(!this.isCacheEnabled(t)||t?.cache===`no-cache`||t?.cache===`reload`)return;let n=this.requestCache.get(e);if(!(!n||n.requestTime+this.cacheTime<Date.now()))return n}setCacheEntry(e,t,n){this.isCacheEnabled(n)&&(this.requestCache.set(e,{requestTime:Date.now(),value:t}),n?.signal&&n.signal.addEventListener(`abort`,()=>{this.requestCache.delete(e)}))}cacheResource(e,t){e?.id&&!e.meta?.tag?.some(e=>e.code===`SUBSETTED`)&&this.setCacheEntry(this.fhirUrl(e.resourceType,e.id).toString(),new xD(Promise.resolve(e)),t)}deleteCacheEntry(e){this.requestCache&&this.requestCache.delete(e)}async request(e,t={},n={}){let r=await this.wrappedFetch(e,t);if(r.status===401)return this.handleUnauthenticated(e,t);if(r.status===204||r.status===304)return;let i=r.headers.get(`content-type`)?.includes(`json`);if(r.status===404&&!i)throw new Xx(Rx);let a=await this.parseBody(r,i);if(r.status===200&&t.followRedirectOnOk||r.status===201&&t.followRedirectOnCreated){let e=await eO(r,a);if(e)return this.request(e,{...t,method:`GET`,body:void 0})}if(r.status===202&&t.pollStatusOnAccepted){let e=await eO(r,a)??n.statusUrl;if(e)return this.pollStatus(e,t,n)}if(r.status>=400)throw new Xx(Zx(a));return a}async parseBody(e,t){let n;if(e.headers.get(`content-length`)!==`0`){if(t)try{n=await e.json()}catch(t){throw console.error(`Error parsing response`,e.status,t),t}else n=await e.text();return n}}async fetchWithRetry(e,t){e.startsWith(`http`)||(e=ew(this.baseUrl,e));let n=t?.maxRetries??this.maxRetries;for(let r=0;r<=n;r++)try{this.logLevel!==`none`&&this.logRequest(e,t);let i=await this.fetch(e,t);if(this.logLevel!==`none`&&this.logResponse(i),this.setCurrentRateLimit(i),r>=n||!oO(i))return i;let a=this.getRetryDelay(r);if(a>(t.maxRetryTime??this.maxRetryTime))return i;await qC(a,{signal:t.signal})}catch(e){if(e.message===`Failed to fetch`&&r===0&&this.dispatchEvent({type:`offline`}),e.name===`AbortError`||r===n)throw e}throw Error(`Unreachable`)}logRequest(e,t){if(console.log(`> ${t.method} ${e}`),this.logLevel===`verbose`&&t.headers){let e=t.headers;for(let t of ZC(Object.keys(e)))console.log(`> ${t}: ${e[t]}`)}}logResponse(e){console.log(`< ${e.status} ${e.statusText}`),this.logLevel===`verbose`&&e.headers&&e.headers.forEach((e,t)=>console.log(`< ${t}: ${e}`))}setCurrentRateLimit(e){if(!e?.headers||typeof e.headers.get!=`function`)return;let t=e.headers.get(`ratelimit`);t&&(this.currentRateLimits=t)}rateLimitStatus(){if(!this.currentRateLimits)return[];let e=this.currentRateLimits;return e.split(`,`).map(t=>{let n=t.split(`;`).map(e=>e.trim());if(n.length!==3)throw Error(`Could not parse RateLimit header: `+e);let r=n[0].substring(1,n[0].length-1),i=n.find(e=>e.startsWith(`r=`))?.substring(2),a=i?Number.parseInt(i,10):NaN,o=n.find(e=>e.startsWith(`t=`))?.substring(2),s=o?Number.parseInt(o,10):NaN;if(!r||Number.isNaN(a)||Number.isNaN(s))throw Error(`Could not parse RateLimit header: `+e);return{name:r,remainingUnits:a,secondsUntilReset:s,resetsAfter:Math.ceil((Date.now()+1e3*s)/1e3)}})}getRetryDelay(e){let t=this.rateLimitStatus(),n=500*1.5**e;for(let e of t)e.remainingUnits||(n=Math.max(n,e.secondsUntilReset*1e3));return n}async pollStatus(e,t,n){let r={...t,method:`GET`,body:void 0,redirect:`follow`};return n.pollCount===void 0?(t.headers&&typeof t.headers==`object`&&`Prefer`in t.headers&&(r.headers={...t.headers},delete r.headers.Prefer),n.statusUrl=e,n.pollCount=1):(await qC(t.pollStatusPeriod??1e3,{signal:t.signal}),n.pollCount++),this.request(e,{...t,method:`GET`},n)}async executeAutoBatch(){if(this.autoBatchQueue===void 0)return;let e=[...this.autoBatchQueue];if(this.autoBatchQueue.length=0,this.autoBatchTimerId=void 0,e.length===1){let t=e[0];try{t.options.method=t.method,t.resolve(await this.request(ew(this.fhirBaseUrl,t.url),t.options))}catch(e){t.reject(new Xx(Zx(e)))}return}let t={resourceType:`Bundle`,type:`batch`,entry:e.map(e=>({request:{method:e.method,url:e.url},resource:e.options.body?JSON.parse(e.options.body):void 0}))},n=await this.post(this.fhirBaseUrl,t);for(let t=0;t<e.length;t++){let r=e[t],i=n.entry?.[t];i?.response?.outcome&&!Jx(i.response.outcome)?r.reject(new Xx(i.response.outcome)):r.resolve(i?.resource)}}addFetchOptionsDefaults(e){Object.entries(this.defaultHeaders).forEach(([t,n])=>{this.setRequestHeader(e,t,n)}),this.setRequestHeader(e,`Accept`,VD,!0),this.options.extendedMode!==!1&&this.setRequestHeader(e,`X-Medplum`,`extended`),e.body&&this.setRequestHeader(e,`Content-Type`,ZE.FHIR_JSON,!0),this.accessToken?this.setRequestHeader(e,`Authorization`,`Bearer `+this.accessToken):this.basicAuth&&this.setRequestHeader(e,`Authorization`,`Basic `+this.basicAuth),e.cache||=`no-cache`,e.credentials||=`include`}setRequestContentType(e,t){this.setRequestHeader(e,`Content-Type`,t)}getRequestHeader(e,t){let n=e?.headers;if(n){if(Array.isArray(n)){let e=n.find(([e])=>e.toLowerCase()===t.toLowerCase());return e?e[1]:void 0}else if(n instanceof Headers)return n.get(t)??void 0;else if(PC(n))return n[t]??void 0}}setRequestHeader(e,t,n,r=!1){let i=e.headers;i?Array.isArray(i)?(!r||!i.some(([e])=>e.toLowerCase()===t.toLowerCase()))&&i.push([t,n]):i instanceof Headers?(!r||!i.has(t))&&i.set(t,n):PC(i)&&(!r||!i[t])&&(i[t]=n):e.headers={[t]:n}}setRequestBody(e,t){typeof t==`string`||typeof Blob<`u`&&(t instanceof Blob||t?.constructor.name===`Blob`)||typeof File<`u`&&(t instanceof File||t?.constructor.name===`File`)||typeof Uint8Array<`u`&&(t instanceof Uint8Array||t?.constructor.name===`Uint8Array`)?e.body=t:typeof t==`object`&&t&&(typeof t.getReader==`function`||typeof t.pipe==`function`&&typeof t.on==`function`)?(e.body=t,e.duplex=`half`):t&&(e.body=JSON.stringify(t))}handleUnauthenticated(e,t){if(this.refresh())return this.request(e,t);throw this.clear(),this.onUnauthenticated?.(),new Xx(zx)}async startPkce(){let e=VE();this.storage.setString(`pkceState`,e);let t=VE().slice(0,128);this.storage.setString(`codeVerifier`,t);try{return{codeChallengeMethod:`S256`,codeChallenge:VC(await HE(t)).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replaceAll(`=`,``)}}catch(e){return console.warn(`Failed to hash code verifier. Falling back to 'plain' code challenge method`,e),{codeChallengeMethod:`plain`,codeChallenge:t}}}async requestAuthorization(e){let t=await this.ensureCodeChallenge(e??{}),n=new URL(this.authorizeUrl);n.searchParams.set(`response_type`,`code`),n.searchParams.set(`state`,this.storage.getString(`pkceState`)),n.searchParams.set(`client_id`,t.clientId??this.clientId),n.searchParams.set(`redirect_uri`,t.redirectUri??LE.getOrigin()),n.searchParams.set(`code_challenge_method`,t.codeChallengeMethod),n.searchParams.set(`code_challenge`,t.codeChallenge),n.searchParams.set(`scope`,t.scope??`openid profile`),LE.assign(n.toString())}processCode(e,t){let n={grant_type:YD.AuthorizationCode,code:e,client_id:t?.clientId??this.clientId??``,redirect_uri:t?.redirectUri??LE.getOrigin()},r=this.storage.getString(`codeVerifier`);return r&&(n.code_verifier=r),this.fetchTokens(n)}refreshIfExpired(e){return!this.refreshPromise&&this.accessTokenExpires!==void 0&&!this.isAuthenticated(e)&&this.refresh(e),this.refreshPromise??Promise.resolve()}refresh(e){if(this.refreshPromise)return this.refreshPromise;if(!(!this.refreshToken&&!(this.clientId&&this.clientSecret)))return this.refreshPromise=this.runRefreshWithLock(e),this.refreshPromise}async runRefreshWithLock(e){let t=()=>{let t=this.getActiveLogin();return t?.accessToken&&t.accessToken!==this.accessToken&&this.setAccessToken(t.accessToken,t.refreshToken),this.isAuthenticated(e)?Promise.resolve(this.getProfile()):this.refreshToken?this.fetchTokens({grant_type:YD.RefreshToken,client_id:this.clientId??``,refresh_token:this.refreshToken}):this.clientId&&this.clientSecret?this.startClientLogin(this.clientId,this.clientSecret):Promise.resolve(void 0)},n=typeof navigator<`u`?navigator.locks:void 0;if(!n?.request)return t();let r=`medplum-refresh:${this.storage.makeKey(`activeLogin`)}`;return n.request(r,t)}async startClientLogin(e,t){return this.clientId=e,this.clientSecret=t,this.fetchTokens({grant_type:YD.ClientCredentials,client_id:e,client_secret:t})}async startJwtBearerLogin(e,t,n){return this.clientId=e,this.fetchTokens({grant_type:YD.JwtBearer,client_id:e,assertion:t,scope:n})}async startJwtAssertionLogin(e){return this.fetchTokens({grant_type:YD.ClientCredentials,client_assertion_type:ZD.JwtBearer,client_assertion:e})}setBasicAuth(e,t){this.clientId=e,this.clientSecret=t,this.basicAuth=zE(e+`:`+t)}setLogLevel(e){this.logLevel=e,this.options.verbose=e===`verbose`}getLogLevel(){return this.logLevel}setVerbose(e){this.logLevel=e?`verbose`:`none`,this.options.verbose=e}async fhircastSubscribe(e,t){if(!(typeof e==`string`&&e!==``))throw new Xx(Wx(`Invalid topic provided. Topic must be a valid string.`));if(!(typeof t==`object`&&Array.isArray(t)&&t.length>0))throw new Xx(Wx(`Invalid events provided. Events must be an array of event names containing at least one event.`));let n={channelType:`websocket`,mode:`subscribe`,topic:e,events:t},r=(await this.post(this.fhircastHubUrl,cD(n),ZE.FORM_URL_ENCODED))[`hub.channel.endpoint`];if(!r)throw Error(`Invalid response!`);return n.endpoint=r,n}async fhircastUnsubscribe(e){if(!lD(e))throw new Xx(Wx(`Invalid topic or subscriptionRequest. SubscriptionRequest must be an object.`));if(!(e.endpoint&&typeof e.endpoint==`string`&&e.endpoint.startsWith(`ws`)))throw new Xx(Wx(`Provided subscription request must have an endpoint in order to unsubscribe.`));e.mode=`unsubscribe`,await this.post(this.fhircastHubUrl,cD(e),ZE.FORM_URL_ENCODED)}fhircastConnect(e){return new mD(e)}async fhircastPublish(e,t,n,r){return rD(t)?this.post(this.fhircastHubUrl,pD(e,t,n,r),ZE.JSON):(iD(t),this.post(this.fhircastHubUrl,pD(e,t,n),ZE.JSON))}async fhircastGetContext(e){return this.get(`${this.fhircastHubUrl}/${e}`,{cache:`no-cache`})}async invite(e,t){return this.post(`admin/projects/`+e+`/invite`,t)}async handleTokenError(e){try{let t=await e.json();throw qx(t)?new Xx(t):t.error_description?new Xx(Ux(t.error_description)):Error(JSON.stringify(t))}catch(e){throw e instanceof Xx?(e.message=`Failed to fetch tokens: ${e.message}`,e):new Xx(Ux(`Failed to fetch tokens`),{cause:e})}}async fetchTokens(e){let t=new URLSearchParams(e),n={...this.defaultHeaders,"Content-Type":ZE.FORM_URL_ENCODED};this.basicAuth&&(n.Authorization=`Basic ${this.basicAuth}`),this.credentialsInHeader&&(t.delete(`client_id`),t.delete(`client_secret`),!this.basicAuth&&e.client_id&&e.client_secret&&(n.Authorization=`Basic ${zE(e.client_id+`:`+e.client_secret)}`));let r={method:`POST`,headers:n,body:t.toString(),credentials:`include`},i;try{i=await this.fetchWithRetry(this.tokenUrl,r)}catch(e){throw this.refreshPromise=void 0,e}i.ok||(this.clearActiveLogin(),this.onUnauthenticated?.(),await this.handleTokenError(i));let a=await i.json();return await this.verifyTokens(a),this.getProfile()}async verifyTokens(e){let t=e.access_token;if(gD(t)){let e=_D(t);if(Date.now()>=e.exp*1e3)throw this.clearActiveLogin(),new Xx(Bx);if(e.cid){if(e.cid!==this.clientId)throw this.clearActiveLogin(),new Xx(Vx)}else if(this.clientId&&e.client_id!==this.clientId)throw this.clearActiveLogin(),new Xx(Vx)}return this.setActiveLogin({accessToken:t,refreshToken:e.refresh_token,project:e.project,profile:e.profile})}checkSessionDetailsMatchLogin(e){return this.sessionDetails&&e?e.profile?.reference?.endsWith(this.sessionDetails.profile.id)??!1:!0}setupStorageListener(){try{window.addEventListener(`storage`,e=>{if(e.key===null)LE.reload();else if(e.key===this.storage.makeKey(`activeLogin`)){let t=e.oldValue?JSON.parse(e.oldValue):void 0,n=e.newValue?JSON.parse(e.newValue):void 0;t?.profile.reference!==n?.profile.reference||!this.checkSessionDetailsMatchLogin(n)?LE.reload():n?this.setAccessToken(n.accessToken,n.refreshToken):this.clear()}})}catch{}}getSubscriptionManager(){return this.subscriptionManager||=new RD(this,tw(this.baseUrl,`/ws/subscriptions-r4`)),this.subscriptionManager}subscribeToCriteria(e,t){return this.getSubscriptionManager().addCriteria(e,t)}unsubscribeFromCriteria(e,t){this.subscriptionManager&&this.subscriptionManager.removeCriteria(e,t)}getMasterSubscriptionEmitter(){return this.getSubscriptionManager().getMasterEmitter()}};function $D(){if(!globalThis.fetch)throw Error(`Fetch not available in this environment`);return globalThis.fetch.bind(globalThis)}async function eO(e,t){let n=e.headers.get(`content-location`);if(n)return n;let r=e.headers.get(`location`);if(r)return r;if(qx(t)&&t.issue?.[0]?.diagnostics)return t.issue[0].diagnostics}function tO(e){let t=e.entry?.map(e=>e.resource)??[];return Object.assign(t,{bundle:e})}function nO(e){return PC(e)&&`data`in e&&`contentType`in e}function rO(e,t,n,r){return nO(e)?e:{data:e,filename:t,contentType:n,onProgress:r}}function iO(e){return PC(e)&&`docDefinition`in e}function aO(e,t,n,r){return iO(e)?e:{docDefinition:e,filename:t,tableLayouts:n,fonts:r}}function oO(e){return e.status===429||e.status>=500}function sO({parentContext:e,path:t,elements:n,profileUrl:r,debugMode:i,accessPolicyResource:a}){if(t===e?.path)return;i??=e?.debugMode??!1,a??=e?.accessPolicyResource;let o=cO(t,n,e,!!i),s=JC(t,`.`,2)[1];o=lO(o,a,s),o=uO(o,a,s);let c=Object.create(null);for(let[e,n]of Object.entries(o))c[t+`.`+e]=n;let l;if(e&&!e.isDefaultContext)l=e.getExtendedProps;else{let e=Object.create(null);l=t=>{let n=JC(t,`.`,2)[1];if(n){if(!e[n]){let t=dO(n,a?.hiddenFields);e[n]={hidden:t,readonly:t||dO(n,a?.readonlyFields)}}return e[n]}}}return{path:t,elements:o,elementsByPath:c,profileUrl:r??e?.profileUrl,debugMode:i,getExtendedProps:l,accessPolicyResource:a}}function cO(e,t,n,r){let i=Object.create(null);if(n)for(let[t,r]of Object.entries(n.elementsByPath)){let n=GC(e,t);n!==void 0&&(i[n]=r)}let a=!1;if(t)for(let[e,n]of Object.entries(t))e in i||(i[e]=n,a=!0);return r&&console.assert(a,`Unnecessary ElementsContext; not using any newly provided elements`),i}function lO(e,t,n){if(!t?.hiddenFields?.length)return e;let r=n?n+`.`:``;return Object.fromEntries(Object.entries(e).filter(([e])=>!dO(r+e,t.hiddenFields)))}function uO(e,t,n){if(!t?.readonlyFields?.length)return e;let r=Object.create(null),i=n?n+`.`:``;for(let[n,a]of Object.entries(e))dO(i+n,t.readonlyFields)?r[n]={...a,readonly:!0}:r[n]=a;return r}function dO(e,t){if(!t?.length)return!1;let n=e.split(`.`);for(let e=1;e<=n.length;e++){let r=n.slice(0,e).join(`.`);if(t.includes(r))return!0}return!1}function fO(e){return e.type!==void 0&&e.type.length>0}function pO(e,t,n,r){let i=TS(e,t.path,{profileUrl:r});if(i){let e=n.typeSchema?.elements??n.elements;return i.some(r=>kS(r,t,n,e))??!1}return console.assert(!1,`getNestedProperty[%s] in isDiscriminatorComponentMatch missed`,t.path),!1}function mO(e,t,n,r){if(e)for(let i of t){let t={value:e,type:i.typeSchema?.type??i.type?.[0].code};if(n.every(e=>pO(t,e,i,i.typeSchema?.url??r)))return i.name}}var hO=class{rootSchema;visitor;elementsContextStack;sliceAllowList;constructor(e,t,n){if(e.type===void 0)throw Error(`schema must include a type`);this.rootSchema=e;let r=sO({parentContext:void 0,path:this.rootSchema.type,elements:n??this.rootSchema.elements,profileUrl:this.rootSchema.name===this.rootSchema.type?void 0:this.rootSchema.url});if(r===void 0)throw Error(`Could not create root elements context`);this.elementsContextStack=[r],this.visitor=t}get elementsContext(){return this.elementsContextStack.at(-1)}crawlElement(e,t,n){this.visitor.onEnterSchema&&this.visitor.onEnterSchema(this.rootSchema);let r=Object.fromEntries(Object.entries(this.elementsContext.elements).filter(([e])=>e.startsWith(t)));this.crawlElementsImpl(r,n),this.visitor.onExitSchema&&this.visitor.onExitSchema(this.rootSchema)}crawlSlice(e,t,n){let r=this.prepareSlices(n.slices,n);if(!wC(r.slices))throw Error(`cannot crawl slice ${t.name} since it has no type information`);this.visitor.onEnterSchema&&this.visitor.onEnterSchema(this.rootSchema),this.sliceAllowList=[t],this.crawlSliceImpl(r.slices[0],t.path,r),this.sliceAllowList=void 0,this.visitor.onExitSchema&&this.visitor.onExitSchema(this.rootSchema)}crawlResource(){this.visitor.onEnterSchema&&this.visitor.onEnterSchema(this.rootSchema),this.crawlElementsImpl(this.rootSchema.elements,this.rootSchema.type),this.visitor.onExitSchema&&this.visitor.onExitSchema(this.rootSchema)}crawlElementsImpl(e,t){let n=gO(e);for(let e of n)this.crawlElementNode(e,t)}crawlElementNode(e,t){let n=t+`.`+e.key;this.visitor.onEnterElement&&this.visitor.onEnterElement(n,e.element,this.elementsContext);for(let n of e.children)this.crawlElementNode(n,t);wC(e.element?.slicing?.slices)&&this.crawlSlicingImpl(e.element.slicing,n),this.visitor.onExitElement&&this.visitor.onExitElement(n,e.element,this.elementsContext)}prepareSlices(e,t){let n=[];for(let t of e){if(!fO(t))continue;let e=t.type.find(e=>wC(e.profile))?.profile?.[0];if(wC(e)){let n=gS(e);n&&(t.typeSchema=n)}n.push(t)}return{...t,slices:n}}crawlSlicingImpl(e,t){let n=this.prepareSlices(e.slices,e);for(let e of n.slices)(this.sliceAllowList===void 0||this.sliceAllowList.includes(e))&&this.crawlSliceImpl(e,t,n)}crawlSliceImpl(e,t,n){let r=e.typeSchema;r&&this.visitor.onEnterSchema&&this.visitor.onEnterSchema(r),this.visitor.onEnterSlice&&this.visitor.onEnterSlice(t,e,n);let i,a=r?.elements??e.elements;wC(a)&&(i=sO({path:t,parentContext:this.elementsContext,elements:a})),i&&this.elementsContextStack.push(i),this.crawlElementsImpl(a,t),i&&this.elementsContextStack.pop(),this.visitor.onExitSlice&&this.visitor.onExitSlice(t,e,n),r&&this.visitor.onExitSchema&&this.visitor.onExitSchema(r)}};function gO(e){let t=[];function n(e,t){return t.startsWith(e+`.`)}function r(e,t){for(let i of e.children)if(n(i.key,t.key)){r(i,t);return}e.children.push(t)}let i=Object.entries(e);i.sort((e,t)=>e[0].localeCompare(t[0]));for(let[e,a]of i){let i={key:e,element:a,children:[]},o=!1;for(let a of t)if(n(a.key,e)){r(a,i),o=!0;break}o||t.push(i)}return t}var _O=`__sliceName`;function vO(e,t){let n=new bO(e,e.resourceType,`resource`);return new hO(t,n).crawlResource(),n.getDefaultValue()}function yO(e,t,n){for(let[r,i]of Object.entries(t)){if(n===void 0||n===r){wO(e,r,i,t);continue}let a=GC(n,r);a!==void 0&&wO(e,a,i,t)}return e}var bO=class{rootValue;schemaStack;valueStack;constructor(e,t,n){this.schemaStack=[],this.valueStack=[],this.rootValue=MC(e),this.valueStack.splice(0,this.valueStack.length,{type:n,path:t,values:[this.rootValue]})}get schema(){return this.schemaStack.at(-1)}get value(){return this.valueStack.at(-1)}onEnterSchema(e){this.schemaStack.push(e)}onExitSchema(){this.schemaStack.pop()}onEnterElement(e,t,n){let r=this.value.values,i=this.value.path,a=GC(i,e);if(a===void 0)throw Error(`Expected ${e} to be prefixed by ${i}`);let o=[];for(let e of r){if(e===void 0)continue;let r=GC(n.path,i),s=Array.isArray(e)?e:[e];for(let e of s){xO(e,a,t,n.elements,r),wO(e,a,t,n.elements);let i=CO(e,a,n.elements,r);i!==void 0&&o.push(i)}}this.valueStack.push({type:`element`,path:e,values:o})}onExitElement(e,t,n){if(!this.valueStack.pop())throw Error(`Expected value context to exist when exiting element`);let r=GC(this.value.path,e);if(r===void 0)throw Error(`Expected ${e} to be prefixed by ${this.value.path}`);let i=GC(n.path,this.value.path);for(let e of this.value.values){let a=CO(e,r,n.elements,i);if(Array.isArray(a))for(let e=a.length-1;e>=0;e--){let t=a[e];wC(t)||a.splice(e,1)}CC(a)&&SO(e,void 0,r,t)}}onEnterSlice(e,t,n){let r=this.value.values,i=[];for(let e of r)if(e!==void 0){let r=Array.isArray(e)?e:[e],a=this.getMatchingSliceValues(r,t,n);i.push(a)}this.valueStack.push({type:`slice`,path:e,values:i})}getMatchingSliceValues(e,t,n){let r=[];for(let i of e)(i[_O]??mO(i,[t],n.discriminator,this.schema.url))===t.name&&r.push(i);for(let n=r.length;n<t.min;n++)if(WC(t.type[0].code)){let t=Object.create(null);r.push(t),e.push(t)}return r}onExitSlice(){let e=this.valueStack.pop();if(!e)throw Error(`Expected value context to exist in onExitSlice`);for(let t of e.values)for(let e=t.length-1;e>=0;e--){let n=t[e];_O in n&&delete n[_O]}}getDefaultValue(){return this.rootValue}};function xO(e,t,n,r,i){let a=CO(e,t,r,i);n.min>0&&a===void 0&&WC(n.type[0].code)&&(n.isArray?SO(e,[Object.create(null)],t,n):SO(e,Object.create(null),t,n))}function SO(e,t,n,r){if(n.includes(`.`))throw Error(`key cannot be nested`);let i=n;if(n.includes(`[x]`)){let e=r.type[0].code;i=n.replace(`[x]`,UC(e))}t===void 0?delete e[i]:e[i]=t}function CO(e,t,n,r){let i=t.split(`.`),a=e,o;for(let e=0;e<i.length;e++){let t=i[e];if(t.includes(`[x]`)){let a=n[(r?r+`.`:``)+i.slice(0,e+1).join(`.`)].type[0].code;t=t.replace(`[x]`,UC(a))}if(e===i.length-1){o=Array.isArray(a)?a.map(e=>e[t]):a[t];continue}if(Array.isArray(a))a=a.map(e=>e[t]);else if(PC(a)){if(a[t]===void 0)return;a=a[t]}else return}return o}function wO(e,t,n,r){if(!(n.fixed||n.pattern))return e;if(Array.isArray(e))return e.map(e=>wO(e,t,n,r));e??=Object.create(null);let i=e,a=t.split(`.`),o=i;for(let e=0;e<a.length;e++){let t=a[e];if(t.includes(`[x]`)){let n=r[a.slice(0,e+1).join(`.`)].type[0].code;t=t.replace(`[x]`,UC(n))}if(e===a.length-1){let e=Array.isArray(o)?o:[o];for(let r of e)n.fixed?r[t]??=n.fixed.value:n.pattern&&(r[t]=TO(r[t],n.pattern.value))}else{if(!(t in o)){let n=a.slice(0,e+1).join(`.`);o[t]=r[n].isArray?[Object.create(null)]:Object.create(null)}o=o[t]}}return i}function TO(e,t){if(Array.isArray(t)&&(Array.isArray(e)||e===void 0))return(e?.length??0)>0?e:MC(t);if(PC(t)&&(PC(e)&&!Array.isArray(e)||e===void 0)){let n=MC(e)??Object.create(null);for(let e of Object.keys(t))n[e]=TO(n[e],t[e]);return n}return e}function EO(e){return e.match(/^\((.+)\)\.identifier$/)?.[1]}function DO(e,t){return new Qw(e,new lT(t,new eT(`identifier`)))}var OO={BOOLEAN:`BOOLEAN`,NUMBER:`NUMBER`,QUANTITY:`QUANTITY`,TEXT:`TEXT`,REFERENCE:`REFERENCE`,CANONICAL:`CANONICAL`,DATE:`DATE`,DATETIME:`DATETIME`,PERIOD:`PERIOD`,UUID:`UUID`};function kO(e,t){return Ww.types[e]?.searchParamsDetails?.[t.code]??jO(e,t)}function AO(e,t,n){let r=Ww.types[e];r||(r={},Ww.types[e]=r),r.searchParamsDetails||={},r.searchParamsDetails[t]=n}function jO(e,t){let n=t.code,r=t.expression,i=IO(e,r),a={elementDefinitions:[],propertyTypes:new Set,array:!1};for(let n of i){let r=zO(n),i=YC(()=>r.join(`.`));r.length===1&&r[0]instanceof wx&&r[0].operator!==`.`?a.propertyTypes.add(`boolean`):t.code.endsWith(`:identifier`)?a.propertyTypes.add(`Identifier`):i().endsWith(`extension.value.code`)||i().endsWith(`extension.value.coding.code`)?(a.array=!0,a.propertyTypes.clear(),a.propertyTypes.add(`code`)):MO(a,r,e,1),i().endsWith(`extension.valueDateTime`)&&(a.array=!1,a.propertyTypes.clear(),a.propertyTypes.add(`dateTime`))}let o;if(t.code.endsWith(`:identifier`)){let t=EO(r);if(t===void 0)throw Error(`Unexpected expression for derived identifier search parameter: ${r}`);o=DO(r,LO(e,t))}else o=LO(e,r);let s=a.elementDefinitions.map(e=>({...e,type:e.type?.filter(e=>a.propertyTypes.has(e.code))})).filter(e=>e.type&&e.type.length>0),c={type:FO(t,a.propertyTypes),elementDefinitions:s,parsedExpression:o,array:a.array,referenceTargetTypes:BO(t,s)};return AO(e,n,c),c}function MO(e,t,n,r){let i=t[r];if(i instanceof rT){e.propertyTypes.add(i.right.toString());return}if(i instanceof bT){NO(e,i);return}let a=i.toString(),o=Bw(n,a);if(!o)throw Error(`Element definition not found for ${n} ${a}`);let s=!1,c=r+1;c<t.length&&t[c]instanceof xT&&(s=!0,c++);let l=t[c];if(o.isArray&&!s&&(e.array=!0),c===t.length-1){if(l instanceof rT){e.elementDefinitions.push(o),e.propertyTypes.add(l.right.toString());return}if(l instanceof bT&&l.name===`ofType`){e.elementDefinitions.push(o),e.propertyTypes.add(l.args[0].toString());return}}if(c>=t.length){e.elementDefinitions.push(o);for(let t of o.type??aw)e.propertyTypes.add(t.code);return}for(let n of o.type??aw){let r=n.code;PO(r)&&(r=o.type[0].code),MO(e,t,r,c)}}function NO(e,t){if(t.name===`as`){e.propertyTypes.add(t.args[0].toString());return}if(t.name===`ofType`){e.propertyTypes.add(t.args[0].toString());return}if(t.name===`resolve`){e.propertyTypes.add(`string`);return}if(t.name===`where`&&t.args[0]instanceof hT){e.propertyTypes.add(t.args[0].right.toString());return}throw Error(`Unhandled FHIRPath function: ${t.name}`)}function PO(e){return e===`Element`||e===`BackboneElement`}function FO(e,t){switch(e.type){case`date`:return t.size===1&&t.has(Y.date)?OO.DATE:OO.DATETIME;case`number`:return OO.NUMBER;case`quantity`:return OO.QUANTITY;case`reference`:return t.has(Y.canonical)?OO.CANONICAL:OO.REFERENCE;case`token`:return t.size===1&&t.has(Y.boolean)?OO.BOOLEAN:OO.TEXT;default:return OO.TEXT}}function IO(e,t){let n=[];return RO(e,IT(t).child,n),n}function LO(e,t){let n=[],r=IT(t);if(RO(e,r.child,n),n.length===0)return r;let i=n[0];for(let e=1;e<n.length;e++)i=new uT(i,n[e]);return new Qw(`<original-not-available>`,i)}function RO(e,t,n){t instanceof uT?(RO(e,t.left,n),RO(e,t.right,n)):t.toString().includes(e+`.`)&&n.push(t)}function zO(e){return e instanceof rT||e instanceof xT?[zO(e.left),e].flat():e instanceof wx&&e.operator!==`.`?[e]:e instanceof lT?[zO(e.left),zO(e.right)].flat():e instanceof bT&&(e.name===`where`&&!(e.args[0]instanceof hT)||e.name===`last`)?[]:[e]}function BO(e,t){if(e.target?.length===1)return e.target;if(t){let e=new Set;for(let n of t)for(let t of n.type)if(!(t.code!==`Reference`||!t.targetProfile))for(let n of t.targetProfile){let t=n.split(`/`).at(-1);t&&t!==`Resource`&&e.add(t)}if(e.size>0)return Array.from(e)}}var VO=`https://meta.medplum.com/releases`,HO=new Map;function UO(e){let t=e;if(!t.tag_name?.startsWith(`v`))throw Error(`Manifest missing valid tag_name starting with a 'v' (eg. v5.1.15)`);let n=t.assets;if(!n?.length)throw Error(`Manifest missing assets list`);for(let e of n){if(!e.browser_download_url)throw Error(`Asset missing browser download URL`);if(!e.name)throw Error(`Asset missing name`)}}async function WO(e,t,n){let r=t?HO.get(t):void 0;if(!r){let i=t?`v${t}`:`latest`,a=new URL(`${VO}/${i}.json`);if(a.searchParams.set(`a`,e),a.searchParams.set(`c`,BD),n)for(let[e,t]of Object.entries(n))a.searchParams.set(e,t);let o=await fetch(a.toString());if(o.status!==200){let e;try{e=(await o.json()).message}catch(e){console.error(`Failed to parse message from body: ${Qx(e)}`)}throw Error(`Received status code ${o.status} while fetching manifest for version '${t??`latest`}'. Message: ${e}`)}let s=await o.json();UO(s),r=s,HO.set(r.tag_name.slice(1),r)}return r}async function GO(e){let t=await WO(e);if(!t.tag_name.startsWith(`v`))throw Error(`Invalid release name found. Release tag '${t.tag_name}' did not start with 'v'`);return t.tag_name.slice(1)}var KO=(0,b.createContext)(void 0);function qO(){return(0,b.useContext)(KO)}function Z(){return qO().medplum}function JO(){return qO().navigate}function YO(){return qO().profile}var XO=[`change`,`storageInitialized`,`storageInitFailed`,`profileRefreshing`,`profileRefreshed`];function ZO(e){let t=e.medplum,n=e.navigate??QO,[r,i]=(0,b.useState)({profile:t.getProfile(),loading:t.isLoading()});(0,b.useEffect)(()=>{function e(){i(e=>({...e,profile:t.getProfile(),loading:t.isLoading()}))}for(let n of XO)t.addEventListener(n,e);return()=>{for(let n of XO)t.removeEventListener(n,e)}},[t]);let a=(0,b.useMemo)(()=>({...r,medplum:t,navigate:n}),[r,t,n]);return(0,I.jsx)(KO.Provider,{value:a,children:e.children})}function QO(e){window.location.assign(e)}var $O=new Map,ek=e=>(0,b.useMemo)(()=>{if(!e)return;let t=e.split(`?`)[0];if(!t)return e;let n;try{n=new URLSearchParams(new URL(e).search)}catch{return e}if(!n.has(`Key-Pair-Id`)||!n.has(`Signature`))return e;let r=n.get(`Expires`);if(!r||r.length>13)return e;let i=$O.get(t);if(i){let e=new URLSearchParams(new URL(i).search).get(`Expires`);if(e&&Number.parseInt(e,10)*1e3-5e3>Date.now())return i}return $O.set(t,e),e},[e]),tk=3e3;function nk(e,t,n){let r=Z(),i=YO()?e:void 0,[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(n?.subscriptionProps),l=(0,b.useRef)(!1),u=(0,b.useRef)(void 0),d=(0,b.useRef)(void 0),f=(0,b.useRef)(void 0),p=(0,b.useRef)(t);p.current=t;let m=(0,b.useRef)(n?.onWebSocketOpen);m.current=n?.onWebSocketOpen;let h=(0,b.useRef)(n?.onWebSocketClose);h.current=n?.onWebSocketClose;let g=(0,b.useRef)(n?.onSubscriptionConnect);g.current=n?.onSubscriptionConnect;let _=(0,b.useRef)(n?.onSubscriptionDisconnect);_.current=n?.onSubscriptionDisconnect;let v=(0,b.useRef)(n?.onError);v.current=n?.onError,(0,b.useEffect)(()=>{EC(n?.subscriptionProps,s)||c(n?.subscriptionProps)},[s,n]),(0,b.useEffect)(()=>{u.current&&=(clearTimeout(u.current),void 0);let e=!1;return(d.current!==i||!EC(f.current,s))&&(e=!0),e&&d.current&&r.unsubscribeFromCriteria(d.current,f.current),d.current=i,f.current=s,e&&i?o(r.subscribeToCriteria(i,s)):i||o(void 0),()=>{u.current=setTimeout(()=>{o(void 0),i&&r.unsubscribeFromCriteria(i,s)},tk)}},[r,i,s]);let y=(0,b.useCallback)(e=>{p.current?.(e.payload)},[]),x=(0,b.useCallback)(()=>{m.current?.()},[]),S=(0,b.useCallback)(()=>{h.current?.()},[]),C=(0,b.useCallback)(e=>{g.current?.(e.payload.subscriptionId)},[]),w=(0,b.useCallback)(e=>{_.current?.(e.payload.subscriptionId)},[]),T=(0,b.useCallback)(e=>{v.current?.(e.payload)},[]);(0,b.useEffect)(()=>a?(l.current||=(a.addEventListener(`message`,y),a.addEventListener(`open`,x),a.addEventListener(`close`,S),a.addEventListener(`connect`,C),a.addEventListener(`disconnect`,w),a.addEventListener(`error`,T),!0),()=>{l.current=!1,a.removeEventListener(`message`,y),a.removeEventListener(`open`,x),a.removeEventListener(`close`,S),a.removeEventListener(`connect`,C),a.removeEventListener(`disconnect`,w),a.removeEventListener(`error`,T)}):()=>void 0,[a,y,x,S,C,w,T])}function rk(e){let t=Z(),{resourceType:n,countCriteria:r,subscriptionCriteria:i}=e,[a,o]=(0,b.useState)(0),s=(0,b.useCallback)(e=>{t.search(n,r,{cache:e}).then(e=>o(e.total)).catch(console.error)},[t,n,r]);return(0,b.useEffect)(()=>{s(`default`)},[s]),nk(i,()=>{s(`reload`)}),a}function ik(e,t){let n=Z(),[r,i]=(0,b.useState)(()=>ak(n,e)),a=(0,b.useCallback)(e=>{EC(e,r)||i(e)},[r]);return(0,b.useEffect)(()=>{let r=!0,i=ak(n,e);return!i&&Uw(e)?n.readReference(e).then(e=>{r&&a(e)}).catch(e=>{r&&(a(void 0),t&&t(Zx(e)))}):a(i),(()=>r=!1)},[n,e,a,t]),r}function ak(e,t){if(t){if(Hw(t))return t;if(Uw(t))return e.getCachedReference(t)}}var ok={group:`group`,display:`display`,question:`question`,boolean:`boolean`,decimal:`decimal`,integer:`integer`,date:`date`,dateTime:`dateTime`,time:`time`,string:`string`,text:`text`,url:`url`,choice:`choice`,openChoice:`open-choice`,attachment:`attachment`,reference:`reference`,quantity:`quantity`},sk=`${Ox}/fhir/StructureDefinition/questionnaire-itemControl`,ck=`${Ox}/fhir/StructureDefinition/questionnaire-referenceFilter`,lk=`${Ox}/fhir/StructureDefinition/questionnaire-referenceResource`,uk=`${Ox}/fhir/StructureDefinition/questionnaire-validationError`,dk=`${Ox}/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-enableWhenExpression`,fk=`${Ox}/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-calculatedExpression`,pk=`${Ox}/fhir/StructureDefinition/questionnaire-signatureRequired`,mk=`${Ox}/fhir/StructureDefinition/questionnaireresponse-signature`,hk=`${Ox}/fhir/StructureDefinition/questionnaire-hidden`;function gk(e){return e.type===`choice`||e.type===`open-choice`}function _k(e,t){return{...t,item:vk(e.item,t.item,t)}}function vk(e,t,n){if(!t)return t;let r=[];for(let i of t){let t=e?.find(e=>e.linkId===i.linkId);t&&!yk(t,n)||(t?.item&&i.item?r.push({...i,item:vk(t.item,i.item,n)}):r.push(i))}return r}function yk(e,t){if(vC(e,hk)?.valueBoolean===!0)return!1;let n=bk(e,t);return n===void 0?xk(e,t):n}function bk(e,t){let n=vC(e,dk);if(t&&n){let e=n.valueExpression?.expression;if(e){let n=jS(t);return MS(RT(e,[n],{"%resource":n}))}}}function xk(e,t){if(!e.enableWhen)return!0;let n=e.enableBehavior??`any`;for(let r of e.enableWhen){let e=Ok(t?.item,r.question);if(r.operator===`exists`&&!r.answerBoolean&&!e?.length){if(n===`any`)return!0;continue}let{anyMatch:i,allMatch:a}=Ak(r,e,n);if(n===`any`&&i)return!0;if(n===`all`&&!a)return!1}return n!==`any`}function Sk(e,t,n=t.item){for(let r of e){let e=n?.find(e=>e.linkId===r.linkId);e&&(Ck(t,r,e),r.item&&e.item&&Sk(r.item,t,e.item))}}function Ck(e,t,n){try{let r=Ek(t,e);if(!r)return;let i=Tk(t,r);if(!i)return;n.answer=[i]}catch(e){n.extension=[{url:uk,valueString:`Expression evaluation failed: ${Qx(e)}`}]}}var wk={[ok.boolean]:[Y.boolean],[ok.date]:[Y.date],[ok.dateTime]:[Y.dateTime],[ok.time]:[Y.time],[ok.url]:[Y.string,Y.uri,Y.url],[ok.attachment]:[Y.Attachment],[ok.reference]:[Y.Reference],[ok.quantity]:[Y.Quantity],[ok.decimal]:[Y.decimal,Y.integer],[ok.integer]:[Y.decimal,Y.integer]};function Tk(e,t){if(e.type){if(e.type===ok.choice||e.type===ok.openChoice)return{[`value${UC(t.type)}`]:t.value};if(e.type===ok.string||e.type===ok.text)return typeof t.value==`string`?{valueString:t.value}:void 0;if(wk[e.type]?.includes(t.type))return{[`value${UC(e.type)}`]:t.value}}}function Ek(e,t){if(!t)return;let n=vC(e,fk);if(n){let e=n.valueExpression?.expression;if(e){let n=jS(t),r=RT(e,[n],{"%resource":n});return r.length===0?void 0:r[0]}}}function Dk(e,t,n){let r=[];for(let i of e){let e=n.answerOption?.find(e=>ow(Vk(e))===i);if(e){let n=Vk(e);n&&r.push({[t]:n.value})}}return r}function Ok(e,t){for(let n of e??aw){if(n.linkId===t)return n.answer;if(n.item){let e=Ok(n.item,t);if(e)return e}}}function kk(e,t,n){if(n===`exists`)return!!e===t.value;if(e){let[{value:r}]=RT(`%actualAnswer ${n===`=`||n===`!=`?n?.replace(`=`,`~`):n} %expectedAnswer`,[e],{"%actualAnswer":e,"%expectedAnswer":t});return r}else return!1}function Ak(e,t,n){let r=t||[],i=Hk(e),a=!1,o=!0;for(let t of r){let r=Uk(t),{operator:s}=e;if(kk(r,i,s)?a=!0:o=!1,n===`any`&&a)break}return{anyMatch:a,allMatch:o}}function jk(e){let t=vC(e,lk);if(t){if(t.valueCode!==void 0)return[t.valueCode];if(t.valueCodeableConcept)return t.valueCodeableConcept?.coding?.map(e=>e.code)}}function Mk(e,t){let n=MC(e),r=vC(n,lk);return!t||t.length===0?(r&&(n.extension=n.extension?.filter(e=>e!==r)),n):(r||(n.extension??=[],r={url:lk},n.extension.push(r)),t.length===1?(r.valueCode=t[0],delete r.valueCodeableConcept):(r.valueCodeableConcept={coding:t.map(e=>({code:e}))},delete r.valueCode),n)}function Nk(e,t,n){let r=vC(e,ck);if(!r?.valueString)return;let i=r.valueString;t?.reference&&(i=i.replaceAll(`$subj`,t.reference)),n?.reference&&(i=i.replaceAll(`$encounter`,n.reference));let a={},o=i.split(`&`);for(let e of o){let[t,n]=JC(e,`=`,2);a[t]=n}return a}function Pk(e,t){return{resourceType:`QuestionnaireResponse`,questionnaire:e.url??oC(e),item:Fk(e.item,t?.item),status:`in-progress`}}function Fk(e,t){let n;for(let r of e??aw){if(r.type===ok.display)continue;let e=t?.filter(e=>e.linkId===r.linkId);if(e?.length)for(let t of e)t.id=t.id??Rk(),t.text=t.text??r.text,t.item=Fk(r.item,t.item),t.answer=zk(r,t),n=XC(n,t);else n=XC(n,Ik(r))}return n}function Ik(e){return{id:Rk(),linkId:e.linkId,text:e.text,item:Fk(e.item,void 0),answer:zk(e)}}var Lk=1;function Rk(){return`id-`+ Lk++}function zk(e,t){if(!(e.type===ok.display||e.type===ok.group)){if(t?.answer&&t.answer.length>0)return t.answer;if(e.initial&&e.initial.length>0)return e.initial.map(e=>({...e}));if(e.answerOption)return e.answerOption.filter(e=>e.initialSelected).map(e=>({...e,initialSelected:void 0}))}}function Bk(e){return LS({type:`QuestionnaireItemInitial`,value:e},`value`)}function Vk(e){return LS({type:`QuestionnaireItemAnswerOption`,value:e},`value`)}function Hk(e){return LS({type:`QuestionnaireItemEnableWhen`,value:e},`answer`)}function Uk(e){return LS({type:`QuestionnaireResponseItemAnswer`,value:e},`value`)}function Wk(e){let t=ik(e.questionnaire),n=ik(e.defaultValue),[,r]=(0,b.useReducer)(e=>e+1,0),i=(0,b.useRef)({activePage:0});if(!i.current.questionnaire&&t&&(i.current.questionnaire=t,i.current.pages=e.disablePagination?void 0:Gk(t)),t&&e.defaultValue&&n&&!i.current.questionnaireResponse&&(i.current.questionnaireResponse=Pk(t,n),p()),t&&!e.defaultValue&&!i.current.questionnaireResponse&&(i.current.questionnaireResponse=Pk(t),p()),!i.current.questionnaire||!i.current.questionnaireResponse)return{loading:!0};function a(e,t){let n=i.current.questionnaireResponse;for(let t of e)n=n?.item?.find(e=>t.id?e.id===t.id:e.linkId===t.linkId);return t&&(n=n?.item?.find(e=>e.linkId===t.linkId)),n}function o(){i.current.activePage=(i.current.activePage??0)+1,r()}function s(){i.current.activePage=(i.current.activePage??0)-1,r()}function c(e,t){let n=a(e);n&&(n.item??=[],n.item.push(Ik(t)),p())}function l(e,t){let n=a(e,t);n&&(n.answer??=[],n.answer.push({}),p())}function u(e,t,n){let r=a(e,t);r&&(r.answer=n,p())}function d(e){let t=i.current.questionnaireResponse;t&&(e?(t.extension=t.extension??[],t.extension=t.extension.filter(e=>e.url!==mk),t.extension.push({url:mk,valueSignature:e})):t.extension=t.extension?.filter(e=>e.url!==mk),p())}function f(){let e=i.current.questionnaire;if(e?.item){let t=i.current.questionnaireResponse;Sk(e.item,t)}}function p(){let t=i.current.questionnaireResponse,n=i.current.questionnaire;!t||!n||(f(),r(),e.onChange?.(_k(n,t)))}return{loading:!1,pagination:!!i.current.pages,questionnaire:i.current.questionnaire,questionnaireResponse:_k(i.current.questionnaire,i.current.questionnaireResponse),subject:e.subject,encounter:e.encounter,activePage:i.current.activePage,pages:i.current.pages,items:Kk(i.current.questionnaire,i.current.pages,i.current.activePage),responseItems:qk(i.current.questionnaireResponse,i.current.pages,i.current.activePage),onNextPage:o,onPrevPage:s,onAddGroup:c,onAddAnswer:l,onChangeAnswer:u,onChangeSignature:d}}function Gk(e){if(e?.item&&vC(e?.item?.[0],sk)?.valueCodeableConcept?.coding?.[0]?.code===`page`)return e.item.map((e,t)=>({linkId:e.linkId,title:e.text??`Page ${t+1}`,group:e}))}function Kk(e,t,n=0){return t&&e?.item?.[n]?[e.item[n]]:e.item??[]}function qk(e,t,n=0){return t&&e?.item?.[n]?[e.item[n]]:e.item??[]}function Jk(e,t,n={leading:!1}){let[r,i]=(0,b.useState)(e),a=(0,b.useRef)(!1),o=(0,b.useRef)(void 0),s=(0,b.useRef)(!1),c=(0,b.useCallback)(()=>window.clearTimeout(o.current),[]);return(0,b.useEffect)(()=>{a.current&&(!s.current&&n.leading?(s.current=!0,i(e),o.current=setTimeout(()=>{s.current=!1},t)):(c(),o.current=setTimeout(()=>{s.current=!1,i(e)},t)))},[e,n.leading,t,c]),(0,b.useEffect)(()=>(a.current=!0,c),[c]),[r,c]}var Yk=250;function Xk(e,t,n){return Qk(`searchOne`,e,t,n)}function Zk(e,t,n){return Qk(`searchResources`,e,t,n)}function Qk(e,t,n,r){let i=Z(),[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(),[l,u]=(0,b.useState)(),d=(0,b.useMemo)(()=>({resourceType:t,query:n}),[i.fhirSearchUrl(t,n).toString()]),f=r?.enabled??!0,[p]=Jk(d,r?.debounceMs??Yk,{leading:!0});return(0,b.useEffect)(()=>{if(!f)return()=>{};o(!0);let t=!0;return i[e](p.resourceType,p.query).then(e=>{t&&(o(!1),c(e),u(Lx))}).catch(e=>{t&&(o(!1),c(void 0),u(Zx(e)))}),()=>{t=!1}},[i,e,p,f]),[s,a,l]}function $k(e){let t=e.value;return t?(0,I.jsx)(I.Fragment,{children:cw(t,e.options)}):null}var eA=[`meta`,`implicitRules`,`contained`,`extension`,`modifierExtension`],tA=[`language`,`text`],nA=(0,b.createContext)({path:``,profileUrl:void 0,elements:Object.create(null),elementsByPath:Object.create(null),getExtendedProps:()=>({readonly:!1,hidden:!1}),accessPolicyResource:void 0,debugMode:!1,isDefaultContext:!0});nA.displayName=`ElementsContext`;var rA=[`extension`,`modifierExtension`],iA=[`id`,...eA].filter(e=>!rA.includes(e));function aA(e){return Object.entries(e).filter(([e,t])=>!wC(t.type)||t.max===0||t.path.toLowerCase().endsWith(`extension.url`)&&t.fixed||rA.includes(e)&&!wC(t.slicing?.slices)||iA.includes(e)?!1:!(tA.includes(e)&&t.path.split(`.`).length===2||e.includes(`.`)))}function oA(e,t){return e.line&&e.line.length>t?e.line[t]:``}function sA(e,t,n){let r=e.line||[];for(;r.length<=t;)r.push(``);return r[t]=n,{...e,line:TC(r)}}function cA(e){let[t,n]=(0,b.useState)(e.defaultValue||{}),{getExtendedProps:r}=(0,b.useContext)(nA),[i,a,o,s,c,l,u]=(0,b.useMemo)(()=>[`use`,`type`,`line1`,`line2`,`city`,`state`,`postalCode`].map(t=>r(e.path+`.`+t)),[r,e.path]);function d(r){n(e=>({...e,...r})),e.onChange&&e.onChange({...t,...r})}function f(e){d({use:e})}function p(e){d({type:e})}function m(e){d(sA(t,0,e))}function h(e){d(sA(t,1,e))}function g(e){d({city:e})}function _(e){d({state:e})}function v(e){d({postalCode:e})}return(0,I.jsxs)(V,{gap:`xs`,wrap:`nowrap`,grow:!0,children:[(0,I.jsx)(Eg,{disabled:e.disabled||i?.readonly,"data-testid":`address-use`,defaultValue:t.use,onChange:e=>f(e.currentTarget.value),data:[``,`home`,`work`,`temp`,`old`,`billing`]}),(0,I.jsx)(Eg,{disabled:e.disabled||a?.readonly,"data-testid":`address-type`,defaultValue:t.type,onChange:e=>p(e.currentTarget.value),data:[``,`postal`,`physical`,`both`]}),(0,I.jsx)(yb,{disabled:e.disabled||o?.readonly,placeholder:`Line 1`,defaultValue:oA(t,0),onChange:e=>m(e.currentTarget.value)}),(0,I.jsx)(yb,{disabled:e.disabled||s?.readonly,placeholder:`Line 2`,defaultValue:oA(t,1),onChange:e=>h(e.currentTarget.value)}),(0,I.jsx)(yb,{disabled:e.disabled||c?.readonly,placeholder:`City`,defaultValue:t.city,onChange:e=>g(e.currentTarget.value)}),(0,I.jsx)(yb,{disabled:e.disabled||l?.readonly,placeholder:`State`,defaultValue:t.state,onChange:e=>_(e.currentTarget.value)}),(0,I.jsx)(yb,{disabled:e.disabled||u?.readonly,placeholder:`Postal Code`,defaultValue:t.postalCode,onChange:e=>v(e.currentTarget.value)})]})}function lA(e){let t=YO(),[n,r]=(0,b.useState)(e.defaultValue||{});function i(n){let i=n?{text:n,authorReference:t&&aC(t),time:new Date().toISOString()}:{};r(i),e.onChange&&e.onChange(i)}return(0,I.jsx)(yb,{disabled:e.disabled,name:e.name,placeholder:`Annotation text`,defaultValue:n.text,onChange:e=>i(e.currentTarget.value)})}var uA={outline:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},filled:{xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`currentColor`,stroke:`none`}},Q=(e,t,n,r)=>{let i=(0,b.forwardRef)(({color:n=`currentColor`,size:i=24,stroke:a=2,title:o,className:s,children:c,...l},u)=>(0,b.createElement)(`svg`,{ref:u,...uA[e],width:i,height:i,className:[`tabler-icon`,`tabler-icon-${t}`,s].join(` `),...e===`filled`?{fill:n}:{strokeWidth:a,stroke:n},...l},[o&&(0,b.createElement)(`title`,{key:`svg-title`},o),...r.map(([e,t])=>(0,b.createElement)(e,t)),...Array.isArray(c)?c:[c]]));return i.displayName=`${n}`,i},dA=Q(`outline`,`adjustments-horizontal`,`AdjustmentsHorizontal`,[[`path`,{d:`M12 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-0`}],[`path`,{d:`M4 6l8 0`,key:`svg-1`}],[`path`,{d:`M16 6l4 0`,key:`svg-2`}],[`path`,{d:`M6 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-3`}],[`path`,{d:`M4 12l2 0`,key:`svg-4`}],[`path`,{d:`M10 12l10 0`,key:`svg-5`}],[`path`,{d:`M15 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-6`}],[`path`,{d:`M4 18l11 0`,key:`svg-7`}],[`path`,{d:`M19 18l1 0`,key:`svg-8`}]]),fA=Q(`outline`,`alert-circle`,`AlertCircle`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0`,key:`svg-0`}],[`path`,{d:`M12 8v4`,key:`svg-1`}],[`path`,{d:`M12 16h.01`,key:`svg-2`}]]),pA=Q(`outline`,`arrow-down`,`ArrowDown`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M18 13l-6 6`,key:`svg-1`}],[`path`,{d:`M6 13l6 6`,key:`svg-2`}]]),mA=Q(`outline`,`arrow-up`,`ArrowUp`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M18 11l-6 -6`,key:`svg-1`}],[`path`,{d:`M6 11l6 -6`,key:`svg-2`}]]),hA=Q(`outline`,`bleach-off`,`BleachOff`,[[`path`,{d:`M5 19h14m1.986 -1.977a2 2 0 0 0 -.146 -.773l-7.1 -12.25a2 2 0 0 0 -3.5 0l-.815 1.405m-1.488 2.568l-4.797 8.277a2 2 0 0 0 1.75 2.75`,key:`svg-0`}],[`path`,{d:`M3 3l18 18`,key:`svg-1`}]]),gA=Q(`outline`,`bleach`,`Bleach`,[[`path`,{d:`M5 19h14a2 2 0 0 0 1.84 -2.75l-7.1 -12.25a2 2 0 0 0 -3.5 0l-7.1 12.25a2 2 0 0 0 1.75 2.75`,key:`svg-0`}]]),_A=Q(`outline`,`bookmark`,`Bookmark`,[[`path`,{d:`M18 7v14l-6 -4l-6 4v-14a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4`,key:`svg-0`}]]),vA=Q(`outline`,`box-multiple`,`BoxMultiple`,[[`path`,{d:`M7 5a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2l0 -10`,key:`svg-0`}],[`path`,{d:`M17 17v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2h2`,key:`svg-1`}]]),yA=Q(`outline`,`brackets-contain`,`BracketsContain`,[[`path`,{d:`M7 4h-4v16h4`,key:`svg-0`}],[`path`,{d:`M17 4h4v16h-4`,key:`svg-1`}],[`path`,{d:`M8 16h.01`,key:`svg-2`}],[`path`,{d:`M12 16h.01`,key:`svg-3`}],[`path`,{d:`M16 16h.01`,key:`svg-4`}]]),bA=Q(`outline`,`brand-asana`,`BrandAsana`,[[`path`,{d:`M9 7a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-0`}],[`path`,{d:`M14 16a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-1`}],[`path`,{d:`M4 16a3 3 0 1 0 6 0a3 3 0 1 0 -6 0`,key:`svg-2`}]]),xA=Q(`outline`,`briefcase`,`Briefcase`,[[`path`,{d:`M3 9a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v9a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2l0 -9`,key:`svg-0`}],[`path`,{d:`M8 7v-2a2 2 0 0 1 2 -2h4a2 2 0 0 1 2 2v2`,key:`svg-1`}],[`path`,{d:`M12 12l0 .01`,key:`svg-2`}],[`path`,{d:`M3 13a20 20 0 0 0 18 0`,key:`svg-3`}]]),SA=Q(`outline`,`bucket-off`,`BucketOff`,[[`path`,{d:`M5.029 5.036c-.655 .58 -1.029 1.25 -1.029 1.964c0 2.033 3.033 3.712 6.96 3.967m3.788 -.21c3.064 -.559 5.252 -2.029 5.252 -3.757c0 -2.21 -3.582 -4 -8 -4c-1.605 0 -3.1 .236 -4.352 .643`,key:`svg-0`}],[`path`,{d:`M4 7c0 .664 .088 1.324 .263 1.965l2.737 10.035c.5 1.5 2.239 2 5 2s4.5 -.5 5 -2c.1 -.3 .252 -.812 .457 -1.535m.862 -3.146c.262 -.975 .735 -2.76 1.418 -5.354a7.45 7.45 0 0 0 .263 -1.965`,key:`svg-1`}],[`path`,{d:`M3 3l18 18`,key:`svg-2`}]]),CA=Q(`outline`,`bucket`,`Bucket`,[[`path`,{d:`M4 7a8 4 0 1 0 16 0a8 4 0 1 0 -16 0`,key:`svg-0`}],[`path`,{d:`M4 7c0 .664 .088 1.324 .263 1.965l2.737 10.035c.5 1.5 2.239 2 5 2s4.5 -.5 5 -2c.333 -1 1.246 -4.345 2.737 -10.035a7.45 7.45 0 0 0 .263 -1.965`,key:`svg-1`}]]),wA=Q(`outline`,`building`,`Building`,[[`path`,{d:`M3 21l18 0`,key:`svg-0`}],[`path`,{d:`M9 8l1 0`,key:`svg-1`}],[`path`,{d:`M9 12l1 0`,key:`svg-2`}],[`path`,{d:`M9 16l1 0`,key:`svg-3`}],[`path`,{d:`M14 8l1 0`,key:`svg-4`}],[`path`,{d:`M14 12l1 0`,key:`svg-5`}],[`path`,{d:`M14 16l1 0`,key:`svg-6`}],[`path`,{d:`M5 21v-16a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v16`,key:`svg-7`}]]),TA=Q(`outline`,`calendar`,`Calendar`,[[`path`,{d:`M4 7a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12`,key:`svg-0`}],[`path`,{d:`M16 3v4`,key:`svg-1`}],[`path`,{d:`M8 3v4`,key:`svg-2`}],[`path`,{d:`M4 11h16`,key:`svg-3`}],[`path`,{d:`M11 15h1`,key:`svg-4`}],[`path`,{d:`M12 15v3`,key:`svg-5`}]]),EA=Q(`outline`,`check`,`Check`,[[`path`,{d:`M5 12l5 5l10 -10`,key:`svg-0`}]]),DA=Q(`outline`,`checkbox`,`Checkbox`,[[`path`,{d:`M9 11l3 3l8 -8`,key:`svg-0`}],[`path`,{d:`M20 12v6a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h9`,key:`svg-1`}]]),OA=Q(`outline`,`chevron-down`,`ChevronDown`,[[`path`,{d:`M6 9l6 6l6 -6`,key:`svg-0`}]]),kA=Q(`outline`,`circle-check`,`CircleCheck`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`,key:`svg-0`}],[`path`,{d:`M9 12l2 2l4 -4`,key:`svg-1`}]]),AA=Q(`outline`,`circle-minus`,`CircleMinus`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0`,key:`svg-0`}],[`path`,{d:`M9 12l6 0`,key:`svg-1`}]]),jA=Q(`outline`,`circle-plus`,`CirclePlus`,[[`path`,{d:`M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0`,key:`svg-0`}],[`path`,{d:`M9 12h6`,key:`svg-1`}],[`path`,{d:`M12 9v6`,key:`svg-2`}]]),MA=Q(`outline`,`cloud-upload`,`CloudUpload`,[[`path`,{d:`M7 18a4.6 4.4 0 0 1 0 -9a5 4.5 0 0 1 11 2h1a3.5 3.5 0 0 1 0 7h-1`,key:`svg-0`}],[`path`,{d:`M9 15l3 -3l3 3`,key:`svg-1`}],[`path`,{d:`M12 12l0 9`,key:`svg-2`}]]),NA=Q(`outline`,`columns`,`Columns`,[[`path`,{d:`M4 6l5.5 0`,key:`svg-0`}],[`path`,{d:`M4 10l5.5 0`,key:`svg-1`}],[`path`,{d:`M4 14l5.5 0`,key:`svg-2`}],[`path`,{d:`M4 18l5.5 0`,key:`svg-3`}],[`path`,{d:`M14.5 6l5.5 0`,key:`svg-4`}],[`path`,{d:`M14.5 10l5.5 0`,key:`svg-5`}],[`path`,{d:`M14.5 14l5.5 0`,key:`svg-6`}],[`path`,{d:`M14.5 18l5.5 0`,key:`svg-7`}]]),PA=Q(`outline`,`copy`,`Copy`,[[`path`,{d:`M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667l0 -8.666`,key:`svg-0`}],[`path`,{d:`M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1`,key:`svg-1`}]]),FA=Q(`outline`,`currency-dollar`,`CurrencyDollar`,[[`path`,{d:`M16.7 8a3 3 0 0 0 -2.7 -2h-4a3 3 0 0 0 0 6h4a3 3 0 0 1 0 6h-4a3 3 0 0 1 -2.7 -2`,key:`svg-0`}],[`path`,{d:`M12 3v3m0 12v3`,key:`svg-1`}]]),IA=Q(`outline`,`database`,`Database`,[[`path`,{d:`M4 6a8 3 0 1 0 16 0a8 3 0 1 0 -16 0`,key:`svg-0`}],[`path`,{d:`M4 6v6a8 3 0 0 0 16 0v-6`,key:`svg-1`}],[`path`,{d:`M4 12v6a8 3 0 0 0 16 0v-6`,key:`svg-2`}]]),LA=Q(`outline`,`device-desktop`,`DeviceDesktop`,[[`path`,{d:`M3 5a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10`,key:`svg-0`}],[`path`,{d:`M7 20h10`,key:`svg-1`}],[`path`,{d:`M9 16v4`,key:`svg-2`}],[`path`,{d:`M15 16v4`,key:`svg-3`}]]),RA=Q(`outline`,`device-floppy`,`DeviceFloppy`,[[`path`,{d:`M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2`,key:`svg-0`}],[`path`,{d:`M10 14a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-1`}],[`path`,{d:`M14 4l0 4l-6 0l0 -4`,key:`svg-2`}]]),zA=Q(`outline`,`dots`,`Dots`,[[`path`,{d:`M4 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-0`}],[`path`,{d:`M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-1`}],[`path`,{d:`M18 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-2`}]]),BA=Q(`outline`,`edit`,`Edit`,[[`path`,{d:`M7 7h-1a2 2 0 0 0 -2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2 -2v-1`,key:`svg-0`}],[`path`,{d:`M20.385 6.585a2.1 2.1 0 0 0 -2.97 -2.97l-8.415 8.385v3h3l8.385 -8.415`,key:`svg-1`}],[`path`,{d:`M16 5l3 3`,key:`svg-2`}]]),VA=Q(`outline`,`equal-not`,`EqualNot`,[[`path`,{d:`M5 10h14`,key:`svg-0`}],[`path`,{d:`M5 14h14`,key:`svg-1`}],[`path`,{d:`M5 19l14 -14`,key:`svg-2`}]]),HA=Q(`outline`,`equal`,`Equal`,[[`path`,{d:`M5 10h14`,key:`svg-0`}],[`path`,{d:`M5 14h14`,key:`svg-1`}]]),UA=Q(`outline`,`eye-off`,`EyeOff`,[[`path`,{d:`M10.585 10.587a2 2 0 0 0 2.829 2.828`,key:`svg-0`}],[`path`,{d:`M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87`,key:`svg-1`}],[`path`,{d:`M3 3l18 18`,key:`svg-2`}]]),WA=Q(`outline`,`eye`,`Eye`,[[`path`,{d:`M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0`,key:`svg-0`}],[`path`,{d:`M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6`,key:`svg-1`}]]),GA=Q(`outline`,`file-alert`,`FileAlert`,[[`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`,key:`svg-0`}],[`path`,{d:`M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2`,key:`svg-1`}],[`path`,{d:`M12 17l.01 0`,key:`svg-2`}],[`path`,{d:`M12 11l0 3`,key:`svg-3`}]]),KA=Q(`outline`,`file-plus`,`FilePlus`,[[`path`,{d:`M14 3v4a1 1 0 0 0 1 1h4`,key:`svg-0`}],[`path`,{d:`M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2`,key:`svg-1`}],[`path`,{d:`M12 11l0 6`,key:`svg-2`}],[`path`,{d:`M9 14l6 0`,key:`svg-3`}]]),qA=Q(`outline`,`filter`,`Filter`,[[`path`,{d:`M4 4h16v2.172a2 2 0 0 1 -.586 1.414l-4.414 4.414v7l-6 2v-8.5l-4.48 -4.928a2 2 0 0 1 -.52 -1.345v-2.227`,key:`svg-0`}]]),JA=Q(`outline`,`folder`,`Folder`,[[`path`,{d:`M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2`,key:`svg-0`}]]),YA=Q(`outline`,`forms`,`Forms`,[[`path`,{d:`M12 3a3 3 0 0 0 -3 3v12a3 3 0 0 0 3 3`,key:`svg-0`}],[`path`,{d:`M6 3a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3`,key:`svg-1`}],[`path`,{d:`M13 7h7a1 1 0 0 1 1 1v8a1 1 0 0 1 -1 1h-7`,key:`svg-2`}],[`path`,{d:`M5 7h-1a1 1 0 0 0 -1 1v8a1 1 0 0 0 1 1h1`,key:`svg-3`}],[`path`,{d:`M17 12h.01`,key:`svg-4`}],[`path`,{d:`M13 12h.01`,key:`svg-5`}]]),XA=Q(`outline`,`id`,`Id`,[[`path`,{d:`M3 7a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v10a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3l0 -10`,key:`svg-0`}],[`path`,{d:`M7 10a2 2 0 1 0 4 0a2 2 0 1 0 -4 0`,key:`svg-1`}],[`path`,{d:`M15 8l2 0`,key:`svg-2`}],[`path`,{d:`M15 12l2 0`,key:`svg-3`}],[`path`,{d:`M7 16l10 0`,key:`svg-4`}]]),ZA=Q(`outline`,`layout-sidebar`,`LayoutSidebar`,[[`path`,{d:`M4 6a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2l0 -12`,key:`svg-0`}],[`path`,{d:`M9 4l0 16`,key:`svg-1`}]]),QA=Q(`outline`,`list-details`,`ListDetails`,[[`path`,{d:`M13 5h8`,key:`svg-0`}],[`path`,{d:`M13 9h5`,key:`svg-1`}],[`path`,{d:`M13 15h8`,key:`svg-2`}],[`path`,{d:`M13 19h5`,key:`svg-3`}],[`path`,{d:`M3 5a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4`,key:`svg-4`}],[`path`,{d:`M3 15a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1l0 -4`,key:`svg-5`}]]),$A=Q(`outline`,`lock-access`,`LockAccess`,[[`path`,{d:`M4 8v-2a2 2 0 0 1 2 -2h2`,key:`svg-0`}],[`path`,{d:`M4 16v2a2 2 0 0 0 2 2h2`,key:`svg-1`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v2`,key:`svg-2`}],[`path`,{d:`M16 20h2a2 2 0 0 0 2 -2v-2`,key:`svg-3`}],[`path`,{d:`M8 12a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v3a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1l0 -3`,key:`svg-4`}],[`path`,{d:`M10 11v-2a2 2 0 1 1 4 0v2`,key:`svg-5`}]]),ej=Q(`outline`,`lock`,`Lock`,[[`path`,{d:`M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-6`,key:`svg-0`}],[`path`,{d:`M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0`,key:`svg-1`}],[`path`,{d:`M8 11v-4a4 4 0 1 1 8 0v4`,key:`svg-2`}]]),tj=Q(`outline`,`logout`,`Logout`,[[`path`,{d:`M14 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2`,key:`svg-0`}],[`path`,{d:`M9 12h12l-3 -3`,key:`svg-1`}],[`path`,{d:`M18 15l3 -3`,key:`svg-2`}]]),nj=Q(`outline`,`math-greater`,`MathGreater`,[[`path`,{d:`M5 18l14 -6l-14 -6`,key:`svg-0`}]]),rj=Q(`outline`,`math-lower`,`MathLower`,[[`path`,{d:`M19 18l-14 -6l14 -6`,key:`svg-0`}]]),ij=Q(`outline`,`message`,`Message`,[[`path`,{d:`M8 9h8`,key:`svg-0`}],[`path`,{d:`M8 13h6`,key:`svg-1`}],[`path`,{d:`M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3h12`,key:`svg-2`}]]),aj=Q(`outline`,`microscope`,`Microscope`,[[`path`,{d:`M5 21h14`,key:`svg-0`}],[`path`,{d:`M6 18h2`,key:`svg-1`}],[`path`,{d:`M7 18v3`,key:`svg-2`}],[`path`,{d:`M9 11l3 3l6 -6l-3 -3l-6 6`,key:`svg-3`}],[`path`,{d:`M10.5 12.5l-1.5 1.5`,key:`svg-4`}],[`path`,{d:`M17 3l3 3`,key:`svg-5`}],[`path`,{d:`M12 21a6 6 0 0 0 3.715 -10.712`,key:`svg-6`}]]),oj=Q(`outline`,`minus`,`Minus`,[[`path`,{d:`M5 12l14 0`,key:`svg-0`}]]),sj=Q(`outline`,`moon`,`Moon`,[[`path`,{d:`M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454l0 .008`,key:`svg-0`}]]),cj=Q(`outline`,`packages`,`Packages`,[[`path`,{d:`M7 16.5l-5 -3l5 -3l5 3v5.5l-5 3l0 -5.5`,key:`svg-0`}],[`path`,{d:`M2 13.5v5.5l5 3`,key:`svg-1`}],[`path`,{d:`M7 16.545l5 -3.03`,key:`svg-2`}],[`path`,{d:`M17 16.5l-5 -3l5 -3l5 3v5.5l-5 3l0 -5.5`,key:`svg-3`}],[`path`,{d:`M12 19l5 3`,key:`svg-4`}],[`path`,{d:`M17 16.5l5 -3`,key:`svg-5`}],[`path`,{d:`M12 13.5v-5.5l-5 -3l5 -3l5 3v5.5`,key:`svg-6`}],[`path`,{d:`M7 5.03v5.455`,key:`svg-7`}],[`path`,{d:`M12 8l5 -3`,key:`svg-8`}]]),lj=Q(`outline`,`palette`,`Palette`,[[`path`,{d:`M12 21a9 9 0 0 1 0 -18c4.97 0 9 3.582 9 8c0 1.06 -.474 2.078 -1.318 2.828c-.844 .75 -1.989 1.172 -3.182 1.172h-2.5a2 2 0 0 0 -1 3.75a1.3 1.3 0 0 1 -1 2.25`,key:`svg-0`}],[`path`,{d:`M7.5 10.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-1`}],[`path`,{d:`M11.5 7.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-2`}],[`path`,{d:`M15.5 10.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`,key:`svg-3`}]]),uj=Q(`outline`,`pencil`,`Pencil`,[[`path`,{d:`M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4`,key:`svg-0`}],[`path`,{d:`M13.5 6.5l4 4`,key:`svg-1`}]]),dj=Q(`outline`,`pin`,`Pin`,[[`path`,{d:`M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4`,key:`svg-0`}],[`path`,{d:`M9 15l-4.5 4.5`,key:`svg-1`}],[`path`,{d:`M14.5 4l5.5 5.5`,key:`svg-2`}]]),fj=Q(`outline`,`pinned-off`,`PinnedOff`,[[`path`,{d:`M3 3l18 18`,key:`svg-0`}],[`path`,{d:`M15 4.5l-3.249 3.249m-2.57 1.433l-2.181 .818l-1.5 1.5l7 7l1.5 -1.5l.82 -2.186m1.43 -2.563l3.25 -3.251`,key:`svg-1`}],[`path`,{d:`M9 15l-4.5 4.5`,key:`svg-2`}],[`path`,{d:`M14.5 4l5.5 5.5`,key:`svg-3`}]]),pj=Q(`outline`,`player-play`,`PlayerPlay`,[[`path`,{d:`M7 4v16l13 -8l-13 -8`,key:`svg-0`}]]),mj=Q(`outline`,`plus`,`Plus`,[[`path`,{d:`M12 5l0 14`,key:`svg-0`}],[`path`,{d:`M5 12l14 0`,key:`svg-1`}]]),hj=Q(`outline`,`receipt`,`Receipt`,[[`path`,{d:`M5 21v-16a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v16l-3 -2l-2 2l-2 -2l-2 2l-2 -2l-3 2m4 -14h6m-6 4h6m-2 4h2`,key:`svg-0`}]]),gj=Q(`outline`,`refresh`,`Refresh`,[[`path`,{d:`M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4`,key:`svg-0`}],[`path`,{d:`M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4`,key:`svg-1`}]]),_j=Q(`outline`,`repeat`,`Repeat`,[[`path`,{d:`M4 12v-3a3 3 0 0 1 3 -3h13m-3 -3l3 3l-3 3`,key:`svg-0`}],[`path`,{d:`M20 12v3a3 3 0 0 1 -3 3h-13m3 3l-3 -3l3 -3`,key:`svg-1`}]]),vj=Q(`outline`,`report-medical`,`ReportMedical`,[[`path`,{d:`M9 5h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2h-2`,key:`svg-0`}],[`path`,{d:`M9 5a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2`,key:`svg-1`}],[`path`,{d:`M10 14l4 0`,key:`svg-2`}],[`path`,{d:`M12 12l0 4`,key:`svg-3`}]]),yj=Q(`outline`,`router`,`Router`,[[`path`,{d:`M3 15a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2l0 -4`,key:`svg-0`}],[`path`,{d:`M17 17l0 .01`,key:`svg-1`}],[`path`,{d:`M13 17l0 .01`,key:`svg-2`}],[`path`,{d:`M15 13l0 -2`,key:`svg-3`}],[`path`,{d:`M11.75 8.75a4 4 0 0 1 6.5 0`,key:`svg-4`}],[`path`,{d:`M8.5 6.5a8 8 0 0 1 13 0`,key:`svg-5`}]]),bj=Q(`outline`,`search`,`Search`,[[`path`,{d:`M3 10a7 7 0 1 0 14 0a7 7 0 1 0 -14 0`,key:`svg-0`}],[`path`,{d:`M21 21l-6 -6`,key:`svg-1`}]]),xj=Q(`outline`,`settings`,`Settings`,[[`path`,{d:`M10.325 4.317c.426 -1.756 2.924 -1.756 3.35 0a1.724 1.724 0 0 0 2.573 1.066c1.543 -.94 3.31 .826 2.37 2.37a1.724 1.724 0 0 0 1.065 2.572c1.756 .426 1.756 2.924 0 3.35a1.724 1.724 0 0 0 -1.066 2.573c.94 1.543 -.826 3.31 -2.37 2.37a1.724 1.724 0 0 0 -2.572 1.065c-.426 1.756 -2.924 1.756 -3.35 0a1.724 1.724 0 0 0 -2.573 -1.066c-1.543 .94 -3.31 -.826 -2.37 -2.37a1.724 1.724 0 0 0 -1.065 -2.572c-1.756 -.426 -1.756 -2.924 0 -3.35a1.724 1.724 0 0 0 1.066 -2.573c-.94 -1.543 .826 -3.31 2.37 -2.37c1 .608 2.296 .07 2.572 -1.065`,key:`svg-0`}],[`path`,{d:`M9 12a3 3 0 1 0 6 0a3 3 0 0 0 -6 0`,key:`svg-1`}]]),Sj=Q(`outline`,`sort-ascending`,`SortAscending`,[[`path`,{d:`M4 6l7 0`,key:`svg-0`}],[`path`,{d:`M4 12l7 0`,key:`svg-1`}],[`path`,{d:`M4 18l9 0`,key:`svg-2`}],[`path`,{d:`M15 9l3 -3l3 3`,key:`svg-3`}],[`path`,{d:`M18 6l0 12`,key:`svg-4`}]]),Cj=Q(`outline`,`sort-descending`,`SortDescending`,[[`path`,{d:`M4 6l9 0`,key:`svg-0`}],[`path`,{d:`M4 12l7 0`,key:`svg-1`}],[`path`,{d:`M4 18l7 0`,key:`svg-2`}],[`path`,{d:`M15 15l3 3l3 -3`,key:`svg-3`}],[`path`,{d:`M18 6l0 12`,key:`svg-4`}]]),wj=Q(`outline`,`square`,`Square`,[[`path`,{d:`M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14`,key:`svg-0`}]]),Tj=Q(`outline`,`star`,`Star`,[[`path`,{d:`M12 17.75l-6.172 3.245l1.179 -6.873l-5 -4.867l6.9 -1l3.086 -6.253l3.086 6.253l6.9 1l-5 4.867l1.179 6.873l-6.158 -3.245`,key:`svg-0`}]]),Ej=Q(`outline`,`sun-high`,`SunHigh`,[[`path`,{d:`M14.828 14.828a4 4 0 1 0 -5.656 -5.656a4 4 0 0 0 5.656 5.656`,key:`svg-0`}],[`path`,{d:`M6.343 17.657l-1.414 1.414`,key:`svg-1`}],[`path`,{d:`M6.343 6.343l-1.414 -1.414`,key:`svg-2`}],[`path`,{d:`M17.657 6.343l1.414 -1.414`,key:`svg-3`}],[`path`,{d:`M17.657 17.657l1.414 1.414`,key:`svg-4`}],[`path`,{d:`M4 12h-2`,key:`svg-5`}],[`path`,{d:`M12 4v-2`,key:`svg-6`}],[`path`,{d:`M20 12h2`,key:`svg-7`}],[`path`,{d:`M12 20v2`,key:`svg-8`}]]),Dj=Q(`outline`,`switch-horizontal`,`SwitchHorizontal`,[[`path`,{d:`M16 3l4 4l-4 4`,key:`svg-0`}],[`path`,{d:`M10 7l10 0`,key:`svg-1`}],[`path`,{d:`M8 13l-4 4l4 4`,key:`svg-2`}],[`path`,{d:`M4 17l9 0`,key:`svg-3`}]]),Oj=Q(`outline`,`table-export`,`TableExport`,[[`path`,{d:`M12.5 21h-7.5a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v7.5`,key:`svg-0`}],[`path`,{d:`M3 10h18`,key:`svg-1`}],[`path`,{d:`M10 3v18`,key:`svg-2`}],[`path`,{d:`M16 19h6`,key:`svg-3`}],[`path`,{d:`M19 16l3 3l-3 3`,key:`svg-4`}]]),kj=Q(`outline`,`table`,`Table`,[[`path`,{d:`M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14`,key:`svg-0`}],[`path`,{d:`M3 10h18`,key:`svg-1`}],[`path`,{d:`M10 3v18`,key:`svg-2`}]]),Aj=Q(`outline`,`text-recognition`,`TextRecognition`,[[`path`,{d:`M4 8v-2a2 2 0 0 1 2 -2h2`,key:`svg-0`}],[`path`,{d:`M4 16v2a2 2 0 0 0 2 2h2`,key:`svg-1`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v2`,key:`svg-2`}],[`path`,{d:`M16 20h2a2 2 0 0 0 2 -2v-2`,key:`svg-3`}],[`path`,{d:`M12 16v-7`,key:`svg-4`}],[`path`,{d:`M9 9h6`,key:`svg-5`}]]),jj=Q(`outline`,`trash`,`Trash`,[[`path`,{d:`M4 7l16 0`,key:`svg-0`}],[`path`,{d:`M10 11l0 6`,key:`svg-1`}],[`path`,{d:`M14 11l0 6`,key:`svg-2`}],[`path`,{d:`M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12`,key:`svg-3`}],[`path`,{d:`M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3`,key:`svg-4`}]]),Mj=Q(`outline`,`upload`,`Upload`,[[`path`,{d:`M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2`,key:`svg-0`}],[`path`,{d:`M7 9l5 -5l5 5`,key:`svg-1`}],[`path`,{d:`M12 4l0 12`,key:`svg-2`}]]),Nj=Q(`outline`,`user-plus`,`UserPlus`,[[`path`,{d:`M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0`,key:`svg-0`}],[`path`,{d:`M16 19h6`,key:`svg-1`}],[`path`,{d:`M19 16v6`,key:`svg-2`}],[`path`,{d:`M6 21v-2a4 4 0 0 1 4 -4h4`,key:`svg-3`}]]),Pj=Q(`outline`,`webhook`,`Webhook`,[[`path`,{d:`M4.876 13.61a4 4 0 1 0 6.124 3.39h6`,key:`svg-0`}],[`path`,{d:`M15.066 20.502a4 4 0 1 0 1.934 -7.502c-.706 0 -1.424 .179 -2 .5l-3 -5.5`,key:`svg-1`}],[`path`,{d:`M16 8a4 4 0 1 0 -8 0c0 1.506 .77 2.818 2 3.5l-3 5.5`,key:`svg-2`}]]),Fj=Q(`outline`,`x`,`X`,[[`path`,{d:`M18 6l-12 12`,key:`svg-0`}],[`path`,{d:`M6 6l12 12`,key:`svg-1`}]]),Ij=Q(`filled`,`circle-filled`,`CircleFilled`,[[`path`,{d:`M7 3.34a10 10 0 1 1 -4.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 4.995 -8.336z`,key:`svg-0`}]]),Lj=class extends b.Component{state;constructor(e){super(e),this.state={lastLocation:LE.getLocation()}}static getDerivedStateFromError(e){return{error:e,lastLocation:LE.getLocation()}}componentDidUpdate(e,t){LE.getLocation()!==this.state.lastLocation&&this.setState({lastLocation:LE.getLocation(),error:void 0})}shouldComponentUpdate(e,t){return!!(this.props.children!==e.children||t.error&&!this.state.error||this.state.lastLocation!==LE.getLocation())}componentDidCatch(e,t){console.error(`Uncaught error:`,e,t)}render(){return this.state.error?(0,I.jsx)(Dd,{icon:(0,I.jsx)(fA,{size:16}),title:`Something went wrong`,color:`red`,children:Qx(this.state.error)}):this.props.children}};function Rj(){return(0,I.jsx)(Kp,{style:{width:`100%`,height:`100vh`},children:(0,I.jsx)(cu,{})})}var zj={main:`_main_6f7o5_1`};function Bj(e){e.preventDefault(),e.stopPropagation()}function Vj(e){return e.button===1||e.ctrlKey||e.metaKey}function Hj(e){if(Uj(e))return!0;if(e instanceof HTMLTableCellElement){let t=e.children;if(t.length===1&&Uj(t[0]))return!0}return!1}function Uj(e){return e instanceof HTMLInputElement&&e.type===`checkbox`}async function Wj(e,t){return new Promise((n,r)=>{let i=new MessageChannel;i.port1.onmessage=({data:e})=>{i.port1.close(),e.error?r(e.error):n(e.result)},e.contentWindow?.postMessage(t,new URL(e.src).origin,[i.port2])})}function Gj(e,t){let n=new Blob([e],{type:ZE.JSON}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${t??new Date().toISOString().replaceAll(/\D/g,``)}.json`,document.body.appendChild(i),i.click(),URL.revokeObjectURL(r)}function Kj(e){let t=JO(),{to:n,suffix:r,label:i,onClick:a,children:o,...s}=e,c=qj(n);return r&&(c+=`/`+r),(0,I.jsx)(Pd,{href:c,"aria-label":i,onAuxClick:e=>{e.stopPropagation()},onClick:e=>{e.stopPropagation(),a?(e.preventDefault(),a(e)):n&&(Vj(e)||(e.preventDefault(),t(c)))},...s,children:o})}function qj(e){if(e){if(typeof e==`string`)return Jj(e);if(Hw(e))return Yj(e);if(Uw(e))return Xj(e)}return`#`}function Jj(e){return e.startsWith(`http://`)||e.startsWith(`https://`)||e.startsWith(`/`)?e:`/`+e}function Yj(e){return`/${e.resourceType}/${e.id}`}function Xj(e){return`/${e.reference}`}function Zj(e){let t=e.split(` `).filter(Boolean);return t.length>1?t[0][0]+t.at(-1)?.at(0):t.length===1?t[0][0]:``}function Qj(e){let t=ik(e.value),n=t?uC(t):e.alt??``,r=Zj(n),i=ek((t&&pC(t))??e.src??void 0),a=e.radius??`xl`,o={...e,value:void 0,link:void 0};return e.link?(0,I.jsx)(Kj,{to:t,children:(0,I.jsx)(kp,{src:i,alt:n,radius:a,...o,children:r})}):(0,I.jsx)(kp,{src:i,alt:n,radius:a,...o,children:r})}var $j={logoButton:`_logoButton_799cf_1`,user:`_user_799cf_11`,userName:`_userName_799cf_25`},eM={iconBox:`_iconBox_1mfdi_1`,interactive:`_interactive_1mfdi_12`};function tM(e){let{projectDisplay:t,profileDisplay:n,label:r,selected:i}=e,a=r?`${t} - ${r}`:t;return(0,I.jsxs)(V,{gap:`xs`,align:`center`,wrap:`nowrap`,style:{width:`100%`,minWidth:0},children:[(0,I.jsx)(z,{className:eM.iconBox,children:(0,I.jsx)(xA,{size:16,stroke:2})}),(0,I.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,I.jsx)(H,{size:`sm`,fw:500,truncate:!0,children:a}),(0,I.jsx)(H,{size:`xs`,c:`dimmed`,truncate:!0,children:n})]}),i&&(0,I.jsx)(EA,{size:16,stroke:2,color:`var(--mantine-color-blue-6)`})]})}function nM(e){let{membership:t,label:n}=e;return(0,I.jsx)(tM,{projectDisplay:t.project?.display,profileDisplay:t.profile?.display,label:n})}function rM(){return`Medplum`}var iM={divider:`_divider_3o3ui_1`,accountSection:`_accountSection_3o3ui_5`,projectOption:`_projectOption_3o3ui_9`,recentProjectItem:`_recentProjectItem_3o3ui_18`,dropdown:`_dropdown_3o3ui_22`,settingsRow:`_settingsRow_3o3ui_43`,settingsControlWrapper:`_settingsControlWrapper_3o3ui_50`,segmentedControl:`_segmentedControl_3o3ui_57`,appearanceControl:`_appearanceControl_3o3ui_76`,layoutControl:`_layoutControl_3o3ui_93`},aM=`var(--mantine-color-dimmed)`,oM=[{value:`light`,label:(0,I.jsx)(cM,{Icon:Ej,label:`Light`})},{value:`auto`,label:(0,I.jsx)(cM,{Icon:LA,label:`System`})},{value:`dark`,label:(0,I.jsx)(cM,{Icon:sj,label:`Dark`})}],sM=[{label:`v1`,value:`v1`},{label:`v2`,value:`v2`}];function cM({Icon:e,label:t}){return(0,I.jsx)(`span`,{"aria-label":t,style:{display:`flex`},children:(0,I.jsx)(e,{size:16,color:aM,"aria-hidden":!0})})}function lM(){return(0,I.jsx)(dm,{my:4,mx:4,className:iM.divider})}function uM(e,t){return t?e.project.reference===t.project.reference&&e.profile.reference===t.profile.reference:!1}function dM(e){return`${e.project.reference}-${e.profile.reference}`}function fM(e){let{medplum:t,profile:n,navigate:r}=qO(),i=t.getActiveLogin(),a=t.getLogins().filter(e=>!uM(e,i)),o=t.getProject(),{colorScheme:s,setColorScheme:c}=ci(),[l]=(0,b.useState)(()=>localStorage.appShellLayoutVersion??`v1`),u=e.showLayoutVersionToggle??!0,d=o?.name??t.getActiveLogin()?.project.display,f=i?.profile.display??(n?lw(n.name?.[0]):void 0);function p(e){t.setActiveLogin(e).then(()=>LE.reload()).catch(console.error)}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(z,{className:iM.accountSection,children:(0,I.jsx)(z,{className:iM.projectOption,children:(0,I.jsx)(tM,{projectDisplay:d,profileDisplay:f,selected:!0})})}),a.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(lM,{}),a.map(e=>(0,I.jsx)(W.Item,{className:iM.recentProjectItem,onClick:()=>p(e),children:(0,I.jsx)(z,{className:iM.projectOption,children:(0,I.jsx)(tM,{projectDisplay:e.project.display,profileDisplay:e.profile.display})})},dM(e)))]}),(0,I.jsx)(lM,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(Dj,{size:16,color:aM}),onClick:()=>r(`/signin`),children:(0,I.jsx)(H,{size:`sm`,children:`Switch to another project`})}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(xj,{size:16,color:aM}),onClick:()=>r(`/${oC(n)}`),children:(0,I.jsx)(H,{size:`sm`,children:`Account settings`})}),(0,I.jsxs)(_d,{className:iM.settingsRow,align:`center`,pl:`sm`,pr:`xs`,py:`xs`,children:[(0,I.jsxs)(_d,{align:`center`,gap:`xs`,children:[(0,I.jsx)(lj,{size:16,color:aM}),(0,I.jsx)(H,{size:`sm`,children:`Appearance`})]}),(0,I.jsx)(z,{className:iM.settingsControlWrapper,children:(0,I.jsx)(uy,{classNames:{root:Mn(iM.segmentedControl,iM.appearanceControl)},size:`xs`,radius:`xl`,withItemsBorders:!1,value:s,onChange:e=>c(e),data:oM,"aria-label":`Color scheme`})})]}),u&&(0,I.jsxs)(_d,{className:iM.settingsRow,align:`center`,pl:`sm`,pr:`xs`,py:`xs`,children:[(0,I.jsxs)(_d,{align:`center`,gap:`xs`,children:[(0,I.jsx)(kj,{size:16,color:aM}),(0,I.jsx)(H,{size:`sm`,children:`Layout`})]}),(0,I.jsx)(z,{className:iM.settingsControlWrapper,children:(0,I.jsx)(uy,{classNames:{root:Mn(iM.segmentedControl,iM.layoutControl)},size:`xs`,radius:`xl`,withItemsBorders:!1,value:l,onChange:e=>{localStorage.appShellLayoutVersion=e,LE.reload()},data:sM,"aria-label":`App shell layout version`})})]}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(tj,{size:16,color:aM}),onClick:async()=>{await t.signOut(),r(`/signin`)},children:(0,I.jsx)(H,{size:`sm`,children:`Sign out`})}),(0,I.jsx)(lM,{}),(0,I.jsxs)(H,{size:`xs`,c:`dimmed`,fw:500,my:`sm`,ta:`center`,children:[rM(),` `,e.version]})]})}var pM={selectedItems:`selected-items`,options:`options`};function mM(e){let t=If({onDropdownClose:()=>t.resetSelectedOption(),onDropdownOpen:()=>t.updateSelectedOptionIndex(`active`)}),{name:n,label:r,description:i,error:a,defaultValue:o,toOption:s,loadOptions:c,itemComponent:l,pillComponent:u,emptyComponent:d,onChange:f,onCreate:p,creatable:m,clearable:h,required:g,placeholder:_,leftSection:v,maxValues:y,optionsDropdownMaxHeight:x=320,minInputLength:S=0,...C}=e,w=C.disabled,T=hM(o),[E,D]=(0,b.useState)(``),[O,k]=(0,b.useState)(),[A,j]=(0,b.useState)(),[M,ee]=(0,b.useState)(),[N,P]=(0,b.useState)(T.map(s)),[te,ne]=(0,b.useState)([]),re=l??gM,ie=u??_M,ae=d??vM,oe=(0,b.useRef)(E),se=(0,b.useRef)(void 0),ce=(0,b.useRef)(void 0),le=(0,b.useRef)(O),ue=(0,b.useRef)(A),de=(0,b.useRef)(M);(0,b.useLayoutEffect)(()=>{oe.current=E,le.current=O,ue.current=A,de.current=M});let fe=(0,b.useCallback)(()=>{if(k(void 0),oe.current===ce.current&&c===se.current||(oe.current?.length??0)<S)return;ce.current=oe.current,se.current=c;let e=new AbortController;j(e),c(oe.current??``,e.signal).then(n=>{e.signal.aborted||(ne(n.map(s)),de.current?(n.length>0&&f(n.slice(0,1)),ee(!1)):n.length>0&&t.openDropdown())}).catch(t=>{e.signal.aborted||t.message.includes(`aborted`)||J({color:`red`,message:Qx(t)})}).finally(()=>{e.signal.aborted||j(void 0)})},[t,c,f,s,S]),pe=(0,b.useCallback)(e=>{(te&&te.length>0||m)&&t.openDropdown(),t.updateSelectedOptionIndex(),D(e.currentTarget.value),ue.current&&(ue.current.abort(),j(void 0)),le.current!==void 0&&window.clearTimeout(le.current),k(window.setTimeout(()=>fe(),100))},[t,te,m,fe]),me=(0,b.useCallback)(e=>{let t=N.some(t=>t.value===e),n=t?N.filter(t=>t.value!==e):[...N],r=te?.find(t=>t.value===e);if(!r&&m!==!1&&p&&(r=s(p(e))),r){if(y===0){f([r.resource]),N.length>0&&P([]);return}t||n.push(r)}if(y!==void 0)for(;n.length>y;)n.shift();f(n.map(e=>e.resource)),P(n)},[m,te,N,y,f,p,s]),he=(0,b.useMemo)(()=>{if(!w)return e=>{w||(y===1&&(D(``),ne([]),t.closeDropdown()),ce.current=void 0,e===`$create`?(D(``),me(E)):me(e))}},[me,t,w,y,E]),ge=(0,b.useCallback)(e=>{let t=N.filter(t=>t.value!==e.value);f(t.map(e=>e.resource)),P(t)},[N,f]),_e=(0,b.useCallback)(e=>{e.key===`Enter`?(O||A)&&ee(!0):e.key===`Backspace`&&E.length===0&&(Bj(e),ge(N[N.length-1]))},[A,ge,E.length,N,O]);(0,b.useEffect)(()=>()=>{ue.current&&ue.current.abort()},[]);let ve=!w&&h&&N.length>0&&(0,I.jsx)(zf.ClearButton,{title:`Clear all`,size:`sm`,onClear:()=>{D(``),P([]),f([]),t.closeDropdown()}}),ye=m&&E.trim().length>0,be=te.length>0||ye;return(0,I.jsxs)(zf,{store:t,onOptionSubmit:he,withinPortal:!0,shadow:`xl`,...C,children:[(0,I.jsx)(zf.DropdownTarget,{children:(0,I.jsx)(vg,{label:r,description:i,error:a,className:e.className,leftSection:v,rightSection:A?(0,I.jsx)(cu,{size:16}):ve,required:g,disabled:w,children:(0,I.jsxs)(pg.Group,{"data-testid":pM.selectedItems,children:[N.map(e=>(0,I.jsx)(ie,{item:e,disabled:w,onRemove:()=>ge(e)},e.value)),!w&&(y===void 0||y===0||N.length<y)&&(0,I.jsx)(zf.EventsTarget,{children:(0,I.jsx)(vg.Field,{role:`searchbox`,name:n,value:E,placeholder:_,onFocus:pe,onBlur:()=>{t.closeDropdown(),D(``)},onKeyDown:_e,onChange:pe})})]})})}),(0,I.jsx)(zf.Dropdown,{hidden:!be,"data-testid":pM.options,children:(0,I.jsx)(zf.Options,{children:(0,I.jsxs)(dl,{type:`scroll`,mah:x,children:[te.map(e=>{let t=N.some(t=>t.value===e.value);return(0,I.jsx)(zf.Option,{value:e.value,active:t,children:(0,I.jsx)(re,{...e,active:t})},e.value)}),ye&&(0,I.jsxs)(zf.Option,{value:`$create`,children:[`+ Create `,E]}),!m&&E.trim().length>0&&te.length===0&&(0,I.jsx)(ae,{search:E})]})})})]})}function hM(e){return e?Array.isArray(e)?e:[e]:[]}function gM(e){return(0,I.jsxs)(V,{gap:`xs`,children:[e.active&&(0,I.jsx)(EA,{size:12}),(0,I.jsx)(`span`,{children:e.label})]})}function _M({item:e,disabled:t,onRemove:n}){return(0,I.jsx)(pg,{withRemoveButton:!t,onRemove:n,children:e.label})}function vM(){return(0,I.jsx)(zf.Empty,{children:`Nothing found`})}var yM={searchInput:`_searchInput_dick8_1`};function bM(e){return{value:e.id,label:uC(e),resource:e}}function xM(e){let t=JO(),n=Z(),r=(0,b.useCallback)(async(e,t)=>{let r=CM(e),i={signal:t};return wM(await n.graphql(r,void 0,void 0,i),e)},[n]),i=(0,b.useCallback)(e=>{e.length>0&&t(`/${oC(e[0])}`)},[t]);return(0,I.jsx)(mM,{size:`sm`,radius:`md`,className:yM.searchInput,leftSection:(0,I.jsx)(bj,{size:16}),placeholder:`Search`,itemComponent:SM,toOption:bM,onChange:i,loadOptions:r,maxValues:0,clearable:!1},`${e.pathname}?${e.searchParams}`)}var SM=(0,b.forwardRef)(({resource:e,active:t,...n},r)=>{let i;return e.resourceType===`Patient`?i=e.birthDate:e.resourceType===`ServiceRequest`&&(i=e.subject?.display),(0,I.jsx)(`div`,{ref:r,...n,children:(0,I.jsxs)(V,{wrap:`nowrap`,children:[(0,I.jsx)(Qj,{value:e}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{children:uC(e)}),(0,I.jsx)(H,{size:`xs`,c:`dimmed`,children:i})]})]})})});function CM(e){let t=JSON.stringify(e);return NC(e)?`{
97
97
  Patients1: PatientList(_id: ${t}, _count: 1) {
98
98
  resourceType
99
99
  id
@@ -156,7 +156,7 @@ ${o?`${s(`light`)}{${o}}`:``}`}function Dr({color:e,theme:t,autoContrast:n}){ret
156
156
  display
157
157
  }
158
158
  }
159
- }`.replaceAll(/\s+/g,` `)}function SM(e,t){let n=[];return e.data.Patients1&&n.push(...e.data.Patients1),e.data.Patients2&&n.push(...e.data.Patients2),e.data.ServiceRequestList&&n.push(...e.data.ServiceRequestList),wM(CM(n),t).slice(0,5)}function CM(e){let t=new Set,n=[];for(let r of e)t.has(r.id)||(t.add(r.id),n.push(r));return n}function wM(e,t){return e.sort((e,n)=>TM(n,t)-TM(e,t))}function TM(e,t){let n=0;if(e.identifier)for(let r of e.identifier)n=Math.max(n,EM(r.value,t));if(e.resourceType===`Patient`&&e.name)for(let r of e.name)n=Math.max(n,EM(lw(r),t));return n}function EM(e,t){if(!e)return 0;let n=e.toLowerCase().indexOf(t.toLowerCase());return n<0?0:100-n}function DM(e){let t=qO(),[n,r]=(0,b.useState)(!1);return(0,I.jsx)(af.Header,{p:8,style:{zIndex:101},children:(0,I.jsxs)(V,{justify:`space-between`,children:[(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(ml,{className:Zj.logoButton,"aria-expanded":e.navbarOpen,"aria-controls":`navbar`,onClick:()=>e.navbarToggle(),children:e.logo}),!e.headerSearchDisabled&&(0,I.jsx)(yM,{pathname:e.pathname,searchParams:e.searchParams})]}),(0,I.jsxs)(V,{gap:`lg`,pr:`sm`,children:[e.notifications,(0,I.jsxs)(W,{width:260,shadow:`md`,radius:`md`,position:`bottom-end`,transitionProps:{transition:`fade-down`},opened:n,onClose:()=>r(!1),children:[(0,I.jsx)(W.Target,{children:(0,I.jsx)(ml,{className:Zj.user,"aria-label":`User menu`,"data-active":n||void 0,onClick:()=>r(e=>!e),children:(0,I.jsxs)(V,{gap:7,children:[(0,I.jsx)(Xj,{value:t,radius:`xl`,size:24}),(0,I.jsx)(H,{size:`sm`,className:Zj.userName,children:lw(t?.name?.[0])}),(0,I.jsx)(EA,{size:12,stroke:1.5})]})})}),(0,I.jsx)(W.Dropdown,{className:nM.dropdown,children:(0,I.jsx)(uM,{version:e.version})})]})]})]})})}var OM=()=>kb({opened:!1,empty:!1,selected:-1,listId:``,query:``,registeredActions:new Set}),kM=e=>Ab(e);function AM(e,t){let n=t.getState();t.setState({...n,...e(t.getState())})}function jM(e){AM(()=>({opened:!0,selected:-1}),e)}function MM(e){AM(()=>({opened:!1}),e)}function NM(e){AM(e=>({opened:!e.opened,selected:e.opened?e.selected:-1}),e)}function PM(e,t){t.updateState(t=>({...t,selected:e}))}function FM(e,t){t.updateState(t=>({...t,listId:e}))}function IM(e,t=document){let n=t.querySelector(e);if(n)return n;let r=t instanceof ShadowRoot?t.host.children:t.children;for(let t=0;t<r.length;t+=1){let n=r[t];if(n.shadowRoot){let t=IM(e,n.shadowRoot);if(t)return t}let i=IM(e,n);if(i)return i}return null}function LM(e,t){let n=t.getState(),r=n.listId?IM(`#${n.listId}`):null,i=r?.querySelector(`[data-selected]`),a=r?.querySelectorAll(`[data-action]`)??[],o=Ct(e===-1?a.length-1:e===a.length?0:e,0,a.length-1);return i?.removeAttribute(`data-selected`),a[o]?.scrollIntoView({block:`nearest`}),a[o]?.setAttribute(`data-selected`,`true`),PM(o,t),o}function RM(e){return LM(e.getState().selected+1,e)}function zM(e){return LM(e.getState().selected-1,e)}function BM(e){IM(`#${e.getState().listId} [data-selected]`)?.click()}function VM(e,t){let n=t.getState();return n.registeredActions.add(e),()=>{n.registeredActions.delete(e)}}function HM(e,t){AM(()=>({query:e}),t),Promise.resolve().then(()=>{LM(0,t),AM(e=>({empty:e.query.trim().length>0&&e.registeredActions.size===0||!1}),t)})}function UM({clearQuery:e},t){t.updateState(t=>({...t,selected:-1,query:e?``:t.query,empty:e?!1:t.empty}))}var WM={open:jM,close:MM,toggle:NM,updateState:AM,setSelectedAction:PM,setListId:FM,selectAction:LM,selectNextAction:RM,selectPreviousAction:zM,triggerSelectedAction:BM,registerAction:VM,setQuery:HM,clearSpotlightState:UM};function GM(){let e=OM();return[e,{open:()=>jM(e),close:()=>MM(e),toggle:()=>NM(e)}]}var[KM,qM]=GM(),{open:JM,close:YM,toggle:XM}=qM;function ZM(e){let t=e;return t.group!==void 0&&Array.isArray(t.actions)}function QM(e){return Array.isArray(e)?e.map(e=>e.trim()).join(`,`).toLowerCase().trim():typeof e==`string`?e.toLowerCase().trim():``}function $M(e){return e.reduce((e,t)=>`actions`in t?[...e,...t.actions.map(e=>({...e,group:t.group}))]:[...e,t],[])}function eN(e){let t={},n=[];return e.forEach(e=>{e.group?(t[e.group]||(t[e.group]={pushed:!1,data:{group:e.group,actions:[]}}),t[e.group].data.actions.push(e),t[e.group].pushed||(t[e.group].pushed=!0,n.push(t[e.group].data))):n.push(e)}),n}var tN=(e,t)=>{let n=e.trim().toLowerCase(),r=[[],[]];return $M(t).forEach(e=>{e.label?.toLowerCase().includes(n)?r[0].push(e):(e.description?.toLowerCase().includes(n)||QM(e.keywords).includes(n))&&r[1].push(e)}),eN(r.flat())};function nN(e,t){if(!Array.isArray(e))return[];let n=0;return e.reduce((e,r)=>{if(n>=t)return e;if(ZM(r)){let i=nN(r.actions,t-n);e.push({group:r.group,actions:i}),n+=i.length}else e.push(r),n+=1;return e},[])}var rN={root:`m_d2b315db`,content:`m_3cd250e0`,body:`m_d2abce9b`,search:`m_f366a061`,actionsList:`m_6e463822`,action:`m_d49bb8ef`,actionBody:`m_3d475731`,actionSection:`m_832642f6`,actionLabel:`m_6c2a1345`,actionDescription:`m_a6d9d78d`,empty:`m_82f78f74`,footer:`m_ddcaf054`,actionsGroup:`m_5a3e5f7b`},[iN,aN]=et(`Spotlight component was not found in tree`),oN={dimmedSections:!0,highlightQuery:!1},sN=B((e,t)=>{let{className:n,style:r,classNames:i,styles:a,id:o,description:s,label:c,leftSection:l,rightSection:u,children:d,dimmedSections:f,highlightQuery:p,highlightColor:m,closeSpotlightOnTrigger:h,onClick:g,onMouseDown:_,keywords:v,vars:y,...b}=R(`SpotlightAction`,oN,e),x=aN(),S={classNames:i,styles:a},C=p&&typeof c==`string`?(0,I.jsx)(Nm,{component:`span`,highlight:x.query,color:m,...x.getStyles(`actionLabel`,S),children:c}):(0,I.jsx)(`span`,{...x.getStyles(`actionLabel`,S),children:c});return(0,I.jsx)(ml,{ref:t,"data-action":!0,...x.getStyles(`action`,{className:n,style:r,...S}),...b,onMouseDown:e=>{e.preventDefault(),_?.(e)},onClick:e=>{g?.(e),(h??x.closeOnActionTrigger)&&WM.close(x.store)},tabIndex:-1,children:d||(0,I.jsxs)(I.Fragment,{children:[l&&(0,I.jsx)(z,{component:`span`,mod:{position:`left`,dimmed:f},...x.getStyles(`actionSection`,S),children:l}),(0,I.jsxs)(`span`,{...x.getStyles(`actionBody`,S),children:[C,(0,I.jsx)(`span`,{...x.getStyles(`actionDescription`,S),children:s})]}),u&&(0,I.jsx)(z,{component:`span`,mod:{position:`right`,dimmed:f},...x.getStyles(`actionSection`,S),children:u})]})})});sN.classes=rN,sN.displayName=`@mantine/spotlight/SpotlightAction`;var cN=B((e,t)=>{let{className:n,style:r,styles:i,classNames:a,label:o,children:s,...c}=R(`SpotlightActionsGroup`,null,e);return(0,I.jsx)(z,{...aN().getStyles(`actionsGroup`,{className:n,style:r,classNames:a,styles:i}),ref:t,...c,__vars:{"--spotlight-label":`'${o?.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}'`},children:s})});cN.classes=rN,cN.displayName=`@mantine/core/SpotlightActionsGroup`;var lN=B((e,t)=>{let{className:n,style:r,id:i,children:a,vars:o,classNames:s,styles:c,...l}=R(`SpotlightActionsList`,null,e),u=aN(),d=`mantine-${(0,b.useId)().replace(/:/g,``)}`,f=i||d;return(0,b.useEffect)(()=>(WM.setListId(f,u.store),()=>WM.setListId(``,u.store)),[]),(0,I.jsx)(ul.Autosize,{...u.getStyles(`actionsList`,{className:n,style:r,classNames:s,styles:c}),ref:t,type:`scroll`,scrollbarSize:`var(--spotlight-actions-list-padding)`,offsetScrollbars:`y`,id:f,...l,children:a})});lN.classes=rN,lN.displayName=`@mantine/spotlight/SpotlightActionsList`;var uN=B((e,t)=>{let{className:n,style:r,classNames:i,styles:a,...o}=R(`SpotlightEmpty`,null,e);return(0,I.jsx)(z,{ref:t,...aN().getStyles(`empty`,{classNames:i,styles:a,className:n,style:r}),...o})});uN.classes=rN,uN.displayName=`@mantine/spotlight/SpotlightEmpty`;var dN=B((e,t)=>{let{className:n,style:r,classNames:i,styles:a,...o}=R(`SpotlightFooter`,null,e);return(0,I.jsx)(z,{ref:t,...aN().getStyles(`footer`,{className:n,classNames:i,style:r,styles:a}),...o})});dN.classes=rN,dN.displayName=`@mantine/spotlight/SpotlightFooter`;function fN(e,t){if(!e)return[];let n=()=>WM.open(t);return Array.isArray(e)?e.map(e=>[e,n]):[[e,n]]}var pN={size:600,yOffset:80,zIndex:lt(`max`),overlayProps:{backgroundOpacity:.35,blur:7},transitionProps:{duration:200,transition:`pop`},store:KM,clearQueryOnClose:!0,closeOnActionTrigger:!0,shortcut:`mod + K`,maxHeight:400},mN=B((e,t)=>{let n=R(`SpotlightRoot`,pN,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,store:l,children:u,query:d,onQueryChange:f,transitionProps:p,clearQueryOnClose:m,shortcut:h,tagsToIgnore:g,triggerOnContentEditable:_,disabled:v,onSpotlightOpen:y,onSpotlightClose:b,forceOpened:x,closeOnActionTrigger:S,maxHeight:C,scrollable:w,attributes:T,...E}=n,D=Sr(),{opened:O,query:k}=kM(l),A=typeof d==`string`?d:k,j=e=>{f?.(e),WM.setQuery(e,l)},M=L({name:`Spotlight`,classes:rN,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:T});return yn(fN(h,l),g,_),Lt(()=>{O?y?.():b?.()},[O]),v?null:(0,I.jsx)(iN,{value:{getStyles:M,query:A,setQuery:j,store:l,closeOnActionTrigger:S},children:(0,I.jsx)(rg,{ref:t,...E,withCloseButton:!1,opened:O||!!x,padding:0,onClose:()=>WM.close(l),className:i,style:a,classNames:Fn({theme:D,classNames:[rN,r],props:n,stylesCtx:void 0}),styles:In({theme:D,styles:o,props:n,stylesCtx:void 0}),transitionProps:{...p,onExited:()=>{m&&j(``),WM.clearSpotlightState({clearQuery:m},l),p?.onExited?.()}},__vars:{"--spotlight-max-height":w?F(C):void 0},__staticSelector:`Spotlight`,"data-scrollable":w||void 0,children:u})})});mN.classes=rN,mN.displayName=`@mantine/spotlight/SpotlightRoot`;var hN={size:`lg`},gN=B((e,t)=>{let{classNames:n,styles:r,onKeyDown:i,onChange:a,vars:o,value:s,...c}=R(`SpotlightSearch`,hN,e),l=aN(),u=l.getStyles(`search`),[d,f]=(0,b.useState)(!1),p=e=>{i?.(e),!d&&(e.nativeEvent.code===`ArrowDown`&&(e.preventDefault(),WM.selectNextAction(l.store)),e.nativeEvent.code===`ArrowUp`&&(e.preventDefault(),WM.selectPreviousAction(l.store)),(e.nativeEvent.code===`Enter`||e.nativeEvent.code===`NumpadEnter`)&&(e.preventDefault(),WM.triggerSelectedAction(l.store)))};return(0,I.jsx)(dd,{ref:t,classNames:[{input:u.className},n],styles:[{input:u.style},r],...c,value:s??l.query,onChange:e=>{l.setQuery(e.currentTarget.value),a?.(e)},onKeyDown:p,onCompositionStart:()=>f(!0),onCompositionEnd:()=>f(!1)})});gN.classes=rN,gN.displayName=`@mantine/spotlight/SpotlightSearch`;var _N={size:600,yOffset:80,limit:1/0,zIndex:lt(`max`),overlayProps:{backgroundOpacity:.35,blur:7},transitionProps:{duration:200,transition:`pop`},store:KM,filter:tN,clearQueryOnClose:!0,closeOnActionTrigger:!0,shortcut:`mod + K`},vN=B((e,t)=>{let{searchProps:n,filter:r,query:i,onQueryChange:a,actions:o,nothingFound:s,highlightQuery:c,limit:l,scrollAreaProps:u,...d}=R(`Spotlight`,_N,e),[f,p]=an({value:i,defaultValue:``,finalValue:``,onChange:a}),m=nN(r(f,o),l).map(e=>{if(ZM(e)){let t=e.actions.map(({id:e,...t})=>(0,I.jsx)(sN,{highlightQuery:c,...t},e));return(0,I.jsx)(cN,{label:e.group,children:t},e.group)}return(0,I.jsx)(sN,{highlightQuery:c,...e},e.id)});return(0,I.jsxs)(mN,{...d,query:f,onQueryChange:p,ref:t,children:[(0,I.jsx)(gN,{...n}),m.length>0&&(0,I.jsx)(lN,{...u,children:m}),m.length===0&&s&&(0,I.jsx)(uN,{children:s})]})});vN.classes=rN,vN.displayName=`@mantine/spotlight/Spotlight`,vN.Search=gN,vN.ActionsList=lN,vN.Action=sN,vN.Empty=uN,vN.ActionsGroup=cN,vN.Footer=dN,vN.Root=mN,vN.open=qM.open,vN.close=qM.close,vN.toggle=qM.toggle;var yN=(0,b.createContext)({submitting:!1});yN.displayName=`FormContext`;function bN(e){let t={};for(let n of Array.from(e.elements))n instanceof HTMLInputElement?xN(t,n):n instanceof HTMLTextAreaElement?t[n.name]=n.value:n instanceof HTMLSelectElement&&SN(t,n);return t}function xN(e,t){t.disabled||(t.type===`checkbox`||t.type===`radio`)&&!t.checked||(e[t.name]=t.value)}function SN(e,t){e[t.name]=t.value}function CN(e){let[t,n]=(0,b.useState)(!1);return(0,I.jsx)(yN.Provider,{value:{submitting:t},children:(0,I.jsx)(`form`,{style:e.style,"data-testid":e.testid,onSubmit:t=>{t.preventDefault();let r=bN(t.target);if(e.onSubmit){n(!0);let t=e.onSubmit(r);t?.then?t.catch(console.error).finally(()=>{n(!1)}):n(!1)}},children:e.children})})}function wN(e){let{children:t,...n}=e,{submitting:r}=(0,b.useContext)(yN);return(0,I.jsx)(U,{type:`submit`,loading:r,...n,children:t})}function TN(e){let t=Z(),n=t.getUserConfiguration();function r(r){let{menuname:i,bookmarkname:a}=r,o=`${e.pathname}?${e.searchParams.toString()}`,s=MC(n);(s.menu?.find(({title:e})=>e===i))?.link?.push({name:a,target:o}),t.updateResource(s).then(r=>{n.menu=r.menu,t.dispatchEvent({type:`change`}),J({color:`green`,message:`Success`}),e.onOk()}).catch(e=>{J({color:`red`,message:Qx(e)})})}return(0,I.jsx)(rg,{title:`Add Bookmark`,closeButtonProps:{"aria-label":`Close`},opened:e.visible,onClose:e.onCancel,children:(0,I.jsx)(CN,{onSubmit:r,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(EN,{config:n}),(0,I.jsx)(yb,{label:`Bookmark Name`,type:`text`,name:`bookmarkname`,placeholder:`Bookmark Name`,defaultValue:e.pathname.split(`/`)[1]||``,withAsterisk:!0}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(wN,{mt:`sm`,children:`OK`})})]})})})}function EN(e){function t(e){return e?.menu?.map(e=>e.title)}let n=t(e.config);return(0,I.jsx)(Eg,{name:`menuname`,defaultValue:n[0],label:`Select Menu Option`,data:n,withAsterisk:!0})}function DN(e){return typeof e.code==`string`?e.code:JSON.stringify(e)}function ON(e){return typeof e.display==`string`?e.display:DN(e)}function kN(e){return{value:DN(e),label:ON(e),resource:e}}function AN(e){return{code:e,display:e}}function jN(e){let t=Z(),{binding:n,creatable:r,clearable:i,expandParams:a,withHelpText:o,...s}=e,c=(0,b.useCallback)(async(e,r)=>{if(!n)return[];let i=(await t.valueSetExpand({count:10,...a,url:n,filter:e},{signal:r})).expansion?.contains??[],o=[];for(let e of i)e.code&&!o.some(t=>t.code===e.code)&&o.push(e);return o},[t,a,n]);return(0,I.jsx)(fM,{...s,creatable:r??!0,clearable:i??!0,toOption:kN,loadOptions:c,onCreate:AN,itemComponent:o?MN:void 0})}var MN=(0,b.forwardRef)(({label:e,resource:t,active:n,...r},i)=>(0,I.jsx)(`div`,{ref:i,...r,children:(0,I.jsxs)(V,{wrap:`nowrap`,gap:`xs`,children:[n&&(0,I.jsx)(wA,{size:12}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{children:e}),(0,I.jsx)(H,{size:`xs`,c:`dimmed`,children:`${t.system}#${t.code}`})]})]})}));function NN(e){let{defaultValue:t,onChange:n,withHelpText:r,...i}=e,[a,o]=(0,b.useState)(t);function s(e){let t=e[0],r=FN(t);o(r),n&&n(r)}return(0,I.jsx)(jN,{defaultValue:PN(a),onChange:s,withHelpText:r??!0,...i})}function PN(e){return e?{code:e}:void 0}function FN(e){return e?.code}function IN(e){let[t,n]=(0,b.useState)(e.defaultValue),r=e.onChange,i=(0,b.useCallback)(e=>{n(e),r&&r(e)},[r]);return(0,I.jsx)(NN,{disabled:e.disabled,"data-autofocus":e.autoFocus,"data-testid":e.testId,defaultValue:t,onChange:i,name:e.name,placeholder:e.placeholder,binding:`https://medplum.com/fhir/ValueSet/resource-types`,creatable:!1,maxValues:e.maxValues??1,clearable:!1,withHelpText:!1})}var LN={navbar:`_navbar_196ng_1`,logoButton:`_logoButton_196ng_6`,menuTitle:`_menuTitle_196ng_25`,link:`_link_196ng_52`,dismissButton:`_dismissButton_196ng_92`,linkLabel:`_linkLabel_196ng_110`,iconWrapper:`_iconWrapper_196ng_121`,alertDot:`_alertDot_196ng_128`,linkCount:`_linkCount_196ng_139`,addBookmarkLink:`_addBookmarkLink_196ng_192`,toggleButton:`_toggleButton_196ng_202`,divider:`_divider_196ng_231`},RN={actionSection:`_actionSection_1l8yv_8`,action:`_action_1l8yv_8`,actionDescription:`_actionDescription_1l8yv_27`,actionsGroup:`_actionsGroup_1l8yv_32`,actionsList:`_actionsList_1l8yv_55`,content:`_content_1l8yv_60`},zN=200;function BN(){return(0,I.jsxs)(G,{gap:`xs`,py:`lg`,children:[(0,I.jsxs)(H,{size:`sm`,c:`dimmed`,children:[`Press `,(0,I.jsx)(fh,{children:`⌘`}),` + `,(0,I.jsx)(fh,{children:`K`}),` to open Search next time.`]}),(0,I.jsxs)(H,{size:`sm`,c:`dimmed`,children:[`(`,(0,I.jsx)(fh,{children:`Ctrl`}),` + `,(0,I.jsx)(fh,{children:`K`}),` on Windows)`]})]})}function VN({patientsOnly:e}){let t=Z(),n=KO(),[r,i]=(0,b.useState)((0,I.jsx)(BN,{})),[a,o]=(0,b.useState)([]),s=Ot(r=>{let a=HN(r);e?t.graphql(a).then(e=>{o(GN(UN(e).filter(e=>e.resourceType===`Patient`),n))}).catch(console.error).finally(()=>i(`No results found`)):Promise.all([t.graphql(a),t.valueSetExpand({url:`https://medplum.com/fhir/ValueSet/resource-types`,filter:r,count:5})]).then(([e,t])=>{o(KN(UN(e),t.expansion?.contains??[],n))}).catch(console.error).finally(()=>i(`No results found`))},zN);return(0,I.jsx)(vN,{actions:a,nothingFound:r,radius:`md`,highlightQuery:!0,searchProps:{leftSection:(0,I.jsx)(vj,{size:`1.2rem`,stroke:2,color:`var(--mantine-color-gray-5)`}),placeholder:`Start typing to search…`,type:`search`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,name:e?`provider-spotlight-search`:`spotlight-search`,"data-1p-ignore":`true`,"data-lpignore":`true`,leftSectionProps:{style:{marginLeft:`calc(var(--mantine-spacing-md) - 12px)`}}},classNames:{body:RN.body,content:RN.content,search:RN.search,actionsList:RN.actionsList,action:RN.action,actionSection:RN.actionSection,actionDescription:RN.actionDescription,actionsGroup:RN.actionsGroup},onQueryChange:e=>{if(!e){s.cancel(),i((0,I.jsx)(BN,{})),o([]);return}i(`Searching...`),s(e)}})}function HN(e){let t=JSON.stringify(e);return NC(e)?`{
159
+ }`.replaceAll(/\s+/g,` `)}function wM(e,t){let n=[];return e.data.Patients1&&n.push(...e.data.Patients1),e.data.Patients2&&n.push(...e.data.Patients2),e.data.ServiceRequestList&&n.push(...e.data.ServiceRequestList),EM(TM(n),t).slice(0,5)}function TM(e){let t=new Set,n=[];for(let r of e)t.has(r.id)||(t.add(r.id),n.push(r));return n}function EM(e,t){return e.sort((e,n)=>DM(n,t)-DM(e,t))}function DM(e,t){let n=0;if(e.identifier)for(let r of e.identifier)n=Math.max(n,OM(r.value,t));if(e.resourceType===`Patient`&&e.name)for(let r of e.name)n=Math.max(n,OM(lw(r),t));return n}function OM(e,t){if(!e)return 0;let n=e.toLowerCase().indexOf(t.toLowerCase());return n<0?0:100-n}function kM(e){let t=YO(),[n,r]=(0,b.useState)(!1);return(0,I.jsx)(af.Header,{p:8,style:{zIndex:101},children:(0,I.jsxs)(V,{justify:`space-between`,children:[(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(ml,{className:$j.logoButton,"aria-expanded":e.navbarOpen,"aria-controls":`navbar`,onClick:()=>e.navbarToggle(),children:e.logo}),!e.headerSearchDisabled&&(0,I.jsx)(xM,{pathname:e.pathname,searchParams:e.searchParams})]}),(0,I.jsxs)(V,{gap:`lg`,pr:`sm`,children:[e.notifications,(0,I.jsxs)(W,{width:260,shadow:`md`,radius:`md`,position:`bottom-end`,transitionProps:{transition:`fade-down`},opened:n,onClose:()=>r(!1),children:[(0,I.jsx)(W.Target,{children:(0,I.jsx)(ml,{className:$j.user,"aria-label":`User menu`,"data-active":n||void 0,onClick:()=>r(e=>!e),children:(0,I.jsxs)(V,{gap:7,children:[(0,I.jsx)(Qj,{value:t,radius:`xl`,size:24}),(0,I.jsx)(H,{size:`sm`,className:$j.userName,children:lw(t?.name?.[0])}),(0,I.jsx)(OA,{size:12,stroke:1.5})]})})}),(0,I.jsx)(W.Dropdown,{className:iM.dropdown,children:(0,I.jsx)(fM,{version:e.version})})]})]})]})})}var AM=()=>kb({opened:!1,empty:!1,selected:-1,listId:``,query:``,registeredActions:new Set}),jM=e=>Ab(e);function MM(e,t){let n=t.getState();t.setState({...n,...e(t.getState())})}function NM(e){MM(()=>({opened:!0,selected:-1}),e)}function PM(e){MM(()=>({opened:!1}),e)}function FM(e){MM(e=>({opened:!e.opened,selected:e.opened?e.selected:-1}),e)}function IM(e,t){t.updateState(t=>({...t,selected:e}))}function LM(e,t){t.updateState(t=>({...t,listId:e}))}function RM(e,t=document){let n=t.querySelector(e);if(n)return n;let r=t instanceof ShadowRoot?t.host.children:t.children;for(let t=0;t<r.length;t+=1){let n=r[t];if(n.shadowRoot){let t=RM(e,n.shadowRoot);if(t)return t}let i=RM(e,n);if(i)return i}return null}function zM(e,t){let n=t.getState(),r=n.listId?RM(`#${n.listId}`):null,i=r?.querySelector(`[data-selected]`),a=r?.querySelectorAll(`[data-action]`)??[],o=Ct(e===-1?a.length-1:e===a.length?0:e,0,a.length-1);return i?.removeAttribute(`data-selected`),a[o]?.scrollIntoView({block:`nearest`}),a[o]?.setAttribute(`data-selected`,`true`),IM(o,t),o}function BM(e){return zM(e.getState().selected+1,e)}function VM(e){return zM(e.getState().selected-1,e)}function HM(e){RM(`#${e.getState().listId} [data-selected]`)?.click()}function UM(e,t){let n=t.getState();return n.registeredActions.add(e),()=>{n.registeredActions.delete(e)}}function WM(e,t){MM(()=>({query:e}),t),Promise.resolve().then(()=>{zM(0,t),MM(e=>({empty:e.query.trim().length>0&&e.registeredActions.size===0||!1}),t)})}function GM({clearQuery:e},t){t.updateState(t=>({...t,selected:-1,query:e?``:t.query,empty:e?!1:t.empty}))}var KM={open:NM,close:PM,toggle:FM,updateState:MM,setSelectedAction:IM,setListId:LM,selectAction:zM,selectNextAction:BM,selectPreviousAction:VM,triggerSelectedAction:HM,registerAction:UM,setQuery:WM,clearSpotlightState:GM};function qM(){let e=AM();return[e,{open:()=>NM(e),close:()=>PM(e),toggle:()=>FM(e)}]}var[JM,YM]=qM(),{open:XM,close:ZM,toggle:QM}=YM;function $M(e){let t=e;return t.group!==void 0&&Array.isArray(t.actions)}function eN(e){return Array.isArray(e)?e.map(e=>e.trim()).join(`,`).toLowerCase().trim():typeof e==`string`?e.toLowerCase().trim():``}function tN(e){return e.reduce((e,t)=>`actions`in t?[...e,...t.actions.map(e=>({...e,group:t.group}))]:[...e,t],[])}function nN(e){let t={},n=[];return e.forEach(e=>{e.group?(t[e.group]||(t[e.group]={pushed:!1,data:{group:e.group,actions:[]}}),t[e.group].data.actions.push(e),t[e.group].pushed||(t[e.group].pushed=!0,n.push(t[e.group].data))):n.push(e)}),n}var rN=(e,t)=>{let n=e.trim().toLowerCase(),r=[[],[]];return tN(t).forEach(e=>{e.label?.toLowerCase().includes(n)?r[0].push(e):(e.description?.toLowerCase().includes(n)||eN(e.keywords).includes(n))&&r[1].push(e)}),nN(r.flat())};function iN(e,t){if(!Array.isArray(e))return[];let n=0;return e.reduce((e,r)=>{if(n>=t)return e;if($M(r)){let i=iN(r.actions,t-n);e.push({group:r.group,actions:i}),n+=i.length}else e.push(r),n+=1;return e},[])}var aN={root:`m_d2b315db`,content:`m_3cd250e0`,body:`m_d2abce9b`,search:`m_f366a061`,actionsList:`m_6e463822`,action:`m_d49bb8ef`,actionBody:`m_3d475731`,actionSection:`m_832642f6`,actionLabel:`m_6c2a1345`,actionDescription:`m_a6d9d78d`,empty:`m_82f78f74`,footer:`m_ddcaf054`,actionsGroup:`m_5a3e5f7b`},[oN,sN]=et(`Spotlight component was not found in tree`),cN={dimmedSections:!0,highlightQuery:!1},lN=B((e,t)=>{let{className:n,style:r,classNames:i,styles:a,id:o,description:s,label:c,leftSection:l,rightSection:u,children:d,dimmedSections:f,highlightQuery:p,highlightColor:m,closeSpotlightOnTrigger:h,onClick:g,onMouseDown:_,keywords:v,vars:y,...b}=R(`SpotlightAction`,cN,e),x=sN(),S={classNames:i,styles:a},C=p&&typeof c==`string`?(0,I.jsx)(Nm,{component:`span`,highlight:x.query,color:m,...x.getStyles(`actionLabel`,S),children:c}):(0,I.jsx)(`span`,{...x.getStyles(`actionLabel`,S),children:c});return(0,I.jsx)(ml,{ref:t,"data-action":!0,...x.getStyles(`action`,{className:n,style:r,...S}),...b,onMouseDown:e=>{e.preventDefault(),_?.(e)},onClick:e=>{g?.(e),(h??x.closeOnActionTrigger)&&KM.close(x.store)},tabIndex:-1,children:d||(0,I.jsxs)(I.Fragment,{children:[l&&(0,I.jsx)(z,{component:`span`,mod:{position:`left`,dimmed:f},...x.getStyles(`actionSection`,S),children:l}),(0,I.jsxs)(`span`,{...x.getStyles(`actionBody`,S),children:[C,(0,I.jsx)(`span`,{...x.getStyles(`actionDescription`,S),children:s})]}),u&&(0,I.jsx)(z,{component:`span`,mod:{position:`right`,dimmed:f},...x.getStyles(`actionSection`,S),children:u})]})})});lN.classes=aN,lN.displayName=`@mantine/spotlight/SpotlightAction`;var uN=B((e,t)=>{let{className:n,style:r,styles:i,classNames:a,label:o,children:s,...c}=R(`SpotlightActionsGroup`,null,e);return(0,I.jsx)(z,{...sN().getStyles(`actionsGroup`,{className:n,style:r,classNames:a,styles:i}),ref:t,...c,__vars:{"--spotlight-label":`'${o?.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}'`},children:s})});uN.classes=aN,uN.displayName=`@mantine/core/SpotlightActionsGroup`;var dN=B((e,t)=>{let{className:n,style:r,id:i,children:a,vars:o,classNames:s,styles:c,...l}=R(`SpotlightActionsList`,null,e),u=sN(),d=`mantine-${(0,b.useId)().replace(/:/g,``)}`,f=i||d;return(0,b.useEffect)(()=>(KM.setListId(f,u.store),()=>KM.setListId(``,u.store)),[]),(0,I.jsx)(ul.Autosize,{...u.getStyles(`actionsList`,{className:n,style:r,classNames:s,styles:c}),ref:t,type:`scroll`,scrollbarSize:`var(--spotlight-actions-list-padding)`,offsetScrollbars:`y`,id:f,...l,children:a})});dN.classes=aN,dN.displayName=`@mantine/spotlight/SpotlightActionsList`;var fN=B((e,t)=>{let{className:n,style:r,classNames:i,styles:a,...o}=R(`SpotlightEmpty`,null,e);return(0,I.jsx)(z,{ref:t,...sN().getStyles(`empty`,{classNames:i,styles:a,className:n,style:r}),...o})});fN.classes=aN,fN.displayName=`@mantine/spotlight/SpotlightEmpty`;var pN=B((e,t)=>{let{className:n,style:r,classNames:i,styles:a,...o}=R(`SpotlightFooter`,null,e);return(0,I.jsx)(z,{ref:t,...sN().getStyles(`footer`,{className:n,classNames:i,style:r,styles:a}),...o})});pN.classes=aN,pN.displayName=`@mantine/spotlight/SpotlightFooter`;function mN(e,t){if(!e)return[];let n=()=>KM.open(t);return Array.isArray(e)?e.map(e=>[e,n]):[[e,n]]}var hN={size:600,yOffset:80,zIndex:lt(`max`),overlayProps:{backgroundOpacity:.35,blur:7},transitionProps:{duration:200,transition:`pop`},store:JM,clearQueryOnClose:!0,closeOnActionTrigger:!0,shortcut:`mod + K`,maxHeight:400},gN=B((e,t)=>{let n=R(`SpotlightRoot`,hN,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,store:l,children:u,query:d,onQueryChange:f,transitionProps:p,clearQueryOnClose:m,shortcut:h,tagsToIgnore:g,triggerOnContentEditable:_,disabled:v,onSpotlightOpen:y,onSpotlightClose:b,forceOpened:x,closeOnActionTrigger:S,maxHeight:C,scrollable:w,attributes:T,...E}=n,D=Sr(),{opened:O,query:k}=jM(l),A=typeof d==`string`?d:k,j=e=>{f?.(e),KM.setQuery(e,l)},M=L({name:`Spotlight`,classes:aN,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:T});return yn(mN(h,l),g,_),Lt(()=>{O?y?.():b?.()},[O]),v?null:(0,I.jsx)(oN,{value:{getStyles:M,query:A,setQuery:j,store:l,closeOnActionTrigger:S},children:(0,I.jsx)(rg,{ref:t,...E,withCloseButton:!1,opened:O||!!x,padding:0,onClose:()=>KM.close(l),className:i,style:a,classNames:Fn({theme:D,classNames:[aN,r],props:n,stylesCtx:void 0}),styles:In({theme:D,styles:o,props:n,stylesCtx:void 0}),transitionProps:{...p,onExited:()=>{m&&j(``),KM.clearSpotlightState({clearQuery:m},l),p?.onExited?.()}},__vars:{"--spotlight-max-height":w?F(C):void 0},__staticSelector:`Spotlight`,"data-scrollable":w||void 0,children:u})})});gN.classes=aN,gN.displayName=`@mantine/spotlight/SpotlightRoot`;var _N={size:`lg`},vN=B((e,t)=>{let{classNames:n,styles:r,onKeyDown:i,onChange:a,vars:o,value:s,...c}=R(`SpotlightSearch`,_N,e),l=sN(),u=l.getStyles(`search`),[d,f]=(0,b.useState)(!1),p=e=>{i?.(e),!d&&(e.nativeEvent.code===`ArrowDown`&&(e.preventDefault(),KM.selectNextAction(l.store)),e.nativeEvent.code===`ArrowUp`&&(e.preventDefault(),KM.selectPreviousAction(l.store)),(e.nativeEvent.code===`Enter`||e.nativeEvent.code===`NumpadEnter`)&&(e.preventDefault(),KM.triggerSelectedAction(l.store)))};return(0,I.jsx)(dd,{ref:t,classNames:[{input:u.className},n],styles:[{input:u.style},r],...c,value:s??l.query,onChange:e=>{l.setQuery(e.currentTarget.value),a?.(e)},onKeyDown:p,onCompositionStart:()=>f(!0),onCompositionEnd:()=>f(!1)})});vN.classes=aN,vN.displayName=`@mantine/spotlight/SpotlightSearch`;var yN={size:600,yOffset:80,limit:1/0,zIndex:lt(`max`),overlayProps:{backgroundOpacity:.35,blur:7},transitionProps:{duration:200,transition:`pop`},store:JM,filter:rN,clearQueryOnClose:!0,closeOnActionTrigger:!0,shortcut:`mod + K`},bN=B((e,t)=>{let{searchProps:n,filter:r,query:i,onQueryChange:a,actions:o,nothingFound:s,highlightQuery:c,limit:l,scrollAreaProps:u,...d}=R(`Spotlight`,yN,e),[f,p]=an({value:i,defaultValue:``,finalValue:``,onChange:a}),m=iN(r(f,o),l).map(e=>{if($M(e)){let t=e.actions.map(({id:e,...t})=>(0,I.jsx)(lN,{highlightQuery:c,...t},e));return(0,I.jsx)(uN,{label:e.group,children:t},e.group)}return(0,I.jsx)(lN,{highlightQuery:c,...e},e.id)});return(0,I.jsxs)(gN,{...d,query:f,onQueryChange:p,ref:t,children:[(0,I.jsx)(vN,{...n}),m.length>0&&(0,I.jsx)(dN,{...u,children:m}),m.length===0&&s&&(0,I.jsx)(fN,{children:s})]})});bN.classes=aN,bN.displayName=`@mantine/spotlight/Spotlight`,bN.Search=vN,bN.ActionsList=dN,bN.Action=lN,bN.Empty=fN,bN.ActionsGroup=uN,bN.Footer=pN,bN.Root=gN,bN.open=YM.open,bN.close=YM.close,bN.toggle=YM.toggle;var xN=(0,b.createContext)({submitting:!1});xN.displayName=`FormContext`;function SN(e){let t={};for(let n of Array.from(e.elements))n instanceof HTMLInputElement?CN(t,n):n instanceof HTMLTextAreaElement?t[n.name]=n.value:n instanceof HTMLSelectElement&&wN(t,n);return t}function CN(e,t){t.disabled||(t.type===`checkbox`||t.type===`radio`)&&!t.checked||(e[t.name]=t.value)}function wN(e,t){e[t.name]=t.value}function TN(e){let[t,n]=(0,b.useState)(!1);return(0,I.jsx)(xN.Provider,{value:{submitting:t},children:(0,I.jsx)(`form`,{style:e.style,"data-testid":e.testid,onSubmit:t=>{t.preventDefault();let r=SN(t.target);if(e.onSubmit){n(!0);let t=e.onSubmit(r);t?.then?t.catch(console.error).finally(()=>{n(!1)}):n(!1)}},children:e.children})})}function EN(e){let{children:t,...n}=e,{submitting:r}=(0,b.useContext)(xN);return(0,I.jsx)(U,{type:`submit`,loading:r,...n,children:t})}function DN(e){let t=Z(),n=t.getUserConfiguration();function r(r){let{menuname:i,bookmarkname:a}=r,o=`${e.pathname}?${e.searchParams.toString()}`,s=MC(n);(s.menu?.find(({title:e})=>e===i))?.link?.push({name:a,target:o}),t.updateResource(s).then(r=>{n.menu=r.menu,t.dispatchEvent({type:`change`}),J({color:`green`,message:`Success`}),e.onOk()}).catch(e=>{J({color:`red`,message:Qx(e)})})}return(0,I.jsx)(rg,{title:`Add Bookmark`,closeButtonProps:{"aria-label":`Close`},opened:e.visible,onClose:e.onCancel,children:(0,I.jsx)(TN,{onSubmit:r,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(ON,{config:n}),(0,I.jsx)(yb,{label:`Bookmark Name`,type:`text`,name:`bookmarkname`,placeholder:`Bookmark Name`,defaultValue:e.pathname.split(`/`)[1]||``,withAsterisk:!0}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(EN,{mt:`sm`,children:`OK`})})]})})})}function ON(e){function t(e){return e?.menu?.map(e=>e.title)}let n=t(e.config);return(0,I.jsx)(Eg,{name:`menuname`,defaultValue:n[0],label:`Select Menu Option`,data:n,withAsterisk:!0})}function kN(e){return typeof e.code==`string`?e.code:JSON.stringify(e)}function AN(e){return typeof e.display==`string`?e.display:kN(e)}function jN(e){return{value:kN(e),label:AN(e),resource:e}}function MN(e){return{code:e,display:e}}function NN(e){let t=Z(),{binding:n,creatable:r,clearable:i,expandParams:a,withHelpText:o,...s}=e,c=(0,b.useCallback)(async(e,r)=>{if(!n)return[];let i=(await t.valueSetExpand({count:10,...a,url:n,filter:e},{signal:r})).expansion?.contains??[],o=[];for(let e of i)e.code&&!o.some(t=>t.code===e.code)&&o.push(e);return o},[t,a,n]);return(0,I.jsx)(mM,{...s,creatable:r??!0,clearable:i??!0,toOption:jN,loadOptions:c,onCreate:MN,itemComponent:o?PN:void 0})}var PN=(0,b.forwardRef)(({label:e,resource:t,active:n,...r},i)=>(0,I.jsx)(`div`,{ref:i,...r,children:(0,I.jsxs)(V,{wrap:`nowrap`,gap:`xs`,children:[n&&(0,I.jsx)(EA,{size:12}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{children:e}),(0,I.jsx)(H,{size:`xs`,c:`dimmed`,children:`${t.system}#${t.code}`})]})]})}));function FN(e){let{defaultValue:t,onChange:n,withHelpText:r,...i}=e,[a,o]=(0,b.useState)(t);function s(e){let t=e[0],r=LN(t);o(r),n&&n(r)}return(0,I.jsx)(NN,{defaultValue:IN(a),onChange:s,withHelpText:r??!0,...i})}function IN(e){return e?{code:e}:void 0}function LN(e){return e?.code}function RN(e){let[t,n]=(0,b.useState)(e.defaultValue),r=e.onChange,i=(0,b.useCallback)(e=>{n(e),r&&r(e)},[r]);return(0,I.jsx)(FN,{disabled:e.disabled,"data-autofocus":e.autoFocus,"data-testid":e.testId,defaultValue:t,onChange:i,name:e.name,placeholder:e.placeholder,binding:`https://medplum.com/fhir/ValueSet/resource-types`,creatable:!1,maxValues:e.maxValues??1,clearable:!1,withHelpText:!1})}var zN={navbar:`_navbar_196ng_1`,logoButton:`_logoButton_196ng_6`,menuTitle:`_menuTitle_196ng_25`,link:`_link_196ng_52`,dismissButton:`_dismissButton_196ng_92`,linkLabel:`_linkLabel_196ng_110`,iconWrapper:`_iconWrapper_196ng_121`,alertDot:`_alertDot_196ng_128`,linkCount:`_linkCount_196ng_139`,addBookmarkLink:`_addBookmarkLink_196ng_192`,toggleButton:`_toggleButton_196ng_202`,divider:`_divider_196ng_231`},BN={actionSection:`_actionSection_1l8yv_8`,action:`_action_1l8yv_8`,actionDescription:`_actionDescription_1l8yv_27`,actionsGroup:`_actionsGroup_1l8yv_32`,actionsList:`_actionsList_1l8yv_55`,content:`_content_1l8yv_60`},VN=200;function HN(){return(0,I.jsxs)(G,{gap:`xs`,py:`lg`,children:[(0,I.jsxs)(H,{size:`sm`,c:`dimmed`,children:[`Press `,(0,I.jsx)(fh,{children:`⌘`}),` + `,(0,I.jsx)(fh,{children:`K`}),` to open Search next time.`]}),(0,I.jsxs)(H,{size:`sm`,c:`dimmed`,children:[`(`,(0,I.jsx)(fh,{children:`Ctrl`}),` + `,(0,I.jsx)(fh,{children:`K`}),` on Windows)`]})]})}function UN({patientsOnly:e}){let t=Z(),n=JO(),[r,i]=(0,b.useState)((0,I.jsx)(HN,{})),[a,o]=(0,b.useState)([]),s=Ot(r=>{let a=WN(r);e?t.graphql(a).then(e=>{o(qN(GN(e).filter(e=>e.resourceType===`Patient`),n))}).catch(console.error).finally(()=>i(`No results found`)):Promise.all([t.graphql(a),t.valueSetExpand({url:`https://medplum.com/fhir/ValueSet/resource-types`,filter:r,count:5})]).then(([e,t])=>{o(JN(GN(e),t.expansion?.contains??[],n))}).catch(console.error).finally(()=>i(`No results found`))},VN);return(0,I.jsx)(bN,{actions:a,nothingFound:r,radius:`md`,highlightQuery:!0,searchProps:{leftSection:(0,I.jsx)(bj,{size:`1.2rem`,stroke:2,color:`var(--mantine-color-gray-5)`}),placeholder:`Start typing to search…`,type:`search`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,name:e?`provider-spotlight-search`:`spotlight-search`,"data-1p-ignore":`true`,"data-lpignore":`true`,leftSectionProps:{style:{marginLeft:`calc(var(--mantine-spacing-md) - 12px)`}}},classNames:{body:BN.body,content:BN.content,search:BN.search,actionsList:BN.actionsList,action:BN.action,actionSection:BN.actionSection,actionDescription:BN.actionDescription,actionsGroup:BN.actionsGroup},onQueryChange:e=>{if(!e){s.cancel(),i((0,I.jsx)(HN,{})),o([]);return}i(`Searching...`),s(e)}})}function WN(e){let t=JSON.stringify(e);return NC(e)?`{
160
160
  Patients1: PatientList(_id: ${t}, _count: 1) {
161
161
  resourceType
162
162
  id
@@ -194,21 +194,21 @@ ${o?`${s(`light`)}{${o}}`:``}`}function Dr({color:e,theme:t,autoContrast:n}){ret
194
194
  identifier { system value }
195
195
  subject { display }
196
196
  }
197
- }`.replaceAll(/\s+/g,` `)}function UN(e){let t=[];return e.data.Patients1&&t.push(...e.data.Patients1),e.data.Patients2&&t.push(...e.data.Patients2),e.data.ServiceRequestList&&t.push(...e.data.ServiceRequestList),WN(t)}function WN(e){let t=new Set,n=[];for(let r of e)r.id&&!t.has(r.id)&&(t.add(r.id),n.push(r));return n}function GN(e,t){let n=e.filter(e=>!!e.id).map(e=>({id:e.id,label:e.name?lw(e.name[0]):e.id,description:e.birthDate,leftSection:(0,I.jsx)(Xj,{value:e,radius:`xl`,size:24}),onClick:()=>t(`/Patient/${e.id}`)}));return n.length>0?[{group:`Patients`,actions:n}]:[]}function KN(e,t,n){let r=[],i=t.map(e=>({id:`resource-type-${e.code}`,label:e.display??e.code??``,description:`Resource Type`,onClick:()=>n(`/${e.code}`)}));i.length>0&&r.push({group:`Resource Types`,actions:i});let a=[],o=[];for(let t of e)t.resourceType===`Patient`&&t.id?a.push({id:t.id,label:t.name?lw(t.name[0]):t.id,description:t.birthDate,leftSection:(0,I.jsx)(Xj,{value:t,radius:`xl`,size:24}),onClick:()=>n(`/Patient/${t.id}`)}):t.resourceType===`ServiceRequest`&&t.id&&o.push({id:t.id,label:t.id,description:t.subject?.display,onClick:()=>n(`/ServiceRequest/${t.id}`)});return a.length>0&&r.push({group:`Patients`,actions:a}),o.length>0&&r.push({group:`Service Requests`,actions:o}),r}function qN(e){let t=KO(),n=qO(),r=XN(e.pathname,e.searchParams,e.menus),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(!1);function c(n,r){n.stopPropagation(),n.preventDefault(),t(r),window.innerWidth<768&&e.closeNavbar()}function l(e){e&&t(`/${e}`)}let u=e.opened??!0;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(af.Navbar,{id:`navbar`,className:LN.navbar,children:[e.logo&&(0,I.jsx)(af.Section,{px:`xs`,pt:`xs`,pb:`4px`,children:(0,I.jsx)(ml,{className:LN.logoButton,onClick:e.navbarToggle,"aria-expanded":u,"aria-controls":`navbar`,"aria-label":`Medplum Logo`,children:e.logo})}),(0,I.jsx)(ul,{px:`xs`,pb:`xs`,pt:`sm`,h:`100%`,children:(0,I.jsxs)(af.Section,{grow:!0,children:[e.spotlightEnabled&&(0,I.jsx)(z,{mb:2,children:(0,I.jsx)(Qv,{label:`Search`,position:`right`,transitionProps:{duration:0},disabled:u,children:(0,I.jsxs)(ml,{className:LN.link,onClick:()=>qM.open(),"aria-label":`Search`,children:[(0,I.jsx)(vj,{size:`1.2rem`}),(0,I.jsx)(`span`,{className:LN.linkLabel,"data-opened":u||void 0,children:`Search`})]})})}),e.spotlightEnabled&&(0,I.jsx)(VN,{patientsOnly:e.patientsOnly}),!e.resourceTypeSearchDisabled&&(0,I.jsx)(af.Section,{mb:`sm`,children:(0,I.jsx)(IN,{name:`resourceType`,placeholder:`Resource Type`,maxValues:0,onChange:e=>l(e)},window.location.pathname)}),e.menus?.map((e,t)=>(0,I.jsxs)(b.Fragment,{children:[e.title&&(0,I.jsx)(H,{className:LN.menuTitle,"data-opened":u||void 0,children:e.title}),(0,I.jsx)(G,{gap:`2`,children:e.links?.map(e=>e.notificationCount?(0,I.jsx)(YN,{to:e.href,active:e.href===r?.href,onClick:t=>c(t,e.href),icon:e.icon,label:e.label??``,opened:u,alert:e.alert,notificationCount:e.notificationCount,onDismiss:e.onDismiss},e.href):(0,I.jsx)(JN,{to:e.href,active:e.href===r?.href,onClick:t=>c(t,e.href),icon:e.icon,label:e.label??``,opened:u,alert:e.alert,count:e.count,onDismiss:e.onDismiss},e.href))})]},`menu-${e.title??t}`)),e.displayAddBookmark&&(0,I.jsx)(Qv,{label:`Add Bookmark`,position:`right`,transitionProps:{duration:0},disabled:u,children:(0,I.jsxs)(ml,{className:`${LN.link} ${LN.addBookmarkLink}`,onClick:()=>s(!0),children:[(0,I.jsx)(kA,{}),(0,I.jsx)(`span`,{className:LN.linkLabel,"data-opened":u||void 0,children:`Add Bookmark`})]})})]})}),e.userMenuEnabled&&(0,I.jsxs)(af.Section,{px:`xs`,py:`xs`,children:[(0,I.jsx)(Qv,{label:u?`Close Sidebar`:`Open Sidebar`,position:`right`,transitionProps:{duration:0},children:(0,I.jsx)(ml,{className:LN.toggleButton,"data-opened":u||void 0,"aria-label":u?`Close Sidebar`:`Open Sidebar`,onClick:e.navbarToggle,"aria-expanded":u,"aria-controls":`navbar`,children:(0,I.jsx)(YA,{})})}),(0,I.jsx)(dm,{my:`xs`,className:LN.divider}),(0,I.jsxs)(W,{width:260,shadow:`md`,radius:`md`,position:`top-start`,transitionProps:{transition:`fade-up`},opened:i,onClose:()=>a(!1),children:[(0,I.jsx)(W.Target,{children:(0,I.jsxs)(ml,{className:LN.link,pl:`7`,"aria-label":`User menu`,"data-active":i||void 0,onClick:()=>a(e=>!e),bd:`1px 0 0 0 solid var(--mantine-color-gray-200)`,children:[(0,I.jsx)(Xj,{value:n,radius:`xl`,size:24}),(0,I.jsx)(`span`,{className:LN.linkLabel,"data-opened":u||void 0,children:lw(n?.name?.[0])})]})}),(0,I.jsx)(W.Dropdown,{className:nM.dropdown,children:(0,I.jsx)(uM,{version:e.version,showLayoutVersionToggle:e.showLayoutVersionToggle})})]})]})]}),e.pathname&&e.searchParams&&(0,I.jsx)(TN,{pathname:e.pathname,searchParams:e.searchParams,visible:o,onOk:()=>s(!1),onCancel:()=>s(!1)})]})}function JN(e){let{to:t,icon:n,label:r,onClick:i,active:a,count:o,alert:s,opened:c,onDismiss:l}=e,u=o!==void 0&&o>0,d=n??(0,I.jsx)(hA,{}),f=u&&s&&!c;function p(e){e.preventDefault(),e.stopPropagation(),l?.()}return(0,I.jsx)(Qv,{label:r,position:`right`,transitionProps:{duration:0},disabled:c,children:(0,I.jsxs)(Wj,{to:t,onClick:i,className:LN.link,"data-active":a||void 0,children:[(0,I.jsxs)(`span`,{className:LN.iconWrapper,children:[d,f&&(0,I.jsx)(`span`,{className:LN.alertDot})]}),(0,I.jsx)(`span`,{className:LN.linkLabel,"data-opened":c||void 0,children:r}),u&&(0,I.jsx)(`span`,{className:LN.linkCount,"data-opened":c||void 0,"data-alert":s||void 0,children:o.toLocaleString()}),l&&c&&(0,I.jsx)(Qv,{label:`Dismiss`,openDelay:500,children:(0,I.jsx)(ml,{"aria-label":`Dismiss`,className:LN.dismissButton,onClick:p,children:(0,I.jsx)(Nj,{size:14})})})]})})}function YN(e){let t=tk(e.notificationCount);return(0,I.jsx)(JN,{to:e.to,active:e.active,onClick:e.onClick,icon:e.icon,label:e.label,opened:e.opened,alert:e.alert,count:t,onDismiss:e.onDismiss})}function XN(e,t,n){if(!e||!t||!n)return;let r,i=0;for(let a of n)if(a.links)for(let n of a.links){let a=ZN(e,t,n.href);a>i&&(i=a,r=n)}return r}function ZN(e,t,n){let r=new URL(n,`https://example.com`);if(e!==r.pathname)return 0;let i=[`_count`,`_offset`];for(let[e,n]of r.searchParams.entries())if(!i.includes(e)&&t.get(e)!==n)return 0;let a=1;for(let[e,n]of t.entries())i.includes(e)||r.searchParams.get(e)===n&&a++;return a}var QN=250,$N=59;function eP(e){let[t,n]=(0,b.useState)(localStorage.navbarOpen===`true`),[r]=(0,b.useState)(e.layoutVersion??localStorage.appShellLayoutVersion??`v1`),i=Z(),a=qO();function o(e){localStorage.navbarOpen=e.toString(),n(e)}function s(){o(!1)}function c(){o(!t)}if(i.isLoading())return(0,I.jsx)(Ij,{});let l,u,d,f;return r===`v2`?(l={height:0},u={width:t?QN:$N,breakpoint:0,collapsed:{desktop:!a,mobile:!a}},d=void 0,f=a?(0,I.jsx)(qN,{logo:e.logo,pathname:e.pathname,searchParams:e.searchParams,menus:e.menus,navbarToggle:c,closeNavbar:s,displayAddBookmark:e.displayAddBookmark,resourceTypeSearchDisabled:!0,opened:t,spotlightEnabled:!0,patientsOnly:e.spotlightPatientsOnly,userMenuEnabled:!0,version:e.version,showLayoutVersionToggle:e.showLayoutVersionToggle}):void 0):(l={height:60},u={width:QN,breakpoint:`sm`,collapsed:{desktop:!a||!t,mobile:!a||!t}},d=a&&(0,I.jsx)(DM,{pathname:e.pathname,searchParams:e.searchParams,headerSearchDisabled:e.headerSearchDisabled,logo:e.logo,version:e.version,navbarOpen:t,navbarToggle:c,notifications:e.notifications}),f=a&&t?(0,I.jsx)(qN,{pathname:e.pathname,searchParams:e.searchParams,menus:e.menus,navbarToggle:c,closeNavbar:s,displayAddBookmark:e.displayAddBookmark,resourceTypeSearchDisabled:e.resourceTypeSearchDisabled,patientsOnly:e.spotlightPatientsOnly}):void 0),(0,I.jsxs)(af,{header:l,navbar:u,padding:0,children:[d,f,(0,I.jsx)(af.Main,{className:Lj.main,children:(0,I.jsx)(Fj,{children:(0,I.jsx)(b.Suspense,{fallback:(0,I.jsx)(Ij,{}),children:e.children})})})]})}var tP=`https://ccda.medplum.com`,nP=`https://ccda-validator.medplum.com/`;function rP(e){let{url:t}=e,[n,r]=(0,b.useState)(!1),i=(0,b.useRef)(null),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{t&&n&&i.current&&(Hj(i.current,{command:`loadCcdaXml`,value:t}).catch(console.error),r(!1))},[t,n]),t?(0,I.jsxs)(`div`,{"data-testid":`ccda-iframe`,style:{maxWidth:e.maxWidth},children:[(0,I.jsx)(`div`,{style:{minHeight:400},children:(0,I.jsx)(`iframe`,{title:`C-CDA Viewer`,width:`100%`,height:`400`,ref:i,src:tP,allowFullScreen:!0,frameBorder:0,seamless:!0,onLoad:()=>r(!0)})}),(0,I.jsxs)(`div`,{style:{marginTop:`10px`,marginBottom:`10px`,display:`flex`,alignItems:`center`},children:[(0,I.jsx)(U,{type:`button`,onClick:async()=>{if(t)try{c(!0);let e=await(await fetch(t)).text(),n=new FormData;n.append(`ccdaFile`,new Blob([e],{type:`text/xml`}),`ccda.xml`);let r=await fetch(`${nP}referenceccdaservice/?validationObjective=C-CDA_IG_Plus_Vocab&referenceFileName=No%20scenario%20File&curesUpdate=true&severityLevel=WARNING`,{method:`POST`,body:n,credentials:`omit`,redirect:`manual`});if(!r.ok)throw Error(`Validation failed: ${r.status} ${r.statusText}`);o(await r.json())}catch(e){o(void 0),console.error(`CCDA validation error:`,e)}finally{c(!1)}},disabled:s,children:s?`Validating...`:`Validate`}),a&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{style:{marginLeft:`15px`},children:[(0,I.jsx)(`strong`,{children:`Validation Results:`}),` `,a?a.resultsMetaData.resultMetaData.filter(e=>e?.type.includes(`Error`)).reduce((e,t)=>e+(t.count||0),0):0,` errors found`]}),(0,I.jsx)(U,{type:`button`,onClick:()=>{a&&Uj(JSON.stringify(a,null,2),`ccda-validation-results`)},color:`green`,style:{marginLeft:`auto`},children:`Download Full Results`})]})]})]}):null}function iP(e){let{maxRetries:t=5,...n}=e,[r,i]=(0,b.useState)(0),[a,o]=(0,b.useState)(`fetching`),s=(0,b.useRef)(void 0);return(0,b.useEffect)(()=>()=>{s.current!==void 0&&clearTimeout(s.current)},[]),a===`failed`?(0,I.jsx)(`div`,{className:`image-placeholder`,children:`Image unavailable`}):a===`backoff`?(0,I.jsx)(cu,{}):(0,I.jsx)(`img`,{onLoad:()=>o(`loaded`),onError:()=>{if(r>=t){o(`failed`);return}o(`backoff`);let e=Math.min(1e3*2**r,16e3);s.current=setTimeout(()=>{i(e=>e+1),o(`fetching`),s.current=void 0},e)},...n})}function aP(e){let{contentType:t,url:n,title:r}=e.value??{},i=QO(n);return i?(0,I.jsxs)(`div`,{"data-testid":`attachment-display`,children:[t?.startsWith(`image/`)&&(0,I.jsx)(iP,{"data-testid":`attachment-image`,style:{maxWidth:e.maxWidth},src:i,alt:r}),t?.startsWith(`video/`)&&(0,I.jsx)(`video`,{"data-testid":`attachment-video`,style:{maxWidth:e.maxWidth},controls:!0,children:(0,I.jsx)(`source`,{type:t,src:i})}),(t?.startsWith(`text/`)||t===`application/json`||t===`application/pdf`)&&(0,I.jsx)(`div`,{"data-testid":`attachment-iframe`,style:{maxWidth:e.maxWidth,minHeight:400},children:(0,I.jsx)(`iframe`,{title:`Attachment`,width:`100%`,height:`400`,src:i+`#navpanes=0`,allowFullScreen:!0,frameBorder:0,seamless:!0})}),t===ZE.CDA_XML&&(0,I.jsx)(rP,{url:i}),(0,I.jsx)(`div`,{"data-testid":`download-link`,style:{padding:`2px 16px 16px 16px`},children:(0,I.jsx)(Pd,{href:n,"data-testid":`attachment-details`,target:`_blank`,rel:`noopener noreferrer`,download:oP(r),children:r||`Download`})})]}):null}function oP(e){return e?.includes(`.`)?e:void 0}var sP={root:`_root_1bd5a_1`,compact:`_compact_1bd5a_19`};function cP(e){let{children:t,compact:n}=e;return(0,I.jsx)(`dl`,{className:Mn(sP.root,{[sP.compact]:n}),children:t})}function lP(e){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`dt`,{children:e.term}),(0,I.jsx)(`dd`,{children:e.children})]})}function uP(e){let t=e.values?.map((t,n)=>(0,I.jsx)(`div`,{children:(0,I.jsx)(aP,{value:t,maxWidth:e.maxWidth})},`attatchment-`+n)),n;if(e.includeDescriptionListEntry){if(e.property===void 0)throw Error(`props.property is required when includeDescriptionListEntry is true`);if(!wC(e.path))throw Error(`props.path is required when includeDescriptionListEntry is true`);n=(0,I.jsx)(lP,{term:Iw(e.path.split(`.`).pop()),children:t})}else n=(0,I.jsx)(I.Fragment,{children:t});return n}function dP(e){let t=Z(),n=(0,b.useRef)(null);function r(e){Rj(e),n.current?.click()}function i(e){Rj(e);let t=e.target.files;t&&Array.from(t).forEach(a)}function a(n){n&&n.name&&(e.onUploadStart&&e.onUploadStart(),t.createAttachment({data:n,contentType:n.type||`application/octet-stream`,filename:n.name,securityContext:e.securityContext,onProgress:e.onUploadProgress}).then(t=>e.onUpload(t)).catch(t=>{e.onUploadError&&e.onUploadError(Zx(t))}))}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{disabled:e.disabled,type:`file`,"data-testid":`upload-file-input`,style:{display:`none`},ref:n,onChange:e=>i(e)}),e.children({onClick:r,disabled:e.disabled})]})}function fP(e){let[t,n]=(0,b.useState)(e.defaultValue??[]);function r(t){n(t),e.onChange&&e.onChange(t)}return(0,I.jsxs)(`table`,{style:{width:`100%`},children:[(0,I.jsxs)(`colgroup`,{children:[(0,I.jsx)(`col`,{width:`97%`}),(0,I.jsx)(`col`,{width:`3%`})]}),(0,I.jsxs)(`tbody`,{children:[t.map((n,i)=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:(0,I.jsx)(aP,{value:n,maxWidth:200})}),(0,I.jsx)(`td`,{children:(0,I.jsx)(gu,{disabled:e.disabled,title:`Remove`,variant:`subtle`,size:`sm`,color:`gray`,onClick:e=>{Rj(e);let n=t.slice();n.splice(i,1),r(n)},children:(0,I.jsx)(OA,{})})})]},`${i}-${t.length}`)),(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{}),(0,I.jsx)(`td`,{children:(0,I.jsx)(dP,{disabled:e.disabled,onUpload:e=>{r([...t,e])},children:e=>(0,I.jsx)(gu,{...e,title:`Add`,variant:`subtle`,size:`sm`,color:e.disabled?`gray`:`green`,children:(0,I.jsx)(AA,{})})})})]})]})]})}function pP(e){let[t,n]=(0,b.useState)(e.defaultValue);function r(t){n(t),e.onChange&&e.onChange(t)}return t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(aP,{value:t,maxWidth:200}),(0,I.jsx)(U,{disabled:e.disabled,onClick:e=>{Rj(e),r(void 0)},children:`Remove`})]}):(0,I.jsx)(dP,{disabled:e.disabled,securityContext:e.securityContext,onUpload:r,children:e=>(0,I.jsx)(U,{...e,children:`Upload...`})})}var mP={root:`_root_1vii2_1`};function hP(e){let{children:t,...n}=e;return(0,I.jsx)(am,{className:mP.root,...n,children:t})}var gP={paper:`_paper_1igaj_1`,fill:`_fill_1igaj_20`};function _P(e){let{width:t,fill:n,className:r,children:i,...a}=e,o=t?{maxWidth:t}:void 0;return(0,I.jsx)(yl,{className:Mn(gP.paper,n&&gP.fill,r),style:o,shadow:`sm`,radius:`sm`,withBorder:!0,...a,children:i})}function vP(e){let{children:t,...n}=e;return(0,I.jsx)(hP,{children:(0,I.jsx)(_P,{...n,children:t})})}function yP(e){return(0,I.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 180 180`,style:{width:e.size,height:e.size},children:[(0,I.jsx)(`title`,{children:`Medplum Logo`}),(0,I.jsx)(`path`,{fill:e.fill??`#9c36b5`,d:`M84 56c-3-15-15-24-23-28l5-10c8 2 14 8 20 14 0-12 1-16 5-21 8-9 13-9 41-9 0 7 1 18-3 24-7 9-16 7-41 8 5 8 7 14 8 22 36-24 74-7 74 39 0 42-40 83-80 83s-80-41-80-83c0-46 38-63 74-39Zm-3 43H65c-4 0-7 3-7 7v4c0 4 3 7 7 7h16v16c0 4 3 7 7 7h4c4 0 7-3 7-7v-16h16c4 0 7-3 7-7v-4c0-4-3-7-7-7H99V83c0-4-3-7-7-7h-4c-4 0-7 3-7 7z`})]})}function bP(e,t){return e?.issue?.filter(e=>CP(e.expression?.[0],t))?.map(e=>e.details?.text)?.join(`
198
- `)}function xP(e,t){return e?.issue?.filter(e=>CP(e.expression?.[0],t))}var SP=/\[\d+\]/;function CP(e,t){if((typeof e==`string`&&SP.test(e))!==(typeof t==`string`&&SP.test(t))&&(e=e?.replace(SP,``),t=t?.replace(SP,``)),e===t)return!0;if(!e||!t)return!1;let n=e.indexOf(`.`);if(n>=0&&e.substring(n+1)===t)return!0;let r=t.indexOf(`.`);return r>=0&&t.substring(r+1)===e}function wP(e){let{onSuccess:t}=e,n=Z(),[r,i]=(0,b.useState)(),[a,o]=(0,b.useState)(!1);return(0,I.jsx)(vP,{width:450,children:(0,I.jsxs)(CN,{onSubmit:e=>{i(void 0),n.post(`auth/changepassword`,e).then(()=>{o(!0),t?.()}).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:`Change password`})]}),!a&&(0,I.jsxs)(G,{gap:`xl`,mt:`xl`,children:[(0,I.jsx)(sv,{name:`oldPassword`,label:`Old password`,required:!0,autoFocus:!0,error:bP(r,`oldPassword`)}),(0,I.jsx)(sv,{name:`newPassword`,label:`New password`,required:!0,error:bP(r,`newPassword`)}),(0,I.jsx)(sv,{name:`confirmPassword`,label:`Confirm new password`,required:!0,error:bP(r,`confirmPassword`)}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,children:(0,I.jsx)(U,{type:`submit`,children:`Change password`})})]}),a&&(0,I.jsx)(`div`,{"data-testid":`success`,children:`Password changed successfully`})]})})}function TP(e){let[t,n]=(0,b.useState)();return(0,I.jsxs)(CN,{onSubmit:t=>{n(void 0),e.onSubmit(t)?.catch(e=>n(Qx(e)))},children:[(0,I.jsxs)(Kp,{style:{flexDirection:`column`},children:[(0,I.jsx)(yP,{size:32}),(0,I.jsx)(q,{order:3,py:`lg`,children:e.title}),!e.qrCodeUrl&&e.description&&(0,I.jsx)(H,{c:`dimmed`,mb:`lg`,mt:`-lg`,children:e.description})]}),t&&(0,I.jsx)(Dd,{icon:(0,I.jsx)(uA,{size:16}),title:`Error`,color:`red`,mb:`lg`,children:t}),e.qrCodeUrl&&(0,I.jsx)(Kp,{children:(0,I.jsxs)(G,{mb:`xl`,children:[e.description&&(0,I.jsx)(H,{c:`dimmed`,mb:`md`,mt:`-lg`,ta:`center`,children:e.description}),(0,I.jsx)(Im,{src:e.qrCodeUrl,alt:`Multi Factor Auth QR Code`,w:`60%`,mx:`auto`,radius:`md`,p:`xs`,bg:`var(--mantine-color-white)`,style:{border:`1px solid light-dark(var(--mantine-color-gray-2), var(--mantine-color-dark-4))`}})]})}),(0,I.jsx)(G,{gap:`sm`,children:(0,I.jsx)(yb,{name:`token`,label:`MFA code`,autoComplete:`one-time-code`,required:!0,autoFocus:!0})}),(0,I.jsx)(G,{gap:`xs`,pt:`md`,children:(0,I.jsx)(wN,{fullWidth:!0,children:e.buttonText})})]})}function EP(e){let{outcome:t,issues:n,...r}=e,i=t?.issue||n;return!i||i.length===0?null:(0,I.jsx)(Dd,{icon:(0,I.jsx)(uA,{size:16}),color:`red`,...r,children:i.map(e=>(0,I.jsx)(`div`,{"data-testid":`text-field-error`,children:eS(e)},e.details?.text))})}function DP(e){let t=Z(),[n,r]=(0,b.useState)(),i=xP(n,void 0);return(0,I.jsxs)(CN,{onSubmit:async n=>{try{e.handleAuthResponse(await t.startNewProject({login:e.login,projectName:n.projectName}))}catch(e){r(Zx(e))}},children:[(0,I.jsxs)(_d,{direction:`column`,align:`center`,justify:`center`,children:[(0,I.jsx)(yP,{size:32}),(0,I.jsx)(q,{order:3,py:`lg`,children:`Create a new project`})]}),(0,I.jsx)(EP,{issues:i,mb:`lg`}),(0,I.jsx)(G,{gap:`sm`,children:(0,I.jsx)(yb,{name:`projectName`,label:`Project Name`,placeholder:`My Project`,required:!0,autoFocus:!0,error:bP(n,`projectName`)})}),(0,I.jsxs)(G,{gap:`xs`,mt:`md`,children:[(0,I.jsx)(wN,{fullWidth:!0,children:`Create Project`}),(0,I.jsxs)(H,{c:`dimmed`,size:`xs`,pt:`lg`,ta:`center`,children:[`By clicking "Create Project" you agree to the Medplum`,` `,(0,I.jsx)(Pd,{href:`https://www.medplum.com/privacy`,children:`Privacy\xA0Policy`}),` and `,(0,I.jsx)(Pd,{href:`https://www.medplum.com/terms`,children:`Terms\xA0of\xA0Service`}),`.`]})]})]})}function OP(e,t){let n=document.getElementsByTagName(`head`)[0],r=document.createElement(`script`);r.async=!0,r.src=e,r.onload=t??null,n.appendChild(r)}function kP(e){let{googleClientId:t,handleGoogleCredential:n}=e,r=(0,b.useRef)(null),[i,a]=(0,b.useState)(typeof google<`u`),o=(0,b.useRef)(!1),s=(0,b.useRef)(!1);return(0,b.useEffect)(()=>{if(typeof google>`u`){OP(`https://accounts.google.com/gsi/client`,()=>a(!0));return}o.current||=(google.accounts.id.initialize({client_id:t,callback:n}),!0),r.current&&!s.current&&(google.accounts.id.renderButton(r.current,{type:`standard`,logo_alignment:`center`,width:r.current.clientWidth}),s.current=!0)},[t,i,n]),t?(0,I.jsx)(z,{ref:r,w:`100%`,h:40,display:`flex`,style:{justifyContent:`center`}}):null}function AP(e){if(e)return e;let t=LE.getOrigin();if(t&&[].includes(t))return`__GOOGLE_CLIENT_ID__`}function jP(e){typeof grecaptcha>`u`&&OP(`https://www.google.com/recaptcha/api.js?render=`+e)}function MP(e){return new Promise((t,n)=>{grecaptcha.ready(async()=>{try{t(await grecaptcha.execute(e,{action:`submit`}))}catch(e){n(e)}})})}function NP(e){let t=AP(e.googleClientId),n=e.recaptchaSiteKey,r=Z(),[i,a]=(0,b.useState)(),o=xP(i,void 0);return(0,b.useEffect)(()=>{n&&jP(n)},[n]),(0,I.jsxs)(CN,{onSubmit:async t=>{a(void 0);try{let i=``;n&&(i=await MP(n)),e.handleAuthResponse(await r.startNewUser({projectId:e.projectId,clientId:e.clientId,firstName:t.firstName,lastName:t.lastName,email:t.email,password:t.password,remember:t.remember===`true`,recaptchaSiteKey:n,recaptchaToken:i}))}catch(e){a(Zx(e))}},children:[(0,I.jsx)(_d,{direction:`column`,align:`center`,justify:`center`,children:e.children}),(0,I.jsx)(EP,{issues:o,mb:`lg`}),t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(z,{style:{minHeight:40},children:(0,I.jsx)(kP,{googleClientId:t,handleGoogleCredential:async t=>{try{e.handleAuthResponse(await r.startGoogleLogin({googleClientId:t.clientId,googleCredential:t.credential,projectId:e.projectId,createUser:!0}))}catch(e){a(Zx(e))}}})}),(0,I.jsx)(dm,{label:`or`,labelPosition:`center`,my:`lg`})]}),(0,I.jsxs)(G,{gap:`sm`,children:[(0,I.jsx)(yb,{name:`firstName`,type:`text`,label:`First name`,placeholder:`First name`,required:!0,autoFocus:!0,error:bP(i,`firstName`)}),(0,I.jsx)(yb,{name:`lastName`,type:`text`,label:`Last name`,placeholder:`Last name`,required:!0,error:bP(i,`lastName`)}),(0,I.jsx)(yb,{name:`email`,type:`email`,label:`Email`,placeholder:`name@domain.com`,required:!0,error:bP(i,`email`)}),(0,I.jsx)(sv,{name:`password`,label:`Password`,autoComplete:`off`,required:!0,error:bP(i,`password`)})]}),(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsx)(lp,{id:`remember`,name:`remember`,label:`Remember me`,size:`xs`,style:{lineHeight:1},pt:`md`,pb:`xs`}),(0,I.jsx)(wN,{fullWidth:!0,children:`Register Account`}),(0,I.jsxs)(H,{c:`dimmed`,size:`xs`,pt:`lg`,ta:`center`,children:[`By clicking "Register Account" you agree to the Medplum`,` `,(0,I.jsx)(Pd,{href:`https://www.medplum.com/privacy`,children:`Privacy\xA0Policy`}),` and `,(0,I.jsx)(Pd,{href:`https://www.medplum.com/terms`,children:`Terms\xA0of\xA0Service`}),`.`]}),(0,I.jsxs)(H,{c:`dimmed`,size:`xs`,ta:`center`,children:[`This site is protected by reCAPTCHA and the Google`,` `,(0,I.jsx)(Pd,{href:`https://policies.google.com/privacy`,children:`Privacy\xA0Policy`}),` and `,(0,I.jsx)(Pd,{href:`https://policies.google.com/terms`,children:`Terms\xA0of\xA0Service`}),` apply.`]})]})]})}function PP(e){let{type:t,projectId:n,clientId:r,googleClientId:i,recaptchaSiteKey:a,onSuccess:o}=e,s=Z(),[c,l]=(0,b.useState)(e.login),[u,d]=(0,b.useState)(),[f,p]=(0,b.useState)(!1);(0,b.useEffect)(()=>{t===`patient`&&c&&s.startNewPatient({login:c,projectId:n}).then(e=>s.processCode(e.code)).then(()=>o()).catch(e=>d(Zx(e)))},[s,t,n,c,o]);function m(e){e.code&&s.processCode(e.code).then(()=>o()).catch(e=>d(Zx(e))),e.login&&l(e.login),e.emailVerificationRequired&&p(!0)}return(0,I.jsxs)(vP,{width:400,px:`xl`,py:`xl`,bdrs:`md`,children:[(0,I.jsx)(EP,{issues:xP(u,void 0),mb:`lg`}),!c&&(0,I.jsx)(NP,{projectId:n,clientId:r,googleClientId:i,recaptchaSiteKey:a,handleAuthResponse:m,children:e.children}),f&&(0,I.jsx)(`div`,{children:`Please check your email for a verification link. Click the link to continue setting up your account.`}),c&&!f&&t===`project`&&(0,I.jsx)(DP,{login:c,handleAuthResponse:m})]})}function FP(e){let{projectId:t,recaptchaSiteKey:n,onSuccess:r,onSignIn:i,onRegister:a}=e,o=Z(),[s,c]=(0,b.useState)(),[l,u]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{n&&jP(n)},[n]),(0,I.jsx)(vP,{width:400,px:`xl`,py:`xl`,bdrs:`md`,children:(0,I.jsxs)(CN,{onSubmit:async e=>{c(void 0);try{let i=``;n&&(i=await MP(n)),await o.post(`auth/resetpassword`,{...e,projectId:t,recaptchaToken:i}),u(!0),r?.()}catch(e){c(Zx(e))}},children:[(0,I.jsxs)(_d,{direction:`column`,align:`center`,justify:`center`,children:[(0,I.jsx)(yP,{size:32}),(0,I.jsx)(q,{order:3,py:`lg`,children:`Reset your password`})]}),(0,I.jsx)(EP,{issues:xP(s,void 0),mb:`lg`}),!l&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{gap:`sm`,mb:`md`,children:(0,I.jsx)(yb,{name:`email`,type:`email`,label:`Email`,placeholder:`name@domain.com`,required:!0,autoFocus:!0,error:bP(s,`email`)})}),(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsx)(wN,{fullWidth:!0,children:`Reset Password`}),i&&(0,I.jsx)(H,{size:`sm`,mt:`lg`,c:`dimmed`,style:{textAlign:`center`},"data-dashlane-ignore":`true`,"data-lp-ignore":`true`,"data-no-autofill":`true`,"data-form-type":`navigation`,children:(0,I.jsx)(Pd,{onClick:i,children:`Back to Sign In`})}),a&&(0,I.jsxs)(H,{size:`sm`,mt:`none`,c:`dimmed`,style:{textAlign:`center`},"data-dashlane-ignore":`true`,"data-lp-ignore":`true`,"data-no-autofill":`true`,"data-form-type":`navigation`,children:[`Don't have an account? `,(0,I.jsx)(Pd,{onClick:a,children:`Sign Up`})]})]})]}),l&&(0,I.jsx)(H,{c:`dimmed`,size:`sm`,ta:`center`,mt:`md`,children:`If the account exists on our system, a password reset email will be sent.`})]})})}function IP(e){let{id:t,secret:n,onSuccess:r,onSignIn:i}=e,a=Z(),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(!1);return(0,I.jsxs)(vP,{width:450,children:[(0,I.jsx)(EP,{issues:xP(o,void 0)}),(0,I.jsxs)(CN,{onSubmit:e=>{if(e.password!==e.confirmPassword){s(Ux(`Passwords do not match`,`confirmPassword`));return}s(void 0),a.post(`auth/setpassword`,{id:t,secret:n,password:e.password}).then(()=>{l(!0),r?.()}).catch(e=>s(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:`Set password`})]}),!c&&(0,I.jsxs)(G,{children:[(0,I.jsx)(sv,{name:`password`,label:`New password`,required:!0,error:bP(o,`password`)}),(0,I.jsx)(sv,{name:`confirmPassword`,label:`Confirm new password`,required:!0,error:bP(o,`confirmPassword`)}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,children:(0,I.jsx)(U,{type:`submit`,children:`Set password`})})]}),c&&(0,I.jsxs)(`div`,{"data-testid":`success`,children:[`Password set. You can now\xA0`,i?(0,I.jsx)(Pd,{component:`button`,type:`button`,onClick:i,children:`sign in`}):`sign in`,`.`]})]})]})}function LP(e){let[t,n]=(0,b.useState)();return t?(0,I.jsx)(zP,{email:t,resetEmail:()=>n(void 0),...e}):(0,I.jsx)(RP,{setEmail:n,...e})}function RP(e){let{setEmail:t,onRegister:n,handleAuthResponse:r,children:i,disableEmailAuth:a,...o}=e,s=Z(),c=!e.disableGoogleAuth&&AP(e.googleClientId),[l,u]=(0,b.useState)(),d=xP(l,void 0),f=(0,b.useCallback)(async e=>{if(!e.authorizeUrl)return!1;let t=JSON.stringify({...await s.ensureCodeChallenge(o),domain:e.domain,returnTo:LE.getLocation()}),n=new URL(e.authorizeUrl);return n.searchParams.set(`state`,t),LE.assign(n.toString()),!0},[s,o]),p=(0,b.useCallback)(async e=>{await f(await s.post(`auth/method`,{email:e.email}))||t(e.email)},[s,f,t]),m=(0,b.useCallback)(async e=>{try{let t=await s.startGoogleLogin({...o,googleCredential:e.credential});await f(t)||r(t)}catch(e){u(Zx(e))}},[s,o,f,r]);return(0,I.jsxs)(CN,{onSubmit:p,children:[(0,I.jsx)(_d,{direction:`column`,align:`center`,justify:`center`,children:i}),(0,I.jsx)(EP,{issues:d,mb:`lg`}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(z,{style:{minHeight:40},children:(0,I.jsx)(kP,{googleClientId:c,handleGoogleCredential:m})}),!a&&(0,I.jsx)(dm,{label:`or`,labelPosition:`center`,my:`lg`})]}),!a&&(0,I.jsx)(yb,{name:`email`,type:`email`,label:`Email`,mb:`md`,placeholder:`name@domain.com`,required:!0,autoFocus:!0,error:bP(l,`email`),"data-testid":`auth.email`}),(0,I.jsxs)(G,{gap:`xs`,children:[!a&&(0,I.jsx)(wN,{fullWidth:!0,children:`Continue`}),n&&(0,I.jsxs)(H,{size:`sm`,mt:`lg`,c:`dimmed`,style:{textAlign:`center`},"data-dashlane-ignore":`true`,"data-lp-ignore":`true`,"data-no-autofill":`true`,"data-form-type":`navigation`,children:[`Don’t have an account? `,(0,I.jsx)(Pd,{onClick:n,children:`Register`})]})]})]})}function zP(e){let{onForgotPassword:t,handleAuthResponse:n,children:r,...i}=e,a=Z(),[o,s]=(0,b.useState)(),c=xP(o,void 0);return(0,I.jsxs)(CN,{onSubmit:(0,b.useCallback)(e=>a.startLogin({...i,password:e.password,remember:e.remember===`on`}).then(n).catch(e=>s(Zx(e))),[a,i,n]),children:[(0,I.jsx)(_d,{direction:`column`,align:`center`,justify:`center`,children:r}),(0,I.jsx)(EP,{issues:c,mb:`lg`}),(0,I.jsxs)(G,{gap:`sm`,children:[(0,I.jsx)(yb,{label:`Email`,value:e.email,disabled:!0,rightSectionWidth:36,rightSection:(0,I.jsx)(gu,{variant:`subtle`,color:`gray`,onClick:e.resetEmail,"aria-label":`Change email`,children:(0,I.jsx)(cj,{size:`1rem`,stroke:1.5})})}),(0,I.jsx)(sv,{name:`password`,label:`Password`,autoComplete:`off`,required:!0,autoFocus:!0,error:bP(o,`password`),"data-testid":`auth.password`})]}),(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsx)(lp,{id:`remember`,name:`remember`,label:`Remember me`,size:`xs`,style:{lineHeight:1},pt:`md`,pb:`xs`}),(0,I.jsx)(wN,{children:`Sign In`}),t&&(0,I.jsx)(H,{size:`sm`,mt:`lg`,c:`dimmed`,style:{textAlign:`center`},"data-dashlane-ignore":`true`,"data-lp-ignore":`true`,"data-no-autofill":`true`,"data-form-type":`navigation`,children:(0,I.jsx)(Pd,{onClick:t,children:`Reset Password`})})]})]})}function BP(e){let t=Z(),n=If(),[r,i]=(0,b.useState)(``),[a,o]=(0,b.useState)();function s(e){return!!e?.toLowerCase()?.includes(r.toLowerCase())}function c(e){return s(e.profile?.display)||s(e.project?.display)||s(VP(e))}function l(n){t.post(`auth/profile`,{login:e.login,profile:n}).then(e.handleAuthResponse).catch(e=>o(Zx(e)))}let u=e.memberships.filter(c).slice(0,10).map(e=>(0,I.jsx)(zf.Option,{value:e.id,className:Qj.interactive,children:(0,I.jsx)(eM,{membership:e,label:VP(e)})},e.id));return(0,I.jsxs)(G,{gap:`0`,children:[(0,I.jsxs)(_d,{justify:`center`,align:`center`,direction:`column`,wrap:`nowrap`,children:[(0,I.jsx)(yP,{size:32}),(0,I.jsx)(q,{order:3,py:`lg`,children:`Choose a Project`})]}),(0,I.jsx)(EP,{outcome:a,mb:`lg`}),(0,I.jsxs)(zf,{store:n,onOptionSubmit:l,children:[(0,I.jsx)(zf.EventsTarget,{children:(0,I.jsx)(yb,{placeholder:`Search`,value:r,mb:`md`,autoFocus:!0,leftSection:(0,I.jsx)(vj,{size:16}),onChange:e=>{i(e.currentTarget.value),n.updateSelectedOptionIndex()}})}),(0,I.jsx)(`div`,{children:(0,I.jsx)(zf.Options,{style:{marginLeft:`-10px`,marginRight:`-10px`,marginBottom:`-10px`},children:u.length>0?u:(0,I.jsx)(zf.Empty,{children:`Nothing found...`})})})]}),(0,I.jsx)(H,{size:`sm`,ta:`center`,mt:`md`,children:(0,I.jsx)(Pd,{component:`button`,type:`button`,onClick:()=>{window.location.href=`/signin?project=new&login=${e.login}`},children:`Create a new project`})})]})}function VP(e){return _C(e,`https://medplum.com/identifier/label`)}var HP=/^patient\/Condition\.(?:\*|c?r?u?d?s?)$/,UP=`?category=http://terminology.hl7.org/CodeSystem/condition-category|encounter-diagnosis`,WP=`?category=http://terminology.hl7.org/CodeSystem/condition-category|problem-list-item`,GP=`?category=http://hl7.org/fhir/us/core/CodeSystem/condition-category|health-concern`,KP=/^patient\/Observation\.(?:\*|c?r?u?d?s?)$/,qP=`?category=http://hl7.org/fhir/us/core/CodeSystem/us-core-observation-category|clinical-test`,JP=`?category=http://terminology.hl7.org/CodeSystem/observation-category|laboratory`,YP=`?category=http://terminology.hl7.org/CodeSystem/observation-category|social-history`,XP=`?category=http://hl7.org/fhir/us/core/CodeSystem/us-core-category|sdoh`,ZP=`?category=http://terminology.hl7.org/CodeSystem/observation-category|survey`,QP=`?category=http://terminology.hl7.org/CodeSystem/observation-category|vital-signs`;function $P(e){let t=Z();return(0,I.jsx)(CN,{onSubmit:n=>{t.post(`auth/scope`,{login:e.login,scope:Object.keys(n).join(` `)}).then(e.handleAuthResponse).catch(console.log)},children:(0,I.jsxs)(G,{children:[(0,I.jsxs)(_d,{direction:`column`,align:`center`,justify:`center`,children:[(0,I.jsx)(yP,{size:32}),(0,I.jsx)(q,{order:3,py:`lg`,children:`Choose scope`})]}),(0,I.jsx)(G,{children:(e.scope??`openid`).split(` `).map(e=>{let t;return HP.test(e)?t=[e+UP,e+WP,e+GP]:KP.test(e)&&(t=[e+qP,e+JP,e+YP,e+XP,e+ZP,e+QP]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(lp,{id:e,name:e,label:e,defaultChecked:!0},e),t?.map(e=>(0,I.jsx)(lp,{id:e,name:e,label:e},e))]},e+`_group`)})}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,children:(0,I.jsx)(wN,{fullWidth:!0,children:`Set Scope`})})]})})}function eF(e){let{login:t,chooseScopes:n,onSuccess:r,onForgotPassword:i,onRegister:a,onCode:o,...s}=e,c=Z(),[l,u]=(0,b.useState)(),d=(0,b.useRef)(!1),[f,p]=(0,b.useState)(!1),[m,h]=(0,b.useState)(),[g,_]=(0,b.useState)(!1),[v,y]=(0,b.useState)(),x=(0,b.useCallback)(e=>{o?o(e):c.processCode(e).then(()=>{r&&r()}).catch(e=>J({color:`red`,message:Qx(e)}))},[c,o,r]),S=(0,b.useCallback)(e=>{p(!!e.mfaEnrollRequired),h(e.enrollQrCode),_(!!e.mfaRequired),e.login&&u(e.login),e.memberships&&y(e.memberships),e.code&&(n?y(void 0):x(e.code))},[n,x]),C=(0,b.useCallback)(e=>{x(e.code)},[x]);return(0,b.useEffect)(()=>{t&&!d.current&&!l&&(d.current=!0,c.get(`auth/login/`+t).then(S).catch(e=>J({color:`red`,message:Qx(e)})))},[c,t,d,l,S]),(0,I.jsx)(vP,{width:400,px:`xl`,py:`xl`,bdrs:`md`,children:l?f&&m?(0,I.jsx)(TP,{title:`Enroll in MFA`,description:`Scan this QR code with your authenticator app.`,buttonText:`Enroll`,qrCodeUrl:m,onSubmit:async e=>{S(await c.post(`auth/mfa/login-enroll`,{login:l,token:e.token}))}}):g?(0,I.jsx)(TP,{title:`Enter MFA code`,description:`Enter the code from your authenticator app.`,buttonText:`Submit Code`,onSubmit:async e=>{S(await c.post(`auth/mfa/verify`,{login:l,token:e.token}))}}):e.projectId===`new`?(0,I.jsx)(DP,{login:l,handleAuthResponse:S}):v?(0,I.jsx)(BP,{login:l,memberships:v,handleAuthResponse:S}):e.chooseScopes?(0,I.jsx)($P,{login:l,scope:e.scope,handleAuthResponse:C}):(0,I.jsx)(`div`,{children:`Success`}):(0,I.jsx)(LP,{onForgotPassword:i,onRegister:a,handleAuthResponse:S,disableGoogleAuth:e.disableGoogleAuth,disableEmailAuth:e.disableEmailAuth,...s,children:e.children})})}function tF(e){return(0,I.jsx)(I.Fragment,{children:Sw(e.value)})}function nF(e){return(0,I.jsx)(I.Fragment,{children:Cw(e.value,e.includeCode)})}function rF(e){let t=e.value;if(!t)return null;let n=[];return t.value&&n.push(t.value),(t.use||t.system)&&(n.push(` [`),t.use&&n.push(t.use),t.use&&t.system&&n.push(` `),t.system&&n.push(t.system),n.push(`]`)),(0,I.jsx)(I.Fragment,{children:n.join(``).trim()})}function iF(e){let t=e.value;return t?(0,I.jsxs)(I.Fragment,{children:[t.name,t.name&&`: `,t.telecom?.map(e=>(0,I.jsx)(rF,{value:e},`telecom-${t.name}-${e.value}`))]}):null}function aF(e,t,n){let r=PS(e,t,{profileUrl:n});return r?Array.isArray(r)?[r.map(e=>e.value),r[0].type]:[r.value,r.type]:[void 0,`undefined`]}function oF(e,t,n){let r=FS(e,t,n);return r?Array.isArray(r)?[r.map(e=>e.value),r[0].type]:[r.value,r.type]:[void 0,`undefined`]}function sF(e){let{elementDefinitionType:t}=e,n=Z(),r=(0,b.useContext)(eA),[i,a]=(0,b.useState)(mS(`Extension`)),o=(0,b.useMemo)(()=>{if(wC(t?.profile))return t.profile[0]},[t]),[s,c]=(0,b.useState)(o!==void 0);if((0,b.useEffect)(()=>{o&&(c(!0),n.requestProfileSchema(o).then(()=>{let e=gS(o);c(!1),e&&a(e)}).catch(e=>{c(!1),console.warn(e)}))},[n,o]),o&&(s||!hS(o)))return(0,I.jsx)(`div`,{children:`Loading...`});if(i.elements[`value[x]`]?.max!==0){let[t,n]=aF({type:`Extension`,value:e.value},`value[x]`,o??r.profileUrl);return(0,I.jsx)(xF,{propertyType:n,value:t})}return(0,I.jsx)(TF,{path:e.path,value:{type:i.type,value:e.value},compact:e.compact,ignoreMissingValues:e.ignoreMissingValues,link:e.link,profileUrl:o})}function cF(e){let t=e.value;return t?(0,I.jsx)(I.Fragment,{children:lw(t,e.options)}):null}function lF(e){return(0,I.jsxs)(`div`,{children:[e.value?.system,`: `,e.value?.value]})}function uF(e){return(0,I.jsx)(I.Fragment,{children:xw(e.value)})}function dF(e){return(0,I.jsx)(I.Fragment,{children:bw(e.value,e.precision)})}function fF(e){return(0,I.jsx)(I.Fragment,{children:yw(e.value,e.precision,e.exclusive)})}function pF(e){let t=e.value;return t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dF,{value:t.numerator,precision:e.precision}),`\xA0/\xA0`,(0,I.jsx)(dF,{value:t.denominator,precision:e.precision})]}):null}function mF(e){if(!e.value)return null;let t=e.value.display||e.value.reference||yC(e.value);return e.link!==!1&&e.value.reference?(0,I.jsx)(Wj,{to:e.value,children:t}):(0,I.jsx)(I.Fragment,{children:t})}function hF(e,t,n,r){if(!wC(n?.slices))return[e];let i=Array(t.length+1);for(let e=0;e<i.length;e++)i[e]=[];for(let a of e){let e=fO(a,t,n.discriminator,r),o=e?t.findIndex(t=>t.name===e):-1;o===-1&&(o=t.length),i[o].push(a)}return i}async function gF({medplum:e,property:t}){return new Promise((n,r)=>{if(!t.slicing){n([]);return}let i=[],a=[],o=[];for(let n of t.slicing.slices){if(!uO(n)){console.debug(`Unsupported slice definition`,n);continue}let t;wC(n.elements)||(t=n.type[0]?.profile?.[0]),i.push(n),a.push(t),t&&o.push(e.requestProfileSchema(t))}Promise.all(o).then(()=>{for(let e=0;e<i.length;e++){let t=i[e],n=a[e];n&&(t.typeSchema=gS(n))}n(i)}).catch(r)})}function _F(e,t,n){return t===void 0?n:(0,I.jsx)(e,{value:t,children:n})}function vF(e){let{slice:t,property:n}=e,r=t.typeSchema?.elements??t.elements,i=(0,b.useContext)(eA),a=(0,b.useMemo)(()=>{if(wC(r))return aO({parentContext:i,elements:r,path:e.path,profileUrl:t.typeSchema?.url})},[i,e.path,t.typeSchema?.url,r]);return _F(eA.Provider,a,(0,I.jsx)(I.Fragment,{children:e.value.map((r,i)=>(0,I.jsx)(`div`,{children:(0,I.jsx)(xF,{property:n,path:e.path,arrayElement:!0,elementDefinitionType:t.type[0],propertyType:t.type[0].code,value:r,ignoreMissingValues:e.ignoreMissingValues,link:e.link})},`${i}-${e.value.length}`))}))}var yF=50;function bF(e){let{property:t,propertyType:n}=e,r=Z(),i=(0,b.useMemo)(()=>Array.isArray(e.values)?e.values:[],[e.values]),[a,o]=(0,b.useState)(!0),[s,c]=(0,b.useState)([]),[l,u]=(0,b.useState)(()=>[i]),[d,f]=(0,b.useState)(0),p=(0,b.useContext)(eA);if((0,b.useEffect)(()=>{gF({medplum:r,property:t}).then(e=>{f(i.length),c(e),u(hF(i.slice(0,yF),e,t.slicing,p.profileUrl)),o(!1)}).catch(e=>{console.error(e),o(!1)})},[r,t,p.profileUrl,u,i]),a)return(0,I.jsx)(`div`,{children:`Loading...`});let m;if(t.type[0]?.code!==`Extension`){let r=l[s.length],i=r.map((i,a)=>(0,I.jsx)(`div`,{children:(0,I.jsx)(xF,{path:e.path,arrayElement:!0,property:t,propertyType:n,value:i,ignoreMissingValues:e.ignoreMissingValues,link:e.link})},`${a}-${r.length}`));if(e.includeDescriptionListEntry){if(!wC(e.path))throw Error(`props.path is required when includeDescriptionListEntry is true`);m=(0,I.jsx)(lP,{term:Iw(e.path.split(`.`).pop()),children:i})}else m=(0,I.jsx)(I.Fragment,{children:i})}return(0,I.jsxs)(I.Fragment,{children:[s.map((n,r)=>{if(!e.path)throw Error(`Displaying a resource property with slices of type ${e.propertyType} requires path`);let i=(0,I.jsx)(vF,{path:e.path,slice:n,property:t,value:l[r],ignoreMissingValues:e.ignoreMissingValues,link:e.link},n.name);return e.includeDescriptionListEntry&&(i=(0,I.jsx)(lP,{term:Iw(n.name),children:i},n.name)),i}),m,d>yF&&(0,I.jsx)(V,{justify:`right`,children:(0,I.jsxs)(H,{children:[`... `,d,` total values`]})})]})}function xF(e){let{property:t,propertyType:n,value:r}=e;if(t?.path?.endsWith(`.id`))return(0,I.jsxs)(_d,{gap:3,align:`center`,children:[r,!CC(r)&&(0,I.jsx)(sm,{value:r,timeout:2e3,children:({copied:e,copy:t})=>(0,I.jsx)(Qv,{label:e?`Copied`:`Copy`,withArrow:!0,position:`right`,children:(0,I.jsx)(gu,{variant:`subtle`,color:e?`teal`:`gray`,onClick:t,children:e?(0,I.jsx)(wA,{size:`1rem`}):(0,I.jsx)(MA,{size:`1rem`})})})})]});if(t&&(t.isArray||t.max>1)&&!e.arrayElement)return n===Y.Attachment?(0,I.jsx)(uP,{values:r,maxWidth:e.maxWidth,includeDescriptionListEntry:e.includeArrayDescriptionListEntry,property:t,path:e.path}):(0,I.jsx)(bF,{path:e.path,property:t,propertyType:n,values:r,includeDescriptionListEntry:e.includeArrayDescriptionListEntry,ignoreMissingValues:e.ignoreMissingValues,link:e.link});switch(n){case Y.boolean:return(0,I.jsx)(I.Fragment,{children:r===void 0?``:(!!r).toString()});case Y.SystemString:case Y.string:return e.property?.path?.toLowerCase().includes(`secret`)?(0,I.jsx)(SF,{value:r}):(0,I.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:r});case Y.code:case Y.date:case Y.decimal:case Y.id:case Y.integer:case Y.positiveInt:case Y.unsignedInt:case Y.uri:case Y.url:case Y.xhtml:return PC(r)&&!FC(r)?(console.warn(`Non-standard FHIR data or missing primitive value with extension`,{path:e.path,propertyType:n,value:r}),null):(0,I.jsx)(I.Fragment,{children:r?.toString()});case Y.canonical:return(0,I.jsx)(mF,{value:{reference:r},link:e.link});case Y.dateTime:case Y.instant:return(0,I.jsx)(I.Fragment,{children:fw(r)});case Y.time:return(0,I.jsx)(I.Fragment,{children:dw(r)});case Y.markdown:return(0,I.jsx)(`pre`,{children:r});case Y.Address:return(0,I.jsx)(Zk,{value:r});case Y.Annotation:return(0,I.jsx)(I.Fragment,{children:r?.text});case Y.Attachment:return(0,I.jsx)(aP,{value:r,maxWidth:e.maxWidth});case Y.CodeableConcept:return(0,I.jsx)(tF,{value:r});case Y.Coding:return(0,I.jsx)(nF,{value:r});case Y.ContactDetail:return(0,I.jsx)(iF,{value:r});case Y.ContactPoint:return(0,I.jsx)(rF,{value:r});case Y.HumanName:return(0,I.jsx)(cF,{value:r});case Y.Identifier:return(0,I.jsx)(lF,{value:r});case Y.Money:return(0,I.jsx)(uF,{value:r});case Y.Period:return(0,I.jsx)(I.Fragment,{children:pw(r)});case Y.Quantity:case Y.Duration:return(0,I.jsx)(dF,{value:r});case Y.Range:return(0,I.jsx)(fF,{value:r});case Y.Ratio:return(0,I.jsx)(pF,{value:r});case Y.Reference:return(0,I.jsx)(mF,{value:r,link:e.link});case Y.Timing:return(0,I.jsx)(I.Fragment,{children:_w(r)});case Y.Dosage:case Y.UsageContext:if(!e.path)throw Error(`Displaying property of type ${e.propertyType} requires path`);return(0,I.jsx)(TF,{path:e.path,value:{type:n,value:r},compact:!0,ignoreMissingValues:e.ignoreMissingValues});case Y.Extension:if(!e.path)throw Error(`Displaying property of type ${e.propertyType} requires path`);return(0,I.jsx)(sF,{path:e.path,value:r,compact:!0,ignoreMissingValues:e.ignoreMissingValues,elementDefinitionType:e.elementDefinitionType});default:if(!t)throw Error(`Displaying property of type ${e.propertyType} requires element schema`);if(!e.path)throw Error(`Displaying property of type ${e.propertyType} requires path`);return(0,I.jsx)(TF,{path:e.path,value:{type:t.type[0].code,value:r},compact:!0,ignoreMissingValues:e.ignoreMissingValues})}}function SF(e){let[t,n]=(0,b.useState)(!1),r=e.value??``,i=!CC(r),a=`•`.repeat(8);return(0,I.jsxs)(_d,{gap:3,align:`center`,children:[t?(0,I.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:r}):(0,I.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},"aria-hidden":`true`,children:i?a:``}),i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(sm,{value:e.value,timeout:2e3,children:({copied:e,copy:t})=>(0,I.jsx)(Qv,{label:e?`Copied`:`Copy secret`,withArrow:!0,position:`right`,children:(0,I.jsx)(gu,{variant:`subtle`,color:e?`teal`:`gray`,onClick:t,"aria-label":e?`Copied`:`Copy secret`,children:e?(0,I.jsx)(wA,{size:`1rem`}):(0,I.jsx)(MA,{size:`1rem`})})})}),(0,I.jsx)(Qv,{label:t?`Hide secret`:`Show secret`,withArrow:!0,position:`right`,children:(0,I.jsx)(gu,{variant:`subtle`,color:`gray`,onClick:()=>n(!t),"aria-label":t?`Hide secret`:`Show secret`,children:t?(0,I.jsx)(VA,{size:`1rem`}):(0,I.jsx)(HA,{size:`1rem`})})})]})]})}var CF=[`extension`,`modifierExtension`],wF=Qk.filter(e=>!CF.includes(e));function TF(e){let t=e.value,{value:n,type:r}=t,i=(0,b.useContext)(eA),a=e.profileUrl??i?.profileUrl,o=(0,b.useMemo)(()=>pS(r,a),[a,r]),s=(0,b.useMemo)(()=>{if(o)return aO({parentContext:i,elements:o.elements,path:e.path,profileUrl:o.url,accessPolicyResource:e.accessPolicyResource})},[o,i,e.path,e.accessPolicyResource]);if(CC(n))return null;if(!o)return(0,I.jsxs)(`div`,{children:[r,`\xA0not implemented`]});if(typeof n==`object`&&`name`in n&&Object.keys(n).length===1&&typeof n.name==`string`)return(0,I.jsx)(`div`,{children:n.name});let c=s??i;return _F(eA.Provider,s,(0,I.jsx)(cP,{compact:e.compact,children:Object.entries(c.elements).map(([n,r])=>{if(CF.includes(n)&&CC(r.slicing?.slices)||wF.includes(n)||$k.includes(n)&&r.path.split(`.`).length===2||n.includes(`.`))return null;let[i,a]=aF(t,n,c.profileUrl);if((e.ignoreMissingValues||r.max===0)&&CC(i)||e.path.endsWith(`.extension`)&&(n===`url`||n===`id`))return null;let o=r.max>1||r.isArray,s=(0,I.jsx)(xF,{property:r,propertyType:a,path:e.path+`.`+n,value:i,ignoreMissingValues:e.ignoreMissingValues,includeArrayDescriptionListEntry:o,link:e.link},n);return o?s:(0,I.jsx)(lP,{term:Iw(n),children:s},n)})}))}var EF={dimmed:`_dimmed_11me5_1`,preserveBreaks:`_preserveBreaks_11me5_5`},DF=`Read Only`;function OF(e,t){return e?(0,I.jsx)(Qv.Floating,{label:e,children:t}):t}function kF(e){let{debugMode:t}=(0,b.useContext)(eA),n;return n=t&&e.fhirPath?`${e.title} - ${e.fhirPath}`:e.title,OF(e?.readonly?DF:void 0,(0,I.jsxs)(V,{wrap:`nowrap`,"data-testid":e.testId,children:[(0,I.jsx)(`div`,{children:e.children}),(0,I.jsx)(`div`,{children:(0,I.jsx)(dd.Wrapper,{id:e.htmlFor,label:n,classNames:{label:e?.readonly?EF.dimmed:void 0},description:e.description,withAsterisk:e.withAsterisk,children:null})})]}))}function AF(e){let{debugMode:t}=(0,b.useContext)(eA),n;return n=t&&e.fhirPath?`${e.title} - ${e.fhirPath}`:e.title,OF(e?.readonly?DF:void 0,(0,I.jsx)(dd.Wrapper,{id:e.htmlFor,label:n,classNames:{label:Mn({[EF.dimmed]:e?.readonly},EF.preserveBreaks)},description:e.description,withAsterisk:e.withAsterisk,error:bP(e.outcome,e.errorExpression??e.htmlFor),"data-testid":e.testId,children:e.children}))}function jF(e,t,n,r,i){let a=r.type;if(a.length>1)for(let n of a){let r=t.replace(`[x]`,UC(n.code));r in e&&delete e[r]}return CC(i)?e[n]=void 0:e[n]=i,e}function MF(e){return!!e&&!CC(e.url)&&!CC(e.name)}function NF(e){let{defaultValue:t,onChange:n,withHelpText:r,outcome:i,path:a,valuePath:o,...s}=e,[c,l]=(0,b.useState)(t);function u(e){let t=FF(e);l(t),n&&n(t)}return(0,I.jsx)(jN,{defaultValue:c&&PF(c),onChange:u,withHelpText:r??!0,...s})}function PF(e){return e.coding?.map(e=>({system:e.system,code:e.code,display:e.display}))}function FF(e){if(e.length!==0)return{coding:e.map(e=>({system:e.system,code:e.code,display:e.display}))}}function IF(e){let{defaultValue:t,onChange:n,withHelpText:r,response:i,...a}=e,[o,s]=(0,b.useState)(i?.answer?.[0]?.valueCoding??t);function c(e){let t=e[0],r=t&&RF(t);s(r),n&&n(r)}return(0,I.jsx)(jN,{defaultValue:o?LF(o):void 0,maxValues:1,onChange:c,withHelpText:r??!0,...a})}function LF(e){return{system:e.system,code:e.code,display:e.display}}function RF(e){return{system:e.system,code:e.code,display:e.display}}function zF(e){let{path:t,outcome:n}=e,{elementsByPath:r,getExtendedProps:i}=(0,b.useContext)(eA),[a,o]=(0,b.useState)(e.defaultValue),[s,c,l]=(0,b.useMemo)(()=>[`system`,`use`,`value`].map(e=>r[t+`.`+e]),[r,t]),[u,d,f]=(0,b.useMemo)(()=>[`system`,`use`,`value`].map(e=>i(t+`.`+e)),[i,t]);function p(t){t&&Object.keys(t).length===0&&(t=void 0),o(t),e.onChange&&e.onChange(t)}function m(e){let t={...a,system:e};e||delete t.system,p(t)}function h(e){let t={...a,use:e};e||delete t.use,p(t)}function g(e){let t={...a,value:e};e||delete t.value,p(t)}let _=e.valuePath??t;return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,align:`flex-start`,children:[(0,I.jsx)(Eg,{disabled:e.disabled||u?.readonly,"data-testid":`system`,defaultValue:a?.system,required:(s?.min??0)>0,onChange:e=>m(e.currentTarget.value),data:[``,`email`,`phone`,`fax`,`pager`,`sms`,`url`,`other`],error:bP(n,_+`.system`)}),(0,I.jsx)(Eg,{disabled:e.disabled||d?.readonly,"data-testid":`use`,defaultValue:a?.use,required:(c?.min??0)>0,onChange:e=>h(e.currentTarget.value),data:[``,`home`,`work`,`temp`,`old`,`mobile`],error:bP(n,_+`.use`)}),(0,I.jsx)(yb,{disabled:e.disabled||f?.readonly,placeholder:`Value`,defaultValue:a?.value,required:(l?.min??0)>0,onChange:e=>g(e.currentTarget.value),error:bP(n,_+`.value`)})]})}function BF(e){let[t,n]=(0,b.useState)(e.defaultValue),{getExtendedProps:r}=(0,b.useContext)(eA),[i,a]=(0,b.useMemo)(()=>[`name`,`telecom`].map(t=>r(e.path+`.`+t)),[r,e.path]);function o(t){n(t),e.onChange&&e.onChange(t)}function s(e){let n={...t,name:e};e||delete n.name,o(n)}function c(e){let n={...t,telecom:e&&[e]};e||delete n.telecom,o(n)}return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)(yb,{disabled:e.disabled||i?.readonly,"data-testid":e.name+`-name`,name:e.name+`-name`,placeholder:`Name`,style:{width:180},defaultValue:t?.name,onChange:e=>s(e.currentTarget.value)}),(0,I.jsx)(zF,{disabled:e.disabled||a?.readonly,name:e.name+`-telecom`,path:e.path+`.telecom`,defaultValue:t?.telecom?.[0],onChange:c,outcome:e.outcome})]})}function VF(e){if(!e)return``;let t=new Date(e);return uw(t)?t.toLocaleDateString(`sv`)+`T`+t.toLocaleTimeString(`sv`):``}function HF(e){if(!e)return``;let t=new Date(e);return uw(t)?t.toISOString():``}function UF(e){return(0,I.jsx)(yb,{id:e.name,name:e.name,label:e.label,"data-autofocus":e.autoFocus,"data-testid":e[`data-testid`]??e.name,placeholder:e.placeholder,required:e.required,disabled:e.disabled,type:WF(),step:1,defaultValue:VF(e.defaultValue),autoFocus:e.autoFocus,error:bP(e.outcome,e.name),onChange:t=>{if(e.onChange){let n=t.currentTarget.value;e.onChange(HF(n))}}})}function WF(){return`datetime-local`}function GF(e){let{propertyType:t}=e,n=Z(),r=(0,b.useMemo)(()=>{if(wC(t.profile))return t.profile[0]},[t]),[i,a]=(0,b.useState)(r!==void 0);return(0,b.useEffect)(()=>{r&&(a(!0),n.requestProfileSchema(r).then(()=>a(!1)).catch(e=>{a(!1),console.warn(e)}))},[n,r]),r&&(i||!hS(r))?(0,I.jsx)(`div`,{children:`Loading...`}):(0,I.jsx)(MI,{profileUrl:r,path:e.path,typeName:`Extension`,defaultValue:e.defaultValue,onChange:e.onChange})}function KF(e){let{outcome:t,path:n}=e,[r,i]=(0,b.useState)(e.defaultValue),{getExtendedProps:a}=(0,b.useContext)(eA),[o,s,c,l,u]=(0,b.useMemo)(()=>[`use`,`prefix`,`given`,`family`,`suffix`].map(t=>a(e.path+`.`+t)),[a,e.path]);function d(t){i(t),e.onChange&&e.onChange(t)}function f(e){d({...r,use:e||void 0})}function p(e){d({...r,prefix:e?e.split(` `):void 0})}function m(e){d({...r,given:e?e.split(` `):void 0})}function h(e){d({...r,family:e||void 0})}function g(e){d({...r,suffix:e?e.split(` `):void 0})}let _=e.valuePath??n;return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)(Eg,{disabled:e.disabled||o?.readonly,defaultValue:r?.use,name:e.name+`-use`,"data-testid":`use`,onChange:e=>f(e.currentTarget.value),data:[``,`temp`,`old`,`usual`,`official`,`nickname`,`anonymous`,`maiden`],error:bP(t,_+`.use`)}),(0,I.jsx)(yb,{disabled:e.disabled||s?.readonly,placeholder:`Prefix`,name:e.name+`-prefix`,defaultValue:r?.prefix?.join(` `),onChange:e=>p(e.currentTarget.value),error:bP(t,_+`.prefix`)}),(0,I.jsx)(yb,{disabled:e.disabled||c?.readonly,placeholder:`Given`,name:e.name+`-given`,defaultValue:r?.given?.join(` `),onChange:e=>m(e.currentTarget.value),error:bP(t,_+`.given`)}),(0,I.jsx)(yb,{disabled:e.disabled||l?.readonly,name:e.name+`-family`,placeholder:`Family`,defaultValue:r?.family,onChange:e=>h(e.currentTarget.value),error:bP(t,_+`.family`)}),(0,I.jsx)(yb,{disabled:e.disabled||u?.readonly,placeholder:`Suffix`,name:e.name+`-suffix`,defaultValue:r?.suffix?.join(` `),onChange:e=>g(e.currentTarget.value),error:bP(t,_+`.suffix`)})]})}function qF(e){let[t,n]=(0,b.useState)(e.defaultValue),{elementsByPath:r,getExtendedProps:i}=(0,b.useContext)(eA),[a,o]=(0,b.useMemo)(()=>[`system`,`value`].map(t=>r[e.path+`.`+t]),[r,e.path]),[s,c]=(0,b.useMemo)(()=>[`system`,`value`].map(t=>i(e.path+`.`+t)),[i,e.path]);function l(t){n(t),e.onChange&&e.onChange(t)}let u=e.valuePath??e.path;return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,align:`flex-start`,children:[(0,I.jsx)(yb,{disabled:e.disabled||s?.readonly,placeholder:`System`,required:(a?.min??0)>0,defaultValue:t?.system,onChange:e=>l({...t,system:e.currentTarget.value}),error:bP(e.outcome,u+`.system`)}),(0,I.jsx)(yb,{disabled:e.disabled||c?.readonly,placeholder:`Value`,required:(o?.min??0)>0,defaultValue:t?.value,onChange:e=>l({...t,value:e.currentTarget.value}),error:bP(e.outcome,u+`.value`)})]})}var JF=[`USD`,`EUR`,`CAD`,`GBP`,`AUD`];function YF(e){let{onChange:t}=e,[n,r]=(0,b.useState)(e.defaultValue),{getExtendedProps:i}=(0,b.useContext)(eA),[a,o]=(0,b.useMemo)(()=>[`currency`,`value`].map(t=>i(e.path+`.`+t)),[i,e.path]),s=(0,b.useCallback)(e=>{r(e),t&&t(e)},[t]),c=(0,b.useCallback)(e=>{s({...n,currency:e.currentTarget.value})},[n,s]),l=(0,b.useCallback)(e=>{s({...n,value:e.currentTarget.valueAsNumber})},[n,s]),u=(0,I.jsx)(Eg,{disabled:e.disabled||a?.readonly,defaultValue:n?.currency,data:JF,styles:{input:{fontWeight:500,borderTopLeftRadius:0,borderBottomLeftRadius:0,width:92}},onChange:c});return(0,I.jsx)(yb,{disabled:e.disabled||o?.readonly,type:`number`,name:e.name,label:e.label,placeholder:e.placeholder??`Value`,defaultValue:n?.value?.toString()??`USD`,leftSection:(0,I.jsx)(NA,{size:14}),rightSection:u,rightSectionWidth:92,onChange:l})}function XF(e){let[t,n]=(0,b.useState)(e.defaultValue),{getExtendedProps:r}=(0,b.useContext)(eA),[i,a]=(0,b.useMemo)(()=>[`start`,`end`].map(t=>r(e.path+`.`+t)),[r,e.path]);function o(t){n(t),e.onChange&&e.onChange(t)}return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)(UF,{disabled:e.disabled||i?.readonly,name:e.name+`.start`,placeholder:`Start`,defaultValue:t?.start,onChange:e=>o({...t,start:e})}),(0,I.jsx)(UF,{disabled:e.disabled||a?.readonly,name:e.name+`.end`,placeholder:`End`,defaultValue:t?.end,onChange:e=>o({...t,end:e})})]})}function ZF(e){let[t,n]=(0,b.useState)(e.defaultValue),{getExtendedProps:r}=(0,b.useContext)(eA),[i,a,o]=(0,b.useMemo)(()=>[`comparator`,`value`,`unit`].map(t=>r(e.path+`.`+t)),[r,e.path]);function s(t){n(t),e.onChange&&e.onChange(t)}return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)(Eg,{disabled:e.disabled||i?.readonly,style:{width:80},"data-testid":e.name+`-comparator`,defaultValue:t?.comparator,data:[``,`<`,`<=`,`>=`,`>`],onChange:e=>s({...t,comparator:e.currentTarget.value})}),(0,I.jsx)(yb,{disabled:e.disabled||a?.readonly,id:e.name,name:e.name,required:e.required,"data-autofocus":e.autoFocus,"data-testid":e.name+`-value`,type:`number`,placeholder:`Value`,defaultValue:t?.value,autoFocus:e.autoFocus,step:`any`,onWheel:t=>{e.disableWheel&&t.currentTarget.blur()},onChange:e=>{s({...t,value:QF(e.currentTarget.value)})}}),(0,I.jsx)(yb,{disabled:e.disabled||o?.readonly,placeholder:`Unit`,"data-testid":e.name+`-unit`,defaultValue:t?.unit,onChange:e=>s({...t,unit:e.currentTarget.value})})]})}function QF(e){if(e)return Number.parseFloat(e)}function $F(e){let[t,n]=(0,b.useState)(e.defaultValue),{getExtendedProps:r}=(0,b.useContext)(eA),[i,a]=(0,b.useMemo)(()=>[`low`,`high`].map(t=>r(e.path+`.`+t)),[r,e.path]);function o(t){n(t),e.onChange&&e.onChange(t)}return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)(ZF,{path:e.path+`.low`,disabled:e.disabled||i?.readonly,name:e.name+`-low`,defaultValue:t?.low,onChange:e=>o({...t,low:e})}),(0,I.jsx)(ZF,{path:e.path+`.high`,disabled:e.disabled||a?.readonly,name:e.name+`-high`,defaultValue:t?.high,onChange:e=>o({...t,high:e})})]})}function eI(e){let[t,n]=(0,b.useState)(e.defaultValue),{getExtendedProps:r}=(0,b.useContext)(eA),[i,a]=(0,b.useMemo)(()=>[`numerator`,`denominator`].map(t=>r(e.path+`.`+t)),[r,e.path]);function o(t){n(t),e.onChange&&e.onChange(t)}return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)(ZF,{path:e.path+`.numerator`,disabled:e.disabled||i?.readonly,name:e.name+`-numerator`,defaultValue:t?.numerator,onChange:e=>o({...t,numerator:e})}),(0,I.jsx)(ZF,{path:e.path+`.denominator`,disabled:e.disabled||a?.readonly,name:e.name+`-denominator`,defaultValue:t?.denominator,onChange:e=>o({...t,denominator:e})})]})}var tI={Device:`device-name`,Observation:`code`,Subscription:`criteria`,User:`email:contains`},nI=`AccessPolicy.Account.ActivityDefinition.Bot.CapabilityStatement.CareTeam.ClientApplication.CodeSystem.CompartmentDefinition.ConceptMap.EffectEvidenceSynthesis.Endpoint.EventDefinition.Evidence.EvidenceVariable.ExampleScenario.GraphDefinition.Group.HealthcareService.ImplementationGuide.InsurancePlan.Library.Location.Measure.MedicinalProduct.MessageDefinition.NamingSystem.OperationDefinition.Organization.Patient.Person.PlanDefinition.Practitioner.Project.Questionnaire.RelatedPerson.ResearchDefinition.ResearchElementDefinition.ResearchStudy.RiskEvidenceSynthesis.SearchParameter.StructureDefinition.StructureMap.TerminologyCapabilities.TestScript.UserConfiguration.ValueSet`.split(`.`);function rI(e){return{value:oC(e)??``,label:uC(e),resource:e}}function iI(e){return tI[e]??(nI.includes(e)?`name`:`_id`)}var aI=(0,b.forwardRef)(({label:e,resource:t,active:n,...r},i)=>(0,I.jsx)(`div`,{ref:i,...r,children:(0,I.jsxs)(V,{wrap:`nowrap`,children:[(0,I.jsx)(Xj,{value:t}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{children:e}),(0,I.jsx)(H,{size:`xs`,c:`dimmed`,children:t.birthDate||t.id})]})]})}));aI.displayName=`DefaultResourceItemComponent`;function oI(e){let t=Z(),{resourceType:n,searchCriteria:r}=e,i=e.itemComponent??aI,a=e.onChange,o=(0,b.useRef)(e.defaultValue),[s,c]=(0,b.useState)(!e.defaultValue||e.defaultValue.length===0?[]:void 0);(0,b.useEffect)(()=>{let e=!1,n=o.current;return n&&n.length>0&&Promise.allSettled(n.map(e=>{if(Hw(e))return Promise.resolve(e);if(Uw(e)){let n=e;return t.readReference(n)}return Promise.reject(Error(`Not a resolvable item`))})).then(t=>{e||c(t.filter(e=>e.status===`fulfilled`).map(e=>e.value))}).catch(()=>{}),()=>{e=!0}},[t]);let l=(0,b.useCallback)(async(e,i)=>{let a=iI(n),o=new URLSearchParams({[a]:e??``,_count:`10`,...r});return await t.searchResources(n,o,{signal:i})},[t,n,r]),u=(0,b.useCallback)(e=>{a&&a(e)},[a]);return s===void 0?null:(0,I.jsx)(fM,{disabled:e.disabled,name:e.name,label:e.label,error:e.error,required:e.required,itemComponent:i,defaultValue:s,placeholder:e.placeholder,maxValues:e.maxValues,toOption:rI,loadOptions:l,onChange:u,clearable:!0})}function sI(e){let t=e.onChange,n=(0,b.useCallback)(e=>{t&&t(e[0])},[t]);return(0,I.jsx)(oI,{resourceType:e.resourceType,name:e.name,defaultValue:e.defaultValue?[e.defaultValue]:void 0,searchCriteria:e.searchCriteria,placeholder:e.placeholder,required:e.required,itemComponent:e.itemComponent,onChange:n,disabled:e.disabled,label:e.label,error:e.error,maxValues:1})}function cI(e){let{onChange:t}=e,n=Z(),[r,i]=(0,b.useState)(e.defaultValue),[a,o]=(0,b.useState)(()=>lI(e.targetTypes)),[s,c]=(0,b.useState)(()=>uI(e.defaultValue,a)),l=(0,b.useRef)(new Sx),u=(0,b.useMemo)(()=>s?.type===`profile`?{...e.searchCriteria,_profile:s.value}:e.searchCriteria,[e.searchCriteria,s]);(0,b.useEffect)(()=>{let e=!1,t=a?.map(t=>{if(!fI(t))return Promise.resolve(t);e=!0;let r=t.value,i=l.current.get(r);if(i)return i;let a=new xD(dI(n,t.value).then(e=>{let n={...t};return e?wC(e.type)?(n.resourceType=e.type,n.name=e.name,n.title=e.title):(console.error(`StructureDefinition.type missing for ${t.value}`),n.error=`StructureDefinition.type missing`):(console.error(`StructureDefinition not found for ${t.value}`),n.error=`StructureDefinition not found`),n}).catch(e=>(console.error(e),{...t,error:e})));return l.current.set(r,a),a});!t||!e||Promise.all(t).then(e=>{if(o(e),!s)return;let t=e.findIndex(e=>e.value===s.value||e.resourceType===s.resourceType);if(t===-1){console.debug(`defaultValue had unexpected resourceType: ${s.resourceType}`);return}c(e[t])}).catch(console.error)},[n,s,a]);let d=(0,b.useCallback)(e=>{let n=e?aC(e):void 0;i(n),t&&t(n)},[t]),f=(0,b.useMemo)(()=>a?a.map(e=>({value:e.value,label:e.type===`profile`?e.title??e.name??e.resourceType??e.value:e.value})):[],[a]);return(0,I.jsxs)(I.Fragment,{children:[e.name&&(0,I.jsx)(`input`,{type:`hidden`,name:e.name,value:r?.reference??``}),(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[a&&a.length>1&&(0,I.jsx)(Eg,{name:e.name+`-resourceType`,disabled:e.disabled,"data-autofocus":e.autoFocus,"data-testid":`reference-input-resource-type-select`,defaultValue:s?.resourceType,autoFocus:e.autoFocus,onChange:e=>{let t=e.currentTarget.value;c(a.find(e=>e.value===t))},data:f}),!a&&(0,I.jsx)(IN,{disabled:e.disabled,autoFocus:e.autoFocus,testId:`reference-input-resource-type-input`,defaultValue:s?.resourceType,onChange:e=>{c(e?{type:`resourceType`,value:e,resourceType:e}:void 0)},name:e.name+`-resourceType`,placeholder:`Resource Type`}),(0,I.jsx)(sI,{resourceType:s?.resourceType,name:e.name+`-id`,required:e.required,placeholder:e.placeholder,defaultValue:r,searchCriteria:u,onChange:d,disabled:e.disabled})]})]})}function lI(e){if(!e||e.length===0||e.length===1&&e[0]===`Resource`)return;let t=[];for(let n of e)n.includes(`/`)?t.push({type:`profile`,value:n}):t.push({type:`resourceType`,value:n,resourceType:n});return t}function uI(e,t){let n=e?.reference?.split(`/`)[0];if(n)return t?.find(e=>e.resourceType===n)||{type:`resourceType`,value:n,resourceType:n};if(t&&t.length>0)return t[0]}async function dI(e,t){let n=gS(t);if(n)return{type:n.type,name:n.name,title:n.title};let r=`{
197
+ }`.replaceAll(/\s+/g,` `)}function GN(e){let t=[];return e.data.Patients1&&t.push(...e.data.Patients1),e.data.Patients2&&t.push(...e.data.Patients2),e.data.ServiceRequestList&&t.push(...e.data.ServiceRequestList),KN(t)}function KN(e){let t=new Set,n=[];for(let r of e)r.id&&!t.has(r.id)&&(t.add(r.id),n.push(r));return n}function qN(e,t){let n=e.filter(e=>!!e.id).map(e=>({id:e.id,label:e.name?lw(e.name[0]):e.id,description:e.birthDate,leftSection:(0,I.jsx)(Qj,{value:e,radius:`xl`,size:24}),onClick:()=>t(`/Patient/${e.id}`)}));return n.length>0?[{group:`Patients`,actions:n}]:[]}function JN(e,t,n){let r=[],i=t.map(e=>({id:`resource-type-${e.code}`,label:e.display??e.code??``,description:`Resource Type`,onClick:()=>n(`/${e.code}`)}));i.length>0&&r.push({group:`Resource Types`,actions:i});let a=[],o=[];for(let t of e)t.resourceType===`Patient`&&t.id?a.push({id:t.id,label:t.name?lw(t.name[0]):t.id,description:t.birthDate,leftSection:(0,I.jsx)(Qj,{value:t,radius:`xl`,size:24}),onClick:()=>n(`/Patient/${t.id}`)}):t.resourceType===`ServiceRequest`&&t.id&&o.push({id:t.id,label:t.id,description:t.subject?.display,onClick:()=>n(`/ServiceRequest/${t.id}`)});return a.length>0&&r.push({group:`Patients`,actions:a}),o.length>0&&r.push({group:`Service Requests`,actions:o}),r}function YN(e){let t=JO(),n=YO(),r=QN(e.pathname,e.searchParams,e.menus),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(!1);function c(n,r){n.stopPropagation(),n.preventDefault(),t(r),window.innerWidth<768&&e.closeNavbar()}function l(e){e&&t(`/${e}`)}let u=e.opened??!0;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(af.Navbar,{id:`navbar`,className:zN.navbar,children:[e.logo&&(0,I.jsx)(af.Section,{px:`xs`,pt:`xs`,pb:`4px`,children:(0,I.jsx)(ml,{className:zN.logoButton,onClick:e.navbarToggle,"aria-expanded":u,"aria-controls":`navbar`,"aria-label":`Medplum Logo`,children:e.logo})}),(0,I.jsx)(ul,{px:`xs`,pb:`xs`,pt:`sm`,h:`100%`,children:(0,I.jsxs)(af.Section,{grow:!0,children:[e.spotlightEnabled&&(0,I.jsx)(z,{mb:2,children:(0,I.jsx)(Qv,{label:`Search`,position:`right`,transitionProps:{duration:0},disabled:u,children:(0,I.jsxs)(ml,{className:zN.link,onClick:()=>YM.open(),"aria-label":`Search`,children:[(0,I.jsx)(bj,{size:`1.2rem`}),(0,I.jsx)(`span`,{className:zN.linkLabel,"data-opened":u||void 0,children:`Search`})]})})}),e.spotlightEnabled&&(0,I.jsx)(UN,{patientsOnly:e.patientsOnly}),!e.resourceTypeSearchDisabled&&(0,I.jsx)(af.Section,{mb:`sm`,children:(0,I.jsx)(RN,{name:`resourceType`,placeholder:`Resource Type`,maxValues:0,onChange:e=>l(e)},window.location.pathname)}),e.menus?.map((e,t)=>(0,I.jsxs)(b.Fragment,{children:[e.title&&(0,I.jsx)(H,{className:zN.menuTitle,"data-opened":u||void 0,children:e.title}),(0,I.jsx)(G,{gap:`2`,children:e.links?.map(e=>e.notificationCount?(0,I.jsx)(ZN,{to:e.href,active:e.href===r?.href,onClick:t=>c(t,e.href),icon:e.icon,label:e.label??``,opened:u,alert:e.alert,notificationCount:e.notificationCount,onDismiss:e.onDismiss},e.href):(0,I.jsx)(XN,{to:e.href,active:e.href===r?.href,onClick:t=>c(t,e.href),icon:e.icon,label:e.label??``,opened:u,alert:e.alert,count:e.count,onDismiss:e.onDismiss},e.href))})]},`menu-${e.title??t}`)),e.displayAddBookmark&&(0,I.jsx)(Qv,{label:`Add Bookmark`,position:`right`,transitionProps:{duration:0},disabled:u,children:(0,I.jsxs)(ml,{className:`${zN.link} ${zN.addBookmarkLink}`,onClick:()=>s(!0),children:[(0,I.jsx)(jA,{}),(0,I.jsx)(`span`,{className:zN.linkLabel,"data-opened":u||void 0,children:`Add Bookmark`})]})})]})}),e.userMenuEnabled&&(0,I.jsxs)(af.Section,{px:`xs`,py:`xs`,children:[(0,I.jsx)(Qv,{label:u?`Close Sidebar`:`Open Sidebar`,position:`right`,transitionProps:{duration:0},children:(0,I.jsx)(ml,{className:zN.toggleButton,"data-opened":u||void 0,"aria-label":u?`Close Sidebar`:`Open Sidebar`,onClick:e.navbarToggle,"aria-expanded":u,"aria-controls":`navbar`,children:(0,I.jsx)(ZA,{})})}),(0,I.jsx)(dm,{my:`xs`,className:zN.divider}),(0,I.jsxs)(W,{width:260,shadow:`md`,radius:`md`,position:`top-start`,transitionProps:{transition:`fade-up`},opened:i,onClose:()=>a(!1),children:[(0,I.jsx)(W.Target,{children:(0,I.jsxs)(ml,{className:zN.link,pl:`7`,"aria-label":`User menu`,"data-active":i||void 0,onClick:()=>a(e=>!e),bd:`1px 0 0 0 solid var(--mantine-color-gray-200)`,children:[(0,I.jsx)(Qj,{value:n,radius:`xl`,size:24}),(0,I.jsx)(`span`,{className:zN.linkLabel,"data-opened":u||void 0,children:lw(n?.name?.[0])})]})}),(0,I.jsx)(W.Dropdown,{className:iM.dropdown,children:(0,I.jsx)(fM,{version:e.version,showLayoutVersionToggle:e.showLayoutVersionToggle})})]})]})]}),e.pathname&&e.searchParams&&(0,I.jsx)(DN,{pathname:e.pathname,searchParams:e.searchParams,visible:o,onOk:()=>s(!1),onCancel:()=>s(!1)})]})}function XN(e){let{to:t,icon:n,label:r,onClick:i,active:a,count:o,alert:s,opened:c,onDismiss:l}=e,u=o!==void 0&&o>0,d=n??(0,I.jsx)(_A,{}),f=u&&s&&!c;function p(e){e.preventDefault(),e.stopPropagation(),l?.()}return(0,I.jsx)(Qv,{label:r,position:`right`,transitionProps:{duration:0},disabled:c,children:(0,I.jsxs)(Kj,{to:t,onClick:i,className:zN.link,"data-active":a||void 0,children:[(0,I.jsxs)(`span`,{className:zN.iconWrapper,children:[d,f&&(0,I.jsx)(`span`,{className:zN.alertDot})]}),(0,I.jsx)(`span`,{className:zN.linkLabel,"data-opened":c||void 0,children:r}),u&&(0,I.jsx)(`span`,{className:zN.linkCount,"data-opened":c||void 0,"data-alert":s||void 0,children:o.toLocaleString()}),l&&c&&(0,I.jsx)(Qv,{label:`Dismiss`,openDelay:500,children:(0,I.jsx)(ml,{"aria-label":`Dismiss`,className:zN.dismissButton,onClick:p,children:(0,I.jsx)(Fj,{size:14})})})]})})}function ZN(e){let t=rk(e.notificationCount);return(0,I.jsx)(XN,{to:e.to,active:e.active,onClick:e.onClick,icon:e.icon,label:e.label,opened:e.opened,alert:e.alert,count:t,onDismiss:e.onDismiss})}function QN(e,t,n){if(!e||!t||!n)return;let r,i=0;for(let a of n)if(a.links)for(let n of a.links){let a=$N(e,t,n.href);a>i&&(i=a,r=n)}return r}function $N(e,t,n){let r=new URL(n,`https://example.com`);if(e!==r.pathname)return 0;let i=[`_count`,`_offset`];for(let[e,n]of r.searchParams.entries())if(!i.includes(e)&&t.get(e)!==n)return 0;let a=1;for(let[e,n]of t.entries())i.includes(e)||r.searchParams.get(e)===n&&a++;return a}var eP=250,tP=59;function nP(e){let[t,n]=(0,b.useState)(localStorage.navbarOpen===`true`),[r]=(0,b.useState)(e.layoutVersion??localStorage.appShellLayoutVersion??`v1`),i=Z(),a=YO();function o(e){localStorage.navbarOpen=e.toString(),n(e)}function s(){o(!1)}function c(){o(!t)}if(i.isLoading())return(0,I.jsx)(Rj,{});let l,u,d,f;return r===`v2`?(l={height:0},u={width:t?eP:tP,breakpoint:0,collapsed:{desktop:!a,mobile:!a}},d=void 0,f=a?(0,I.jsx)(YN,{logo:e.logo,pathname:e.pathname,searchParams:e.searchParams,menus:e.menus,navbarToggle:c,closeNavbar:s,displayAddBookmark:e.displayAddBookmark,resourceTypeSearchDisabled:!0,opened:t,spotlightEnabled:!0,patientsOnly:e.spotlightPatientsOnly,userMenuEnabled:!0,version:e.version,showLayoutVersionToggle:e.showLayoutVersionToggle}):void 0):(l={height:60},u={width:eP,breakpoint:`sm`,collapsed:{desktop:!a||!t,mobile:!a||!t}},d=a&&(0,I.jsx)(kM,{pathname:e.pathname,searchParams:e.searchParams,headerSearchDisabled:e.headerSearchDisabled,logo:e.logo,version:e.version,navbarOpen:t,navbarToggle:c,notifications:e.notifications}),f=a&&t?(0,I.jsx)(YN,{pathname:e.pathname,searchParams:e.searchParams,menus:e.menus,navbarToggle:c,closeNavbar:s,displayAddBookmark:e.displayAddBookmark,resourceTypeSearchDisabled:e.resourceTypeSearchDisabled,patientsOnly:e.spotlightPatientsOnly}):void 0),(0,I.jsxs)(af,{header:l,navbar:u,padding:0,children:[d,f,(0,I.jsx)(af.Main,{className:zj.main,children:(0,I.jsx)(Lj,{children:(0,I.jsx)(b.Suspense,{fallback:(0,I.jsx)(Rj,{}),children:e.children})})})]})}var rP=`https://ccda.medplum.com`,iP=`https://ccda-validator.medplum.com/`;function aP(e){let{url:t}=e,[n,r]=(0,b.useState)(!1),i=(0,b.useRef)(null),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{t&&n&&i.current&&(Wj(i.current,{command:`loadCcdaXml`,value:t}).catch(console.error),r(!1))},[t,n]),t?(0,I.jsxs)(`div`,{"data-testid":`ccda-iframe`,style:{maxWidth:e.maxWidth},children:[(0,I.jsx)(`div`,{style:{minHeight:400},children:(0,I.jsx)(`iframe`,{title:`C-CDA Viewer`,width:`100%`,height:`400`,ref:i,src:rP,allowFullScreen:!0,frameBorder:0,seamless:!0,onLoad:()=>r(!0)})}),(0,I.jsxs)(`div`,{style:{marginTop:`10px`,marginBottom:`10px`,display:`flex`,alignItems:`center`},children:[(0,I.jsx)(U,{type:`button`,onClick:async()=>{if(t)try{c(!0);let e=await(await fetch(t)).text(),n=new FormData;n.append(`ccdaFile`,new Blob([e],{type:`text/xml`}),`ccda.xml`);let r=await fetch(`${iP}referenceccdaservice/?validationObjective=C-CDA_IG_Plus_Vocab&referenceFileName=No%20scenario%20File&curesUpdate=true&severityLevel=WARNING`,{method:`POST`,body:n,credentials:`omit`,redirect:`manual`});if(!r.ok)throw Error(`Validation failed: ${r.status} ${r.statusText}`);o(await r.json())}catch(e){o(void 0),console.error(`CCDA validation error:`,e)}finally{c(!1)}},disabled:s,children:s?`Validating...`:`Validate`}),a&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{style:{marginLeft:`15px`},children:[(0,I.jsx)(`strong`,{children:`Validation Results:`}),` `,a?a.resultsMetaData.resultMetaData.filter(e=>e?.type.includes(`Error`)).reduce((e,t)=>e+(t.count||0),0):0,` errors found`]}),(0,I.jsx)(U,{type:`button`,onClick:()=>{a&&Gj(JSON.stringify(a,null,2),`ccda-validation-results`)},color:`green`,style:{marginLeft:`auto`},children:`Download Full Results`})]})]})]}):null}function oP(e){let{maxRetries:t=5,...n}=e,[r,i]=(0,b.useState)(0),[a,o]=(0,b.useState)(`fetching`),s=(0,b.useRef)(void 0);return(0,b.useEffect)(()=>()=>{s.current!==void 0&&clearTimeout(s.current)},[]),a===`failed`?(0,I.jsx)(`div`,{className:`image-placeholder`,children:`Image unavailable`}):a===`backoff`?(0,I.jsx)(cu,{}):(0,I.jsx)(`img`,{onLoad:()=>o(`loaded`),onError:()=>{if(r>=t){o(`failed`);return}o(`backoff`);let e=Math.min(1e3*2**r,16e3);s.current=setTimeout(()=>{i(e=>e+1),o(`fetching`),s.current=void 0},e)},...n})}function sP(e){let{contentType:t,url:n,title:r}=e.value??{},i=ek(n);return i?(0,I.jsxs)(`div`,{"data-testid":`attachment-display`,children:[t?.startsWith(`image/`)&&(0,I.jsx)(oP,{"data-testid":`attachment-image`,style:{maxWidth:e.maxWidth},src:i,alt:r}),t?.startsWith(`video/`)&&(0,I.jsx)(`video`,{"data-testid":`attachment-video`,style:{maxWidth:e.maxWidth},controls:!0,children:(0,I.jsx)(`source`,{type:t,src:i})}),(t?.startsWith(`text/`)||t===`application/json`||t===`application/pdf`)&&(0,I.jsx)(`div`,{"data-testid":`attachment-iframe`,style:{maxWidth:e.maxWidth,minHeight:400},children:(0,I.jsx)(`iframe`,{title:`Attachment`,width:`100%`,height:`400`,src:i+`#navpanes=0`,allowFullScreen:!0,frameBorder:0,seamless:!0})}),t===ZE.CDA_XML&&(0,I.jsx)(aP,{url:i}),(0,I.jsx)(`div`,{"data-testid":`download-link`,style:{padding:`2px 16px 16px 16px`},children:(0,I.jsx)(Pd,{href:n,"data-testid":`attachment-details`,target:`_blank`,rel:`noopener noreferrer`,download:cP(r),children:r||`Download`})})]}):null}function cP(e){return e?.includes(`.`)?e:void 0}var lP={root:`_root_1bd5a_1`,compact:`_compact_1bd5a_19`};function uP(e){let{children:t,compact:n}=e;return(0,I.jsx)(`dl`,{className:Mn(lP.root,{[lP.compact]:n}),children:t})}function dP(e){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`dt`,{children:e.term}),(0,I.jsx)(`dd`,{children:e.children})]})}function fP(e){let t=e.values?.map((t,n)=>(0,I.jsx)(`div`,{children:(0,I.jsx)(sP,{value:t,maxWidth:e.maxWidth})},`attatchment-`+n)),n;if(e.includeDescriptionListEntry){if(e.property===void 0)throw Error(`props.property is required when includeDescriptionListEntry is true`);if(!wC(e.path))throw Error(`props.path is required when includeDescriptionListEntry is true`);n=(0,I.jsx)(dP,{term:Iw(e.path.split(`.`).pop()),children:t})}else n=(0,I.jsx)(I.Fragment,{children:t});return n}function pP(e){let t=Z(),n=(0,b.useRef)(null);function r(e){Bj(e),n.current?.click()}function i(e){Bj(e);let t=e.target.files;t&&Array.from(t).forEach(a)}function a(n){n&&n.name&&(e.onUploadStart&&e.onUploadStart(),t.createAttachment({data:n,contentType:n.type||`application/octet-stream`,filename:n.name,securityContext:e.securityContext,onProgress:e.onUploadProgress}).then(t=>e.onUpload(t)).catch(t=>{e.onUploadError&&e.onUploadError(Zx(t))}))}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{disabled:e.disabled,type:`file`,"data-testid":`upload-file-input`,style:{display:`none`},ref:n,onChange:e=>i(e)}),e.children({onClick:r,disabled:e.disabled})]})}function mP(e){let[t,n]=(0,b.useState)(e.defaultValue??[]);function r(t){n(t),e.onChange&&e.onChange(t)}return(0,I.jsxs)(`table`,{style:{width:`100%`},children:[(0,I.jsxs)(`colgroup`,{children:[(0,I.jsx)(`col`,{width:`97%`}),(0,I.jsx)(`col`,{width:`3%`})]}),(0,I.jsxs)(`tbody`,{children:[t.map((n,i)=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:(0,I.jsx)(sP,{value:n,maxWidth:200})}),(0,I.jsx)(`td`,{children:(0,I.jsx)(gu,{disabled:e.disabled,title:`Remove`,variant:`subtle`,size:`sm`,color:`gray`,onClick:e=>{Bj(e);let n=t.slice();n.splice(i,1),r(n)},children:(0,I.jsx)(AA,{})})})]},`${i}-${t.length}`)),(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{}),(0,I.jsx)(`td`,{children:(0,I.jsx)(pP,{disabled:e.disabled,onUpload:e=>{r([...t,e])},children:e=>(0,I.jsx)(gu,{...e,title:`Add`,variant:`subtle`,size:`sm`,color:e.disabled?`gray`:`green`,children:(0,I.jsx)(MA,{})})})})]})]})]})}function hP(e){let[t,n]=(0,b.useState)(e.defaultValue);function r(t){n(t),e.onChange&&e.onChange(t)}return t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(sP,{value:t,maxWidth:200}),(0,I.jsx)(U,{disabled:e.disabled,onClick:e=>{Bj(e),r(void 0)},children:`Remove`})]}):(0,I.jsx)(pP,{disabled:e.disabled,securityContext:e.securityContext,onUpload:r,children:e=>(0,I.jsx)(U,{...e,children:`Upload...`})})}var gP={root:`_root_1vii2_1`};function _P(e){let{children:t,...n}=e;return(0,I.jsx)(am,{className:gP.root,...n,children:t})}var vP={paper:`_paper_1igaj_1`,fill:`_fill_1igaj_20`};function yP(e){let{width:t,fill:n,className:r,children:i,...a}=e,o=t?{maxWidth:t}:void 0;return(0,I.jsx)(yl,{className:Mn(vP.paper,n&&vP.fill,r),style:o,shadow:`sm`,radius:`sm`,withBorder:!0,...a,children:i})}function bP(e){let{children:t,...n}=e;return(0,I.jsx)(_P,{children:(0,I.jsx)(yP,{...n,children:t})})}function xP(e){return(0,I.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 180 180`,style:{width:e.size,height:e.size},children:[(0,I.jsx)(`title`,{children:`Medplum Logo`}),(0,I.jsx)(`path`,{fill:e.fill??`#9c36b5`,d:`M84 56c-3-15-15-24-23-28l5-10c8 2 14 8 20 14 0-12 1-16 5-21 8-9 13-9 41-9 0 7 1 18-3 24-7 9-16 7-41 8 5 8 7 14 8 22 36-24 74-7 74 39 0 42-40 83-80 83s-80-41-80-83c0-46 38-63 74-39Zm-3 43H65c-4 0-7 3-7 7v4c0 4 3 7 7 7h16v16c0 4 3 7 7 7h4c4 0 7-3 7-7v-16h16c4 0 7-3 7-7v-4c0-4-3-7-7-7H99V83c0-4-3-7-7-7h-4c-4 0-7 3-7 7z`})]})}function SP(e,t){return e?.issue?.filter(e=>TP(e.expression?.[0],t))?.map(e=>e.details?.text)?.join(`
198
+ `)}function CP(e,t){return e?.issue?.filter(e=>TP(e.expression?.[0],t))}var wP=/\[\d+\]/;function TP(e,t){if((typeof e==`string`&&wP.test(e))!==(typeof t==`string`&&wP.test(t))&&(e=e?.replace(wP,``),t=t?.replace(wP,``)),e===t)return!0;if(!e||!t)return!1;let n=e.indexOf(`.`);if(n>=0&&e.substring(n+1)===t)return!0;let r=t.indexOf(`.`);return r>=0&&t.substring(r+1)===e}function EP(e){let{onSuccess:t}=e,n=Z(),[r,i]=(0,b.useState)(),[a,o]=(0,b.useState)(!1);return(0,I.jsx)(bP,{width:450,children:(0,I.jsxs)(TN,{onSubmit:e=>{i(void 0),n.post(`auth/changepassword`,e).then(()=>{o(!0),t?.()}).catch(e=>i(Zx(e)))},children:[(0,I.jsxs)(_d,{direction:`column`,align:`center`,justify:`center`,children:[(0,I.jsx)(xP,{size:32}),(0,I.jsx)(q,{children:`Change password`})]}),!a&&(0,I.jsxs)(G,{gap:`xl`,mt:`xl`,children:[(0,I.jsx)(sv,{name:`oldPassword`,label:`Old password`,required:!0,autoFocus:!0,error:SP(r,`oldPassword`)}),(0,I.jsx)(sv,{name:`newPassword`,label:`New password`,required:!0,error:SP(r,`newPassword`)}),(0,I.jsx)(sv,{name:`confirmPassword`,label:`Confirm new password`,required:!0,error:SP(r,`confirmPassword`)}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,children:(0,I.jsx)(U,{type:`submit`,children:`Change password`})})]}),a&&(0,I.jsx)(`div`,{"data-testid":`success`,children:`Password changed successfully`})]})})}var DP=/^patient\/Condition\.(?:\*|c?r?u?d?s?)$/,OP=`?category=http://terminology.hl7.org/CodeSystem/condition-category|encounter-diagnosis`,kP=`?category=http://terminology.hl7.org/CodeSystem/condition-category|problem-list-item`,AP=`?category=http://hl7.org/fhir/us/core/CodeSystem/condition-category|health-concern`,jP=/^patient\/Observation\.(?:\*|c?r?u?d?s?)$/,MP=`?category=http://hl7.org/fhir/us/core/CodeSystem/us-core-observation-category|clinical-test`,NP=`?category=http://terminology.hl7.org/CodeSystem/observation-category|laboratory`,PP=`?category=http://terminology.hl7.org/CodeSystem/observation-category|social-history`,FP=`?category=http://hl7.org/fhir/us/core/CodeSystem/us-core-category|sdoh`,IP=`?category=http://terminology.hl7.org/CodeSystem/observation-category|survey`,LP=`?category=http://terminology.hl7.org/CodeSystem/observation-category|vital-signs`;function RP(e){let t=Z();return(0,I.jsx)(TN,{onSubmit:n=>{t.post(`auth/scope`,{login:e.login,scope:Object.keys(n).join(` `)}).then(e.handleAuthResponse).catch(console.log)},children:(0,I.jsxs)(G,{children:[(0,I.jsxs)(_d,{direction:`column`,align:`center`,justify:`center`,children:[e.logo??(0,I.jsx)(xP,{size:32}),(0,I.jsx)(q,{order:3,py:`lg`,children:e.title??`Choose scope`}),e.children]}),(0,I.jsx)(G,{children:(e.scope??`openid`).split(` `).map(e=>{let t;return DP.test(e)?t=[e+OP,e+kP,e+AP]:jP.test(e)&&(t=[e+MP,e+NP,e+PP,e+FP,e+IP,e+LP]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(lp,{id:e,name:e,label:e,defaultChecked:!0},e),t?.map(e=>(0,I.jsx)(lp,{id:e,name:e,label:e},e))]},e+`_group`)})}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,children:(0,I.jsx)(EN,{fullWidth:!0,children:e.submitLabel??`Set Scope`})})]})})}function zP(e){let[t,n]=(0,b.useState)();return(0,I.jsxs)(TN,{onSubmit:t=>{n(void 0),e.onSubmit(t)?.catch(e=>n(Qx(e)))},children:[(0,I.jsxs)(Kp,{style:{flexDirection:`column`},children:[(0,I.jsx)(xP,{size:32}),(0,I.jsx)(q,{order:3,py:`lg`,children:e.title}),!e.qrCodeUrl&&e.description&&(0,I.jsx)(H,{c:`dimmed`,mb:`lg`,mt:`-lg`,children:e.description})]}),t&&(0,I.jsx)(Dd,{icon:(0,I.jsx)(fA,{size:16}),title:`Error`,color:`red`,mb:`lg`,children:t}),e.qrCodeUrl&&(0,I.jsx)(Kp,{children:(0,I.jsxs)(G,{mb:`xl`,children:[e.description&&(0,I.jsx)(H,{c:`dimmed`,mb:`md`,mt:`-lg`,ta:`center`,children:e.description}),(0,I.jsx)(Im,{src:e.qrCodeUrl,alt:`Multi Factor Auth QR Code`,w:`60%`,mx:`auto`,radius:`md`,p:`xs`,bg:`var(--mantine-color-white)`,style:{border:`1px solid light-dark(var(--mantine-color-gray-2), var(--mantine-color-dark-4))`}})]})}),(0,I.jsx)(G,{gap:`sm`,children:(0,I.jsx)(yb,{name:`token`,label:`MFA code`,autoComplete:`one-time-code`,required:!0,autoFocus:!0})}),(0,I.jsx)(G,{gap:`xs`,pt:`md`,children:(0,I.jsx)(EN,{fullWidth:!0,children:e.buttonText})})]})}function BP(e){let{outcome:t,issues:n,...r}=e,i=t?.issue||n;return!i||i.length===0?null:(0,I.jsx)(Dd,{icon:(0,I.jsx)(fA,{size:16}),color:`red`,...r,children:i.map(e=>(0,I.jsx)(`div`,{"data-testid":`text-field-error`,children:eS(e)},e.details?.text))})}function VP(e){let t=Z(),[n,r]=(0,b.useState)(),i=CP(n,void 0);return(0,I.jsxs)(TN,{onSubmit:async n=>{try{e.handleAuthResponse(await t.startNewProject({login:e.login,projectName:n.projectName}))}catch(e){r(Zx(e))}},children:[(0,I.jsxs)(_d,{direction:`column`,align:`center`,justify:`center`,children:[(0,I.jsx)(xP,{size:32}),(0,I.jsx)(q,{order:3,py:`lg`,children:`Create a new project`})]}),(0,I.jsx)(BP,{issues:i,mb:`lg`}),(0,I.jsx)(G,{gap:`sm`,children:(0,I.jsx)(yb,{name:`projectName`,label:`Project Name`,placeholder:`My Project`,required:!0,autoFocus:!0,error:SP(n,`projectName`)})}),(0,I.jsxs)(G,{gap:`xs`,mt:`md`,children:[(0,I.jsx)(EN,{fullWidth:!0,children:`Create Project`}),(0,I.jsxs)(H,{c:`dimmed`,size:`xs`,pt:`lg`,ta:`center`,children:[`By clicking "Create Project" you agree to the Medplum`,` `,(0,I.jsx)(Pd,{href:`https://www.medplum.com/privacy`,children:`Privacy\xA0Policy`}),` and `,(0,I.jsx)(Pd,{href:`https://www.medplum.com/terms`,children:`Terms\xA0of\xA0Service`}),`.`]})]})]})}function HP(e,t){let n=document.getElementsByTagName(`head`)[0],r=document.createElement(`script`);r.async=!0,r.src=e,r.onload=t??null,n.appendChild(r)}function UP(e){let{googleClientId:t,handleGoogleCredential:n}=e,r=(0,b.useRef)(null),[i,a]=(0,b.useState)(typeof google<`u`),o=(0,b.useRef)(!1),s=(0,b.useRef)(!1);return(0,b.useEffect)(()=>{if(typeof google>`u`){HP(`https://accounts.google.com/gsi/client`,()=>a(!0));return}o.current||=(google.accounts.id.initialize({client_id:t,callback:n}),!0),r.current&&!s.current&&(google.accounts.id.renderButton(r.current,{type:`standard`,logo_alignment:`center`,width:r.current.clientWidth}),s.current=!0)},[t,i,n]),t?(0,I.jsx)(z,{ref:r,w:`100%`,h:40,display:`flex`,style:{justifyContent:`center`}}):null}function WP(e){if(e)return e;let t=LE.getOrigin();if(t&&[].includes(t))return`__GOOGLE_CLIENT_ID__`}function GP(e){typeof grecaptcha>`u`&&HP(`https://www.google.com/recaptcha/api.js?render=`+e)}function KP(e){return new Promise((t,n)=>{grecaptcha.ready(async()=>{try{t(await grecaptcha.execute(e,{action:`submit`}))}catch(e){n(e)}})})}function qP(e){let t=WP(e.googleClientId),n=e.recaptchaSiteKey,r=Z(),[i,a]=(0,b.useState)(),o=CP(i,void 0);return(0,b.useEffect)(()=>{n&&GP(n)},[n]),(0,I.jsxs)(TN,{onSubmit:async t=>{a(void 0);try{let i=``;n&&(i=await KP(n)),e.handleAuthResponse(await r.startNewUser({projectId:e.projectId,clientId:e.clientId,firstName:t.firstName,lastName:t.lastName,email:t.email,password:t.password,remember:t.remember===`true`,recaptchaSiteKey:n,recaptchaToken:i}))}catch(e){a(Zx(e))}},children:[(0,I.jsx)(_d,{direction:`column`,align:`center`,justify:`center`,children:e.children}),(0,I.jsx)(BP,{issues:o,mb:`lg`}),t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(z,{style:{minHeight:40},children:(0,I.jsx)(UP,{googleClientId:t,handleGoogleCredential:async t=>{try{e.handleAuthResponse(await r.startGoogleLogin({googleClientId:t.clientId,googleCredential:t.credential,projectId:e.projectId,createUser:!0}))}catch(e){a(Zx(e))}}})}),(0,I.jsx)(dm,{label:`or`,labelPosition:`center`,my:`lg`})]}),(0,I.jsxs)(G,{gap:`sm`,children:[(0,I.jsx)(yb,{name:`firstName`,type:`text`,label:`First name`,placeholder:`First name`,required:!0,autoFocus:!0,error:SP(i,`firstName`)}),(0,I.jsx)(yb,{name:`lastName`,type:`text`,label:`Last name`,placeholder:`Last name`,required:!0,error:SP(i,`lastName`)}),(0,I.jsx)(yb,{name:`email`,type:`email`,label:`Email`,placeholder:`name@domain.com`,required:!0,error:SP(i,`email`)}),(0,I.jsx)(sv,{name:`password`,label:`Password`,autoComplete:`off`,required:!0,error:SP(i,`password`)})]}),(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsx)(lp,{id:`remember`,name:`remember`,label:`Remember me`,size:`xs`,style:{lineHeight:1},pt:`md`,pb:`xs`}),(0,I.jsx)(EN,{fullWidth:!0,children:`Register Account`}),(0,I.jsxs)(H,{c:`dimmed`,size:`xs`,pt:`lg`,ta:`center`,children:[`By clicking "Register Account" you agree to the Medplum`,` `,(0,I.jsx)(Pd,{href:`https://www.medplum.com/privacy`,children:`Privacy\xA0Policy`}),` and `,(0,I.jsx)(Pd,{href:`https://www.medplum.com/terms`,children:`Terms\xA0of\xA0Service`}),`.`]}),(0,I.jsxs)(H,{c:`dimmed`,size:`xs`,ta:`center`,children:[`This site is protected by reCAPTCHA and the Google`,` `,(0,I.jsx)(Pd,{href:`https://policies.google.com/privacy`,children:`Privacy\xA0Policy`}),` and `,(0,I.jsx)(Pd,{href:`https://policies.google.com/terms`,children:`Terms\xA0of\xA0Service`}),` apply.`]})]})]})}function JP(e){let{type:t,projectId:n,clientId:r,googleClientId:i,recaptchaSiteKey:a,onSuccess:o}=e,s=Z(),[c,l]=(0,b.useState)(e.login),[u,d]=(0,b.useState)(),[f,p]=(0,b.useState)(!1);(0,b.useEffect)(()=>{t===`patient`&&c&&s.startNewPatient({login:c,projectId:n}).then(e=>s.processCode(e.code)).then(()=>o()).catch(e=>d(Zx(e)))},[s,t,n,c,o]);function m(e){e.code&&s.processCode(e.code).then(()=>o()).catch(e=>d(Zx(e))),e.login&&l(e.login),e.emailVerificationRequired&&p(!0)}return(0,I.jsxs)(bP,{width:400,px:`xl`,py:`xl`,bdrs:`md`,children:[(0,I.jsx)(BP,{issues:CP(u,void 0),mb:`lg`}),!c&&(0,I.jsx)(qP,{projectId:n,clientId:r,googleClientId:i,recaptchaSiteKey:a,handleAuthResponse:m,children:e.children}),f&&(0,I.jsx)(`div`,{children:`Please check your email for a verification link. Click the link to continue setting up your account.`}),c&&!f&&t===`project`&&(0,I.jsx)(VP,{login:c,handleAuthResponse:m})]})}function YP(e){let{projectId:t,recaptchaSiteKey:n,onSuccess:r,onSignIn:i,onRegister:a}=e,o=Z(),[s,c]=(0,b.useState)(),[l,u]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{n&&GP(n)},[n]),(0,I.jsx)(bP,{width:400,px:`xl`,py:`xl`,bdrs:`md`,children:(0,I.jsxs)(TN,{onSubmit:async e=>{c(void 0);try{let i=``;n&&(i=await KP(n)),await o.post(`auth/resetpassword`,{...e,projectId:t,recaptchaToken:i}),u(!0),r?.()}catch(e){c(Zx(e))}},children:[(0,I.jsxs)(_d,{direction:`column`,align:`center`,justify:`center`,children:[(0,I.jsx)(xP,{size:32}),(0,I.jsx)(q,{order:3,py:`lg`,children:`Reset your password`})]}),(0,I.jsx)(BP,{issues:CP(s,void 0),mb:`lg`}),!l&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(G,{gap:`sm`,mb:`md`,children:(0,I.jsx)(yb,{name:`email`,type:`email`,label:`Email`,placeholder:`name@domain.com`,required:!0,autoFocus:!0,error:SP(s,`email`)})}),(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsx)(EN,{fullWidth:!0,children:`Reset Password`}),i&&(0,I.jsx)(H,{size:`sm`,mt:`lg`,c:`dimmed`,style:{textAlign:`center`},"data-dashlane-ignore":`true`,"data-lp-ignore":`true`,"data-no-autofill":`true`,"data-form-type":`navigation`,children:(0,I.jsx)(Pd,{onClick:i,children:`Back to Sign In`})}),a&&(0,I.jsxs)(H,{size:`sm`,mt:`none`,c:`dimmed`,style:{textAlign:`center`},"data-dashlane-ignore":`true`,"data-lp-ignore":`true`,"data-no-autofill":`true`,"data-form-type":`navigation`,children:[`Don't have an account? `,(0,I.jsx)(Pd,{onClick:a,children:`Sign Up`})]})]})]}),l&&(0,I.jsx)(H,{c:`dimmed`,size:`sm`,ta:`center`,mt:`md`,children:`If the account exists on our system, a password reset email will be sent.`})]})})}function XP(e){let{id:t,secret:n,onSuccess:r,onSignIn:i}=e,a=Z(),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(!1);return(0,I.jsxs)(bP,{width:450,children:[(0,I.jsx)(BP,{issues:CP(o,void 0)}),(0,I.jsxs)(TN,{onSubmit:e=>{if(e.password!==e.confirmPassword){s(Ux(`Passwords do not match`,`confirmPassword`));return}s(void 0),a.post(`auth/setpassword`,{id:t,secret:n,password:e.password}).then(()=>{l(!0),r?.()}).catch(e=>s(Zx(e)))},children:[(0,I.jsxs)(_d,{direction:`column`,align:`center`,justify:`center`,children:[(0,I.jsx)(xP,{size:32}),(0,I.jsx)(q,{children:`Set password`})]}),!c&&(0,I.jsxs)(G,{children:[(0,I.jsx)(sv,{name:`password`,label:`New password`,required:!0,error:SP(o,`password`)}),(0,I.jsx)(sv,{name:`confirmPassword`,label:`Confirm new password`,required:!0,error:SP(o,`confirmPassword`)}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,children:(0,I.jsx)(U,{type:`submit`,children:`Set password`})})]}),c&&(0,I.jsxs)(`div`,{"data-testid":`success`,children:[`Password set. You can now\xA0`,i?(0,I.jsx)(Pd,{component:`button`,type:`button`,onClick:i,children:`sign in`}):`sign in`,`.`]})]})]})}function ZP(e){let[t,n]=(0,b.useState)();return t?(0,I.jsx)($P,{email:t,resetEmail:()=>n(void 0),...e}):(0,I.jsx)(QP,{setEmail:n,...e})}function QP(e){let{setEmail:t,onRegister:n,handleAuthResponse:r,children:i,disableEmailAuth:a,...o}=e,s=Z(),c=!e.disableGoogleAuth&&WP(e.googleClientId),[l,u]=(0,b.useState)(),d=CP(l,void 0),f=(0,b.useCallback)(async e=>{if(!e.authorizeUrl)return!1;let t=JSON.stringify({...await s.ensureCodeChallenge(o),domain:e.domain,returnTo:LE.getLocation()}),n=new URL(e.authorizeUrl);return n.searchParams.set(`state`,t),LE.assign(n.toString()),!0},[s,o]),p=(0,b.useCallback)(async e=>{await f(await s.post(`auth/method`,{email:e.email}))||t(e.email)},[s,f,t]),m=(0,b.useCallback)(async e=>{try{let t=await s.startGoogleLogin({...o,googleCredential:e.credential});await f(t)||r(t)}catch(e){u(Zx(e))}},[s,o,f,r]);return(0,I.jsxs)(TN,{onSubmit:p,children:[(0,I.jsx)(_d,{direction:`column`,align:`center`,justify:`center`,children:i}),(0,I.jsx)(BP,{issues:d,mb:`lg`}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(z,{style:{minHeight:40},children:(0,I.jsx)(UP,{googleClientId:c,handleGoogleCredential:m})}),!a&&(0,I.jsx)(dm,{label:`or`,labelPosition:`center`,my:`lg`})]}),!a&&(0,I.jsx)(yb,{name:`email`,type:`email`,label:`Email`,mb:`md`,placeholder:`name@domain.com`,required:!0,autoFocus:!0,error:SP(l,`email`),"data-testid":`auth.email`}),(0,I.jsxs)(G,{gap:`xs`,children:[!a&&(0,I.jsx)(EN,{fullWidth:!0,children:`Continue`}),n&&(0,I.jsxs)(H,{size:`sm`,mt:`lg`,c:`dimmed`,style:{textAlign:`center`},"data-dashlane-ignore":`true`,"data-lp-ignore":`true`,"data-no-autofill":`true`,"data-form-type":`navigation`,children:[`Don’t have an account? `,(0,I.jsx)(Pd,{onClick:n,children:`Register`})]})]})]})}function $P(e){let{onForgotPassword:t,handleAuthResponse:n,children:r,...i}=e,a=Z(),[o,s]=(0,b.useState)(),c=CP(o,void 0);return(0,I.jsxs)(TN,{onSubmit:(0,b.useCallback)(e=>a.startLogin({...i,password:e.password,remember:e.remember===`on`}).then(n).catch(e=>s(Zx(e))),[a,i,n]),children:[(0,I.jsx)(_d,{direction:`column`,align:`center`,justify:`center`,children:r}),(0,I.jsx)(BP,{issues:c,mb:`lg`}),(0,I.jsxs)(G,{gap:`sm`,children:[(0,I.jsx)(yb,{label:`Email`,value:e.email,disabled:!0,rightSectionWidth:36,rightSection:(0,I.jsx)(gu,{variant:`subtle`,color:`gray`,onClick:e.resetEmail,"aria-label":`Change email`,children:(0,I.jsx)(uj,{size:`1rem`,stroke:1.5})})}),(0,I.jsx)(sv,{name:`password`,label:`Password`,autoComplete:`off`,required:!0,autoFocus:!0,error:SP(o,`password`),"data-testid":`auth.password`})]}),(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsx)(lp,{id:`remember`,name:`remember`,label:`Remember me`,size:`xs`,style:{lineHeight:1},pt:`md`,pb:`xs`}),(0,I.jsx)(EN,{children:`Sign In`}),t&&(0,I.jsx)(H,{size:`sm`,mt:`lg`,c:`dimmed`,style:{textAlign:`center`},"data-dashlane-ignore":`true`,"data-lp-ignore":`true`,"data-no-autofill":`true`,"data-form-type":`navigation`,children:(0,I.jsx)(Pd,{onClick:t,children:`Reset Password`})})]})]})}function eF(e){let t=Z(),n=If(),[r,i]=(0,b.useState)(``),[a,o]=(0,b.useState)();function s(e){return!!e?.toLowerCase()?.includes(r.toLowerCase())}function c(e){return s(e.profile?.display)||s(e.project?.display)||s(tF(e))}function l(n){t.post(`auth/profile`,{login:e.login,profile:n}).then(e.handleAuthResponse).catch(e=>o(Zx(e)))}let u=e.memberships.filter(c).slice(0,10).map(e=>(0,I.jsx)(zf.Option,{value:e.id,className:eM.interactive,children:(0,I.jsx)(nM,{membership:e,label:tF(e)})},e.id));return(0,I.jsxs)(G,{gap:`0`,children:[(0,I.jsxs)(_d,{justify:`center`,align:`center`,direction:`column`,wrap:`nowrap`,children:[(0,I.jsx)(xP,{size:32}),(0,I.jsx)(q,{order:3,py:`lg`,children:`Choose a Project`})]}),(0,I.jsx)(BP,{outcome:a,mb:`lg`}),(0,I.jsxs)(zf,{store:n,onOptionSubmit:l,children:[(0,I.jsx)(zf.EventsTarget,{children:(0,I.jsx)(yb,{placeholder:`Search`,value:r,mb:`md`,autoFocus:!0,leftSection:(0,I.jsx)(bj,{size:16}),onChange:e=>{i(e.currentTarget.value),n.updateSelectedOptionIndex()}})}),(0,I.jsx)(`div`,{children:(0,I.jsx)(zf.Options,{style:{marginLeft:`-10px`,marginRight:`-10px`,marginBottom:`-10px`},children:u.length>0?u:(0,I.jsx)(zf.Empty,{children:`Nothing found...`})})})]}),(0,I.jsx)(H,{size:`sm`,ta:`center`,mt:`md`,children:(0,I.jsx)(Pd,{component:`button`,type:`button`,onClick:()=>{window.location.href=`/signin?project=new&login=${e.login}`},children:`Create a new project`})})]})}function tF(e){return _C(e,`https://medplum.com/identifier/label`)}function nF(e){let{login:t,chooseScopes:n,chooseScopeFormProps:r,onSuccess:i,onForgotPassword:a,onRegister:o,onCode:s,...c}=e,l=Z(),[u,d]=(0,b.useState)(),f=(0,b.useRef)(!1),[p,m]=(0,b.useState)(!1),[h,g]=(0,b.useState)(),[_,v]=(0,b.useState)(!1),[y,x]=(0,b.useState)(),S=(0,b.useCallback)(e=>{s?s(e):l.processCode(e).then(()=>{i&&i()}).catch(e=>J({color:`red`,message:Qx(e)}))},[l,s,i]),C=(0,b.useCallback)(e=>{m(!!e.mfaEnrollRequired),g(e.enrollQrCode),v(!!e.mfaRequired),e.login&&d(e.login),e.memberships&&x(e.memberships),e.code&&(n?x(void 0):S(e.code))},[n,S]),w=(0,b.useCallback)(e=>{S(e.code)},[S]);return(0,b.useEffect)(()=>{t&&!f.current&&!u&&(f.current=!0,l.get(`auth/login/`+t).then(C).catch(e=>J({color:`red`,message:Qx(e)})))},[l,t,f,u,C]),(0,I.jsx)(bP,{width:400,px:`xl`,py:`xl`,bdrs:`md`,children:u?p&&h?(0,I.jsx)(zP,{title:`Enroll in MFA`,description:`Scan this QR code with your authenticator app.`,buttonText:`Enroll`,qrCodeUrl:h,onSubmit:async e=>{C(await l.post(`auth/mfa/login-enroll`,{login:u,token:e.token}))}}):_?(0,I.jsx)(zP,{title:`Enter MFA code`,description:`Enter the code from your authenticator app.`,buttonText:`Submit Code`,onSubmit:async e=>{C(await l.post(`auth/mfa/verify`,{login:u,token:e.token}))}}):e.projectId===`new`?(0,I.jsx)(VP,{login:u,handleAuthResponse:C}):y?(0,I.jsx)(eF,{login:u,memberships:y,handleAuthResponse:C}):e.chooseScopes?(0,I.jsx)(RP,{login:u,scope:e.scope,handleAuthResponse:w,...r}):(0,I.jsx)(`div`,{children:`Success`}):(0,I.jsx)(ZP,{onForgotPassword:a,onRegister:o,handleAuthResponse:C,disableGoogleAuth:e.disableGoogleAuth,disableEmailAuth:e.disableEmailAuth,...c,children:e.children})})}function rF(e){return(0,I.jsx)(I.Fragment,{children:Sw(e.value)})}function iF(e){return(0,I.jsx)(I.Fragment,{children:Cw(e.value,e.includeCode)})}function aF(e){let t=e.value;if(!t)return null;let n=[];return t.value&&n.push(t.value),(t.use||t.system)&&(n.push(` [`),t.use&&n.push(t.use),t.use&&t.system&&n.push(` `),t.system&&n.push(t.system),n.push(`]`)),(0,I.jsx)(I.Fragment,{children:n.join(``).trim()})}function oF(e){let t=e.value;return t?(0,I.jsxs)(I.Fragment,{children:[t.name,t.name&&`: `,t.telecom?.map(e=>(0,I.jsx)(aF,{value:e},`telecom-${t.name}-${e.value}`))]}):null}function sF(e,t,n){let r=PS(e,t,{profileUrl:n});return r?Array.isArray(r)?[r.map(e=>e.value),r[0].type]:[r.value,r.type]:[void 0,`undefined`]}function cF(e,t,n){let r=FS(e,t,n);return r?Array.isArray(r)?[r.map(e=>e.value),r[0].type]:[r.value,r.type]:[void 0,`undefined`]}function lF(e){let{elementDefinitionType:t}=e,n=Z(),r=(0,b.useContext)(nA),[i,a]=(0,b.useState)(mS(`Extension`)),o=(0,b.useMemo)(()=>{if(wC(t?.profile))return t.profile[0]},[t]),[s,c]=(0,b.useState)(o!==void 0);if((0,b.useEffect)(()=>{o&&(c(!0),n.requestProfileSchema(o).then(()=>{let e=gS(o);c(!1),e&&a(e)}).catch(e=>{c(!1),console.warn(e)}))},[n,o]),o&&(s||!hS(o)))return(0,I.jsx)(`div`,{children:`Loading...`});if(i.elements[`value[x]`]?.max!==0){let[t,n]=sF({type:`Extension`,value:e.value},`value[x]`,o??r.profileUrl);return(0,I.jsx)(CF,{propertyType:n,value:t})}return(0,I.jsx)(DF,{path:e.path,value:{type:i.type,value:e.value},compact:e.compact,ignoreMissingValues:e.ignoreMissingValues,link:e.link,profileUrl:o})}function uF(e){let t=e.value;return t?(0,I.jsx)(I.Fragment,{children:lw(t,e.options)}):null}function dF(e){return(0,I.jsxs)(`div`,{children:[e.value?.system,`: `,e.value?.value]})}function fF(e){return(0,I.jsx)(I.Fragment,{children:xw(e.value)})}function pF(e){return(0,I.jsx)(I.Fragment,{children:bw(e.value,e.precision)})}function mF(e){return(0,I.jsx)(I.Fragment,{children:yw(e.value,e.precision,e.exclusive)})}function hF(e){let t=e.value;return t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(pF,{value:t.numerator,precision:e.precision}),`\xA0/\xA0`,(0,I.jsx)(pF,{value:t.denominator,precision:e.precision})]}):null}function gF(e){if(!e.value)return null;let t=e.value.display||e.value.reference||yC(e.value);return e.link!==!1&&e.value.reference?(0,I.jsx)(Kj,{to:e.value,children:t}):(0,I.jsx)(I.Fragment,{children:t})}function _F(e,t,n,r){if(!wC(n?.slices))return[e];let i=Array(t.length+1);for(let e=0;e<i.length;e++)i[e]=[];for(let a of e){let e=mO(a,t,n.discriminator,r),o=e?t.findIndex(t=>t.name===e):-1;o===-1&&(o=t.length),i[o].push(a)}return i}async function vF({medplum:e,property:t}){return new Promise((n,r)=>{if(!t.slicing){n([]);return}let i=[],a=[],o=[];for(let n of t.slicing.slices){if(!fO(n)){console.debug(`Unsupported slice definition`,n);continue}let t;wC(n.elements)||(t=n.type[0]?.profile?.[0]),i.push(n),a.push(t),t&&o.push(e.requestProfileSchema(t))}Promise.all(o).then(()=>{for(let e=0;e<i.length;e++){let t=i[e],n=a[e];n&&(t.typeSchema=gS(n))}n(i)}).catch(r)})}function yF(e,t,n){return t===void 0?n:(0,I.jsx)(e,{value:t,children:n})}function bF(e){let{slice:t,property:n}=e,r=t.typeSchema?.elements??t.elements,i=(0,b.useContext)(nA),a=(0,b.useMemo)(()=>{if(wC(r))return sO({parentContext:i,elements:r,path:e.path,profileUrl:t.typeSchema?.url})},[i,e.path,t.typeSchema?.url,r]);return yF(nA.Provider,a,(0,I.jsx)(I.Fragment,{children:e.value.map((r,i)=>(0,I.jsx)(`div`,{children:(0,I.jsx)(CF,{property:n,path:e.path,arrayElement:!0,elementDefinitionType:t.type[0],propertyType:t.type[0].code,value:r,ignoreMissingValues:e.ignoreMissingValues,link:e.link})},`${i}-${e.value.length}`))}))}var xF=50;function SF(e){let{property:t,propertyType:n}=e,r=Z(),i=(0,b.useMemo)(()=>Array.isArray(e.values)?e.values:[],[e.values]),[a,o]=(0,b.useState)(!0),[s,c]=(0,b.useState)([]),[l,u]=(0,b.useState)(()=>[i]),[d,f]=(0,b.useState)(0),p=(0,b.useContext)(nA);if((0,b.useEffect)(()=>{vF({medplum:r,property:t}).then(e=>{f(i.length),c(e),u(_F(i.slice(0,xF),e,t.slicing,p.profileUrl)),o(!1)}).catch(e=>{console.error(e),o(!1)})},[r,t,p.profileUrl,u,i]),a)return(0,I.jsx)(`div`,{children:`Loading...`});let m;if(t.type[0]?.code!==`Extension`){let r=l[s.length],i=r.map((i,a)=>(0,I.jsx)(`div`,{children:(0,I.jsx)(CF,{path:e.path,arrayElement:!0,property:t,propertyType:n,value:i,ignoreMissingValues:e.ignoreMissingValues,link:e.link})},`${a}-${r.length}`));if(e.includeDescriptionListEntry){if(!wC(e.path))throw Error(`props.path is required when includeDescriptionListEntry is true`);m=(0,I.jsx)(dP,{term:Iw(e.path.split(`.`).pop()),children:i})}else m=(0,I.jsx)(I.Fragment,{children:i})}return(0,I.jsxs)(I.Fragment,{children:[s.map((n,r)=>{if(!e.path)throw Error(`Displaying a resource property with slices of type ${e.propertyType} requires path`);let i=(0,I.jsx)(bF,{path:e.path,slice:n,property:t,value:l[r],ignoreMissingValues:e.ignoreMissingValues,link:e.link},n.name);return e.includeDescriptionListEntry&&(i=(0,I.jsx)(dP,{term:Iw(n.name),children:i},n.name)),i}),m,d>xF&&(0,I.jsx)(V,{justify:`right`,children:(0,I.jsxs)(H,{children:[`... `,d,` total values`]})})]})}function CF(e){let{property:t,propertyType:n,value:r}=e;if(t?.path?.endsWith(`.id`))return(0,I.jsxs)(_d,{gap:3,align:`center`,children:[r,!CC(r)&&(0,I.jsx)(sm,{value:r,timeout:2e3,children:({copied:e,copy:t})=>(0,I.jsx)(Qv,{label:e?`Copied`:`Copy`,withArrow:!0,position:`right`,children:(0,I.jsx)(gu,{variant:`subtle`,color:e?`teal`:`gray`,onClick:t,children:e?(0,I.jsx)(EA,{size:`1rem`}):(0,I.jsx)(PA,{size:`1rem`})})})})]});if(t&&(t.isArray||t.max>1)&&!e.arrayElement)return n===Y.Attachment?(0,I.jsx)(fP,{values:r,maxWidth:e.maxWidth,includeDescriptionListEntry:e.includeArrayDescriptionListEntry,property:t,path:e.path}):(0,I.jsx)(SF,{path:e.path,property:t,propertyType:n,values:r,includeDescriptionListEntry:e.includeArrayDescriptionListEntry,ignoreMissingValues:e.ignoreMissingValues,link:e.link});switch(n){case Y.boolean:return(0,I.jsx)(I.Fragment,{children:r===void 0?``:(!!r).toString()});case Y.SystemString:case Y.string:return e.property?.path?.toLowerCase().includes(`secret`)?(0,I.jsx)(wF,{value:r}):(0,I.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:r});case Y.code:case Y.date:case Y.decimal:case Y.id:case Y.integer:case Y.positiveInt:case Y.unsignedInt:case Y.uri:case Y.url:case Y.xhtml:return PC(r)&&!FC(r)?(console.warn(`Non-standard FHIR data or missing primitive value with extension`,{path:e.path,propertyType:n,value:r}),null):(0,I.jsx)(I.Fragment,{children:r?.toString()});case Y.canonical:return(0,I.jsx)(gF,{value:{reference:r},link:e.link});case Y.dateTime:case Y.instant:return(0,I.jsx)(I.Fragment,{children:fw(r)});case Y.time:return(0,I.jsx)(I.Fragment,{children:dw(r)});case Y.markdown:return(0,I.jsx)(`pre`,{children:r});case Y.Address:return(0,I.jsx)($k,{value:r});case Y.Annotation:return(0,I.jsx)(I.Fragment,{children:r?.text});case Y.Attachment:return(0,I.jsx)(sP,{value:r,maxWidth:e.maxWidth});case Y.CodeableConcept:return(0,I.jsx)(rF,{value:r});case Y.Coding:return(0,I.jsx)(iF,{value:r});case Y.ContactDetail:return(0,I.jsx)(oF,{value:r});case Y.ContactPoint:return(0,I.jsx)(aF,{value:r});case Y.HumanName:return(0,I.jsx)(uF,{value:r});case Y.Identifier:return(0,I.jsx)(dF,{value:r});case Y.Money:return(0,I.jsx)(fF,{value:r});case Y.Period:return(0,I.jsx)(I.Fragment,{children:pw(r)});case Y.Quantity:case Y.Duration:return(0,I.jsx)(pF,{value:r});case Y.Range:return(0,I.jsx)(mF,{value:r});case Y.Ratio:return(0,I.jsx)(hF,{value:r});case Y.Reference:return(0,I.jsx)(gF,{value:r,link:e.link});case Y.Timing:return(0,I.jsx)(I.Fragment,{children:_w(r)});case Y.Dosage:case Y.UsageContext:if(!e.path)throw Error(`Displaying property of type ${e.propertyType} requires path`);return(0,I.jsx)(DF,{path:e.path,value:{type:n,value:r},compact:!0,ignoreMissingValues:e.ignoreMissingValues});case Y.Extension:if(!e.path)throw Error(`Displaying property of type ${e.propertyType} requires path`);return(0,I.jsx)(lF,{path:e.path,value:r,compact:!0,ignoreMissingValues:e.ignoreMissingValues,elementDefinitionType:e.elementDefinitionType});default:if(!t)throw Error(`Displaying property of type ${e.propertyType} requires element schema`);if(!e.path)throw Error(`Displaying property of type ${e.propertyType} requires path`);return(0,I.jsx)(DF,{path:e.path,value:{type:t.type[0].code,value:r},compact:!0,ignoreMissingValues:e.ignoreMissingValues})}}function wF(e){let[t,n]=(0,b.useState)(!1),r=e.value??``,i=!CC(r),a=`•`.repeat(8);return(0,I.jsxs)(_d,{gap:3,align:`center`,children:[t?(0,I.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:r}):(0,I.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},"aria-hidden":`true`,children:i?a:``}),i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(sm,{value:e.value,timeout:2e3,children:({copied:e,copy:t})=>(0,I.jsx)(Qv,{label:e?`Copied`:`Copy secret`,withArrow:!0,position:`right`,children:(0,I.jsx)(gu,{variant:`subtle`,color:e?`teal`:`gray`,onClick:t,"aria-label":e?`Copied`:`Copy secret`,children:e?(0,I.jsx)(EA,{size:`1rem`}):(0,I.jsx)(PA,{size:`1rem`})})})}),(0,I.jsx)(Qv,{label:t?`Hide secret`:`Show secret`,withArrow:!0,position:`right`,children:(0,I.jsx)(gu,{variant:`subtle`,color:`gray`,onClick:()=>n(!t),"aria-label":t?`Hide secret`:`Show secret`,children:t?(0,I.jsx)(UA,{size:`1rem`}):(0,I.jsx)(WA,{size:`1rem`})})})]})]})}var TF=[`extension`,`modifierExtension`],EF=eA.filter(e=>!TF.includes(e));function DF(e){let t=e.value,{value:n,type:r}=t,i=(0,b.useContext)(nA),a=e.profileUrl??i?.profileUrl,o=(0,b.useMemo)(()=>pS(r,a),[a,r]),s=(0,b.useMemo)(()=>{if(o)return sO({parentContext:i,elements:o.elements,path:e.path,profileUrl:o.url,accessPolicyResource:e.accessPolicyResource})},[o,i,e.path,e.accessPolicyResource]);if(CC(n))return null;if(!o)return(0,I.jsxs)(`div`,{children:[r,`\xA0not implemented`]});if(typeof n==`object`&&`name`in n&&Object.keys(n).length===1&&typeof n.name==`string`)return(0,I.jsx)(`div`,{children:n.name});let c=s??i;return yF(nA.Provider,s,(0,I.jsx)(uP,{compact:e.compact,children:Object.entries(c.elements).map(([n,r])=>{if(TF.includes(n)&&CC(r.slicing?.slices)||EF.includes(n)||tA.includes(n)&&r.path.split(`.`).length===2||n.includes(`.`))return null;let[i,a]=sF(t,n,c.profileUrl);if((e.ignoreMissingValues||r.max===0)&&CC(i)||e.path.endsWith(`.extension`)&&(n===`url`||n===`id`))return null;let o=r.max>1||r.isArray,s=(0,I.jsx)(CF,{property:r,propertyType:a,path:e.path+`.`+n,value:i,ignoreMissingValues:e.ignoreMissingValues,includeArrayDescriptionListEntry:o,link:e.link},n);return o?s:(0,I.jsx)(dP,{term:Iw(n),children:s},n)})}))}var OF={dimmed:`_dimmed_11me5_1`,preserveBreaks:`_preserveBreaks_11me5_5`},kF=`Read Only`;function AF(e,t){return e?(0,I.jsx)(Qv.Floating,{label:e,children:t}):t}function jF(e){let{debugMode:t}=(0,b.useContext)(nA),n;return n=t&&e.fhirPath?`${e.title} - ${e.fhirPath}`:e.title,AF(e?.readonly?kF:void 0,(0,I.jsxs)(V,{wrap:`nowrap`,"data-testid":e.testId,children:[(0,I.jsx)(`div`,{children:e.children}),(0,I.jsx)(`div`,{children:(0,I.jsx)(dd.Wrapper,{id:e.htmlFor,label:n,classNames:{label:e?.readonly?OF.dimmed:void 0},description:e.description,withAsterisk:e.withAsterisk,children:null})})]}))}function MF(e){let{debugMode:t}=(0,b.useContext)(nA),n;return n=t&&e.fhirPath?`${e.title} - ${e.fhirPath}`:e.title,AF(e?.readonly?kF:void 0,(0,I.jsx)(dd.Wrapper,{id:e.htmlFor,label:n,classNames:{label:Mn({[OF.dimmed]:e?.readonly},OF.preserveBreaks)},description:e.description,withAsterisk:e.withAsterisk,error:SP(e.outcome,e.errorExpression??e.htmlFor),"data-testid":e.testId,children:e.children}))}function NF(e,t,n,r,i){let a=r.type;if(a.length>1)for(let n of a){let r=t.replace(`[x]`,UC(n.code));r in e&&delete e[r]}return CC(i)?e[n]=void 0:e[n]=i,e}function PF(e){return!!e&&!CC(e.url)&&!CC(e.name)}function FF(e){let{defaultValue:t,onChange:n,withHelpText:r,outcome:i,path:a,valuePath:o,...s}=e,[c,l]=(0,b.useState)(t);function u(e){let t=LF(e);l(t),n&&n(t)}return(0,I.jsx)(NN,{defaultValue:c&&IF(c),onChange:u,withHelpText:r??!0,...s})}function IF(e){return e.coding?.map(e=>({system:e.system,code:e.code,display:e.display}))}function LF(e){if(e.length!==0)return{coding:e.map(e=>({system:e.system,code:e.code,display:e.display}))}}function RF(e){let{defaultValue:t,onChange:n,withHelpText:r,response:i,...a}=e,[o,s]=(0,b.useState)(i?.answer?.[0]?.valueCoding??t);function c(e){let t=e[0],r=t&&BF(t);s(r),n&&n(r)}return(0,I.jsx)(NN,{defaultValue:o?zF(o):void 0,maxValues:1,onChange:c,withHelpText:r??!0,...a})}function zF(e){return{system:e.system,code:e.code,display:e.display}}function BF(e){return{system:e.system,code:e.code,display:e.display}}function VF(e){let{path:t,outcome:n}=e,{elementsByPath:r,getExtendedProps:i}=(0,b.useContext)(nA),[a,o]=(0,b.useState)(e.defaultValue),[s,c,l]=(0,b.useMemo)(()=>[`system`,`use`,`value`].map(e=>r[t+`.`+e]),[r,t]),[u,d,f]=(0,b.useMemo)(()=>[`system`,`use`,`value`].map(e=>i(t+`.`+e)),[i,t]);function p(t){t&&Object.keys(t).length===0&&(t=void 0),o(t),e.onChange&&e.onChange(t)}function m(e){let t={...a,system:e};e||delete t.system,p(t)}function h(e){let t={...a,use:e};e||delete t.use,p(t)}function g(e){let t={...a,value:e};e||delete t.value,p(t)}let _=e.valuePath??t;return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,align:`flex-start`,children:[(0,I.jsx)(Eg,{disabled:e.disabled||u?.readonly,"data-testid":`system`,defaultValue:a?.system,required:(s?.min??0)>0,onChange:e=>m(e.currentTarget.value),data:[``,`email`,`phone`,`fax`,`pager`,`sms`,`url`,`other`],error:SP(n,_+`.system`)}),(0,I.jsx)(Eg,{disabled:e.disabled||d?.readonly,"data-testid":`use`,defaultValue:a?.use,required:(c?.min??0)>0,onChange:e=>h(e.currentTarget.value),data:[``,`home`,`work`,`temp`,`old`,`mobile`],error:SP(n,_+`.use`)}),(0,I.jsx)(yb,{disabled:e.disabled||f?.readonly,placeholder:`Value`,defaultValue:a?.value,required:(l?.min??0)>0,onChange:e=>g(e.currentTarget.value),error:SP(n,_+`.value`)})]})}function HF(e){let[t,n]=(0,b.useState)(e.defaultValue),{getExtendedProps:r}=(0,b.useContext)(nA),[i,a]=(0,b.useMemo)(()=>[`name`,`telecom`].map(t=>r(e.path+`.`+t)),[r,e.path]);function o(t){n(t),e.onChange&&e.onChange(t)}function s(e){let n={...t,name:e};e||delete n.name,o(n)}function c(e){let n={...t,telecom:e&&[e]};e||delete n.telecom,o(n)}return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)(yb,{disabled:e.disabled||i?.readonly,"data-testid":e.name+`-name`,name:e.name+`-name`,placeholder:`Name`,style:{width:180},defaultValue:t?.name,onChange:e=>s(e.currentTarget.value)}),(0,I.jsx)(VF,{disabled:e.disabled||a?.readonly,name:e.name+`-telecom`,path:e.path+`.telecom`,defaultValue:t?.telecom?.[0],onChange:c,outcome:e.outcome})]})}function UF(e){if(!e)return``;let t=new Date(e);return uw(t)?t.toLocaleDateString(`sv`)+`T`+t.toLocaleTimeString(`sv`):``}function WF(e){if(!e)return``;let t=new Date(e);return uw(t)?t.toISOString():``}function GF(e){return(0,I.jsx)(yb,{id:e.name,name:e.name,label:e.label,"data-autofocus":e.autoFocus,"data-testid":e[`data-testid`]??e.name,placeholder:e.placeholder,required:e.required,disabled:e.disabled,type:KF(),step:1,defaultValue:UF(e.defaultValue),autoFocus:e.autoFocus,error:SP(e.outcome,e.name),onChange:t=>{if(e.onChange){let n=t.currentTarget.value;e.onChange(WF(n))}}})}function KF(){return`datetime-local`}function qF(e){let{propertyType:t}=e,n=Z(),r=(0,b.useMemo)(()=>{if(wC(t.profile))return t.profile[0]},[t]),[i,a]=(0,b.useState)(r!==void 0);return(0,b.useEffect)(()=>{r&&(a(!0),n.requestProfileSchema(r).then(()=>a(!1)).catch(e=>{a(!1),console.warn(e)}))},[n,r]),r&&(i||!hS(r))?(0,I.jsx)(`div`,{children:`Loading...`}):(0,I.jsx)(PI,{profileUrl:r,path:e.path,typeName:`Extension`,defaultValue:e.defaultValue,onChange:e.onChange})}function JF(e){let{outcome:t,path:n}=e,[r,i]=(0,b.useState)(e.defaultValue),{getExtendedProps:a}=(0,b.useContext)(nA),[o,s,c,l,u]=(0,b.useMemo)(()=>[`use`,`prefix`,`given`,`family`,`suffix`].map(t=>a(e.path+`.`+t)),[a,e.path]);function d(t){i(t),e.onChange&&e.onChange(t)}function f(e){d({...r,use:e||void 0})}function p(e){d({...r,prefix:e?e.split(` `):void 0})}function m(e){d({...r,given:e?e.split(` `):void 0})}function h(e){d({...r,family:e||void 0})}function g(e){d({...r,suffix:e?e.split(` `):void 0})}let _=e.valuePath??n;return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)(Eg,{disabled:e.disabled||o?.readonly,defaultValue:r?.use,name:e.name+`-use`,"data-testid":`use`,onChange:e=>f(e.currentTarget.value),data:[``,`temp`,`old`,`usual`,`official`,`nickname`,`anonymous`,`maiden`],error:SP(t,_+`.use`)}),(0,I.jsx)(yb,{disabled:e.disabled||s?.readonly,placeholder:`Prefix`,name:e.name+`-prefix`,defaultValue:r?.prefix?.join(` `),onChange:e=>p(e.currentTarget.value),error:SP(t,_+`.prefix`)}),(0,I.jsx)(yb,{disabled:e.disabled||c?.readonly,placeholder:`Given`,name:e.name+`-given`,defaultValue:r?.given?.join(` `),onChange:e=>m(e.currentTarget.value),error:SP(t,_+`.given`)}),(0,I.jsx)(yb,{disabled:e.disabled||l?.readonly,name:e.name+`-family`,placeholder:`Family`,defaultValue:r?.family,onChange:e=>h(e.currentTarget.value),error:SP(t,_+`.family`)}),(0,I.jsx)(yb,{disabled:e.disabled||u?.readonly,placeholder:`Suffix`,name:e.name+`-suffix`,defaultValue:r?.suffix?.join(` `),onChange:e=>g(e.currentTarget.value),error:SP(t,_+`.suffix`)})]})}function YF(e){let[t,n]=(0,b.useState)(e.defaultValue),{elementsByPath:r,getExtendedProps:i}=(0,b.useContext)(nA),[a,o]=(0,b.useMemo)(()=>[`system`,`value`].map(t=>r[e.path+`.`+t]),[r,e.path]),[s,c]=(0,b.useMemo)(()=>[`system`,`value`].map(t=>i(e.path+`.`+t)),[i,e.path]);function l(t){n(t),e.onChange&&e.onChange(t)}let u=e.valuePath??e.path;return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,align:`flex-start`,children:[(0,I.jsx)(yb,{disabled:e.disabled||s?.readonly,placeholder:`System`,required:(a?.min??0)>0,defaultValue:t?.system,onChange:e=>l({...t,system:e.currentTarget.value}),error:SP(e.outcome,u+`.system`)}),(0,I.jsx)(yb,{disabled:e.disabled||c?.readonly,placeholder:`Value`,required:(o?.min??0)>0,defaultValue:t?.value,onChange:e=>l({...t,value:e.currentTarget.value}),error:SP(e.outcome,u+`.value`)})]})}var XF=[`USD`,`EUR`,`CAD`,`GBP`,`AUD`];function ZF(e){let{onChange:t}=e,[n,r]=(0,b.useState)(e.defaultValue),{getExtendedProps:i}=(0,b.useContext)(nA),[a,o]=(0,b.useMemo)(()=>[`currency`,`value`].map(t=>i(e.path+`.`+t)),[i,e.path]),s=(0,b.useCallback)(e=>{r(e),t&&t(e)},[t]),c=(0,b.useCallback)(e=>{s({...n,currency:e.currentTarget.value})},[n,s]),l=(0,b.useCallback)(e=>{s({...n,value:e.currentTarget.valueAsNumber})},[n,s]),u=(0,I.jsx)(Eg,{disabled:e.disabled||a?.readonly,defaultValue:n?.currency,data:XF,styles:{input:{fontWeight:500,borderTopLeftRadius:0,borderBottomLeftRadius:0,width:92}},onChange:c});return(0,I.jsx)(yb,{disabled:e.disabled||o?.readonly,type:`number`,name:e.name,label:e.label,placeholder:e.placeholder??`Value`,defaultValue:n?.value?.toString()??`USD`,leftSection:(0,I.jsx)(FA,{size:14}),rightSection:u,rightSectionWidth:92,onChange:l})}function QF(e){let[t,n]=(0,b.useState)(e.defaultValue),{getExtendedProps:r}=(0,b.useContext)(nA),[i,a]=(0,b.useMemo)(()=>[`start`,`end`].map(t=>r(e.path+`.`+t)),[r,e.path]);function o(t){n(t),e.onChange&&e.onChange(t)}return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)(GF,{disabled:e.disabled||i?.readonly,name:e.name+`.start`,placeholder:`Start`,defaultValue:t?.start,onChange:e=>o({...t,start:e})}),(0,I.jsx)(GF,{disabled:e.disabled||a?.readonly,name:e.name+`.end`,placeholder:`End`,defaultValue:t?.end,onChange:e=>o({...t,end:e})})]})}function $F(e){let[t,n]=(0,b.useState)(e.defaultValue),{getExtendedProps:r}=(0,b.useContext)(nA),[i,a,o]=(0,b.useMemo)(()=>[`comparator`,`value`,`unit`].map(t=>r(e.path+`.`+t)),[r,e.path]);function s(t){n(t),e.onChange&&e.onChange(t)}return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)(Eg,{disabled:e.disabled||i?.readonly,style:{width:80},"data-testid":e.name+`-comparator`,defaultValue:t?.comparator,data:[``,`<`,`<=`,`>=`,`>`],onChange:e=>s({...t,comparator:e.currentTarget.value})}),(0,I.jsx)(yb,{disabled:e.disabled||a?.readonly,id:e.name,name:e.name,required:e.required,"data-autofocus":e.autoFocus,"data-testid":e.name+`-value`,type:`number`,placeholder:`Value`,defaultValue:t?.value,autoFocus:e.autoFocus,step:`any`,onWheel:t=>{e.disableWheel&&t.currentTarget.blur()},onChange:e=>{s({...t,value:eI(e.currentTarget.value)})}}),(0,I.jsx)(yb,{disabled:e.disabled||o?.readonly,placeholder:`Unit`,"data-testid":e.name+`-unit`,defaultValue:t?.unit,onChange:e=>s({...t,unit:e.currentTarget.value})})]})}function eI(e){if(e)return Number.parseFloat(e)}function tI(e){let[t,n]=(0,b.useState)(e.defaultValue),{getExtendedProps:r}=(0,b.useContext)(nA),[i,a]=(0,b.useMemo)(()=>[`low`,`high`].map(t=>r(e.path+`.`+t)),[r,e.path]);function o(t){n(t),e.onChange&&e.onChange(t)}return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)($F,{path:e.path+`.low`,disabled:e.disabled||i?.readonly,name:e.name+`-low`,defaultValue:t?.low,onChange:e=>o({...t,low:e})}),(0,I.jsx)($F,{path:e.path+`.high`,disabled:e.disabled||a?.readonly,name:e.name+`-high`,defaultValue:t?.high,onChange:e=>o({...t,high:e})})]})}function nI(e){let[t,n]=(0,b.useState)(e.defaultValue),{getExtendedProps:r}=(0,b.useContext)(nA),[i,a]=(0,b.useMemo)(()=>[`numerator`,`denominator`].map(t=>r(e.path+`.`+t)),[r,e.path]);function o(t){n(t),e.onChange&&e.onChange(t)}return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)($F,{path:e.path+`.numerator`,disabled:e.disabled||i?.readonly,name:e.name+`-numerator`,defaultValue:t?.numerator,onChange:e=>o({...t,numerator:e})}),(0,I.jsx)($F,{path:e.path+`.denominator`,disabled:e.disabled||a?.readonly,name:e.name+`-denominator`,defaultValue:t?.denominator,onChange:e=>o({...t,denominator:e})})]})}var rI={Device:`device-name`,Observation:`code`,Subscription:`criteria`,User:`email:contains`},iI=`AccessPolicy.Account.ActivityDefinition.Bot.CapabilityStatement.CareTeam.ClientApplication.CodeSystem.CompartmentDefinition.ConceptMap.EffectEvidenceSynthesis.Endpoint.EventDefinition.Evidence.EvidenceVariable.ExampleScenario.GraphDefinition.Group.HealthcareService.ImplementationGuide.InsurancePlan.Library.Location.Measure.MedicinalProduct.MessageDefinition.NamingSystem.OperationDefinition.Organization.Patient.Person.PlanDefinition.Practitioner.Project.Questionnaire.RelatedPerson.ResearchDefinition.ResearchElementDefinition.ResearchStudy.RiskEvidenceSynthesis.SearchParameter.StructureDefinition.StructureMap.TerminologyCapabilities.TestScript.UserConfiguration.ValueSet`.split(`.`);function aI(e){return{value:oC(e)??``,label:uC(e),resource:e}}function oI(e){return rI[e]??(iI.includes(e)?`name`:`_id`)}var sI=(0,b.forwardRef)(({label:e,resource:t,active:n,...r},i)=>(0,I.jsx)(`div`,{ref:i,...r,children:(0,I.jsxs)(V,{wrap:`nowrap`,children:[(0,I.jsx)(Qj,{value:t}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{children:e}),(0,I.jsx)(H,{size:`xs`,c:`dimmed`,children:t.birthDate||t.id})]})]})}));sI.displayName=`DefaultResourceItemComponent`;function cI(e){let t=Z(),{resourceType:n,searchCriteria:r}=e,i=e.itemComponent??sI,a=e.onChange,o=(0,b.useRef)(e.defaultValue),[s,c]=(0,b.useState)(!e.defaultValue||e.defaultValue.length===0?[]:void 0);(0,b.useEffect)(()=>{let e=!1,n=o.current;return n&&n.length>0&&Promise.allSettled(n.map(e=>{if(Hw(e))return Promise.resolve(e);if(Uw(e)){let n=e;return t.readReference(n)}return Promise.reject(Error(`Not a resolvable item`))})).then(t=>{e||c(t.filter(e=>e.status===`fulfilled`).map(e=>e.value))}).catch(()=>{}),()=>{e=!0}},[t]);let l=(0,b.useCallback)(async(e,i)=>{let a=oI(n),o=new URLSearchParams({[a]:e??``,_count:`10`,...r});return await t.searchResources(n,o,{signal:i})},[t,n,r]),u=(0,b.useCallback)(e=>{a&&a(e)},[a]);return s===void 0?null:(0,I.jsx)(mM,{disabled:e.disabled,name:e.name,label:e.label,error:e.error,required:e.required,itemComponent:i,defaultValue:s,placeholder:e.placeholder,maxValues:e.maxValues,toOption:aI,loadOptions:l,onChange:u,clearable:!0})}function lI(e){let t=e.onChange,n=(0,b.useCallback)(e=>{t&&t(e[0])},[t]);return(0,I.jsx)(cI,{resourceType:e.resourceType,name:e.name,defaultValue:e.defaultValue?[e.defaultValue]:void 0,searchCriteria:e.searchCriteria,placeholder:e.placeholder,required:e.required,itemComponent:e.itemComponent,onChange:n,disabled:e.disabled,label:e.label,error:e.error,maxValues:1})}function uI(e){let{onChange:t}=e,n=Z(),[r,i]=(0,b.useState)(e.defaultValue),[a,o]=(0,b.useState)(()=>dI(e.targetTypes)),[s,c]=(0,b.useState)(()=>fI(e.defaultValue,a)),l=(0,b.useRef)(new Sx),u=(0,b.useMemo)(()=>s?.type===`profile`?{...e.searchCriteria,_profile:s.value}:e.searchCriteria,[e.searchCriteria,s]);(0,b.useEffect)(()=>{let e=!1,t=a?.map(t=>{if(!mI(t))return Promise.resolve(t);e=!0;let r=t.value,i=l.current.get(r);if(i)return i;let a=new xD(pI(n,t.value).then(e=>{let n={...t};return e?wC(e.type)?(n.resourceType=e.type,n.name=e.name,n.title=e.title):(console.error(`StructureDefinition.type missing for ${t.value}`),n.error=`StructureDefinition.type missing`):(console.error(`StructureDefinition not found for ${t.value}`),n.error=`StructureDefinition not found`),n}).catch(e=>(console.error(e),{...t,error:e})));return l.current.set(r,a),a});!t||!e||Promise.all(t).then(e=>{if(o(e),!s)return;let t=e.findIndex(e=>e.value===s.value||e.resourceType===s.resourceType);if(t===-1){console.debug(`defaultValue had unexpected resourceType: ${s.resourceType}`);return}c(e[t])}).catch(console.error)},[n,s,a]);let d=(0,b.useCallback)(e=>{let n=e?aC(e):void 0;i(n),t&&t(n)},[t]),f=(0,b.useMemo)(()=>a?a.map(e=>({value:e.value,label:e.type===`profile`?e.title??e.name??e.resourceType??e.value:e.value})):[],[a]);return(0,I.jsxs)(I.Fragment,{children:[e.name&&(0,I.jsx)(`input`,{type:`hidden`,name:e.name,value:r?.reference??``}),(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[a&&a.length>1&&(0,I.jsx)(Eg,{name:e.name+`-resourceType`,disabled:e.disabled,"data-autofocus":e.autoFocus,"data-testid":`reference-input-resource-type-select`,defaultValue:s?.resourceType,autoFocus:e.autoFocus,onChange:e=>{let t=e.currentTarget.value;c(a.find(e=>e.value===t))},data:f}),!a&&(0,I.jsx)(RN,{disabled:e.disabled,autoFocus:e.autoFocus,testId:`reference-input-resource-type-input`,defaultValue:s?.resourceType,onChange:e=>{c(e?{type:`resourceType`,value:e,resourceType:e}:void 0)},name:e.name+`-resourceType`,placeholder:`Resource Type`}),(0,I.jsx)(lI,{resourceType:s?.resourceType,name:e.name+`-id`,required:e.required,placeholder:e.placeholder,defaultValue:r,searchCriteria:u,onChange:d,disabled:e.disabled})]})]})}function dI(e){if(!e||e.length===0||e.length===1&&e[0]===`Resource`)return;let t=[];for(let n of e)n.includes(`/`)?t.push({type:`profile`,value:n}):t.push({type:`resourceType`,value:n,resourceType:n});return t}function fI(e,t){let n=e?.reference?.split(`/`)[0];if(n)return t?.find(e=>e.resourceType===n)||{type:`resourceType`,value:n,resourceType:n};if(t&&t.length>0)return t[0]}async function pI(e,t){let n=gS(t);if(n)return{type:n.type,name:n.name,title:n.title};let r=`{
199
199
  StructureDefinitionList(url: "${t}", _sort: "_lastUpdated", _count: 1) {
200
200
  type,
201
201
  name,
202
202
  title,
203
203
  }
204
- }`.replaceAll(/\s+/g,` `);return(await e.graphql(r)).data.StructureDefinitionList[0]}function fI(e){return e.type===`profile`&&!e?.error&&CC(e.resourceType)}function pI(e,t,n){return t===void 0?e:n===void 0?t:`${t}[${n}]`}var mI={indented:`_indented_ldk1d_1`};function hI({propertyDisplayName:e,onClick:t,testId:n}){let r=e?`Add ${e}`:`Add`;return e?(0,I.jsx)(U,{title:r,size:`sm`,color:`green.6`,variant:`subtle`,"data-testid":n,leftSection:(0,I.jsx)(kA,{size:`1.25rem`}),onClick:t,children:r}):(0,I.jsx)(gu,{title:r,color:`green.6`,"data-testid":n,onClick:t,children:(0,I.jsx)(kA,{size:`1.25rem`})})}function gI({propertyDisplayName:e,onClick:t,testId:n}){return(0,I.jsx)(gu,{title:e?`Remove ${e}`:`Remove`,color:`red.5`,"data-testid":n,variant:`subtle`,onClick:t,children:(0,I.jsx)(OA,{size:`1.25rem`})})}function _I(e){let{slice:t,property:n}=e,[r,i]=(0,b.useState)(e.defaultValue),a=t.typeSchema?.elements??t.elements,o=(0,b.useContext)(eA),s=(0,b.useMemo)(()=>{if(wC(a))return aO({parentContext:o,elements:a,path:e.path,profileUrl:t.typeSchema?.url})},[o,e.path,t.typeSchema?.url,a]);function c(t){i(t),e.onChange&&e.onChange(t)}let l=t.min>0,u=CC(t.elements),d=Lw(t.name),f=e.property.readonly&&r.length===0;return _F(eA.Provider,s,(0,I.jsx)(AF,{title:d,description:t.definition,withAsterisk:l,fhirPath:`${n.path}:${t.name}`,testId:e.testId,readonly:e.property.readonly,children:f?(0,I.jsx)(H,{c:`dimmed`,children:`(empty)`}):(0,I.jsxs)(G,{className:u?mI.indented:void 0,children:[r.map((n,i)=>(0,I.jsxs)(V,{wrap:`nowrap`,children:[(0,I.jsx)(`div`,{style:{flexGrow:1},"data-testid":e.testId&&`${e.testId}-elements-${i}`,children:(0,I.jsx)(DI,{elementDefinitionType:t.type[0],name:t.name,defaultValue:n,onChange:e=>{let t=[...r];t[i]=e,c(t)},outcome:e.outcome,min:t.min,max:t.max,binding:t.binding,path:e.path,valuePath:void 0,readOnly:e.property.readonly})}),!e.property.readonly&&r.length>t.min&&(0,I.jsx)(gI,{propertyDisplayName:d,testId:e.testId&&`${e.testId}-remove-${i}`,onClick:e=>{Rj(e);let t=[...r];t.splice(i,1),c(t)}})]},`${i}-${r.length}`)),!e.property.readonly&&r.length<t.max&&(0,I.jsx)(V,{wrap:`nowrap`,style:{justifyContent:`flex-start`},children:(0,I.jsx)(hI,{propertyDisplayName:d,onClick:e=>{Rj(e),c([...r,void 0])},testId:e.testId&&`${e.testId}-add`})})]})}))}function vI(e){let{property:t}=e,n=Z(),[r,i]=(0,b.useState)(!0),[a,o]=(0,b.useState)([]),[s]=(0,b.useState)(()=>Array.isArray(e.defaultValue)?e.defaultValue:[]),[c,l]=(0,b.useState)(()=>[s]),u=(0,b.useContext)(eA),d=t.type[0]?.code;(0,b.useEffect)(()=>{gF({medplum:n,property:t}).then(e=>{o(e);let n=hF(s,e,t.slicing,u.profileUrl);yI(n,e),l(n),i(!1)}).catch(e=>{console.error(e),i(!1)})},[n,t,s,u.profileUrl,l]);function f(t,n){let r=[...c];if(r[n]=t,l(r),e.onChange){let t=r.flat().filter(e=>e!==void 0);e.onChange(t)}}if(r)return(0,I.jsx)(`div`,{children:`Loading...`});let p=a.length,m=c[p],h=!(e.hideNonSliceValues??(d===`Extension`&&a.length>0)),g=Iw(t.path),_=e.property.readonly&&a.length===0&&s.length===0;return(0,I.jsxs)(G,{className:e.indent?mI.indented:void 0,children:[_&&(0,I.jsx)(H,{c:`dimmed`,children:`(empty)`}),a.map((n,r)=>(0,I.jsx)(_I,{slice:n,path:e.path,valuePath:e.valuePath,property:t,defaultValue:c[r],onChange:e=>{f(e,r)},testId:`slice-${n.name}`},n.name)),h&&m.map((t,n)=>(0,I.jsxs)(V,{wrap:`nowrap`,style:{flexGrow:1},children:[(0,I.jsx)(`div`,{style:{flexGrow:1},children:(0,I.jsx)(TI,{arrayElement:!0,property:e.property,name:e.name+`.`+n,path:e.path,valuePath:pI(e.path,e.valuePath,n),defaultValue:t,onChange:e=>{let t=[...m];t[n]=e,f(t,p)},defaultPropertyType:void 0,outcome:e.outcome})}),!e.property.readonly&&(0,I.jsx)(gI,{propertyDisplayName:g,testId:`nonsliced-remove-${n}`,onClick:e=>{Rj(e);let t=[...m];t.splice(n,1),f(t,p)}})]},`${n}-${m.length}`)),!e.property.readonly&&h&&c.flat().length<t.max&&(0,I.jsx)(V,{wrap:`nowrap`,style:{justifyContent:`flex-start`},children:(0,I.jsx)(hI,{propertyDisplayName:g,onClick:e=>{Rj(e);let t=[...m];t.push(void 0),f(t,p)},testId:`nonsliced-add`})})]})}function yI(e,t){for(let n=0;n<t.length;n++){let r=t[n],i=e[n];for(;i.length<r.min;)i.push(void 0)}}function bI(e){let[t,n]=(0,b.useState)(!1),r=jt(),i=(0,b.useRef)(null),a={...e.styles};return t||(a.input||={},a.input.WebkitTextSecurity=`disc`),(0,I.jsxs)(_d,{gap:`xs`,children:[(0,I.jsx)(oh,{...e,styles:{...a,root:{...a.root??{},flexGrow:1}},ref:i,autosize:!0,minRows:1,onFocus:()=>n(!0),onBlur:()=>n(!1)}),(0,I.jsx)(gu,{title:`Copy secret`,onClick:()=>{r.copy(i.current?.value),J({color:`green`,message:`Copied`})},children:(0,I.jsx)(MA,{})})]})}var xI=[`sun`,`mon`,`tue`,`wed`,`thu`,`fri`,`sat`];function SI(e){let[t,n]=(0,b.useState)(e.defaultValue),[r,i]=(0,b.useState)(!e.disabled&&(e.defaultModalOpen??!1));return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)(`span`,{"data-testid":`timinginput-display`,children:_w(t)||`No repeat`}),(0,I.jsx)(U,{disabled:e.disabled,onClick:()=>i(!0),children:`Edit`})]}),!e.disabled&&(0,I.jsx)(wI,{path:e.path,visible:r,defaultValue:t,onOk:t=>{e.onChange&&e.onChange(t),n(t),i(!1)},onCancel:()=>i(!1)})]})}var CI={repeat:{period:1,periodUnit:`d`}};function wI(e){let[t,n]=(0,b.useState)(e.defaultValue||CI),[r,i]=(0,b.useState)(()=>(e.defaultValue?.repeat?.timeOfDay??[]).map((e,t)=>({id:t,value:e}))),a=(0,b.useRef)(r.length),{getExtendedProps:o}=(0,b.useContext)(eA),[s,c,l,u,d,f]=(0,b.useMemo)(()=>[`event`,`repeat`,`repeat.period`,`repeat.periodUnit`,`repeat.dayOfWeek`,`repeat.timeOfDay`].map(t=>o(e.path+`.`+t)),[o,e.path]);function p(e){n(t=>({...t,event:[e]}))}function m(e){n(t=>({...t,repeat:e}))}function h(e){n(t=>({...t,repeat:{...t.repeat,period:e}}))}function g(e){n(t=>({...t,repeat:{...t.repeat,periodUnit:e}}))}function _(e){n(t=>({...t,repeat:{...t.repeat,dayOfWeek:e}}))}function v(e){i(t=>{let r=e(t),i=r.map(e=>e.value);return n(e=>({...e,repeat:{...e.repeat,timeOfDay:i}})),r})}return(0,I.jsx)(rg,{title:`Timing`,closeButtonProps:{"aria-label":`Close`},opened:e.visible,onClose:()=>e.onCancel(),children:(0,I.jsxs)(G,{gap:`md`,children:[(0,I.jsx)(AF,{title:`Starts on`,htmlFor:`timing-dialog-start`,children:(0,I.jsx)(UF,{disabled:s?.readonly,name:`timing-dialog-start`,onChange:e=>p(e)})}),(0,I.jsx)(Wy,{disabled:c?.readonly,label:`Repeat`,checked:!!t.repeat,onChange:e=>m(e.currentTarget.checked?CI.repeat:void 0)}),t.repeat&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(AF,{title:`Repeat every`,htmlFor:`timing-dialog-period`,children:(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)(yb,{disabled:l?.readonly,type:`number`,step:1,id:`timing-dialog-period`,name:`timing-dialog-period`,defaultValue:t.repeat.period||1,onChange:e=>h(Number.parseInt(e.currentTarget.value,10)||1)}),(0,I.jsx)(Eg,{disabled:u?.readonly,id:`timing-dialog-periodUnit`,name:`timing-dialog-periodUnit`,defaultValue:t.repeat.periodUnit,onChange:e=>g(e.currentTarget.value),data:[{label:`minute`,value:`min`},{label:`hour`,value:`h`},{label:`day`,value:`d`},{label:`week`,value:`wk`},{label:`month`,value:`mo`},{label:`year`,value:`a`}]})]})}),t.repeat.periodUnit===`wk`&&(0,I.jsx)(AF,{title:`Repeat on`,children:(0,I.jsx)($p.Group,{multiple:!0,onChange:_,value:t.repeat?.dayOfWeek,children:(0,I.jsx)(V,{justify:`space-between`,mt:`xs`,gap:`xs`,children:xI.map(e=>(0,I.jsx)($p,{value:e,size:`xs`,radius:`xl`,disabled:d?.readonly,checked:(t.repeat?.dayOfWeek??[]).includes(e),children:e.charAt(0).toUpperCase()},e))})})}),(0,I.jsx)(AF,{title:`At times`,children:(0,I.jsxs)(G,{mt:`xs`,children:[r.map((e,t)=>(0,I.jsxs)(V,{children:[(0,I.jsx)(yb,{disabled:f?.readonly,type:`time`,id:`timing-dialog-repeat-timeOfDay[${t}]`,name:`timing-dialog-repeat-timeOfDay[${t}]`,"data-testid":`timing-repeat-timeOfDay-input-${t}`,defaultValue:e.value.slice(0,5),onChange:n=>{let r=`${n.currentTarget.value}:00`;v(n=>n.with(t,{...e,value:r}))},style:{flexGrow:1}}),(0,I.jsx)(gI,{testId:`timing-repeat-timeOfDay-remove-${t}`,onClick:()=>v(e=>e.toSpliced(t,1))})]},e.id)),(0,I.jsx)(z,{children:(0,I.jsx)(hI,{propertyDisplayName:`Time of Day`,onClick:()=>v(e=>{let t=a.current++;return e.concat({id:t,value:`00:00:00`})})})})]})})]}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(U,{onClick:()=>e.onOk(t),children:`OK`})})]})})}function TI(e){let{property:t,name:n,onChange:r,defaultValue:i}=e,a=e.defaultPropertyType&&e.defaultPropertyType!==`undefined`?e.defaultPropertyType:t.type[0].code,o=t.type;if((t.isArray||t.max>1)&&!e.arrayElement){if(a===Y.Attachment)return(0,I.jsx)(fP,{name:n,defaultValue:i,onChange:r,disabled:t.readonly});let s=o[0]?.code!==Y.Extension;return(0,I.jsx)(vI,{property:t,name:n,path:e.path,valuePath:e.valuePath,defaultValue:i,indent:s,onChange:r,outcome:e.outcome})}else if(o.length>1)return(0,I.jsx)(EI,{elementDefinitionTypes:o,...e});else return(0,I.jsx)(DI,{name:n,defaultValue:i,onChange:t=>{if(e.onChange){let n=e.name.replace(`[x]`,UC(o[0].code));e.onChange(t,n)}},outcome:e.outcome,elementDefinitionType:o[0],min:t.min,max:t.min,binding:t.binding,path:e.path,valuePath:e.valuePath,readOnly:t.readonly})}function EI(e){let t=e.elementDefinitionTypes,n;e.defaultPropertyType&&(n=t.find(t=>t.code===e.defaultPropertyType)),n||=t[0];let[r,i]=(0,b.useState)(n);return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,align:`flex-start`,children:[(0,I.jsx)(Eg,{disabled:e.property.readonly,style:{width:`200px`},defaultValue:r.code,"data-testid":e.name&&e.name+`-selector`,onChange:e=>{i(t.find(t=>t.code===e.currentTarget.value))},data:t.map(e=>({value:e.code,label:e.code}))}),(0,I.jsx)(DI,{name:e.name,defaultValue:e.defaultValue,outcome:e.outcome,elementDefinitionType:r,onChange:t=>{e.onChange&&e.onChange(t,e.name.replace(`[x]`,UC(r.code)))},min:e.property.min,max:e.property.max,binding:e.property.binding,path:e.property.path,valuePath:e.valuePath,readOnly:e.property.readonly})]})}function DI(e){let{name:t,onChange:n,outcome:r,binding:i,path:a,valuePath:o,readOnly:s}=e,c=e.min!==void 0&&e.min>0,l=e.elementDefinitionType.code,u=(0,b.useContext)(eA),d=(0,b.useMemo)(()=>{if(!WC(l)||!CC(e.defaultValue))return e.defaultValue;let t=Object.create(null);if(u.path===e.path)_O(t,u.elements);else{let n=GC(u.path,e.path);if(n===void 0)return e.defaultValue;_O(t,u.elements,n)}return wC(t)?t:e.defaultValue},[l,u.path,u.elements,e.path,e.defaultValue]);if(!l)return(0,I.jsx)(`div`,{children:`Property type not specified `});function f(){return{name:t,defaultValue:d,onChange:n,outcome:r,path:a,valuePath:o,disabled:s}}function p(){return{id:t,name:t,"data-testid":t,defaultValue:d,required:c,error:bP(e.outcome,o??a),disabled:s}}switch(l){case Y.SystemString:case Y.canonical:case Y.string:case Y.uri:case Y.url:return e.path===`Project.secret.value[x]`||e.path===`ClientApplication.certificateTrustStore`?(0,I.jsx)(bI,{...p(),onChange:t=>{e.onChange&&e.onChange(t.currentTarget.value)}}):(0,I.jsx)(yb,{...p(),onChange:e=>{n&&n(e.currentTarget.value)}});case Y.date:return(0,I.jsx)(yb,{...p(),type:`date`,onChange:e=>{n&&n(e.currentTarget.value)}});case Y.time:return(0,I.jsx)(yb,{...p(),type:`time`,step:1,onChange:e=>{n&&n(e.currentTarget.value)}});case Y.dateTime:case Y.instant:return(0,I.jsx)(UF,{...p(),onChange:n,outcome:r});case Y.decimal:case Y.integer:case Y.positiveInt:case Y.unsignedInt:return(0,I.jsx)(yb,{...p(),type:`number`,step:l===Y.decimal?`any`:`1`,onChange:e=>{if(n){let t=e.currentTarget.valueAsNumber;n(Number.isNaN(t)?void 0:t)}}});case Y.code:return(0,I.jsx)(NN,{...p(),error:void 0,onChange:n,binding:i?.valueSet,creatable:!0,maxValues:1});case Y.boolean:return(0,I.jsx)(lp,{...p(),defaultChecked:!!d,onChange:e=>{n&&n(e.currentTarget.checked)}});case Y.base64Binary:case Y.markdown:case Y.xhtml:return(0,I.jsx)(oh,{...p(),spellCheck:l!==Y.base64Binary,onChange:e=>{n&&n(e.currentTarget.value)}});case Y.Address:return(0,I.jsx)(oA,{...f()});case Y.Annotation:return(0,I.jsx)(sA,{...f()});case Y.Attachment:return(0,I.jsx)(pP,{...f()});case Y.CodeableConcept:return(0,I.jsx)(NF,{binding:i?.valueSet,...f()});case Y.Coding:return(0,I.jsx)(IF,{binding:i?.valueSet,...f()});case Y.ContactDetail:return(0,I.jsx)(BF,{...f()});case Y.ContactPoint:return(0,I.jsx)(zF,{...f()});case Y.Extension:return(0,I.jsx)(GF,{...f(),propertyType:e.elementDefinitionType});case Y.HumanName:return(0,I.jsx)(KF,{...f()});case Y.Identifier:return(0,I.jsx)(qF,{...f()});case Y.Money:return(0,I.jsx)(YF,{...f()});case Y.Period:return(0,I.jsx)(XF,{...f()});case Y.Duration:case Y.Quantity:return(0,I.jsx)(ZF,{...f()});case Y.Range:return(0,I.jsx)($F,{...f()});case Y.Ratio:return(0,I.jsx)(eI,{...f()});case Y.Reference:return(0,I.jsx)(cI,{...f(),targetTypes:kI(e.elementDefinitionType)});case Y.Timing:return(0,I.jsx)(SI,{...f()});case Y.Dosage:case Y.UsageContext:default:return(0,I.jsx)(MI,{...f(),typeName:l})}}var OI=[`${Ox}/fhir/StructureDefinition/`,`https://medplum.com/fhir/StructureDefinition/`];function kI(e){return e?.targetProfile?.map(e=>{let t=OI.find(t=>e.startsWith(t));return t?e.slice(t.length):e})}function AI(e){let[t,n]=(0,b.useState)(e.defaultValue??{}),r=(0,b.useContext)(eA),i=(0,b.useMemo)(()=>rA(r.elements),[r.elements]);function a(t){n(t),e.onChange&&e.onChange(t)}let o={type:e.type,value:t};return(0,I.jsx)(G,{style:{flexGrow:1},"data-testid":e.testId,children:i.map(([n,r])=>{let[i,s]=oF(o,n,r),c=r.min!==void 0&&r.min>0,l=e.valuePath?e.valuePath+`.`+n:void 0,u=(0,I.jsx)(TI,{property:r,name:n,path:e.path+`.`+n,valuePath:l,defaultValue:i,defaultPropertyType:s,onChange:(e,i)=>{a(jF({...t},n,i??n,r,e))},outcome:e.outcome},n);return e.type===`Extension`||tA.includes(n)?u:r.type.length===1&&r.type[0].code===`boolean`?(0,I.jsx)(kF,{title:Iw(n),description:r.description,htmlFor:n,fhirPath:r.path,withAsterisk:c,readonly:r.readonly,children:u},n):(0,I.jsx)(AF,{title:Iw(n),description:r.description,withAsterisk:c,htmlFor:n,outcome:e.outcome,fhirPath:r.path,errorExpression:l,readonly:r.readonly,children:u},n)})})}var jI={nested:`_nested_1ya4k_1`};function MI(e){let[t]=(0,b.useState)(()=>e.defaultValue??{}),n=(0,b.useContext)(eA),r=e.profileUrl??n?.profileUrl,i=(0,b.useMemo)(()=>pS(e.typeName,r),[e.typeName,r]),a=i?.type??e.typeName,o=(0,b.useMemo)(()=>{if(i)return aO({parentContext:n,elements:i.elements,path:e.path,profileUrl:i.url,accessPolicyResource:e.accessPolicyResource})},[i,n,e.path,e.accessPolicyResource]);if(!i)return(0,I.jsxs)(`div`,{children:[a,`\xA0not implemented`]});let s=n.path!==``;return _F(eA.Provider,o,(0,I.jsx)(z,{className:Mn({[jI.nested]:s}),children:(0,I.jsx)(AI,{path:e.path,valuePath:e.valuePath,type:a,defaultValue:t,onChange:e.onChange,outcome:e.outcome})}))}var NI=class{x;y;pressure;time;constructor(e,t,n,r){if(isNaN(e)||isNaN(t))throw Error(`Point is invalid: (${e}, ${t})`);this.x=+e,this.y=+t,this.pressure=n||0,this.time=r||Date.now()}distanceTo(e){return Math.sqrt((this.x-e.x)**2+(this.y-e.y)**2)}equals(e){return this.x===e.x&&this.y===e.y&&this.pressure===e.pressure&&this.time===e.time}velocityFrom(e){return this.time===e.time?0:this.distanceTo(e)/(this.time-e.time)}},PI=class e{constructor(e,t,n,r,i,a){this.startPoint=e,this.control2=t,this.control1=n,this.endPoint=r,this.startWidth=i,this.endWidth=a}static fromPoints(t,n){let r=this.calculateControlPoints(t[0],t[1],t[2]).c2,i=this.calculateControlPoints(t[1],t[2],t[3]).c1;return new e(t[1],r,i,t[2],n.start,n.end)}static calculateControlPoints(e,t,n){let r=e.x-t.x,i=e.y-t.y,a=t.x-n.x,o=t.y-n.y,s={x:(e.x+t.x)/2,y:(e.y+t.y)/2},c={x:(t.x+n.x)/2,y:(t.y+n.y)/2},l=Math.sqrt(r*r+i*i),u=Math.sqrt(a*a+o*o),d=s.x-c.x,f=s.y-c.y,p=l+u==0?0:u/(l+u),m={x:c.x+d*p,y:c.y+f*p},h=t.x-m.x,g=t.y-m.y;return{c1:new NI(s.x+h,s.y+g),c2:new NI(c.x+h,c.y+g)}}length(){let e=0,t,n;for(let r=0;r<=10;r+=1){let i=r/10,a=this.point(i,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),o=this.point(i,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(r>0){let r=a-t,i=o-n;e+=Math.sqrt(r*r+i*i)}t=a,n=o}return e}point(e,t,n,r,i){return t*(1-e)*(1-e)*(1-e)+3*n*(1-e)*(1-e)*e+3*r*(1-e)*e*e+i*e*e*e}},FI=class{_et;constructor(){try{this._et=new EventTarget}catch{this._et=document}}addEventListener(e,t,n){this._et.addEventListener(e,t,n)}dispatchEvent(e){return this._et.dispatchEvent(e)}removeEventListener(e,t,n){this._et.removeEventListener(e,t,n)}};function II(e,t=250){let n=0,r=null,i,a,o,s=()=>{n=Date.now(),r=null,i=e.apply(a,o),r||(a=null,o=[])};return function(...c){let l=Date.now(),u=t-(l-n);return a=this,o=c,u<=0||u>t?(r&&=(clearTimeout(r),null),n=l,i=e.apply(a,o),r||(a=null,o=[])):r||=window.setTimeout(s,u),i}}var LI=class e extends FI{constructor(t,n={}){super(),this.canvas=t,this.velocityFilterWeight=n.velocityFilterWeight||.7,this.minWidth=n.minWidth||.5,this.maxWidth=n.maxWidth||2.5,this.throttle=n.throttle??16,this.minDistance=n.minDistance??5,this.dotSize=n.dotSize||0,this.penColor=n.penColor||`black`,this.backgroundColor=n.backgroundColor||`rgba(0,0,0,0)`,this.compositeOperation=n.compositeOperation||`source-over`,this.canvasContextOptions=n.canvasContextOptions??{},this._strokeMoveUpdate=this.throttle?II(e.prototype._strokeUpdate,this.throttle):e.prototype._strokeUpdate,this._handleMouseDown=this._handleMouseDown.bind(this),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this._handleTouchStart=this._handleTouchStart.bind(this),this._handleTouchMove=this._handleTouchMove.bind(this),this._handleTouchEnd=this._handleTouchEnd.bind(this),this._handlePointerDown=this._handlePointerDown.bind(this),this._handlePointerMove=this._handlePointerMove.bind(this),this._handlePointerUp=this._handlePointerUp.bind(this),this._handlePointerCancel=this._handlePointerCancel.bind(this),this._handleTouchCancel=this._handleTouchCancel.bind(this),this._ctx=t.getContext(`2d`,this.canvasContextOptions),this.clear(),this.on()}dotSize;minWidth;maxWidth;penColor;minDistance;velocityFilterWeight;compositeOperation;backgroundColor;throttle;canvasContextOptions;_ctx;_drawingStroke=!1;_isEmpty=!0;_dataUrl;_dataUrlOptions;_lastPoints=[];_data=[];_lastVelocity=0;_lastWidth=0;_strokeMoveUpdate;_strokePointerId;clear(){let{_ctx:e,canvas:t}=this;e.fillStyle=this.backgroundColor,e.clearRect(0,0,t.width,t.height),e.fillRect(0,0,t.width,t.height),this._data=[],this._reset(this._getPointGroupOptions()),this._isEmpty=!0,this._dataUrl=void 0,this._dataUrlOptions=void 0,this._strokePointerId=void 0}redraw(){let e=this._data,t=this._dataUrl,n=this._dataUrlOptions;this.clear(),t&&this.fromDataURL(t,n),this.fromData(e,{clear:!1})}fromDataURL(e,t={}){return new Promise((n,r)=>{let i=new Image,a=t.ratio||window.devicePixelRatio||1,o=t.width||this.canvas.width/a,s=t.height||this.canvas.height/a,c=t.xOffset||0,l=t.yOffset||0;this._reset(this._getPointGroupOptions()),i.onload=()=>{this._ctx.drawImage(i,c,l,o,s),n()},i.onerror=e=>{r(e)},i.crossOrigin=`anonymous`,i.src=e,this._isEmpty=!1,this._dataUrl=e,this._dataUrlOptions={...t}})}toDataURL(e=`image/png`,t){switch(e){case`image/svg+xml`:return typeof t!=`object`&&(t=void 0),`data:image/svg+xml;base64,${btoa(this.toSVG(t))}`;default:return typeof t!=`number`&&(t=void 0),this.canvas.toDataURL(e,t)}}on(){this.canvas.style.touchAction=`none`,this.canvas.style.msTouchAction=`none`,this.canvas.style.userSelect=`none`,this.canvas.style.webkitUserSelect=`none`;let e=/Macintosh/.test(navigator.userAgent)&&`ontouchstart`in document;window.PointerEvent&&!e?this._handlePointerEvents():(this._handleMouseEvents(),`ontouchstart`in window&&this._handleTouchEvents())}off(){this.canvas.style.touchAction=`auto`,this.canvas.style.msTouchAction=`auto`,this.canvas.style.userSelect=`auto`,this.canvas.style.webkitUserSelect=`auto`,this.canvas.removeEventListener(`pointerdown`,this._handlePointerDown),this.canvas.removeEventListener(`mousedown`,this._handleMouseDown),this.canvas.removeEventListener(`touchstart`,this._handleTouchStart),this._removeMoveUpEventListeners()}_getListenerFunctions(){let e=window.document===this.canvas.ownerDocument?window:this.canvas.ownerDocument.defaultView??this.canvas.ownerDocument;return{addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}_removeMoveUpEventListeners(){let{removeEventListener:e}=this._getListenerFunctions();e(`pointermove`,this._handlePointerMove),e(`pointerup`,this._handlePointerUp),e(`pointercancel`,this._handlePointerCancel),e(`mousemove`,this._handleMouseMove),e(`mouseup`,this._handleMouseUp),e(`touchmove`,this._handleTouchMove),e(`touchend`,this._handleTouchEnd),e(`touchcancel`,this._handleTouchCancel)}isEmpty(){return this._isEmpty}fromData(e,{clear:t=!0}={}){t&&this.clear(),this._fromData(e,this._drawCurve.bind(this),this._drawDot.bind(this)),this._data=this._data.concat(e)}toData(){return this._data}_isLeftButtonPressed(e,t){return t?e.buttons===1:(e.buttons&1)==1}_pointerEventToSignatureEvent(e){return{event:e,type:e.type,x:e.clientX,y:e.clientY,pressure:`pressure`in e?e.pressure:0}}_touchEventToSignatureEvent(e){let t=e.changedTouches[0];return{event:e,type:e.type,x:t.clientX,y:t.clientY,pressure:t.force}}_handleMouseDown(e){!this._isLeftButtonPressed(e,!0)||this._drawingStroke||this._strokeBegin(this._pointerEventToSignatureEvent(e))}_handleMouseMove(e){if(!this._isLeftButtonPressed(e,!0)||!this._drawingStroke){this._strokeEnd(this._pointerEventToSignatureEvent(e),!1);return}this._strokeMoveUpdate(this._pointerEventToSignatureEvent(e))}_handleMouseUp(e){this._isLeftButtonPressed(e)||this._strokeEnd(this._pointerEventToSignatureEvent(e))}_handleTouchStart(e){e.targetTouches.length!==1||this._drawingStroke||(e.cancelable&&e.preventDefault(),this._strokeBegin(this._touchEventToSignatureEvent(e)))}_handleTouchMove(e){if(e.targetTouches.length===1){if(e.cancelable&&e.preventDefault(),!this._drawingStroke){this._strokeEnd(this._touchEventToSignatureEvent(e),!1);return}this._strokeMoveUpdate(this._touchEventToSignatureEvent(e))}}_handleTouchEnd(e){e.targetTouches.length===0&&(e.cancelable&&e.preventDefault(),this._strokeEnd(this._touchEventToSignatureEvent(e)))}_handlePointerCancel(e){this._allowPointerId(e)&&(e.preventDefault(),this._strokeEnd(this._pointerEventToSignatureEvent(e),!1))}_handleTouchCancel(e){e.cancelable&&e.preventDefault(),this._strokeEnd(this._touchEventToSignatureEvent(e),!1)}_getPointerId(e){return e.persistentDeviceId||e.pointerId}_allowPointerId(e,t=!1){return this._strokePointerId===void 0?t:this._getPointerId(e)===this._strokePointerId}_handlePointerDown(e){this._drawingStroke||!this._isLeftButtonPressed(e)||!this._allowPointerId(e,!0)||(this._strokePointerId=this._getPointerId(e),e.preventDefault(),this._strokeBegin(this._pointerEventToSignatureEvent(e)))}_handlePointerMove(e){if(this._allowPointerId(e)){if(!this._isLeftButtonPressed(e,!0)||!this._drawingStroke){this._strokeEnd(this._pointerEventToSignatureEvent(e),!1);return}e.preventDefault(),this._strokeMoveUpdate(this._pointerEventToSignatureEvent(e))}}_handlePointerUp(e){this._isLeftButtonPressed(e)||!this._allowPointerId(e)||(e.preventDefault(),this._strokeEnd(this._pointerEventToSignatureEvent(e)))}_getPointGroupOptions(e){return{penColor:e&&`penColor`in e?e.penColor:this.penColor,dotSize:e&&`dotSize`in e?e.dotSize:this.dotSize,minWidth:e&&`minWidth`in e?e.minWidth:this.minWidth,maxWidth:e&&`maxWidth`in e?e.maxWidth:this.maxWidth,velocityFilterWeight:e&&`velocityFilterWeight`in e?e.velocityFilterWeight:this.velocityFilterWeight,compositeOperation:e&&`compositeOperation`in e?e.compositeOperation:this.compositeOperation}}_strokeBegin(e){if(!this.dispatchEvent(new CustomEvent(`beginStroke`,{detail:e,cancelable:!0})))return;let{addEventListener:t}=this._getListenerFunctions();switch(e.event.type){case`mousedown`:t(`mousemove`,this._handleMouseMove,{passive:!1}),t(`mouseup`,this._handleMouseUp,{passive:!1});break;case`touchstart`:t(`touchmove`,this._handleTouchMove,{passive:!1}),t(`touchend`,this._handleTouchEnd,{passive:!1}),t(`touchcancel`,this._handleTouchCancel,{passive:!1});break;case`pointerdown`:t(`pointermove`,this._handlePointerMove,{passive:!1}),t(`pointerup`,this._handlePointerUp,{passive:!1}),t(`pointercancel`,this._handlePointerCancel,{passive:!1});break;default:}this._drawingStroke=!0;let n=this._getPointGroupOptions(),r={...n,points:[]};this._data.push(r),this._reset(n),this._strokeUpdate(e)}_strokeUpdate(e){if(!this._drawingStroke)return;if(this._data.length===0){this._strokeBegin(e);return}this.dispatchEvent(new CustomEvent(`beforeUpdateStroke`,{detail:e}));let t=this._createPoint(e.x,e.y,e.pressure),n=this._data[this._data.length-1],r=n.points,i=r.length>0&&r[r.length-1],a=i?t.distanceTo(i)<=this.minDistance:!1,o=this._getPointGroupOptions(n);if(!i||!(i&&a)){let e=this._addPoint(t,o);i?e&&this._drawCurve(e,o):this._drawDot(t,o),r.push({time:t.time,x:t.x,y:t.y,pressure:t.pressure})}this.dispatchEvent(new CustomEvent(`afterUpdateStroke`,{detail:e}))}_strokeEnd(e,t=!0){this._removeMoveUpEventListeners(),this._drawingStroke&&(t&&this._strokeUpdate(e),this._drawingStroke=!1,this._strokePointerId=void 0,this.dispatchEvent(new CustomEvent(`endStroke`,{detail:e})))}_handlePointerEvents(){this._drawingStroke=!1,this.canvas.addEventListener(`pointerdown`,this._handlePointerDown,{passive:!1})}_handleMouseEvents(){this._drawingStroke=!1,this.canvas.addEventListener(`mousedown`,this._handleMouseDown,{passive:!1})}_handleTouchEvents(){this.canvas.addEventListener(`touchstart`,this._handleTouchStart,{passive:!1})}_reset(e){this._lastPoints=[],this._lastVelocity=0,this._lastWidth=(e.minWidth+e.maxWidth)/2,this._ctx.fillStyle=e.penColor,this._ctx.globalCompositeOperation=e.compositeOperation}_createPoint(e,t,n){let r=this.canvas.getBoundingClientRect();return new NI(e-r.left,t-r.top,n,new Date().getTime())}_addPoint(e,t){let{_lastPoints:n}=this;if(n.push(e),n.length>2){n.length===3&&n.unshift(n[0]);let e=this._calculateCurveWidths(n[1],n[2],t),r=PI.fromPoints(n,e);return n.shift(),r}return null}_calculateCurveWidths(e,t,n){let r=n.velocityFilterWeight*t.velocityFrom(e)+(1-n.velocityFilterWeight)*this._lastVelocity,i=this._strokeWidth(r,n),a={end:i,start:this._lastWidth};return this._lastVelocity=r,this._lastWidth=i,a}_strokeWidth(e,t){return Math.max(t.maxWidth/(e+1),t.minWidth)}_drawCurveSegment(e,t,n){let r=this._ctx;r.moveTo(e,t),r.arc(e,t,n,0,2*Math.PI,!1),this._isEmpty=!1}_drawCurve(e,t){let n=this._ctx,r=e.endWidth-e.startWidth,i=Math.ceil(e.length())*2;n.beginPath(),n.fillStyle=t.penColor;for(let n=0;n<i;n+=1){let a=n/i,o=a*a,s=o*a,c=1-a,l=c*c,u=l*c,d=u*e.startPoint.x;d+=3*l*a*e.control1.x,d+=3*c*o*e.control2.x,d+=s*e.endPoint.x;let f=u*e.startPoint.y;f+=3*l*a*e.control1.y,f+=3*c*o*e.control2.y,f+=s*e.endPoint.y;let p=Math.min(e.startWidth+s*r,t.maxWidth);this._drawCurveSegment(d,f,p)}n.closePath(),n.fill()}_drawDot(e,t){let n=this._ctx,r=t.dotSize>0?t.dotSize:(t.minWidth+t.maxWidth)/2;n.beginPath(),this._drawCurveSegment(e.x,e.y,r),n.closePath(),n.fillStyle=t.penColor,n.fill()}_fromData(e,t,n){for(let r of e){let{points:e}=r,i=this._getPointGroupOptions(r);if(e.length>1)for(let n=0;n<e.length;n+=1){let r=e[n],a=new NI(r.x,r.y,r.pressure,r.time);n===0&&this._reset(i);let o=this._addPoint(a,i);o&&t(o,i)}else this._reset(i),n(e[0],i)}}toSVG({includeBackgroundColor:e=!1,includeDataUrl:t=!1}={}){let n=this._data,r=Math.max(window.devicePixelRatio||1,1),i=this.canvas.width/r,a=this.canvas.height/r,o=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);if(o.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),o.setAttribute(`xmlns:xlink`,`http://www.w3.org/1999/xlink`),o.setAttribute(`viewBox`,`0 0 ${i} ${a}`),o.setAttribute(`width`,i.toString()),o.setAttribute(`height`,a.toString()),e&&this.backgroundColor){let e=document.createElement(`rect`);e.setAttribute(`width`,`100%`),e.setAttribute(`height`,`100%`),e.setAttribute(`fill`,this.backgroundColor),o.appendChild(e)}if(t&&this._dataUrl){let e=this._dataUrlOptions?.ratio||window.devicePixelRatio||1,t=this._dataUrlOptions?.width||this.canvas.width/e,n=this._dataUrlOptions?.height||this.canvas.height/e,r=this._dataUrlOptions?.xOffset||0,i=this._dataUrlOptions?.yOffset||0,a=document.createElement(`image`);a.setAttribute(`x`,r.toString()),a.setAttribute(`y`,i.toString()),a.setAttribute(`width`,t.toString()),a.setAttribute(`height`,n.toString()),a.setAttribute(`preserveAspectRatio`,`none`),a.setAttribute(`href`,this._dataUrl),o.appendChild(a)}return this._fromData(n,(e,{penColor:t})=>{let n=document.createElement(`path`);if(!isNaN(e.control1.x)&&!isNaN(e.control1.y)&&!isNaN(e.control2.x)&&!isNaN(e.control2.y)){let r=`M ${e.startPoint.x.toFixed(3)},${e.startPoint.y.toFixed(3)} C ${e.control1.x.toFixed(3)},${e.control1.y.toFixed(3)} ${e.control2.x.toFixed(3)},${e.control2.y.toFixed(3)} ${e.endPoint.x.toFixed(3)},${e.endPoint.y.toFixed(3)}`;n.setAttribute(`d`,r),n.setAttribute(`stroke-width`,(e.endWidth*2.25).toFixed(3)),n.setAttribute(`stroke`,t),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke-linecap`,`round`),o.appendChild(n)}},(e,{penColor:t,dotSize:n,minWidth:r,maxWidth:i})=>{let a=document.createElement(`circle`),s=n>0?n:(r+i)/2;a.setAttribute(`r`,s.toString()),a.setAttribute(`cx`,e.x.toString()),a.setAttribute(`cy`,e.y.toString()),a.setAttribute(`fill`,t),o.appendChild(a)}),o.outerHTML}};function RI(e){let t=Z(),{width:n=500,height:r=200,defaultValue:i,who:a,onChange:o,...s}=e,c=(0,b.useRef)(null),l=(0,b.useRef)(null),u=(0,b.useRef)(o);(0,b.useLayoutEffect)(()=>{u.current=o}),(0,b.useEffect)(()=>{function e(){u.current?.({type:[{system:Ox+`/fhir/signature-type`,code:`ProofOfOrigin`,display:`Proof of Origin`}],when:new Date().toISOString(),who:a??aC(t.getProfile()),data:l.current?.toDataURL().split(`,`)[1]})}if(c.current){let t=new LI(c.current);i?.data&&t.fromDataURL(i.data).catch(console.error),t.addEventListener(`endStroke`,e),l.current=t}return()=>{l.current&&l.current.removeEventListener(`beginStroke`,e)}},[t,i,a]);let d=()=>{l.current&&l.current.clear(),u.current?.(void 0)};return(0,I.jsxs)(yl,{withBorder:!0,p:0,w:n,h:r,pos:`relative`,...s,children:[(0,I.jsx)(`canvas`,{ref:c,width:n,height:r,"aria-label":`Signature input area`}),(0,I.jsx)(U,{onClick:d,"aria-label":`Clear signature`,pos:`absolute`,top:0,right:0,size:`xs`,leftSection:(0,I.jsx)(kj,{size:16}),variant:`subtle`,color:`gray`,children:`Clear`})]})}function zI(e){let t=[...e.context,e.responseItem];return(0,I.jsxs)(`div`,{children:[e.item.text&&(0,I.jsx)(q,{order:4,mb:`md`,children:e.item.text}),(0,I.jsx)(iL,{formState:e.formState,context:t,items:e.item.item??[],responseItems:e.responseItem.item??[]})]},e.item.linkId)}var BI=30,VI=50;function HI(e){let t=e.formState,n=e.item,r=e.responseItem;function i(i){if(t&&e.context)if(n.repeats&&e.index!==void 0&&n.type!==ik.choice&&n.type!==ik.openChoice){let n=[...r.answer||[]];i.length===0?n.splice(e.index,1):n[e.index]=i[0],t.onChangeAnswer(e.context,e.item,n)}else t.onChangeAnswer(e.context,e.item,i)}let a=n.type;if(!a)return null;let o=n.linkId;if(!o)return null;let s=n.repeats&&e.index!==void 0&&n.type!==ik.choice&&n.type!==ik.openChoice?`${o}-${e.index}`:o,c;n.initial&&n.initial.length>0?c=n.initial[0]:n.answerOption&&n.answerOption.length>0&&(c=n.answerOption.find(e=>e.initialSelected));let l=XI(r,e.index)??Rk(c),u=vC(r,`${Ox}/fhir/StructureDefinition/questionnaire-validationError`),d=null;switch(a){case ik.display:d=(0,I.jsx)(`p`,{children:e.item.text},e.item.linkId);break;case ik.boolean:d=(0,I.jsx)(kF,{title:e.item.text,htmlFor:s,children:(0,I.jsx)(lp,{id:s,name:o,required:e.required??n.required,defaultChecked:l?.value,onChange:e=>i([{valueBoolean:e.currentTarget.checked}])})},e.item.linkId);break;case ik.decimal:d=(0,I.jsx)(yb,{type:`number`,step:`any`,id:s,name:o,required:e.required??n.required,defaultValue:l?.value,onChange:e=>i(e.currentTarget.value===``?[]:[{valueDecimal:e.currentTarget.valueAsNumber}])});break;case ik.integer:d=(0,I.jsx)(yb,{type:`number`,step:1,id:s,name:o,required:e.required??n.required,defaultValue:l?.value,onChange:e=>i(e.currentTarget.value===``?[]:[{valueInteger:e.currentTarget.valueAsNumber}])});break;case ik.date:d=(0,I.jsx)(yb,{type:`date`,id:s,name:o,required:e.required??n.required,defaultValue:l?.value,onChange:e=>i([{valueDate:e.currentTarget.value}])});break;case ik.dateTime:d=(0,I.jsx)(UF,{name:o,required:e.required??n.required,defaultValue:l?.value,onChange:e=>i([{valueDateTime:e}])});break;case ik.time:d=(0,I.jsx)(yb,{type:`time`,id:s,name:o,required:e.required??n.required,defaultValue:l?.value,onChange:e=>i([{valueTime:e.currentTarget.value}])});break;case ik.string:case ik.url:d=(0,I.jsx)(yb,{id:s,name:o,required:e.required??n.required,defaultValue:l?.value,onChange:e=>{let t=e.currentTarget.value;i(t===``?[]:[{valueString:t}])}});break;case ik.text:d=(0,I.jsx)(oh,{id:s,name:o,required:e.required??n.required,defaultValue:l?.value,onChange:e=>{let t=e.currentTarget.value;i(t===``?[]:[{valueString:t}])}});break;case ik.attachment:d=(0,I.jsx)(V,{py:4,children:(0,I.jsx)(pP,{path:``,name:s,defaultValue:l?.value,onChange:e=>i([{valueAttachment:e}])})});break;case ik.reference:d=(0,I.jsx)(cI,{name:s,required:e.required??n.required,targetTypes:kk(n),searchCriteria:jk(n,t?.subject,t?.encounter),defaultValue:l?.value,onChange:e=>i([{valueReference:e}])});break;case ik.quantity:d=(0,I.jsx)(ZF,{path:``,name:s,required:e.required??n.required,defaultValue:l?.value,onChange:e=>i([{valueQuantity:e}]),disableWheel:!0});break;case ik.choice:case ik.openChoice:{let{widget:t,multiselect:a}=eL(n),o={name:s,item:n,required:e.required??n.required,initial:c,response:r,multiselect:a,onChangeAnswer:i};d=t===`check-box`?(0,I.jsx)(JI,{...o}):t===`drop-down`?(0,I.jsx)(UI,{...o}):(0,I.jsx)(qI,{...o})}break;default:return null}return(0,I.jsxs)(I.Fragment,{children:[d,u?.valueString&&(0,I.jsx)(H,{c:`red`,size:`lg`,mt:4,children:u.valueString})]})}function UI(e){let{name:t,item:n,required:r,initial:i,onChangeAnswer:a,response:o,multiselect:s}=e;if(!n.answerOption?.length&&!n.answerValueSet)return(0,I.jsx)(YI,{});let c=Rk(i),l=XI(o)??c,u=ZI(o),d=n.repeats||s;if(n.answerValueSet)return(0,I.jsx)(jN,{name:t,placeholder:`Select items`,binding:n.answerValueSet,maxValues:d?void 0:1,required:r,onChange:e=>{d?e.length===0?a([{}]):a(e.map(e=>({valueCoding:e}))):a([{valueCoding:e[0]}])},defaultValue:l?.value});if(d){let{propertyName:e,data:t}=tL(n);return(0,I.jsx)(Sg,{data:t,placeholder:`Select items`,searchable:!0,defaultValue:u||[ow(c)],required:r,onChange:t=>{t.length===0?a([{}]):a(Tk(t,e,n))}})}else{let e=[``];if(n.answerOption)for(let t of n.answerOption){let n=zk(t);e.push(ow(n))}return(0,I.jsx)(Eg,{id:t,name:t,required:r,onChange:e=>{let t=e.currentTarget.selectedIndex;if(t===0){a([{}]);return}let r=n.answerOption[t-1],i=zk(r);a([{[`value`+UC(i.type)]:i.value}])},defaultValue:Cw(l?.value)||l?.value,data:e})}}function WI(e,t){return e?t.valueSetExpand({url:e,count:31}).then(e=>e.expansion?.contains??[]):Promise.resolve([])}function GI(e){let t=Z(),[n,r]=(0,b.useState)([]),[i,a]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{async function n(){if(e){a(!0);try{r(await WI(e,t))}catch(e){console.error(`Error loading value set:`,e)}finally{a(!1)}}}n().catch(console.error)},[e,t]),[n,i]}function KI(e,t){return e.map((e,n)=>[`${t}-valueset-${n}`,{type:`Coding`,value:{system:e.system,code:e.code,display:e.display}}])}function qI(e){let{name:t,item:n,required:r,initial:i,onChangeAnswer:a,response:o}=e,s=Bw(`QuestionnaireItemAnswerOption`,`value[x]`),c=Rk(i),[l,u]=GI(n.answerValueSet),d=[],f;if(n.answerValueSet)d.push(...KI(l,t));else if(n.answerOption){let e=n.answerOption.slice(0,VI).map((e,n)=>{let r=`${t}-option-${n}`,i=zk(e);return i?.value?(c&&yC(i)===yC(c)&&(f=r),[r,i]):null}).filter(e=>e!==null);d.push(...e)}let p=QI(d,XI(o));if(u)return(0,I.jsx)(H,{children:`Loading options...`});if(d.length===0)return(0,I.jsx)(YI,{});let m=d.slice(0,BI);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Pv.Group,{name:t,value:p??f,required:r,onChange:e=>{let t=d.find(t=>t[0]===e);if(t){let e=t[1];a([{[`value`+UC(e.type)]:e.value}])}},children:m.map(([e,t])=>(0,I.jsx)(Pv,{id:e,value:e,py:4,required:r,label:(0,I.jsx)(xF,{property:s,propertyType:t.type,value:t.value})},e))}),(n.answerValueSet&&d.length>BI||n.answerOption&&d.length>VI)&&(0,I.jsxs)(H,{size:`sm`,c:`dimmed`,mt:`xs`,children:[`Showing first `,BI,` options`]})]})}function JI(e){let{name:t,item:n,onChangeAnswer:r,response:i}=e,a=Bw(`QuestionnaireItemAnswerOption`,`value[x]`),[o,s]=GI(n.answerValueSet),[c,l]=(0,b.useState)(n.answerValueSet?(i?.answer?.map(e=>e.valueCoding)||[]).filter(e=>e!==void 0):ZI(i)),u=[];if(n.answerValueSet)u.push(...KI(o,t));else if(n.answerOption){let e=n.answerOption.slice(0,VI).map((e,n)=>{let r=`${t}-option-${n}`,i=zk(e);return i?.value?[r,i]:null}).filter(e=>e!==null);u.push(...e)}if(s)return(0,I.jsx)(H,{children:`Loading options...`});if(u.length===0)return(0,I.jsx)(YI,{});let d=u.slice(0,BI),f=(e,t)=>{if(n.answerValueSet){let n=c,i;i=t?[...n,e.value]:n.filter(t=>!EC(t,e.value)),l(i),i.length===0?r([{}]):r(i.map(e=>({valueCoding:e})))}else{let i=c,a=ow(e),o;o=t?[...i,a]:i.filter(e=>e!==a),l(o),o.length===0?r([{}]):r(Tk(o,`value`+UC(e.type),n))}};return(0,I.jsxs)(V,{style:{flexDirection:`column`,alignItems:`flex-start`},children:[d.map(([e,t])=>{let r=ow(t),i=n.answerValueSet?c.some(e=>EC(e,t.value)):c.includes(r);return(0,I.jsx)(lp,{id:e,label:(0,I.jsx)(xF,{property:a,propertyType:t.type,value:t.value}),checked:i,onChange:e=>f(t,e.currentTarget.checked)},e)}),(n.answerValueSet&&u.length>BI||n.answerOption&&u.length>VI)&&(0,I.jsxs)(H,{size:`sm`,c:`dimmed`,children:[`Showing first `,BI,` options`]})]})}function YI(){return(0,I.jsx)(yb,{disabled:!0,placeholder:`No Answers Defined`})}function XI(e,t=0){return zk(e?.answer?.[t]??{})}function ZI(e){let t=e?.answer;return t?t.map(e=>zk(e)).map(e=>Cw(e?.value)||e?.value).filter(Boolean):[]}function QI(e,t){return e.find(e=>EC(e[1].value,t?.value))?.[0]}var $I=[`drop-down`,`radio-button`,`check-box`];function eL(e){let t=`radio-button`,n=!1;e.answerValueSet&&(t=`drop-down`);for(let r of e.extension??[]){if(r.url!==ak)continue;let e=r.valueCodeableConcept?.coding?.[0]?.code;$I.includes(e)&&(t=e),e===`multi-select`&&(n=!0)}return t===`radio-button`&&n&&(t=`check-box`),{widget:t,multiselect:n}}function tL(e){if(e.answerOption?.length===0)return{propertyName:``,data:[]};let t=e.answerOption[0];return{propertyName:`value`+UC(zk(t).type),data:(e.answerOption??[]).map(e=>{let t=ow(zk(e));return{value:t,label:t}})}}function nL(e){return(0,I.jsxs)(I.Fragment,{children:[e.responseItems.map(t=>(0,I.jsx)(zI,{formState:e.formState,context:e.context,item:e.item,responseItem:t},`group-${t.id}`)),(0,I.jsx)(Pd,{onClick:()=>e.formState.onAddGroup(e.context,e.item),children:`Add Group: ${e.item.text}`})]})}function rL(e){let{formState:t,context:n,item:r,responseItem:i}=e,a=r.type===ik.choice||r.type===ik.openChoice,o=!a,s=!a&&i.answer&&i.answer.length>0?i.answer:[{}];return(0,I.jsxs)(AF,{title:e.item.text,withAsterisk:e.item.required,children:[(0,I.jsx)(G,{gap:`xs`,children:s?.map((e,a)=>(0,I.jsx)(HI,{formState:t,context:n,item:r,responseItem:i,index:a},`${r.linkId}-${a}`))}),o&&(0,I.jsx)(Pd,{onClick:()=>t.onAddAnswer(n,r),children:`Add Item`})]},e.item.linkId)}function iL(e){let{formState:t,context:n,items:r,responseItems:i}=e,a=n.length===0,o=!1;return(0,I.jsx)(G,{gap:`xl`,children:r.map((e,r)=>{if(!_k(e,t.questionnaireResponse))return null;let s=e.type===ik.group,c=a&&s&&o;if(s&&(o=!0),e.type===ik.display)return(0,I.jsx)(`p`,{children:e.text},`display-${e.id}-${r}`);let l=i.filter(t=>t.linkId===e.linkId);return e.type===ik.group&&e.repeats?(0,I.jsxs)(b.Fragment,{children:[c&&(0,I.jsx)(dm,{color:`var(--mantine-color-gray-2)`}),(0,I.jsx)(nL,{formState:t,context:n,item:e,responseItems:l})]},`repeating-group-${e.id}-${r}`):e.type===ik.group?(0,I.jsxs)(b.Fragment,{children:[c&&(0,I.jsx)(dm,{color:`var(--mantine-color-gray-2)`}),(0,I.jsx)(zI,{formState:t,context:n,item:e,responseItem:l[0]})]},`group-${e.id}-${r}`):e.type===ik.boolean?(0,I.jsx)(HI,{formState:t,context:n,item:e,responseItem:l[0],index:0},`boolean-item-${e.id}-${r}`):e.repeats?(0,I.jsx)(rL,{formState:t,context:n,item:e,responseItem:l[0]},`repeating-item-${e.id}-${r}`):(0,I.jsx)(AF,{htmlFor:e.linkId,title:e.text,withAsterisk:e.required,children:(0,I.jsx)(HI,{formState:t,context:n,item:e,responseItem:l[0],index:0})},`repeating-item-${e.id}-${r}`)})})}function aL(e){let{formState:t,submitButtonText:n,excludeButtons:r,children:i}=e,a=t.pages,o=t.activePage,s=o>0,c=o<a.length-1,l=o===a.length-1;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Iy,{active:o,allowNextStepsSelect:!1,p:6,children:a.map((e,t)=>(0,I.jsx)(Iy.Step,{label:e.title,children:t===o&&i},e.linkId))}),!r&&(0,I.jsxs)(V,{justify:`flex-end`,mt:`xl`,gap:`xs`,children:[s&&(0,I.jsx)(U,{onClick:t.onPrevPage,children:`Back`}),c&&(0,I.jsx)(U,{onClick:e=>{e.currentTarget.closest(`form`).reportValidity()&&t.onNextPage()},children:`Next`}),l&&(0,I.jsx)(wN,{children:n??`Submit`})]})]})}function oL(e){let t=Z(),[n,r]=(0,b.useState)(!1),i=(0,b.useRef)(e),a=(0,b.useRef)(void 0);(0,b.useLayoutEffect)(()=>{i.current=e});let o=(0,b.useCallback)(e=>{a.current=e},[]),s=Hk({questionnaire:e.questionnaire,defaultValue:e.questionnaireResponse,subject:e.subject,encounter:e.encounter,source:e.source,disablePagination:e.disablePagination,onChange:o}),c=(0,b.useRef)(s);(0,b.useLayoutEffect)(()=>{c.current=s}),(0,b.useEffect)(()=>{let e=a.current;e&&(a.current=void 0,r(!1),i.current.onChange?.(e))});let l=(0,b.useMemo)(()=>s.loading?!1:!!vC(s.questionnaire,dk),[s]),u=(0,b.useMemo)(()=>s.loading?!1:!!s.questionnaireResponse.extension?.find(e=>e.url===fk),[s]),d=(0,b.useCallback)(()=>{let e=c.current;if(e.loading)return;let n=i.current.onSubmit;if(!n)return;if(l&&!u){r(!0);return}let a=e.questionnaire,o=e.questionnaireResponse,s=i.current.subject,d=i.current.source;if(!d){let e=t.getProfile();e&&(d=aC(e))}n({...o,questionnaire:a.url??oC(a),subject:s,source:d,authored:new Date().toISOString(),status:`completed`})},[t,l,u]);return s.loading?null:(0,I.jsxs)(CN,{testid:`questionnaire-form`,onSubmit:d,children:[s.questionnaire.title&&(0,I.jsx)(q,{order:1,fz:`1.625rem`,fw:700,lh:1.3,mb:`xl`,children:s.questionnaire.title}),e.afterHeader&&(0,I.jsxs)(G,{gap:`xl`,mb:`xl`,children:[e.afterHeader,(0,I.jsx)(dm,{color:`var(--mantine-color-gray-2)`})]}),s.pagination?(0,I.jsx)(aL,{formState:s,submitButtonText:e.submitButtonText,excludeButtons:e.excludeButtons,children:(0,I.jsx)(iL,{formState:s,context:[],items:s.items,responseItems:s.responseItems})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(iL,{formState:s,context:[],items:s.items,responseItems:s.responseItems}),l&&(0,I.jsxs)(G,{mt:`md`,gap:0,children:[(0,I.jsx)(H,{size:`sm`,fw:500,children:`Signature`}),(0,I.jsx)(RI,{onChange:s.onChangeSignature}),!u&&n&&(0,I.jsx)(H,{c:`red`,size:`sm`,children:`Signature is required.`})]}),!e.excludeButtons&&(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,gap:`xs`,children:(0,I.jsx)(wN,{children:e.submitButtonText??`Submit`})})]})]})}var sL={draft:`blue`,active:`blue`,"on-hold":`yellow`,revoked:`red`,completed:`green`,"entered-in-error":`red`,unknown:`gray`,retired:`gray`,registered:`blue`,preliminary:`blue`,final:`green`,amended:`yellow`,corrected:`yellow`,cancelled:`red`,requested:`blue`,received:`blue`,accepted:`blue`,rejected:`red`,ready:`blue`,"in-progress":`blue`,failed:`red`,proposed:`blue`,pending:`blue`,booked:`blue`,arrived:`blue`,fulfilled:`green`,noshow:`red`,"checked-in":`blue`,waitlist:`gray`,routine:`gray`,urgent:`red`,asap:`red`,stat:`red`,"not-done":`red`,connected:`green`,disconnected:`red`,finished:`green`,planned:`gray`};function cL(e){let{status:t,...n}=e;return(0,I.jsx)(Mp,{color:e.color||sL[t],...n,children:t.replaceAll(`-`,` `)})}var lL={noteBody:`_noteBody_10swh_1`,noteCite:`_noteCite_10swh_5`,noteRoot:`_noteRoot_10swh_10`};function uL({value:e}){return e?(0,I.jsx)(G,{justify:`flex-start`,gap:`xs`,children:e.map(e=>e.text&&(0,I.jsx)(Ip,{classNames:{cite:lL.noteCite,root:lL.noteRoot},cite:e.authorReference?.display||e.authorString,icon:null,children:e.text},`note-${e.text}`))}):null}function dL(e){let{value:t,link:n,...r}=e,[i,a]=(0,b.useState)(),o=nk(t,a),s;if(i&&!Jx(i))s=`[${Qx(i)}]`;else if(o)s=uC(o);else return null;return n?(0,I.jsx)(Wj,{to:t,...r,children:s}):(0,I.jsx)(H,{component:`span`,...r,children:s})}function fL(e){return(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(Xj,{size:24,radius:12,value:e.value,link:e.link}),(0,I.jsx)(dL,{value:e.value,link:e.link})]})}var pL={table:`_table_pe9td_1`,criticalRow:`_criticalRow_pe9td_12`,noteBody:`_noteBody_pe9td_23`,noteCite:`_noteCite_pe9td_27`,noteRoot:`_noteRoot_pe9td_32`};mL.defaultProps={hideObservationNotes:!1,hideSpecimenInfo:!1,hideSubject:!1};function mL(e){let t=Z(),n=nk(e.value),[r,i]=(0,b.useState)();if((0,b.useEffect)(()=>{n?.specimen&&Promise.allSettled(n.specimen.map(e=>t.readReference(e))).then(e=>e.filter(e=>e.status===`fulfilled`).map(e=>e.value)).then(i).catch(console.error)},[t,n]),!n)return null;let a=r?.flatMap(e=>e.note||[])||[];if(n.presentedForm&&n.presentedForm.length>0){let e=n.presentedForm[0];e.contentType?.startsWith(`text/plain`)&&e.data&&a.push({text:window.atob(e.data)})}return(0,I.jsxs)(G,{children:[(0,I.jsx)(q,{children:`Diagnostic Report`}),(0,I.jsx)(hL,{value:n,hideSubject:e.hideSubject}),r&&!e.hideSpecimenInfo&&gL(r),n.result&&(0,I.jsx)(_L,{hideObservationNotes:e.hideObservationNotes,value:n.result}),a.length>0&&(0,I.jsx)(uL,{value:a}),n.conclusion&&(0,I.jsxs)(G,{mt:`md`,children:[(0,I.jsx)(H,{fw:500,size:`sm`,c:`dimmed`,children:`Conclusion`}),(0,I.jsx)(H,{children:n.conclusion})]})]})}function hL({value:e,hideSubject:t=!1}){return(0,I.jsxs)(V,{mt:`md`,gap:30,children:[e.subject&&!t&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{size:`xs`,tt:`uppercase`,c:`dimmed`,children:`Subject`}),(0,I.jsx)(fL,{value:e.subject,link:!0})]}),e.resultsInterpreter?.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{size:`xs`,tt:`uppercase`,c:`dimmed`,children:`Interpreter`}),(0,I.jsx)(fL,{value:e,link:!0})]},e.reference)),e.performer?.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{size:`xs`,tt:`uppercase`,c:`dimmed`,children:`Performer`}),(0,I.jsx)(fL,{value:e,link:!0})]},e.reference)),e.issued&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{size:`xs`,tt:`uppercase`,c:`dimmed`,children:`Issued`}),(0,I.jsx)(H,{children:fw(e.issued)})]}),e.status&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{size:`xs`,tt:`uppercase`,c:`dimmed`,children:`Status`}),(0,I.jsx)(cL,{status:e.status})]})]})}function gL(e){return(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsx)(q,{order:2,size:`h6`,children:`Specimens`}),(0,I.jsx)(yh,{type:`ordered`,children:e?.map(e=>(0,I.jsx)(yh.Item,{ml:`sm`,children:(0,I.jsxs)(V,{gap:20,children:[(0,I.jsxs)(V,{gap:5,children:[(0,I.jsx)(H,{fw:500,children:`Collected:`}),` `,fw(e.collection?.collectedDateTime)]}),(0,I.jsxs)(V,{gap:5,children:[(0,I.jsx)(H,{fw:500,children:`Received:`}),` `,fw(e.receivedTime)]})]})},`specimen-${e.id}`))})]})}function _L(e){return(0,I.jsxs)(`table`,{className:pL.table,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:`Test`}),(0,I.jsx)(`th`,{children:`Value`}),(0,I.jsx)(`th`,{children:`Reference Range`}),(0,I.jsx)(`th`,{children:`Interpretation`}),(0,I.jsx)(`th`,{children:`Category`}),(0,I.jsx)(`th`,{children:`Performer`}),(0,I.jsx)(`th`,{children:`Status`})]})}),(0,I.jsx)(`tbody`,{children:(0,I.jsx)(vL,{value:e.value,ancestorIds:e.ancestorIds,hideObservationNotes:e.hideObservationNotes})})]})}function vL(e){return(0,I.jsx)(I.Fragment,{children:e.value?.map(t=>(0,I.jsx)(yL,{value:t,ancestorIds:e.ancestorIds,hideObservationNotes:e.hideObservationNotes},`obs-${Uw(t)?t.reference:t.id}`))})}function yL(e){let t=nk(e.value);if(!t||e.ancestorIds?.includes(t.id))return null;let n=!e.hideObservationNotes&&t.note,r=SL(t);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`tr`,{className:Mn({[pL.criticalRow]:r}),children:[(0,I.jsx)(`td`,{rowSpan:n?2:1,children:(0,I.jsx)(Wj,{to:t,children:(0,I.jsx)(tF,{value:t.code})})}),(0,I.jsx)(`td`,{children:(0,I.jsx)(bL,{value:t})}),(0,I.jsx)(`td`,{children:(0,I.jsx)(xL,{value:t.referenceRange})}),(0,I.jsx)(`td`,{children:t.interpretation&&t.interpretation.length>0&&(0,I.jsx)(tF,{value:t.interpretation[0]})}),(0,I.jsx)(`td`,{children:t.category&&t.category.length>0&&(0,I.jsx)(I.Fragment,{children:t.category.map(e=>(0,I.jsx)(`div`,{children:(0,I.jsx)(tF,{value:e})},`category-${Sw(e)}`))})}),(0,I.jsx)(`td`,{children:t.performer?.map(e=>(0,I.jsx)(mF,{value:e},e.reference))}),(0,I.jsx)(`td`,{children:t.status&&(0,I.jsx)(cL,{status:t.status})})]}),t.hasMember&&(0,I.jsx)(vL,{value:t.hasMember,ancestorIds:e.ancestorIds?[...e.ancestorIds,t.id]:[t.id],hideObservationNotes:e.hideObservationNotes}),n&&(0,I.jsx)(`tr`,{children:(0,I.jsx)(`td`,{colSpan:6,children:(0,I.jsx)(uL,{value:t.note})})})]})}function bL(e){let t=e.value;return(0,I.jsx)(I.Fragment,{children:ww(t)})}function xL(e){let t=e.value&&e.value.length>0&&e.value[0];return t?t.text?(0,I.jsx)(I.Fragment,{children:t.text}):(0,I.jsx)(fF,{value:t}):null}function SL(e){let t=e.interpretation?.[0]?.coding?.[0]?.code;return t===`AA`||t===`LL`||t===`HH`||t===`A`}var CL=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Pointer=void 0,e.unescapeToken=t,e.escapeToken=n;function t(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function n(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.Pointer=function(){function e(e){e===void 0&&(e=[``]),this.tokens=e}return e.fromJSON=function(n){var r=n.split(`/`).map(t);if(r[0]!==``)throw Error(`Invalid JSON Pointer: ${n}`);return new e(r)},e.prototype.toString=function(){return this.tokens.map(n).join(`/`)},e.prototype.evaluate=function(e){for(var t=null,n=``,r=e,i=1,a=this.tokens.length;i<a;i++)t=r,n=this.tokens[i],!(n==`__proto__`||n==`constructor`||n==`prototype`)&&(r=(t||{})[n]);return{parent:t,key:n,value:r}},e.prototype.get=function(e){return this.evaluate(e).value},e.prototype.set=function(e,t){var n=this.evaluate(e);n.parent&&(n.parent[n.key]=t)},e.prototype.push=function(e){this.tokens.push(e)},e.prototype.add=function(t){return new e(this.tokens.concat(String(t)))},e.prototype.parent=function(){return new e(this.tokens.length>1?this.tokens.slice(0,-1):[``])},e}()})),wL=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hasOwnProperty=void 0,e.objectType=t,e.clone=r,e.hasOwnProperty=Object.prototype.hasOwnProperty;function t(e){return e===void 0?`undefined`:e===null?`null`:Array.isArray(e)?`array`:typeof e}function n(e){return typeof e==`object`&&!!e}function r(t){if(!n(t))return t;if(t.constructor==Array){for(var i=t.length,a=Array(i),o=0;o<i;o++)a[o]=r(t[o]);return a}if(t.constructor==Date)return new Date(+t);var s={};for(var c in t)e.hasOwnProperty.call(t,c)&&(s[c]=r(t[c]));return s}})),TL=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isDestructive=n,e.subtract=r,e.intersection=i,e.diffArrays=l,e.diffObjects=u,e.diffAny=d;var t=wL();function n(e){var t=e.op;return t===`remove`||t===`replace`||t===`copy`||t===`move`}function r(e,n){var r=[];for(var i in e)t.hasOwnProperty.call(e,i)&&e[i]!==void 0&&!(t.hasOwnProperty.call(n,i)&&n[i]!==void 0)&&r.push(i);return r}function i(e){for(var n=e.length,r={},i=0;i<n;i++){var a=e[i];for(var o in a)t.hasOwnProperty.call(a,o)&&a[o]!==void 0&&(r[o]=(r[o]||0)+1)}for(var o in r)r[o]<n&&delete r[o];return Object.keys(r)}function a(e,n){var r=[];for(var i in e)t.hasOwnProperty.call(e,i)&&e[i]!==void 0&&t.hasOwnProperty.call(n,i)&&n[i]!==void 0&&r.push(i);return r}function o(e){return e.op===`add`}function s(e){return e.op===`remove`}function c(e,t){return{operations:e.operations.concat(t),cost:e.cost+1}}function l(e,t,n,r){r===void 0&&(r=d);var i=Math.max(e.length,t.length),a=new Map([[0,{operations:[],cost:0}]]);function l(o,s){var u=o*i+s,d=a.get(u);if(d===void 0){if(o>0&&s>0&&!r(e[o-1],t[s-1],n.add(String(o-1))).length)d=l(o-1,s-1);else{var f=[];if(o>0){var p=l(o-1,s),m={op:`remove`,index:o-1};f.push(c(p,m))}if(s>0){var h=l(o,s-1),g={op:`add`,index:o-1,value:t[s-1]};f.push(c(h,g))}if(o>0&&s>0){var _=l(o-1,s-1),v={op:`replace`,index:o-1,original:e[o-1],value:t[s-1]};f.push(c(_,v))}d=f.sort(function(e,t){return e.cost-t.cost})[0]}a.set(u,d)}return d}var u=isNaN(e.length)||e.length<=0?0:e.length;return l(u,isNaN(t.length)||t.length<=0?0:t.length).operations.reduce(function(e,t){var i=e[0],a=e[1];if(o(t)){var c=t.index+1+a,l=c<u+a?String(c):`-`,d={op:t.op,path:n.add(l).toString(),value:t.value};return[i.concat(d),a+1]}else if(s(t)){var d={op:t.op,path:n.add(String(t.index+a)).toString()};return[i.concat(d),a-1]}else{var f=n.add(String(t.index+a)),p=r(t.original,t.value,f);return[i.concat.apply(i,p),a]}},[[],0])[0]}function u(e,t,n,i){i===void 0&&(i=d);var o=[];return r(e,t).forEach(function(e){o.push({op:`remove`,path:n.add(e).toString()})}),r(t,e).forEach(function(e){o.push({op:`add`,path:n.add(e).toString(),value:t[e]})}),a(e,t).forEach(function(r){o.push.apply(o,i(e[r],t[r],n.add(r)))}),o}function d(e,n,r,i){if(i===void 0&&(i=d),e===n)return[];var a=(0,t.objectType)(e),o=(0,t.objectType)(n);return a==`array`&&o==`array`?l(e,n,r,i):a==`object`&&o==`object`?u(e,n,r,i):[{op:`replace`,path:r.toString(),value:n}]}})),EL=o((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidOperationError=e.TestError=e.MissingError=void 0,e.add=l,e.remove=u,e.replace=d,e.move=f,e.copy=p,e.test=m,e.apply=g;var n=CL(),r=wL(),i=TL(),a=function(e){t(n,e);function n(t){var n=e.call(this,`Value required at path: ${t}`)||this;return n.path=t,n.name=`MissingError`,n}return n}(Error);e.MissingError=a;var o=function(e){t(n,e);function n(t,n){var r=e.call(this,`Test failed: ${t} != ${n}`)||this;return r.actual=t,r.expected=n,r.name=`TestError`,r}return n}(Error);e.TestError=o;function s(e,t,n){if(Array.isArray(e))if(t==`-`)e.push(n);else{var r=parseInt(t,10);e.splice(r,0,n)}else e[t]=n}function c(e,t){if(Array.isArray(e)){var n=parseInt(t,10);e.splice(n,1)}else delete e[t]}function l(e,t,i){var o=n.Pointer.fromJSON(t.path);if(i?.implicitArrayCreation&&o.tokens[o.tokens.length-1]===`-`){var c=o.parent().evaluate(e);c.value===void 0&&(0,r.objectType)(c.parent)===`object`&&(c.parent[c.key]=[])}var l=o.evaluate(e);return l.parent===void 0||i?.implicitArrayCreation&&l.key===`-`&&!Array.isArray(l.parent)?new a(t.path):(s(l.parent,l.key,(0,r.clone)(t.value)),null)}function u(e,t,r){var i=n.Pointer.fromJSON(t.path).evaluate(e);return i.value===void 0?new a(t.path):(c(i.parent,i.key),null)}function d(e,t,i){var o=n.Pointer.fromJSON(t.path).evaluate(e);if(o.parent===null)return new a(t.path);if(Array.isArray(o.parent)){if(parseInt(o.key,10)>=o.parent.length)return new a(t.path)}else if(o.value===void 0)return new a(t.path);return o.parent[o.key]=(0,r.clone)(t.value),null}function f(e,t,r){var i=n.Pointer.fromJSON(t.from).evaluate(e);if(i.value===void 0)return new a(t.from);var o=n.Pointer.fromJSON(t.path).evaluate(e);return o.parent===void 0?new a(t.path):(c(i.parent,i.key),s(o.parent,o.key,i.value),null)}function p(e,t,i){var o=n.Pointer.fromJSON(t.from).evaluate(e);if(o.value===void 0)return new a(t.from);var c=n.Pointer.fromJSON(t.path).evaluate(e);return c.parent===void 0?new a(t.path):(s(c.parent,c.key,(0,r.clone)(o.value)),null)}function m(e,t,r){var a=n.Pointer.fromJSON(t.path).evaluate(e);return(0,i.diffAny)(a.value,t.value,new n.Pointer).length?new o(a.value,t.value):null}var h=function(e){t(n,e);function n(t){var n=e.call(this,`Invalid operation: ${t.op}`)||this;return n.operation=t,n.name=`InvalidOperationError`,n}return n}(Error);e.InvalidOperationError=h;function g(e,t,n){switch(t.op){case`add`:return l(e,t,n);case`remove`:return u(e,t,n);case`replace`:return d(e,t,n);case`move`:return f(e,t,n);case`copy`:return p(e,t,n);case`test`:return m(e,t,n)}return new h(t)}})),DL=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Pointer=void 0,e.createPatch=i;var t=CL();Object.defineProperty(e,"Pointer",{enumerable:!0,get:function(){return t.Pointer}}),EL();var n=TL();function r(e){function t(r,i,a){var o=e(r,i,a);return Array.isArray(o)?o:(0,n.diffAny)(r,i,a,t)}return t}function i(e,i,a){var o=new t.Pointer;return(a?r(a):n.diffAny)(e,i,o)}})),OL={removed:`_removed_el5zk_1`,added:`_added_el5zk_6`};function kL(e){let{name:t,path:n,property:r,originalValue:i,revisedValue:a}=e,o=!!r?.type?.find(e=>e.code===`Attachment`),[s,c]=(0,b.useState)(o);return(0,I.jsx)(I.Fragment,{children:o&&!s||!o?(0,I.jsx)(I.Fragment,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:t}),(0,I.jsx)(K.Td,{className:OL.removed,children:i&&(0,I.jsx)(xF,{path:n,property:r,propertyType:i.type,value:i.value,ignoreMissingValues:!0})}),(0,I.jsx)(K.Td,{className:OL.added,children:a&&(0,I.jsx)(xF,{path:n,property:r,propertyType:a.type,value:a.value,ignoreMissingValues:!0})})]})}):(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:t}),(0,I.jsx)(K.Td,{colSpan:2,style:{textAlign:`right`},children:(0,I.jsx)(U,{onClick:()=>c(e=>!e),variant:`light`,children:`Expand`})})]})})}var AL={root:`_root_15xvr_1`,removed:`_removed_15xvr_20`,added:`_added_15xvr_25`},jL=DL();function ML(e){let t=Z(),{original:n,revised:r}=e,[i,a]=(0,b.useState)(!1);(0,b.useEffect)(()=>{t.requestSchema(e.original.resourceType).then(()=>a(!0)).catch(console.log)},[t,e.original.resourceType]);let o=(0,b.useMemo)(()=>{if(!i)return null;let e=[jS(n)],t=[jS(r)],a=[],o=NL((0,jL.createPatch)(n,r));for(let r of o){let i=r.path,o=PL(i),s=FL(n.resourceType,o),c=r.op===`add`?void 0:RT(o,e),l=r.op===`remove`?void 0:RT(o,t);a.push({key:`op-${r.op}-${r.path}`,name:`${UC(r.op)} ${o}`,path:s?.path??n.resourceType+`.`+o,property:s,originalValue:IL(s,c),revisedValue:IL(s,l)})}return a},[i,n,r]);return o?(0,I.jsxs)(K,{className:AL.root,children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{}),(0,I.jsx)(K.Th,{children:`Before`}),(0,I.jsx)(K.Th,{children:`After`})]})}),(0,I.jsx)(K.Tbody,{children:o.map(e=>{let{key:t,...n}=e;return(0,I.jsx)(kL,{...n},t)})})]}):null}function NL(e){let t=[];for(let n of e){let{op:r,path:i}=n;if(i.startsWith(`/meta/author`)||i.startsWith(`/meta/compartment`)||i.startsWith(`/meta/lastUpdated`)||i.startsWith(`/meta/versionId`))continue;let a=e.filter(e=>e.op===r&&e.path===i).length,o={op:r,path:i};a>1&&(r===`add`||r===`remove`)&&/\/[0-9-]+$/.test(i)&&(o.op=`replace`,o.path=i.replace(/\/[^/]+$/,``)),t.some(e=>e.op===o.op&&e.path===o.path)||t.push(o)}return t}function PL(e){let t=e.split(`/`).filter(Boolean),n=``;for(let e=0;e<t.length;e++){let r=t[e];r===`-`?n+=`.last()`:/^\d+$/.test(r)?n+=`[${r}]`:(e>0&&(n+=`.`),n+=r)}return n.endsWith(`.url`)&&(n=n.replace(/\.url$/,``)),n}function FL(e,t){try{return DO(e,{resourceType:`SearchParameter`,base:[e],code:e+`.`+t,expression:e+`.`+t})?.elementDefinitions?.[0]}catch(n){console.warn(`Failed to get element definition`,{resourceType:e,fhirPath:t,err:n});return}}function IL(e,t){return t&&{type:Array.isArray(t)?t[0].type:t.type,value:LL(t,!!e?.isArray)}}function LL(e,t){let n=Dx(e).flatMap(e=>e.value);return t?n:n[0]}function RL(e){let{profileUrl:t}=e,n=Z(),r=n.getAccessPolicy(),i=nk(e.value),[a,o]=(0,b.useState)(!1);(0,b.useEffect)(()=>{if(i)if(t)n.requestProfileSchema(t,{expandProfile:!0}).then(()=>{gS(t)?o(!0):console.error(`Schema not found for ${t}`)}).catch(e=>{console.error(`Error in requestProfileSchema`,e)});else{let e=i.resourceType;n.requestSchema(e).then(()=>{o(!0)}).catch(console.error)}},[n,t,i]);let s=(0,b.useMemo)(()=>i&&ME(i,OE.READ,r),[r,i]);return!a||!i?null:(0,I.jsx)(TF,{path:i.resourceType,value:{type:i.resourceType,value:e.forceUseInput?e.value:i},profileUrl:t,ignoreMissingValues:e.ignoreMissingValues,accessPolicyResource:s})}var zL={item:`_item_5q6yx_1`,itemPadding:`_itemPadding_5q6yx_5`};function BL(e){return(0,I.jsx)(hP,{children:e.children})}function VL(e){let{resource:t,profile:n,padding:r,popupMenuItems:i,...a}=e,o=n??t.meta?.author,s=t.meta?.onBehalfOf,c=e.dateTime??t.meta?.lastUpdated;return(0,I.jsxs)(_P,{"data-testid":`timeline-item`,fill:!0,...a,children:[(0,I.jsxs)(V,{justify:`space-between`,gap:8,mx:`xs`,my:`sm`,children:[(0,I.jsx)(Xj,{value:o,link:!0,size:`md`}),(0,I.jsxs)(`div`,{style:{flex:1},children:[(0,I.jsxs)(H,{size:`sm`,children:[(0,I.jsx)(dL,{c:`inherit`,fw:500,value:o,link:!0}),s&&(0,I.jsxs)(H,{component:`span`,size:`xs`,c:`dimmed`,children:[` on behalf of `,(0,I.jsx)(dL,{c:`inherit`,value:s,link:!0})]})]}),(0,I.jsxs)(H,{size:`xs`,children:[(0,I.jsx)(Wj,{c:`dimmed`,to:e.resource,children:fw(c)}),(0,I.jsx)(H,{component:`span`,c:`dimmed`,mx:8,children:`·`}),(0,I.jsx)(Wj,{c:`dimmed`,to:e.resource,children:e.resource.resourceType})]})]}),i&&(0,I.jsxs)(W,{position:`bottom-end`,shadow:`md`,width:200,children:[(0,I.jsx)(W.Target,{children:(0,I.jsx)(gu,{color:`gray`,variant:`subtle`,radius:`xl`,"aria-label":`Actions for ${oC(e.resource)}`,children:(0,I.jsx)(LA,{})})}),i]})]}),(0,I.jsx)(Fj,{children:(0,I.jsx)(`div`,{className:Mn(zL.item,{[zL.itemPadding]:r}),children:e.children})})]})}function HL(e,t){e.sort((e,n)=>{let r=UL(e,t),i=UL(n,t);return r>i?1:r<i?-1:WL(e,t)-WL(n,t)})}function UL(e,t){if(!GL(e,t)){let t=e.priority;if(typeof t==`string`)return{stat:4,asap:3,urgent:2}[t]??0}return 0}function WL(e,t){if(!GL(e,t)){if(e.resourceType===`Communication`&&e.sent)return new Date(e.sent).getTime();if((e.resourceType===`DiagnosticReport`||e.resourceType===`Media`||e.resourceType===`Observation`)&&e.issued)return new Date(e.issued).getTime();if(e.resourceType===`DocumentReference`&&e.date)return new Date(e.date).getTime()}let n=e.meta?.lastUpdated;return n?new Date(n).getTime():0}function GL(e,t){return!!t&&e.resourceType===t.resourceType&&e.id===t.id}var KL={pinnedComment:`_pinnedComment_u08s5_1`};function qL(e){let t=Z(),n=t.getProfile(),r=(0,b.useRef)(null),i=nk(e.value),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)([]),[l,u]=(0,b.useState)(10),d=e.loadTimelineResources,f=(0,b.useRef)(s);(0,b.useLayoutEffect)(()=>{f.current=s});let p=(0,b.useCallback)(e=>{HL(e,i),e.reverse(),c(e)},[i]),m=(0,b.useCallback)(e=>{let t=[];for(let n of e){if(n.status!==`fulfilled`)continue;let e=n.value;if(e.type===`history`&&o(e),e.entry)for(let n of e.entry)t.push(n.resource)}p(t)},[p]),h=(0,b.useCallback)(e=>p([...f.current,e]),[p]),g=(0,b.useCallback)(()=>{let n,r;`resourceType`in e.value?(n=e.value.resourceType,r=e.value.id):[n,r]=e.value.reference?.split(`/`),d(t,n,r).then(m).catch(console.error)},[t,e.value,d,m]);(0,b.useEffect)(()=>g(),[g]);function _(r){!i||!e.createCommunication||t.createResource(e.createCommunication(i,n,r)).then(e=>h(e)).catch(console.error)}function v(r){!i||!e.createMedia||t.createResource(e.createMedia(i,n,r)).then(e=>h(e)).then(()=>Ib({id:`upload-notification`,color:`teal`,title:`Upload complete`,message:``,icon:(0,I.jsx)(wA,{size:16}),autoClose:2e3})).catch(e=>Ib({id:`upload-notification`,color:`red`,title:`Upload error`,message:Qx(e),icon:(0,I.jsx)(UA,{size:16}),autoClose:2e3}))}function y(){J({id:`upload-notification`,loading:!0,title:`Initializing upload...`,message:`Please wait...`,autoClose:!1,withCloseButton:!1})}function x(e){Ib({id:`upload-notification`,loading:!0,title:`Uploading...`,message:eR(e),autoClose:!1,withCloseButton:!1})}function S(e){Ib({id:`upload-notification`,color:`red`,title:`Upload error`,message:Qx(e),icon:(0,I.jsx)(UA,{size:16}),autoClose:2e3})}if(!i)return(0,I.jsx)(Kp,{style:{width:`100%`,height:`100%`},children:(0,I.jsx)(cu,{})});let C=s.filter(e=>e).slice(0,l);return(0,I.jsxs)(BL,{children:[e.createCommunication&&(0,I.jsx)(_P,{children:(0,I.jsx)(CN,{testid:`timeline-form`,onSubmit:e=>{_(e.text);let t=r.current;t&&(t.value=``,t.focus())},children:(0,I.jsxs)(V,{gap:`xs`,wrap:`nowrap`,style:{width:`100%`},children:[(0,I.jsx)(Xj,{value:n}),(0,I.jsx)(yb,{name:`text`,ref:r,placeholder:`Add comment`,style:{width:`100%`,maxWidth:300}}),(0,I.jsx)(gu,{type:`submit`,radius:`xl`,color:`blue`,variant:`filled`,children:(0,I.jsx)(nj,{size:16})}),(0,I.jsx)(dP,{securityContext:aC(i),onUpload:v,onUploadStart:y,onUploadProgress:x,onUploadError:S,children:e=>(0,I.jsx)(gu,{...e,radius:`xl`,color:`blue`,variant:`filled`,children:(0,I.jsx)(AA,{size:16})})})]})})}),C.map(t=>{let n=`${t.resourceType}/${t.id}/${t.meta?.versionId}`,r=e.getMenu?e.getMenu({primaryResource:i,currentResource:t,reloadTimeline:g}):void 0;if(t.resourceType===i.resourceType&&t.id===i.id)return(0,I.jsx)(JL,{history:a,resource:t,popupMenuItems:r},n);switch(t.resourceType){case`AuditEvent`:return(0,I.jsx)(QL,{resource:t,popupMenuItems:r},n);case`Communication`:return(0,I.jsx)(XL,{resource:t,popupMenuItems:r},n);case`DiagnosticReport`:return(0,I.jsx)($L,{resource:t,popupMenuItems:r},n);case`Media`:return(0,I.jsx)(ZL,{resource:t,popupMenuItems:r},n);default:return(0,I.jsx)(VL,{resource:t,padding:!0,children:(0,I.jsx)(RL,{value:t,ignoreMissingValues:!0})},n)}}),l<s.length&&(0,I.jsx)(V,{justify:`center`,pb:`lg`,children:(0,I.jsx)(U,{onClick:()=>u(l+10),children:`Show More`})})]})}function JL(e){let{history:t,resource:n,...r}=e,i=YL(t,n);return i?(0,I.jsx)(VL,{resource:n,padding:!0,...r,children:(0,I.jsx)(ML,{original:i,revised:e.resource})}):(0,I.jsxs)(VL,{resource:n,padding:!0,...r,children:[(0,I.jsx)(`h3`,{children:`Created`}),(0,I.jsx)(RL,{value:n,ignoreMissingValues:!0,forceUseInput:!0})]})}function YL(e,t){let n=e.entry??[],r=n.findIndex(e=>e.resource?.meta?.versionId===t.meta?.versionId);if(!(r>=n.length-1))return n[r+1].resource}function XL(e){let t=!e.resource.priority||e.resource.priority===`routine`?void 0:KL.pinnedComment;return(0,I.jsx)(VL,{resource:e.resource,profile:e.resource.sender,dateTime:e.resource.sent,padding:!0,className:t,popupMenuItems:e.popupMenuItems,children:(0,I.jsx)(`p`,{children:e.resource.payload?.[0]?.contentString})})}function ZL(e){let t=e.resource.content?.contentType,n=t&&!t.startsWith(`image/`)&&!t.startsWith(`video/`)&&t!==`application/pdf`;return(0,I.jsx)(VL,{resource:e.resource,padding:!!n,popupMenuItems:e.popupMenuItems,children:(0,I.jsx)(aP,{value:e.resource.content})})}function QL(e){return(0,I.jsx)(VL,{resource:e.resource,padding:!0,popupMenuItems:e.popupMenuItems,children:(0,I.jsx)(ul,{children:(0,I.jsx)(`pre`,{children:e.resource.outcomeDesc})})})}function $L(e){return(0,I.jsx)(VL,{resource:e.resource,padding:!0,popupMenuItems:e.popupMenuItems,children:(0,I.jsx)(mL,{value:e.resource})})}function eR(e){if(e.lengthComputable){let t=100*e.loaded/e.total;return`Uploaded: ${tR(e.loaded)} / ${tR(e.total)} ${t.toFixed(2)}%`}return`Uploaded: ${tR(e.loaded)}`}function tR(e){if(e===0)return`0.00 B`;let t=Math.floor(Math.log(e)/Math.log(1024));return(e/1024**t).toFixed(2)+` `+` KMGTP`.charAt(t)+`B`}function nR(e){let{resource:t,...n}=e;return(0,I.jsx)(qL,{value:t,loadTimelineResources:async(e,t,n)=>{let r=`${t}/${n}`;return Promise.allSettled([e.readHistory(t,n),e.search(`Task`,{_filter:`based-on eq ${r} or focus eq ${r} or subject eq ${r}`,_count:100})])},...n})}function rR(e){let{encounter:t,...n}=e;return(0,I.jsx)(qL,{value:t,loadTimelineResources:async(e,t,n)=>Promise.allSettled([e.readHistory(`Encounter`,n),e.search(`Communication`,`encounter=Encounter/`+n),e.search(`Media`,`encounter=Encounter/`+n)]),createCommunication:(e,t,n)=>({resourceType:`Communication`,status:`completed`,encounter:aC(e),subject:e.subject,sender:aC(t),sent:new Date().toISOString(),payload:[{contentString:n}]}),createMedia:(e,t,n)=>({resourceType:`Media`,status:`completed`,encounter:aC(e),subject:e.subject,operator:aC(t),issued:new Date().toISOString(),content:n}),...n})}function iR(e){let t;try{t=LT(e.path,e.resource)}catch(e){return console.warn(`FhirPathDisplay:`,e),null}if(t.length>1)throw Error(`Component "path" for "FhirPathDisplay" must resolve to a single element. \
204
+ }`.replaceAll(/\s+/g,` `);return(await e.graphql(r)).data.StructureDefinitionList[0]}function mI(e){return e.type===`profile`&&!e?.error&&CC(e.resourceType)}function hI(e,t,n){return t===void 0?e:n===void 0?t:`${t}[${n}]`}var gI={indented:`_indented_ldk1d_1`};function _I({propertyDisplayName:e,onClick:t,testId:n}){let r=e?`Add ${e}`:`Add`;return e?(0,I.jsx)(U,{title:r,size:`sm`,color:`green.6`,variant:`subtle`,"data-testid":n,leftSection:(0,I.jsx)(jA,{size:`1.25rem`}),onClick:t,children:r}):(0,I.jsx)(gu,{title:r,color:`green.6`,"data-testid":n,onClick:t,children:(0,I.jsx)(jA,{size:`1.25rem`})})}function vI({propertyDisplayName:e,onClick:t,testId:n}){return(0,I.jsx)(gu,{title:e?`Remove ${e}`:`Remove`,color:`red.5`,"data-testid":n,variant:`subtle`,onClick:t,children:(0,I.jsx)(AA,{size:`1.25rem`})})}function yI(e){let{slice:t,property:n}=e,[r,i]=(0,b.useState)(e.defaultValue),a=t.typeSchema?.elements??t.elements,o=(0,b.useContext)(nA),s=(0,b.useMemo)(()=>{if(wC(a))return sO({parentContext:o,elements:a,path:e.path,profileUrl:t.typeSchema?.url})},[o,e.path,t.typeSchema?.url,a]);function c(t){i(t),e.onChange&&e.onChange(t)}let l=t.min>0,u=CC(t.elements),d=Lw(t.name),f=e.property.readonly&&r.length===0;return yF(nA.Provider,s,(0,I.jsx)(MF,{title:d,description:t.definition,withAsterisk:l,fhirPath:`${n.path}:${t.name}`,testId:e.testId,readonly:e.property.readonly,children:f?(0,I.jsx)(H,{c:`dimmed`,children:`(empty)`}):(0,I.jsxs)(G,{className:u?gI.indented:void 0,children:[r.map((n,i)=>(0,I.jsxs)(V,{wrap:`nowrap`,children:[(0,I.jsx)(`div`,{style:{flexGrow:1},"data-testid":e.testId&&`${e.testId}-elements-${i}`,children:(0,I.jsx)(kI,{elementDefinitionType:t.type[0],name:t.name,defaultValue:n,onChange:e=>{let t=[...r];t[i]=e,c(t)},outcome:e.outcome,min:t.min,max:t.max,binding:t.binding,path:e.path,valuePath:void 0,readOnly:e.property.readonly})}),!e.property.readonly&&r.length>t.min&&(0,I.jsx)(vI,{propertyDisplayName:d,testId:e.testId&&`${e.testId}-remove-${i}`,onClick:e=>{Bj(e);let t=[...r];t.splice(i,1),c(t)}})]},`${i}-${r.length}`)),!e.property.readonly&&r.length<t.max&&(0,I.jsx)(V,{wrap:`nowrap`,style:{justifyContent:`flex-start`},children:(0,I.jsx)(_I,{propertyDisplayName:d,onClick:e=>{Bj(e),c([...r,void 0])},testId:e.testId&&`${e.testId}-add`})})]})}))}function bI(e){let{property:t}=e,n=Z(),[r,i]=(0,b.useState)(!0),[a,o]=(0,b.useState)([]),[s]=(0,b.useState)(()=>Array.isArray(e.defaultValue)?e.defaultValue:[]),[c,l]=(0,b.useState)(()=>[s]),u=(0,b.useContext)(nA),d=t.type[0]?.code;(0,b.useEffect)(()=>{vF({medplum:n,property:t}).then(e=>{o(e);let n=_F(s,e,t.slicing,u.profileUrl);xI(n,e),l(n),i(!1)}).catch(e=>{console.error(e),i(!1)})},[n,t,s,u.profileUrl,l]);function f(t,n){let r=[...c];if(r[n]=t,l(r),e.onChange){let t=r.flat().filter(e=>e!==void 0);e.onChange(t)}}if(r)return(0,I.jsx)(`div`,{children:`Loading...`});let p=a.length,m=c[p],h=!(e.hideNonSliceValues??(d===`Extension`&&a.length>0)),g=Iw(t.path),_=e.property.readonly&&a.length===0&&s.length===0;return(0,I.jsxs)(G,{className:e.indent?gI.indented:void 0,children:[_&&(0,I.jsx)(H,{c:`dimmed`,children:`(empty)`}),a.map((n,r)=>(0,I.jsx)(yI,{slice:n,path:e.path,valuePath:e.valuePath,property:t,defaultValue:c[r],onChange:e=>{f(e,r)},testId:`slice-${n.name}`},n.name)),h&&m.map((t,n)=>(0,I.jsxs)(V,{wrap:`nowrap`,style:{flexGrow:1},children:[(0,I.jsx)(`div`,{style:{flexGrow:1},children:(0,I.jsx)(DI,{arrayElement:!0,property:e.property,name:e.name+`.`+n,path:e.path,valuePath:hI(e.path,e.valuePath,n),defaultValue:t,onChange:e=>{let t=[...m];t[n]=e,f(t,p)},defaultPropertyType:void 0,outcome:e.outcome})}),!e.property.readonly&&(0,I.jsx)(vI,{propertyDisplayName:g,testId:`nonsliced-remove-${n}`,onClick:e=>{Bj(e);let t=[...m];t.splice(n,1),f(t,p)}})]},`${n}-${m.length}`)),!e.property.readonly&&h&&c.flat().length<t.max&&(0,I.jsx)(V,{wrap:`nowrap`,style:{justifyContent:`flex-start`},children:(0,I.jsx)(_I,{propertyDisplayName:g,onClick:e=>{Bj(e);let t=[...m];t.push(void 0),f(t,p)},testId:`nonsliced-add`})})]})}function xI(e,t){for(let n=0;n<t.length;n++){let r=t[n],i=e[n];for(;i.length<r.min;)i.push(void 0)}}function SI(e){let[t,n]=(0,b.useState)(!1),r=jt(),i=(0,b.useRef)(null),a={...e.styles};return t||(a.input||={},a.input.WebkitTextSecurity=`disc`),(0,I.jsxs)(_d,{gap:`xs`,children:[(0,I.jsx)(oh,{...e,styles:{...a,root:{...a.root??{},flexGrow:1}},ref:i,autosize:!0,minRows:1,onFocus:()=>n(!0),onBlur:()=>n(!1)}),(0,I.jsx)(gu,{title:`Copy secret`,onClick:()=>{r.copy(i.current?.value),J({color:`green`,message:`Copied`})},children:(0,I.jsx)(PA,{})})]})}var CI=[`sun`,`mon`,`tue`,`wed`,`thu`,`fri`,`sat`];function wI(e){let[t,n]=(0,b.useState)(e.defaultValue),[r,i]=(0,b.useState)(!e.disabled&&(e.defaultModalOpen??!1));return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)(`span`,{"data-testid":`timinginput-display`,children:_w(t)||`No repeat`}),(0,I.jsx)(U,{disabled:e.disabled,onClick:()=>i(!0),children:`Edit`})]}),!e.disabled&&(0,I.jsx)(EI,{path:e.path,visible:r,defaultValue:t,onOk:t=>{e.onChange&&e.onChange(t),n(t),i(!1)},onCancel:()=>i(!1)})]})}var TI={repeat:{period:1,periodUnit:`d`}};function EI(e){let[t,n]=(0,b.useState)(e.defaultValue||TI),[r,i]=(0,b.useState)(()=>(e.defaultValue?.repeat?.timeOfDay??[]).map((e,t)=>({id:t,value:e}))),a=(0,b.useRef)(r.length),{getExtendedProps:o}=(0,b.useContext)(nA),[s,c,l,u,d,f]=(0,b.useMemo)(()=>[`event`,`repeat`,`repeat.period`,`repeat.periodUnit`,`repeat.dayOfWeek`,`repeat.timeOfDay`].map(t=>o(e.path+`.`+t)),[o,e.path]);function p(e){n(t=>({...t,event:[e]}))}function m(e){n(t=>({...t,repeat:e}))}function h(e){n(t=>({...t,repeat:{...t.repeat,period:e}}))}function g(e){n(t=>({...t,repeat:{...t.repeat,periodUnit:e}}))}function _(e){n(t=>({...t,repeat:{...t.repeat,dayOfWeek:e}}))}function v(e){i(t=>{let r=e(t),i=r.map(e=>e.value);return n(e=>({...e,repeat:{...e.repeat,timeOfDay:i}})),r})}return(0,I.jsx)(rg,{title:`Timing`,closeButtonProps:{"aria-label":`Close`},opened:e.visible,onClose:()=>e.onCancel(),children:(0,I.jsxs)(G,{gap:`md`,children:[(0,I.jsx)(MF,{title:`Starts on`,htmlFor:`timing-dialog-start`,children:(0,I.jsx)(GF,{disabled:s?.readonly,name:`timing-dialog-start`,onChange:e=>p(e)})}),(0,I.jsx)(Wy,{disabled:c?.readonly,label:`Repeat`,checked:!!t.repeat,onChange:e=>m(e.currentTarget.checked?TI.repeat:void 0)}),t.repeat&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(MF,{title:`Repeat every`,htmlFor:`timing-dialog-period`,children:(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,children:[(0,I.jsx)(yb,{disabled:l?.readonly,type:`number`,step:1,id:`timing-dialog-period`,name:`timing-dialog-period`,defaultValue:t.repeat.period||1,onChange:e=>h(Number.parseInt(e.currentTarget.value,10)||1)}),(0,I.jsx)(Eg,{disabled:u?.readonly,id:`timing-dialog-periodUnit`,name:`timing-dialog-periodUnit`,defaultValue:t.repeat.periodUnit,onChange:e=>g(e.currentTarget.value),data:[{label:`minute`,value:`min`},{label:`hour`,value:`h`},{label:`day`,value:`d`},{label:`week`,value:`wk`},{label:`month`,value:`mo`},{label:`year`,value:`a`}]})]})}),t.repeat.periodUnit===`wk`&&(0,I.jsx)(MF,{title:`Repeat on`,children:(0,I.jsx)($p.Group,{multiple:!0,onChange:_,value:t.repeat?.dayOfWeek,children:(0,I.jsx)(V,{justify:`space-between`,mt:`xs`,gap:`xs`,children:CI.map(e=>(0,I.jsx)($p,{value:e,size:`xs`,radius:`xl`,disabled:d?.readonly,checked:(t.repeat?.dayOfWeek??[]).includes(e),children:e.charAt(0).toUpperCase()},e))})})}),(0,I.jsx)(MF,{title:`At times`,children:(0,I.jsxs)(G,{mt:`xs`,children:[r.map((e,t)=>(0,I.jsxs)(V,{children:[(0,I.jsx)(yb,{disabled:f?.readonly,type:`time`,id:`timing-dialog-repeat-timeOfDay[${t}]`,name:`timing-dialog-repeat-timeOfDay[${t}]`,"data-testid":`timing-repeat-timeOfDay-input-${t}`,defaultValue:e.value.slice(0,5),onChange:n=>{let r=`${n.currentTarget.value}:00`;v(n=>n.with(t,{...e,value:r}))},style:{flexGrow:1}}),(0,I.jsx)(vI,{testId:`timing-repeat-timeOfDay-remove-${t}`,onClick:()=>v(e=>e.toSpliced(t,1))})]},e.id)),(0,I.jsx)(z,{children:(0,I.jsx)(_I,{propertyDisplayName:`Time of Day`,onClick:()=>v(e=>{let t=a.current++;return e.concat({id:t,value:`00:00:00`})})})})]})})]}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(U,{onClick:()=>e.onOk(t),children:`OK`})})]})})}function DI(e){let{property:t,name:n,onChange:r,defaultValue:i}=e,a=e.defaultPropertyType&&e.defaultPropertyType!==`undefined`?e.defaultPropertyType:t.type[0].code,o=t.type;if((t.isArray||t.max>1)&&!e.arrayElement){if(a===Y.Attachment)return(0,I.jsx)(mP,{name:n,defaultValue:i,onChange:r,disabled:t.readonly});let s=o[0]?.code!==Y.Extension;return(0,I.jsx)(bI,{property:t,name:n,path:e.path,valuePath:e.valuePath,defaultValue:i,indent:s,onChange:r,outcome:e.outcome})}else if(o.length>1)return(0,I.jsx)(OI,{elementDefinitionTypes:o,...e});else return(0,I.jsx)(kI,{name:n,defaultValue:i,onChange:t=>{if(e.onChange){let n=e.name.replace(`[x]`,UC(o[0].code));e.onChange(t,n)}},outcome:e.outcome,elementDefinitionType:o[0],min:t.min,max:t.min,binding:t.binding,path:e.path,valuePath:e.valuePath,readOnly:t.readonly})}function OI(e){let t=e.elementDefinitionTypes,n;e.defaultPropertyType&&(n=t.find(t=>t.code===e.defaultPropertyType)),n||=t[0];let[r,i]=(0,b.useState)(n);return(0,I.jsxs)(V,{gap:`xs`,grow:!0,wrap:`nowrap`,align:`flex-start`,children:[(0,I.jsx)(Eg,{disabled:e.property.readonly,style:{width:`200px`},defaultValue:r.code,"data-testid":e.name&&e.name+`-selector`,onChange:e=>{i(t.find(t=>t.code===e.currentTarget.value))},data:t.map(e=>({value:e.code,label:e.code}))}),(0,I.jsx)(kI,{name:e.name,defaultValue:e.defaultValue,outcome:e.outcome,elementDefinitionType:r,onChange:t=>{e.onChange&&e.onChange(t,e.name.replace(`[x]`,UC(r.code)))},min:e.property.min,max:e.property.max,binding:e.property.binding,path:e.property.path,valuePath:e.valuePath,readOnly:e.property.readonly})]})}function kI(e){let{name:t,onChange:n,outcome:r,binding:i,path:a,valuePath:o,readOnly:s}=e,c=e.min!==void 0&&e.min>0,l=e.elementDefinitionType.code,u=(0,b.useContext)(nA),d=(0,b.useMemo)(()=>{if(!WC(l)||!CC(e.defaultValue))return e.defaultValue;let t=Object.create(null);if(u.path===e.path)yO(t,u.elements);else{let n=GC(u.path,e.path);if(n===void 0)return e.defaultValue;yO(t,u.elements,n)}return wC(t)?t:e.defaultValue},[l,u.path,u.elements,e.path,e.defaultValue]);if(!l)return(0,I.jsx)(`div`,{children:`Property type not specified `});function f(){return{name:t,defaultValue:d,onChange:n,outcome:r,path:a,valuePath:o,disabled:s}}function p(){return{id:t,name:t,"data-testid":t,defaultValue:d,required:c,error:SP(e.outcome,o??a),disabled:s}}switch(l){case Y.SystemString:case Y.canonical:case Y.string:case Y.uri:case Y.url:return e.path===`Project.secret.value[x]`||e.path===`ClientApplication.certificateTrustStore`?(0,I.jsx)(SI,{...p(),onChange:t=>{e.onChange&&e.onChange(t.currentTarget.value)}}):(0,I.jsx)(yb,{...p(),onChange:e=>{n&&n(e.currentTarget.value)}});case Y.date:return(0,I.jsx)(yb,{...p(),type:`date`,onChange:e=>{n&&n(e.currentTarget.value)}});case Y.time:return(0,I.jsx)(yb,{...p(),type:`time`,step:1,onChange:e=>{n&&n(e.currentTarget.value)}});case Y.dateTime:case Y.instant:return(0,I.jsx)(GF,{...p(),onChange:n,outcome:r});case Y.decimal:case Y.integer:case Y.positiveInt:case Y.unsignedInt:return(0,I.jsx)(yb,{...p(),type:`number`,step:l===Y.decimal?`any`:`1`,onChange:e=>{if(n){let t=e.currentTarget.valueAsNumber;n(Number.isNaN(t)?void 0:t)}}});case Y.code:return(0,I.jsx)(FN,{...p(),error:void 0,onChange:n,binding:i?.valueSet,creatable:!0,maxValues:1});case Y.boolean:return(0,I.jsx)(lp,{...p(),defaultChecked:!!d,onChange:e=>{n&&n(e.currentTarget.checked)}});case Y.base64Binary:case Y.markdown:case Y.xhtml:return(0,I.jsx)(oh,{...p(),spellCheck:l!==Y.base64Binary,onChange:e=>{n&&n(e.currentTarget.value)}});case Y.Address:return(0,I.jsx)(cA,{...f()});case Y.Annotation:return(0,I.jsx)(lA,{...f()});case Y.Attachment:return(0,I.jsx)(hP,{...f()});case Y.CodeableConcept:return(0,I.jsx)(FF,{binding:i?.valueSet,...f()});case Y.Coding:return(0,I.jsx)(RF,{binding:i?.valueSet,...f()});case Y.ContactDetail:return(0,I.jsx)(HF,{...f()});case Y.ContactPoint:return(0,I.jsx)(VF,{...f()});case Y.Extension:return(0,I.jsx)(qF,{...f(),propertyType:e.elementDefinitionType});case Y.HumanName:return(0,I.jsx)(JF,{...f()});case Y.Identifier:return(0,I.jsx)(YF,{...f()});case Y.Money:return(0,I.jsx)(ZF,{...f()});case Y.Period:return(0,I.jsx)(QF,{...f()});case Y.Duration:case Y.Quantity:return(0,I.jsx)($F,{...f()});case Y.Range:return(0,I.jsx)(tI,{...f()});case Y.Ratio:return(0,I.jsx)(nI,{...f()});case Y.Reference:return(0,I.jsx)(uI,{...f(),targetTypes:jI(e.elementDefinitionType)});case Y.Timing:return(0,I.jsx)(wI,{...f()});case Y.Dosage:case Y.UsageContext:default:return(0,I.jsx)(PI,{...f(),typeName:l})}}var AI=[`${Ox}/fhir/StructureDefinition/`,`https://medplum.com/fhir/StructureDefinition/`];function jI(e){return e?.targetProfile?.map(e=>{let t=AI.find(t=>e.startsWith(t));return t?e.slice(t.length):e})}function MI(e){let[t,n]=(0,b.useState)(e.defaultValue??{}),r=(0,b.useContext)(nA),i=(0,b.useMemo)(()=>aA(r.elements),[r.elements]);function a(t){n(t),e.onChange&&e.onChange(t)}let o={type:e.type,value:t};return(0,I.jsx)(G,{style:{flexGrow:1},"data-testid":e.testId,children:i.map(([n,r])=>{let[i,s]=cF(o,n,r),c=r.min!==void 0&&r.min>0,l=e.valuePath?e.valuePath+`.`+n:void 0,u=(0,I.jsx)(DI,{property:r,name:n,path:e.path+`.`+n,valuePath:l,defaultValue:i,defaultPropertyType:s,onChange:(e,i)=>{a(NF({...t},n,i??n,r,e))},outcome:e.outcome},n);return e.type===`Extension`||rA.includes(n)?u:r.type.length===1&&r.type[0].code===`boolean`?(0,I.jsx)(jF,{title:Iw(n),description:r.description,htmlFor:n,fhirPath:r.path,withAsterisk:c,readonly:r.readonly,children:u},n):(0,I.jsx)(MF,{title:Iw(n),description:r.description,withAsterisk:c,htmlFor:n,outcome:e.outcome,fhirPath:r.path,errorExpression:l,readonly:r.readonly,children:u},n)})})}var NI={nested:`_nested_1ya4k_1`};function PI(e){let[t]=(0,b.useState)(()=>e.defaultValue??{}),n=(0,b.useContext)(nA),r=e.profileUrl??n?.profileUrl,i=(0,b.useMemo)(()=>pS(e.typeName,r),[e.typeName,r]),a=i?.type??e.typeName,o=(0,b.useMemo)(()=>{if(i)return sO({parentContext:n,elements:i.elements,path:e.path,profileUrl:i.url,accessPolicyResource:e.accessPolicyResource})},[i,n,e.path,e.accessPolicyResource]);if(!i)return(0,I.jsxs)(`div`,{children:[a,`\xA0not implemented`]});let s=n.path!==``;return yF(nA.Provider,o,(0,I.jsx)(z,{className:Mn({[NI.nested]:s}),children:(0,I.jsx)(MI,{path:e.path,valuePath:e.valuePath,type:a,defaultValue:t,onChange:e.onChange,outcome:e.outcome})}))}var FI=class{x;y;pressure;time;constructor(e,t,n,r){if(isNaN(e)||isNaN(t))throw Error(`Point is invalid: (${e}, ${t})`);this.x=+e,this.y=+t,this.pressure=n||0,this.time=r||Date.now()}distanceTo(e){return Math.sqrt((this.x-e.x)**2+(this.y-e.y)**2)}equals(e){return this.x===e.x&&this.y===e.y&&this.pressure===e.pressure&&this.time===e.time}velocityFrom(e){return this.time===e.time?0:this.distanceTo(e)/(this.time-e.time)}},II=class e{constructor(e,t,n,r,i,a){this.startPoint=e,this.control2=t,this.control1=n,this.endPoint=r,this.startWidth=i,this.endWidth=a}static fromPoints(t,n){let r=this.calculateControlPoints(t[0],t[1],t[2]).c2,i=this.calculateControlPoints(t[1],t[2],t[3]).c1;return new e(t[1],r,i,t[2],n.start,n.end)}static calculateControlPoints(e,t,n){let r=e.x-t.x,i=e.y-t.y,a=t.x-n.x,o=t.y-n.y,s={x:(e.x+t.x)/2,y:(e.y+t.y)/2},c={x:(t.x+n.x)/2,y:(t.y+n.y)/2},l=Math.sqrt(r*r+i*i),u=Math.sqrt(a*a+o*o),d=s.x-c.x,f=s.y-c.y,p=l+u==0?0:u/(l+u),m={x:c.x+d*p,y:c.y+f*p},h=t.x-m.x,g=t.y-m.y;return{c1:new FI(s.x+h,s.y+g),c2:new FI(c.x+h,c.y+g)}}length(){let e=0,t,n;for(let r=0;r<=10;r+=1){let i=r/10,a=this.point(i,this.startPoint.x,this.control1.x,this.control2.x,this.endPoint.x),o=this.point(i,this.startPoint.y,this.control1.y,this.control2.y,this.endPoint.y);if(r>0){let r=a-t,i=o-n;e+=Math.sqrt(r*r+i*i)}t=a,n=o}return e}point(e,t,n,r,i){return t*(1-e)*(1-e)*(1-e)+3*n*(1-e)*(1-e)*e+3*r*(1-e)*e*e+i*e*e*e}},LI=class{_et;constructor(){try{this._et=new EventTarget}catch{this._et=document}}addEventListener(e,t,n){this._et.addEventListener(e,t,n)}dispatchEvent(e){return this._et.dispatchEvent(e)}removeEventListener(e,t,n){this._et.removeEventListener(e,t,n)}};function RI(e,t=250){let n=0,r=null,i,a,o,s=()=>{n=Date.now(),r=null,i=e.apply(a,o),r||(a=null,o=[])};return function(...c){let l=Date.now(),u=t-(l-n);return a=this,o=c,u<=0||u>t?(r&&=(clearTimeout(r),null),n=l,i=e.apply(a,o),r||(a=null,o=[])):r||=window.setTimeout(s,u),i}}var zI=class e extends LI{constructor(t,n={}){super(),this.canvas=t,this.velocityFilterWeight=n.velocityFilterWeight||.7,this.minWidth=n.minWidth||.5,this.maxWidth=n.maxWidth||2.5,this.throttle=n.throttle??16,this.minDistance=n.minDistance??5,this.dotSize=n.dotSize||0,this.penColor=n.penColor||`black`,this.backgroundColor=n.backgroundColor||`rgba(0,0,0,0)`,this.compositeOperation=n.compositeOperation||`source-over`,this.canvasContextOptions=n.canvasContextOptions??{},this._strokeMoveUpdate=this.throttle?RI(e.prototype._strokeUpdate,this.throttle):e.prototype._strokeUpdate,this._handleMouseDown=this._handleMouseDown.bind(this),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this._handleTouchStart=this._handleTouchStart.bind(this),this._handleTouchMove=this._handleTouchMove.bind(this),this._handleTouchEnd=this._handleTouchEnd.bind(this),this._handlePointerDown=this._handlePointerDown.bind(this),this._handlePointerMove=this._handlePointerMove.bind(this),this._handlePointerUp=this._handlePointerUp.bind(this),this._handlePointerCancel=this._handlePointerCancel.bind(this),this._handleTouchCancel=this._handleTouchCancel.bind(this),this._ctx=t.getContext(`2d`,this.canvasContextOptions),this.clear(),this.on()}dotSize;minWidth;maxWidth;penColor;minDistance;velocityFilterWeight;compositeOperation;backgroundColor;throttle;canvasContextOptions;_ctx;_drawingStroke=!1;_isEmpty=!0;_dataUrl;_dataUrlOptions;_lastPoints=[];_data=[];_lastVelocity=0;_lastWidth=0;_strokeMoveUpdate;_strokePointerId;clear(){let{_ctx:e,canvas:t}=this;e.fillStyle=this.backgroundColor,e.clearRect(0,0,t.width,t.height),e.fillRect(0,0,t.width,t.height),this._data=[],this._reset(this._getPointGroupOptions()),this._isEmpty=!0,this._dataUrl=void 0,this._dataUrlOptions=void 0,this._strokePointerId=void 0}redraw(){let e=this._data,t=this._dataUrl,n=this._dataUrlOptions;this.clear(),t&&this.fromDataURL(t,n),this.fromData(e,{clear:!1})}fromDataURL(e,t={}){return new Promise((n,r)=>{let i=new Image,a=t.ratio||window.devicePixelRatio||1,o=t.width||this.canvas.width/a,s=t.height||this.canvas.height/a,c=t.xOffset||0,l=t.yOffset||0;this._reset(this._getPointGroupOptions()),i.onload=()=>{this._ctx.drawImage(i,c,l,o,s),n()},i.onerror=e=>{r(e)},i.crossOrigin=`anonymous`,i.src=e,this._isEmpty=!1,this._dataUrl=e,this._dataUrlOptions={...t}})}toDataURL(e=`image/png`,t){switch(e){case`image/svg+xml`:return typeof t!=`object`&&(t=void 0),`data:image/svg+xml;base64,${btoa(this.toSVG(t))}`;default:return typeof t!=`number`&&(t=void 0),this.canvas.toDataURL(e,t)}}on(){this.canvas.style.touchAction=`none`,this.canvas.style.msTouchAction=`none`,this.canvas.style.userSelect=`none`,this.canvas.style.webkitUserSelect=`none`;let e=/Macintosh/.test(navigator.userAgent)&&`ontouchstart`in document;window.PointerEvent&&!e?this._handlePointerEvents():(this._handleMouseEvents(),`ontouchstart`in window&&this._handleTouchEvents())}off(){this.canvas.style.touchAction=`auto`,this.canvas.style.msTouchAction=`auto`,this.canvas.style.userSelect=`auto`,this.canvas.style.webkitUserSelect=`auto`,this.canvas.removeEventListener(`pointerdown`,this._handlePointerDown),this.canvas.removeEventListener(`mousedown`,this._handleMouseDown),this.canvas.removeEventListener(`touchstart`,this._handleTouchStart),this._removeMoveUpEventListeners()}_getListenerFunctions(){let e=window.document===this.canvas.ownerDocument?window:this.canvas.ownerDocument.defaultView??this.canvas.ownerDocument;return{addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}_removeMoveUpEventListeners(){let{removeEventListener:e}=this._getListenerFunctions();e(`pointermove`,this._handlePointerMove),e(`pointerup`,this._handlePointerUp),e(`pointercancel`,this._handlePointerCancel),e(`mousemove`,this._handleMouseMove),e(`mouseup`,this._handleMouseUp),e(`touchmove`,this._handleTouchMove),e(`touchend`,this._handleTouchEnd),e(`touchcancel`,this._handleTouchCancel)}isEmpty(){return this._isEmpty}fromData(e,{clear:t=!0}={}){t&&this.clear(),this._fromData(e,this._drawCurve.bind(this),this._drawDot.bind(this)),this._data=this._data.concat(e)}toData(){return this._data}_isLeftButtonPressed(e,t){return t?e.buttons===1:(e.buttons&1)==1}_pointerEventToSignatureEvent(e){return{event:e,type:e.type,x:e.clientX,y:e.clientY,pressure:`pressure`in e?e.pressure:0}}_touchEventToSignatureEvent(e){let t=e.changedTouches[0];return{event:e,type:e.type,x:t.clientX,y:t.clientY,pressure:t.force}}_handleMouseDown(e){!this._isLeftButtonPressed(e,!0)||this._drawingStroke||this._strokeBegin(this._pointerEventToSignatureEvent(e))}_handleMouseMove(e){if(!this._isLeftButtonPressed(e,!0)||!this._drawingStroke){this._strokeEnd(this._pointerEventToSignatureEvent(e),!1);return}this._strokeMoveUpdate(this._pointerEventToSignatureEvent(e))}_handleMouseUp(e){this._isLeftButtonPressed(e)||this._strokeEnd(this._pointerEventToSignatureEvent(e))}_handleTouchStart(e){e.targetTouches.length!==1||this._drawingStroke||(e.cancelable&&e.preventDefault(),this._strokeBegin(this._touchEventToSignatureEvent(e)))}_handleTouchMove(e){if(e.targetTouches.length===1){if(e.cancelable&&e.preventDefault(),!this._drawingStroke){this._strokeEnd(this._touchEventToSignatureEvent(e),!1);return}this._strokeMoveUpdate(this._touchEventToSignatureEvent(e))}}_handleTouchEnd(e){e.targetTouches.length===0&&(e.cancelable&&e.preventDefault(),this._strokeEnd(this._touchEventToSignatureEvent(e)))}_handlePointerCancel(e){this._allowPointerId(e)&&(e.preventDefault(),this._strokeEnd(this._pointerEventToSignatureEvent(e),!1))}_handleTouchCancel(e){e.cancelable&&e.preventDefault(),this._strokeEnd(this._touchEventToSignatureEvent(e),!1)}_getPointerId(e){return e.persistentDeviceId||e.pointerId}_allowPointerId(e,t=!1){return this._strokePointerId===void 0?t:this._getPointerId(e)===this._strokePointerId}_handlePointerDown(e){this._drawingStroke||!this._isLeftButtonPressed(e)||!this._allowPointerId(e,!0)||(this._strokePointerId=this._getPointerId(e),e.preventDefault(),this._strokeBegin(this._pointerEventToSignatureEvent(e)))}_handlePointerMove(e){if(this._allowPointerId(e)){if(!this._isLeftButtonPressed(e,!0)||!this._drawingStroke){this._strokeEnd(this._pointerEventToSignatureEvent(e),!1);return}e.preventDefault(),this._strokeMoveUpdate(this._pointerEventToSignatureEvent(e))}}_handlePointerUp(e){this._isLeftButtonPressed(e)||!this._allowPointerId(e)||(e.preventDefault(),this._strokeEnd(this._pointerEventToSignatureEvent(e)))}_getPointGroupOptions(e){return{penColor:e&&`penColor`in e?e.penColor:this.penColor,dotSize:e&&`dotSize`in e?e.dotSize:this.dotSize,minWidth:e&&`minWidth`in e?e.minWidth:this.minWidth,maxWidth:e&&`maxWidth`in e?e.maxWidth:this.maxWidth,velocityFilterWeight:e&&`velocityFilterWeight`in e?e.velocityFilterWeight:this.velocityFilterWeight,compositeOperation:e&&`compositeOperation`in e?e.compositeOperation:this.compositeOperation}}_strokeBegin(e){if(!this.dispatchEvent(new CustomEvent(`beginStroke`,{detail:e,cancelable:!0})))return;let{addEventListener:t}=this._getListenerFunctions();switch(e.event.type){case`mousedown`:t(`mousemove`,this._handleMouseMove,{passive:!1}),t(`mouseup`,this._handleMouseUp,{passive:!1});break;case`touchstart`:t(`touchmove`,this._handleTouchMove,{passive:!1}),t(`touchend`,this._handleTouchEnd,{passive:!1}),t(`touchcancel`,this._handleTouchCancel,{passive:!1});break;case`pointerdown`:t(`pointermove`,this._handlePointerMove,{passive:!1}),t(`pointerup`,this._handlePointerUp,{passive:!1}),t(`pointercancel`,this._handlePointerCancel,{passive:!1});break;default:}this._drawingStroke=!0;let n=this._getPointGroupOptions(),r={...n,points:[]};this._data.push(r),this._reset(n),this._strokeUpdate(e)}_strokeUpdate(e){if(!this._drawingStroke)return;if(this._data.length===0){this._strokeBegin(e);return}this.dispatchEvent(new CustomEvent(`beforeUpdateStroke`,{detail:e}));let t=this._createPoint(e.x,e.y,e.pressure),n=this._data[this._data.length-1],r=n.points,i=r.length>0&&r[r.length-1],a=i?t.distanceTo(i)<=this.minDistance:!1,o=this._getPointGroupOptions(n);if(!i||!(i&&a)){let e=this._addPoint(t,o);i?e&&this._drawCurve(e,o):this._drawDot(t,o),r.push({time:t.time,x:t.x,y:t.y,pressure:t.pressure})}this.dispatchEvent(new CustomEvent(`afterUpdateStroke`,{detail:e}))}_strokeEnd(e,t=!0){this._removeMoveUpEventListeners(),this._drawingStroke&&(t&&this._strokeUpdate(e),this._drawingStroke=!1,this._strokePointerId=void 0,this.dispatchEvent(new CustomEvent(`endStroke`,{detail:e})))}_handlePointerEvents(){this._drawingStroke=!1,this.canvas.addEventListener(`pointerdown`,this._handlePointerDown,{passive:!1})}_handleMouseEvents(){this._drawingStroke=!1,this.canvas.addEventListener(`mousedown`,this._handleMouseDown,{passive:!1})}_handleTouchEvents(){this.canvas.addEventListener(`touchstart`,this._handleTouchStart,{passive:!1})}_reset(e){this._lastPoints=[],this._lastVelocity=0,this._lastWidth=(e.minWidth+e.maxWidth)/2,this._ctx.fillStyle=e.penColor,this._ctx.globalCompositeOperation=e.compositeOperation}_createPoint(e,t,n){let r=this.canvas.getBoundingClientRect();return new FI(e-r.left,t-r.top,n,new Date().getTime())}_addPoint(e,t){let{_lastPoints:n}=this;if(n.push(e),n.length>2){n.length===3&&n.unshift(n[0]);let e=this._calculateCurveWidths(n[1],n[2],t),r=II.fromPoints(n,e);return n.shift(),r}return null}_calculateCurveWidths(e,t,n){let r=n.velocityFilterWeight*t.velocityFrom(e)+(1-n.velocityFilterWeight)*this._lastVelocity,i=this._strokeWidth(r,n),a={end:i,start:this._lastWidth};return this._lastVelocity=r,this._lastWidth=i,a}_strokeWidth(e,t){return Math.max(t.maxWidth/(e+1),t.minWidth)}_drawCurveSegment(e,t,n){let r=this._ctx;r.moveTo(e,t),r.arc(e,t,n,0,2*Math.PI,!1),this._isEmpty=!1}_drawCurve(e,t){let n=this._ctx,r=e.endWidth-e.startWidth,i=Math.ceil(e.length())*2;n.beginPath(),n.fillStyle=t.penColor;for(let n=0;n<i;n+=1){let a=n/i,o=a*a,s=o*a,c=1-a,l=c*c,u=l*c,d=u*e.startPoint.x;d+=3*l*a*e.control1.x,d+=3*c*o*e.control2.x,d+=s*e.endPoint.x;let f=u*e.startPoint.y;f+=3*l*a*e.control1.y,f+=3*c*o*e.control2.y,f+=s*e.endPoint.y;let p=Math.min(e.startWidth+s*r,t.maxWidth);this._drawCurveSegment(d,f,p)}n.closePath(),n.fill()}_drawDot(e,t){let n=this._ctx,r=t.dotSize>0?t.dotSize:(t.minWidth+t.maxWidth)/2;n.beginPath(),this._drawCurveSegment(e.x,e.y,r),n.closePath(),n.fillStyle=t.penColor,n.fill()}_fromData(e,t,n){for(let r of e){let{points:e}=r,i=this._getPointGroupOptions(r);if(e.length>1)for(let n=0;n<e.length;n+=1){let r=e[n],a=new FI(r.x,r.y,r.pressure,r.time);n===0&&this._reset(i);let o=this._addPoint(a,i);o&&t(o,i)}else this._reset(i),n(e[0],i)}}toSVG({includeBackgroundColor:e=!1,includeDataUrl:t=!1}={}){let n=this._data,r=Math.max(window.devicePixelRatio||1,1),i=this.canvas.width/r,a=this.canvas.height/r,o=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`);if(o.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),o.setAttribute(`xmlns:xlink`,`http://www.w3.org/1999/xlink`),o.setAttribute(`viewBox`,`0 0 ${i} ${a}`),o.setAttribute(`width`,i.toString()),o.setAttribute(`height`,a.toString()),e&&this.backgroundColor){let e=document.createElement(`rect`);e.setAttribute(`width`,`100%`),e.setAttribute(`height`,`100%`),e.setAttribute(`fill`,this.backgroundColor),o.appendChild(e)}if(t&&this._dataUrl){let e=this._dataUrlOptions?.ratio||window.devicePixelRatio||1,t=this._dataUrlOptions?.width||this.canvas.width/e,n=this._dataUrlOptions?.height||this.canvas.height/e,r=this._dataUrlOptions?.xOffset||0,i=this._dataUrlOptions?.yOffset||0,a=document.createElement(`image`);a.setAttribute(`x`,r.toString()),a.setAttribute(`y`,i.toString()),a.setAttribute(`width`,t.toString()),a.setAttribute(`height`,n.toString()),a.setAttribute(`preserveAspectRatio`,`none`),a.setAttribute(`href`,this._dataUrl),o.appendChild(a)}return this._fromData(n,(e,{penColor:t})=>{let n=document.createElement(`path`);if(!isNaN(e.control1.x)&&!isNaN(e.control1.y)&&!isNaN(e.control2.x)&&!isNaN(e.control2.y)){let r=`M ${e.startPoint.x.toFixed(3)},${e.startPoint.y.toFixed(3)} C ${e.control1.x.toFixed(3)},${e.control1.y.toFixed(3)} ${e.control2.x.toFixed(3)},${e.control2.y.toFixed(3)} ${e.endPoint.x.toFixed(3)},${e.endPoint.y.toFixed(3)}`;n.setAttribute(`d`,r),n.setAttribute(`stroke-width`,(e.endWidth*2.25).toFixed(3)),n.setAttribute(`stroke`,t),n.setAttribute(`fill`,`none`),n.setAttribute(`stroke-linecap`,`round`),o.appendChild(n)}},(e,{penColor:t,dotSize:n,minWidth:r,maxWidth:i})=>{let a=document.createElement(`circle`),s=n>0?n:(r+i)/2;a.setAttribute(`r`,s.toString()),a.setAttribute(`cx`,e.x.toString()),a.setAttribute(`cy`,e.y.toString()),a.setAttribute(`fill`,t),o.appendChild(a)}),o.outerHTML}};function BI(e){let t=Z(),{width:n=500,height:r=200,defaultValue:i,who:a,onChange:o,...s}=e,c=(0,b.useRef)(null),l=(0,b.useRef)(null),u=(0,b.useRef)(o);(0,b.useLayoutEffect)(()=>{u.current=o}),(0,b.useEffect)(()=>{function e(){u.current?.({type:[{system:Ox+`/fhir/signature-type`,code:`ProofOfOrigin`,display:`Proof of Origin`}],when:new Date().toISOString(),who:a??aC(t.getProfile()),data:l.current?.toDataURL().split(`,`)[1]})}if(c.current){let t=new zI(c.current);i?.data&&t.fromDataURL(i.data).catch(console.error),t.addEventListener(`endStroke`,e),l.current=t}return()=>{l.current&&l.current.removeEventListener(`beginStroke`,e)}},[t,i,a]);let d=()=>{l.current&&l.current.clear(),u.current?.(void 0)};return(0,I.jsxs)(yl,{withBorder:!0,p:0,w:n,h:r,pos:`relative`,...s,children:[(0,I.jsx)(`canvas`,{ref:c,width:n,height:r,"aria-label":`Signature input area`}),(0,I.jsx)(U,{onClick:d,"aria-label":`Clear signature`,pos:`absolute`,top:0,right:0,size:`xs`,leftSection:(0,I.jsx)(jj,{size:16}),variant:`subtle`,color:`gray`,children:`Clear`})]})}function VI(e){let t=[...e.context,e.responseItem];return(0,I.jsxs)(`div`,{children:[e.item.text&&(0,I.jsx)(q,{order:4,mb:`md`,children:e.item.text}),(0,I.jsx)(oL,{formState:e.formState,context:t,items:e.item.item??[],responseItems:e.responseItem.item??[]})]},e.item.linkId)}var HI=30,UI=50;function WI(e){let t=e.formState,n=e.item,r=e.responseItem;function i(i){if(t&&e.context)if(n.repeats&&e.index!==void 0&&n.type!==ok.choice&&n.type!==ok.openChoice){let n=[...r.answer||[]];i.length===0?n.splice(e.index,1):n[e.index]=i[0],t.onChangeAnswer(e.context,e.item,n)}else t.onChangeAnswer(e.context,e.item,i)}let a=n.type;if(!a)return null;let o=n.linkId;if(!o)return null;let s=n.repeats&&e.index!==void 0&&n.type!==ok.choice&&n.type!==ok.openChoice?`${o}-${e.index}`:o,c;n.initial&&n.initial.length>0?c=n.initial[0]:n.answerOption&&n.answerOption.length>0&&(c=n.answerOption.find(e=>e.initialSelected));let l=QI(r,e.index)??Bk(c),u=vC(r,`${Ox}/fhir/StructureDefinition/questionnaire-validationError`),d=null;switch(a){case ok.display:d=(0,I.jsx)(`p`,{children:e.item.text},e.item.linkId);break;case ok.boolean:d=(0,I.jsx)(jF,{title:e.item.text,htmlFor:s,children:(0,I.jsx)(lp,{id:s,name:o,required:e.required??n.required,defaultChecked:l?.value,onChange:e=>i([{valueBoolean:e.currentTarget.checked}])})},e.item.linkId);break;case ok.decimal:d=(0,I.jsx)(yb,{type:`number`,step:`any`,id:s,name:o,required:e.required??n.required,defaultValue:l?.value,onChange:e=>i(e.currentTarget.value===``?[]:[{valueDecimal:e.currentTarget.valueAsNumber}])});break;case ok.integer:d=(0,I.jsx)(yb,{type:`number`,step:1,id:s,name:o,required:e.required??n.required,defaultValue:l?.value,onChange:e=>i(e.currentTarget.value===``?[]:[{valueInteger:e.currentTarget.valueAsNumber}])});break;case ok.date:d=(0,I.jsx)(yb,{type:`date`,id:s,name:o,required:e.required??n.required,defaultValue:l?.value,onChange:e=>i([{valueDate:e.currentTarget.value}])});break;case ok.dateTime:d=(0,I.jsx)(GF,{name:o,required:e.required??n.required,defaultValue:l?.value,onChange:e=>i([{valueDateTime:e}])});break;case ok.time:d=(0,I.jsx)(yb,{type:`time`,id:s,name:o,required:e.required??n.required,defaultValue:l?.value,onChange:e=>i([{valueTime:e.currentTarget.value}])});break;case ok.string:case ok.url:d=(0,I.jsx)(yb,{id:s,name:o,required:e.required??n.required,defaultValue:l?.value,onChange:e=>{let t=e.currentTarget.value;i(t===``?[]:[{valueString:t}])}});break;case ok.text:d=(0,I.jsx)(oh,{id:s,name:o,required:e.required??n.required,defaultValue:l?.value,onChange:e=>{let t=e.currentTarget.value;i(t===``?[]:[{valueString:t}])}});break;case ok.attachment:d=(0,I.jsx)(V,{py:4,children:(0,I.jsx)(hP,{path:``,name:s,defaultValue:l?.value,onChange:e=>i([{valueAttachment:e}])})});break;case ok.reference:d=(0,I.jsx)(uI,{name:s,required:e.required??n.required,targetTypes:jk(n),searchCriteria:Nk(n,t?.subject,t?.encounter),defaultValue:l?.value,onChange:e=>i([{valueReference:e}])});break;case ok.quantity:d=(0,I.jsx)($F,{path:``,name:s,required:e.required??n.required,defaultValue:l?.value,onChange:e=>i([{valueQuantity:e}]),disableWheel:!0});break;case ok.choice:case ok.openChoice:{let{widget:t,multiselect:a}=nL(n),o={name:s,item:n,required:e.required??n.required,initial:c,response:r,multiselect:a,onChangeAnswer:i};d=t===`check-box`?(0,I.jsx)(XI,{...o}):t===`drop-down`?(0,I.jsx)(GI,{...o}):(0,I.jsx)(YI,{...o})}break;default:return null}return(0,I.jsxs)(I.Fragment,{children:[d,u?.valueString&&(0,I.jsx)(H,{c:`red`,size:`lg`,mt:4,children:u.valueString})]})}function GI(e){let{name:t,item:n,required:r,initial:i,onChangeAnswer:a,response:o,multiselect:s}=e;if(!n.answerOption?.length&&!n.answerValueSet)return(0,I.jsx)(ZI,{});let c=Bk(i),l=QI(o)??c,u=$I(o),d=n.repeats||s;if(n.answerValueSet)return(0,I.jsx)(NN,{name:t,placeholder:`Select items`,binding:n.answerValueSet,maxValues:d?void 0:1,required:r,onChange:e=>{d?e.length===0?a([{}]):a(e.map(e=>({valueCoding:e}))):a([{valueCoding:e[0]}])},defaultValue:l?.value});if(d){let{propertyName:e,data:t}=rL(n);return(0,I.jsx)(Sg,{data:t,placeholder:`Select items`,searchable:!0,defaultValue:u||[ow(c)],required:r,onChange:t=>{t.length===0?a([{}]):a(Dk(t,e,n))}})}else{let e=[``];if(n.answerOption)for(let t of n.answerOption){let n=Vk(t);e.push(ow(n))}return(0,I.jsx)(Eg,{id:t,name:t,required:r,onChange:e=>{let t=e.currentTarget.selectedIndex;if(t===0){a([{}]);return}let r=n.answerOption[t-1],i=Vk(r);a([{[`value`+UC(i.type)]:i.value}])},defaultValue:Cw(l?.value)||l?.value,data:e})}}function KI(e,t){return e?t.valueSetExpand({url:e,count:31}).then(e=>e.expansion?.contains??[]):Promise.resolve([])}function qI(e){let t=Z(),[n,r]=(0,b.useState)([]),[i,a]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{async function n(){if(e){a(!0);try{r(await KI(e,t))}catch(e){console.error(`Error loading value set:`,e)}finally{a(!1)}}}n().catch(console.error)},[e,t]),[n,i]}function JI(e,t){return e.map((e,n)=>[`${t}-valueset-${n}`,{type:`Coding`,value:{system:e.system,code:e.code,display:e.display}}])}function YI(e){let{name:t,item:n,required:r,initial:i,onChangeAnswer:a,response:o}=e,s=Bw(`QuestionnaireItemAnswerOption`,`value[x]`),c=Bk(i),[l,u]=qI(n.answerValueSet),d=[],f;if(n.answerValueSet)d.push(...JI(l,t));else if(n.answerOption){let e=n.answerOption.slice(0,UI).map((e,n)=>{let r=`${t}-option-${n}`,i=Vk(e);return i?.value?(c&&yC(i)===yC(c)&&(f=r),[r,i]):null}).filter(e=>e!==null);d.push(...e)}let p=eL(d,QI(o));if(u)return(0,I.jsx)(H,{children:`Loading options...`});if(d.length===0)return(0,I.jsx)(ZI,{});let m=d.slice(0,HI);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Pv.Group,{name:t,value:p??f,required:r,onChange:e=>{let t=d.find(t=>t[0]===e);if(t){let e=t[1];a([{[`value`+UC(e.type)]:e.value}])}},children:m.map(([e,t])=>(0,I.jsx)(Pv,{id:e,value:e,py:4,required:r,label:(0,I.jsx)(CF,{property:s,propertyType:t.type,value:t.value})},e))}),(n.answerValueSet&&d.length>HI||n.answerOption&&d.length>UI)&&(0,I.jsxs)(H,{size:`sm`,c:`dimmed`,mt:`xs`,children:[`Showing first `,HI,` options`]})]})}function XI(e){let{name:t,item:n,onChangeAnswer:r,response:i}=e,a=Bw(`QuestionnaireItemAnswerOption`,`value[x]`),[o,s]=qI(n.answerValueSet),[c,l]=(0,b.useState)(n.answerValueSet?(i?.answer?.map(e=>e.valueCoding)||[]).filter(e=>e!==void 0):$I(i)),u=[];if(n.answerValueSet)u.push(...JI(o,t));else if(n.answerOption){let e=n.answerOption.slice(0,UI).map((e,n)=>{let r=`${t}-option-${n}`,i=Vk(e);return i?.value?[r,i]:null}).filter(e=>e!==null);u.push(...e)}if(s)return(0,I.jsx)(H,{children:`Loading options...`});if(u.length===0)return(0,I.jsx)(ZI,{});let d=u.slice(0,HI),f=(e,t)=>{if(n.answerValueSet){let n=c,i;i=t?[...n,e.value]:n.filter(t=>!EC(t,e.value)),l(i),i.length===0?r([{}]):r(i.map(e=>({valueCoding:e})))}else{let i=c,a=ow(e),o;o=t?[...i,a]:i.filter(e=>e!==a),l(o),o.length===0?r([{}]):r(Dk(o,`value`+UC(e.type),n))}};return(0,I.jsxs)(V,{style:{flexDirection:`column`,alignItems:`flex-start`},children:[d.map(([e,t])=>{let r=ow(t),i=n.answerValueSet?c.some(e=>EC(e,t.value)):c.includes(r);return(0,I.jsx)(lp,{id:e,label:(0,I.jsx)(CF,{property:a,propertyType:t.type,value:t.value}),checked:i,onChange:e=>f(t,e.currentTarget.checked)},e)}),(n.answerValueSet&&u.length>HI||n.answerOption&&u.length>UI)&&(0,I.jsxs)(H,{size:`sm`,c:`dimmed`,children:[`Showing first `,HI,` options`]})]})}function ZI(){return(0,I.jsx)(yb,{disabled:!0,placeholder:`No Answers Defined`})}function QI(e,t=0){return Vk(e?.answer?.[t]??{})}function $I(e){let t=e?.answer;return t?t.map(e=>Vk(e)).map(e=>Cw(e?.value)||e?.value).filter(Boolean):[]}function eL(e,t){return e.find(e=>EC(e[1].value,t?.value))?.[0]}var tL=[`drop-down`,`radio-button`,`check-box`];function nL(e){let t=`radio-button`,n=!1;e.answerValueSet&&(t=`drop-down`);for(let r of e.extension??[]){if(r.url!==sk)continue;let e=r.valueCodeableConcept?.coding?.[0]?.code;tL.includes(e)&&(t=e),e===`multi-select`&&(n=!0)}return t===`radio-button`&&n&&(t=`check-box`),{widget:t,multiselect:n}}function rL(e){if(e.answerOption?.length===0)return{propertyName:``,data:[]};let t=e.answerOption[0];return{propertyName:`value`+UC(Vk(t).type),data:(e.answerOption??[]).map(e=>{let t=ow(Vk(e));return{value:t,label:t}})}}function iL(e){return(0,I.jsxs)(I.Fragment,{children:[e.responseItems.map(t=>(0,I.jsx)(VI,{formState:e.formState,context:e.context,item:e.item,responseItem:t},`group-${t.id}`)),(0,I.jsx)(Pd,{onClick:()=>e.formState.onAddGroup(e.context,e.item),children:`Add Group: ${e.item.text}`})]})}function aL(e){let{formState:t,context:n,item:r,responseItem:i}=e,a=r.type===ok.choice||r.type===ok.openChoice,o=!a,s=!a&&i.answer&&i.answer.length>0?i.answer:[{}];return(0,I.jsxs)(MF,{title:e.item.text,withAsterisk:e.item.required,children:[(0,I.jsx)(G,{gap:`xs`,children:s?.map((e,a)=>(0,I.jsx)(WI,{formState:t,context:n,item:r,responseItem:i,index:a},`${r.linkId}-${a}`))}),o&&(0,I.jsx)(Pd,{onClick:()=>t.onAddAnswer(n,r),children:`Add Item`})]},e.item.linkId)}function oL(e){let{formState:t,context:n,items:r,responseItems:i}=e,a=n.length===0,o=!1;return(0,I.jsx)(G,{gap:`xl`,children:r.map((e,r)=>{if(!yk(e,t.questionnaireResponse))return null;let s=e.type===ok.group,c=a&&s&&o;if(s&&(o=!0),e.type===ok.display)return(0,I.jsx)(`p`,{children:e.text},`display-${e.id}-${r}`);let l=i.filter(t=>t.linkId===e.linkId);return e.type===ok.group&&e.repeats?(0,I.jsxs)(b.Fragment,{children:[c&&(0,I.jsx)(dm,{color:`var(--mantine-color-gray-2)`}),(0,I.jsx)(iL,{formState:t,context:n,item:e,responseItems:l})]},`repeating-group-${e.id}-${r}`):e.type===ok.group?(0,I.jsxs)(b.Fragment,{children:[c&&(0,I.jsx)(dm,{color:`var(--mantine-color-gray-2)`}),(0,I.jsx)(VI,{formState:t,context:n,item:e,responseItem:l[0]})]},`group-${e.id}-${r}`):e.type===ok.boolean?(0,I.jsx)(WI,{formState:t,context:n,item:e,responseItem:l[0],index:0},`boolean-item-${e.id}-${r}`):e.repeats?(0,I.jsx)(aL,{formState:t,context:n,item:e,responseItem:l[0]},`repeating-item-${e.id}-${r}`):(0,I.jsx)(MF,{htmlFor:e.linkId,title:e.text,withAsterisk:e.required,children:(0,I.jsx)(WI,{formState:t,context:n,item:e,responseItem:l[0],index:0})},`repeating-item-${e.id}-${r}`)})})}function sL(e){let{formState:t,submitButtonText:n,excludeButtons:r,children:i}=e,a=t.pages,o=t.activePage,s=o>0,c=o<a.length-1,l=o===a.length-1;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Iy,{active:o,allowNextStepsSelect:!1,p:6,children:a.map((e,t)=>(0,I.jsx)(Iy.Step,{label:e.title,children:t===o&&i},e.linkId))}),!r&&(0,I.jsxs)(V,{justify:`flex-end`,mt:`xl`,gap:`xs`,children:[s&&(0,I.jsx)(U,{onClick:t.onPrevPage,children:`Back`}),c&&(0,I.jsx)(U,{onClick:e=>{e.currentTarget.closest(`form`).reportValidity()&&t.onNextPage()},children:`Next`}),l&&(0,I.jsx)(EN,{children:n??`Submit`})]})]})}function cL(e){let t=Z(),[n,r]=(0,b.useState)(!1),i=(0,b.useRef)(e),a=(0,b.useRef)(void 0);(0,b.useLayoutEffect)(()=>{i.current=e});let o=(0,b.useCallback)(e=>{a.current=e},[]),s=Wk({questionnaire:e.questionnaire,defaultValue:e.questionnaireResponse,subject:e.subject,encounter:e.encounter,source:e.source,disablePagination:e.disablePagination,onChange:o}),c=(0,b.useRef)(s);(0,b.useLayoutEffect)(()=>{c.current=s}),(0,b.useEffect)(()=>{let e=a.current;e&&(a.current=void 0,r(!1),i.current.onChange?.(e))});let l=(0,b.useMemo)(()=>s.loading?!1:!!vC(s.questionnaire,pk),[s]),u=(0,b.useMemo)(()=>s.loading?!1:!!s.questionnaireResponse.extension?.find(e=>e.url===mk),[s]),d=(0,b.useCallback)(()=>{let e=c.current;if(e.loading)return;let n=i.current.onSubmit;if(!n)return;if(l&&!u){r(!0);return}let a=e.questionnaire,o=e.questionnaireResponse,s=i.current.subject,d=i.current.source;if(!d){let e=t.getProfile();e&&(d=aC(e))}n({...o,questionnaire:a.url??oC(a),subject:s,source:d,authored:new Date().toISOString(),status:`completed`})},[t,l,u]);return s.loading?null:(0,I.jsxs)(TN,{testid:`questionnaire-form`,onSubmit:d,children:[s.questionnaire.title&&(0,I.jsx)(q,{order:1,fz:`1.625rem`,fw:700,lh:1.3,mb:`xl`,children:s.questionnaire.title}),e.afterHeader&&(0,I.jsxs)(G,{gap:`xl`,mb:`xl`,children:[e.afterHeader,(0,I.jsx)(dm,{color:`var(--mantine-color-gray-2)`})]}),s.pagination?(0,I.jsx)(sL,{formState:s,submitButtonText:e.submitButtonText,excludeButtons:e.excludeButtons,children:(0,I.jsx)(oL,{formState:s,context:[],items:s.items,responseItems:s.responseItems})}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(oL,{formState:s,context:[],items:s.items,responseItems:s.responseItems}),l&&(0,I.jsxs)(G,{mt:`md`,gap:0,children:[(0,I.jsx)(H,{size:`sm`,fw:500,children:`Signature`}),(0,I.jsx)(BI,{onChange:s.onChangeSignature}),!u&&n&&(0,I.jsx)(H,{c:`red`,size:`sm`,children:`Signature is required.`})]}),!e.excludeButtons&&(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,gap:`xs`,children:(0,I.jsx)(EN,{children:e.submitButtonText??`Submit`})})]})]})}var lL={draft:`blue`,active:`blue`,"on-hold":`yellow`,revoked:`red`,completed:`green`,"entered-in-error":`red`,unknown:`gray`,retired:`gray`,registered:`blue`,preliminary:`blue`,final:`green`,amended:`yellow`,corrected:`yellow`,cancelled:`red`,requested:`blue`,received:`blue`,accepted:`blue`,rejected:`red`,ready:`blue`,"in-progress":`blue`,failed:`red`,proposed:`blue`,pending:`blue`,booked:`blue`,arrived:`blue`,fulfilled:`green`,noshow:`red`,"checked-in":`blue`,waitlist:`gray`,routine:`gray`,urgent:`red`,asap:`red`,stat:`red`,"not-done":`red`,connected:`green`,disconnected:`red`,finished:`green`,planned:`gray`};function uL(e){let{status:t,...n}=e;return(0,I.jsx)(Mp,{color:e.color||lL[t],...n,children:t.replaceAll(`-`,` `)})}var dL={noteBody:`_noteBody_10swh_1`,noteCite:`_noteCite_10swh_5`,noteRoot:`_noteRoot_10swh_10`};function fL({value:e}){return e?(0,I.jsx)(G,{justify:`flex-start`,gap:`xs`,children:e.map(e=>e.text&&(0,I.jsx)(Ip,{classNames:{cite:dL.noteCite,root:dL.noteRoot},cite:e.authorReference?.display||e.authorString,icon:null,children:e.text},`note-${e.text}`))}):null}function pL(e){let{value:t,link:n,...r}=e,[i,a]=(0,b.useState)(),o=ik(t,a),s;if(i&&!Jx(i))s=`[${Qx(i)}]`;else if(o)s=uC(o);else return null;return n?(0,I.jsx)(Kj,{to:t,...r,children:s}):(0,I.jsx)(H,{component:`span`,...r,children:s})}function mL(e){return(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(Qj,{size:24,radius:12,value:e.value,link:e.link}),(0,I.jsx)(pL,{value:e.value,link:e.link})]})}var hL={table:`_table_pe9td_1`,criticalRow:`_criticalRow_pe9td_12`,noteBody:`_noteBody_pe9td_23`,noteCite:`_noteCite_pe9td_27`,noteRoot:`_noteRoot_pe9td_32`};gL.defaultProps={hideObservationNotes:!1,hideSpecimenInfo:!1,hideSubject:!1};function gL(e){let t=Z(),n=ik(e.value),[r,i]=(0,b.useState)();if((0,b.useEffect)(()=>{n?.specimen&&Promise.allSettled(n.specimen.map(e=>t.readReference(e))).then(e=>e.filter(e=>e.status===`fulfilled`).map(e=>e.value)).then(i).catch(console.error)},[t,n]),!n)return null;let a=r?.flatMap(e=>e.note||[])||[];if(n.presentedForm&&n.presentedForm.length>0){let e=n.presentedForm[0];e.contentType?.startsWith(`text/plain`)&&e.data&&a.push({text:window.atob(e.data)})}return(0,I.jsxs)(G,{children:[(0,I.jsx)(q,{children:`Diagnostic Report`}),(0,I.jsx)(_L,{value:n,hideSubject:e.hideSubject}),r&&!e.hideSpecimenInfo&&vL(r),n.result&&(0,I.jsx)(yL,{hideObservationNotes:e.hideObservationNotes,value:n.result}),a.length>0&&(0,I.jsx)(fL,{value:a}),n.conclusion&&(0,I.jsxs)(G,{mt:`md`,children:[(0,I.jsx)(H,{fw:500,size:`sm`,c:`dimmed`,children:`Conclusion`}),(0,I.jsx)(H,{children:n.conclusion})]})]})}function _L({value:e,hideSubject:t=!1}){return(0,I.jsxs)(V,{mt:`md`,gap:30,children:[e.subject&&!t&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{size:`xs`,tt:`uppercase`,c:`dimmed`,children:`Subject`}),(0,I.jsx)(mL,{value:e.subject,link:!0})]}),e.resultsInterpreter?.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{size:`xs`,tt:`uppercase`,c:`dimmed`,children:`Interpreter`}),(0,I.jsx)(mL,{value:e,link:!0})]},e.reference)),e.performer?.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{size:`xs`,tt:`uppercase`,c:`dimmed`,children:`Performer`}),(0,I.jsx)(mL,{value:e,link:!0})]},e.reference)),e.issued&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{size:`xs`,tt:`uppercase`,c:`dimmed`,children:`Issued`}),(0,I.jsx)(H,{children:fw(e.issued)})]}),e.status&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{size:`xs`,tt:`uppercase`,c:`dimmed`,children:`Status`}),(0,I.jsx)(uL,{status:e.status})]})]})}function vL(e){return(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsx)(q,{order:2,size:`h6`,children:`Specimens`}),(0,I.jsx)(yh,{type:`ordered`,children:e?.map(e=>(0,I.jsx)(yh.Item,{ml:`sm`,children:(0,I.jsxs)(V,{gap:20,children:[(0,I.jsxs)(V,{gap:5,children:[(0,I.jsx)(H,{fw:500,children:`Collected:`}),` `,fw(e.collection?.collectedDateTime)]}),(0,I.jsxs)(V,{gap:5,children:[(0,I.jsx)(H,{fw:500,children:`Received:`}),` `,fw(e.receivedTime)]})]})},`specimen-${e.id}`))})]})}function yL(e){return(0,I.jsxs)(`table`,{className:hL.table,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:`Test`}),(0,I.jsx)(`th`,{children:`Value`}),(0,I.jsx)(`th`,{children:`Reference Range`}),(0,I.jsx)(`th`,{children:`Interpretation`}),(0,I.jsx)(`th`,{children:`Category`}),(0,I.jsx)(`th`,{children:`Performer`}),(0,I.jsx)(`th`,{children:`Status`})]})}),(0,I.jsx)(`tbody`,{children:(0,I.jsx)(bL,{value:e.value,ancestorIds:e.ancestorIds,hideObservationNotes:e.hideObservationNotes})})]})}function bL(e){return(0,I.jsx)(I.Fragment,{children:e.value?.map(t=>(0,I.jsx)(xL,{value:t,ancestorIds:e.ancestorIds,hideObservationNotes:e.hideObservationNotes},`obs-${Uw(t)?t.reference:t.id}`))})}function xL(e){let t=ik(e.value);if(!t||e.ancestorIds?.includes(t.id))return null;let n=!e.hideObservationNotes&&t.note,r=wL(t);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`tr`,{className:Mn({[hL.criticalRow]:r}),children:[(0,I.jsx)(`td`,{rowSpan:n?2:1,children:(0,I.jsx)(Kj,{to:t,children:(0,I.jsx)(rF,{value:t.code})})}),(0,I.jsx)(`td`,{children:(0,I.jsx)(SL,{value:t})}),(0,I.jsx)(`td`,{children:(0,I.jsx)(CL,{value:t.referenceRange})}),(0,I.jsx)(`td`,{children:t.interpretation&&t.interpretation.length>0&&(0,I.jsx)(rF,{value:t.interpretation[0]})}),(0,I.jsx)(`td`,{children:t.category&&t.category.length>0&&(0,I.jsx)(I.Fragment,{children:t.category.map(e=>(0,I.jsx)(`div`,{children:(0,I.jsx)(rF,{value:e})},`category-${Sw(e)}`))})}),(0,I.jsx)(`td`,{children:t.performer?.map(e=>(0,I.jsx)(gF,{value:e},e.reference))}),(0,I.jsx)(`td`,{children:t.status&&(0,I.jsx)(uL,{status:t.status})})]}),t.hasMember&&(0,I.jsx)(bL,{value:t.hasMember,ancestorIds:e.ancestorIds?[...e.ancestorIds,t.id]:[t.id],hideObservationNotes:e.hideObservationNotes}),n&&(0,I.jsx)(`tr`,{children:(0,I.jsx)(`td`,{colSpan:6,children:(0,I.jsx)(fL,{value:t.note})})})]})}function SL(e){let t=e.value;return(0,I.jsx)(I.Fragment,{children:ww(t)})}function CL(e){let t=e.value&&e.value.length>0&&e.value[0];return t?t.text?(0,I.jsx)(I.Fragment,{children:t.text}):(0,I.jsx)(mF,{value:t}):null}function wL(e){let t=e.interpretation?.[0]?.coding?.[0]?.code;return t===`AA`||t===`LL`||t===`HH`||t===`A`}var TL=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Pointer=void 0,e.unescapeToken=t,e.escapeToken=n;function t(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function n(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.Pointer=function(){function e(e){e===void 0&&(e=[``]),this.tokens=e}return e.fromJSON=function(n){var r=n.split(`/`).map(t);if(r[0]!==``)throw Error(`Invalid JSON Pointer: ${n}`);return new e(r)},e.prototype.toString=function(){return this.tokens.map(n).join(`/`)},e.prototype.evaluate=function(e){for(var t=null,n=``,r=e,i=1,a=this.tokens.length;i<a;i++)t=r,n=this.tokens[i],!(n==`__proto__`||n==`constructor`||n==`prototype`)&&(r=(t||{})[n]);return{parent:t,key:n,value:r}},e.prototype.get=function(e){return this.evaluate(e).value},e.prototype.set=function(e,t){var n=this.evaluate(e);n.parent&&(n.parent[n.key]=t)},e.prototype.push=function(e){this.tokens.push(e)},e.prototype.add=function(t){return new e(this.tokens.concat(String(t)))},e.prototype.parent=function(){return new e(this.tokens.length>1?this.tokens.slice(0,-1):[``])},e}()})),EL=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hasOwnProperty=void 0,e.objectType=t,e.clone=r,e.hasOwnProperty=Object.prototype.hasOwnProperty;function t(e){return e===void 0?`undefined`:e===null?`null`:Array.isArray(e)?`array`:typeof e}function n(e){return typeof e==`object`&&!!e}function r(t){if(!n(t))return t;if(t.constructor==Array){for(var i=t.length,a=Array(i),o=0;o<i;o++)a[o]=r(t[o]);return a}if(t.constructor==Date)return new Date(+t);var s={};for(var c in t)e.hasOwnProperty.call(t,c)&&(s[c]=r(t[c]));return s}})),DL=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isDestructive=n,e.subtract=r,e.intersection=i,e.diffArrays=l,e.diffObjects=u,e.diffAny=d;var t=EL();function n(e){var t=e.op;return t===`remove`||t===`replace`||t===`copy`||t===`move`}function r(e,n){var r=[];for(var i in e)t.hasOwnProperty.call(e,i)&&e[i]!==void 0&&!(t.hasOwnProperty.call(n,i)&&n[i]!==void 0)&&r.push(i);return r}function i(e){for(var n=e.length,r={},i=0;i<n;i++){var a=e[i];for(var o in a)t.hasOwnProperty.call(a,o)&&a[o]!==void 0&&(r[o]=(r[o]||0)+1)}for(var o in r)r[o]<n&&delete r[o];return Object.keys(r)}function a(e,n){var r=[];for(var i in e)t.hasOwnProperty.call(e,i)&&e[i]!==void 0&&t.hasOwnProperty.call(n,i)&&n[i]!==void 0&&r.push(i);return r}function o(e){return e.op===`add`}function s(e){return e.op===`remove`}function c(e,t){return{operations:e.operations.concat(t),cost:e.cost+1}}function l(e,t,n,r){r===void 0&&(r=d);var i=Math.max(e.length,t.length),a=new Map([[0,{operations:[],cost:0}]]);function l(o,s){var u=o*i+s,d=a.get(u);if(d===void 0){if(o>0&&s>0&&!r(e[o-1],t[s-1],n.add(String(o-1))).length)d=l(o-1,s-1);else{var f=[];if(o>0){var p=l(o-1,s),m={op:`remove`,index:o-1};f.push(c(p,m))}if(s>0){var h=l(o,s-1),g={op:`add`,index:o-1,value:t[s-1]};f.push(c(h,g))}if(o>0&&s>0){var _=l(o-1,s-1),v={op:`replace`,index:o-1,original:e[o-1],value:t[s-1]};f.push(c(_,v))}d=f.sort(function(e,t){return e.cost-t.cost})[0]}a.set(u,d)}return d}var u=isNaN(e.length)||e.length<=0?0:e.length;return l(u,isNaN(t.length)||t.length<=0?0:t.length).operations.reduce(function(e,t){var i=e[0],a=e[1];if(o(t)){var c=t.index+1+a,l=c<u+a?String(c):`-`,d={op:t.op,path:n.add(l).toString(),value:t.value};return[i.concat(d),a+1]}else if(s(t)){var d={op:t.op,path:n.add(String(t.index+a)).toString()};return[i.concat(d),a-1]}else{var f=n.add(String(t.index+a)),p=r(t.original,t.value,f);return[i.concat.apply(i,p),a]}},[[],0])[0]}function u(e,t,n,i){i===void 0&&(i=d);var o=[];return r(e,t).forEach(function(e){o.push({op:`remove`,path:n.add(e).toString()})}),r(t,e).forEach(function(e){o.push({op:`add`,path:n.add(e).toString(),value:t[e]})}),a(e,t).forEach(function(r){o.push.apply(o,i(e[r],t[r],n.add(r)))}),o}function d(e,n,r,i){if(i===void 0&&(i=d),e===n)return[];var a=(0,t.objectType)(e),o=(0,t.objectType)(n);return a==`array`&&o==`array`?l(e,n,r,i):a==`object`&&o==`object`?u(e,n,r,i):[{op:`replace`,path:r.toString(),value:n}]}})),OL=o((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidOperationError=e.TestError=e.MissingError=void 0,e.add=l,e.remove=u,e.replace=d,e.move=f,e.copy=p,e.test=m,e.apply=g;var n=TL(),r=EL(),i=DL(),a=function(e){t(n,e);function n(t){var n=e.call(this,`Value required at path: ${t}`)||this;return n.path=t,n.name=`MissingError`,n}return n}(Error);e.MissingError=a;var o=function(e){t(n,e);function n(t,n){var r=e.call(this,`Test failed: ${t} != ${n}`)||this;return r.actual=t,r.expected=n,r.name=`TestError`,r}return n}(Error);e.TestError=o;function s(e,t,n){if(Array.isArray(e))if(t==`-`)e.push(n);else{var r=parseInt(t,10);e.splice(r,0,n)}else e[t]=n}function c(e,t){if(Array.isArray(e)){var n=parseInt(t,10);e.splice(n,1)}else delete e[t]}function l(e,t,i){var o=n.Pointer.fromJSON(t.path);if(i?.implicitArrayCreation&&o.tokens[o.tokens.length-1]===`-`){var c=o.parent().evaluate(e);c.value===void 0&&(0,r.objectType)(c.parent)===`object`&&(c.parent[c.key]=[])}var l=o.evaluate(e);return l.parent===void 0||i?.implicitArrayCreation&&l.key===`-`&&!Array.isArray(l.parent)?new a(t.path):(s(l.parent,l.key,(0,r.clone)(t.value)),null)}function u(e,t,r){var i=n.Pointer.fromJSON(t.path).evaluate(e);return i.value===void 0?new a(t.path):(c(i.parent,i.key),null)}function d(e,t,i){var o=n.Pointer.fromJSON(t.path).evaluate(e);if(o.parent===null)return new a(t.path);if(Array.isArray(o.parent)){if(parseInt(o.key,10)>=o.parent.length)return new a(t.path)}else if(o.value===void 0)return new a(t.path);return o.parent[o.key]=(0,r.clone)(t.value),null}function f(e,t,r){var i=n.Pointer.fromJSON(t.from).evaluate(e);if(i.value===void 0)return new a(t.from);var o=n.Pointer.fromJSON(t.path).evaluate(e);return o.parent===void 0?new a(t.path):(c(i.parent,i.key),s(o.parent,o.key,i.value),null)}function p(e,t,i){var o=n.Pointer.fromJSON(t.from).evaluate(e);if(o.value===void 0)return new a(t.from);var c=n.Pointer.fromJSON(t.path).evaluate(e);return c.parent===void 0?new a(t.path):(s(c.parent,c.key,(0,r.clone)(o.value)),null)}function m(e,t,r){var a=n.Pointer.fromJSON(t.path).evaluate(e);return(0,i.diffAny)(a.value,t.value,new n.Pointer).length?new o(a.value,t.value):null}var h=function(e){t(n,e);function n(t){var n=e.call(this,`Invalid operation: ${t.op}`)||this;return n.operation=t,n.name=`InvalidOperationError`,n}return n}(Error);e.InvalidOperationError=h;function g(e,t,n){switch(t.op){case`add`:return l(e,t,n);case`remove`:return u(e,t,n);case`replace`:return d(e,t,n);case`move`:return f(e,t,n);case`copy`:return p(e,t,n);case`test`:return m(e,t,n)}return new h(t)}})),kL=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Pointer=void 0,e.createPatch=i;var t=TL();Object.defineProperty(e,"Pointer",{enumerable:!0,get:function(){return t.Pointer}}),OL();var n=DL();function r(e){function t(r,i,a){var o=e(r,i,a);return Array.isArray(o)?o:(0,n.diffAny)(r,i,a,t)}return t}function i(e,i,a){var o=new t.Pointer;return(a?r(a):n.diffAny)(e,i,o)}})),AL={removed:`_removed_el5zk_1`,added:`_added_el5zk_6`};function jL(e){let{name:t,path:n,property:r,originalValue:i,revisedValue:a}=e,o=!!r?.type?.find(e=>e.code===`Attachment`),[s,c]=(0,b.useState)(o);return(0,I.jsx)(I.Fragment,{children:o&&!s||!o?(0,I.jsx)(I.Fragment,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:t}),(0,I.jsx)(K.Td,{className:AL.removed,children:i&&(0,I.jsx)(CF,{path:n,property:r,propertyType:i.type,value:i.value,ignoreMissingValues:!0})}),(0,I.jsx)(K.Td,{className:AL.added,children:a&&(0,I.jsx)(CF,{path:n,property:r,propertyType:a.type,value:a.value,ignoreMissingValues:!0})})]})}):(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:t}),(0,I.jsx)(K.Td,{colSpan:2,style:{textAlign:`right`},children:(0,I.jsx)(U,{onClick:()=>c(e=>!e),variant:`light`,children:`Expand`})})]})})}var ML={root:`_root_15xvr_1`,removed:`_removed_15xvr_20`,added:`_added_15xvr_25`},NL=kL();function PL(e){let t=Z(),{original:n,revised:r}=e,[i,a]=(0,b.useState)(!1);(0,b.useEffect)(()=>{t.requestSchema(e.original.resourceType).then(()=>a(!0)).catch(console.log)},[t,e.original.resourceType]);let o=(0,b.useMemo)(()=>{if(!i)return null;let e=[jS(n)],t=[jS(r)],a=[],o=FL((0,NL.createPatch)(n,r));for(let r of o){let i=r.path,o=IL(i),s=LL(n.resourceType,o),c=r.op===`add`?void 0:RT(o,e),l=r.op===`remove`?void 0:RT(o,t);a.push({key:`op-${r.op}-${r.path}`,name:`${UC(r.op)} ${o}`,path:s?.path??n.resourceType+`.`+o,property:s,originalValue:RL(s,c),revisedValue:RL(s,l)})}return a},[i,n,r]);return o?(0,I.jsxs)(K,{className:ML.root,children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{}),(0,I.jsx)(K.Th,{children:`Before`}),(0,I.jsx)(K.Th,{children:`After`})]})}),(0,I.jsx)(K.Tbody,{children:o.map(e=>{let{key:t,...n}=e;return(0,I.jsx)(jL,{...n},t)})})]}):null}function FL(e){let t=[];for(let n of e){let{op:r,path:i}=n;if(i.startsWith(`/meta/author`)||i.startsWith(`/meta/compartment`)||i.startsWith(`/meta/lastUpdated`)||i.startsWith(`/meta/versionId`))continue;let a=e.filter(e=>e.op===r&&e.path===i).length,o={op:r,path:i};a>1&&(r===`add`||r===`remove`)&&/\/[0-9-]+$/.test(i)&&(o.op=`replace`,o.path=i.replace(/\/[^/]+$/,``)),t.some(e=>e.op===o.op&&e.path===o.path)||t.push(o)}return t}function IL(e){let t=e.split(`/`).filter(Boolean),n=``;for(let e=0;e<t.length;e++){let r=t[e];r===`-`?n+=`.last()`:/^\d+$/.test(r)?n+=`[${r}]`:(e>0&&(n+=`.`),n+=r)}return n.endsWith(`.url`)&&(n=n.replace(/\.url$/,``)),n}function LL(e,t){try{return kO(e,{resourceType:`SearchParameter`,base:[e],code:e+`.`+t,expression:e+`.`+t})?.elementDefinitions?.[0]}catch(n){console.warn(`Failed to get element definition`,{resourceType:e,fhirPath:t,err:n});return}}function RL(e,t){return t&&{type:Array.isArray(t)?t[0].type:t.type,value:zL(t,!!e?.isArray)}}function zL(e,t){let n=Dx(e).flatMap(e=>e.value);return t?n:n[0]}function BL(e){let{profileUrl:t}=e,n=Z(),r=n.getAccessPolicy(),i=ik(e.value),[a,o]=(0,b.useState)(!1);(0,b.useEffect)(()=>{if(i)if(t)n.requestProfileSchema(t,{expandProfile:!0}).then(()=>{gS(t)?o(!0):console.error(`Schema not found for ${t}`)}).catch(e=>{console.error(`Error in requestProfileSchema`,e)});else{let e=i.resourceType;n.requestSchema(e).then(()=>{o(!0)}).catch(console.error)}},[n,t,i]);let s=(0,b.useMemo)(()=>i&&ME(i,OE.READ,r),[r,i]);return!a||!i?null:(0,I.jsx)(DF,{path:i.resourceType,value:{type:i.resourceType,value:e.forceUseInput?e.value:i},profileUrl:t,ignoreMissingValues:e.ignoreMissingValues,accessPolicyResource:s})}var VL={item:`_item_5q6yx_1`,itemPadding:`_itemPadding_5q6yx_5`};function HL(e){return(0,I.jsx)(_P,{children:e.children})}function UL(e){let{resource:t,profile:n,padding:r,popupMenuItems:i,...a}=e,o=n??t.meta?.author,s=t.meta?.onBehalfOf,c=e.dateTime??t.meta?.lastUpdated;return(0,I.jsxs)(yP,{"data-testid":`timeline-item`,fill:!0,...a,children:[(0,I.jsxs)(V,{justify:`space-between`,gap:8,mx:`xs`,my:`sm`,children:[(0,I.jsx)(Qj,{value:o,link:!0,size:`md`}),(0,I.jsxs)(`div`,{style:{flex:1},children:[(0,I.jsxs)(H,{size:`sm`,children:[(0,I.jsx)(pL,{c:`inherit`,fw:500,value:o,link:!0}),s&&(0,I.jsxs)(H,{component:`span`,size:`xs`,c:`dimmed`,children:[` on behalf of `,(0,I.jsx)(pL,{c:`inherit`,value:s,link:!0})]})]}),(0,I.jsxs)(H,{size:`xs`,children:[(0,I.jsx)(Kj,{c:`dimmed`,to:e.resource,children:fw(c)}),(0,I.jsx)(H,{component:`span`,c:`dimmed`,mx:8,children:`·`}),(0,I.jsx)(Kj,{c:`dimmed`,to:e.resource,children:e.resource.resourceType})]})]}),i&&(0,I.jsxs)(W,{position:`bottom-end`,shadow:`md`,width:200,children:[(0,I.jsx)(W.Target,{children:(0,I.jsx)(gu,{color:`gray`,variant:`subtle`,radius:`xl`,"aria-label":`Actions for ${oC(e.resource)}`,children:(0,I.jsx)(zA,{})})}),i]})]}),(0,I.jsx)(Lj,{children:(0,I.jsx)(`div`,{className:Mn(VL.item,{[VL.itemPadding]:r}),children:e.children})})]})}function WL(e,t){e.sort((e,n)=>{let r=GL(e,t),i=GL(n,t);return r>i?1:r<i?-1:KL(e,t)-KL(n,t)})}function GL(e,t){if(!qL(e,t)){let t=e.priority;if(typeof t==`string`)return{stat:4,asap:3,urgent:2}[t]??0}return 0}function KL(e,t){if(!qL(e,t)){if(e.resourceType===`Communication`&&e.sent)return new Date(e.sent).getTime();if((e.resourceType===`DiagnosticReport`||e.resourceType===`Media`||e.resourceType===`Observation`)&&e.issued)return new Date(e.issued).getTime();if(e.resourceType===`DocumentReference`&&e.date)return new Date(e.date).getTime()}let n=e.meta?.lastUpdated;return n?new Date(n).getTime():0}function qL(e,t){return!!t&&e.resourceType===t.resourceType&&e.id===t.id}var JL={pinnedComment:`_pinnedComment_u08s5_1`};function YL(e){let t=Z(),n=t.getProfile(),r=(0,b.useRef)(null),i=ik(e.value),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)([]),[l,u]=(0,b.useState)(10),d=e.loadTimelineResources,f=(0,b.useRef)(s);(0,b.useLayoutEffect)(()=>{f.current=s});let p=(0,b.useCallback)(e=>{WL(e,i),e.reverse(),c(e)},[i]),m=(0,b.useCallback)(e=>{let t=[];for(let n of e){if(n.status!==`fulfilled`)continue;let e=n.value;if(e.type===`history`&&o(e),e.entry)for(let n of e.entry)t.push(n.resource)}p(t)},[p]),h=(0,b.useCallback)(e=>p([...f.current,e]),[p]),g=(0,b.useCallback)(()=>{let n,r;`resourceType`in e.value?(n=e.value.resourceType,r=e.value.id):[n,r]=e.value.reference?.split(`/`),d(t,n,r).then(m).catch(console.error)},[t,e.value,d,m]);(0,b.useEffect)(()=>g(),[g]);function _(r){!i||!e.createCommunication||t.createResource(e.createCommunication(i,n,r)).then(e=>h(e)).catch(console.error)}function v(r){!i||!e.createMedia||t.createResource(e.createMedia(i,n,r)).then(e=>h(e)).then(()=>Ib({id:`upload-notification`,color:`teal`,title:`Upload complete`,message:``,icon:(0,I.jsx)(EA,{size:16}),autoClose:2e3})).catch(e=>Ib({id:`upload-notification`,color:`red`,title:`Upload error`,message:Qx(e),icon:(0,I.jsx)(GA,{size:16}),autoClose:2e3}))}function y(){J({id:`upload-notification`,loading:!0,title:`Initializing upload...`,message:`Please wait...`,autoClose:!1,withCloseButton:!1})}function x(e){Ib({id:`upload-notification`,loading:!0,title:`Uploading...`,message:nR(e),autoClose:!1,withCloseButton:!1})}function S(e){Ib({id:`upload-notification`,color:`red`,title:`Upload error`,message:Qx(e),icon:(0,I.jsx)(GA,{size:16}),autoClose:2e3})}if(!i)return(0,I.jsx)(Kp,{style:{width:`100%`,height:`100%`},children:(0,I.jsx)(cu,{})});let C=s.filter(e=>e).slice(0,l);return(0,I.jsxs)(HL,{children:[e.createCommunication&&(0,I.jsx)(yP,{children:(0,I.jsx)(TN,{testid:`timeline-form`,onSubmit:e=>{_(e.text);let t=r.current;t&&(t.value=``,t.focus())},children:(0,I.jsxs)(V,{gap:`xs`,wrap:`nowrap`,style:{width:`100%`},children:[(0,I.jsx)(Qj,{value:n}),(0,I.jsx)(yb,{name:`text`,ref:r,placeholder:`Add comment`,style:{width:`100%`,maxWidth:300}}),(0,I.jsx)(gu,{type:`submit`,radius:`xl`,color:`blue`,variant:`filled`,children:(0,I.jsx)(ij,{size:16})}),(0,I.jsx)(pP,{securityContext:aC(i),onUpload:v,onUploadStart:y,onUploadProgress:x,onUploadError:S,children:e=>(0,I.jsx)(gu,{...e,radius:`xl`,color:`blue`,variant:`filled`,children:(0,I.jsx)(MA,{size:16})})})]})})}),C.map(t=>{let n=`${t.resourceType}/${t.id}/${t.meta?.versionId}`,r=e.getMenu?e.getMenu({primaryResource:i,currentResource:t,reloadTimeline:g}):void 0;if(t.resourceType===i.resourceType&&t.id===i.id)return(0,I.jsx)(XL,{history:a,resource:t,popupMenuItems:r},n);switch(t.resourceType){case`AuditEvent`:return(0,I.jsx)(eR,{resource:t,popupMenuItems:r},n);case`Communication`:return(0,I.jsx)(QL,{resource:t,popupMenuItems:r},n);case`DiagnosticReport`:return(0,I.jsx)(tR,{resource:t,popupMenuItems:r},n);case`Media`:return(0,I.jsx)($L,{resource:t,popupMenuItems:r},n);default:return(0,I.jsx)(UL,{resource:t,padding:!0,children:(0,I.jsx)(BL,{value:t,ignoreMissingValues:!0})},n)}}),l<s.length&&(0,I.jsx)(V,{justify:`center`,pb:`lg`,children:(0,I.jsx)(U,{onClick:()=>u(l+10),children:`Show More`})})]})}function XL(e){let{history:t,resource:n,...r}=e,i=ZL(t,n);return i?(0,I.jsx)(UL,{resource:n,padding:!0,...r,children:(0,I.jsx)(PL,{original:i,revised:e.resource})}):(0,I.jsxs)(UL,{resource:n,padding:!0,...r,children:[(0,I.jsx)(`h3`,{children:`Created`}),(0,I.jsx)(BL,{value:n,ignoreMissingValues:!0,forceUseInput:!0})]})}function ZL(e,t){let n=e.entry??[],r=n.findIndex(e=>e.resource?.meta?.versionId===t.meta?.versionId);if(!(r>=n.length-1))return n[r+1].resource}function QL(e){let t=!e.resource.priority||e.resource.priority===`routine`?void 0:JL.pinnedComment;return(0,I.jsx)(UL,{resource:e.resource,profile:e.resource.sender,dateTime:e.resource.sent,padding:!0,className:t,popupMenuItems:e.popupMenuItems,children:(0,I.jsx)(`p`,{children:e.resource.payload?.[0]?.contentString})})}function $L(e){let t=e.resource.content?.contentType,n=t&&!t.startsWith(`image/`)&&!t.startsWith(`video/`)&&t!==`application/pdf`;return(0,I.jsx)(UL,{resource:e.resource,padding:!!n,popupMenuItems:e.popupMenuItems,children:(0,I.jsx)(sP,{value:e.resource.content})})}function eR(e){return(0,I.jsx)(UL,{resource:e.resource,padding:!0,popupMenuItems:e.popupMenuItems,children:(0,I.jsx)(ul,{children:(0,I.jsx)(`pre`,{children:e.resource.outcomeDesc})})})}function tR(e){return(0,I.jsx)(UL,{resource:e.resource,padding:!0,popupMenuItems:e.popupMenuItems,children:(0,I.jsx)(gL,{value:e.resource})})}function nR(e){if(e.lengthComputable){let t=100*e.loaded/e.total;return`Uploaded: ${rR(e.loaded)} / ${rR(e.total)} ${t.toFixed(2)}%`}return`Uploaded: ${rR(e.loaded)}`}function rR(e){if(e===0)return`0.00 B`;let t=Math.floor(Math.log(e)/Math.log(1024));return(e/1024**t).toFixed(2)+` `+` KMGTP`.charAt(t)+`B`}function iR(e){let{resource:t,...n}=e;return(0,I.jsx)(YL,{value:t,loadTimelineResources:async(e,t,n)=>{let r=`${t}/${n}`;return Promise.allSettled([e.readHistory(t,n),e.search(`Task`,{_filter:`based-on eq ${r} or focus eq ${r} or subject eq ${r}`,_count:100})])},...n})}function aR(e){let{encounter:t,...n}=e;return(0,I.jsx)(YL,{value:t,loadTimelineResources:async(e,t,n)=>Promise.allSettled([e.readHistory(`Encounter`,n),e.search(`Communication`,`encounter=Encounter/`+n),e.search(`Media`,`encounter=Encounter/`+n)]),createCommunication:(e,t,n)=>({resourceType:`Communication`,status:`completed`,encounter:aC(e),subject:e.subject,sender:aC(t),sent:new Date().toISOString(),payload:[{contentString:n}]}),createMedia:(e,t,n)=>({resourceType:`Media`,status:`completed`,encounter:aC(e),subject:e.subject,operator:aC(t),issued:new Date().toISOString(),content:n}),...n})}function oR(e){let t;try{t=LT(e.path,e.resource)}catch(e){return console.warn(`FhirPathDisplay:`,e),null}if(t.length>1)throw Error(`Component "path" for "FhirPathDisplay" must resolve to a single element. \
205
205
  Received ${t.length} elements \
206
- [${JSON.stringify(t,null,2)}]`);return(0,I.jsx)(xF,{value:t[0]||``,propertyType:e.propertyType})}function aR(e){return(0,I.jsxs)(rg,{title:`Export`,closeButtonProps:{"aria-label":`Close`},opened:e.visible,onClose:e.onCancel,children:[(0,I.jsxs)(z,{display:`flex`,style:{justifyContent:`space-between`},children:[e.exportCsv&&(0,I.jsx)(oR,{text:`CSV`,exportLogic:e.exportCsv,onCancel:e.onCancel}),e.exportTransactionBundle&&(0,I.jsx)(oR,{text:`Transaction Bundle`,exportLogic:e.exportTransactionBundle,onCancel:e.onCancel})]}),(0,I.jsx)(H,{style:{marginTop:`10px`,marginLeft:`2px`},children:`Limited to 1000 records`})]})}function oR(e){return(0,I.jsx)(U,{onClick:()=>{e.exportLogic(),e.onCancel()},children:`Export as ${e.text}`})}var sR={string:[X.EQUALS,X.NOT,X.CONTAINS,X.EXACT],fulltext:[X.EQUALS,X.NOT,X.CONTAINS,X.EXACT],token:[X.EQUALS,X.NOT,X.TEXT],reference:[X.EQUALS,X.NOT],numeric:[X.EQUALS,X.NOT_EQUALS,X.GREATER_THAN,X.LESS_THAN,X.GREATER_THAN_OR_EQUALS,X.LESS_THAN_OR_EQUALS],quantity:[X.EQUALS,X.NOT_EQUALS,X.GREATER_THAN,X.LESS_THAN,X.GREATER_THAN_OR_EQUALS,X.LESS_THAN_OR_EQUALS],date:[X.EQUALS,X.NOT_EQUALS,X.GREATER_THAN,X.LESS_THAN,X.GREATER_THAN_OR_EQUALS,X.LESS_THAN_OR_EQUALS,X.STARTS_AFTER,X.ENDS_BEFORE,X.APPROXIMATELY],datetime:[X.EQUALS,X.NOT_EQUALS,X.GREATER_THAN,X.LESS_THAN,X.GREATER_THAN_OR_EQUALS,X.LESS_THAN_OR_EQUALS,X.STARTS_AFTER,X.ENDS_BEFORE,X.APPROXIMATELY],uri:[X.EQUALS,X.NOT,X.ABOVE,X.BELOW]},cR={eq:`equals`,ne:`not equals`,gt:`greater than`,lt:`less than`,ge:`greater than or equals`,le:`less than or equals`,sa:`starts after`,eb:`ends before`,ap:`approximately`,sw:`starts with`,contains:`contains`,exact:`exact`,text:`text`,not:`not`,above:`above`,below:`below`,in:`in`,"not-in":`not in`,"of-type":`of type`,missing:`missing`,present:`present`,identifier:`identifier`,iterate:`iterate`};function lR(e,t){return{...e,filters:t,offset:0,name:void 0}}function uR(e,t){return lR(e,(e.filters??[]).filter(e=>e.code!==t))}function dR(e,t,n,r,i){i&&(e=uR(e,t));let a=[];return e.filters&&a.push(...e.filters),a.push({code:t,operator:n,value:r??``}),lR(e,a)}function fR(e,t){if(!e.filters)return e;let n=[...e.filters];return n.splice(t,1),{...e,filters:n,name:void 0}}function pR(e,t){return gR(e,t,-1)}function mR(e,t){return gR(e,t,0)}function hR(e,t){return gR(e,t,1)}function gR(e,t,n){let r=new Date;r.setDate(r.getDate()+n),r.setHours(0,0,0,0);let i=new Date(r.getTime());return i.setDate(i.getDate()+1),i.setTime(i.getTime()-1),CR(e,t,r,i)}function _R(e,t){let n=new Date;return CR(e,t,n,new Date(n.getTime()+1440*60*1e3))}function vR(e,t){return xR(e,t,-1)}function yR(e,t){return xR(e,t,0)}function bR(e,t){return xR(e,t,1)}function xR(e,t,n){let r=new Date;r.setMonth(r.getMonth()+n),r.setDate(1),r.setHours(0,0,0,0);let i=new Date(r.getTime());return i.setMonth(i.getMonth()+1),i.setDate(1),i.setHours(0,0,0,0),i.setTime(i.getTime()-1),CR(e,t,r,i)}function SR(e,t){let n=new Date;return n.setMonth(0),n.setDate(1),n.setHours(0,0,0,0),CR(e,t,n,new Date)}function CR(e,t,n,r){return e=uR(e,t),e=wR(e,t,X.GREATER_THAN_OR_EQUALS,n),e=wR(e,t,X.LESS_THAN_OR_EQUALS,r),e}function wR(e,t,n,r){return dR(e,t,n,r.toISOString())}function TR(e,t,n=!0){return dR(e,t,X.MISSING,n.toString())}function ER(e,t){return e.offset===t?e:{...e,offset:t,name:void 0}}function DR(e,t){let n=e.count??20;return ER(e,(t-1)*n)}function OR(e,t,n){return t===kR(e)&&n!==void 0&&n===AR(e)?e:{...e,sortRules:[{code:t,descending:!!n}],name:void 0}}function kR(e){let t=e.sortRules;if(!t||t.length===0)return;let n=t[0].code;return n.startsWith(`-`)?n.substr(1):n}function AR(e){let t=e.sortRules;return!t||t.length===0?!1:!!t[0].descending}function jR(e){return sR[e.type]}function MR(e){return cR[e]??``}function NR(e){let t=e;return t.includes(`.`)&&(t=t.split(`.`).pop()),t===`versionId`?`Version ID`:(t=t.replace(`[x]`,``),t=t.replaceAll(/([A-Z])/g,` $1`),t=t.replaceAll(/[-_]/g,` `),t=t.replaceAll(/\s+/g,` `),t=t.trim(),t.toLowerCase()===`id`?`ID`:t.split(/\s/).map(UC).join(` `))}function PR(e,t){let n=t.name;return n===`id`?(0,I.jsx)(Wj,{to:`/${e.resourceType}/${e.id}`,children:e.id}):n===`meta.versionId`?e.meta?.versionId:n===`_lastUpdated`?fw(e.meta?.lastUpdated):`${e.resourceType}.${t.name}`===t.elementDefinition?.path?FR(e,t.elementDefinition):t.searchParams?.length===1&&t.name===t.searchParams[0].code?IR(e,t.searchParams[0]):null}function FR(e,t){let n=t.path?.split(`.`)?.pop()?.replaceAll(`[x]`,``)??``,[r,i]=aF({type:e.resourceType,value:e},n);return r?(0,I.jsx)(xF,{path:t.path,property:t,propertyType:i,value:r,maxWidth:200,ignoreMissingValues:!0,link:!1}):null}function IR(e,t){let n=RT(t.expression,[{type:e.resourceType,value:e}]);return!n||n.length===0?null:(0,I.jsx)(I.Fragment,{children:n.map((e,t)=>(0,I.jsx)(xF,{propertyType:e.type,value:e.value,maxWidth:200,ignoreMissingValues:!0,link:!1},`${t}-${n.length}`))})}function LR(e){let t=(0,b.useRef)(!1),[n,r]=(0,b.useState)({search:JSON.parse(yC(e.search))}),[i,a]=(0,b.useState)(!1);(0,b.useEffect)(()=>{r({search:e.search})},[e.search]);let o=(0,b.useMemo)(()=>{if(!e.visible)return[];let t=e.search.resourceType;return ZC(RR(mS(t),Pw(t))).map(e=>({value:e,label:NR(e)}))},[e.visible,e.search.resourceType]);function s(e){r({search:{...n.search,fields:e}})}return(0,I.jsx)(rg,{title:`Fields`,closeButtonProps:{"aria-label":`Close`},opened:e.visible,onClose:()=>{e.onCancel()},size:`auto`,withOverlay:!0,closeOnClickOutside:!1,overlayProps:{onMouseDownCapture:()=>{t.current=i},onClick:()=>{t.current||e.onCancel(),t.current=!1},children:(0,I.jsx)(`div`,{"data-testid":`overlay-child`})},children:(0,I.jsxs)(G,{children:[(0,I.jsx)(Sg,{style:{width:550},placeholder:`Select fields to display`,data:o,value:n.search.fields??[],onChange:s,onDropdownOpen:()=>a(!0),onDropdownClose:()=>a(!1),maxDropdownHeight:`250px`,clearButtonProps:{"aria-label":`Clear selection`},clearable:!0,searchable:!0}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(U,{onClick:()=>e.onOk(n.search),children:`OK`})})]})})}function RR(e,t){let n=[],r=new Set,i=new Set;for(let t of Object.keys(e.elements))n.push(t),r.add(t.toLowerCase()),i.add(NR(t));if(t)for(let e of Object.keys(t)){let t=NR(e);!r.has(e)&&!i.has(t)&&(n.push(e),r.add(e),i.add(t))}return n}function zR(e){let t=DO(e.resourceType,e.searchParam),n=e.name??`filter-value`;switch(t.type){case EO.REFERENCE:return(0,I.jsx)(cI,{name:n,defaultValue:e.defaultValue?{reference:e.defaultValue}:void 0,targetTypes:e.searchParam.target,autoFocus:e.autoFocus,onChange:t=>{t?e.onChange(t.reference):e.onChange(``)}});case EO.BOOLEAN:return(0,I.jsx)(lp,{name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultChecked:e.defaultValue===`true`,autoFocus:e.autoFocus,onChange:t=>e.onChange(t.currentTarget.checked.toString())});case EO.DATE:return(0,I.jsx)(yb,{type:`date`,name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:t=>e.onChange(t.currentTarget.value)});case EO.DATETIME:return(0,I.jsx)(UF,{name:n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:e.onChange});case EO.NUMBER:return(0,I.jsx)(yb,{type:`number`,name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:t=>e.onChange(t.currentTarget.value)});case EO.QUANTITY:return(0,I.jsx)(ZF,{name:n,path:``,defaultValue:BR(e.defaultValue),autoFocus:e.autoFocus,onChange:t=>{t?e.onChange(`${t.value}`):e.onChange(``)}});default:return(0,I.jsx)(yb,{name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:t=>e.onChange(t.currentTarget.value),placeholder:`Search value`})}}function BR(e){if(e){let[t,n,r]=e.split(`|`);if(t)return{value:Number.parseFloat(t),system:n,unit:r}}}function VR(e){let[t,n]=(0,b.useState)(MC(e.search)),r=(0,b.useRef)(t);(0,b.useLayoutEffect)(()=>{r.current=t}),(0,b.useEffect)(()=>{n(MC(e.search))},[e.search]);function i(e){n(dR(r.current,e.code,e.operator,e.value))}let a=e.search.resourceType,o=Pw(a)??{},s=t.filters||[];return(0,I.jsx)(rg,{title:`Filters`,closeButtonProps:{"aria-label":`Close`},size:900,opened:e.visible,onClose:e.onCancel,children:(0,I.jsxs)(CN,{onSubmit:()=>e.onOk(r.current),children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`table`,{children:[(0,I.jsxs)(`colgroup`,{children:[(0,I.jsx)(`col`,{style:{width:200}}),(0,I.jsx)(`col`,{style:{width:200}}),(0,I.jsx)(`col`,{style:{width:380}}),(0,I.jsx)(`col`,{style:{width:40}})]}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:`Field`}),(0,I.jsx)(`th`,{children:`Operation`}),(0,I.jsx)(`th`,{children:`Value`}),(0,I.jsx)(`th`,{})]})}),(0,I.jsx)(`tbody`,{children:s.map((e,t)=>(0,I.jsx)(HR,{id:`filter-${t}-row`,resourceType:a,searchParams:o,value:e,onChange:e=>{let i=[...s];i[t]=e,n(lR(r.current,i))},onDelete:()=>n(fR(r.current,t))},`filter-${t}-row`))})]}),(0,I.jsx)(hI,{propertyDisplayName:`Filter`,onClick:()=>i({})})]}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,children:(0,I.jsx)(wN,{children:`OK`})})]})})}function HR(e){let t=e.value;function n(t){e.onChange({code:t,operator:X.EQUALS,value:``})}function r(n){e.onChange({code:t.code,operator:n,value:``})}function i(n){e.onChange({code:t.code,operator:t.operator,value:n})}let a=e.searchParams[t.code],o=a&&jR(a);return(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:(0,I.jsx)(Eg,{"data-testid":`${e.id}-filter-field`,defaultValue:e.value.code,onChange:e=>n(e.currentTarget.value),data:[``,...Object.keys(e.searchParams).map(e=>({value:e,label:NR(e)}))]})}),(0,I.jsx)(`td`,{children:o&&(0,I.jsx)(Eg,{"data-testid":`${e.id}-filter-operation`,defaultValue:t.operator,onChange:e=>r(e.currentTarget.value),data:[``,...o.map(e=>({value:e,label:MR(e)}))]},`${e.id}-filter-value-${e.value.code}`)}),(0,I.jsx)(`td`,{children:a&&t.operator&&(0,I.jsx)(zR,{name:`${e.id}-filter-value`,resourceType:e.resourceType,searchParam:a,defaultValue:t.value,onChange:i},`${e.id}-filter-value-${e.value.code}-${e.value.operator}`)}),(0,I.jsx)(`td`,{children:e.onDelete&&(0,I.jsx)(gu,{variant:`outline`,color:`red`,radius:`xl`,"aria-label":`Delete filter`,onClick:e.onDelete,children:(0,I.jsx)(Nj,{style:{width:`70%`,height:`70%`},stroke:1.5})})})]})}function UR(e){let[t,n]=(0,b.useState)(e.defaultValue??``);if(!e.searchParam||!e.filter)return null;function r(){e.onOk({...e.filter,value:t})}return(0,I.jsx)(rg,{title:e.title,size:`xl`,opened:e.visible,onClose:e.onCancel,children:(0,I.jsx)(CN,{onSubmit:r,children:(0,I.jsxs)(Tm,{children:[(0,I.jsx)(Tm.Col,{span:10,children:(0,I.jsx)(zR,{resourceType:e.resourceType,searchParam:e.searchParam,defaultValue:t,autoFocus:!0,onChange:n})}),(0,I.jsx)(Tm.Col,{span:2,children:(0,I.jsx)(U,{onClick:r,fullWidth:!0,children:`OK`})})]})})})}function WR(e){let{resourceType:t,filter:n}=e,r=Ww.types[t].searchParams?.[n.code];if(r){if(r.type===`reference`&&(n.operator===X.EQUALS||n.operator===X.NOT_EQUALS))return(0,I.jsx)(dL,{value:{reference:n.value}});let e=DO(t,r);if(n.code===`_lastUpdated`||e.type===EO.DATETIME)return(0,I.jsx)(I.Fragment,{children:fw(n.value)})}return(0,I.jsx)(I.Fragment,{children:n.value})}function GR(e){if(!e.searchParams)return null;function t(t,n){i(OR(e.search,t.code,n))}function n(t){i(uR(e.search,t.code))}function r(t,n){e.onPrompt(t,{code:t.code,operator:n,value:``})}function i(t){e.onChange(t)}return e.searchParams.length===1?(0,I.jsx)(KR,{search:e.search,searchParam:e.searchParams[0],onSort:t,onPrompt:r,onChange:i,onClear:n}):(0,I.jsx)(W.Dropdown,{children:e.searchParams.map(e=>(0,I.jsx)(W.Item,{children:NR(e.code)},e.code))})}function KR(e){switch(e.searchParam.type){case`date`:return(0,I.jsx)(qR,{...e});case`number`:case`quantity`:return(0,I.jsx)(JR,{...e});case`reference`:return(0,I.jsx)(YR,{...e});case`string`:return(0,I.jsx)(XR,{...e});case`token`:return(0,I.jsx)(ZR,{...e});case`uri`:return(0,I.jsx)(QR,{...e});default:return(0,I.jsxs)(I.Fragment,{children:[`Unknown search param type: `,e.searchParam.type]})}}function qR(e){let{searchParam:t}=e,n=t.code;return(0,I.jsxs)(W.Dropdown,{children:[(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(bj,{size:14}),onClick:()=>e.onSort(t,!1),children:`Sort Oldest to Newest`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(xj,{size:14}),onClick:()=>e.onSort(t,!0),children:`Sort Newest to Oldest`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(BA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Equals...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(zA,{size:14}),onClick:()=>e.onPrompt(t,X.NOT_EQUALS),children:`Does not equal...`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(tj,{size:14}),onClick:()=>e.onPrompt(t,X.ENDS_BEFORE),children:`Before...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(ej,{size:14}),onClick:()=>e.onPrompt(t,X.STARTS_AFTER),children:`After...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(_A,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Between...`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(CA,{size:14}),onClick:()=>e.onChange(hR(e.search,n)),children:`Tomorrow`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(CA,{size:14}),onClick:()=>e.onChange(mR(e.search,n)),children:`Today`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(CA,{size:14}),onClick:()=>e.onChange(pR(e.search,n)),children:`Yesterday`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(CA,{size:14}),onClick:()=>e.onChange(_R(e.search,n)),children:`Next 24 Hours`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(CA,{size:14}),onClick:()=>e.onChange(bR(e.search,n)),children:`Next Month`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(CA,{size:14}),onClick:()=>e.onChange(yR(e.search,n)),children:`This Month`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(CA,{size:14}),onClick:()=>e.onChange(vR(e.search,n)),children:`Last Month`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(CA,{size:14}),onClick:()=>e.onChange(SR(e.search,n)),children:`Year to date`}),(0,I.jsx)($R,{...e})]})}function JR(e){let{searchParam:t}=e;return(0,I.jsxs)(W.Dropdown,{children:[(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(bj,{size:14}),onClick:()=>e.onSort(t,!1),children:`Sort Smallest to Largest`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(xj,{size:14}),onClick:()=>e.onSort(t,!0),children:`Sort Largest to Smallest`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(BA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Equals...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(zA,{size:14}),onClick:()=>e.onPrompt(t,X.NOT_EQUALS),children:`Does not equal...`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(ej,{size:14}),onClick:()=>e.onPrompt(t,X.GREATER_THAN),children:`Greater than...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(yj,{size:14}),onClick:()=>e.onPrompt(t,X.GREATER_THAN_OR_EQUALS),children:`Greater than or equal to...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(tj,{size:14}),onClick:()=>e.onPrompt(t,X.LESS_THAN),children:`Less than...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(yj,{size:14}),onClick:()=>e.onPrompt(t,X.LESS_THAN_OR_EQUALS),children:`Less than or equal to...`}),(0,I.jsx)($R,{...e})]})}function YR(e){let{searchParam:t}=e;return(0,I.jsxs)(W.Dropdown,{children:[(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(BA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Equals...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(zA,{size:14}),onClick:()=>e.onPrompt(t,X.NOT),children:`Does not equal...`}),(0,I.jsx)($R,{...e})]})}function XR(e){let{searchParam:t}=e;return(0,I.jsxs)(W.Dropdown,{children:[(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(bj,{size:14}),onClick:()=>e.onSort(t,!1),children:`Sort A to Z`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(xj,{size:14}),onClick:()=>e.onSort(t,!0),children:`Sort Z to A`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(BA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Equals...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(zA,{size:14}),onClick:()=>e.onPrompt(t,X.NOT),children:`Does not equal...`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(xA,{size:14}),onClick:()=>e.onPrompt(t,X.CONTAINS),children:`Contains...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(bA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Does not contain...`}),(0,I.jsx)($R,{...e})]})}function ZR(e){let{searchParam:t}=e;return(0,I.jsxs)(W.Dropdown,{children:[(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(BA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Equals...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(zA,{size:14}),onClick:()=>e.onPrompt(t,X.NOT),children:`Does not equal...`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(BA,{size:14}),onClick:()=>e.onPrompt(t,X.TEXT),children:`Text contains...`}),(0,I.jsx)($R,{...e})]})}function QR(e){let{searchParam:t}=e;return(0,I.jsxs)(W.Dropdown,{children:[(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(BA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Equals...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(zA,{size:14}),onClick:()=>e.onPrompt(t,X.NOT),children:`Does not equal...`}),(0,I.jsx)($R,{...e})]})}function $R(e){let{searchParam:t}=e,n=t.code;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(mA,{size:14}),onClick:()=>e.onChange(TR(e.search,n)),children:`Missing`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(pA,{size:14}),onClick:()=>e.onChange(TR(e.search,n,!1)),children:`Not missing`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(Nj,{size:14}),onClick:()=>e.onClear(t),children:`Clear filters`})]})}function ez(e){switch(e){case`next`:return{"aria-label":`Next page`};case`previous`:return{"aria-label":`Previous page`};case`first`:return{"aria-label":`First page`};case`last`:return{"aria-label":`Last page`};default:return{}}}var tz={root:`_root_vlout_1`,table:`_table_vlout_8`,tr:`_tr_vlout_12`,th:`_th_vlout_18`,control:`_control_vlout_22`,icon:`_icon_vlout_31`};function nz(e){let t=e.resourceType,n=[];for(let r of e.fields||[`id`,`_lastUpdated`])n.push(rz(t,r));return n}function rz(e,t){if(t===`_lastUpdated`)return{name:`_lastUpdated`,searchParams:[{resourceType:`SearchParameter`,base:[`Resource`],code:`_lastUpdated`,name:`_lastUpdated`,type:`date`,expression:`Resource.meta.lastUpdated`}]};if(t===`meta.versionId`)return{name:`meta.versionId`,searchParams:[{resourceType:`SearchParameter`,base:[`Resource`],code:`_versionId`,name:`_versionId`,type:`token`,expression:`Resource.meta.versionId`}]};let n=Bw(e,t),r=Fw(e,t.toLowerCase());if(n&&r)return{name:t,elementDefinition:n,searchParams:[r]};if(n){let r=Pw(e),i;if(r){let n=RegExp(`${e}\\.${t.replaceAll(`[x]`,``)}([^\\w-]|$)`);i=Object.values(r).filter(e=>!!e.expression&&n.test(e?.expression)),i.length===0&&(i=void 0)}return{name:t,elementDefinition:n,searchParams:i}}return r?{name:t,elementDefinition:DO(e,r).elementDefinitions?.[0],searchParams:[r]}:{name:t}}var iz=class extends Event{definition;constructor(e){super(`change`),this.definition=e}},az=class extends Event{response;constructor(e){super(`load`),this.response=e}},oz=class extends Event{resource;browserEvent;constructor(e,t){super(`click`),this.resource=e,this.browserEvent=t}};function sz(e){let t=Z(),[n,r]=(0,b.useState)(),{search:i,onLoad:a}=e,[o,s]=(0,b.useState)(i);EC(i,o)||s(i);let[c,l]=(0,b.useState)({selected:{},fieldEditorVisible:!1,filterEditorVisible:!1,exportDialogVisible:!1,filterDialogVisible:!1}),u=(0,b.useRef)(c);(0,b.useLayoutEffect)(()=>{u.current=c});let d=o.total??`accurate`,f=(0,b.useCallback)(e=>{r(void 0),t.requestSchema(o.resourceType).then(()=>t.search(o.resourceType,cE({...o,total:d,fields:void 0}),e)).then(e=>{l({...u.current,searchResponse:e}),a&&a(new az(e))}).catch(e=>{l({...u.current,searchResponse:void 0}),r(Zx(e))})},[t,o,d,a]),p=(0,b.useCallback)(()=>{l({...u.current,searchResponse:void 0}),f({cache:`reload`})},[f]);(0,b.useEffect)(()=>{f()},[f]);function m(e,t){e.stopPropagation();let n=e.target.checked,r={...u.current.selected};n?r[t]=!0:delete r[t],l({...u.current,selected:r})}function h(e){e.stopPropagation();let t=e.target.checked,n={},r=u.current.searchResponse;t&&r?.entry&&r.entry.forEach(e=>{e.resource?.id&&(n[e.resource.id]=!0)}),l({...u.current,selected:n})}function g(){if(!c.searchResponse?.entry||c.searchResponse.entry.length===0)return!1;for(let e of c.searchResponse.entry)if(e.resource?.id&&!c.selected[e.resource.id])return!1;return!0}function _(t){e.onChange&&e.onChange(new iz(t))}function v(t,n){if(Bj(t.target)||t.button===2)return;Rj(t);let r=zj(t);!r&&e.onClick&&e.onClick(new oz(n,t)),r&&e.onAuxClick&&e.onAuxClick(new oz(n,t))}function y(){return!!(e.onExport??e.onExportCsv??e.onExportTransactionBundle)}if(n)return(0,I.jsx)(EP,{outcome:n});if(!fS(o.resourceType))return(0,I.jsx)(Kp,{style:{width:`100%`,height:`100%`},children:(0,I.jsx)(cu,{})});let x=e.checkboxesEnabled,S=nz(o),C=o.resourceType,w=c.searchResponse,T=(w?.entry)?.map(e=>e.resource),E=`subtle`,D=`gray`,O=window.innerWidth<768;return(0,I.jsxs)(`div`,{className:tz.root,"data-testid":`search-control`,children:[!e.hideToolbar&&(0,I.jsxs)(V,{justify:`space-between`,mb:`xl`,children:[(0,I.jsxs)(V,{gap:2,children:[(0,I.jsx)(U,{size:`compact-md`,variant:E,color:D,leftSection:(0,I.jsx)(jA,{size:16}),onClick:()=>l({...u.current,fieldEditorVisible:!0,dialogOpenTime:Date.now()}),children:`Fields`}),(0,I.jsx)(U,{size:`compact-md`,variant:E,color:D,leftSection:(0,I.jsx)(GA,{size:16}),onClick:()=>l({...u.current,filterEditorVisible:!0,dialogOpenTime:Date.now()}),children:`Filters`}),e.onNew&&(0,I.jsx)(U,{size:`compact-md`,variant:E,color:D,leftSection:(0,I.jsx)(WA,{size:16}),onClick:e.onNew,children:`New...`}),!O&&y()&&(0,I.jsx)(U,{size:`compact-md`,variant:E,color:D,leftSection:(0,I.jsx)(Ej,{size:16}),onClick:e.onExport?e.onExport:()=>l({...u.current,exportDialogVisible:!0,dialogOpenTime:Date.now()}),children:`Export...`}),!O&&e.onDelete&&(0,I.jsx)(U,{size:`compact-md`,variant:E,color:D,leftSection:(0,I.jsx)(kj,{size:16}),onClick:()=>e.onDelete(Object.keys(c.selected)),children:`Delete...`}),!O&&e.onBulk&&(0,I.jsx)(U,{size:`compact-md`,variant:E,color:D,leftSection:(0,I.jsx)(gA,{size:16}),onClick:()=>e.onBulk(Object.keys(c.selected)),children:`Bulk...`})]}),(0,I.jsxs)(V,{gap:2,children:[w&&(0,I.jsxs)(H,{size:`xs`,c:`dimmed`,"data-testid":`count-display`,children:[dz(o,w).toLocaleString(),`-`,fz(o,w).toLocaleString(),w.total!==void 0&&` of ${o.total===`estimate`?`~`:``}${w.total?.toLocaleString()}`]}),(0,I.jsx)(gu,{variant:E,color:D,title:`Refresh`,onClick:p,children:(0,I.jsx)(mj,{size:16})})]})]}),(0,I.jsxs)(K,{className:tz.table,children:[(0,I.jsxs)(K.Thead,{children:[(0,I.jsxs)(K.Tr,{children:[x&&(0,I.jsx)(K.Th,{children:(0,I.jsx)(`input`,{type:`checkbox`,value:`checked`,"aria-label":`all-checkbox`,"data-testid":`all-checkbox`,checked:g(),onChange:e=>h(e)})}),S.map(e=>(0,I.jsx)(K.Th,{children:(0,I.jsxs)(W,{shadow:`md`,width:240,position:`bottom-end`,children:[(0,I.jsx)(W.Target,{children:(0,I.jsx)(ml,{className:tz.control,p:2,children:(0,I.jsxs)(V,{justify:`space-between`,wrap:`nowrap`,children:[(0,I.jsx)(H,{fw:500,children:NR(e.name)}),(0,I.jsx)(Kp,{className:tz.icon,children:(0,I.jsx)(lA,{size:14,stroke:1.5})})]})})}),(0,I.jsx)(GR,{search:o,searchParams:e.searchParams,onPrompt:(e,t)=>{l({...u.current,filterDialogVisible:!0,filterDialogSearchParam:e,filterDialogFilter:t,dialogOpenTime:Date.now()})},onChange:e=>{_(e)}})]})},e.name))]}),!e.hideFilters&&(0,I.jsxs)(K.Tr,{children:[x&&(0,I.jsx)(K.Th,{}),S.map(e=>(0,I.jsx)(K.Th,{children:e.searchParams&&(0,I.jsx)(cz,{resourceType:C,searchParams:e.searchParams,filters:o.filters})},e.name))]})]}),(0,I.jsx)(K.Tbody,{children:T?.map(e=>e&&(0,I.jsxs)(K.Tr,{className:tz.tr,"data-testid":`search-control-row`,onClick:t=>v(t,e),onAuxClick:t=>v(t,e),children:[x&&(0,I.jsx)(K.Td,{children:(0,I.jsx)(`input`,{type:`checkbox`,value:`checked`,"data-testid":`row-checkbox`,"aria-label":`Checkbox for ${e.id}`,checked:!!c.selected[e.id],onChange:t=>m(t,e.id)})}),S.map(t=>(0,I.jsx)(K.Td,{children:PR(e,t)},t.name))]},e.id))})]}),!T?.length&&(0,I.jsx)(hP,{children:(0,I.jsx)(Kp,{style:{height:150},children:(0,I.jsx)(H,{size:`xl`,c:`dimmed`,children:`No results`})})}),w&&(0,I.jsx)(Kp,{m:`md`,p:`md`,children:(0,I.jsx)(rv,{value:lz(o),total:uz(o,w),onChange:e=>_(DR(o,e)),getControlProps:ez})}),(0,I.jsx)(LR,{search:o,visible:c.fieldEditorVisible,onOk:e=>{_(e),l({...u.current,fieldEditorVisible:!1})},onCancel:()=>{l({...u.current,fieldEditorVisible:!1})}},`search-field-editor-${c.dialogOpenTime}`),(0,I.jsx)(VR,{search:o,visible:c.filterEditorVisible,onOk:e=>{_(e),l({...u.current,filterEditorVisible:!1})},onCancel:()=>{l({...u.current,filterEditorVisible:!1})}},`search-filter-editor-${c.dialogOpenTime}`),(0,I.jsx)(aR,{visible:c.exportDialogVisible,exportCsv:e.onExportCsv,exportTransactionBundle:e.onExportTransactionBundle,onCancel:()=>{l({...u.current,exportDialogVisible:!1})}},`search-export-dialog-${c.dialogOpenTime}`),(0,I.jsx)(UR,{visible:c.filterDialogVisible,title:c.filterDialogSearchParam?.code?NR(c.filterDialogSearchParam.code):``,resourceType:C,searchParam:c.filterDialogSearchParam,filter:c.filterDialogFilter,defaultValue:``,onOk:e=>{_(dR(o,e.code,e.operator,e.value)),l({...u.current,filterDialogVisible:!1})},onCancel:()=>{l({...u.current,filterDialogVisible:!1})}},`search-filter-dialog-${c.dialogOpenTime}`)]})}function cz(e){let t=(e.filters??[]).filter(t=>e.searchParams.find(e=>e.code===t.code));return t.length===0?(0,I.jsx)(`span`,{children:`no filters`}):(0,I.jsx)(I.Fragment,{children:t.map(t=>(0,I.jsxs)(`div`,{children:[MR(t.operator),`\xA0`,(0,I.jsx)(WR,{resourceType:e.resourceType,filter:t})]},`filter-${t.code}-${t.operator}-${t.value}`))})}function lz(e){return Math.floor((e.offset??0)/(e.count??20))+1}function uz(e,t){let n=e.count??20,r=pz(e,t);return Math.ceil(r/n)}function dz(e,t){return Math.min(pz(e,t),(e.offset??0)+1)}function fz(e,t){return Math.max(dz(e,t)+(t.entry?.length??0)-1,0)}function pz(e,t){let n=t.total;return n===void 0&&(n=(e.offset??0)+(t.entry?.length??0)+ +!!t.link?.some(e=>e.relation===`next`)),n}function mz(e){let t=Z(),[n,r]=(0,b.useState)(!1),[i,a]=(0,b.useState)(),{query:o,fields:s}=e,[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)({});(0,b.useEffect)(()=>{a(void 0),t.graphql(o).then(l).catch(e=>a(Zx(e)))},[t,o]);function f(e,t){e.stopPropagation();let n=e.target.checked,r={...u};n?r[t]=!0:delete r[t],d(r)}function p(e){e.stopPropagation();let t=e.target.checked,n={},r=c?.data.ResourceList;t&&r&&r.forEach(e=>{e.id&&(n[e.id]=!0)}),d(n)}function m(){let e=c?.data.ResourceList;if(!e||e.length===0)return!1;for(let t of e)if(t.id&&!u[t.id])return!1;return!0}function h(t,n){Bj(t.target)||(Rj(t),t.button!==1&&e.onClick&&e.onClick(new oz(n,t)),t.button===1&&e.onAuxClick&&e.onAuxClick(new oz(n,t)))}if((0,b.useEffect)(()=>{t.requestSchema(e.resourceType).then(()=>r(!0)).catch(console.log)},[t,e.resourceType]),!n)return(0,I.jsx)(cu,{});let g=e.checkboxesEnabled;return(0,I.jsxs)(`div`,{onContextMenu:e=>Rj(e),"data-testid":`search-control`,children:[(0,I.jsxs)(K,{children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[g&&(0,I.jsx)(K.Th,{children:(0,I.jsx)(`input`,{type:`checkbox`,value:`checked`,"aria-label":`all-checkbox`,"data-testid":`all-checkbox`,checked:m(),onChange:e=>p(e)})}),s.map(e=>(0,I.jsx)(K.Th,{children:e.name},e.name))]})}),(0,I.jsx)(K.Tbody,{children:c?.data.ResourceList.map(e=>e&&(0,I.jsxs)(K.Tr,{"data-testid":`search-control-row`,onClick:t=>h(t,e),onAuxClick:t=>h(t,e),children:[g&&(0,I.jsx)(K.Td,{children:(0,I.jsx)(`input`,{type:`checkbox`,value:`checked`,"data-testid":`row-checkbox`,"aria-label":`Checkbox for ${e.id}`,checked:!!u[e.id],onChange:t=>f(t,e.id)})}),s.map(t=>(0,I.jsx)(K.Td,{children:(0,I.jsx)(iR,{propertyType:t.propertyType,path:t.fhirPath,resource:e})},t.name))]},e.id))})]}),c?.data.ResourceList.length===0&&(0,I.jsx)(`div`,{"data-testid":`empty-search`,children:`No results`}),i&&(0,I.jsx)(`div`,{"data-testid":`search-error`,children:(0,I.jsx)(`pre`,{style:{textAlign:`left`},children:JSON.stringify(i,void 0,2)})}),e.onBulk&&(0,I.jsx)(U,{onClick:()=>e.onBulk(Object.keys(u)),children:`Bulk...`})]})}var hz=(0,b.memo)(mz),gz={root:`_root_1fbwr_1`,entry:`_entry_1fbwr_8`,key:`_key_1fbwr_13`,value:`_value_1fbwr_20`};function _z(e){return(0,I.jsx)(ul,{children:(0,I.jsx)(`div`,{className:gz.root,children:e.children})})}_z.Entry=function(e){return(0,I.jsx)(`div`,{className:gz.entry,children:e.children})},_z.Key=function(e){return(0,I.jsx)(`div`,{className:gz.key,children:e.children})},_z.Value=function(e){return(0,I.jsx)(`div`,{className:gz.value,children:e.children})};var vz={list:`_list_y4z6g_1`,link:`_link_y4z6g_6`};function yz(e){let{baseUrl:t,tabs:n,children:r,...i}=e,a=bz(n),o=KO(),[s,c]=(0,b.useState)(()=>{let e=LE.getPathname().split(`/`).pop();if(e){let t=e.toLowerCase(),n=a.find(e=>e.value.split(/[?#]/)[0].toLowerCase()===t);if(n)return n.value}return a[0].value});function l(e){e||=a[0].value,c(e),o(`${t}/${e}`)}return(0,I.jsxs)(vb,{value:s,onChange:l,...i,children:[(0,I.jsx)(vb.List,{className:vz.list,children:a.map(e=>(0,I.jsx)(vb.Tab,{value:e.value,children:(0,I.jsx)(Pd,{className:vz.link,href:`${t}/${e.value}`,onClick:xz,children:e.label})},e.value))}),r]})}function bz(e){return e.map(e=>FC(e)?{label:e,value:e.toLowerCase()}:e)}function xz(e){zj(e)||e.preventDefault()}function Sz(e){let{group:t}=e;return(0,I.jsx)(yl,{withBorder:!0,radius:`md`,p:`xs`,display:`flex`,style:{alignItems:`center`,justifyContent:`center`},children:(0,I.jsxs)(V,{children:[t.measureScore&&(0,I.jsx)(Tz,{group:t}),!t.measureScore&&(0,I.jsx)(wz,{group:t})]})})}function Cz(e){let{measure:t}=e;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(H,{fz:`md`,fw:500,mb:8,children:t.title}),(0,I.jsx)(H,{fz:`xs`,c:`dimmed`,mb:8,children:t.subtitle})]})}function wz(e){let{group:t}=e,n=t.population,r=n?.find(e=>Sw(e.code)===`numerator`),i=n?.find(e=>Sw(e.code)===`denominator`),a=r?.count,o=i?.count;if(o===0)return(0,I.jsxs)(z,{children:[(0,I.jsx)(q,{order:3,children:`Not Applicable`}),(0,I.jsx)(H,{children:`Denominator: ${o}`})]});if(a===void 0||o===void 0)return(0,I.jsxs)(z,{children:[(0,I.jsx)(q,{order:3,children:`Insufficient Data`}),(0,I.jsx)(H,{children:`Numerator: ${a}`}),(0,I.jsx)(H,{children:`Denominator: ${o}`})]});let s=a/o*100;return(0,I.jsx)(oy,{size:120,thickness:12,roundCaps:!0,sections:[{value:s,color:Dz(s)}],label:(0,I.jsx)(_d,{justify:`center`,children:(0,I.jsxs)(H,{fw:700,fz:18,children:[a,` / `,o]})})})}function Tz(e){let{group:t}=e;return(0,I.jsx)(I.Fragment,{children:(t.measureScore?.unit??t.measureScore?.code)===`%`?(0,I.jsx)(oy,{size:120,thickness:12,roundCaps:!0,sections:[{value:Ez(t),color:Dz(t?.measureScore?.value??0)}],label:(0,I.jsx)(_d,{justify:`center`,children:(0,I.jsx)(H,{fw:700,fz:18,children:(0,I.jsx)(dF,{value:t.measureScore})})})}):(0,I.jsx)(_d,{h:120,align:`center`,children:(0,I.jsx)(q,{order:3,children:(0,I.jsx)(dF,{value:t.measureScore})})})})}function Ez(e){let t=e.measureScore?.value,n=e.measureScore?.unit;return t?t<=1&&n===`%`?t*100:t:0}function Dz(e){return e<=33?`red`:e<=67?`yellow`:`green`}function Oz(e){let t=nk(e.measureReport),[n]=Jk(`Measure`,{url:t?.measure});return t?(0,I.jsxs)(z,{children:[n&&(0,I.jsx)(Cz,{measure:n}),(0,I.jsx)(vy,{cols:{base:3,sm:1},spacing:{base:`md`,sm:`sm`},children:t.group?.map((e,t)=>(0,I.jsx)(Sz,{group:e},e.id??t))})]}):null}var kz=`patient-accounts`,Az=`Patient Accounts`,jz=[`Organization`,`HealthcareService`,`CareTeam`];function Mz(e){let{patient:t}=e,n=Z(),r=n.isProjectAdmin()||n.isSuperAdmin(),i=(0,b.useMemo)(()=>cC(t.meta)??[],[t.meta]),[a,o]=(0,b.useState)(i),[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(!0),[d,f]=(0,b.useState)(!1),p=(0,b.useMemo)(()=>{let e=[];for(let t of a)i.some(e=>e.reference===t.reference)||e.push({reference:t,type:`addition`});for(let t of i)a.some(e=>e.reference===t.reference)||e.push({reference:t,type:`removal`});return e},[i,a]),m=p.length>0,h=(0,b.useCallback)(e=>{e?.reference&&(a.some(t=>t.reference===e.reference)||o(t=>[...t,e]))},[a]),g=(0,b.useCallback)(e=>{o(t=>t.filter(t=>t.reference!==e))},[]),_=(0,b.useCallback)(async()=>{let r=t.id;if(!r){zb.show({id:kz,title:Az,color:`red`,message:`Cannot update accounts: Patient resource has no ID.`,icon:(0,I.jsx)(Nj,{size:`1rem`}),autoClose:!1,withCloseButton:!0});return}f(!0),c(!1);let i=n.fhirUrl(`Patient`,r,`$set-accounts`),o={resourceType:`Parameters`,parameter:[...a.map(e=>({name:`accounts`,valueReference:{reference:e.reference}})),{name:`propagate`,valueBoolean:l}]};zb.show({id:kz,title:Az,loading:!0,message:l?`Saving account changes and propagating to compartment...`:`Saving account changes...`,autoClose:!1,withCloseButton:!1});try{let t={};l&&(t.Prefer=`respond-async`),await n.post(i,o,void 0,{headers:t}),n.invalidateUrl(n.fhirUrl(`Patient`,r)),zb.update({id:kz,title:Az,color:`green`,message:l?`Account changes saved. Compartment updates are being applied.`:`Account changes saved.`,icon:(0,I.jsx)(wA,{size:`1rem`}),loading:!1,autoClose:!0,withCloseButton:!0}),e.onSaved?.()}catch(e){zb.update({id:kz,title:Az,color:`red`,message:Qx(e),icon:(0,I.jsx)(Nj,{size:`1rem`}),loading:!1,autoClose:!1,withCloseButton:!0})}finally{f(!1)}},[n,t,a,l,e]);return r?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(G,{children:[(0,I.jsx)(q,{order:3,children:`Current Accounts`}),a.length===0?(0,I.jsx)(H,{c:`dimmed`,children:`No accounts assigned to this patient.`}):(0,I.jsxs)(K,{children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:`Type`}),(0,I.jsx)(K.Th,{children:`Account`}),(0,I.jsx)(K.Th,{})]})}),(0,I.jsx)(K.Tbody,{children:a.map(e=>(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:(0,I.jsx)(Nz,{reference:e})}),(0,I.jsx)(K.Td,{children:(0,I.jsx)(fL,{value:e,link:!0})}),(0,I.jsx)(K.Td,{children:(0,I.jsx)(gu,{variant:`subtle`,color:`red`,"aria-label":`Remove ${e.reference}`,onClick:()=>g(e.reference),children:(0,I.jsx)(Nj,{size:16})})})]},e.reference))})]}),(0,I.jsx)(dm,{}),(0,I.jsx)(q,{order:4,children:`Add Account`}),(0,I.jsx)(cI,{name:`newAccount`,placeholder:`Search for Organization, HealthcareService, or CareTeam...`,targetTypes:jz,onChange:e=>{e&&h(e)}}),m&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dm,{}),(0,I.jsx)(q,{order:4,children:`Pending Changes`}),(0,I.jsx)(G,{gap:`xs`,children:p.map(e=>(0,I.jsxs)(V,{gap:`xs`,children:[e.type===`addition`?(0,I.jsx)(Mp,{color:`green`,variant:`light`,leftSection:(0,I.jsx)(fj,{size:12}),children:`Add`}):(0,I.jsx)(Mp,{color:`red`,variant:`light`,leftSection:(0,I.jsx)(ij,{size:12}),children:`Remove`}),(0,I.jsx)(fL,{value:e.reference,link:!0})]},`${e.type}-${e.reference.reference}`))})]}),(0,I.jsx)(z,{children:(0,I.jsx)(U,{disabled:!m||d,onClick:()=>c(!0),children:`Save Changes`})})]}),(0,I.jsx)(rg,{opened:s,onClose:()=>c(!1),title:`Confirm Account Changes`,size:`md`,keepMounted:!0,children:(0,I.jsxs)(G,{children:[(0,I.jsxs)(H,{children:[`The following changes will be applied to Patient`,` `,(0,I.jsxs)(`strong`,{children:[t.name?.[0]?.given?.join(` `),` `,t.name?.[0]?.family]}),`:`]}),p.filter(e=>e.type===`addition`).length>0&&(0,I.jsxs)(z,{children:[(0,I.jsx)(H,{fw:600,c:`green`,children:`Adding:`}),(0,I.jsx)(G,{gap:`xs`,mt:`xs`,children:p.filter(e=>e.type===`addition`).map(e=>(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(fj,{size:14,color:`green`}),(0,I.jsx)(fL,{value:e.reference})]},e.reference.reference))})]}),p.filter(e=>e.type===`removal`).length>0&&(0,I.jsxs)(z,{children:[(0,I.jsx)(H,{fw:600,c:`red`,children:`Removing:`}),(0,I.jsx)(G,{gap:`xs`,mt:`xs`,children:p.filter(e=>e.type===`removal`).map(e=>(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(ij,{size:14,color:`red`}),(0,I.jsx)(fL,{value:e.reference})]},e.reference.reference))})]}),(0,I.jsx)(lp,{label:`Propagate changes to all resources in this patient's compartment`,checked:l,onChange:e=>u(e.currentTarget.checked)}),(0,I.jsxs)(V,{justify:`right`,mt:`md`,children:[(0,I.jsx)(U,{variant:`default`,onClick:()=>c(!1),children:`Cancel`}),(0,I.jsx)(U,{onClick:_,loading:d,children:`Confirm`})]})]})})]}):(0,I.jsx)(Dd,{color:`blue`,title:`Admin access required`,children:`You need project admin access to manage patient account assignments.`})}function Nz({reference:e}){let t=e.reference?.split(`/`)[0]??`Unknown`;return(0,I.jsx)(Mp,{variant:`light`,color:{Organization:`blue`,HealthcareService:`teal`,CareTeam:`violet`}[t]??`gray`,size:`sm`,children:t})}var Pz=`patient-export`,Fz=`Patient Export`,Iz={everything:{operation:`$everything`,extension:`json`,contentType:ZE.FHIR_JSON},summary:{operation:`$summary`,extension:`json`,contentType:ZE.FHIR_JSON},ccda:{operation:`$ccda-export`,extension:`xml`,contentType:ZE.CDA_XML},ccdaReferral:{operation:`$ccda-export`,type:`referral`,extension:`xml`,contentType:ZE.CDA_XML}};function Lz(e){let t=Z(),{patient:n}=e;return(0,I.jsx)(CN,{onSubmit:(0,b.useCallback)(async e=>{let r=sC(n),{operation:i,type:a,contentType:o,extension:s}=Iz[e.format],c=t.fhirUrl(`Patient`,r,i),l={};a&&(l.type=a),e.author&&(l.author={reference:e.author}),e.authoredOn&&(l.authoredOn=HF(e.authoredOn)),e.startDate&&(l.start=e.startDate),e.endDate&&(l.end=e.endDate),zb.show({id:Pz,title:Fz,loading:!0,message:`Exporting...`,autoClose:!1,withCloseButton:!1});try{Rz(await t.post(c,l,void 0,{cache:`no-cache`,headers:{Accept:o}}),`Patient-export-${r}-${new Date().toISOString().replaceAll(`:`,`-`)}.${s}`,o),zb.update({id:Pz,title:Fz,color:`green`,message:`Done`,icon:(0,I.jsx)(wA,{size:`1rem`}),loading:!1,autoClose:!0,withCloseButton:!0})}catch(e){zb.update({id:Pz,title:Fz,color:`red`,message:Qx(e),icon:(0,I.jsx)(Nj,{size:`1rem`}),loading:!1,autoClose:!1,withCloseButton:!0})}},[t,n]),children:(0,I.jsxs)(G,{children:[(0,I.jsx)(AF,{title:`Export Format`,description:`Required`,withAsterisk:!0,children:(0,I.jsx)(uy,{name:`format`,data:[{label:`FHIR Everything`,value:`everything`},{label:`Patient Summary`,value:`summary`},{label:`C-CDA`,value:`ccda`},{label:`C-CDA Referral`,value:`ccdaReferral`}],fullWidth:!0})}),(0,I.jsx)(AF,{title:`Author`,description:`Optional author for composition. Default value is current user.`,children:(0,I.jsx)(cI,{name:`author`,placeholder:`Author`,targetTypes:[`Organization`,`Practitioner`,`PractitionerRole`]})}),(0,I.jsx)(AF,{title:`Authored On`,description:`Optional date for composition authored on. Default value is current date.`,children:(0,I.jsx)(UF,{name:`authoredOn`,placeholder:`Authored on`})}),(0,I.jsx)(AF,{title:`Start Date`,description:`The start date of care. If no start date is provided, all records prior to the end date are in scope.`,children:(0,I.jsx)(UF,{name:`startDate`,placeholder:`Start date`})}),(0,I.jsx)(AF,{title:`End Date`,description:`The end date of care. If no end date is provided, all records subsequent to the start date are in scope.`,children:(0,I.jsx)(UF,{name:`endDate`,placeholder:`End date`})}),(0,I.jsx)(V,{justify:`right`,children:(0,I.jsx)(wN,{children:`Request Export`})})]})})}function Rz(e,t,n){let r=typeof e==`string`?e:JSON.stringify(e,null,2),i=new Blob([r],{type:n}),a=window.URL.createObjectURL(i),o=document.createElement(`a`);document.body.appendChild(o),o.style.display=`none`,o.href=a,o.download=t,o.click(),window.URL.revokeObjectURL(a)}function zz(e){if(e.gender===`male`)return`blue`;if(e.gender===`female`)return`pink`}function Bz(e){let t=nk(e.patient);return t?(0,I.jsxs)(_z,{children:[(0,I.jsx)(Xj,{value:t,size:`lg`,color:zz(t)}),(0,I.jsxs)(_z.Entry,{children:[(0,I.jsx)(_z.Key,{children:`Name`}),(0,I.jsx)(_z.Value,{children:(0,I.jsx)(Wj,{to:t,fw:500,children:t.name?(0,I.jsx)(cF,{value:t.name[0],options:{use:!1}}):`[blank]`})})]}),t.birthDate&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(_z.Entry,{children:[(0,I.jsx)(_z.Key,{children:`DoB`}),(0,I.jsx)(_z.Value,{children:t.birthDate})]}),(0,I.jsxs)(_z.Entry,{children:[(0,I.jsx)(_z.Key,{children:`Age`}),(0,I.jsx)(_z.Value,{children:gC(t.birthDate)})]})]}),t.gender&&(0,I.jsxs)(_z.Entry,{children:[(0,I.jsx)(_z.Key,{children:`Gender`}),(0,I.jsx)(_z.Value,{children:t.gender})]}),t.address&&(0,I.jsxs)(_z.Entry,{children:[(0,I.jsx)(_z.Key,{children:`State`}),(0,I.jsx)(_z.Value,{children:t.address[0]?.state})]}),t.identifier?.map(e=>(0,I.jsxs)(_z.Entry,{children:[(0,I.jsx)(_z.Key,{children:e?.system}),(0,I.jsx)(_z.Value,{children:e?.value})]},`${e?.system}-${e?.value}`))]}):null}function Vz(e){let{patient:t,...n}=e;return(0,I.jsx)(qL,{value:t,loadTimelineResources:(0,b.useCallback)((e,t,n)=>{let r=`${t}/${n}`;return Promise.allSettled([e.readHistory(`Patient`,n),e.search(`ClinicalImpression`,{subject:r,_count:100}),e.search(`Communication`,{subject:r,_count:100}),e.search(`Device`,{patient:r,_count:100}),e.search(`DeviceRequest`,{patient:r,_count:100}),e.search(`DiagnosticReport`,{subject:r,_count:100}),e.search(`Media`,{subject:r,_count:100}),e.search(`ServiceRequest`,{subject:r,_count:100}),e.search(`Task`,{subject:r,_count:100})])},[]),createCommunication:(e,t,n)=>({resourceType:`Communication`,status:`completed`,subject:aC(e),sender:aC(t),sent:new Date().toISOString(),payload:[{contentString:n}]}),createMedia:(e,t,n)=>({resourceType:`Media`,status:`completed`,subject:aC(e),operator:aC(t),issued:new Date().toISOString(),content:n}),...n})}var Hz={section:`_section_pqpwm_1`,hovering:`_hovering_pqpwm_7`,editing:`_editing_pqpwm_11`};function Uz(e){let t=Z(),n=nk(e.value),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(),[l,u]=(0,b.useState)();function d(){c(void 0)}function f(){o(void 0)}if((0,b.useEffect)(()=>{t.requestSchema(`PlanDefinition`).then(()=>i(!0)).catch(console.log)},[t]),(0,b.useEffect)(()=>(u(Zz(n??{resourceType:`PlanDefinition`,status:`active`})),document.addEventListener(`mouseover`,d),document.addEventListener(`click`,f),()=>{document.removeEventListener(`mouseover`,d),document.removeEventListener(`click`,f)}),[n]),!r||!l)return null;function p(e,t){u(n=>({...n,[e]:t}))}return(0,I.jsx)(`div`,{children:(0,I.jsxs)(CN,{testid:`questionnaire-form`,onSubmit:()=>e.onSubmit(l),children:[(0,I.jsx)(yb,{label:`Plan Title`,py:`md`,defaultValue:l.title,onChange:e=>p(`title`,e.currentTarget.value)}),(0,I.jsx)(Wz,{actions:l.action||[],selectedKey:a,setSelectedKey:o,hoverKey:s,setHoverKey:c,onChange:e=>p(`action`,e)}),(0,I.jsx)(wN,{children:`Save`})]})})}function Wz(e){function t(t){e.onChange(e.actions.map(e=>e.id===t.id?t:e))}function n(t){e.onChange([...e.actions,t]),e.setSelectedKey(t.id)}function r(t){e.onChange(e.actions.filter(e=>e!==t))}return(0,I.jsxs)(G,{gap:`md`,className:Hz.section,children:[e.actions.map(n=>(0,I.jsx)(Gz,{action:n,selectedKey:e.selectedKey,setSelectedKey:e.setSelectedKey,hoverKey:e.hoverKey,setHoverKey:e.setHoverKey,onChange:t,onRemove:()=>r(n)},n.id)),(0,I.jsx)(`div`,{children:(0,I.jsx)(U,{variant:`outline`,onClick:e=>{Rj(e),n({id:Xz()})},children:`Add action`})})]})}function Gz(e){let{action:t}=e;function n(t){t.stopPropagation(),e.setSelectedKey(e.action.id)}function r(t){Rj(t),e.setHoverKey(e.action.id)}return(0,I.jsx)(`div`,{onClick:n,onMouseOver:r,onFocus:r,children:(0,I.jsx)(Kz,{action:t,onChange:e.onChange,selectedKey:e.selectedKey,hoverKey:e.hoverKey,onRemove:e.onRemove})})}function Kz(e){let{action:t}=e,[n,r]=(0,b.useState)(),i=Z(),[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(),l=e.selectedKey===e.action.id,u=e.hoverKey===e.action.id;function d(n,r){e.onChange({...t,[n]:r})}let f=Mn(Hz.section,{[Hz.hovering]:u&&!l});return(0,b.useEffect)(()=>{(async()=>{if(!t.definitionCanonical)return;o(!0);let e=await i.readCanonical([`Questionnaire`,`ActivityDefinition`],t.definitionCanonical);r(Jz(e)),c(e),o(!1)})().catch(console.error)},[t.definitionCanonical,i]),a?(0,I.jsx)(cu,{}):(0,I.jsxs)(yl,{"data-testid":t.id,className:f,p:0,radius:`sm`,withBorder:!0,children:[(0,I.jsxs)(_d,{w:`100%`,p:`xs`,bg:`gray.0`,gap:`md`,align:`center`,justify:`space-between`,children:[(0,I.jsx)(yb,{w:`100%`,name:`actionTitle-${t.id}`,defaultValue:t.title,placeholder:`Title`,onChange:e=>d(`title`,e.currentTarget.value)}),(0,I.jsx)(xu,{"data-testid":`close-button`,onClick:e.onRemove})]}),l&&(0,I.jsxs)(G,{gap:`xl`,p:`md`,children:[(0,I.jsx)(z,{children:(0,I.jsx)(yb,{label:`Task Description`,placeholder:`Enter task description`,name:`actionDescription-${t.id}`,defaultValue:t.description,onChange:e=>d(`description`,e.currentTarget.value)})}),(0,I.jsx)(z,{children:(0,I.jsx)(Eg,{label:`Type of Action`,value:n,onChange:t=>{let n=t.currentTarget.value===`standard`?void 0:t.currentTarget.value;r(n),e.onChange({...e.action,definitionCanonical:n===`standard`?void 0:e.action.definitionCanonical})},data:[{value:`standard`,label:`Standard task`},{value:`questionnaire`,label:`Task with Questionnaire`},{value:`activitydefinition`,label:`Task with Activity Definition`}]})}),n===`questionnaire`&&(0,I.jsxs)(G,{gap:0,children:[(0,I.jsxs)(V,{gap:0,mb:`xs`,children:[(0,I.jsx)(H,{fw:600,children:`Select questionnaire`}),(0,I.jsx)(H,{c:`red`,children:`*`})]}),(0,I.jsxs)(H,{size:`sm`,c:`dimmed`,mb:`sm`,children:[`Questionnaire to be shown in the task in Encounter view. You can create new one from`,` `,(0,I.jsx)(Pd,{href:`/Questionnaire`,target:`_blank`,c:`blue`,children:`questionnaires list`})]}),(0,I.jsx)(qz,{resource:s,resourceType:`Questionnaire`,action:t,onChange:e.onChange,placeholder:`Search for questionnaire`})]}),n===`activitydefinition`&&(0,I.jsxs)(G,{gap:0,children:[(0,I.jsxs)(V,{gap:0,mb:`xs`,children:[(0,I.jsx)(H,{fw:600,children:`Select activity definition`}),(0,I.jsx)(H,{c:`red`,children:`*`})]}),(0,I.jsxs)(H,{size:`sm`,c:`dimmed`,mb:`sm`,children:[`ActivityDefinition.kind resource to be shown in the task in Encounter view. You can create new one from`,` `,(0,I.jsx)(Pd,{href:`/ActivityDefinition`,target:`_blank`,c:`blue`,children:`activity definitions list`})]}),(0,I.jsx)(qz,{resource:s,resourceType:`ActivityDefinition`,action:t,onChange:e.onChange,placeholder:`Search for activity definition`})]})]})]})}function qz(e){let{id:t}=e.action,{resource:n}=e;return(0,I.jsx)(sI,{name:t,placeholder:e.placeholder,resourceType:e.resourceType,defaultValue:n,onChange:t=>{t?e.onChange({...e.action,definitionCanonical:`url`in t?t.url:void 0,definitionUri:`url`in t?void 0:oC(t)}):e.onChange({...e.action,definitionCanonical:void 0})}})}function Jz(e){return e===void 0?`standard`:e.resourceType.toLowerCase()}var Yz=1;function Xz(e){if(e){if(e.startsWith(`id-`)){let t=Number.parseInt(e.substring(3),10);Number.isNaN(t)||(Yz=Math.max(Yz,t+1))}return e}return`id-`+ Yz++}function Zz(e){return{...e,action:Qz(e.action)}}function Qz(e){if(e)return e.map(e=>({...e,id:Xz(e.id),action:Qz(e.action)}))}var $z={section:`_section_my8o4_1`,hovering:`_hovering_my8o4_10`,editing:`_editing_my8o4_14`,questionBody:`_questionBody_my8o4_20`,topActions:`_topActions_my8o4_24`,bottomActions:`_bottomActions_my8o4_33`,movementActions:`_movementActions_my8o4_44`,movementIcons:`_movementIcons_my8o4_56`,columnAlignment:`_columnAlignment_my8o4_60`,linkIdInput:`_linkIdInput_my8o4_65`,typeSelect:`_typeSelect_my8o4_70`,preserveBreaks:`_preserveBreaks_my8o4_74`};function eB(e){let t=Z(),n=nk(e.questionnaire),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(),[l,u]=(0,b.useState)();function d(){u(void 0)}function f(){c(void 0)}return(0,b.useEffect)(()=>{t.requestSchema(`Questionnaire`).then(()=>i(!0)).catch(console.log)},[t]),(0,b.useEffect)(()=>(o(lB(n??{resourceType:`Questionnaire`,status:`active`})),document.addEventListener(`mouseover`,d),document.addEventListener(`click`,f),()=>{document.removeEventListener(`mouseover`,d),document.removeEventListener(`click`,f)}),[n]),!r||!a?null:(0,I.jsx)(`div`,{children:(0,I.jsxs)(CN,{testid:`questionnaire-form`,onSubmit:()=>e.onSubmit(a),children:[(0,I.jsx)(tB,{item:a,selectedKey:s,setSelectedKey:c,hoverKey:l,setHoverKey:u,onChange:(t,n)=>{o(t),e.autoSave&&!n&&e.onSubmit&&e.onSubmit(t)}}),(0,I.jsx)(wN,{children:`Save`})]})})}function tB(e){let t=e.item,n=e.item,r=Hw(e.item),i=r||n.type===ik.group,a=n.linkId??`[untitled]`,o=e.selectedKey===e.item.id,s=e.hoverKey===e.item.id,c=(0,b.useRef)(e.item);(0,b.useLayoutEffect)(()=>{c.current=e.item});function l(t){Rj(t),e.setSelectedKey(e.item.id)}function u(t){Rj(t),e.setHoverKey(e.item.id)}function d(t){let n=c.current;e.onChange({...n,item:n.item?.map(e=>e.id===t.id?t:e)})}function f(t,n){e.onChange({...e.item,item:[...e.item.item??[],t]},n)}function p(t){e.onChange({...e.item,item:e.item.item?.filter(e=>e!==t)})}function m(t,n){e.onChange({...c.current,[t]:n})}function h(t){e.onChange({...e.item,...t})}function g(t){e.onChange({...e.item,item:e.item.item?.map(e=>e===t?{...e,repeats:!e.repeats}:e)})}function _(t,n){let r=pB(e.item.item,t,n);e.onChange({...e.item,item:r})}let v=Mn($z.section,{[$z.editing]:o,[$z.hovering]:s&&!o});return(0,I.jsxs)(`div`,{"data-testid":n.linkId,className:v,onClick:l,onMouseOver:u,onFocus:u,children:[(0,I.jsx)(`div`,{className:$z.questionBody,children:o?(0,I.jsxs)(I.Fragment,{children:[r&&(0,I.jsx)(yb,{size:`xl`,defaultValue:t.title,onBlur:e=>m(`title`,e.currentTarget.value)}),!r&&(0,I.jsx)(oh,{autosize:!0,minRows:2,defaultValue:n.text,onBlur:e=>m(`text`,e.currentTarget.value)}),n.type===`reference`&&(0,I.jsx)(iB,{item:n,onChange:h}),mk(n)&&(0,I.jsx)(nB,{item:n,onChange:e=>h(e)})]}):(0,I.jsxs)(I.Fragment,{children:[t.title&&(0,I.jsx)(q,{children:t.title}),n.text&&(0,I.jsx)(`div`,{className:$z.preserveBreaks,children:n.text}),!i&&(0,I.jsx)(HI,{item:n,index:0,required:!1,responseItem:{linkId:n.linkId}})]})}),n.item?.map((t,n)=>(0,I.jsx)(`div`,{children:(0,I.jsx)(tB,{item:t,selectedKey:e.selectedKey,setSelectedKey:e.setSelectedKey,hoverKey:e.hoverKey,isFirst:n===0,isLast:n===(e.item.item??[]).length-1,setHoverKey:e.setHoverKey,onChange:d,onRemove:()=>p(t),onRepeatable:g,onMoveUp:()=>_(n,-1),onMoveDown:()=>_(n,1)})},t.id)),!i&&(0,I.jsx)(`div`,{className:$z.topActions,children:o?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(yb,{size:`xs`,className:$z.linkIdInput,defaultValue:n.linkId,onBlur:e=>m(`linkId`,e.currentTarget.value)}),!i&&(0,I.jsx)(Eg,{size:`xs`,className:$z.typeSelect,defaultValue:n.type,onChange:e=>m(`type`,e.currentTarget.value),data:[{value:`display`,label:`Display`},{value:`boolean`,label:`Boolean`},{value:`decimal`,label:`Decimal`},{value:`integer`,label:`Integer`},{value:`date`,label:`Date`},{value:`dateTime`,label:`Date/Time`},{value:`time`,label:`Time`},{value:`string`,label:`String`},{value:`text`,label:`Text`},{value:`url`,label:`URL`},{value:`choice`,label:`Choice`},{value:`open-choice`,label:`Open Choice`},{value:`attachment`,label:`Attachment`},{value:`reference`,label:`Reference`},{value:`quantity`,label:`Quantity`}]})]}):(0,I.jsx)(`div`,{children:a})}),!r&&(0,I.jsx)(z,{className:$z.movementActions,children:(0,I.jsxs)(z,{className:$z.columnAlignment,children:[!e.isFirst&&(0,I.jsx)(Pd,{href:`#`,onClick:t=>{t.preventDefault(),e.onMoveUp&&e.onMoveUp()},children:(0,I.jsx)(fA,{"data-testid":`up-button`,size:15,className:$z.movementIcons})}),!e.isLast&&(0,I.jsx)(Pd,{href:`#`,onClick:t=>{t.preventDefault(),e.onMoveDown&&e.onMoveDown()},children:(0,I.jsx)(dA,{"data-testid":`down-button`,size:15,className:$z.movementIcons})})]})}),(0,I.jsxs)(`div`,{className:$z.bottomActions,children:[i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Pd,{href:`#`,onClick:e=>{e.preventDefault(),f({id:cB(),linkId:sB(`q`),type:`string`,text:`Question`})},children:`Add item`}),(0,I.jsx)(Pd,{href:`#`,onClick:e=>{e.preventDefault(),f({id:cB(),linkId:sB(`g`),type:`group`,text:`Group`},!0)},children:`Add group`})]}),r&&(0,I.jsx)(Pd,{href:`#`,onClick:e=>{e.preventDefault(),f(fB(),!0)},children:`Add Page`}),o&&!r&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Pd,{href:`#`,onClick:t=>{t.preventDefault(),e.onRepeatable&&e.onRepeatable(n)},children:n.repeats?`Remove Repeatable`:`Make Repeatable`}),(0,I.jsx)(Pd,{href:`#`,onClick:t=>{t.preventDefault(),e.onRemove&&e.onRemove()},children:`Remove`})]})]})]})}function nB(e){let t=Bw(`QuestionnaireItemAnswerOption`,`value[x]`),n=e.item.answerOption??[];return(0,I.jsxs)(`div`,{children:[e.item.answerValueSet===void 0?(0,I.jsx)(rB,{options:n,property:t,item:e.item,onChange:e.onChange}):(0,I.jsx)(yb,{placeholder:`Enter Value Set`,defaultValue:e.item.answerValueSet,onChange:t=>e.onChange({...e.item,answerValueSet:t.target.value})}),(0,I.jsxs)(z,{display:`flex`,children:[(0,I.jsx)(Pd,{href:`#`,onClick:t=>{Rj(t),e.onChange({...e.item,answerValueSet:void 0,answerOption:[...n,{id:cB()}]})},children:`Add choice`}),(0,I.jsx)(Cy,{w:`lg`}),(0,I.jsx)(Pd,{href:`#`,onClick:t=>{Rj(t),e.onChange({...e.item,answerOption:[],answerValueSet:``})},children:`Add value set`})]})]})}function rB(e){return(0,I.jsx)(`div`,{children:e.options.map(t=>{let[n,r]=aF({type:`QuestionnaireItemAnswerOption`,value:t},`value`);return(0,I.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`,width:`80%`},children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(TI,{name:`value[x]`,path:`Questionnaire.answerOption.value[x]`,property:e.property,defaultPropertyType:r,defaultValue:n,onChange:(n,r)=>{let i=[...e.options],a=i.findIndex(e=>e.id===t.id);i[a]={id:t.id,[r]:n},e.onChange({...e.item,answerOption:i})},outcome:void 0},t.id)}),(0,I.jsx)(`div`,{children:(0,I.jsx)(Pd,{href:`#`,onClick:n=>{Rj(n),e.onChange({...e.item,answerOption:e.options.filter(e=>e.id!==t.id)})},children:`Remove`})})]},t.id)})})}function iB(e){let t=kk(e.item)??[];return(0,I.jsxs)(I.Fragment,{children:[t.map((n,r)=>(0,I.jsxs)(V,{children:[(0,I.jsx)(IN,{name:`resourceType`,placeholder:`Resource Type`,defaultValue:n,onChange:r=>{e.onChange(Ak(e.item,t.map(e=>e===n?r:e)))}}),(0,I.jsx)(Pd,{href:`#`,onClick:r=>{Rj(r),e.onChange(Ak(e.item,t.filter(e=>e!==n)))},children:`Remove`})]},`${n}-${r}`)),(0,I.jsx)(Pd,{href:`#`,onClick:n=>{Rj(n),e.onChange(Ak(e.item,[...t,``]))},children:`Add Resource Type`})]})}var aB=1,oB=1;function sB(e){return e+ aB++}function cB(){return`id-`+ oB++}function lB(e){return{...e,id:e.id||cB(),item:uB(e.item)}}function uB(e){if(e)return e.forEach(e=>{e.id?.match(/^id-\d+$/)&&(oB=Math.max(oB,Number.parseInt(e.id.substring(3),10)+1)),e.linkId?.match(/^q\d+$/)&&(aB=Math.max(aB,Number.parseInt(e.linkId.substring(1),10)+1))}),e.map(e=>({...e,id:e.id||cB(),item:uB(e.item),answerOption:dB(e.answerOption)}))}function dB(e){if(e)return e.map(e=>({...e,id:e.id||cB()}))}function fB(){return{id:cB(),linkId:sB(`s`),type:`group`,text:`New Page`,extension:[{url:ak,valueCodeableConcept:{coding:[{system:`http://hl7.org/fhir/questionnaire-item-control`,code:`page`}]}}]}}function pB(e,t,n){let r=e??[],i=t+n;if(i<0||i>=r.length)return r;let a=[...r];return[a[t],a[i]]=[a[i],a[t]],a}var mB={section:`_section_4m5it_1`},hB=[`gender`,`age`,`gestationalAge`,`context`,`appliesTo`,`category`],gB={definition:{resourceType:`ObservationDefinition`,code:{text:``}},onSubmit:()=>{}};function _B(e){e=Object.assign(gB,e);let t=e.definition,[n,r]=(0,b.useState)([]),[i,a]=(0,b.useState)(1),[o,s]=(0,b.useState)(1);return(0,b.useEffect)(()=>{r(xB(bB(t,s).qualifiedInterval||[],a))},[t]),(0,I.jsxs)(CN,{testid:`reference-range-editor`,onSubmit:c,children:[(0,I.jsx)(G,{children:n.map(e=>(0,I.jsx)(vB,{unit:CB(t.quantitativeDetails?.unit),onChange:d,onAdd:f,onRemove:p,onRemoveGroup:u,intervalGroup:e},`group-${e.id}`))}),(0,I.jsx)(gu,{title:`Add Group`,variant:`subtle`,size:`sm`,onClick:e=>{Rj(e),l({id:`group-id-${i}`,filters:{},intervals:[]}),a(e=>e+1)},children:(0,I.jsx)(kA,{})}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(wN,{children:`Save`})})]});function c(){let r=n.flatMap(e=>e.intervals).filter(e=>!wB(e));e.onSubmit({...t,qualifiedInterval:r})}function l(e){r(t=>[...t,e])}function u(e){r(t=>t.filter(t=>t.id!==e.id))}function d(e,t){r(n=>{n=[...n];let r=n.find(t=>t.id===e),i=r?.intervals.findIndex(e=>e.id===t.id);return i!==void 0&&r?.intervals[i]&&(r.intervals[i]=t),n})}function f(e,t){t.id===void 0&&(t.id=`id-${o}`,s(e=>e+1)),r(n=>{n=[...n];let r=n.findIndex(t=>t.id===e);if(r!==-1){let e={...n[r]};t={...t,...e.filters},e.intervals=[...e.intervals,t],n[r]=e}return n})}function p(e,t){r(n=>{n=[...n];let r=n.find(t=>t.id===e);return r&&(r.intervals=r.intervals.filter(e=>e.id!==t.id)),n})}}function vB(e){let{intervalGroup:t,unit:n}=e;return(0,I.jsx)(hP,{"data-testid":t.id,className:mB.section,children:(0,I.jsxs)(G,{gap:`lg`,children:[(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(gu,{title:`Remove Group`,variant:`subtle`,"data-testid":`remove-group-button-${t.id}`,size:`sm`,onClick:n=>{Rj(n),e.onRemoveGroup(t)},children:(0,I.jsx)(OA,{})},`remove-group-button-${t.id}`)}),(0,I.jsx)(yB,{intervalGroup:t,onChange:e.onChange}),(0,I.jsx)(dm,{}),t.intervals.map(n=>(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsxs)(V,{children:[(0,I.jsx)(yb,{"data-testid":`condition-${n.id}`,defaultValue:n.condition,label:`Condition: `,size:`sm`,onChange:r=>{Rj(r),e.onChange(t.id,{...n,condition:r.currentTarget.value.trim()})}},`condition-${n.id}`),(0,I.jsx)(gu,{title:`Remove Interval`,variant:`subtle`,size:`sm`,"data-testid":`remove-interval-${n.id}`,onClick:r=>{Rj(r),e.onRemove(t.id,n)},children:(0,I.jsx)(OA,{})},`remove-interval-${n.id}`)]}),(0,I.jsx)($F,{path:``,onChange:r=>{e.onChange(t.id,{...n,range:r})},name:`range-${n.id}`,defaultValue:n.range},`range-${n.id}`)]},`interval-${n.id}`)),(0,I.jsx)(gu,{title:`Add Interval`,variant:`subtle`,size:`sm`,onClick:r=>{Rj(r),e.onAdd(t.id,{range:{low:{unit:n},high:{unit:n}}})},children:(0,I.jsx)(kA,{})})]})})}function yB(e){let{intervalGroup:t,onChange:n}=e,r=t.filters.age??{},i={low:r.low?.unit?r.low:{...r.low,unit:`years`,system:`http://unitsofmeasure.org`},high:r.high?.unit?r.high:{...r.high,unit:`years`,system:`http://unitsofmeasure.org`}};return(0,I.jsxs)(G,{style:{maxWidth:`50%`},children:[(0,I.jsx)(V,{children:(0,I.jsx)(Eg,{data:[``,`male`,`female`],label:`Gender:`,defaultValue:t.filters.gender||``,onChange:e=>{for(let r of t.intervals){let i=e.currentTarget.value;i===``&&(i=void 0),n(t.id,{...r,gender:i})}}})}),(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(H,{component:`label`,htmlFor:`div-age-${t.id}`,children:`Age:`}),(0,I.jsx)(`div`,{id:`div-age-${t.id}`,children:(0,I.jsx)($F,{path:``,name:`age-${t.id}`,defaultValue:i,onChange:e=>{for(let r of t.intervals)n(t.id,{...r,age:e})}},`age-${t.id}`)})]}),(0,I.jsx)(Eg,{data:[``,`pre-puberty`,`follicular`,`midcycle`,`luteal`,`postmenopausal`],label:`Endocrine:`,defaultValue:t.filters.context?.text||``,onChange:e=>{for(let r of t.intervals){let i=e.currentTarget.value;i===``?(i=void 0,n(t.id,{...r,context:void 0})):n(t.id,{...r,context:{text:i,coding:[{code:i,system:`http://terminology.hl7.org/CodeSystem/referencerange-meaning`}]}})}}}),(0,I.jsx)(Eg,{data:[``,`reference`,`critical`,`absolute`],label:`Category: `,defaultValue:t.filters.category,onChange:e=>{for(let r of t.intervals){let i=e.currentTarget.value;i===``?n(t.id,{...r,category:void 0}):n(t.id,{...r,category:i})}}})]})}function bB(e,t){let n=e.qualifiedInterval||[],r=Math.max(...n.map(e=>{let t=Number.parseInt(e.id?.substring(3)||``,10);return Number.isNaN(t)?-1/0:t}))+1;return Number.isFinite(r)||(r=1),e={...e,qualifiedInterval:n.map(e=>({...e,id:e.id||`id-${r++}`}))},t(r),e}function xB(e,t){let n=1,r={};for(let t of e){let e=SB(t);e in r||(r[e]={id:`group-id-${n++}`,filters:Object.fromEntries(hB.map(e=>[e,t[e]])),intervals:[]}),r[e].intervals.push(t)}return t(n),Object.values(r)}function SB(e){return[`gender=${e.gender}`,`age=${yw(e.age)}`,`gestationalAge=${yw(e.gestationalAge)}`,`context=${e.context?.text}`,`appliesTo=${e.appliesTo?.map(e=>e.text).join(`+`)}`,`category=${e.category}`].join(`:`)}function CB(e){return e&&(KC(e,`http://unitsofmeasure.org`)||e.text)}function wB(e){return e.range?.low?.value===void 0&&e.range?.high?.value===void 0}function TB(e){let t=Z(),n=nk(e.value),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)();if((0,b.useEffect)(()=>{n&&!r&&(t.executeBatch(s(n)).then(o).catch(console.log),i(!0))},[t,n,r]),!n||!a)return null;return(0,I.jsx)(Tm,{children:n.action?.map((t,n)=>{let r=t.resource&&c(t.resource),i=r?.input?.[0]?.valueReference,a=r?.output?.[0]?.valueReference;return(0,I.jsxs)(b.Fragment,{children:[(0,I.jsx)(Tm.Col,{span:1,p:`md`,children:r?.status===`completed`?(0,I.jsx)(TA,{}):(0,I.jsx)(Sj,{color:`gray`})}),(0,I.jsxs)(Tm.Col,{span:9,p:`xs`,children:[(0,I.jsx)(H,{fw:500,children:t.title}),t.description&&(0,I.jsx)(`div`,{children:t.description}),(0,I.jsxs)(`div`,{children:[`Last edited by\xA0`,(0,I.jsx)(dL,{value:r?.meta?.author}),`\xA0on\xA0`,fw(r?.meta?.lastUpdated)]}),(0,I.jsxs)(`div`,{children:[`Status: `,(0,I.jsx)(cL,{status:r?.status||`unknown`})]})]}),(0,I.jsxs)(Tm.Col,{span:2,p:`md`,children:[i&&!a&&(0,I.jsx)(U,{onClick:()=>e.onStart(r,i),children:`Start`}),i&&a&&(0,I.jsx)(U,{onClick:()=>e.onEdit(r,i,a),children:`Edit`})]})]},`action-${n}`)})});function s(e){let t=[];if(e.action)for(let n of e.action)n.resource?.reference&&t.push({request:{method:`GET`,url:n.resource.reference}});return{resourceType:`Bundle`,type:`batch`,entry:t}}function c(e){for(let t of a?.entry??[])if(t.resource&&e.reference===oC(t.resource))return t.resource}}function EB(e,t){return OB(DB(e,t),e,t)}function DB(e,t){let n=e.length,r=t.length,i=n+r+1,a=1+2*i,o=Math.trunc(a/2),s=Array(a);s[o+1]={i:0,j:-1,prev:void 0,snake:!0};for(let a=0;a<i;a++){for(let i=-a;i<=a;i+=2){let c=o+i,l=c+1,u=c-1,d=s[l],f=s[u],p,m=0;i===-a||i!==a&&f.i<d.i?(m=d.i,p=d):(m=f.i+1,p=f),s[u]=void 0;let h=m-i,g={i:m,j:h,prev:kB(p),snake:!1};for(;m<n&&h<r&&e[m]===t[h];)m++,h++;if(m>g.i&&(g={i:m,j:h,prev:g,snake:!0}),s[c]=g,m>=n&&h>=r)return s[c]}s[o+a-1]=void 0}}function OB(e,t,n){let r=[],i=e;for(i.snake&&(i=i.prev);i?.prev&&i.prev.j>=0;){let e=i.i,a=i.j;i=i.prev;let o=i.i,s=i.j,c={position:o,lines:t.slice(o,e)},l={position:s,lines:n.slice(s,a)},u;u=c.lines.length===0&&l.lines.length>0?`insert`:c.lines.length>0&&l.lines.length===0?`delete`:`change`,r.push({original:c,revised:l,type:u}),i.snake&&(i=i.prev)}return r}function kB(e){return e&&!e.snake&&e.prev?e.prev:e}function AB(e){let t=(e.entry??[]).filter(e=>!!e.resource).map(e=>({meta:e.resource?.meta,lines:yC(e.resource,!0).match(/[^\r\n]+/g)})).sort((e,t)=>e.meta.lastUpdated.localeCompare(t.meta.lastUpdated));if(!t.length)return[];let n=t[0].lines.map(e=>({id:t[0].meta.versionId,meta:t[0].meta,value:e,span:1}));return jB(n,t),MB(n),n}function jB(e,t){for(let n=1;n<t.length;n++){let r=EB(t[n-1].lines,t[n].lines);for(let i of r){let r=i.original.position,a=i.original.lines,o=i.revised.lines;if((i.type===`delete`||i.type===`change`)&&e.splice(r,a.length),i.type===`insert`||i.type===`change`)for(let a=0;a<i.revised.lines.length;a++)e.splice(r+a,0,{id:t[n].meta.versionId,meta:t[n].meta,value:o[a],span:1})}}}function MB(e){let t=0;for(;t<e.length;){let n=t;for(;n<e.length&&e[n].id===e[t].id;)e[n].span=-1,n++;e[t].span=n-t,t=n}}var NB={container:`_container_1gji2_1`,root:`_root_1gji2_5`,startRow:`_startRow_1gji2_20`,normalRow:`_normalRow_1gji2_25`,author:`_author_1gji2_30`,onBehalfOf:`_onBehalfOf_1gji2_34`,dateTime:`_dateTime_1gji2_40`,lineNumber:`_lineNumber_1gji2_46`,line:`_line_1gji2_46`,pre:`_pre_1gji2_61`};function PB(e,t){return`/${e.resourceType}/${e.id}/_history/${t}`}function FB(e){let t=Math.floor((Date.now()-Date.parse(e))/1e3),n=Math.floor(t/31536e3);if(n>0)return IB(n,`year`);let r=Math.floor(t/2592e3);if(r>0)return IB(r,`month`);let i=Math.floor(t/86400);if(i>0)return IB(i,`day`);let a=Math.floor(t/3600);if(a>0)return IB(a,`hour`);let o=Math.floor(t/60);return o>0?IB(o,`minute`):IB(t,`second`)}function IB(e,t){return`${e} ${e===1?t:t+`s`} ago`}function LB(e){let t=Z(),[n,r]=(0,b.useState)(e.history);if((0,b.useEffect)(()=>{!e.history&&e.resourceType&&e.id&&t.readHistory(e.resourceType,e.id).then(r).catch(console.log)},[t,e.history,e.resourceType,e.id]),!n)return(0,I.jsx)(`div`,{children:`Loading...`});let i=n.entry?.[0]?.resource;if(!i)return null;let a=AB(n);return(0,I.jsx)(`div`,{className:NB.container,children:(0,I.jsx)(`table`,{className:NB.root,children:(0,I.jsx)(`tbody`,{children:a.map((e,t)=>(0,I.jsxs)(`tr`,{className:e.span>0?NB.startRow:NB.normalRow,children:[e.span>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`td`,{className:NB.author,rowSpan:e.span,children:[(0,I.jsx)(dL,{value:e.meta.author,link:!0,fz:`xs`}),e.meta.onBehalfOf&&(0,I.jsxs)(`div`,{className:NB.onBehalfOf,children:[`on behalf of `,(0,I.jsx)(dL,{value:e.meta.onBehalfOf,link:!0,fz:`xs`,c:`dimmed`})]})]}),(0,I.jsx)(`td`,{className:NB.dateTime,rowSpan:e.span,children:(0,I.jsx)(Wj,{to:PB(i,e.meta.versionId),fz:`xs`,children:FB(e.meta.lastUpdated)})})]}),(0,I.jsx)(`td`,{className:NB.lineNumber,children:t+1}),(0,I.jsx)(`td`,{className:NB.line,children:(0,I.jsx)(`pre`,{className:NB.pre,children:e.value})})]},`row-`+t))})})})}var RB={removed:`_removed_el5zk_1`,added:`_added_el5zk_6`};function zB(e){let t=e.original,n=e.revised;return e.ignoreMeta&&(t={...t,meta:void 0},n={...n,meta:void 0}),(0,I.jsx)(`pre`,{style:{color:`gray`},children:EB(yC(t,!0).match(/[^\r\n]+/g)??[`{`,`}`],yC(n,!0).match(/[^\r\n]+/g)??[`{`,`}`]).map((e,t)=>(0,I.jsx)(BB,{delta:e},`delta`+t))})}function BB(e){return(0,I.jsxs)(I.Fragment,{children:[`...`,(0,I.jsx)(`br`,{}),e.delta.original.lines.length>0&&(0,I.jsx)(`div`,{className:RB.removed,children:e.delta.original.lines.join(`
207
- `)}),e.delta.revised.lines.length>0&&(0,I.jsx)(`div`,{className:RB.added,children:e.delta.revised.lines.join(`
208
- `)}),`...`,(0,I.jsx)(`br`,{})]})}var VB={splitButton:`_splitButton_1i0gi_1`,menuControl:`_menuControl_1i0gi_6`};function HB(e){let{outcome:t}=e,n=Z(),r=nk(e.defaultValue),i=r?.resourceType,[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(),l=n.getAccessPolicy(),u=Sr();(0,b.useEffect)(()=>{if(r)if(e.profileUrl){let t=e.profileUrl;n.requestProfileSchema(e.profileUrl,{expandProfile:!0}).then(()=>{let e=gS(t);e?(o(!0),c(gO(r,e))):console.error(`Schema not found for ${t}`)}).catch(e=>{console.error(`Error in requestProfileSchema`,e)})}else n.requestSchema(i).then(()=>{c(r),o(!0)}).catch(console.log)},[n,r,i,e.profileUrl]);let d=(0,b.useMemo)(()=>r&&ME(r,OE.READ,l),[l,r]),f=(0,b.useMemo)(()=>n.isSuperAdmin()||!l||!wC(s?.resourceType)?!0:AE(l,s?.resourceType),[n,l,s?.resourceType]);return!a||!s?(0,I.jsx)(`div`,{children:`Loading...`}):f?(0,I.jsxs)(`form`,{noValidate:!0,autoComplete:`off`,onSubmit:t=>{t.preventDefault(),e.onSubmit&&e.onSubmit(s)},children:[(0,I.jsxs)(G,{mb:`xl`,children:[(0,I.jsx)(AF,{title:`Resource Type`,htmlFor:`resourceType`,outcome:t,children:(0,I.jsx)(yb,{name:`resourceType`,defaultValue:s.resourceType,disabled:!0})}),(0,I.jsx)(AF,{title:`ID`,htmlFor:`id`,outcome:t,children:(0,I.jsx)(yb,{name:`id`,defaultValue:s.id,disabled:!0})})]}),(0,I.jsx)(MI,{path:s.resourceType,valuePath:s.resourceType,typeName:i,defaultValue:s,outcome:t,onChange:c,profileUrl:e.profileUrl,accessPolicyResource:d}),(0,I.jsxs)(V,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,gap:0,children:[(0,I.jsx)(U,{type:`submit`,className:Mn((e.onPatch||e.onDelete)&&VB.splitButton),children:r?.id?`Update`:`Create`}),(e.onPatch||e.onDelete)&&(0,I.jsxs)(W,{transitionProps:{transition:`pop`},position:`bottom-end`,withinPortal:!0,children:[(0,I.jsx)(W.Target,{children:(0,I.jsx)(gu,{variant:`filled`,color:u.primaryColor,size:36,className:VB.menuControl,"aria-label":`More actions`,children:(0,I.jsx)(EA,{size:14,stroke:1.5})})}),(0,I.jsxs)(W.Dropdown,{children:[e.onPatch&&(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(RA,{size:14,stroke:1.5}),onClick:()=>{e.onPatch(s)},children:`Patch`}),e.onDelete&&(0,I.jsx)(W.Item,{color:`red`,leftSection:(0,I.jsx)(kj,{size:14,stroke:1.5,color:`red`}),onClick:()=>{e.onDelete(s)},children:`Delete`})]})]})]})]}):(0,I.jsxs)(Dd,{color:`red`,title:`Permission denied`,icon:(0,I.jsx)(uA,{}),children:[`Your access level prevents you from editing and creating `,s.resourceType,` resources.`]})}function UB(e){let t=Z(),[n,r]=(0,b.useState)(e.history);return(0,b.useEffect)(()=>{!e.history&&e.resourceType&&e.id&&t.readHistory(e.resourceType,e.id).then(r).catch(console.log)},[t,e.history,e.resourceType,e.id]),n?(0,I.jsxs)(K,{withTableBorder:!0,withRowBorders:!0,withColumnBorders:!0,children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:`Author`}),(0,I.jsx)(K.Th,{children:`On Behalf Of`}),(0,I.jsx)(K.Th,{children:`Date`}),(0,I.jsx)(K.Th,{children:`Version`})]})}),(0,I.jsx)(K.Tbody,{children:n.entry?.map((e,t)=>(0,I.jsx)(WB,{entry:e},`entry-`+t))})]}):(0,I.jsx)(`div`,{children:`Loading...`})}function WB(e){let{response:t,resource:n}=e.entry;return n?(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:(0,I.jsx)(fL,{value:n.meta?.author,link:!0})}),(0,I.jsx)(K.Td,{children:n.meta?.onBehalfOf&&(0,I.jsx)(fL,{value:n.meta.onBehalfOf,link:!0})}),(0,I.jsx)(K.Td,{children:fw(n.meta?.lastUpdated)}),(0,I.jsx)(K.Td,{children:(0,I.jsx)(Wj,{to:GB(n),children:n.meta?.versionId})})]}):(0,I.jsx)(K.Tr,{children:(0,I.jsx)(K.Td,{colSpan:4,children:Qx(t?.outcome)})})}function GB(e){return`/${e.resourceType}/${e.id}/_history/${e.meta?.versionId}`}var KB=`modulepreload`,qB=function(e){return`/`+e},JB={},YB=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=qB(t,n),t in JB)return;JB[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:KB,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},XB=e=>{throw TypeError(e)},ZB=(e,t,n)=>t.has(e)||XB(`Cannot `+n),QB=(e,t,n)=>(ZB(e,t,`read from private field`),n?n.call(e):t.get(e)),$B=(e,t,n)=>t.has(e)?XB(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),eV=(e,t,n,r)=>(ZB(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),tV=`popstate`;function nV(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function rV(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return cV(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:lV(t)}return dV(t,n,null,e)}function iV(e,t){if(e===!1||e==null)throw Error(t)}function aV(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function oV(){return Math.random().toString(36).substring(2,10)}function sV(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function cV(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?uV(t):t,state:n,key:t&&t.key||r||oV(),mask:i}}function lV({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function uV(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function dV(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=nV(e)?e:cV(h.location,e,t);n&&n(r,e),l=u()+1;let d=sV(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=nV(e)?e:cV(h.location,e,t);n&&n(r,e),l=u();let i=sV(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return fV(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(tV,d),c=e,()=>{i.removeEventListener(tV,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function fV(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),iV(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:lV(t);return i=i.replace(/ $/,`%20`),!n&&i.startsWith(`//`)&&(i=r+i),new URL(i,r)}var pV,mV=class{constructor(e){if($B(this,pV,new Map),e)for(let[t,n]of e)this.set(t,n)}get(e){if(QB(this,pV).has(e))return QB(this,pV).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw Error(`No value found for context`)}set(e,t){QB(this,pV).set(e,t)}};pV=new WeakMap;var hV=new Set([`lazy`,`caseSensitive`,`path`,`id`,`index`,`children`]);function gV(e){return hV.has(e)}var _V=new Set([`lazy`,`caseSensitive`,`path`,`id`,`index`,`middleware`,`children`]);function vV(e){return _V.has(e)}function yV(e){return e.index===!0}function bV(e,t,n=[],r={},i=!1){return e.map((e,a)=>{let o=[...n,String(a)],s=typeof e.id==`string`?e.id:o.join(`-`);if(iV(e.index!==!0||!e.children,`Cannot specify children on an index route`),iV(i||!r[s],`Found a route id collision on id "${s}". Route id's must be globally unique within Data Router usages`),yV(e)){let n={...e,id:s};return r[s]=xV(n,t(n)),n}else{let n={...e,id:s,children:void 0};return r[s]=xV(n,t(n)),e.children&&(n.children=bV(e.children,t,o,r,i)),n}})}function xV(e,t){return Object.assign(e,{...t,...typeof t.lazy==`object`&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function SV(e,t,n=`/`){return CV(e,t,n,!1)}function CV(e,t,n,r,i){let a=HV((typeof t==`string`?uV(t):t).pathname||`/`,n);if(a==null)return null;let o=i??TV(e),s=null,c=VV(a);for(let e=0;s==null&&e<o.length;++e)s=RV(o[e],c,r);return s}function wV(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function TV(e){let t=EV(e);return OV(t),t}function EV(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;iV(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=$V([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(iV(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),EV(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:IV(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of DV(e.path))a(e,t,!0,n)}),t}function DV(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=DV(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function OV(e){e.sort((e,t)=>e.score===t.score?LV(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var kV=/^:[\w-]+$/,AV=3,jV=2,MV=1,NV=10,PV=-2,FV=e=>e===`*`;function IV(e,t){let n=e.split(`/`),r=n.length;return n.some(FV)&&(r+=PV),t&&(r+=jV),n.filter(e=>!FV(e)).reduce((e,t)=>e+(kV.test(t)?AV:t===``?MV:NV),r)}function LV(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function RV(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=zV({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=zV({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:$V([a,u.pathname]),pathnameBase:tH($V([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=$V([a,u.pathnameBase]))}return o}function zV(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=BV(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function BV(e,t=!1,n=!0){aV(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function VV(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return aV(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function HV(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}function UV({basename:e,pathname:t}){return t===`/`?e:$V([e,t])}var WV=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,GV=e=>WV.test(e);function KV(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?uV(e):e,a;return n?(n=QV(n),a=n.startsWith(`/`)?qV(n.substring(1),`/`):qV(n,t)):a=t,{pathname:a,search:nH(r),hash:rH(i)}}function qV(e,t){let n=eH(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function JV(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function YV(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function XV(e){let t=YV(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function ZV(e,t,n,r=!1){let i;typeof e==`string`?i=uV(e):(i={...e},iV(!i.pathname||!i.pathname.includes(`?`),JV(`?`,`pathname`,`search`,i)),iV(!i.pathname||!i.pathname.includes(`#`),JV(`#`,`pathname`,`hash`,i)),iV(!i.search||!i.search.includes(`#`),JV(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=KV(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var QV=e=>e.replace(/\/\/+/g,`/`),$V=e=>QV(e.join(`/`)),eH=e=>e.replace(/\/+$/,``),tH=e=>eH(e).replace(/^\/*/,`/`),nH=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,rH=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,iH=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function aH(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function oH(e){return $V(e.map(e=>e.route.path).filter(Boolean))||`/`}var sH=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function cH(e,t){let n=e;if(typeof n!=`string`||!WV.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(sH)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=HV(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{aV(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}var lH=Symbol(`Uninstrumented`);function uH(e,t){let n={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};e.forEach(e=>e({id:t.id,index:t.index,path:t.path,instrument(e){let t=Object.keys(n);for(let r of t)e[r]&&n[r].push(e[r])}}));let r={};if(typeof t.lazy==`function`&&n.lazy.length>0){let e=fH(n.lazy,t.lazy,()=>void 0);e&&(r.lazy=e)}if(typeof t.lazy==`object`){let e=t.lazy;[`middleware`,`loader`,`action`].forEach(t=>{let i=e[t],a=n[`lazy.${t}`];if(typeof i==`function`&&a.length>0){let e=fH(a,i,()=>void 0);e&&(r.lazy=Object.assign(r.lazy||{},{[t]:e}))}})}return[`loader`,`action`].forEach(e=>{let i=t[e];if(typeof i==`function`&&n[e].length>0){let t=i[lH]??i,a=fH(n[e],t,(...e)=>mH(e[0]));a&&(e===`loader`&&t.hydrate===!0&&(a.hydrate=!0),a[lH]=t,r[e]=a)}}),t.middleware&&t.middleware.length>0&&n.middleware.length>0&&(r.middleware=t.middleware.map(e=>{let t=e[lH]??e,r=fH(n.middleware,t,(...e)=>mH(e[0]));return r?(r[lH]=t,r):e})),r}function dH(e,t){let n={navigate:[],fetch:[]};if(t.forEach(e=>e({instrument(e){let t=Object.keys(e);for(let r of t)e[r]&&n[r].push(e[r])}})),n.navigate.length>0){let t=e.navigate[lH]??e.navigate,r=fH(n.navigate,t,(...t)=>{let[n,r]=t;return{to:typeof n==`number`||typeof n==`string`?n:n?lV(n):`.`,...hH(e,r??{})}});r&&(r[lH]=t,e.navigate=r)}if(n.fetch.length>0){let t=e.fetch[lH]??e.fetch,r=fH(n.fetch,t,(...t)=>{let[n,,r,i]=t;return{href:r??`.`,fetcherKey:n,...hH(e,i??{})}});r&&(r[lH]=t,e.fetch=r)}return e}function fH(e,t,n){return e.length===0?null:async(...r)=>{let i=await pH(e,n(...r),()=>t(...r),e.length-1);if(i.type===`error`)throw i.value;return i.value}}async function pH(e,t,n,r){let i=e[r],a;if(i){let o,s=async()=>(o?console.error(`You cannot call instrumented handlers more than once`):o=pH(e,t,n,r-1),a=await o,iV(a,`Expected a result`),a.type===`error`&&a.value instanceof Error?{status:`error`,error:a.value}:{status:`success`,error:void 0});try{await i(s,t)}catch(e){console.error(`An instrumentation function threw an error:`,e)}o||await s(),await o}else try{a={type:`success`,value:await n()}}catch(e){a={type:`error`,value:e}}return a||{type:`error`,value:Error(`No result assigned in instrumentation chain.`)}}function mH(e){let{request:t,context:n,params:r,pattern:i}=e;return{request:gH(t),params:{...r},pattern:i,context:_H(n)}}function hH(e,t){return{currentUrl:lV(e.state.location),...`formMethod`in t?{formMethod:t.formMethod}:{},...`formEncType`in t?{formEncType:t.formEncType}:{},...`formData`in t?{formData:t.formData}:{},...`body`in t?{body:t.body}:{}}}function gH(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function _H(e){if(yH(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var vH=Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function yH(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join(`\0`)===vH}var bH=[`POST`,`PUT`,`PATCH`,`DELETE`],xH=new Set(bH),SH=[`GET`,...bH],CH=new Set(SH),wH=new Set([301,302,303,307,308]),TH=new Set([307,308]),EH={state:`idle`,location:void 0,matches:void 0,historyAction:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},DH={state:`idle`,data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},OH={state:`unblocked`,proceed:void 0,reset:void 0,location:void 0},kH=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),AH=`remix-router-transitions`,jH=Symbol(`ResetLoaderData`),MH,NH,PH,FH,IH=class{constructor(e){$B(this,MH),$B(this,NH),$B(this,PH),$B(this,FH),eV(this,MH,e),eV(this,NH,TV(e))}get stableRoutes(){return QB(this,MH)}get activeRoutes(){return QB(this,PH)??QB(this,MH)}get branches(){return QB(this,FH)??QB(this,NH)}get hasHMRRoutes(){return QB(this,PH)!=null}setRoutes(e){eV(this,MH,e),eV(this,NH,TV(e))}setHmrRoutes(e){eV(this,PH,e),eV(this,FH,TV(e))}commitHmrRoutes(){QB(this,PH)&&(eV(this,MH,QB(this,PH)),eV(this,NH,QB(this,FH)),eV(this,PH,void 0),eV(this,FH,void 0))}};MH=new WeakMap,NH=new WeakMap,PH=new WeakMap,FH=new WeakMap;function LH(e){let t=e.window?e.window:typeof window<`u`?window:void 0,n=t!==void 0&&t.document!==void 0&&t.document.createElement!==void 0;iV(e.routes.length>0,`You must provide a non-empty routes array to createRouter`);let r=e.hydrationRouteProperties||[],i=e.mapRouteProperties||kH,a=i;if(e.instrumentations){let t=e.instrumentations;a=e=>({...i(e),...uH(t.map(e=>e.route).filter(Boolean),e)})}let o={},s=new IH(bV(e.routes,a,void 0,o)),c=e.basename||`/`;c.startsWith(`/`)||(c=`/${c}`);let l=e.dataStrategy||eU,u={...e.future},d=null,f=new Set,p=null,m=null,h=null,g=null,_=e.hydrationData!=null,v=CV(s.activeRoutes,e.history.location,c,!1,s.branches),y=!1,b=null,x,S;if(v==null&&!e.patchRoutesOnNavigation){let t=wU(404,{pathname:e.history.location.pathname}),{matches:n,route:r}=CU(s.activeRoutes);x=!0,S=!x,v=n,b={[r.id]:t}}else if(v&&!e.hydrationData&&F(v,s.activeRoutes,e.history.location.pathname).active&&(v=null),!v){x=!1,S=!x,v=[];let t=F(null,s.activeRoutes,e.history.location.pathname);t.active&&t.matches&&(y=!0,v=t.matches)}else if(v.some(e=>e.route.lazy))x=!1,S=!x;else if(!v.some(e=>HH(e.route)))x=!0,S=!x;else{let t=e.hydrationData?e.hydrationData.loaderData:null,n=e.hydrationData?e.hydrationData.errors:null,r=v;if(n){let e=v.findIndex(e=>n[e.route.id]!==void 0);r=r.slice(0,e+1)}S=!1,x=!0,r.forEach(e=>{let r=UH(e.route,t,n);S||=r.renderFallback,x&&=!r.shouldLoad})}let C,w={historyAction:e.history.action,location:e.history.location,matches:v,initialized:x,renderFallback:S,navigation:EH,restoreScrollPosition:e.hydrationData==null?null:!1,preventScrollReset:!1,revalidation:`idle`,loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||b,fetchers:new Map,blockers:new Map},T=`POP`,E=null,D=!1,O,k=!1,A=new Map,j=null,M=!1,ee=!1,N=new Set,P=new Map,te=0,ne=-1,re=new Map,ie=new Set,ae=new Map,oe=new Map,se=new Set,ce=new Map,le,ue=null;function de(){if(d=e.history.listen(({action:t,location:n,delta:r})=>{if(le){le(),le=void 0;return}aV(ce.size===0||r!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let i=Ue({currentLocation:w.location,nextLocation:n,historyAction:t});if(i&&r!=null){let t=new Promise(e=>{le=e});e.history.go(r*-1),He(i,{state:`blocked`,location:n,proceed(){He(i,{state:`proceeding`,proceed:void 0,reset:void 0,location:n}),t.then(()=>e.history.go(r))},reset(){let e=new Map(w.blockers);e.set(i,OH),me({blockers:e})}}),E?.resolve(),E=null;return}return ve(t,n)}),n){JU(t,A);let e=()=>YU(t,A);t.addEventListener(`pagehide`,e),j=()=>t.removeEventListener(`pagehide`,e)}return w.initialized||ve(`POP`,w.location,{initialHydration:!0}),C}function fe(){d&&d(),j&&j(),f.clear(),O&&O.abort(),w.fetchers.forEach((e,t)=>Pe(w.fetchers,t)),w.blockers.forEach((e,t)=>Ve(t))}function pe(e){if(f.add(e),p){let{newErrors:t}=p;p=null,e(w,{deletedFetchers:[],newErrors:t,viewTransitionOpts:void 0,flushSync:!1})}return()=>f.delete(e)}function me(e,t={}){e.matches&&=e.matches.map(e=>{let t=o[e.route.id],n=e.route;return n.element!==t.element||n.errorElement!==t.errorElement||n.hydrateFallbackElement!==t.hydrateFallbackElement?{...e,route:t}:e}),w={...w,...e};let n=[],r=[];w.fetchers.forEach((e,t)=>{e.state===`idle`&&(se.has(t)?n.push(t):r.push(t))}),se.forEach(e=>{!w.fetchers.has(e)&&!P.has(e)&&n.push(e)}),f.size===0&&(p={newErrors:e.errors??null}),[...f].forEach(r=>r(w,{deletedFetchers:n,newErrors:e.errors??null,viewTransitionOpts:t.viewTransitionOpts,flushSync:t.flushSync===!0})),n.forEach(e=>Pe(w.fetchers,e)),r.forEach(e=>w.fetchers.delete(e))}function he(t,n,{flushSync:r}={}){let i=w.actionData!=null&&w.navigation.formMethod!=null&&zU(w.navigation.formMethod)&&w.navigation.state===`loading`&&t.state?._isRedirect!==!0,a;a=n.actionData?Object.keys(n.actionData).length>0?n.actionData:null:i?w.actionData:null;let o=n.loaderData?bU(w.loaderData,n.loaderData,n.matches||[],n.errors):w.loaderData,c=w.blockers;c.size>0&&(c=new Map(c),c.forEach((e,t)=>c.set(t,OH)));let l=M?!1:Je(t,n.matches||w.matches),u=D===!0||w.navigation.formMethod!=null&&zU(w.navigation.formMethod)&&t.state?._isRedirect!==!0;s.commitHmrRoutes(),M||T===`POP`||(T===`PUSH`?e.history.push(t,t.state):T===`REPLACE`&&e.history.replace(t,t.state));let d;if(T===`POP`){let e=A.get(w.location.pathname);e&&e.has(t.pathname)?d={currentLocation:w.location,nextLocation:t}:A.has(t.pathname)&&(d={currentLocation:t,nextLocation:w.location})}else if(k){let e=A.get(w.location.pathname);e?e.add(t.pathname):(e=new Set([t.pathname]),A.set(w.location.pathname,e)),d={currentLocation:w.location,nextLocation:t}}me({...n,actionData:a,loaderData:o,historyAction:T,location:t,initialized:!0,renderFallback:!1,navigation:EH,revalidation:`idle`,restoreScrollPosition:l,preventScrollReset:u,blockers:c},{viewTransitionOpts:d,flushSync:r===!0}),T=`POP`,D=!1,k=!1,M=!1,ee=!1,E?.resolve(),E=null,ue?.resolve(),ue=null}async function ge(t,n){if(E?.resolve(),E=null,typeof t==`number`){E||=XU();let n=E.promise;return e.history.go(t),n}let{path:r,submission:i,error:a}=BH(!1,zH(w.location,w.matches,c,t,n?.fromRouteId,n?.relative),n),o;n?.mask&&(o={pathname:``,search:``,hash:``,...typeof n.mask==`string`?uV(n.mask):{...w.location.mask,...n.mask}});let s=w.location,l=cV(s,r,n&&n.state,void 0,o);l={...l,...e.history.encodeLocation(l)};let u=n&&n.replace!=null?n.replace:void 0,d=`PUSH`;u===!0?d=`REPLACE`:u===!1||i!=null&&zU(i.formMethod)&&i.formAction===w.location.pathname+w.location.search&&(d=`REPLACE`);let f=n&&`preventScrollReset`in n?n.preventScrollReset===!0:void 0,p=(n&&n.flushSync)===!0,m=Ue({currentLocation:s,nextLocation:l,historyAction:d});if(m){He(m,{state:`blocked`,location:l,proceed(){He(m,{state:`proceeding`,proceed:void 0,reset:void 0,location:l}),ge(t,n)},reset(){let e=new Map(w.blockers);e.set(m,OH),me({blockers:e})}});return}await ve(d,l,{submission:i,pendingError:a,preventScrollReset:f,replace:n&&n.replace,enableViewTransition:n&&n.viewTransition,flushSync:p,callSiteDefaultShouldRevalidate:n&&n.defaultShouldRevalidate})}function _e(){ue||=XU(),ke(),me({revalidation:`loading`});let e=ue.promise;return w.navigation.state===`submitting`?e:w.navigation.state===`idle`?(ve(w.historyAction,w.location,{startUninterruptedRevalidation:!0}),e):(ve(T||w.historyAction,w.navigation.location,{overrideNavigation:w.navigation,enableViewTransition:k===!0}),e)}async function ve(t,n,r){O&&O.abort(),O=null,T=t,M=(r&&r.startUninterruptedRevalidation)===!0,qe(w.location,w.matches),D=(r&&r.preventScrollReset)===!0,k=(r&&r.enableViewTransition)===!0;let i=s.activeRoutes,a=r?.initialHydration&&w.matches&&w.matches.length>0&&!y?w.matches:CV(i,n,c,!1,s.branches),o=(r&&r.flushSync)===!0;if(a&&w.initialized&&!ee&&DU(w.location,n)&&!(r&&r.submission&&zU(r.submission.formMethod))){he(n,{matches:a},{flushSync:o});return}let l=F(a,i,n.pathname);if(l.active&&l.matches&&(a=l.matches),!a){let{error:e,notFoundMatches:t,route:r}=We(n.pathname);he(n,{matches:t,loaderData:{},errors:{[r.id]:e}},{flushSync:o});return}let u=r&&r.overrideNavigation?{...r.overrideNavigation,matches:a,historyAction:t}:void 0;O=new AbortController;let d=mU(e.history,n,O.signal,r&&r.submission),f=e.getContext?await e.getContext():new mV,p;if(r&&r.pendingError)p=[SU(a).route.id,{type:`error`,error:r.pendingError}];else if(r&&r.submission&&zU(r.submission.formMethod)){let i=await ye(d,n,r.submission,a,t,f,l.active,r&&r.initialHydration===!0,{replace:r.replace,flushSync:o});if(i.shortCircuited)return;if(i.pendingActionResult){let[e,t]=i.pendingActionResult;if(MU(t)&&aH(t.error)&&t.error.status===404){O=null,he(n,{matches:i.matches,loaderData:{},errors:{[e]:t.error}});return}}a=i.matches||a,p=i.pendingActionResult,u=UU(n,a,t,r.submission),o=!1,l.active=!1,d=mU(e.history,d.url,d.signal)}let{shortCircuited:m,matches:h,loaderData:g,errors:_,workingFetchers:v}=await be(d,n,a,t,f,l.active,u,r&&r.submission,r&&r.fetcherSubmission,r&&r.replace,r&&r.initialHydration===!0,o,p,r&&r.callSiteDefaultShouldRevalidate);m||(O=null,he(n,{matches:h||a,...xU(p),loaderData:g,errors:_,...v?{fetchers:v}:{}}))}async function ye(t,n,i,l,u,d,f,p,m={}){if(ke(),me({navigation:WU(n,l,u,i)},{flushSync:m.flushSync===!0}),f){let e=await Ye(l,n.pathname,t.signal);if(e.type===`aborted`)return{shortCircuited:!0};if(e.type===`error`){if(e.partialMatches.length===0){let{matches:t,route:n}=CU(s.activeRoutes);return{matches:t,pendingActionResult:[n.id,{type:`error`,error:e.error}]}}let t=SU(e.partialMatches).route.id;return{matches:e.partialMatches,pendingActionResult:[t,{type:`error`,error:e.error}]}}else if(e.matches)l=e.matches;else{let{notFoundMatches:e,error:t,route:r}=We(n.pathname);return{matches:e,pendingActionResult:[r.id,{type:`error`,error:t}]}}}let h,g=VU(l,n);if(!g.route.action&&!g.route.lazy)h={type:`error`,error:wU(405,{method:t.method,pathname:n.pathname,routeId:g.route.id})};else{let e=await De(t,n,oU(a,o,t,n,l,g,p?[]:r,d),d,null);if(h=e[g.route.id],!h){for(let t of l)if(e[t.route.id]){h=e[t.route.id];break}}if(t.signal.aborted)return{shortCircuited:!0}}if(NU(h)){let n;return n=m&&m.replace!=null?m.replace:pU(h.response.headers.get(`Location`),new URL(t.url),c,e.history)===w.location.pathname+w.location.search,await Ee(t,h,!0,{submission:i,replace:n}),{shortCircuited:!0}}if(MU(h)){let e=SU(l,g.route.id);return(m&&m.replace)!==!0&&(T=`PUSH`),{matches:l,pendingActionResult:[e.route.id,h,g.route.id]}}return{matches:l,pendingActionResult:[g.route.id,h]}}async function be(t,n,i,l,u,d,f,p,m,h,g,_,v,y){let b=f||UU(n,i,l,p),x=p||m||HU(b),S=!M&&!g;if(d){if(S){let e=xe(v);me({navigation:b,...e===void 0?{}:{actionData:e}},{flushSync:_})}let e=await Ye(i,n.pathname,t.signal);if(e.type===`aborted`)return{shortCircuited:!0};if(e.type===`error`){if(e.partialMatches.length===0){let{matches:t,route:n}=CU(s.activeRoutes);return{matches:t,loaderData:{},errors:{[n.id]:e.error}}}let t=SU(e.partialMatches).route.id;return{matches:e.partialMatches,loaderData:{},errors:{[t]:e.error}}}else if(e.matches)i=e.matches;else{let{error:e,notFoundMatches:t,route:r}=We(n.pathname);return{matches:t,loaderData:{},errors:{[r.id]:e}}}}let C=s.activeRoutes,{dsMatches:T,revalidatingFetchers:E}=VH(t,u,a,o,e.history,w,i,x,n,g?[]:r,g===!0,ee,N,se,ae,ie,C,c,e.patchRoutesOnNavigation!=null,s.branches,v,y);if(ne=++te,!e.dataStrategy&&!T.some(e=>e.shouldLoad)&&!T.some(e=>e.route.middleware&&e.route.middleware.length>0)&&E.length===0){let e=new Map(w.fetchers),t=Re(e);return he(n,{matches:i,loaderData:{},errors:v&&MU(v[1])?{[v[0]]:v[1].error}:null,...xU(v),...t?{fetchers:e}:{}},{flushSync:_}),{shortCircuited:!0}}if(S){let e={};if(!d){e.navigation=b;let t=xe(v);t!==void 0&&(e.actionData=t)}E.length>0&&(e.fetchers=Se(E)),me(e,{flushSync:_})}E.forEach(e=>{Ie(e.key),e.controller&&P.set(e.key,e.controller)});let D=()=>E.forEach(e=>Ie(e.key));O&&O.signal.addEventListener(`abort`,D);let{loaderResults:k,fetcherResults:A}=await Oe(T,E,t,n,u);if(t.signal.aborted)return{shortCircuited:!0};O&&O.signal.removeEventListener(`abort`,D),E.forEach(e=>P.delete(e.key));let j=TU(k);if(j)return await Ee(t,j.result,!0,{replace:h}),{shortCircuited:!0};if(j=TU(A),j)return ie.add(j.key),await Ee(t,j.result,!0,{replace:h}),{shortCircuited:!0};let re=new Map(w.fetchers),{loaderData:oe,errors:ce}=yU(w,i,k,v,E,A,re);g&&w.errors&&(ce={...w.errors,...ce});let le=Re(re),ue=ze(ne,re),de=le||ue||E.length>0;return{matches:i,loaderData:oe,errors:ce,...de?{workingFetchers:re}:{}}}function xe(e){if(e&&!MU(e[1]))return{[e[0]]:e[1].data};if(w.actionData)return Object.keys(w.actionData).length===0?null:w.actionData}function Se(e){let t=new Map(w.fetchers);return e.forEach(e=>{let n=t.get(e.key),r=GU(void 0,n?n.data:void 0);t.set(e.key,r)}),t}async function Ce(t,n,r,i){Ie(t);let a=(i&&i.flushSync)===!0,o=s.activeRoutes,l=zH(w.location,w.matches,c,r,n,i?.relative),u=CV(o,l,c,!1,s.branches),d=F(u,o,l);if(d.active&&d.matches&&(u=d.matches),!u){je(t,n,wU(404,{pathname:l}),{flushSync:a});return}let{path:f,submission:p,error:m}=BH(!0,l,i);if(m){je(t,n,m,{flushSync:a});return}let h=e.getContext?await e.getContext():new mV,g=(i&&i.preventScrollReset)===!0;if(p&&zU(p.formMethod)){await we(t,n,f,u,h,d.active,a,g,p,i&&i.defaultShouldRevalidate);return}ae.set(t,{routeId:n,path:f}),await Te(t,n,f,u,h,d.active,a,g,p)}async function we(t,n,i,l,u,d,f,p,m,h){ke(),ae.delete(t),Ae(t,KU(m,w.fetchers.get(t)),{flushSync:f});let g=new AbortController,_=mU(e.history,i,g.signal,m);if(d){let e=await Ye(l,new URL(_.url).pathname,_.signal,t);if(e.type===`aborted`)return;if(e.type===`error`){je(t,n,e.error,{flushSync:f});return}else if(e.matches)l=e.matches;else{je(t,n,wU(404,{pathname:i}),{flushSync:f});return}}let v=VU(l,i);if(!v.route.action&&!v.route.lazy){je(t,n,wU(405,{method:m.formMethod,pathname:i,routeId:n}),{flushSync:f});return}P.set(t,g);let y=te,b=oU(a,o,_,i,l,v,r,u),x=await De(_,i,b,u,t),S=x[v.route.id];if(!S){for(let e of b)if(x[e.route.id]){S=x[e.route.id];break}}if(_.signal.aborted){P.get(t)===g&&P.delete(t);return}if(se.has(t)){if(NU(S)||MU(S)){Ae(t,qU(void 0));return}}else{if(NU(S))if(P.delete(t),ne>y){Ae(t,qU(void 0));return}else return ie.add(t),Ae(t,GU(m)),Ee(_,S,!1,{fetcherSubmission:m,preventScrollReset:p});if(MU(S)){je(t,n,S.error);return}}let C=w.navigation.location||w.location,E=mU(e.history,C,g.signal),D=s.activeRoutes,k=w.navigation.state===`idle`?w.matches:CV(D,w.navigation.location,c,!1,s.branches);iV(k,`Didn't find any matches after fetcher action`);let A=++te;re.set(t,A);let{dsMatches:j,revalidatingFetchers:M}=VH(E,u,a,o,e.history,w,k,m,C,r,!1,ee,N,se,ae,ie,D,c,e.patchRoutesOnNavigation!=null,s.branches,[v.route.id,S],h),oe=GU(m,S.data),ce=new Map(w.fetchers);ce.set(t,oe),M.filter(e=>e.key!==t).forEach(e=>{let t=e.key,n=ce.get(t),r=GU(void 0,n?n.data:void 0);ce.set(t,r),Ie(t),e.controller&&P.set(t,e.controller)}),me({fetchers:ce});let le=()=>M.forEach(e=>Ie(e.key));g.signal.addEventListener(`abort`,le);let{loaderResults:ue,fetcherResults:de}=await Oe(j,M,E,C,u);if(g.signal.aborted)return;g.signal.removeEventListener(`abort`,le),re.delete(t),P.delete(t),M.forEach(e=>P.delete(e.key));let fe=w.fetchers.has(t),pe=e=>{if(!fe)return e;let n=new Map(e.fetchers);return n.set(t,qU(S.data)),{...e,fetchers:n}},ge=TU(ue);if(ge)return w=pe(w),Ee(E,ge.result,!1,{preventScrollReset:p});if(ge=TU(de),ge)return ie.add(ge.key),w=pe(w),Ee(E,ge.result,!1,{preventScrollReset:p});let _e=new Map(w.fetchers);fe&&_e.set(t,qU(S.data));let{loaderData:ve,errors:ye}=yU(w,k,ue,void 0,M,de,_e);ze(A,_e),w.navigation.state===`loading`&&A>ne?(iV(T,`Expected pending action`),O&&O.abort(),he(w.navigation.location,{matches:k,loaderData:ve,errors:ye,fetchers:_e})):(me({errors:ye,loaderData:bU(w.loaderData,ve,k,ye),fetchers:_e}),ee=!1)}async function Te(t,n,i,s,c,l,u,d,f){let p=w.fetchers.get(t);Ae(t,GU(f,p?p.data:void 0),{flushSync:u});let m=new AbortController,h=mU(e.history,i,m.signal);if(l){let e=await Ye(s,new URL(h.url).pathname,h.signal,t);if(e.type===`aborted`)return;if(e.type===`error`){je(t,n,e.error,{flushSync:u});return}else if(e.matches)s=e.matches;else{je(t,n,wU(404,{pathname:i}),{flushSync:u});return}}let g=VU(s,i);P.set(t,m);let _=te,v=await De(h,i,oU(a,o,h,i,s,g,r,c),c,t),y=v[g.route.id];if(!y){for(let e of s)if(v[e.route.id]){y=v[e.route.id];break}}if(P.get(t)===m&&P.delete(t),!h.signal.aborted){if(se.has(t)){Ae(t,qU(void 0));return}if(NU(y))if(ne>_){Ae(t,qU(void 0));return}else{ie.add(t),await Ee(h,y,!1,{preventScrollReset:d});return}if(MU(y)){je(t,n,y.error);return}Ae(t,qU(y.data))}}async function Ee(r,i,a,{submission:o,fetcherSubmission:s,preventScrollReset:l,replace:u}={}){a||(E?.resolve(),E=null),i.response.headers.has(`X-Remix-Revalidate`)&&(ee=!0);let d=i.response.headers.get(`Location`);iV(d,`Expected a Location header on the redirect Response`),d=pU(d,new URL(r.url),c,e.history);let f=cV(w.location,d,{_isRedirect:!0});if(n){let e=!1;if(i.response.headers.has(`X-Remix-Reload-Document`))e=!0;else if(GV(d)){let n=fV(t,d,!0);e=n.origin!==t.location.origin||HV(n.pathname,c)==null}if(e){u?t.location.replace(d):t.location.assign(d);return}}O=null;let p=u===!0||i.response.headers.has(`X-Remix-Replace`)?`REPLACE`:`PUSH`,{formMethod:m,formAction:h,formEncType:g}=w.navigation;!o&&!s&&m&&h&&g&&(o=HU(w.navigation));let _=o||s;TH.has(i.response.status)&&_&&zU(_.formMethod)?await ve(p,f,{submission:{..._,formAction:d},preventScrollReset:l||D,enableViewTransition:a?k:void 0}):await ve(p,f,{overrideNavigation:UU(f,[],p,o),fetcherSubmission:s,preventScrollReset:l||D,enableViewTransition:a?k:void 0})}async function De(e,t,n,r,i){let a,o={};try{a=await sU(l,e,t,n,i,r,!1)}catch(e){return n.filter(e=>e.shouldLoad).forEach(t=>{o[t.route.id]={type:`error`,error:e}}),o}if(e.signal.aborted)return o;if(!zU(e.method))for(let e of n){if(a[e.route.id]?.type===`error`)break;!a.hasOwnProperty(e.route.id)&&!w.loaderData.hasOwnProperty(e.route.id)&&(!w.errors||!w.errors.hasOwnProperty(e.route.id))&&e.shouldCallHandler()&&(a[e.route.id]={type:`error`,result:Error(`No result returned from dataStrategy for route ${e.route.id}`)})}for(let[t,r]of Object.entries(a))if(jU(r)){let i=r.result;o[t]={type:`redirect`,response:dU(i,e,t,n,c)}}else o[t]=await uU(r);return o}async function Oe(e,t,n,r,i){let a=De(n,r,e,i,null),o=Promise.all(t.map(async e=>{if(e.matches&&e.match&&e.request&&e.controller){let t=(await De(e.request,e.path,e.matches,i,e.key))[e.match.route.id];return{[e.key]:t}}else return Promise.resolve({[e.key]:{type:`error`,error:wU(404,{pathname:e.path})}})}));return{loaderResults:await a,fetcherResults:(await o).reduce((e,t)=>Object.assign(e,t),{})}}function ke(){ee=!0,ae.forEach((e,t)=>{P.has(t)&&N.add(t),Ie(t)})}function Ae(e,t,n={}){let r=new Map(w.fetchers);r.set(e,t),me({fetchers:r},{flushSync:(n&&n.flushSync)===!0})}function je(e,t,n,r={}){let i=SU(w.matches,t),a=new Map(w.fetchers);Pe(a,e),me({errors:{[i.route.id]:n},fetchers:a},{flushSync:(r&&r.flushSync)===!0})}function Me(e){return oe.set(e,(oe.get(e)||0)+1),se.has(e)&&se.delete(e),w.fetchers.get(e)||DH}function Ne(e,t){Ie(e,t?.reason),Ae(e,qU(null))}function Pe(e,t){let n=w.fetchers.get(t);P.has(t)&&!(n&&n.state===`loading`&&re.has(t))&&Ie(t),ae.delete(t),re.delete(t),ie.delete(t),se.delete(t),N.delete(t),e.delete(t)}function Fe(e){let t=(oe.get(e)||0)-1;t<=0?(oe.delete(e),se.add(e)):oe.set(e,t),me({fetchers:new Map(w.fetchers)})}function Ie(e,t){let n=P.get(e);n&&(n.abort(t),P.delete(e))}function Le(e,t){for(let n of e){let e=t.get(n);iV(e,`Expected fetcher: ${n}`);let r=qU(e.data);t.set(n,r)}}function Re(e){let t=[],n=!1;for(let r of ie){let i=e.get(r);iV(i,`Expected fetcher: ${r}`),i.state===`loading`&&(ie.delete(r),t.push(r),n=!0)}return Le(t,e),n}function ze(e,t){let n=[];for(let[r,i]of re)if(i<e){let e=t.get(r);iV(e,`Expected fetcher: ${r}`),e.state===`loading`&&(Ie(r),re.delete(r),n.push(r))}return Le(n,t),n.length>0}function Be(e,t){let n=w.blockers.get(e)||OH;return ce.get(e)!==t&&ce.set(e,t),n}function Ve(e){w.blockers.delete(e),ce.delete(e)}function He(e,t){let n=w.blockers.get(e)||OH;iV(n.state===`unblocked`&&t.state===`blocked`||n.state===`blocked`&&t.state===`blocked`||n.state===`blocked`&&t.state===`proceeding`||n.state===`blocked`&&t.state===`unblocked`||n.state===`proceeding`&&t.state===`unblocked`,`Invalid blocker state transition: ${n.state} -> ${t.state}`);let r=new Map(w.blockers);r.set(e,t),me({blockers:r})}function Ue({currentLocation:e,nextLocation:t,historyAction:n}){if(ce.size===0)return;ce.size>1&&aV(!1,`A router only supports one blocker at a time`);let r=Array.from(ce.entries()),[i,a]=r[r.length-1],o=w.blockers.get(i);if(!(o&&o.state===`proceeding`)&&a({currentLocation:e,nextLocation:t,historyAction:n}))return i}function We(e){let t=wU(404,{pathname:e}),n=s.activeRoutes,{matches:r,route:i}=CU(n);return{notFoundMatches:r,route:i,error:t}}function Ge(e,t,n){if(m=e,g=t,h=n||null,!_&&w.navigation===EH){_=!0;let e=Je(w.location,w.matches);e!=null&&me({restoreScrollPosition:e})}return()=>{m=null,g=null,h=null}}function Ke(e,t){return h&&h(e,t.map(e=>wV(e,w.loaderData)))||e.key}function qe(e,t){if(m&&g){let n=Ke(e,t);m[n]=g()}}function Je(e,t){if(m){let n=Ke(e,t),r=m[n];if(typeof r==`number`)return r}return null}function F(t,n,r){if(e.patchRoutesOnNavigation){let e=s.branches;if(!t)return{active:!0,matches:CV(n,r,c,!0,e)||[]};if(Object.keys(t[0].params).length>0)return{active:!0,matches:CV(n,r,c,!0,e)}}return{active:!1,matches:null}}async function Ye(t,n,r,i){if(!e.patchRoutesOnNavigation)return{type:`success`,matches:t};let l=t;for(;;){let t=o;try{await e.patchRoutesOnNavigation({signal:r,path:n,matches:l,fetcherKey:i,patch:(e,n)=>{r.aborted||qH(e,n,s,t,a,!1)}})}catch(e){return{type:`error`,error:e,partialMatches:l}}if(r.aborted)return{type:`aborted`};let u=s.branches,d=CV(s.activeRoutes,n,c,!1,u),f=null;if(d&&(Object.keys(d[0].params).length===0||(f=CV(s.activeRoutes,n,c,!0,u),!(f&&l.length<f.length&&Xe(l,f.slice(0,l.length))))))return{type:`success`,matches:d};if(f||=CV(s.activeRoutes,n,c,!0,u),!f||Xe(l,f))return{type:`success`,matches:null};l=f}}function Xe(e,t){return e.length===t.length&&e.every((e,n)=>e.route.id===t[n].route.id)}function Ze(e){o={},s.setHmrRoutes(bV(e,a,void 0,o))}function Qe(e,t,n=!1){qH(e,t,s,o,a,n),s.hasHMRRoutes||me({})}return C={get basename(){return c},get future(){return u},get state(){return w},get routes(){return s.stableRoutes},get branches(){return s.branches},get manifest(){return o},get window(){return t},initialize:de,subscribe:pe,enableScrollRestoration:Ge,navigate:ge,fetch:Ce,revalidate:_e,createHref:t=>e.history.createHref(t),encodeLocation:t=>e.history.encodeLocation(t),getFetcher:Me,resetFetcher:Ne,deleteFetcher:Fe,dispose:fe,getBlocker:Be,deleteBlocker:Ve,patchRoutes:Qe,_internalFetchControllers:P,_internalSetRoutes:Ze,_internalSetStateDoNotUseOrYouWillBreakYourApp(e){me(e)}},e.instrumentations&&(C=dH(C,e.instrumentations.map(e=>e.router).filter(Boolean))),C}function RH(e){return e!=null&&(`formData`in e&&e.formData!=null||`body`in e&&e.body!==void 0)}function zH(e,t,n,r,i,a){let o,s;if(i){o=[];for(let e of t)if(o.push(e),e.route.id===i){s=e;break}}else o=t,s=t[t.length-1];let c=ZV(r||`.`,XV(o),HV(e.pathname,n)||e.pathname,a===`path`);if(r??(c.search=e.search,c.hash=e.hash),(r==null||r===``||r===`.`)&&s){let e=BU(c.search);if(s.route.index&&!e)c.search=c.search?c.search.replace(/^\?/,`?index&`):`?index`;else if(!s.route.index&&e){let e=new URLSearchParams(c.search),t=e.getAll(`index`);e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();c.search=n?`?${n}`:``}}return n!==`/`&&(c.pathname=UV({basename:n,pathname:c.pathname})),lV(c)}function BH(e,t,n){if(!n||!RH(n))return{path:t};if(n.formMethod&&!RU(n.formMethod))return{path:t,error:wU(405,{method:n.formMethod})};let r=()=>({path:t,error:wU(400,{type:`invalid-body`})}),i=(n.formMethod||`get`).toUpperCase(),a=EU(t);if(n.body!==void 0){if(n.formEncType===`text/plain`){if(!zU(i))return r();let e=typeof n.body==`string`?n.body:n.body instanceof FormData||n.body instanceof URLSearchParams?Array.from(n.body.entries()).reduce((e,[t,n])=>`${e}${t}=${n}
209
- `,``):String(n.body);return{path:t,submission:{formMethod:i,formAction:a,formEncType:n.formEncType,formData:void 0,json:void 0,text:e}}}else if(n.formEncType===`application/json`){if(!zU(i))return r();try{let e=typeof n.body==`string`?JSON.parse(n.body):n.body;return{path:t,submission:{formMethod:i,formAction:a,formEncType:n.formEncType,formData:void 0,json:e,text:void 0}}}catch{return r()}}}iV(typeof FormData==`function`,`FormData is not available in this environment`);let o,s;if(n.formData)o=gU(n.formData),s=n.formData;else if(n.body instanceof FormData)o=gU(n.body),s=n.body;else if(n.body instanceof URLSearchParams)o=n.body,s=_U(o);else if(n.body==null)o=new URLSearchParams,s=new FormData;else try{o=new URLSearchParams(n.body),s=_U(o)}catch{return r()}let c={formMethod:i,formAction:a,formEncType:n&&n.formEncType||`application/x-www-form-urlencoded`,formData:s,json:void 0,text:void 0};if(zU(c.formMethod))return{path:t,submission:c};let l=uV(t);return e&&l.search&&BU(l.search)&&o.append(`index`,``),l.search=`?${o}`,{path:lV(l),submission:c}}function VH(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x){let S=b?MU(b[1])?b[1].error:b[1].data:void 0,C=i.createURL(a.location),w=i.createURL(c),T;if(u&&a.errors){let e=Object.keys(a.errors)[0];T=o.findIndex(t=>t.route.id===e)}else if(b&&MU(b[1])){let e=b[0];T=o.findIndex(t=>t.route.id===e)-1}let E=b?b[1].statusCode:void 0,D=E&&E>=400,O={currentUrl:C,currentParams:a.matches[0]?.params||{},nextUrl:w,nextParams:o[0].params,...s,actionResult:S,actionStatus:E},k=oH(o),A=o.map((i,o)=>{let{route:s}=i,f=null;if(T!=null&&o>T)f=!1;else if(s.lazy)f=!0;else if(!HH(s))f=!1;else if(u){let{shouldLoad:e}=UH(s,a.loaderData,a.errors);f=e}else WH(a.loaderData,a.matches[o],i)&&(f=!0);if(f!==null)return aU(n,r,e,c,k,i,l,t,f);let p=!1;typeof x==`boolean`?p=x:D?p=!1:d||C.pathname+C.search===w.pathname+w.search?p=!0:C.search===w.search?GH(a.matches[o],i)&&(p=!0):p=!0;let m={...O,defaultShouldRevalidate:p};return aU(n,r,e,c,k,i,l,t,KH(i,m),m,x)}),j=[];return m.forEach((e,s)=>{if(u||!o.some(t=>t.route.id===e.routeId)||p.has(s))return;let c=a.fetchers.get(s),m=c&&c.state!==`idle`&&c.data===void 0,b=CV(g,e.path,_??`/`,!1,y);if(!b){if(v&&m)return;j.push({key:s,routeId:e.routeId,path:e.path,matches:null,match:null,request:null,controller:null});return}if(h.has(s))return;let S=VU(b,e.path),C=new AbortController,w=mU(i,e.path,C.signal),T=null;if(f.has(s))f.delete(s),T=oU(n,r,w,e.path,b,S,l,t);else if(m)d&&(T=oU(n,r,w,e.path,b,S,l,t));else{let i;i=typeof x==`boolean`?x:D?!1:d;let a={...O,defaultShouldRevalidate:i};KH(S,a)&&(T=oU(n,r,w,e.path,b,S,l,t,a))}T&&j.push({key:s,routeId:e.routeId,path:e.path,matches:T,match:S,request:w,controller:C})}),{dsMatches:A,revalidatingFetchers:j}}function HH(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function UH(e,t,n){if(e.lazy)return{shouldLoad:!0,renderFallback:!0};if(!HH(e))return{shouldLoad:!1,renderFallback:!1};let r=t!=null&&e.id in t,i=n!=null&&n[e.id]!==void 0;if(!r&&i)return{shouldLoad:!1,renderFallback:!1};if(typeof e.loader==`function`&&e.loader.hydrate===!0)return{shouldLoad:!0,renderFallback:!r};let a=!r&&!i;return{shouldLoad:a,renderFallback:a}}function WH(e,t,n){let r=!t||n.route.id!==t.route.id,i=!e.hasOwnProperty(n.route.id);return r||i}function GH(e,t){let n=e.route.path;return e.pathname!==t.pathname||n!=null&&n.endsWith(`*`)&&e.params[`*`]!==t.params[`*`]}function KH(e,t){if(e.route.shouldRevalidate){let n=e.route.shouldRevalidate(t);if(typeof n==`boolean`)return n}return t.defaultShouldRevalidate}function qH(e,t,n,r,i,a){let o;if(e){let t=r[e];iV(t,`No route found to patch children into: routeId = ${e}`),t.children||=[],o=t.children}else o=n.activeRoutes;let s=[],c=[];if(t.forEach(e=>{let t=o.find(t=>JH(e,t));t?c.push({existingRoute:t,newRoute:e}):s.push(e)}),s.length>0){let t=bV(s,i,[e||`_`,`patch`,String(o?.length||`0`)],r);o.push(...t)}if(a&&c.length>0)for(let e=0;e<c.length;e++){let{existingRoute:t,newRoute:n}=c[e],r=t,[a]=bV([n],i,[],{},!0);Object.assign(r,{element:a.element?a.element:r.element,errorElement:a.errorElement?a.errorElement:r.errorElement,hydrateFallbackElement:a.hydrateFallbackElement?a.hydrateFallbackElement:r.hydrateFallbackElement})}n.hasHMRRoutes||n.setRoutes([...n.activeRoutes])}function JH(e,t){return`id`in e&&`id`in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children?.every((e,n)=>t.children?.some(t=>JH(e,t)))??!1:!1}var YH=new WeakMap,XH=({key:e,route:t,manifest:n,mapRouteProperties:r})=>{let i=n[t.id];if(iV(i,`No route found in manifest`),!i.lazy||typeof i.lazy!=`object`)return;let a=i.lazy[e];if(!a)return;let o=YH.get(i);o||(o={},YH.set(i,o));let s=o[e];if(s)return s;let c=(async()=>{let t=gV(e),n=i[e]!==void 0&&e!==`hasErrorBoundary`;if(t)aV(!t,`Route property `+e+` is not a supported lazy route property. This property will be ignored.`),o[e]=Promise.resolve();else if(n)aV(!1,`Route "${i.id}" has a static property "${e}" defined. The lazy property will be ignored.`);else{let t=await a();t!=null&&(Object.assign(i,{[e]:t}),Object.assign(i,r(i)))}typeof i.lazy==`object`&&(i.lazy[e]=void 0,Object.values(i.lazy).every(e=>e===void 0)&&(i.lazy=void 0))})();return o[e]=c,c},ZH=new WeakMap;function QH(e,t,n,r,i){let a=n[e.id];if(iV(a,`No route found in manifest`),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy==`function`){let t=ZH.get(a);if(t)return{lazyRoutePromise:t,lazyHandlerPromise:t};let n=(async()=>{iV(typeof e.lazy==`function`,`No lazy route function found`);let t=await e.lazy(),n={};for(let e in t){let r=t[e];if(r===void 0)continue;let i=vV(e),o=a[e]!==void 0&&e!==`hasErrorBoundary`;i?aV(!i,`Route property `+e+` is not a supported property to be returned from a lazy route function. This property will be ignored.`):o?aV(!o,`Route "${a.id}" has a static property "${e}" defined but its lazy function is also returning a value for this property. The lazy route property "${e}" will be ignored.`):n[e]=r}Object.assign(a,n),Object.assign(a,{...r(a),lazy:void 0})})();return ZH.set(a,n),n.catch(()=>{}),{lazyRoutePromise:n,lazyHandlerPromise:n}}let o=Object.keys(e.lazy),s=[],c;for(let a of o){if(i&&i.includes(a))continue;let o=XH({key:a,route:e,manifest:n,mapRouteProperties:r});o&&(s.push(o),a===t&&(c=o))}let l=s.length>0?Promise.all(s).then(()=>{}):void 0;return l?.catch(()=>{}),c?.catch(()=>{}),{lazyRoutePromise:l,lazyHandlerPromise:c}}async function $H(e){let t=e.matches.filter(e=>e.shouldLoad),n={};return(await Promise.all(t.map(e=>e.resolve()))).forEach((e,r)=>{n[t[r].route.id]=e}),n}async function eU(e){return e.matches.some(e=>e.route.middleware)?tU(e,()=>$H(e)):$H(e)}function tU(e,t){return nU(e,t,e=>{if(LU(e))throw e;return e},kU,n);function n(t,n,r){if(r)return Promise.resolve(Object.assign(r.value,{[n]:{type:`error`,result:t}}));{let{matches:r}=e,i=SU(r,r[Math.min(Math.max(r.findIndex(e=>e.route.id===n),0),Math.max(r.findIndex(e=>e.shouldCallHandler()),0))].route.id).route.id;return Promise.resolve({[i]:{type:`error`,result:t}})}}}async function nU(e,t,n,r,i){let{matches:a,...o}=e;return await rU(o,a.flatMap(e=>e.route.middleware?e.route.middleware.map(t=>[e.route.id,t]):[]),t,n,r,i)}async function rU(e,t,n,r,i,a,o=0){let{request:s}=e;if(s.signal.aborted)throw s.signal.reason??Error(`Request aborted: ${s.method} ${s.url}`);let c=t[o];if(!c)return await n();let[l,u]=c,d,f=async()=>{if(d)throw Error("You may only call `next()` once per middleware");try{return d={value:await rU(e,t,n,r,i,a,o+1)},d.value}catch(e){return d={value:await a(e,l,d)},d.value}};try{let t=await u(e,f),n=t==null?void 0:r(t);return i(n)?n:d?n??d.value:(d={value:await f()},d.value)}catch(e){return await a(e,l,d)}}function iU(e,t,n,r,i){let a=XH({key:`middleware`,route:r.route,manifest:t,mapRouteProperties:e}),o=QH(r.route,zU(n.method)?`action`:`loader`,t,e,i);return{middleware:a,route:o.lazyRoutePromise,handler:o.lazyHandlerPromise}}function aU(e,t,n,r,i,a,o,s,c,l=null,u){let d=!1,f=iU(e,t,n,a,o);return{...a,_lazyPromises:f,shouldLoad:c,shouldRevalidateArgs:l,shouldCallHandler(e){return d=!0,l?typeof u==`boolean`?KH(a,{...l,defaultShouldRevalidate:u}):typeof e==`boolean`?KH(a,{...l,defaultShouldRevalidate:e}):KH(a,l):c},resolve(e){let{lazy:t,loader:o,middleware:l}=a.route,u=d||c||e&&!zU(n.method)&&(t||o),p=l&&l.length>0&&!o&&!t;return u&&(zU(n.method)||!p)?cU({request:n,path:r,pattern:i,match:a,lazyHandlerPromise:f?.handler,lazyRoutePromise:f?.route,handlerOverride:e,scopedContext:s}):Promise.resolve({type:`data`,result:void 0})}}}function oU(e,t,n,r,i,a,o,s,c=null){return i.map(l=>l.route.id===a.route.id?aU(e,t,n,r,oH(i),l,o,s,!0,c):{...l,shouldLoad:!1,shouldRevalidateArgs:c,shouldCallHandler:()=>!1,_lazyPromises:iU(e,t,n,l,o),resolve:()=>Promise.resolve({type:`data`,result:void 0})})}async function sU(e,t,n,r,i,a,o){r.some(e=>e._lazyPromises?.middleware)&&await Promise.all(r.map(e=>e._lazyPromises?.middleware));let s={request:t,url:hU(t,n),pattern:oH(r),params:r[0].params,context:a,matches:r},c=o?()=>{throw Error("You cannot call `runClientMiddleware()` from a static handler `dataStrategy`. Middleware is run outside of `dataStrategy` during SSR in order to bubble up the Response. You can enable middleware via the `respond` API in `query`/`queryRoute`")}:e=>{let t=s;return tU(t,()=>e({...t,fetcherKey:i,runClientMiddleware:()=>{throw Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}}))},l=await e({...s,fetcherKey:i,runClientMiddleware:c});try{await Promise.all(r.flatMap(e=>[e._lazyPromises?.handler,e._lazyPromises?.route]))}catch{}return l}async function cU({request:e,path:t,pattern:n,match:r,lazyHandlerPromise:i,lazyRoutePromise:a,handlerOverride:o,scopedContext:s}){let c,l,u=zU(e.method),d=u?`action`:`loader`,f=i=>{let a,c=new Promise((e,t)=>a=t);l=()=>a(),e.signal.addEventListener(`abort`,l);let u=a=>typeof i==`function`?i({request:e,url:hU(e,t),pattern:n,params:r.params,context:s},...a===void 0?[]:[a]):Promise.reject(Error(`You cannot call the handler for a route which defines a boolean "${d}" [routeId: ${r.route.id}]`)),f=(async()=>{try{return{type:`data`,result:await(o?o(e=>u(e)):u())}}catch(e){return{type:`error`,result:e}}})();return Promise.race([f,c])};try{let t=u?r.route.action:r.route.loader;if(i||a)if(t){let e,[n]=await Promise.all([f(t).catch(t=>{e=t}),i,a]);if(e!==void 0)throw e;c=n}else{await i;let t=u?r.route.action:r.route.loader;if(t)[c]=await Promise.all([f(t),a]);else if(d===`action`){let t=new URL(e.url),n=t.pathname+t.search;throw wU(405,{method:e.method,pathname:n,routeId:r.route.id})}else return{type:`data`,result:void 0}}else if(t)c=await f(t);else{let t=new URL(e.url);throw wU(404,{pathname:t.pathname+t.search})}}catch(e){return{type:`error`,result:e}}finally{l&&e.signal.removeEventListener(`abort`,l)}return c}async function lU(e){let t=e.headers.get(`Content-Type`);return t&&/\bapplication\/json\b/.test(t)?e.body==null?null:e.json():e.text()}async function uU(e){let{result:t,type:n}=e;if(FU(t)){let e;try{e=await lU(t)}catch(e){return{type:`error`,error:e}}return n===`error`?{type:`error`,error:new iH(t.status,t.statusText,e),statusCode:t.status,headers:t.headers}:{type:`data`,data:e,statusCode:t.status,headers:t.headers}}return n===`error`?PU(t)?t.data instanceof Error?{type:`error`,error:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`error`,error:OU(t),statusCode:aH(t)?t.status:void 0,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`error`,error:t,statusCode:aH(t)?t.status:void 0}:PU(t)?{type:`data`,data:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`data`,data:t}}function dU(e,t,n,r,i){let a=e.headers.get(`Location`);if(iV(a,`Redirects returned/thrown from loaders/actions must have a Location header`),!GV(a)){let o=r.slice(0,r.findIndex(e=>e.route.id===n)+1);a=zH(new URL(t.url),o,i,a),e.headers.set(`Location`,a)}return e}var fU=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function pU(e,t,n,r){if(GV(e)){let r=e,i=r.startsWith(`//`)?new URL(t.protocol+r):new URL(r);if(fU.includes(i.protocol))throw Error(`Invalid redirect location`);let a=HV(i.pathname,n)!=null;if(i.origin===t.origin&&a)return QV(i.pathname)+i.search+i.hash}try{let t=r.createURL(e);if(fU.includes(t.protocol))throw Error(`Invalid redirect location`)}catch{}return e}function mU(e,t,n,r){let i=e.createURL(EU(t)).toString(),a={signal:n};if(r&&zU(r.formMethod)){let{formMethod:e,formEncType:t}=r;a.method=e.toUpperCase(),t===`application/json`?(a.headers=new Headers({"Content-Type":t}),a.body=JSON.stringify(r.json)):t===`text/plain`?a.body=r.text:t===`application/x-www-form-urlencoded`&&r.formData?a.body=gU(r.formData):a.body=r.formData}return new Request(i,a)}function hU(e,t){let n=new URL(e.url),r=typeof t==`string`?uV(t):t;if(n.pathname=r.pathname||`/`,r.search){let e=new URLSearchParams(r.search),t=e.getAll(`index`);e.delete(`index`);for(let n of t.filter(Boolean))e.append(`index`,n);n.search=e.size?`?${e.toString()}`:``}else n.search=``;return n.hash=r.hash||``,n}function gU(e){let t=new URLSearchParams;for(let[n,r]of e.entries())t.append(n,typeof r==`string`?r:r.name);return t}function _U(e){let t=new FormData;for(let[n,r]of e.entries())t.append(n,r);return t}function vU(e,t,n,r=!1,i=!1){let a={},o=null,s,c=!1,l={},u=n&&MU(n[1])?n[1].error:void 0;return e.forEach(n=>{if(!(n.route.id in t))return;let d=n.route.id,f=t[d];if(iV(!NU(f),`Cannot handle redirect results in processLoaderData`),MU(f)){let t=f.error;if(u!==void 0&&(t=u,u=void 0),o||={},i)o[d]=t;else{let n=SU(e,d);o[n.route.id]??(o[n.route.id]=t)}r||(a[d]=jH),c||(c=!0,s=aH(f.error)?f.error.status:500),f.headers&&(l[d]=f.headers)}else a[d]=f.data,f.statusCode&&f.statusCode!==200&&!c&&(s=f.statusCode),f.headers&&(l[d]=f.headers)}),u!==void 0&&n&&(o={[n[0]]:u},n[2]&&(a[n[2]]=void 0)),{loaderData:a,errors:o,statusCode:s||200,loaderHeaders:l}}function yU(e,t,n,r,i,a,o){let{loaderData:s,errors:c}=vU(t,n,r);return i.filter(e=>!e.matches||e.matches.some(e=>e.shouldLoad)).forEach(t=>{let{key:n,match:r,controller:i}=t;if(i&&i.signal.aborted)return;let s=a[n];if(iV(s,`Did not find corresponding fetcher result`),MU(s)){let t=SU(e.matches,r?.route.id);c&&c[t.route.id]||(c={...c,[t.route.id]:s.error}),o.delete(n)}else if(NU(s))iV(!1,`Unhandled fetcher revalidation redirect`);else{let e=qU(s.data);o.set(n,e)}}),{loaderData:s,errors:c}}function bU(e,t,n,r){let i=Object.entries(t).filter(([,e])=>e!==jH).reduce((e,[t,n])=>(e[t]=n,e),{});for(let a of n){let n=a.route.id;if(!t.hasOwnProperty(n)&&e.hasOwnProperty(n)&&a.route.loader&&(i[n]=e[n]),r&&r.hasOwnProperty(n))break}return i}function xU(e){return e?MU(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function SU(e,t){return(t?e.slice(0,e.findIndex(e=>e.route.id===t)+1):[...e]).reverse().find(e=>e.route.hasErrorBoundary===!0)||e[0]}function CU(e){let t=e.length===1?e[0]:e.find(e=>e.index||!e.path||e.path===`/`)||{id:`__shim-error-route__`};return{matches:[{params:{},pathname:``,pathnameBase:``,route:t}],route:t}}function wU(e,{pathname:t,routeId:n,method:r,type:i,message:a}={}){let o=`Unknown Server Error`,s=`Unknown @remix-run/router error`;return e===400?(o=`Bad Request`,r&&t&&n?s=`You made a ${r} request to "${t}" but did not provide a \`loader\` for route "${n}", so there is no way to handle the request.`:i===`invalid-body`&&(s=`Unable to encode submission body`)):e===403?(o=`Forbidden`,s=`Route "${n}" does not match URL "${t}"`):e===404?(o=`Not Found`,s=`No route matches URL "${t}"`):e===405&&(o=`Method Not Allowed`,r&&t&&n?s=`You made a ${r.toUpperCase()} request to "${t}" but did not provide an \`action\` for route "${n}", so there is no way to handle the request.`:r&&(s=`Invalid request method "${r.toUpperCase()}"`)),new iH(e||500,o,Error(s),!0)}function TU(e){let t=Object.entries(e);for(let e=t.length-1;e>=0;e--){let[n,r]=t[e];if(NU(r))return{key:n,result:r}}}function EU(e){return lV({...typeof e==`string`?uV(e):e,hash:``})}function DU(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===``?t.hash!==``:e.hash===t.hash?!0:t.hash!==``}function OU(e){return new iH(e.init?.status??500,e.init?.statusText??`Internal Server Error`,e.data)}function kU(e){return typeof e==`object`&&!!e&&Object.entries(e).every(([e,t])=>typeof e==`string`&&AU(t))}function AU(e){return typeof e==`object`&&!!e&&`type`in e&&`result`in e&&(e.type===`data`||e.type===`error`)}function jU(e){return FU(e.result)&&wH.has(e.result.status)}function MU(e){return e.type===`error`}function NU(e){return(e&&e.type)===`redirect`}function PU(e){return typeof e==`object`&&!!e&&`type`in e&&`data`in e&&`init`in e&&e.type===`DataWithResponseInit`}function FU(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.headers==`object`&&e.body!==void 0}function IU(e){return wH.has(e)}function LU(e){return FU(e)&&IU(e.status)&&e.headers.has(`Location`)}function RU(e){return CH.has(e.toUpperCase())}function zU(e){return xH.has(e.toUpperCase())}function BU(e){return new URLSearchParams(e).getAll(`index`).some(e=>e===``)}function VU(e,t){let n=typeof t==`string`?uV(t).search:t.search;if(e[e.length-1].route.index&&BU(n||``))return e[e.length-1];let r=YV(e);return r[r.length-1]}function HU(e){let{formMethod:t,formAction:n,formEncType:r,text:i,formData:a,json:o}=e;if(!(!t||!n||!r)){if(i!=null)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:void 0,text:i};if(a!=null)return{formMethod:t,formAction:n,formEncType:r,formData:a,json:void 0,text:void 0};if(o!==void 0)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:o,text:void 0}}}function UU(e,t,n,r){return r?{state:`loading`,location:e,matches:t,historyAction:n,formMethod:r.formMethod,formAction:r.formAction,formEncType:r.formEncType,formData:r.formData,json:r.json,text:r.text}:{state:`loading`,location:e,matches:t,historyAction:n,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function WU(e,t,n,r){return{state:`submitting`,location:e,matches:t,historyAction:n,formMethod:r.formMethod,formAction:r.formAction,formEncType:r.formEncType,formData:r.formData,json:r.json,text:r.text}}function GU(e,t){return e?{state:`loading`,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:`loading`,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function KU(e,t){return{state:`submitting`,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function qU(e){return{state:`idle`,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function JU(e,t){try{let n=e.sessionStorage.getItem(AH);if(n){let e=JSON.parse(n);for(let[n,r]of Object.entries(e||{}))r&&Array.isArray(r)&&t.set(n,new Set(r||[]))}}catch{}}function YU(e,t){if(t.size>0){let n={};for(let[e,r]of t)n[e]=[...r];try{e.sessionStorage.setItem(AH,JSON.stringify(n))}catch(e){aV(!1,`Failed to save applied view transitions in sessionStorage (${e}).`)}}}function XU(){let e,t,n=new Promise((r,i)=>{e=async e=>{r(e);try{await n}catch{}},t=async e=>{i(e);try{await n}catch{}}});return{promise:n,resolve:e,reject:t}}var ZU=b.createContext(null);ZU.displayName=`DataRouter`;var QU=b.createContext(null);QU.displayName=`DataRouterState`;var $U=b.createContext(!1);function eW(){return b.useContext($U)}var tW=b.createContext({isTransitioning:!1});tW.displayName=`ViewTransition`;var nW=b.createContext(new Map);nW.displayName=`Fetchers`;var rW=b.createContext(null);rW.displayName=`Await`;var iW=b.createContext(null);iW.displayName=`Navigation`;var aW=b.createContext(null);aW.displayName=`Location`;var oW=b.createContext({outlet:null,matches:[],isDataRoute:!1});oW.displayName=`Route`;var sW=b.createContext(null);sW.displayName=`RouteError`;var cW=`REACT_ROUTER_ERROR`,lW=`REDIRECT`,uW=`ROUTE_ERROR_RESPONSE`;function dW(e){if(e.startsWith(`${cW}:${lW}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function fW(e){if(e.startsWith(`${cW}:${uW}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new iH(t.status,t.statusText,t.data)}catch{}}function pW(e,{relative:t}={}){iV(mW(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=b.useContext(iW),{hash:i,pathname:a,search:o}=CW(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:$V([n,a])),r.createHref({pathname:s,search:o,hash:i})}function mW(){return b.useContext(aW)!=null}function hW(){return iV(mW(),`useLocation() may be used only in the context of a <Router> component.`),b.useContext(aW).location}var gW=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function _W(e){b.useContext(iW).static||b.useLayoutEffect(e)}function vW(){let{isDataRoute:e}=b.useContext(oW);return e?HW():yW()}function yW(){iV(mW(),`useNavigate() may be used only in the context of a <Router> component.`);let e=b.useContext(ZU),{basename:t,navigator:n}=b.useContext(iW),{matches:r}=b.useContext(oW),{pathname:i}=hW(),a=JSON.stringify(XV(r)),o=b.useRef(!1);return _W(()=>{o.current=!0}),b.useCallback((r,s={})=>{if(aV(o.current,gW),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=ZV(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:$V([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var bW=b.createContext(null);function xW(e){let t=b.useContext(oW).outlet;return b.useMemo(()=>t&&b.createElement(bW.Provider,{value:e},t),[t,e])}function SW(){let{matches:e}=b.useContext(oW);return e[e.length-1]?.params??{}}function CW(e,{relative:t}={}){let{matches:n}=b.useContext(oW),{pathname:r}=hW(),i=JSON.stringify(XV(n));return b.useMemo(()=>ZV(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function wW(e,t){return TW(e,t)}function TW(e,t,n){iV(mW(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=b.useContext(iW),{matches:i}=b.useContext(oW),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;WW(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
206
+ [${JSON.stringify(t,null,2)}]`);return(0,I.jsx)(CF,{value:t[0]||``,propertyType:e.propertyType})}function sR(e){return(0,I.jsxs)(rg,{title:`Export`,closeButtonProps:{"aria-label":`Close`},opened:e.visible,onClose:e.onCancel,children:[(0,I.jsxs)(z,{display:`flex`,style:{justifyContent:`space-between`},children:[e.exportCsv&&(0,I.jsx)(cR,{text:`CSV`,exportLogic:e.exportCsv,onCancel:e.onCancel}),e.exportTransactionBundle&&(0,I.jsx)(cR,{text:`Transaction Bundle`,exportLogic:e.exportTransactionBundle,onCancel:e.onCancel})]}),(0,I.jsx)(H,{style:{marginTop:`10px`,marginLeft:`2px`},children:`Limited to 1000 records`})]})}function cR(e){return(0,I.jsx)(U,{onClick:()=>{e.exportLogic(),e.onCancel()},children:`Export as ${e.text}`})}var lR={string:[X.EQUALS,X.NOT,X.CONTAINS,X.EXACT],fulltext:[X.EQUALS,X.NOT,X.CONTAINS,X.EXACT],token:[X.EQUALS,X.NOT,X.TEXT],reference:[X.EQUALS,X.NOT],numeric:[X.EQUALS,X.NOT_EQUALS,X.GREATER_THAN,X.LESS_THAN,X.GREATER_THAN_OR_EQUALS,X.LESS_THAN_OR_EQUALS],quantity:[X.EQUALS,X.NOT_EQUALS,X.GREATER_THAN,X.LESS_THAN,X.GREATER_THAN_OR_EQUALS,X.LESS_THAN_OR_EQUALS],date:[X.EQUALS,X.NOT_EQUALS,X.GREATER_THAN,X.LESS_THAN,X.GREATER_THAN_OR_EQUALS,X.LESS_THAN_OR_EQUALS,X.STARTS_AFTER,X.ENDS_BEFORE,X.APPROXIMATELY],datetime:[X.EQUALS,X.NOT_EQUALS,X.GREATER_THAN,X.LESS_THAN,X.GREATER_THAN_OR_EQUALS,X.LESS_THAN_OR_EQUALS,X.STARTS_AFTER,X.ENDS_BEFORE,X.APPROXIMATELY],uri:[X.EQUALS,X.NOT,X.ABOVE,X.BELOW]},uR={eq:`equals`,ne:`not equals`,gt:`greater than`,lt:`less than`,ge:`greater than or equals`,le:`less than or equals`,sa:`starts after`,eb:`ends before`,ap:`approximately`,sw:`starts with`,contains:`contains`,exact:`exact`,text:`text`,not:`not`,above:`above`,below:`below`,in:`in`,"not-in":`not in`,"of-type":`of type`,missing:`missing`,present:`present`,identifier:`identifier`,iterate:`iterate`};function dR(e,t){return{...e,filters:t,offset:0,name:void 0}}function fR(e,t){return dR(e,(e.filters??[]).filter(e=>e.code!==t))}function pR(e,t,n,r,i){i&&(e=fR(e,t));let a=[];return e.filters&&a.push(...e.filters),a.push({code:t,operator:n,value:r??``}),dR(e,a)}function mR(e,t){if(!e.filters)return e;let n=[...e.filters];return n.splice(t,1),{...e,filters:n,name:void 0}}function hR(e,t){return vR(e,t,-1)}function gR(e,t){return vR(e,t,0)}function _R(e,t){return vR(e,t,1)}function vR(e,t,n){let r=new Date;r.setDate(r.getDate()+n),r.setHours(0,0,0,0);let i=new Date(r.getTime());return i.setDate(i.getDate()+1),i.setTime(i.getTime()-1),TR(e,t,r,i)}function yR(e,t){let n=new Date;return TR(e,t,n,new Date(n.getTime()+1440*60*1e3))}function bR(e,t){return CR(e,t,-1)}function xR(e,t){return CR(e,t,0)}function SR(e,t){return CR(e,t,1)}function CR(e,t,n){let r=new Date;r.setMonth(r.getMonth()+n),r.setDate(1),r.setHours(0,0,0,0);let i=new Date(r.getTime());return i.setMonth(i.getMonth()+1),i.setDate(1),i.setHours(0,0,0,0),i.setTime(i.getTime()-1),TR(e,t,r,i)}function wR(e,t){let n=new Date;return n.setMonth(0),n.setDate(1),n.setHours(0,0,0,0),TR(e,t,n,new Date)}function TR(e,t,n,r){return e=fR(e,t),e=ER(e,t,X.GREATER_THAN_OR_EQUALS,n),e=ER(e,t,X.LESS_THAN_OR_EQUALS,r),e}function ER(e,t,n,r){return pR(e,t,n,r.toISOString())}function DR(e,t,n=!0){return pR(e,t,X.MISSING,n.toString())}function OR(e,t){return e.offset===t?e:{...e,offset:t,name:void 0}}function kR(e,t){let n=e.count??20;return OR(e,(t-1)*n)}function AR(e,t,n){return t===jR(e)&&n!==void 0&&n===MR(e)?e:{...e,sortRules:[{code:t,descending:!!n}],name:void 0}}function jR(e){let t=e.sortRules;if(!t||t.length===0)return;let n=t[0].code;return n.startsWith(`-`)?n.substr(1):n}function MR(e){let t=e.sortRules;return!t||t.length===0?!1:!!t[0].descending}function NR(e){return lR[e.type]}function PR(e){return uR[e]??``}function FR(e){let t=e;return t.includes(`.`)&&(t=t.split(`.`).pop()),t===`versionId`?`Version ID`:(t=t.replace(`[x]`,``),t=t.replaceAll(/([A-Z])/g,` $1`),t=t.replaceAll(/[-_]/g,` `),t=t.replaceAll(/\s+/g,` `),t=t.trim(),t.toLowerCase()===`id`?`ID`:t.split(/\s/).map(UC).join(` `))}function IR(e,t){let n=t.name;return n===`id`?(0,I.jsx)(Kj,{to:`/${e.resourceType}/${e.id}`,children:e.id}):n===`meta.versionId`?e.meta?.versionId:n===`_lastUpdated`?fw(e.meta?.lastUpdated):`${e.resourceType}.${t.name}`===t.elementDefinition?.path?LR(e,t.elementDefinition):t.searchParams?.length===1&&t.name===t.searchParams[0].code?RR(e,t.searchParams[0]):null}function LR(e,t){let n=t.path?.split(`.`)?.pop()?.replaceAll(`[x]`,``)??``,[r,i]=sF({type:e.resourceType,value:e},n);return r?(0,I.jsx)(CF,{path:t.path,property:t,propertyType:i,value:r,maxWidth:200,ignoreMissingValues:!0,link:!1}):null}function RR(e,t){let n=RT(t.expression,[{type:e.resourceType,value:e}]);return!n||n.length===0?null:(0,I.jsx)(I.Fragment,{children:n.map((e,t)=>(0,I.jsx)(CF,{propertyType:e.type,value:e.value,maxWidth:200,ignoreMissingValues:!0,link:!1},`${t}-${n.length}`))})}function zR(e){let t=(0,b.useRef)(!1),[n,r]=(0,b.useState)({search:JSON.parse(yC(e.search))}),[i,a]=(0,b.useState)(!1);(0,b.useEffect)(()=>{r({search:e.search})},[e.search]);let o=(0,b.useMemo)(()=>{if(!e.visible)return[];let t=e.search.resourceType;return ZC(BR(mS(t),Pw(t))).map(e=>({value:e,label:FR(e)}))},[e.visible,e.search.resourceType]);function s(e){r({search:{...n.search,fields:e}})}return(0,I.jsx)(rg,{title:`Fields`,closeButtonProps:{"aria-label":`Close`},opened:e.visible,onClose:()=>{e.onCancel()},size:`auto`,withOverlay:!0,closeOnClickOutside:!1,overlayProps:{onMouseDownCapture:()=>{t.current=i},onClick:()=>{t.current||e.onCancel(),t.current=!1},children:(0,I.jsx)(`div`,{"data-testid":`overlay-child`})},children:(0,I.jsxs)(G,{children:[(0,I.jsx)(Sg,{style:{width:550},placeholder:`Select fields to display`,data:o,value:n.search.fields??[],onChange:s,onDropdownOpen:()=>a(!0),onDropdownClose:()=>a(!1),maxDropdownHeight:`250px`,clearButtonProps:{"aria-label":`Clear selection`},clearable:!0,searchable:!0}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(U,{onClick:()=>e.onOk(n.search),children:`OK`})})]})})}function BR(e,t){let n=[],r=new Set,i=new Set;for(let t of Object.keys(e.elements))n.push(t),r.add(t.toLowerCase()),i.add(FR(t));if(t)for(let e of Object.keys(t)){let t=FR(e);!r.has(e)&&!i.has(t)&&(n.push(e),r.add(e),i.add(t))}return n}function VR(e){let t=kO(e.resourceType,e.searchParam),n=e.name??`filter-value`;switch(t.type){case OO.REFERENCE:return(0,I.jsx)(uI,{name:n,defaultValue:e.defaultValue?{reference:e.defaultValue}:void 0,targetTypes:e.searchParam.target,autoFocus:e.autoFocus,onChange:t=>{t?e.onChange(t.reference):e.onChange(``)}});case OO.BOOLEAN:return(0,I.jsx)(lp,{name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultChecked:e.defaultValue===`true`,autoFocus:e.autoFocus,onChange:t=>e.onChange(t.currentTarget.checked.toString())});case OO.DATE:return(0,I.jsx)(yb,{type:`date`,name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:t=>e.onChange(t.currentTarget.value)});case OO.DATETIME:return(0,I.jsx)(GF,{name:n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:e.onChange});case OO.NUMBER:return(0,I.jsx)(yb,{type:`number`,name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:t=>e.onChange(t.currentTarget.value)});case OO.QUANTITY:return(0,I.jsx)($F,{name:n,path:``,defaultValue:HR(e.defaultValue),autoFocus:e.autoFocus,onChange:t=>{t?e.onChange(`${t.value}`):e.onChange(``)}});default:return(0,I.jsx)(yb,{name:n,"data-autofocus":e.autoFocus,"data-testid":n,defaultValue:e.defaultValue,autoFocus:e.autoFocus,onChange:t=>e.onChange(t.currentTarget.value),placeholder:`Search value`})}}function HR(e){if(e){let[t,n,r]=e.split(`|`);if(t)return{value:Number.parseFloat(t),system:n,unit:r}}}function UR(e){let[t,n]=(0,b.useState)(MC(e.search)),r=(0,b.useRef)(t);(0,b.useLayoutEffect)(()=>{r.current=t}),(0,b.useEffect)(()=>{n(MC(e.search))},[e.search]);function i(e){n(pR(r.current,e.code,e.operator,e.value))}let a=e.search.resourceType,o=Pw(a)??{},s=t.filters||[];return(0,I.jsx)(rg,{title:`Filters`,closeButtonProps:{"aria-label":`Close`},size:900,opened:e.visible,onClose:e.onCancel,children:(0,I.jsxs)(TN,{onSubmit:()=>e.onOk(r.current),children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`table`,{children:[(0,I.jsxs)(`colgroup`,{children:[(0,I.jsx)(`col`,{style:{width:200}}),(0,I.jsx)(`col`,{style:{width:200}}),(0,I.jsx)(`col`,{style:{width:380}}),(0,I.jsx)(`col`,{style:{width:40}})]}),(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:`Field`}),(0,I.jsx)(`th`,{children:`Operation`}),(0,I.jsx)(`th`,{children:`Value`}),(0,I.jsx)(`th`,{})]})}),(0,I.jsx)(`tbody`,{children:s.map((e,t)=>(0,I.jsx)(WR,{id:`filter-${t}-row`,resourceType:a,searchParams:o,value:e,onChange:e=>{let i=[...s];i[t]=e,n(dR(r.current,i))},onDelete:()=>n(mR(r.current,t))},`filter-${t}-row`))})]}),(0,I.jsx)(_I,{propertyDisplayName:`Filter`,onClick:()=>i({})})]}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,children:(0,I.jsx)(EN,{children:`OK`})})]})})}function WR(e){let t=e.value;function n(t){e.onChange({code:t,operator:X.EQUALS,value:``})}function r(n){e.onChange({code:t.code,operator:n,value:``})}function i(n){e.onChange({code:t.code,operator:t.operator,value:n})}let a=e.searchParams[t.code],o=a&&NR(a);return(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:(0,I.jsx)(Eg,{"data-testid":`${e.id}-filter-field`,defaultValue:e.value.code,onChange:e=>n(e.currentTarget.value),data:[``,...Object.keys(e.searchParams).map(e=>({value:e,label:FR(e)}))]})}),(0,I.jsx)(`td`,{children:o&&(0,I.jsx)(Eg,{"data-testid":`${e.id}-filter-operation`,defaultValue:t.operator,onChange:e=>r(e.currentTarget.value),data:[``,...o.map(e=>({value:e,label:PR(e)}))]},`${e.id}-filter-value-${e.value.code}`)}),(0,I.jsx)(`td`,{children:a&&t.operator&&(0,I.jsx)(VR,{name:`${e.id}-filter-value`,resourceType:e.resourceType,searchParam:a,defaultValue:t.value,onChange:i},`${e.id}-filter-value-${e.value.code}-${e.value.operator}`)}),(0,I.jsx)(`td`,{children:e.onDelete&&(0,I.jsx)(gu,{variant:`outline`,color:`red`,radius:`xl`,"aria-label":`Delete filter`,onClick:e.onDelete,children:(0,I.jsx)(Fj,{style:{width:`70%`,height:`70%`},stroke:1.5})})})]})}function GR(e){let[t,n]=(0,b.useState)(e.defaultValue??``);if(!e.searchParam||!e.filter)return null;function r(){e.onOk({...e.filter,value:t})}return(0,I.jsx)(rg,{title:e.title,size:`xl`,opened:e.visible,onClose:e.onCancel,children:(0,I.jsx)(TN,{onSubmit:r,children:(0,I.jsxs)(Tm,{children:[(0,I.jsx)(Tm.Col,{span:10,children:(0,I.jsx)(VR,{resourceType:e.resourceType,searchParam:e.searchParam,defaultValue:t,autoFocus:!0,onChange:n})}),(0,I.jsx)(Tm.Col,{span:2,children:(0,I.jsx)(U,{onClick:r,fullWidth:!0,children:`OK`})})]})})})}function KR(e){let{resourceType:t,filter:n}=e,r=Ww.types[t].searchParams?.[n.code];if(r){if(r.type===`reference`&&(n.operator===X.EQUALS||n.operator===X.NOT_EQUALS))return(0,I.jsx)(pL,{value:{reference:n.value}});let e=kO(t,r);if(n.code===`_lastUpdated`||e.type===OO.DATETIME)return(0,I.jsx)(I.Fragment,{children:fw(n.value)})}return(0,I.jsx)(I.Fragment,{children:n.value})}function qR(e){if(!e.searchParams)return null;function t(t,n){i(AR(e.search,t.code,n))}function n(t){i(fR(e.search,t.code))}function r(t,n){e.onPrompt(t,{code:t.code,operator:n,value:``})}function i(t){e.onChange(t)}return e.searchParams.length===1?(0,I.jsx)(JR,{search:e.search,searchParam:e.searchParams[0],onSort:t,onPrompt:r,onChange:i,onClear:n}):(0,I.jsx)(W.Dropdown,{children:e.searchParams.map(e=>(0,I.jsx)(W.Item,{children:FR(e.code)},e.code))})}function JR(e){switch(e.searchParam.type){case`date`:return(0,I.jsx)(YR,{...e});case`number`:case`quantity`:return(0,I.jsx)(XR,{...e});case`reference`:return(0,I.jsx)(ZR,{...e});case`string`:return(0,I.jsx)(QR,{...e});case`token`:return(0,I.jsx)($R,{...e});case`uri`:return(0,I.jsx)(ez,{...e});default:return(0,I.jsxs)(I.Fragment,{children:[`Unknown search param type: `,e.searchParam.type]})}}function YR(e){let{searchParam:t}=e,n=t.code;return(0,I.jsxs)(W.Dropdown,{children:[(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(Sj,{size:14}),onClick:()=>e.onSort(t,!1),children:`Sort Oldest to Newest`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(Cj,{size:14}),onClick:()=>e.onSort(t,!0),children:`Sort Newest to Oldest`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(HA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Equals...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(VA,{size:14}),onClick:()=>e.onPrompt(t,X.NOT_EQUALS),children:`Does not equal...`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(rj,{size:14}),onClick:()=>e.onPrompt(t,X.ENDS_BEFORE),children:`Before...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(nj,{size:14}),onClick:()=>e.onPrompt(t,X.STARTS_AFTER),children:`After...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(yA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Between...`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(TA,{size:14}),onClick:()=>e.onChange(_R(e.search,n)),children:`Tomorrow`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(TA,{size:14}),onClick:()=>e.onChange(gR(e.search,n)),children:`Today`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(TA,{size:14}),onClick:()=>e.onChange(hR(e.search,n)),children:`Yesterday`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(TA,{size:14}),onClick:()=>e.onChange(yR(e.search,n)),children:`Next 24 Hours`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(TA,{size:14}),onClick:()=>e.onChange(SR(e.search,n)),children:`Next Month`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(TA,{size:14}),onClick:()=>e.onChange(xR(e.search,n)),children:`This Month`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(TA,{size:14}),onClick:()=>e.onChange(bR(e.search,n)),children:`Last Month`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(TA,{size:14}),onClick:()=>e.onChange(wR(e.search,n)),children:`Year to date`}),(0,I.jsx)(tz,{...e})]})}function XR(e){let{searchParam:t}=e;return(0,I.jsxs)(W.Dropdown,{children:[(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(Sj,{size:14}),onClick:()=>e.onSort(t,!1),children:`Sort Smallest to Largest`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(Cj,{size:14}),onClick:()=>e.onSort(t,!0),children:`Sort Largest to Smallest`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(HA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Equals...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(VA,{size:14}),onClick:()=>e.onPrompt(t,X.NOT_EQUALS),children:`Does not equal...`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(nj,{size:14}),onClick:()=>e.onPrompt(t,X.GREATER_THAN),children:`Greater than...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(xj,{size:14}),onClick:()=>e.onPrompt(t,X.GREATER_THAN_OR_EQUALS),children:`Greater than or equal to...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(rj,{size:14}),onClick:()=>e.onPrompt(t,X.LESS_THAN),children:`Less than...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(xj,{size:14}),onClick:()=>e.onPrompt(t,X.LESS_THAN_OR_EQUALS),children:`Less than or equal to...`}),(0,I.jsx)(tz,{...e})]})}function ZR(e){let{searchParam:t}=e;return(0,I.jsxs)(W.Dropdown,{children:[(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(HA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Equals...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(VA,{size:14}),onClick:()=>e.onPrompt(t,X.NOT),children:`Does not equal...`}),(0,I.jsx)(tz,{...e})]})}function QR(e){let{searchParam:t}=e;return(0,I.jsxs)(W.Dropdown,{children:[(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(Sj,{size:14}),onClick:()=>e.onSort(t,!1),children:`Sort A to Z`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(Cj,{size:14}),onClick:()=>e.onSort(t,!0),children:`Sort Z to A`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(HA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Equals...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(VA,{size:14}),onClick:()=>e.onPrompt(t,X.NOT),children:`Does not equal...`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(CA,{size:14}),onClick:()=>e.onPrompt(t,X.CONTAINS),children:`Contains...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(SA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Does not contain...`}),(0,I.jsx)(tz,{...e})]})}function $R(e){let{searchParam:t}=e;return(0,I.jsxs)(W.Dropdown,{children:[(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(HA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Equals...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(VA,{size:14}),onClick:()=>e.onPrompt(t,X.NOT),children:`Does not equal...`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(HA,{size:14}),onClick:()=>e.onPrompt(t,X.TEXT),children:`Text contains...`}),(0,I.jsx)(tz,{...e})]})}function ez(e){let{searchParam:t}=e;return(0,I.jsxs)(W.Dropdown,{children:[(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(HA,{size:14}),onClick:()=>e.onPrompt(t,X.EQUALS),children:`Equals...`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(VA,{size:14}),onClick:()=>e.onPrompt(t,X.NOT),children:`Does not equal...`}),(0,I.jsx)(tz,{...e})]})}function tz(e){let{searchParam:t}=e,n=t.code;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(gA,{size:14}),onClick:()=>e.onChange(DR(e.search,n)),children:`Missing`}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(hA,{size:14}),onClick:()=>e.onChange(DR(e.search,n,!1)),children:`Not missing`}),(0,I.jsx)(W.Divider,{}),(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(Fj,{size:14}),onClick:()=>e.onClear(t),children:`Clear filters`})]})}function nz(e){switch(e){case`next`:return{"aria-label":`Next page`};case`previous`:return{"aria-label":`Previous page`};case`first`:return{"aria-label":`First page`};case`last`:return{"aria-label":`Last page`};default:return{}}}var rz={root:`_root_vlout_1`,table:`_table_vlout_8`,tr:`_tr_vlout_12`,th:`_th_vlout_18`,control:`_control_vlout_22`,icon:`_icon_vlout_31`};function iz(e){let t=e.resourceType,n=[];for(let r of e.fields||[`id`,`_lastUpdated`])n.push(az(t,r));return n}function az(e,t){if(t===`_lastUpdated`)return{name:`_lastUpdated`,searchParams:[{resourceType:`SearchParameter`,base:[`Resource`],code:`_lastUpdated`,name:`_lastUpdated`,type:`date`,expression:`Resource.meta.lastUpdated`}]};if(t===`meta.versionId`)return{name:`meta.versionId`,searchParams:[{resourceType:`SearchParameter`,base:[`Resource`],code:`_versionId`,name:`_versionId`,type:`token`,expression:`Resource.meta.versionId`}]};let n=Bw(e,t),r=Fw(e,t.toLowerCase());if(n&&r)return{name:t,elementDefinition:n,searchParams:[r]};if(n){let r=Pw(e),i;if(r){let n=RegExp(`${e}\\.${t.replaceAll(`[x]`,``)}([^\\w-]|$)`);i=Object.values(r).filter(e=>!!e.expression&&n.test(e?.expression)),i.length===0&&(i=void 0)}return{name:t,elementDefinition:n,searchParams:i}}return r?{name:t,elementDefinition:kO(e,r).elementDefinitions?.[0],searchParams:[r]}:{name:t}}var oz=class extends Event{definition;constructor(e){super(`change`),this.definition=e}},sz=class extends Event{response;constructor(e){super(`load`),this.response=e}},cz=class extends Event{resource;browserEvent;constructor(e,t){super(`click`),this.resource=e,this.browserEvent=t}};function lz(e){let t=Z(),[n,r]=(0,b.useState)(),{search:i,onLoad:a}=e,[o,s]=(0,b.useState)(i);EC(i,o)||s(i);let[c,l]=(0,b.useState)({selected:{},fieldEditorVisible:!1,filterEditorVisible:!1,exportDialogVisible:!1,filterDialogVisible:!1}),u=(0,b.useRef)(c);(0,b.useLayoutEffect)(()=>{u.current=c});let d=o.total??`accurate`,f=(0,b.useCallback)(e=>{r(void 0),t.requestSchema(o.resourceType).then(()=>t.search(o.resourceType,cE({...o,total:d,fields:void 0}),e)).then(e=>{l({...u.current,searchResponse:e}),a&&a(new sz(e))}).catch(e=>{l({...u.current,searchResponse:void 0}),r(Zx(e))})},[t,o,d,a]),p=(0,b.useCallback)(()=>{l({...u.current,searchResponse:void 0}),f({cache:`reload`})},[f]);(0,b.useEffect)(()=>{f()},[f]);function m(e,t){e.stopPropagation();let n=e.target.checked,r={...u.current.selected};n?r[t]=!0:delete r[t],l({...u.current,selected:r})}function h(e){e.stopPropagation();let t=e.target.checked,n={},r=u.current.searchResponse;t&&r?.entry&&r.entry.forEach(e=>{e.resource?.id&&(n[e.resource.id]=!0)}),l({...u.current,selected:n})}function g(){if(!c.searchResponse?.entry||c.searchResponse.entry.length===0)return!1;for(let e of c.searchResponse.entry)if(e.resource?.id&&!c.selected[e.resource.id])return!1;return!0}function _(t){e.onChange&&e.onChange(new oz(t))}function v(t,n){if(Hj(t.target)||t.button===2)return;Bj(t);let r=Vj(t);!r&&e.onClick&&e.onClick(new cz(n,t)),r&&e.onAuxClick&&e.onAuxClick(new cz(n,t))}function y(){return!!(e.onExport??e.onExportCsv??e.onExportTransactionBundle)}if(n)return(0,I.jsx)(BP,{outcome:n});if(!fS(o.resourceType))return(0,I.jsx)(Kp,{style:{width:`100%`,height:`100%`},children:(0,I.jsx)(cu,{})});let x=e.checkboxesEnabled,S=iz(o),C=o.resourceType,w=c.searchResponse,T=(w?.entry)?.map(e=>e.resource),E=`subtle`,D=`gray`,O=window.innerWidth<768;return(0,I.jsxs)(`div`,{className:rz.root,"data-testid":`search-control`,children:[!e.hideToolbar&&(0,I.jsxs)(V,{justify:`space-between`,mb:`xl`,children:[(0,I.jsxs)(V,{gap:2,children:[(0,I.jsx)(U,{size:`compact-md`,variant:E,color:D,leftSection:(0,I.jsx)(NA,{size:16}),onClick:()=>l({...u.current,fieldEditorVisible:!0,dialogOpenTime:Date.now()}),children:`Fields`}),(0,I.jsx)(U,{size:`compact-md`,variant:E,color:D,leftSection:(0,I.jsx)(qA,{size:16}),onClick:()=>l({...u.current,filterEditorVisible:!0,dialogOpenTime:Date.now()}),children:`Filters`}),e.onNew&&(0,I.jsx)(U,{size:`compact-md`,variant:E,color:D,leftSection:(0,I.jsx)(KA,{size:16}),onClick:e.onNew,children:`New...`}),!O&&y()&&(0,I.jsx)(U,{size:`compact-md`,variant:E,color:D,leftSection:(0,I.jsx)(Oj,{size:16}),onClick:e.onExport?e.onExport:()=>l({...u.current,exportDialogVisible:!0,dialogOpenTime:Date.now()}),children:`Export...`}),!O&&e.onDelete&&(0,I.jsx)(U,{size:`compact-md`,variant:E,color:D,leftSection:(0,I.jsx)(jj,{size:16}),onClick:()=>e.onDelete(Object.keys(c.selected)),children:`Delete...`}),!O&&e.onBulk&&(0,I.jsx)(U,{size:`compact-md`,variant:E,color:D,leftSection:(0,I.jsx)(vA,{size:16}),onClick:()=>e.onBulk(Object.keys(c.selected)),children:`Bulk...`})]}),(0,I.jsxs)(V,{gap:2,children:[w&&(0,I.jsxs)(H,{size:`xs`,c:`dimmed`,"data-testid":`count-display`,children:[pz(o,w).toLocaleString(),`-`,mz(o,w).toLocaleString(),w.total!==void 0&&` of ${o.total===`estimate`?`~`:``}${w.total?.toLocaleString()}`]}),(0,I.jsx)(gu,{variant:E,color:D,title:`Refresh`,onClick:p,children:(0,I.jsx)(gj,{size:16})})]})]}),(0,I.jsxs)(K,{className:rz.table,children:[(0,I.jsxs)(K.Thead,{children:[(0,I.jsxs)(K.Tr,{children:[x&&(0,I.jsx)(K.Th,{children:(0,I.jsx)(`input`,{type:`checkbox`,value:`checked`,"aria-label":`all-checkbox`,"data-testid":`all-checkbox`,checked:g(),onChange:e=>h(e)})}),S.map(e=>(0,I.jsx)(K.Th,{children:(0,I.jsxs)(W,{shadow:`md`,width:240,position:`bottom-end`,children:[(0,I.jsx)(W.Target,{children:(0,I.jsx)(ml,{className:rz.control,p:2,children:(0,I.jsxs)(V,{justify:`space-between`,wrap:`nowrap`,children:[(0,I.jsx)(H,{fw:500,children:FR(e.name)}),(0,I.jsx)(Kp,{className:rz.icon,children:(0,I.jsx)(dA,{size:14,stroke:1.5})})]})})}),(0,I.jsx)(qR,{search:o,searchParams:e.searchParams,onPrompt:(e,t)=>{l({...u.current,filterDialogVisible:!0,filterDialogSearchParam:e,filterDialogFilter:t,dialogOpenTime:Date.now()})},onChange:e=>{_(e)}})]})},e.name))]}),!e.hideFilters&&(0,I.jsxs)(K.Tr,{children:[x&&(0,I.jsx)(K.Th,{}),S.map(e=>(0,I.jsx)(K.Th,{children:e.searchParams&&(0,I.jsx)(uz,{resourceType:C,searchParams:e.searchParams,filters:o.filters})},e.name))]})]}),(0,I.jsx)(K.Tbody,{children:T?.map(e=>e&&(0,I.jsxs)(K.Tr,{className:rz.tr,"data-testid":`search-control-row`,onClick:t=>v(t,e),onAuxClick:t=>v(t,e),children:[x&&(0,I.jsx)(K.Td,{children:(0,I.jsx)(`input`,{type:`checkbox`,value:`checked`,"data-testid":`row-checkbox`,"aria-label":`Checkbox for ${e.id}`,checked:!!c.selected[e.id],onChange:t=>m(t,e.id)})}),S.map(t=>(0,I.jsx)(K.Td,{children:IR(e,t)},t.name))]},e.id))})]}),!T?.length&&(0,I.jsx)(_P,{children:(0,I.jsx)(Kp,{style:{height:150},children:(0,I.jsx)(H,{size:`xl`,c:`dimmed`,children:`No results`})})}),w&&(0,I.jsx)(Kp,{m:`md`,p:`md`,children:(0,I.jsx)(rv,{value:dz(o),total:fz(o,w),onChange:e=>_(kR(o,e)),getControlProps:nz})}),(0,I.jsx)(zR,{search:o,visible:c.fieldEditorVisible,onOk:e=>{_(e),l({...u.current,fieldEditorVisible:!1})},onCancel:()=>{l({...u.current,fieldEditorVisible:!1})}},`search-field-editor-${c.dialogOpenTime}`),(0,I.jsx)(UR,{search:o,visible:c.filterEditorVisible,onOk:e=>{_(e),l({...u.current,filterEditorVisible:!1})},onCancel:()=>{l({...u.current,filterEditorVisible:!1})}},`search-filter-editor-${c.dialogOpenTime}`),(0,I.jsx)(sR,{visible:c.exportDialogVisible,exportCsv:e.onExportCsv,exportTransactionBundle:e.onExportTransactionBundle,onCancel:()=>{l({...u.current,exportDialogVisible:!1})}},`search-export-dialog-${c.dialogOpenTime}`),(0,I.jsx)(GR,{visible:c.filterDialogVisible,title:c.filterDialogSearchParam?.code?FR(c.filterDialogSearchParam.code):``,resourceType:C,searchParam:c.filterDialogSearchParam,filter:c.filterDialogFilter,defaultValue:``,onOk:e=>{_(pR(o,e.code,e.operator,e.value)),l({...u.current,filterDialogVisible:!1})},onCancel:()=>{l({...u.current,filterDialogVisible:!1})}},`search-filter-dialog-${c.dialogOpenTime}`)]})}function uz(e){let t=(e.filters??[]).filter(t=>e.searchParams.find(e=>e.code===t.code));return t.length===0?(0,I.jsx)(`span`,{children:`no filters`}):(0,I.jsx)(I.Fragment,{children:t.map(t=>(0,I.jsxs)(`div`,{children:[PR(t.operator),`\xA0`,(0,I.jsx)(KR,{resourceType:e.resourceType,filter:t})]},`filter-${t.code}-${t.operator}-${t.value}`))})}function dz(e){return Math.floor((e.offset??0)/(e.count??20))+1}function fz(e,t){let n=e.count??20,r=hz(e,t);return Math.ceil(r/n)}function pz(e,t){return Math.min(hz(e,t),(e.offset??0)+1)}function mz(e,t){return Math.max(pz(e,t)+(t.entry?.length??0)-1,0)}function hz(e,t){let n=t.total;return n===void 0&&(n=(e.offset??0)+(t.entry?.length??0)+ +!!t.link?.some(e=>e.relation===`next`)),n}function gz(e){let t=Z(),[n,r]=(0,b.useState)(!1),[i,a]=(0,b.useState)(),{query:o,fields:s}=e,[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)({});(0,b.useEffect)(()=>{a(void 0),t.graphql(o).then(l).catch(e=>a(Zx(e)))},[t,o]);function f(e,t){e.stopPropagation();let n=e.target.checked,r={...u};n?r[t]=!0:delete r[t],d(r)}function p(e){e.stopPropagation();let t=e.target.checked,n={},r=c?.data.ResourceList;t&&r&&r.forEach(e=>{e.id&&(n[e.id]=!0)}),d(n)}function m(){let e=c?.data.ResourceList;if(!e||e.length===0)return!1;for(let t of e)if(t.id&&!u[t.id])return!1;return!0}function h(t,n){Hj(t.target)||(Bj(t),t.button!==1&&e.onClick&&e.onClick(new cz(n,t)),t.button===1&&e.onAuxClick&&e.onAuxClick(new cz(n,t)))}if((0,b.useEffect)(()=>{t.requestSchema(e.resourceType).then(()=>r(!0)).catch(console.log)},[t,e.resourceType]),!n)return(0,I.jsx)(cu,{});let g=e.checkboxesEnabled;return(0,I.jsxs)(`div`,{onContextMenu:e=>Bj(e),"data-testid":`search-control`,children:[(0,I.jsxs)(K,{children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[g&&(0,I.jsx)(K.Th,{children:(0,I.jsx)(`input`,{type:`checkbox`,value:`checked`,"aria-label":`all-checkbox`,"data-testid":`all-checkbox`,checked:m(),onChange:e=>p(e)})}),s.map(e=>(0,I.jsx)(K.Th,{children:e.name},e.name))]})}),(0,I.jsx)(K.Tbody,{children:c?.data.ResourceList.map(e=>e&&(0,I.jsxs)(K.Tr,{"data-testid":`search-control-row`,onClick:t=>h(t,e),onAuxClick:t=>h(t,e),children:[g&&(0,I.jsx)(K.Td,{children:(0,I.jsx)(`input`,{type:`checkbox`,value:`checked`,"data-testid":`row-checkbox`,"aria-label":`Checkbox for ${e.id}`,checked:!!u[e.id],onChange:t=>f(t,e.id)})}),s.map(t=>(0,I.jsx)(K.Td,{children:(0,I.jsx)(oR,{propertyType:t.propertyType,path:t.fhirPath,resource:e})},t.name))]},e.id))})]}),c?.data.ResourceList.length===0&&(0,I.jsx)(`div`,{"data-testid":`empty-search`,children:`No results`}),i&&(0,I.jsx)(`div`,{"data-testid":`search-error`,children:(0,I.jsx)(`pre`,{style:{textAlign:`left`},children:JSON.stringify(i,void 0,2)})}),e.onBulk&&(0,I.jsx)(U,{onClick:()=>e.onBulk(Object.keys(u)),children:`Bulk...`})]})}var _z=(0,b.memo)(gz),vz={root:`_root_1fbwr_1`,entry:`_entry_1fbwr_8`,key:`_key_1fbwr_13`,value:`_value_1fbwr_20`};function yz(e){return(0,I.jsx)(ul,{children:(0,I.jsx)(`div`,{className:vz.root,children:e.children})})}yz.Entry=function(e){return(0,I.jsx)(`div`,{className:vz.entry,children:e.children})},yz.Key=function(e){return(0,I.jsx)(`div`,{className:vz.key,children:e.children})},yz.Value=function(e){return(0,I.jsx)(`div`,{className:vz.value,children:e.children})};var bz={list:`_list_y4z6g_1`,link:`_link_y4z6g_6`};function xz(e){let{baseUrl:t,tabs:n,children:r,...i}=e,a=Sz(n),o=JO(),[s,c]=(0,b.useState)(()=>{let e=LE.getPathname().split(`/`).pop();if(e){let t=e.toLowerCase(),n=a.find(e=>e.value.split(/[?#]/)[0].toLowerCase()===t);if(n)return n.value}return a[0].value});function l(e){e||=a[0].value,c(e),o(`${t}/${e}`)}return(0,I.jsxs)(vb,{value:s,onChange:l,...i,children:[(0,I.jsx)(vb.List,{className:bz.list,children:a.map(e=>(0,I.jsx)(vb.Tab,{value:e.value,children:(0,I.jsx)(Pd,{className:bz.link,href:`${t}/${e.value}`,onClick:Cz,children:e.label})},e.value))}),r]})}function Sz(e){return e.map(e=>FC(e)?{label:e,value:e.toLowerCase()}:e)}function Cz(e){Vj(e)||e.preventDefault()}function wz(e){let{group:t}=e;return(0,I.jsx)(yl,{withBorder:!0,radius:`md`,p:`xs`,display:`flex`,style:{alignItems:`center`,justifyContent:`center`},children:(0,I.jsxs)(V,{children:[t.measureScore&&(0,I.jsx)(Dz,{group:t}),!t.measureScore&&(0,I.jsx)(Ez,{group:t})]})})}function Tz(e){let{measure:t}=e;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(H,{fz:`md`,fw:500,mb:8,children:t.title}),(0,I.jsx)(H,{fz:`xs`,c:`dimmed`,mb:8,children:t.subtitle})]})}function Ez(e){let{group:t}=e,n=t.population,r=n?.find(e=>Sw(e.code)===`numerator`),i=n?.find(e=>Sw(e.code)===`denominator`),a=r?.count,o=i?.count;if(o===0)return(0,I.jsxs)(z,{children:[(0,I.jsx)(q,{order:3,children:`Not Applicable`}),(0,I.jsx)(H,{children:`Denominator: ${o}`})]});if(a===void 0||o===void 0)return(0,I.jsxs)(z,{children:[(0,I.jsx)(q,{order:3,children:`Insufficient Data`}),(0,I.jsx)(H,{children:`Numerator: ${a}`}),(0,I.jsx)(H,{children:`Denominator: ${o}`})]});let s=a/o*100;return(0,I.jsx)(oy,{size:120,thickness:12,roundCaps:!0,sections:[{value:s,color:kz(s)}],label:(0,I.jsx)(_d,{justify:`center`,children:(0,I.jsxs)(H,{fw:700,fz:18,children:[a,` / `,o]})})})}function Dz(e){let{group:t}=e;return(0,I.jsx)(I.Fragment,{children:(t.measureScore?.unit??t.measureScore?.code)===`%`?(0,I.jsx)(oy,{size:120,thickness:12,roundCaps:!0,sections:[{value:Oz(t),color:kz(t?.measureScore?.value??0)}],label:(0,I.jsx)(_d,{justify:`center`,children:(0,I.jsx)(H,{fw:700,fz:18,children:(0,I.jsx)(pF,{value:t.measureScore})})})}):(0,I.jsx)(_d,{h:120,align:`center`,children:(0,I.jsx)(q,{order:3,children:(0,I.jsx)(pF,{value:t.measureScore})})})})}function Oz(e){let t=e.measureScore?.value,n=e.measureScore?.unit;return t?t<=1&&n===`%`?t*100:t:0}function kz(e){return e<=33?`red`:e<=67?`yellow`:`green`}function Az(e){let t=ik(e.measureReport),[n]=Xk(`Measure`,{url:t?.measure});return t?(0,I.jsxs)(z,{children:[n&&(0,I.jsx)(Tz,{measure:n}),(0,I.jsx)(vy,{cols:{base:3,sm:1},spacing:{base:`md`,sm:`sm`},children:t.group?.map((e,t)=>(0,I.jsx)(wz,{group:e},e.id??t))})]}):null}var jz=`patient-accounts`,Mz=`Patient Accounts`,Nz=[`Organization`,`HealthcareService`,`CareTeam`];function Pz(e){let{patient:t}=e,n=Z(),r=n.isProjectAdmin()||n.isSuperAdmin(),i=(0,b.useMemo)(()=>cC(t.meta)??[],[t.meta]),[a,o]=(0,b.useState)(i),[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(!0),[d,f]=(0,b.useState)(!1),p=(0,b.useMemo)(()=>{let e=[];for(let t of a)i.some(e=>e.reference===t.reference)||e.push({reference:t,type:`addition`});for(let t of i)a.some(e=>e.reference===t.reference)||e.push({reference:t,type:`removal`});return e},[i,a]),m=p.length>0,h=(0,b.useCallback)(e=>{e?.reference&&(a.some(t=>t.reference===e.reference)||o(t=>[...t,e]))},[a]),g=(0,b.useCallback)(e=>{o(t=>t.filter(t=>t.reference!==e))},[]),_=(0,b.useCallback)(async()=>{let r=t.id;if(!r){zb.show({id:jz,title:Mz,color:`red`,message:`Cannot update accounts: Patient resource has no ID.`,icon:(0,I.jsx)(Fj,{size:`1rem`}),autoClose:!1,withCloseButton:!0});return}f(!0),c(!1);let i=n.fhirUrl(`Patient`,r,`$set-accounts`),o={resourceType:`Parameters`,parameter:[...a.map(e=>({name:`accounts`,valueReference:{reference:e.reference}})),{name:`propagate`,valueBoolean:l}]};zb.show({id:jz,title:Mz,loading:!0,message:l?`Saving account changes and propagating to compartment...`:`Saving account changes...`,autoClose:!1,withCloseButton:!1});try{let t={};l&&(t.Prefer=`respond-async`),await n.post(i,o,void 0,{headers:t}),n.invalidateUrl(n.fhirUrl(`Patient`,r)),zb.update({id:jz,title:Mz,color:`green`,message:l?`Account changes saved. Compartment updates are being applied.`:`Account changes saved.`,icon:(0,I.jsx)(EA,{size:`1rem`}),loading:!1,autoClose:!0,withCloseButton:!0}),e.onSaved?.()}catch(e){zb.update({id:jz,title:Mz,color:`red`,message:Qx(e),icon:(0,I.jsx)(Fj,{size:`1rem`}),loading:!1,autoClose:!1,withCloseButton:!0})}finally{f(!1)}},[n,t,a,l,e]);return r?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(G,{children:[(0,I.jsx)(q,{order:3,children:`Current Accounts`}),a.length===0?(0,I.jsx)(H,{c:`dimmed`,children:`No accounts assigned to this patient.`}):(0,I.jsxs)(K,{children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:`Type`}),(0,I.jsx)(K.Th,{children:`Account`}),(0,I.jsx)(K.Th,{})]})}),(0,I.jsx)(K.Tbody,{children:a.map(e=>(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:(0,I.jsx)(Fz,{reference:e})}),(0,I.jsx)(K.Td,{children:(0,I.jsx)(mL,{value:e,link:!0})}),(0,I.jsx)(K.Td,{children:(0,I.jsx)(gu,{variant:`subtle`,color:`red`,"aria-label":`Remove ${e.reference}`,onClick:()=>g(e.reference),children:(0,I.jsx)(Fj,{size:16})})})]},e.reference))})]}),(0,I.jsx)(dm,{}),(0,I.jsx)(q,{order:4,children:`Add Account`}),(0,I.jsx)(uI,{name:`newAccount`,placeholder:`Search for Organization, HealthcareService, or CareTeam...`,targetTypes:Nz,onChange:e=>{e&&h(e)}}),m&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dm,{}),(0,I.jsx)(q,{order:4,children:`Pending Changes`}),(0,I.jsx)(G,{gap:`xs`,children:p.map(e=>(0,I.jsxs)(V,{gap:`xs`,children:[e.type===`addition`?(0,I.jsx)(Mp,{color:`green`,variant:`light`,leftSection:(0,I.jsx)(mj,{size:12}),children:`Add`}):(0,I.jsx)(Mp,{color:`red`,variant:`light`,leftSection:(0,I.jsx)(oj,{size:12}),children:`Remove`}),(0,I.jsx)(mL,{value:e.reference,link:!0})]},`${e.type}-${e.reference.reference}`))})]}),(0,I.jsx)(z,{children:(0,I.jsx)(U,{disabled:!m||d,onClick:()=>c(!0),children:`Save Changes`})})]}),(0,I.jsx)(rg,{opened:s,onClose:()=>c(!1),title:`Confirm Account Changes`,size:`md`,keepMounted:!0,children:(0,I.jsxs)(G,{children:[(0,I.jsxs)(H,{children:[`The following changes will be applied to Patient`,` `,(0,I.jsxs)(`strong`,{children:[t.name?.[0]?.given?.join(` `),` `,t.name?.[0]?.family]}),`:`]}),p.filter(e=>e.type===`addition`).length>0&&(0,I.jsxs)(z,{children:[(0,I.jsx)(H,{fw:600,c:`green`,children:`Adding:`}),(0,I.jsx)(G,{gap:`xs`,mt:`xs`,children:p.filter(e=>e.type===`addition`).map(e=>(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(mj,{size:14,color:`green`}),(0,I.jsx)(mL,{value:e.reference})]},e.reference.reference))})]}),p.filter(e=>e.type===`removal`).length>0&&(0,I.jsxs)(z,{children:[(0,I.jsx)(H,{fw:600,c:`red`,children:`Removing:`}),(0,I.jsx)(G,{gap:`xs`,mt:`xs`,children:p.filter(e=>e.type===`removal`).map(e=>(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(oj,{size:14,color:`red`}),(0,I.jsx)(mL,{value:e.reference})]},e.reference.reference))})]}),(0,I.jsx)(lp,{label:`Propagate changes to all resources in this patient's compartment`,checked:l,onChange:e=>u(e.currentTarget.checked)}),(0,I.jsxs)(V,{justify:`right`,mt:`md`,children:[(0,I.jsx)(U,{variant:`default`,onClick:()=>c(!1),children:`Cancel`}),(0,I.jsx)(U,{onClick:_,loading:d,children:`Confirm`})]})]})})]}):(0,I.jsx)(Dd,{color:`blue`,title:`Admin access required`,children:`You need project admin access to manage patient account assignments.`})}function Fz({reference:e}){let t=e.reference?.split(`/`)[0]??`Unknown`;return(0,I.jsx)(Mp,{variant:`light`,color:{Organization:`blue`,HealthcareService:`teal`,CareTeam:`violet`}[t]??`gray`,size:`sm`,children:t})}var Iz=`patient-export`,Lz=`Patient Export`,Rz={everything:{operation:`$everything`,extension:`json`,contentType:ZE.FHIR_JSON},summary:{operation:`$summary`,extension:`json`,contentType:ZE.FHIR_JSON},ccda:{operation:`$ccda-export`,extension:`xml`,contentType:ZE.CDA_XML},ccdaReferral:{operation:`$ccda-export`,type:`referral`,extension:`xml`,contentType:ZE.CDA_XML}};function zz(e){let t=Z(),{patient:n}=e,[r,i]=(0,b.useState)(`everything`),[a,o]=(0,b.useState)(!1);return(0,I.jsx)(TN,{onSubmit:(0,b.useCallback)(async e=>{let i=sC(n),{operation:o,type:s,contentType:c,extension:l}=Rz[r],u=t.fhirUrl(`Patient`,i,o),d={};r===`everything`&&a&&u.searchParams.set(`_inlineAttachments`,`true`),s&&(d.type=s),e.author&&(d.author={reference:e.author}),e.authoredOn&&(d.authoredOn=WF(e.authoredOn)),e.startDate&&(d.start=e.startDate),e.endDate&&(d.end=e.endDate),zb.show({id:Iz,title:Lz,loading:!0,message:`Exporting...`,autoClose:!1,withCloseButton:!1});try{Bz(await t.post(u,d,void 0,{cache:`no-cache`,headers:{Accept:c}}),`Patient-export-${i}-${new Date().toISOString().replaceAll(`:`,`-`)}.${l}`,c),zb.update({id:Iz,title:Lz,color:`green`,message:`Done`,icon:(0,I.jsx)(EA,{size:`1rem`}),loading:!1,autoClose:!0,withCloseButton:!0})}catch(e){zb.update({id:Iz,title:Lz,color:`red`,message:Qx(e),icon:(0,I.jsx)(Fj,{size:`1rem`}),loading:!1,autoClose:!1,withCloseButton:!0})}},[t,n,r,a]),children:(0,I.jsxs)(G,{children:[(0,I.jsx)(MF,{title:`Export Format`,description:`Required`,withAsterisk:!0,children:(0,I.jsx)(uy,{name:`format`,value:r,onChange:i,data:[{label:`FHIR Everything`,value:`everything`},{label:`Patient Summary`,value:`summary`},{label:`C-CDA`,value:`ccda`},{label:`C-CDA Referral`,value:`ccdaReferral`}],fullWidth:!0})}),(0,I.jsx)(MF,{title:`Author`,description:`Optional author for composition. Default value is current user.`,children:(0,I.jsx)(uI,{name:`author`,placeholder:`Author`,targetTypes:[`Organization`,`Practitioner`,`PractitionerRole`]})}),(0,I.jsx)(MF,{title:`Authored On`,description:`Optional date for composition authored on. Default value is current date.`,children:(0,I.jsx)(GF,{name:`authoredOn`,placeholder:`Authored on`})}),(0,I.jsx)(MF,{title:`Start Date`,description:`The start date of care. If no start date is provided, all records prior to the end date are in scope.`,children:(0,I.jsx)(GF,{name:`startDate`,placeholder:`Start date`})}),(0,I.jsx)(MF,{title:`End Date`,description:`The end date of care. If no end date is provided, all records subsequent to the start date are in scope.`,children:(0,I.jsx)(GF,{name:`endDate`,placeholder:`End date`})}),r===`everything`&&(0,I.jsx)(MF,{title:`Inline Attachments`,description:`Embed DocumentReference file attachments as base64-encoded data instead of storage URLs.`,children:(0,I.jsx)(G,{gap:`xs`,children:(0,I.jsx)(lp,{label:`Inline attachments`,checked:a,onChange:e=>o(e.currentTarget.checked)})})}),(0,I.jsx)(V,{justify:`right`,children:(0,I.jsx)(EN,{children:`Request Export`})})]})})}function Bz(e,t,n){let r=typeof e==`string`?e:JSON.stringify(e,null,2),i=new Blob([r],{type:n}),a=window.URL.createObjectURL(i),o=document.createElement(`a`);document.body.appendChild(o),o.style.display=`none`,o.href=a,o.download=t,o.click(),window.URL.revokeObjectURL(a)}function Vz(e){if(e.gender===`male`)return`blue`;if(e.gender===`female`)return`pink`}function Hz(e){let t=ik(e.patient);return t?(0,I.jsxs)(yz,{children:[(0,I.jsx)(Qj,{value:t,size:`lg`,color:Vz(t)}),(0,I.jsxs)(yz.Entry,{children:[(0,I.jsx)(yz.Key,{children:`Name`}),(0,I.jsx)(yz.Value,{children:(0,I.jsx)(Kj,{to:t,fw:500,children:t.name?(0,I.jsx)(uF,{value:t.name[0],options:{use:!1}}):`[blank]`})})]}),t.birthDate&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(yz.Entry,{children:[(0,I.jsx)(yz.Key,{children:`DoB`}),(0,I.jsx)(yz.Value,{children:t.birthDate})]}),(0,I.jsxs)(yz.Entry,{children:[(0,I.jsx)(yz.Key,{children:`Age`}),(0,I.jsx)(yz.Value,{children:gC(t.birthDate)})]})]}),t.gender&&(0,I.jsxs)(yz.Entry,{children:[(0,I.jsx)(yz.Key,{children:`Gender`}),(0,I.jsx)(yz.Value,{children:t.gender})]}),t.address&&(0,I.jsxs)(yz.Entry,{children:[(0,I.jsx)(yz.Key,{children:`State`}),(0,I.jsx)(yz.Value,{children:t.address[0]?.state})]}),t.identifier?.map(e=>(0,I.jsxs)(yz.Entry,{children:[(0,I.jsx)(yz.Key,{children:e?.system}),(0,I.jsx)(yz.Value,{children:e?.value})]},`${e?.system}-${e?.value}`))]}):null}function Uz(e){let{patient:t,...n}=e;return(0,I.jsx)(YL,{value:t,loadTimelineResources:(0,b.useCallback)((e,t,n)=>{let r=`${t}/${n}`;return Promise.allSettled([e.readHistory(`Patient`,n),e.search(`ClinicalImpression`,{subject:r,_count:100}),e.search(`Communication`,{subject:r,_count:100}),e.search(`Device`,{patient:r,_count:100}),e.search(`DeviceRequest`,{patient:r,_count:100}),e.search(`DiagnosticReport`,{subject:r,_count:100}),e.search(`Media`,{subject:r,_count:100}),e.search(`ServiceRequest`,{subject:r,_count:100}),e.search(`Task`,{subject:r,_count:100})])},[]),createCommunication:(e,t,n)=>({resourceType:`Communication`,status:`completed`,subject:aC(e),sender:aC(t),sent:new Date().toISOString(),payload:[{contentString:n}]}),createMedia:(e,t,n)=>({resourceType:`Media`,status:`completed`,subject:aC(e),operator:aC(t),issued:new Date().toISOString(),content:n}),...n})}var Wz={section:`_section_pqpwm_1`,hovering:`_hovering_pqpwm_7`,editing:`_editing_pqpwm_11`};function Gz(e){let t=Z(),n=ik(e.value),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(),[l,u]=(0,b.useState)();function d(){c(void 0)}function f(){o(void 0)}if((0,b.useEffect)(()=>{t.requestSchema(`PlanDefinition`).then(()=>i(!0)).catch(console.log)},[t]),(0,b.useEffect)(()=>(u($z(n??{resourceType:`PlanDefinition`,status:`active`})),document.addEventListener(`mouseover`,d),document.addEventListener(`click`,f),()=>{document.removeEventListener(`mouseover`,d),document.removeEventListener(`click`,f)}),[n]),!r||!l)return null;function p(e,t){u(n=>({...n,[e]:t}))}return(0,I.jsx)(`div`,{children:(0,I.jsxs)(TN,{testid:`questionnaire-form`,onSubmit:()=>e.onSubmit(l),children:[(0,I.jsx)(yb,{label:`Plan Title`,py:`md`,defaultValue:l.title,onChange:e=>p(`title`,e.currentTarget.value)}),(0,I.jsx)(Kz,{actions:l.action||[],selectedKey:a,setSelectedKey:o,hoverKey:s,setHoverKey:c,onChange:e=>p(`action`,e)}),(0,I.jsx)(EN,{children:`Save`})]})})}function Kz(e){function t(t){e.onChange(e.actions.map(e=>e.id===t.id?t:e))}function n(t){e.onChange([...e.actions,t]),e.setSelectedKey(t.id)}function r(t){e.onChange(e.actions.filter(e=>e!==t))}return(0,I.jsxs)(G,{gap:`md`,className:Wz.section,children:[e.actions.map(n=>(0,I.jsx)(qz,{action:n,selectedKey:e.selectedKey,setSelectedKey:e.setSelectedKey,hoverKey:e.hoverKey,setHoverKey:e.setHoverKey,onChange:t,onRemove:()=>r(n)},n.id)),(0,I.jsx)(`div`,{children:(0,I.jsx)(U,{variant:`outline`,onClick:e=>{Bj(e),n({id:Qz()})},children:`Add action`})})]})}function qz(e){let{action:t}=e;function n(t){t.stopPropagation(),e.setSelectedKey(e.action.id)}function r(t){Bj(t),e.setHoverKey(e.action.id)}return(0,I.jsx)(`div`,{onClick:n,onMouseOver:r,onFocus:r,children:(0,I.jsx)(Jz,{action:t,onChange:e.onChange,selectedKey:e.selectedKey,hoverKey:e.hoverKey,onRemove:e.onRemove})})}function Jz(e){let{action:t}=e,[n,r]=(0,b.useState)(),i=Z(),[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(),l=e.selectedKey===e.action.id,u=e.hoverKey===e.action.id;function d(n,r){e.onChange({...t,[n]:r})}let f=Mn(Wz.section,{[Wz.hovering]:u&&!l});return(0,b.useEffect)(()=>{(async()=>{if(!t.definitionCanonical)return;o(!0);let e=await i.readCanonical([`Questionnaire`,`ActivityDefinition`],t.definitionCanonical);r(Xz(e)),c(e),o(!1)})().catch(console.error)},[t.definitionCanonical,i]),a?(0,I.jsx)(cu,{}):(0,I.jsxs)(yl,{"data-testid":t.id,className:f,p:0,radius:`sm`,withBorder:!0,children:[(0,I.jsxs)(_d,{w:`100%`,p:`xs`,bg:`gray.0`,gap:`md`,align:`center`,justify:`space-between`,children:[(0,I.jsx)(yb,{w:`100%`,name:`actionTitle-${t.id}`,defaultValue:t.title,placeholder:`Title`,onChange:e=>d(`title`,e.currentTarget.value)}),(0,I.jsx)(xu,{"data-testid":`close-button`,onClick:e.onRemove})]}),l&&(0,I.jsxs)(G,{gap:`xl`,p:`md`,children:[(0,I.jsx)(z,{children:(0,I.jsx)(yb,{label:`Task Description`,placeholder:`Enter task description`,name:`actionDescription-${t.id}`,defaultValue:t.description,onChange:e=>d(`description`,e.currentTarget.value)})}),(0,I.jsx)(z,{children:(0,I.jsx)(Eg,{label:`Type of Action`,value:n,onChange:t=>{let n=t.currentTarget.value===`standard`?void 0:t.currentTarget.value;r(n),e.onChange({...e.action,definitionCanonical:n===`standard`?void 0:e.action.definitionCanonical})},data:[{value:`standard`,label:`Standard task`},{value:`questionnaire`,label:`Task with Questionnaire`},{value:`activitydefinition`,label:`Task with Activity Definition`}]})}),n===`questionnaire`&&(0,I.jsxs)(G,{gap:0,children:[(0,I.jsxs)(V,{gap:0,mb:`xs`,children:[(0,I.jsx)(H,{fw:600,children:`Select questionnaire`}),(0,I.jsx)(H,{c:`red`,children:`*`})]}),(0,I.jsxs)(H,{size:`sm`,c:`dimmed`,mb:`sm`,children:[`Questionnaire to be shown in the task in Encounter view. You can create new one from`,` `,(0,I.jsx)(Pd,{href:`/Questionnaire`,target:`_blank`,c:`blue`,children:`questionnaires list`})]}),(0,I.jsx)(Yz,{resource:s,resourceType:`Questionnaire`,action:t,onChange:e.onChange,placeholder:`Search for questionnaire`})]}),n===`activitydefinition`&&(0,I.jsxs)(G,{gap:0,children:[(0,I.jsxs)(V,{gap:0,mb:`xs`,children:[(0,I.jsx)(H,{fw:600,children:`Select activity definition`}),(0,I.jsx)(H,{c:`red`,children:`*`})]}),(0,I.jsxs)(H,{size:`sm`,c:`dimmed`,mb:`sm`,children:[`ActivityDefinition.kind resource to be shown in the task in Encounter view. You can create new one from`,` `,(0,I.jsx)(Pd,{href:`/ActivityDefinition`,target:`_blank`,c:`blue`,children:`activity definitions list`})]}),(0,I.jsx)(Yz,{resource:s,resourceType:`ActivityDefinition`,action:t,onChange:e.onChange,placeholder:`Search for activity definition`})]})]})]})}function Yz(e){let{id:t}=e.action,{resource:n}=e;return(0,I.jsx)(lI,{name:t,placeholder:e.placeholder,resourceType:e.resourceType,defaultValue:n,onChange:t=>{t?e.onChange({...e.action,definitionCanonical:`url`in t?t.url:void 0,definitionUri:`url`in t?void 0:oC(t)}):e.onChange({...e.action,definitionCanonical:void 0})}})}function Xz(e){return e===void 0?`standard`:e.resourceType.toLowerCase()}var Zz=1;function Qz(e){if(e){if(e.startsWith(`id-`)){let t=Number.parseInt(e.substring(3),10);Number.isNaN(t)||(Zz=Math.max(Zz,t+1))}return e}return`id-`+ Zz++}function $z(e){return{...e,action:eB(e.action)}}function eB(e){if(e)return e.map(e=>({...e,id:Qz(e.id),action:eB(e.action)}))}var tB={section:`_section_my8o4_1`,hovering:`_hovering_my8o4_10`,editing:`_editing_my8o4_14`,questionBody:`_questionBody_my8o4_20`,topActions:`_topActions_my8o4_24`,bottomActions:`_bottomActions_my8o4_33`,movementActions:`_movementActions_my8o4_44`,movementIcons:`_movementIcons_my8o4_56`,columnAlignment:`_columnAlignment_my8o4_60`,linkIdInput:`_linkIdInput_my8o4_65`,typeSelect:`_typeSelect_my8o4_70`,preserveBreaks:`_preserveBreaks_my8o4_74`};function nB(e){let t=Z(),n=ik(e.questionnaire),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(),[l,u]=(0,b.useState)();function d(){u(void 0)}function f(){c(void 0)}return(0,b.useEffect)(()=>{t.requestSchema(`Questionnaire`).then(()=>i(!0)).catch(console.log)},[t]),(0,b.useEffect)(()=>(o(dB(n??{resourceType:`Questionnaire`,status:`active`})),document.addEventListener(`mouseover`,d),document.addEventListener(`click`,f),()=>{document.removeEventListener(`mouseover`,d),document.removeEventListener(`click`,f)}),[n]),!r||!a?null:(0,I.jsx)(`div`,{children:(0,I.jsxs)(TN,{testid:`questionnaire-form`,onSubmit:()=>e.onSubmit(a),children:[(0,I.jsx)(rB,{item:a,selectedKey:s,setSelectedKey:c,hoverKey:l,setHoverKey:u,onChange:(t,n)=>{o(t),e.autoSave&&!n&&e.onSubmit&&e.onSubmit(t)}}),(0,I.jsx)(EN,{children:`Save`})]})})}function rB(e){let t=e.item,n=e.item,r=Hw(e.item),i=r||n.type===ok.group,a=n.linkId??`[untitled]`,o=e.selectedKey===e.item.id,s=e.hoverKey===e.item.id,c=(0,b.useRef)(e.item);(0,b.useLayoutEffect)(()=>{c.current=e.item});function l(t){Bj(t),e.setSelectedKey(e.item.id)}function u(t){Bj(t),e.setHoverKey(e.item.id)}function d(t){let n=c.current;e.onChange({...n,item:n.item?.map(e=>e.id===t.id?t:e)})}function f(t,n){e.onChange({...e.item,item:[...e.item.item??[],t]},n)}function p(t){e.onChange({...e.item,item:e.item.item?.filter(e=>e!==t)})}function m(t,n){e.onChange({...c.current,[t]:n})}function h(t){e.onChange({...e.item,...t})}function g(t){e.onChange({...e.item,item:e.item.item?.map(e=>e===t?{...e,repeats:!e.repeats}:e)})}function _(t,n){let r=hB(e.item.item,t,n);e.onChange({...e.item,item:r})}let v=Mn(tB.section,{[tB.editing]:o,[tB.hovering]:s&&!o});return(0,I.jsxs)(`div`,{"data-testid":n.linkId,className:v,onClick:l,onMouseOver:u,onFocus:u,children:[(0,I.jsx)(`div`,{className:tB.questionBody,children:o?(0,I.jsxs)(I.Fragment,{children:[r&&(0,I.jsx)(yb,{size:`xl`,defaultValue:t.title,onBlur:e=>m(`title`,e.currentTarget.value)}),!r&&(0,I.jsx)(oh,{autosize:!0,minRows:2,defaultValue:n.text,onBlur:e=>m(`text`,e.currentTarget.value)}),n.type===`reference`&&(0,I.jsx)(oB,{item:n,onChange:h}),gk(n)&&(0,I.jsx)(iB,{item:n,onChange:e=>h(e)})]}):(0,I.jsxs)(I.Fragment,{children:[t.title&&(0,I.jsx)(q,{children:t.title}),n.text&&(0,I.jsx)(`div`,{className:tB.preserveBreaks,children:n.text}),!i&&(0,I.jsx)(WI,{item:n,index:0,required:!1,responseItem:{linkId:n.linkId}})]})}),n.item?.map((t,n)=>(0,I.jsx)(`div`,{children:(0,I.jsx)(rB,{item:t,selectedKey:e.selectedKey,setSelectedKey:e.setSelectedKey,hoverKey:e.hoverKey,isFirst:n===0,isLast:n===(e.item.item??[]).length-1,setHoverKey:e.setHoverKey,onChange:d,onRemove:()=>p(t),onRepeatable:g,onMoveUp:()=>_(n,-1),onMoveDown:()=>_(n,1)})},t.id)),!i&&(0,I.jsx)(`div`,{className:tB.topActions,children:o?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(yb,{size:`xs`,className:tB.linkIdInput,defaultValue:n.linkId,onBlur:e=>m(`linkId`,e.currentTarget.value)}),!i&&(0,I.jsx)(Eg,{size:`xs`,className:tB.typeSelect,defaultValue:n.type,onChange:e=>m(`type`,e.currentTarget.value),data:[{value:`display`,label:`Display`},{value:`boolean`,label:`Boolean`},{value:`decimal`,label:`Decimal`},{value:`integer`,label:`Integer`},{value:`date`,label:`Date`},{value:`dateTime`,label:`Date/Time`},{value:`time`,label:`Time`},{value:`string`,label:`String`},{value:`text`,label:`Text`},{value:`url`,label:`URL`},{value:`choice`,label:`Choice`},{value:`open-choice`,label:`Open Choice`},{value:`attachment`,label:`Attachment`},{value:`reference`,label:`Reference`},{value:`quantity`,label:`Quantity`}]})]}):(0,I.jsx)(`div`,{children:a})}),!r&&(0,I.jsx)(z,{className:tB.movementActions,children:(0,I.jsxs)(z,{className:tB.columnAlignment,children:[!e.isFirst&&(0,I.jsx)(Pd,{href:`#`,onClick:t=>{t.preventDefault(),e.onMoveUp&&e.onMoveUp()},children:(0,I.jsx)(mA,{"data-testid":`up-button`,size:15,className:tB.movementIcons})}),!e.isLast&&(0,I.jsx)(Pd,{href:`#`,onClick:t=>{t.preventDefault(),e.onMoveDown&&e.onMoveDown()},children:(0,I.jsx)(pA,{"data-testid":`down-button`,size:15,className:tB.movementIcons})})]})}),(0,I.jsxs)(`div`,{className:tB.bottomActions,children:[i&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Pd,{href:`#`,onClick:e=>{e.preventDefault(),f({id:uB(),linkId:lB(`q`),type:`string`,text:`Question`})},children:`Add item`}),(0,I.jsx)(Pd,{href:`#`,onClick:e=>{e.preventDefault(),f({id:uB(),linkId:lB(`g`),type:`group`,text:`Group`},!0)},children:`Add group`})]}),r&&(0,I.jsx)(Pd,{href:`#`,onClick:e=>{e.preventDefault(),f(mB(),!0)},children:`Add Page`}),o&&!r&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Pd,{href:`#`,onClick:t=>{t.preventDefault(),e.onRepeatable&&e.onRepeatable(n)},children:n.repeats?`Remove Repeatable`:`Make Repeatable`}),(0,I.jsx)(Pd,{href:`#`,onClick:t=>{t.preventDefault(),e.onRemove&&e.onRemove()},children:`Remove`})]})]})]})}function iB(e){let t=Bw(`QuestionnaireItemAnswerOption`,`value[x]`),n=e.item.answerOption??[];return(0,I.jsxs)(`div`,{children:[e.item.answerValueSet===void 0?(0,I.jsx)(aB,{options:n,property:t,item:e.item,onChange:e.onChange}):(0,I.jsx)(yb,{placeholder:`Enter Value Set`,defaultValue:e.item.answerValueSet,onChange:t=>e.onChange({...e.item,answerValueSet:t.target.value})}),(0,I.jsxs)(z,{display:`flex`,children:[(0,I.jsx)(Pd,{href:`#`,onClick:t=>{Bj(t),e.onChange({...e.item,answerValueSet:void 0,answerOption:[...n,{id:uB()}]})},children:`Add choice`}),(0,I.jsx)(Cy,{w:`lg`}),(0,I.jsx)(Pd,{href:`#`,onClick:t=>{Bj(t),e.onChange({...e.item,answerOption:[],answerValueSet:``})},children:`Add value set`})]})]})}function aB(e){return(0,I.jsx)(`div`,{children:e.options.map(t=>{let[n,r]=sF({type:`QuestionnaireItemAnswerOption`,value:t},`value`);return(0,I.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:`space-between`,alignItems:`center`,width:`80%`},children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(DI,{name:`value[x]`,path:`Questionnaire.answerOption.value[x]`,property:e.property,defaultPropertyType:r,defaultValue:n,onChange:(n,r)=>{let i=[...e.options],a=i.findIndex(e=>e.id===t.id);i[a]={id:t.id,[r]:n},e.onChange({...e.item,answerOption:i})},outcome:void 0},t.id)}),(0,I.jsx)(`div`,{children:(0,I.jsx)(Pd,{href:`#`,onClick:n=>{Bj(n),e.onChange({...e.item,answerOption:e.options.filter(e=>e.id!==t.id)})},children:`Remove`})})]},t.id)})})}function oB(e){let t=jk(e.item)??[];return(0,I.jsxs)(I.Fragment,{children:[t.map((n,r)=>(0,I.jsxs)(V,{children:[(0,I.jsx)(RN,{name:`resourceType`,placeholder:`Resource Type`,defaultValue:n,onChange:r=>{e.onChange(Mk(e.item,t.map(e=>e===n?r:e)))}}),(0,I.jsx)(Pd,{href:`#`,onClick:r=>{Bj(r),e.onChange(Mk(e.item,t.filter(e=>e!==n)))},children:`Remove`})]},`${n}-${r}`)),(0,I.jsx)(Pd,{href:`#`,onClick:n=>{Bj(n),e.onChange(Mk(e.item,[...t,``]))},children:`Add Resource Type`})]})}var sB=1,cB=1;function lB(e){return e+ sB++}function uB(){return`id-`+ cB++}function dB(e){return{...e,id:e.id||uB(),item:fB(e.item)}}function fB(e){if(e)return e.forEach(e=>{e.id?.match(/^id-\d+$/)&&(cB=Math.max(cB,Number.parseInt(e.id.substring(3),10)+1)),e.linkId?.match(/^q\d+$/)&&(sB=Math.max(sB,Number.parseInt(e.linkId.substring(1),10)+1))}),e.map(e=>({...e,id:e.id||uB(),item:fB(e.item),answerOption:pB(e.answerOption)}))}function pB(e){if(e)return e.map(e=>({...e,id:e.id||uB()}))}function mB(){return{id:uB(),linkId:lB(`s`),type:`group`,text:`New Page`,extension:[{url:sk,valueCodeableConcept:{coding:[{system:`http://hl7.org/fhir/questionnaire-item-control`,code:`page`}]}}]}}function hB(e,t,n){let r=e??[],i=t+n;if(i<0||i>=r.length)return r;let a=[...r];return[a[t],a[i]]=[a[i],a[t]],a}var gB={section:`_section_4m5it_1`},_B=[`gender`,`age`,`gestationalAge`,`context`,`appliesTo`,`category`],vB={definition:{resourceType:`ObservationDefinition`,code:{text:``}},onSubmit:()=>{}};function yB(e){e=Object.assign(vB,e);let t=e.definition,[n,r]=(0,b.useState)([]),[i,a]=(0,b.useState)(1),[o,s]=(0,b.useState)(1);return(0,b.useEffect)(()=>{r(CB(SB(t,s).qualifiedInterval||[],a))},[t]),(0,I.jsxs)(TN,{testid:`reference-range-editor`,onSubmit:c,children:[(0,I.jsx)(G,{children:n.map(e=>(0,I.jsx)(bB,{unit:TB(t.quantitativeDetails?.unit),onChange:d,onAdd:f,onRemove:p,onRemoveGroup:u,intervalGroup:e},`group-${e.id}`))}),(0,I.jsx)(gu,{title:`Add Group`,variant:`subtle`,size:`sm`,onClick:e=>{Bj(e),l({id:`group-id-${i}`,filters:{},intervals:[]}),a(e=>e+1)},children:(0,I.jsx)(jA,{})}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(EN,{children:`Save`})})]});function c(){let r=n.flatMap(e=>e.intervals).filter(e=>!EB(e));e.onSubmit({...t,qualifiedInterval:r})}function l(e){r(t=>[...t,e])}function u(e){r(t=>t.filter(t=>t.id!==e.id))}function d(e,t){r(n=>{n=[...n];let r=n.find(t=>t.id===e),i=r?.intervals.findIndex(e=>e.id===t.id);return i!==void 0&&r?.intervals[i]&&(r.intervals[i]=t),n})}function f(e,t){t.id===void 0&&(t.id=`id-${o}`,s(e=>e+1)),r(n=>{n=[...n];let r=n.findIndex(t=>t.id===e);if(r!==-1){let e={...n[r]};t={...t,...e.filters},e.intervals=[...e.intervals,t],n[r]=e}return n})}function p(e,t){r(n=>{n=[...n];let r=n.find(t=>t.id===e);return r&&(r.intervals=r.intervals.filter(e=>e.id!==t.id)),n})}}function bB(e){let{intervalGroup:t,unit:n}=e;return(0,I.jsx)(_P,{"data-testid":t.id,className:gB.section,children:(0,I.jsxs)(G,{gap:`lg`,children:[(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(gu,{title:`Remove Group`,variant:`subtle`,"data-testid":`remove-group-button-${t.id}`,size:`sm`,onClick:n=>{Bj(n),e.onRemoveGroup(t)},children:(0,I.jsx)(AA,{})},`remove-group-button-${t.id}`)}),(0,I.jsx)(xB,{intervalGroup:t,onChange:e.onChange}),(0,I.jsx)(dm,{}),t.intervals.map(n=>(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsxs)(V,{children:[(0,I.jsx)(yb,{"data-testid":`condition-${n.id}`,defaultValue:n.condition,label:`Condition: `,size:`sm`,onChange:r=>{Bj(r),e.onChange(t.id,{...n,condition:r.currentTarget.value.trim()})}},`condition-${n.id}`),(0,I.jsx)(gu,{title:`Remove Interval`,variant:`subtle`,size:`sm`,"data-testid":`remove-interval-${n.id}`,onClick:r=>{Bj(r),e.onRemove(t.id,n)},children:(0,I.jsx)(AA,{})},`remove-interval-${n.id}`)]}),(0,I.jsx)(tI,{path:``,onChange:r=>{e.onChange(t.id,{...n,range:r})},name:`range-${n.id}`,defaultValue:n.range},`range-${n.id}`)]},`interval-${n.id}`)),(0,I.jsx)(gu,{title:`Add Interval`,variant:`subtle`,size:`sm`,onClick:r=>{Bj(r),e.onAdd(t.id,{range:{low:{unit:n},high:{unit:n}}})},children:(0,I.jsx)(jA,{})})]})})}function xB(e){let{intervalGroup:t,onChange:n}=e,r=t.filters.age??{},i={low:r.low?.unit?r.low:{...r.low,unit:`years`,system:`http://unitsofmeasure.org`},high:r.high?.unit?r.high:{...r.high,unit:`years`,system:`http://unitsofmeasure.org`}};return(0,I.jsxs)(G,{style:{maxWidth:`50%`},children:[(0,I.jsx)(V,{children:(0,I.jsx)(Eg,{data:[``,`male`,`female`],label:`Gender:`,defaultValue:t.filters.gender||``,onChange:e=>{for(let r of t.intervals){let i=e.currentTarget.value;i===``&&(i=void 0),n(t.id,{...r,gender:i})}}})}),(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(H,{component:`label`,htmlFor:`div-age-${t.id}`,children:`Age:`}),(0,I.jsx)(`div`,{id:`div-age-${t.id}`,children:(0,I.jsx)(tI,{path:``,name:`age-${t.id}`,defaultValue:i,onChange:e=>{for(let r of t.intervals)n(t.id,{...r,age:e})}},`age-${t.id}`)})]}),(0,I.jsx)(Eg,{data:[``,`pre-puberty`,`follicular`,`midcycle`,`luteal`,`postmenopausal`],label:`Endocrine:`,defaultValue:t.filters.context?.text||``,onChange:e=>{for(let r of t.intervals){let i=e.currentTarget.value;i===``?(i=void 0,n(t.id,{...r,context:void 0})):n(t.id,{...r,context:{text:i,coding:[{code:i,system:`http://terminology.hl7.org/CodeSystem/referencerange-meaning`}]}})}}}),(0,I.jsx)(Eg,{data:[``,`reference`,`critical`,`absolute`],label:`Category: `,defaultValue:t.filters.category,onChange:e=>{for(let r of t.intervals){let i=e.currentTarget.value;i===``?n(t.id,{...r,category:void 0}):n(t.id,{...r,category:i})}}})]})}function SB(e,t){let n=e.qualifiedInterval||[],r=Math.max(...n.map(e=>{let t=Number.parseInt(e.id?.substring(3)||``,10);return Number.isNaN(t)?-1/0:t}))+1;return Number.isFinite(r)||(r=1),e={...e,qualifiedInterval:n.map(e=>({...e,id:e.id||`id-${r++}`}))},t(r),e}function CB(e,t){let n=1,r={};for(let t of e){let e=wB(t);e in r||(r[e]={id:`group-id-${n++}`,filters:Object.fromEntries(_B.map(e=>[e,t[e]])),intervals:[]}),r[e].intervals.push(t)}return t(n),Object.values(r)}function wB(e){return[`gender=${e.gender}`,`age=${yw(e.age)}`,`gestationalAge=${yw(e.gestationalAge)}`,`context=${e.context?.text}`,`appliesTo=${e.appliesTo?.map(e=>e.text).join(`+`)}`,`category=${e.category}`].join(`:`)}function TB(e){return e&&(KC(e,`http://unitsofmeasure.org`)||e.text)}function EB(e){return e.range?.low?.value===void 0&&e.range?.high?.value===void 0}function DB(e){let t=Z(),n=ik(e.value),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)();if((0,b.useEffect)(()=>{n&&!r&&(t.executeBatch(s(n)).then(o).catch(console.log),i(!0))},[t,n,r]),!n||!a)return null;return(0,I.jsx)(Tm,{children:n.action?.map((t,n)=>{let r=t.resource&&c(t.resource),i=r?.input?.[0]?.valueReference,a=r?.output?.[0]?.valueReference;return(0,I.jsxs)(b.Fragment,{children:[(0,I.jsx)(Tm.Col,{span:1,p:`md`,children:r?.status===`completed`?(0,I.jsx)(DA,{}):(0,I.jsx)(wj,{color:`gray`})}),(0,I.jsxs)(Tm.Col,{span:9,p:`xs`,children:[(0,I.jsx)(H,{fw:500,children:t.title}),t.description&&(0,I.jsx)(`div`,{children:t.description}),(0,I.jsxs)(`div`,{children:[`Last edited by\xA0`,(0,I.jsx)(pL,{value:r?.meta?.author}),`\xA0on\xA0`,fw(r?.meta?.lastUpdated)]}),(0,I.jsxs)(`div`,{children:[`Status: `,(0,I.jsx)(uL,{status:r?.status||`unknown`})]})]}),(0,I.jsxs)(Tm.Col,{span:2,p:`md`,children:[i&&!a&&(0,I.jsx)(U,{onClick:()=>e.onStart(r,i),children:`Start`}),i&&a&&(0,I.jsx)(U,{onClick:()=>e.onEdit(r,i,a),children:`Edit`})]})]},`action-${n}`)})});function s(e){let t=[];if(e.action)for(let n of e.action)n.resource?.reference&&t.push({request:{method:`GET`,url:n.resource.reference}});return{resourceType:`Bundle`,type:`batch`,entry:t}}function c(e){for(let t of a?.entry??[])if(t.resource&&e.reference===oC(t.resource))return t.resource}}function OB(e,t){return AB(kB(e,t),e,t)}function kB(e,t){let n=e.length,r=t.length,i=n+r+1,a=1+2*i,o=Math.trunc(a/2),s=Array(a);s[o+1]={i:0,j:-1,prev:void 0,snake:!0};for(let a=0;a<i;a++){for(let i=-a;i<=a;i+=2){let c=o+i,l=c+1,u=c-1,d=s[l],f=s[u],p,m=0;i===-a||i!==a&&f.i<d.i?(m=d.i,p=d):(m=f.i+1,p=f),s[u]=void 0;let h=m-i,g={i:m,j:h,prev:jB(p),snake:!1};for(;m<n&&h<r&&e[m]===t[h];)m++,h++;if(m>g.i&&(g={i:m,j:h,prev:g,snake:!0}),s[c]=g,m>=n&&h>=r)return s[c]}s[o+a-1]=void 0}}function AB(e,t,n){let r=[],i=e;for(i.snake&&(i=i.prev);i?.prev&&i.prev.j>=0;){let e=i.i,a=i.j;i=i.prev;let o=i.i,s=i.j,c={position:o,lines:t.slice(o,e)},l={position:s,lines:n.slice(s,a)},u;u=c.lines.length===0&&l.lines.length>0?`insert`:c.lines.length>0&&l.lines.length===0?`delete`:`change`,r.push({original:c,revised:l,type:u}),i.snake&&(i=i.prev)}return r}function jB(e){return e&&!e.snake&&e.prev?e.prev:e}function MB(e){let t=(e.entry??[]).filter(e=>!!e.resource).map(e=>({meta:e.resource?.meta,lines:yC(e.resource,!0).match(/[^\r\n]+/g)})).sort((e,t)=>e.meta.lastUpdated.localeCompare(t.meta.lastUpdated));if(!t.length)return[];let n=t[0].lines.map(e=>({id:t[0].meta.versionId,meta:t[0].meta,value:e,span:1}));return NB(n,t),PB(n),n}function NB(e,t){for(let n=1;n<t.length;n++){let r=OB(t[n-1].lines,t[n].lines);for(let i of r){let r=i.original.position,a=i.original.lines,o=i.revised.lines;if((i.type===`delete`||i.type===`change`)&&e.splice(r,a.length),i.type===`insert`||i.type===`change`)for(let a=0;a<i.revised.lines.length;a++)e.splice(r+a,0,{id:t[n].meta.versionId,meta:t[n].meta,value:o[a],span:1})}}}function PB(e){let t=0;for(;t<e.length;){let n=t;for(;n<e.length&&e[n].id===e[t].id;)e[n].span=-1,n++;e[t].span=n-t,t=n}}var FB={container:`_container_1gji2_1`,root:`_root_1gji2_5`,startRow:`_startRow_1gji2_20`,normalRow:`_normalRow_1gji2_25`,author:`_author_1gji2_30`,onBehalfOf:`_onBehalfOf_1gji2_34`,dateTime:`_dateTime_1gji2_40`,lineNumber:`_lineNumber_1gji2_46`,line:`_line_1gji2_46`,pre:`_pre_1gji2_61`};function IB(e,t){return`/${e.resourceType}/${e.id}/_history/${t}`}function LB(e){let t=Math.floor((Date.now()-Date.parse(e))/1e3),n=Math.floor(t/31536e3);if(n>0)return RB(n,`year`);let r=Math.floor(t/2592e3);if(r>0)return RB(r,`month`);let i=Math.floor(t/86400);if(i>0)return RB(i,`day`);let a=Math.floor(t/3600);if(a>0)return RB(a,`hour`);let o=Math.floor(t/60);return o>0?RB(o,`minute`):RB(t,`second`)}function RB(e,t){return`${e} ${e===1?t:t+`s`} ago`}function zB(e){let t=Z(),[n,r]=(0,b.useState)(e.history);if((0,b.useEffect)(()=>{!e.history&&e.resourceType&&e.id&&t.readHistory(e.resourceType,e.id).then(r).catch(console.log)},[t,e.history,e.resourceType,e.id]),!n)return(0,I.jsx)(`div`,{children:`Loading...`});let i=n.entry?.[0]?.resource;if(!i)return null;let a=MB(n);return(0,I.jsx)(`div`,{className:FB.container,children:(0,I.jsx)(`table`,{className:FB.root,children:(0,I.jsx)(`tbody`,{children:a.map((e,t)=>(0,I.jsxs)(`tr`,{className:e.span>0?FB.startRow:FB.normalRow,children:[e.span>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`td`,{className:FB.author,rowSpan:e.span,children:[(0,I.jsx)(pL,{value:e.meta.author,link:!0,fz:`xs`}),e.meta.onBehalfOf&&(0,I.jsxs)(`div`,{className:FB.onBehalfOf,children:[`on behalf of `,(0,I.jsx)(pL,{value:e.meta.onBehalfOf,link:!0,fz:`xs`,c:`dimmed`})]})]}),(0,I.jsx)(`td`,{className:FB.dateTime,rowSpan:e.span,children:(0,I.jsx)(Kj,{to:IB(i,e.meta.versionId),fz:`xs`,children:LB(e.meta.lastUpdated)})})]}),(0,I.jsx)(`td`,{className:FB.lineNumber,children:t+1}),(0,I.jsx)(`td`,{className:FB.line,children:(0,I.jsx)(`pre`,{className:FB.pre,children:e.value})})]},`row-`+t))})})})}var BB={removed:`_removed_el5zk_1`,added:`_added_el5zk_6`};function VB(e){let t=e.original,n=e.revised;return e.ignoreMeta&&(t={...t,meta:void 0},n={...n,meta:void 0}),(0,I.jsx)(`pre`,{style:{color:`gray`},children:OB(yC(t,!0).match(/[^\r\n]+/g)??[`{`,`}`],yC(n,!0).match(/[^\r\n]+/g)??[`{`,`}`]).map((e,t)=>(0,I.jsx)(HB,{delta:e},`delta`+t))})}function HB(e){return(0,I.jsxs)(I.Fragment,{children:[`...`,(0,I.jsx)(`br`,{}),e.delta.original.lines.length>0&&(0,I.jsx)(`div`,{className:BB.removed,children:e.delta.original.lines.join(`
207
+ `)}),e.delta.revised.lines.length>0&&(0,I.jsx)(`div`,{className:BB.added,children:e.delta.revised.lines.join(`
208
+ `)}),`...`,(0,I.jsx)(`br`,{})]})}var UB={splitButton:`_splitButton_1i0gi_1`,menuControl:`_menuControl_1i0gi_6`};function WB(e){let{outcome:t}=e,n=Z(),r=ik(e.defaultValue),i=r?.resourceType,[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)(),l=n.getAccessPolicy(),u=Sr();(0,b.useEffect)(()=>{if(r)if(e.profileUrl){let t=e.profileUrl;n.requestProfileSchema(e.profileUrl,{expandProfile:!0}).then(()=>{let e=gS(t);e?(o(!0),c(vO(r,e))):console.error(`Schema not found for ${t}`)}).catch(e=>{console.error(`Error in requestProfileSchema`,e)})}else n.requestSchema(i).then(()=>{c(r),o(!0)}).catch(console.log)},[n,r,i,e.profileUrl]);let d=(0,b.useMemo)(()=>r&&ME(r,OE.READ,l),[l,r]),f=(0,b.useMemo)(()=>n.isSuperAdmin()||!l||!wC(s?.resourceType)?!0:AE(l,s?.resourceType),[n,l,s?.resourceType]);return!a||!s?(0,I.jsx)(`div`,{children:`Loading...`}):f?(0,I.jsxs)(`form`,{noValidate:!0,autoComplete:`off`,onSubmit:t=>{t.preventDefault(),e.onSubmit&&e.onSubmit(s)},children:[(0,I.jsxs)(G,{mb:`xl`,children:[(0,I.jsx)(MF,{title:`Resource Type`,htmlFor:`resourceType`,outcome:t,children:(0,I.jsx)(yb,{name:`resourceType`,defaultValue:s.resourceType,disabled:!0})}),(0,I.jsx)(MF,{title:`ID`,htmlFor:`id`,outcome:t,children:(0,I.jsx)(yb,{name:`id`,defaultValue:s.id,disabled:!0})})]}),(0,I.jsx)(PI,{path:s.resourceType,valuePath:s.resourceType,typeName:i,defaultValue:s,outcome:t,onChange:c,profileUrl:e.profileUrl,accessPolicyResource:d}),(0,I.jsxs)(V,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,gap:0,children:[(0,I.jsx)(U,{type:`submit`,className:Mn((e.onPatch||e.onDelete)&&UB.splitButton),children:r?.id?`Update`:`Create`}),(e.onPatch||e.onDelete)&&(0,I.jsxs)(W,{transitionProps:{transition:`pop`},position:`bottom-end`,withinPortal:!0,children:[(0,I.jsx)(W.Target,{children:(0,I.jsx)(gu,{variant:`filled`,color:u.primaryColor,size:36,className:UB.menuControl,"aria-label":`More actions`,children:(0,I.jsx)(OA,{size:14,stroke:1.5})})}),(0,I.jsxs)(W.Dropdown,{children:[e.onPatch&&(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(BA,{size:14,stroke:1.5}),onClick:()=>{e.onPatch(s)},children:`Patch`}),e.onDelete&&(0,I.jsx)(W.Item,{color:`red`,leftSection:(0,I.jsx)(jj,{size:14,stroke:1.5,color:`red`}),onClick:()=>{e.onDelete(s)},children:`Delete`})]})]})]})]}):(0,I.jsxs)(Dd,{color:`red`,title:`Permission denied`,icon:(0,I.jsx)(fA,{}),children:[`Your access level prevents you from editing and creating `,s.resourceType,` resources.`]})}function GB(e){let t=Z(),[n,r]=(0,b.useState)(e.history);return(0,b.useEffect)(()=>{!e.history&&e.resourceType&&e.id&&t.readHistory(e.resourceType,e.id).then(r).catch(console.log)},[t,e.history,e.resourceType,e.id]),n?(0,I.jsxs)(K,{withTableBorder:!0,withRowBorders:!0,withColumnBorders:!0,children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:`Author`}),(0,I.jsx)(K.Th,{children:`On Behalf Of`}),(0,I.jsx)(K.Th,{children:`Date`}),(0,I.jsx)(K.Th,{children:`Version`})]})}),(0,I.jsx)(K.Tbody,{children:n.entry?.map((e,t)=>(0,I.jsx)(KB,{entry:e},`entry-`+t))})]}):(0,I.jsx)(`div`,{children:`Loading...`})}function KB(e){let{response:t,resource:n}=e.entry;return n?(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:(0,I.jsx)(mL,{value:n.meta?.author,link:!0})}),(0,I.jsx)(K.Td,{children:n.meta?.onBehalfOf&&(0,I.jsx)(mL,{value:n.meta.onBehalfOf,link:!0})}),(0,I.jsx)(K.Td,{children:fw(n.meta?.lastUpdated)}),(0,I.jsx)(K.Td,{children:(0,I.jsx)(Kj,{to:qB(n),children:n.meta?.versionId})})]}):(0,I.jsx)(K.Tr,{children:(0,I.jsx)(K.Td,{colSpan:4,children:Qx(t?.outcome)})})}function qB(e){return`/${e.resourceType}/${e.id}/_history/${e.meta?.versionId}`}var JB=`modulepreload`,YB=function(e){return`/`+e},XB={},ZB=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=YB(t,n),t in XB)return;XB[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:JB,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},QB=e=>{throw TypeError(e)},$B=(e,t,n)=>t.has(e)||QB(`Cannot `+n),eV=(e,t,n)=>($B(e,t,`read from private field`),n?n.call(e):t.get(e)),tV=(e,t,n)=>t.has(e)?QB(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),nV=(e,t,n,r)=>($B(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),rV=`popstate`;function iV(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function aV(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return uV(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:dV(t)}return pV(t,n,null,e)}function oV(e,t){if(e===!1||e==null)throw Error(t)}function sV(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function cV(){return Math.random().toString(36).substring(2,10)}function lV(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function uV(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?fV(t):t,state:n,key:t&&t.key||r||cV(),mask:i}}function dV({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function fV(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function pV(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=iV(e)?e:uV(h.location,e,t);n&&n(r,e),l=u()+1;let d=lV(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=iV(e)?e:uV(h.location,e,t);n&&n(r,e),l=u();let i=lV(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return mV(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(rV,d),c=e,()=>{i.removeEventListener(rV,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function mV(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),oV(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:dV(t);return i=i.replace(/ $/,`%20`),!n&&i.startsWith(`//`)&&(i=r+i),new URL(i,r)}var hV,gV=class{constructor(e){if(tV(this,hV,new Map),e)for(let[t,n]of e)this.set(t,n)}get(e){if(eV(this,hV).has(e))return eV(this,hV).get(e);if(e.defaultValue!==void 0)return e.defaultValue;throw Error(`No value found for context`)}set(e,t){eV(this,hV).set(e,t)}};hV=new WeakMap;var _V=new Set([`lazy`,`caseSensitive`,`path`,`id`,`index`,`children`]);function vV(e){return _V.has(e)}var yV=new Set([`lazy`,`caseSensitive`,`path`,`id`,`index`,`middleware`,`children`]);function bV(e){return yV.has(e)}function xV(e){return e.index===!0}function SV(e,t,n=[],r={},i=!1){return e.map((e,a)=>{let o=[...n,String(a)],s=typeof e.id==`string`?e.id:o.join(`-`);if(oV(e.index!==!0||!e.children,`Cannot specify children on an index route`),oV(i||!r[s],`Found a route id collision on id "${s}". Route id's must be globally unique within Data Router usages`),xV(e)){let n={...e,id:s};return r[s]=CV(n,t(n)),n}else{let n={...e,id:s,children:void 0};return r[s]=CV(n,t(n)),e.children&&(n.children=SV(e.children,t,o,r,i)),n}})}function CV(e,t){return Object.assign(e,{...t,...typeof t.lazy==`object`&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function wV(e,t,n=`/`){return TV(e,t,n,!1)}function TV(e,t,n,r,i){let a=WV((typeof t==`string`?fV(t):t).pathname||`/`,n);if(a==null)return null;let o=i??DV(e),s=null,c=UV(a);for(let e=0;s==null&&e<o.length;++e)s=BV(o[e],c,r);return s}function EV(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function DV(e){let t=OV(e);return AV(t),t}function OV(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;oV(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=tH([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(oV(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),OV(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:RV(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of kV(e.path))a(e,t,!0,n)}),t}function kV(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=kV(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function AV(e){e.sort((e,t)=>e.score===t.score?zV(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var jV=/^:[\w-]+$/,MV=3,NV=2,PV=1,FV=10,IV=-2,LV=e=>e===`*`;function RV(e,t){let n=e.split(`/`),r=n.length;return n.some(LV)&&(r+=IV),t&&(r+=NV),n.filter(e=>!LV(e)).reduce((e,t)=>e+(jV.test(t)?MV:t===``?PV:FV),r)}function zV(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function BV(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=VV({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=VV({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:tH([a,u.pathname]),pathnameBase:rH(tH([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=tH([a,u.pathnameBase]))}return o}function VV(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=HV(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function HV(e,t=!1,n=!0){sV(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function UV(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return sV(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function WV(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}function GV({basename:e,pathname:t}){return t===`/`?e:tH([e,t])}var KV=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,qV=e=>KV.test(e);function JV(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?fV(e):e,a;return n?(n=eH(n),a=n.startsWith(`/`)?YV(n.substring(1),`/`):YV(n,t)):a=t,{pathname:a,search:iH(r),hash:aH(i)}}function YV(e,t){let n=nH(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function XV(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ZV(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function QV(e){let t=ZV(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function $V(e,t,n,r=!1){let i;typeof e==`string`?i=fV(e):(i={...e},oV(!i.pathname||!i.pathname.includes(`?`),XV(`?`,`pathname`,`search`,i)),oV(!i.pathname||!i.pathname.includes(`#`),XV(`#`,`pathname`,`hash`,i)),oV(!i.search||!i.search.includes(`#`),XV(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=JV(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var eH=e=>e.replace(/\/\/+/g,`/`),tH=e=>eH(e.join(`/`)),nH=e=>e.replace(/\/+$/,``),rH=e=>nH(e).replace(/^\/*/,`/`),iH=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,aH=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,oH=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function sH(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function cH(e){return tH(e.map(e=>e.route.path).filter(Boolean))||`/`}var lH=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function uH(e,t){let n=e;if(typeof n!=`string`||!KV.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(lH)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=WV(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{sV(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}var dH=Symbol(`Uninstrumented`);function fH(e,t){let n={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};e.forEach(e=>e({id:t.id,index:t.index,path:t.path,instrument(e){let t=Object.keys(n);for(let r of t)e[r]&&n[r].push(e[r])}}));let r={};if(typeof t.lazy==`function`&&n.lazy.length>0){let e=mH(n.lazy,t.lazy,()=>void 0);e&&(r.lazy=e)}if(typeof t.lazy==`object`){let e=t.lazy;[`middleware`,`loader`,`action`].forEach(t=>{let i=e[t],a=n[`lazy.${t}`];if(typeof i==`function`&&a.length>0){let e=mH(a,i,()=>void 0);e&&(r.lazy=Object.assign(r.lazy||{},{[t]:e}))}})}return[`loader`,`action`].forEach(e=>{let i=t[e];if(typeof i==`function`&&n[e].length>0){let t=i[dH]??i,a=mH(n[e],t,(...e)=>gH(e[0]));a&&(e===`loader`&&t.hydrate===!0&&(a.hydrate=!0),a[dH]=t,r[e]=a)}}),t.middleware&&t.middleware.length>0&&n.middleware.length>0&&(r.middleware=t.middleware.map(e=>{let t=e[dH]??e,r=mH(n.middleware,t,(...e)=>gH(e[0]));return r?(r[dH]=t,r):e})),r}function pH(e,t){let n={navigate:[],fetch:[]};if(t.forEach(e=>e({instrument(e){let t=Object.keys(e);for(let r of t)e[r]&&n[r].push(e[r])}})),n.navigate.length>0){let t=e.navigate[dH]??e.navigate,r=mH(n.navigate,t,(...t)=>{let[n,r]=t;return{to:typeof n==`number`||typeof n==`string`?n:n?dV(n):`.`,..._H(e,r??{})}});r&&(r[dH]=t,e.navigate=r)}if(n.fetch.length>0){let t=e.fetch[dH]??e.fetch,r=mH(n.fetch,t,(...t)=>{let[n,,r,i]=t;return{href:r??`.`,fetcherKey:n,..._H(e,i??{})}});r&&(r[dH]=t,e.fetch=r)}return e}function mH(e,t,n){return e.length===0?null:async(...r)=>{let i=await hH(e,n(...r),()=>t(...r),e.length-1);if(i.type===`error`)throw i.value;return i.value}}async function hH(e,t,n,r){let i=e[r],a;if(i){let o,s=async()=>(o?console.error(`You cannot call instrumented handlers more than once`):o=hH(e,t,n,r-1),a=await o,oV(a,`Expected a result`),a.type===`error`&&a.value instanceof Error?{status:`error`,error:a.value}:{status:`success`,error:void 0});try{await i(s,t)}catch(e){console.error(`An instrumentation function threw an error:`,e)}o||await s(),await o}else try{a={type:`success`,value:await n()}}catch(e){a={type:`error`,value:e}}return a||{type:`error`,value:Error(`No result assigned in instrumentation chain.`)}}function gH(e){let{request:t,context:n,params:r,pattern:i}=e;return{request:vH(t),params:{...r},pattern:i,context:yH(n)}}function _H(e,t){return{currentUrl:dV(e.state.location),...`formMethod`in t?{formMethod:t.formMethod}:{},...`formEncType`in t?{formEncType:t.formEncType}:{},...`formData`in t?{formData:t.formData}:{},...`body`in t?{body:t.body}:{}}}function vH(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function yH(e){if(xH(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}var bH=Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function xH(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join(`\0`)===bH}var SH=[`POST`,`PUT`,`PATCH`,`DELETE`],CH=new Set(SH),wH=[`GET`,...SH],TH=new Set(wH),EH=new Set([301,302,303,307,308]),DH=new Set([307,308]),OH={state:`idle`,location:void 0,matches:void 0,historyAction:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},kH={state:`idle`,data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},AH={state:`unblocked`,proceed:void 0,reset:void 0,location:void 0},jH=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),MH=`remix-router-transitions`,NH=Symbol(`ResetLoaderData`),PH,FH,IH,LH,RH=class{constructor(e){tV(this,PH),tV(this,FH),tV(this,IH),tV(this,LH),nV(this,PH,e),nV(this,FH,DV(e))}get stableRoutes(){return eV(this,PH)}get activeRoutes(){return eV(this,IH)??eV(this,PH)}get branches(){return eV(this,LH)??eV(this,FH)}get hasHMRRoutes(){return eV(this,IH)!=null}setRoutes(e){nV(this,PH,e),nV(this,FH,DV(e))}setHmrRoutes(e){nV(this,IH,e),nV(this,LH,DV(e))}commitHmrRoutes(){eV(this,IH)&&(nV(this,PH,eV(this,IH)),nV(this,FH,eV(this,LH)),nV(this,IH,void 0),nV(this,LH,void 0))}};PH=new WeakMap,FH=new WeakMap,IH=new WeakMap,LH=new WeakMap;function zH(e){let t=e.window?e.window:typeof window<`u`?window:void 0,n=t!==void 0&&t.document!==void 0&&t.document.createElement!==void 0;oV(e.routes.length>0,`You must provide a non-empty routes array to createRouter`);let r=e.hydrationRouteProperties||[],i=e.mapRouteProperties||jH,a=i;if(e.instrumentations){let t=e.instrumentations;a=e=>({...i(e),...fH(t.map(e=>e.route).filter(Boolean),e)})}let o={},s=new RH(SV(e.routes,a,void 0,o)),c=e.basename||`/`;c.startsWith(`/`)||(c=`/${c}`);let l=e.dataStrategy||nU,u={...e.future},d=null,f=new Set,p=null,m=null,h=null,g=null,_=e.hydrationData!=null,v=TV(s.activeRoutes,e.history.location,c,!1,s.branches),y=!1,b=null,x,S;if(v==null&&!e.patchRoutesOnNavigation){let t=EU(404,{pathname:e.history.location.pathname}),{matches:n,route:r}=TU(s.activeRoutes);x=!0,S=!x,v=n,b={[r.id]:t}}else if(v&&!e.hydrationData&&F(v,s.activeRoutes,e.history.location.pathname).active&&(v=null),!v){x=!1,S=!x,v=[];let t=F(null,s.activeRoutes,e.history.location.pathname);t.active&&t.matches&&(y=!0,v=t.matches)}else if(v.some(e=>e.route.lazy))x=!1,S=!x;else if(!v.some(e=>WH(e.route)))x=!0,S=!x;else{let t=e.hydrationData?e.hydrationData.loaderData:null,n=e.hydrationData?e.hydrationData.errors:null,r=v;if(n){let e=v.findIndex(e=>n[e.route.id]!==void 0);r=r.slice(0,e+1)}S=!1,x=!0,r.forEach(e=>{let r=GH(e.route,t,n);S||=r.renderFallback,x&&=!r.shouldLoad})}let C,w={historyAction:e.history.action,location:e.history.location,matches:v,initialized:x,renderFallback:S,navigation:OH,restoreScrollPosition:e.hydrationData==null?null:!1,preventScrollReset:!1,revalidation:`idle`,loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||b,fetchers:new Map,blockers:new Map},T=`POP`,E=null,D=!1,O,k=!1,A=new Map,j=null,M=!1,ee=!1,N=new Set,P=new Map,te=0,ne=-1,re=new Map,ie=new Set,ae=new Map,oe=new Map,se=new Set,ce=new Map,le,ue=null;function de(){if(d=e.history.listen(({action:t,location:n,delta:r})=>{if(le){le(),le=void 0;return}sV(ce.size===0||r!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let i=Ue({currentLocation:w.location,nextLocation:n,historyAction:t});if(i&&r!=null){let t=new Promise(e=>{le=e});e.history.go(r*-1),He(i,{state:`blocked`,location:n,proceed(){He(i,{state:`proceeding`,proceed:void 0,reset:void 0,location:n}),t.then(()=>e.history.go(r))},reset(){let e=new Map(w.blockers);e.set(i,AH),me({blockers:e})}}),E?.resolve(),E=null;return}return ve(t,n)}),n){XU(t,A);let e=()=>ZU(t,A);t.addEventListener(`pagehide`,e),j=()=>t.removeEventListener(`pagehide`,e)}return w.initialized||ve(`POP`,w.location,{initialHydration:!0}),C}function fe(){d&&d(),j&&j(),f.clear(),O&&O.abort(),w.fetchers.forEach((e,t)=>Pe(w.fetchers,t)),w.blockers.forEach((e,t)=>Ve(t))}function pe(e){if(f.add(e),p){let{newErrors:t}=p;p=null,e(w,{deletedFetchers:[],newErrors:t,viewTransitionOpts:void 0,flushSync:!1})}return()=>f.delete(e)}function me(e,t={}){e.matches&&=e.matches.map(e=>{let t=o[e.route.id],n=e.route;return n.element!==t.element||n.errorElement!==t.errorElement||n.hydrateFallbackElement!==t.hydrateFallbackElement?{...e,route:t}:e}),w={...w,...e};let n=[],r=[];w.fetchers.forEach((e,t)=>{e.state===`idle`&&(se.has(t)?n.push(t):r.push(t))}),se.forEach(e=>{!w.fetchers.has(e)&&!P.has(e)&&n.push(e)}),f.size===0&&(p={newErrors:e.errors??null}),[...f].forEach(r=>r(w,{deletedFetchers:n,newErrors:e.errors??null,viewTransitionOpts:t.viewTransitionOpts,flushSync:t.flushSync===!0})),n.forEach(e=>Pe(w.fetchers,e)),r.forEach(e=>w.fetchers.delete(e))}function he(t,n,{flushSync:r}={}){let i=w.actionData!=null&&w.navigation.formMethod!=null&&VU(w.navigation.formMethod)&&w.navigation.state===`loading`&&t.state?._isRedirect!==!0,a;a=n.actionData?Object.keys(n.actionData).length>0?n.actionData:null:i?w.actionData:null;let o=n.loaderData?SU(w.loaderData,n.loaderData,n.matches||[],n.errors):w.loaderData,c=w.blockers;c.size>0&&(c=new Map(c),c.forEach((e,t)=>c.set(t,AH)));let l=M?!1:Je(t,n.matches||w.matches),u=D===!0||w.navigation.formMethod!=null&&VU(w.navigation.formMethod)&&t.state?._isRedirect!==!0;s.commitHmrRoutes(),M||T===`POP`||(T===`PUSH`?e.history.push(t,t.state):T===`REPLACE`&&e.history.replace(t,t.state));let d;if(T===`POP`){let e=A.get(w.location.pathname);e&&e.has(t.pathname)?d={currentLocation:w.location,nextLocation:t}:A.has(t.pathname)&&(d={currentLocation:t,nextLocation:w.location})}else if(k){let e=A.get(w.location.pathname);e?e.add(t.pathname):(e=new Set([t.pathname]),A.set(w.location.pathname,e)),d={currentLocation:w.location,nextLocation:t}}me({...n,actionData:a,loaderData:o,historyAction:T,location:t,initialized:!0,renderFallback:!1,navigation:OH,revalidation:`idle`,restoreScrollPosition:l,preventScrollReset:u,blockers:c},{viewTransitionOpts:d,flushSync:r===!0}),T=`POP`,D=!1,k=!1,M=!1,ee=!1,E?.resolve(),E=null,ue?.resolve(),ue=null}async function ge(t,n){if(E?.resolve(),E=null,typeof t==`number`){E||=QU();let n=E.promise;return e.history.go(t),n}let{path:r,submission:i,error:a}=HH(!1,VH(w.location,w.matches,c,t,n?.fromRouteId,n?.relative),n),o;n?.mask&&(o={pathname:``,search:``,hash:``,...typeof n.mask==`string`?fV(n.mask):{...w.location.mask,...n.mask}});let s=w.location,l=uV(s,r,n&&n.state,void 0,o);l={...l,...e.history.encodeLocation(l)};let u=n&&n.replace!=null?n.replace:void 0,d=`PUSH`;u===!0?d=`REPLACE`:u===!1||i!=null&&VU(i.formMethod)&&i.formAction===w.location.pathname+w.location.search&&(d=`REPLACE`);let f=n&&`preventScrollReset`in n?n.preventScrollReset===!0:void 0,p=(n&&n.flushSync)===!0,m=Ue({currentLocation:s,nextLocation:l,historyAction:d});if(m){He(m,{state:`blocked`,location:l,proceed(){He(m,{state:`proceeding`,proceed:void 0,reset:void 0,location:l}),ge(t,n)},reset(){let e=new Map(w.blockers);e.set(m,AH),me({blockers:e})}});return}await ve(d,l,{submission:i,pendingError:a,preventScrollReset:f,replace:n&&n.replace,enableViewTransition:n&&n.viewTransition,flushSync:p,callSiteDefaultShouldRevalidate:n&&n.defaultShouldRevalidate})}function _e(){ue||=QU(),ke(),me({revalidation:`loading`});let e=ue.promise;return w.navigation.state===`submitting`?e:w.navigation.state===`idle`?(ve(w.historyAction,w.location,{startUninterruptedRevalidation:!0}),e):(ve(T||w.historyAction,w.navigation.location,{overrideNavigation:w.navigation,enableViewTransition:k===!0}),e)}async function ve(t,n,r){O&&O.abort(),O=null,T=t,M=(r&&r.startUninterruptedRevalidation)===!0,qe(w.location,w.matches),D=(r&&r.preventScrollReset)===!0,k=(r&&r.enableViewTransition)===!0;let i=s.activeRoutes,a=r?.initialHydration&&w.matches&&w.matches.length>0&&!y?w.matches:TV(i,n,c,!1,s.branches),o=(r&&r.flushSync)===!0;if(a&&w.initialized&&!ee&&kU(w.location,n)&&!(r&&r.submission&&VU(r.submission.formMethod))){he(n,{matches:a},{flushSync:o});return}let l=F(a,i,n.pathname);if(l.active&&l.matches&&(a=l.matches),!a){let{error:e,notFoundMatches:t,route:r}=We(n.pathname);he(n,{matches:t,loaderData:{},errors:{[r.id]:e}},{flushSync:o});return}let u=r&&r.overrideNavigation?{...r.overrideNavigation,matches:a,historyAction:t}:void 0;O=new AbortController;let d=gU(e.history,n,O.signal,r&&r.submission),f=e.getContext?await e.getContext():new gV,p;if(r&&r.pendingError)p=[wU(a).route.id,{type:`error`,error:r.pendingError}];else if(r&&r.submission&&VU(r.submission.formMethod)){let i=await ye(d,n,r.submission,a,t,f,l.active,r&&r.initialHydration===!0,{replace:r.replace,flushSync:o});if(i.shortCircuited)return;if(i.pendingActionResult){let[e,t]=i.pendingActionResult;if(PU(t)&&sH(t.error)&&t.error.status===404){O=null,he(n,{matches:i.matches,loaderData:{},errors:{[e]:t.error}});return}}a=i.matches||a,p=i.pendingActionResult,u=GU(n,a,t,r.submission),o=!1,l.active=!1,d=gU(e.history,d.url,d.signal)}let{shortCircuited:m,matches:h,loaderData:g,errors:_,workingFetchers:v}=await be(d,n,a,t,f,l.active,u,r&&r.submission,r&&r.fetcherSubmission,r&&r.replace,r&&r.initialHydration===!0,o,p,r&&r.callSiteDefaultShouldRevalidate);m||(O=null,he(n,{matches:h||a,...CU(p),loaderData:g,errors:_,...v?{fetchers:v}:{}}))}async function ye(t,n,i,l,u,d,f,p,m={}){if(ke(),me({navigation:KU(n,l,u,i)},{flushSync:m.flushSync===!0}),f){let e=await Ye(l,n.pathname,t.signal);if(e.type===`aborted`)return{shortCircuited:!0};if(e.type===`error`){if(e.partialMatches.length===0){let{matches:t,route:n}=TU(s.activeRoutes);return{matches:t,pendingActionResult:[n.id,{type:`error`,error:e.error}]}}let t=wU(e.partialMatches).route.id;return{matches:e.partialMatches,pendingActionResult:[t,{type:`error`,error:e.error}]}}else if(e.matches)l=e.matches;else{let{notFoundMatches:e,error:t,route:r}=We(n.pathname);return{matches:e,pendingActionResult:[r.id,{type:`error`,error:t}]}}}let h,g=UU(l,n);if(!g.route.action&&!g.route.lazy)h={type:`error`,error:EU(405,{method:t.method,pathname:n.pathname,routeId:g.route.id})};else{let e=await De(t,n,cU(a,o,t,n,l,g,p?[]:r,d),d,null);if(h=e[g.route.id],!h){for(let t of l)if(e[t.route.id]){h=e[t.route.id];break}}if(t.signal.aborted)return{shortCircuited:!0}}if(FU(h)){let n;return n=m&&m.replace!=null?m.replace:hU(h.response.headers.get(`Location`),new URL(t.url),c,e.history)===w.location.pathname+w.location.search,await Ee(t,h,!0,{submission:i,replace:n}),{shortCircuited:!0}}if(PU(h)){let e=wU(l,g.route.id);return(m&&m.replace)!==!0&&(T=`PUSH`),{matches:l,pendingActionResult:[e.route.id,h,g.route.id]}}return{matches:l,pendingActionResult:[g.route.id,h]}}async function be(t,n,i,l,u,d,f,p,m,h,g,_,v,y){let b=f||GU(n,i,l,p),x=p||m||WU(b),S=!M&&!g;if(d){if(S){let e=xe(v);me({navigation:b,...e===void 0?{}:{actionData:e}},{flushSync:_})}let e=await Ye(i,n.pathname,t.signal);if(e.type===`aborted`)return{shortCircuited:!0};if(e.type===`error`){if(e.partialMatches.length===0){let{matches:t,route:n}=TU(s.activeRoutes);return{matches:t,loaderData:{},errors:{[n.id]:e.error}}}let t=wU(e.partialMatches).route.id;return{matches:e.partialMatches,loaderData:{},errors:{[t]:e.error}}}else if(e.matches)i=e.matches;else{let{error:e,notFoundMatches:t,route:r}=We(n.pathname);return{matches:t,loaderData:{},errors:{[r.id]:e}}}}let C=s.activeRoutes,{dsMatches:T,revalidatingFetchers:E}=UH(t,u,a,o,e.history,w,i,x,n,g?[]:r,g===!0,ee,N,se,ae,ie,C,c,e.patchRoutesOnNavigation!=null,s.branches,v,y);if(ne=++te,!e.dataStrategy&&!T.some(e=>e.shouldLoad)&&!T.some(e=>e.route.middleware&&e.route.middleware.length>0)&&E.length===0){let e=new Map(w.fetchers),t=Re(e);return he(n,{matches:i,loaderData:{},errors:v&&PU(v[1])?{[v[0]]:v[1].error}:null,...CU(v),...t?{fetchers:e}:{}},{flushSync:_}),{shortCircuited:!0}}if(S){let e={};if(!d){e.navigation=b;let t=xe(v);t!==void 0&&(e.actionData=t)}E.length>0&&(e.fetchers=Se(E)),me(e,{flushSync:_})}E.forEach(e=>{Ie(e.key),e.controller&&P.set(e.key,e.controller)});let D=()=>E.forEach(e=>Ie(e.key));O&&O.signal.addEventListener(`abort`,D);let{loaderResults:k,fetcherResults:A}=await Oe(T,E,t,n,u);if(t.signal.aborted)return{shortCircuited:!0};O&&O.signal.removeEventListener(`abort`,D),E.forEach(e=>P.delete(e.key));let j=DU(k);if(j)return await Ee(t,j.result,!0,{replace:h}),{shortCircuited:!0};if(j=DU(A),j)return ie.add(j.key),await Ee(t,j.result,!0,{replace:h}),{shortCircuited:!0};let re=new Map(w.fetchers),{loaderData:oe,errors:ce}=xU(w,i,k,v,E,A,re);g&&w.errors&&(ce={...w.errors,...ce});let le=Re(re),ue=ze(ne,re),de=le||ue||E.length>0;return{matches:i,loaderData:oe,errors:ce,...de?{workingFetchers:re}:{}}}function xe(e){if(e&&!PU(e[1]))return{[e[0]]:e[1].data};if(w.actionData)return Object.keys(w.actionData).length===0?null:w.actionData}function Se(e){let t=new Map(w.fetchers);return e.forEach(e=>{let n=t.get(e.key),r=qU(void 0,n?n.data:void 0);t.set(e.key,r)}),t}async function Ce(t,n,r,i){Ie(t);let a=(i&&i.flushSync)===!0,o=s.activeRoutes,l=VH(w.location,w.matches,c,r,n,i?.relative),u=TV(o,l,c,!1,s.branches),d=F(u,o,l);if(d.active&&d.matches&&(u=d.matches),!u){je(t,n,EU(404,{pathname:l}),{flushSync:a});return}let{path:f,submission:p,error:m}=HH(!0,l,i);if(m){je(t,n,m,{flushSync:a});return}let h=e.getContext?await e.getContext():new gV,g=(i&&i.preventScrollReset)===!0;if(p&&VU(p.formMethod)){await we(t,n,f,u,h,d.active,a,g,p,i&&i.defaultShouldRevalidate);return}ae.set(t,{routeId:n,path:f}),await Te(t,n,f,u,h,d.active,a,g,p)}async function we(t,n,i,l,u,d,f,p,m,h){ke(),ae.delete(t),Ae(t,JU(m,w.fetchers.get(t)),{flushSync:f});let g=new AbortController,_=gU(e.history,i,g.signal,m);if(d){let e=await Ye(l,new URL(_.url).pathname,_.signal,t);if(e.type===`aborted`)return;if(e.type===`error`){je(t,n,e.error,{flushSync:f});return}else if(e.matches)l=e.matches;else{je(t,n,EU(404,{pathname:i}),{flushSync:f});return}}let v=UU(l,i);if(!v.route.action&&!v.route.lazy){je(t,n,EU(405,{method:m.formMethod,pathname:i,routeId:n}),{flushSync:f});return}P.set(t,g);let y=te,b=cU(a,o,_,i,l,v,r,u),x=await De(_,i,b,u,t),S=x[v.route.id];if(!S){for(let e of b)if(x[e.route.id]){S=x[e.route.id];break}}if(_.signal.aborted){P.get(t)===g&&P.delete(t);return}if(se.has(t)){if(FU(S)||PU(S)){Ae(t,YU(void 0));return}}else{if(FU(S))if(P.delete(t),ne>y){Ae(t,YU(void 0));return}else return ie.add(t),Ae(t,qU(m)),Ee(_,S,!1,{fetcherSubmission:m,preventScrollReset:p});if(PU(S)){je(t,n,S.error);return}}let C=w.navigation.location||w.location,E=gU(e.history,C,g.signal),D=s.activeRoutes,k=w.navigation.state===`idle`?w.matches:TV(D,w.navigation.location,c,!1,s.branches);oV(k,`Didn't find any matches after fetcher action`);let A=++te;re.set(t,A);let{dsMatches:j,revalidatingFetchers:M}=UH(E,u,a,o,e.history,w,k,m,C,r,!1,ee,N,se,ae,ie,D,c,e.patchRoutesOnNavigation!=null,s.branches,[v.route.id,S],h),oe=qU(m,S.data),ce=new Map(w.fetchers);ce.set(t,oe),M.filter(e=>e.key!==t).forEach(e=>{let t=e.key,n=ce.get(t),r=qU(void 0,n?n.data:void 0);ce.set(t,r),Ie(t),e.controller&&P.set(t,e.controller)}),me({fetchers:ce});let le=()=>M.forEach(e=>Ie(e.key));g.signal.addEventListener(`abort`,le);let{loaderResults:ue,fetcherResults:de}=await Oe(j,M,E,C,u);if(g.signal.aborted)return;g.signal.removeEventListener(`abort`,le),re.delete(t),P.delete(t),M.forEach(e=>P.delete(e.key));let fe=w.fetchers.has(t),pe=e=>{if(!fe)return e;let n=new Map(e.fetchers);return n.set(t,YU(S.data)),{...e,fetchers:n}},ge=DU(ue);if(ge)return w=pe(w),Ee(E,ge.result,!1,{preventScrollReset:p});if(ge=DU(de),ge)return ie.add(ge.key),w=pe(w),Ee(E,ge.result,!1,{preventScrollReset:p});let _e=new Map(w.fetchers);fe&&_e.set(t,YU(S.data));let{loaderData:ve,errors:ye}=xU(w,k,ue,void 0,M,de,_e);ze(A,_e),w.navigation.state===`loading`&&A>ne?(oV(T,`Expected pending action`),O&&O.abort(),he(w.navigation.location,{matches:k,loaderData:ve,errors:ye,fetchers:_e})):(me({errors:ye,loaderData:SU(w.loaderData,ve,k,ye),fetchers:_e}),ee=!1)}async function Te(t,n,i,s,c,l,u,d,f){let p=w.fetchers.get(t);Ae(t,qU(f,p?p.data:void 0),{flushSync:u});let m=new AbortController,h=gU(e.history,i,m.signal);if(l){let e=await Ye(s,new URL(h.url).pathname,h.signal,t);if(e.type===`aborted`)return;if(e.type===`error`){je(t,n,e.error,{flushSync:u});return}else if(e.matches)s=e.matches;else{je(t,n,EU(404,{pathname:i}),{flushSync:u});return}}let g=UU(s,i);P.set(t,m);let _=te,v=await De(h,i,cU(a,o,h,i,s,g,r,c),c,t),y=v[g.route.id];if(!y){for(let e of s)if(v[e.route.id]){y=v[e.route.id];break}}if(P.get(t)===m&&P.delete(t),!h.signal.aborted){if(se.has(t)){Ae(t,YU(void 0));return}if(FU(y))if(ne>_){Ae(t,YU(void 0));return}else{ie.add(t),await Ee(h,y,!1,{preventScrollReset:d});return}if(PU(y)){je(t,n,y.error);return}Ae(t,YU(y.data))}}async function Ee(r,i,a,{submission:o,fetcherSubmission:s,preventScrollReset:l,replace:u}={}){a||(E?.resolve(),E=null),i.response.headers.has(`X-Remix-Revalidate`)&&(ee=!0);let d=i.response.headers.get(`Location`);oV(d,`Expected a Location header on the redirect Response`),d=hU(d,new URL(r.url),c,e.history);let f=uV(w.location,d,{_isRedirect:!0});if(n){let e=!1;if(i.response.headers.has(`X-Remix-Reload-Document`))e=!0;else if(qV(d)){let n=mV(t,d,!0);e=n.origin!==t.location.origin||WV(n.pathname,c)==null}if(e){u?t.location.replace(d):t.location.assign(d);return}}O=null;let p=u===!0||i.response.headers.has(`X-Remix-Replace`)?`REPLACE`:`PUSH`,{formMethod:m,formAction:h,formEncType:g}=w.navigation;!o&&!s&&m&&h&&g&&(o=WU(w.navigation));let _=o||s;DH.has(i.response.status)&&_&&VU(_.formMethod)?await ve(p,f,{submission:{..._,formAction:d},preventScrollReset:l||D,enableViewTransition:a?k:void 0}):await ve(p,f,{overrideNavigation:GU(f,[],p,o),fetcherSubmission:s,preventScrollReset:l||D,enableViewTransition:a?k:void 0})}async function De(e,t,n,r,i){let a,o={};try{a=await lU(l,e,t,n,i,r,!1)}catch(e){return n.filter(e=>e.shouldLoad).forEach(t=>{o[t.route.id]={type:`error`,error:e}}),o}if(e.signal.aborted)return o;if(!VU(e.method))for(let e of n){if(a[e.route.id]?.type===`error`)break;!a.hasOwnProperty(e.route.id)&&!w.loaderData.hasOwnProperty(e.route.id)&&(!w.errors||!w.errors.hasOwnProperty(e.route.id))&&e.shouldCallHandler()&&(a[e.route.id]={type:`error`,result:Error(`No result returned from dataStrategy for route ${e.route.id}`)})}for(let[t,r]of Object.entries(a))if(NU(r)){let i=r.result;o[t]={type:`redirect`,response:pU(i,e,t,n,c)}}else o[t]=await fU(r);return o}async function Oe(e,t,n,r,i){let a=De(n,r,e,i,null),o=Promise.all(t.map(async e=>{if(e.matches&&e.match&&e.request&&e.controller){let t=(await De(e.request,e.path,e.matches,i,e.key))[e.match.route.id];return{[e.key]:t}}else return Promise.resolve({[e.key]:{type:`error`,error:EU(404,{pathname:e.path})}})}));return{loaderResults:await a,fetcherResults:(await o).reduce((e,t)=>Object.assign(e,t),{})}}function ke(){ee=!0,ae.forEach((e,t)=>{P.has(t)&&N.add(t),Ie(t)})}function Ae(e,t,n={}){let r=new Map(w.fetchers);r.set(e,t),me({fetchers:r},{flushSync:(n&&n.flushSync)===!0})}function je(e,t,n,r={}){let i=wU(w.matches,t),a=new Map(w.fetchers);Pe(a,e),me({errors:{[i.route.id]:n},fetchers:a},{flushSync:(r&&r.flushSync)===!0})}function Me(e){return oe.set(e,(oe.get(e)||0)+1),se.has(e)&&se.delete(e),w.fetchers.get(e)||kH}function Ne(e,t){Ie(e,t?.reason),Ae(e,YU(null))}function Pe(e,t){let n=w.fetchers.get(t);P.has(t)&&!(n&&n.state===`loading`&&re.has(t))&&Ie(t),ae.delete(t),re.delete(t),ie.delete(t),se.delete(t),N.delete(t),e.delete(t)}function Fe(e){let t=(oe.get(e)||0)-1;t<=0?(oe.delete(e),se.add(e)):oe.set(e,t),me({fetchers:new Map(w.fetchers)})}function Ie(e,t){let n=P.get(e);n&&(n.abort(t),P.delete(e))}function Le(e,t){for(let n of e){let e=t.get(n);oV(e,`Expected fetcher: ${n}`);let r=YU(e.data);t.set(n,r)}}function Re(e){let t=[],n=!1;for(let r of ie){let i=e.get(r);oV(i,`Expected fetcher: ${r}`),i.state===`loading`&&(ie.delete(r),t.push(r),n=!0)}return Le(t,e),n}function ze(e,t){let n=[];for(let[r,i]of re)if(i<e){let e=t.get(r);oV(e,`Expected fetcher: ${r}`),e.state===`loading`&&(Ie(r),re.delete(r),n.push(r))}return Le(n,t),n.length>0}function Be(e,t){let n=w.blockers.get(e)||AH;return ce.get(e)!==t&&ce.set(e,t),n}function Ve(e){w.blockers.delete(e),ce.delete(e)}function He(e,t){let n=w.blockers.get(e)||AH;oV(n.state===`unblocked`&&t.state===`blocked`||n.state===`blocked`&&t.state===`blocked`||n.state===`blocked`&&t.state===`proceeding`||n.state===`blocked`&&t.state===`unblocked`||n.state===`proceeding`&&t.state===`unblocked`,`Invalid blocker state transition: ${n.state} -> ${t.state}`);let r=new Map(w.blockers);r.set(e,t),me({blockers:r})}function Ue({currentLocation:e,nextLocation:t,historyAction:n}){if(ce.size===0)return;ce.size>1&&sV(!1,`A router only supports one blocker at a time`);let r=Array.from(ce.entries()),[i,a]=r[r.length-1],o=w.blockers.get(i);if(!(o&&o.state===`proceeding`)&&a({currentLocation:e,nextLocation:t,historyAction:n}))return i}function We(e){let t=EU(404,{pathname:e}),n=s.activeRoutes,{matches:r,route:i}=TU(n);return{notFoundMatches:r,route:i,error:t}}function Ge(e,t,n){if(m=e,g=t,h=n||null,!_&&w.navigation===OH){_=!0;let e=Je(w.location,w.matches);e!=null&&me({restoreScrollPosition:e})}return()=>{m=null,g=null,h=null}}function Ke(e,t){return h&&h(e,t.map(e=>EV(e,w.loaderData)))||e.key}function qe(e,t){if(m&&g){let n=Ke(e,t);m[n]=g()}}function Je(e,t){if(m){let n=Ke(e,t),r=m[n];if(typeof r==`number`)return r}return null}function F(t,n,r){if(e.patchRoutesOnNavigation){let e=s.branches;if(!t)return{active:!0,matches:TV(n,r,c,!0,e)||[]};if(Object.keys(t[0].params).length>0)return{active:!0,matches:TV(n,r,c,!0,e)}}return{active:!1,matches:null}}async function Ye(t,n,r,i){if(!e.patchRoutesOnNavigation)return{type:`success`,matches:t};let l=t;for(;;){let t=o;try{await e.patchRoutesOnNavigation({signal:r,path:n,matches:l,fetcherKey:i,patch:(e,n)=>{r.aborted||YH(e,n,s,t,a,!1)}})}catch(e){return{type:`error`,error:e,partialMatches:l}}if(r.aborted)return{type:`aborted`};let u=s.branches,d=TV(s.activeRoutes,n,c,!1,u),f=null;if(d&&(Object.keys(d[0].params).length===0||(f=TV(s.activeRoutes,n,c,!0,u),!(f&&l.length<f.length&&Xe(l,f.slice(0,l.length))))))return{type:`success`,matches:d};if(f||=TV(s.activeRoutes,n,c,!0,u),!f||Xe(l,f))return{type:`success`,matches:null};l=f}}function Xe(e,t){return e.length===t.length&&e.every((e,n)=>e.route.id===t[n].route.id)}function Ze(e){o={},s.setHmrRoutes(SV(e,a,void 0,o))}function Qe(e,t,n=!1){YH(e,t,s,o,a,n),s.hasHMRRoutes||me({})}return C={get basename(){return c},get future(){return u},get state(){return w},get routes(){return s.stableRoutes},get branches(){return s.branches},get manifest(){return o},get window(){return t},initialize:de,subscribe:pe,enableScrollRestoration:Ge,navigate:ge,fetch:Ce,revalidate:_e,createHref:t=>e.history.createHref(t),encodeLocation:t=>e.history.encodeLocation(t),getFetcher:Me,resetFetcher:Ne,deleteFetcher:Fe,dispose:fe,getBlocker:Be,deleteBlocker:Ve,patchRoutes:Qe,_internalFetchControllers:P,_internalSetRoutes:Ze,_internalSetStateDoNotUseOrYouWillBreakYourApp(e){me(e)}},e.instrumentations&&(C=pH(C,e.instrumentations.map(e=>e.router).filter(Boolean))),C}function BH(e){return e!=null&&(`formData`in e&&e.formData!=null||`body`in e&&e.body!==void 0)}function VH(e,t,n,r,i,a){let o,s;if(i){o=[];for(let e of t)if(o.push(e),e.route.id===i){s=e;break}}else o=t,s=t[t.length-1];let c=$V(r||`.`,QV(o),WV(e.pathname,n)||e.pathname,a===`path`);if(r??(c.search=e.search,c.hash=e.hash),(r==null||r===``||r===`.`)&&s){let e=HU(c.search);if(s.route.index&&!e)c.search=c.search?c.search.replace(/^\?/,`?index&`):`?index`;else if(!s.route.index&&e){let e=new URLSearchParams(c.search),t=e.getAll(`index`);e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();c.search=n?`?${n}`:``}}return n!==`/`&&(c.pathname=GV({basename:n,pathname:c.pathname})),dV(c)}function HH(e,t,n){if(!n||!BH(n))return{path:t};if(n.formMethod&&!BU(n.formMethod))return{path:t,error:EU(405,{method:n.formMethod})};let r=()=>({path:t,error:EU(400,{type:`invalid-body`})}),i=(n.formMethod||`get`).toUpperCase(),a=OU(t);if(n.body!==void 0){if(n.formEncType===`text/plain`){if(!VU(i))return r();let e=typeof n.body==`string`?n.body:n.body instanceof FormData||n.body instanceof URLSearchParams?Array.from(n.body.entries()).reduce((e,[t,n])=>`${e}${t}=${n}
209
+ `,``):String(n.body);return{path:t,submission:{formMethod:i,formAction:a,formEncType:n.formEncType,formData:void 0,json:void 0,text:e}}}else if(n.formEncType===`application/json`){if(!VU(i))return r();try{let e=typeof n.body==`string`?JSON.parse(n.body):n.body;return{path:t,submission:{formMethod:i,formAction:a,formEncType:n.formEncType,formData:void 0,json:e,text:void 0}}}catch{return r()}}}oV(typeof FormData==`function`,`FormData is not available in this environment`);let o,s;if(n.formData)o=vU(n.formData),s=n.formData;else if(n.body instanceof FormData)o=vU(n.body),s=n.body;else if(n.body instanceof URLSearchParams)o=n.body,s=yU(o);else if(n.body==null)o=new URLSearchParams,s=new FormData;else try{o=new URLSearchParams(n.body),s=yU(o)}catch{return r()}let c={formMethod:i,formAction:a,formEncType:n&&n.formEncType||`application/x-www-form-urlencoded`,formData:s,json:void 0,text:void 0};if(VU(c.formMethod))return{path:t,submission:c};let l=fV(t);return e&&l.search&&HU(l.search)&&o.append(`index`,``),l.search=`?${o}`,{path:dV(l),submission:c}}function UH(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x){let S=b?PU(b[1])?b[1].error:b[1].data:void 0,C=i.createURL(a.location),w=i.createURL(c),T;if(u&&a.errors){let e=Object.keys(a.errors)[0];T=o.findIndex(t=>t.route.id===e)}else if(b&&PU(b[1])){let e=b[0];T=o.findIndex(t=>t.route.id===e)-1}let E=b?b[1].statusCode:void 0,D=E&&E>=400,O={currentUrl:C,currentParams:a.matches[0]?.params||{},nextUrl:w,nextParams:o[0].params,...s,actionResult:S,actionStatus:E},k=cH(o),A=o.map((i,o)=>{let{route:s}=i,f=null;if(T!=null&&o>T)f=!1;else if(s.lazy)f=!0;else if(!WH(s))f=!1;else if(u){let{shouldLoad:e}=GH(s,a.loaderData,a.errors);f=e}else KH(a.loaderData,a.matches[o],i)&&(f=!0);if(f!==null)return sU(n,r,e,c,k,i,l,t,f);let p=!1;typeof x==`boolean`?p=x:D?p=!1:d||C.pathname+C.search===w.pathname+w.search?p=!0:C.search===w.search?qH(a.matches[o],i)&&(p=!0):p=!0;let m={...O,defaultShouldRevalidate:p};return sU(n,r,e,c,k,i,l,t,JH(i,m),m,x)}),j=[];return m.forEach((e,s)=>{if(u||!o.some(t=>t.route.id===e.routeId)||p.has(s))return;let c=a.fetchers.get(s),m=c&&c.state!==`idle`&&c.data===void 0,b=TV(g,e.path,_??`/`,!1,y);if(!b){if(v&&m)return;j.push({key:s,routeId:e.routeId,path:e.path,matches:null,match:null,request:null,controller:null});return}if(h.has(s))return;let S=UU(b,e.path),C=new AbortController,w=gU(i,e.path,C.signal),T=null;if(f.has(s))f.delete(s),T=cU(n,r,w,e.path,b,S,l,t);else if(m)d&&(T=cU(n,r,w,e.path,b,S,l,t));else{let i;i=typeof x==`boolean`?x:D?!1:d;let a={...O,defaultShouldRevalidate:i};JH(S,a)&&(T=cU(n,r,w,e.path,b,S,l,t,a))}T&&j.push({key:s,routeId:e.routeId,path:e.path,matches:T,match:S,request:w,controller:C})}),{dsMatches:A,revalidatingFetchers:j}}function WH(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function GH(e,t,n){if(e.lazy)return{shouldLoad:!0,renderFallback:!0};if(!WH(e))return{shouldLoad:!1,renderFallback:!1};let r=t!=null&&e.id in t,i=n!=null&&n[e.id]!==void 0;if(!r&&i)return{shouldLoad:!1,renderFallback:!1};if(typeof e.loader==`function`&&e.loader.hydrate===!0)return{shouldLoad:!0,renderFallback:!r};let a=!r&&!i;return{shouldLoad:a,renderFallback:a}}function KH(e,t,n){let r=!t||n.route.id!==t.route.id,i=!e.hasOwnProperty(n.route.id);return r||i}function qH(e,t){let n=e.route.path;return e.pathname!==t.pathname||n!=null&&n.endsWith(`*`)&&e.params[`*`]!==t.params[`*`]}function JH(e,t){if(e.route.shouldRevalidate){let n=e.route.shouldRevalidate(t);if(typeof n==`boolean`)return n}return t.defaultShouldRevalidate}function YH(e,t,n,r,i,a){let o;if(e){let t=r[e];oV(t,`No route found to patch children into: routeId = ${e}`),t.children||=[],o=t.children}else o=n.activeRoutes;let s=[],c=[];if(t.forEach(e=>{let t=o.find(t=>XH(e,t));t?c.push({existingRoute:t,newRoute:e}):s.push(e)}),s.length>0){let t=SV(s,i,[e||`_`,`patch`,String(o?.length||`0`)],r);o.push(...t)}if(a&&c.length>0)for(let e=0;e<c.length;e++){let{existingRoute:t,newRoute:n}=c[e],r=t,[a]=SV([n],i,[],{},!0);Object.assign(r,{element:a.element?a.element:r.element,errorElement:a.errorElement?a.errorElement:r.errorElement,hydrateFallbackElement:a.hydrateFallbackElement?a.hydrateFallbackElement:r.hydrateFallbackElement})}n.hasHMRRoutes||n.setRoutes([...n.activeRoutes])}function XH(e,t){return`id`in e&&`id`in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children?.every((e,n)=>t.children?.some(t=>XH(e,t)))??!1:!1}var ZH=new WeakMap,QH=({key:e,route:t,manifest:n,mapRouteProperties:r})=>{let i=n[t.id];if(oV(i,`No route found in manifest`),!i.lazy||typeof i.lazy!=`object`)return;let a=i.lazy[e];if(!a)return;let o=ZH.get(i);o||(o={},ZH.set(i,o));let s=o[e];if(s)return s;let c=(async()=>{let t=vV(e),n=i[e]!==void 0&&e!==`hasErrorBoundary`;if(t)sV(!t,`Route property `+e+` is not a supported lazy route property. This property will be ignored.`),o[e]=Promise.resolve();else if(n)sV(!1,`Route "${i.id}" has a static property "${e}" defined. The lazy property will be ignored.`);else{let t=await a();t!=null&&(Object.assign(i,{[e]:t}),Object.assign(i,r(i)))}typeof i.lazy==`object`&&(i.lazy[e]=void 0,Object.values(i.lazy).every(e=>e===void 0)&&(i.lazy=void 0))})();return o[e]=c,c},$H=new WeakMap;function eU(e,t,n,r,i){let a=n[e.id];if(oV(a,`No route found in manifest`),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy==`function`){let t=$H.get(a);if(t)return{lazyRoutePromise:t,lazyHandlerPromise:t};let n=(async()=>{oV(typeof e.lazy==`function`,`No lazy route function found`);let t=await e.lazy(),n={};for(let e in t){let r=t[e];if(r===void 0)continue;let i=bV(e),o=a[e]!==void 0&&e!==`hasErrorBoundary`;i?sV(!i,`Route property `+e+` is not a supported property to be returned from a lazy route function. This property will be ignored.`):o?sV(!o,`Route "${a.id}" has a static property "${e}" defined but its lazy function is also returning a value for this property. The lazy route property "${e}" will be ignored.`):n[e]=r}Object.assign(a,n),Object.assign(a,{...r(a),lazy:void 0})})();return $H.set(a,n),n.catch(()=>{}),{lazyRoutePromise:n,lazyHandlerPromise:n}}let o=Object.keys(e.lazy),s=[],c;for(let a of o){if(i&&i.includes(a))continue;let o=QH({key:a,route:e,manifest:n,mapRouteProperties:r});o&&(s.push(o),a===t&&(c=o))}let l=s.length>0?Promise.all(s).then(()=>{}):void 0;return l?.catch(()=>{}),c?.catch(()=>{}),{lazyRoutePromise:l,lazyHandlerPromise:c}}async function tU(e){let t=e.matches.filter(e=>e.shouldLoad),n={};return(await Promise.all(t.map(e=>e.resolve()))).forEach((e,r)=>{n[t[r].route.id]=e}),n}async function nU(e){return e.matches.some(e=>e.route.middleware)?rU(e,()=>tU(e)):tU(e)}function rU(e,t){return iU(e,t,e=>{if(zU(e))throw e;return e},jU,n);function n(t,n,r){if(r)return Promise.resolve(Object.assign(r.value,{[n]:{type:`error`,result:t}}));{let{matches:r}=e,i=wU(r,r[Math.min(Math.max(r.findIndex(e=>e.route.id===n),0),Math.max(r.findIndex(e=>e.shouldCallHandler()),0))].route.id).route.id;return Promise.resolve({[i]:{type:`error`,result:t}})}}}async function iU(e,t,n,r,i){let{matches:a,...o}=e;return await aU(o,a.flatMap(e=>e.route.middleware?e.route.middleware.map(t=>[e.route.id,t]):[]),t,n,r,i)}async function aU(e,t,n,r,i,a,o=0){let{request:s}=e;if(s.signal.aborted)throw s.signal.reason??Error(`Request aborted: ${s.method} ${s.url}`);let c=t[o];if(!c)return await n();let[l,u]=c,d,f=async()=>{if(d)throw Error("You may only call `next()` once per middleware");try{return d={value:await aU(e,t,n,r,i,a,o+1)},d.value}catch(e){return d={value:await a(e,l,d)},d.value}};try{let t=await u(e,f),n=t==null?void 0:r(t);return i(n)?n:d?n??d.value:(d={value:await f()},d.value)}catch(e){return await a(e,l,d)}}function oU(e,t,n,r,i){let a=QH({key:`middleware`,route:r.route,manifest:t,mapRouteProperties:e}),o=eU(r.route,VU(n.method)?`action`:`loader`,t,e,i);return{middleware:a,route:o.lazyRoutePromise,handler:o.lazyHandlerPromise}}function sU(e,t,n,r,i,a,o,s,c,l=null,u){let d=!1,f=oU(e,t,n,a,o);return{...a,_lazyPromises:f,shouldLoad:c,shouldRevalidateArgs:l,shouldCallHandler(e){return d=!0,l?typeof u==`boolean`?JH(a,{...l,defaultShouldRevalidate:u}):typeof e==`boolean`?JH(a,{...l,defaultShouldRevalidate:e}):JH(a,l):c},resolve(e){let{lazy:t,loader:o,middleware:l}=a.route,u=d||c||e&&!VU(n.method)&&(t||o),p=l&&l.length>0&&!o&&!t;return u&&(VU(n.method)||!p)?uU({request:n,path:r,pattern:i,match:a,lazyHandlerPromise:f?.handler,lazyRoutePromise:f?.route,handlerOverride:e,scopedContext:s}):Promise.resolve({type:`data`,result:void 0})}}}function cU(e,t,n,r,i,a,o,s,c=null){return i.map(l=>l.route.id===a.route.id?sU(e,t,n,r,cH(i),l,o,s,!0,c):{...l,shouldLoad:!1,shouldRevalidateArgs:c,shouldCallHandler:()=>!1,_lazyPromises:oU(e,t,n,l,o),resolve:()=>Promise.resolve({type:`data`,result:void 0})})}async function lU(e,t,n,r,i,a,o){r.some(e=>e._lazyPromises?.middleware)&&await Promise.all(r.map(e=>e._lazyPromises?.middleware));let s={request:t,url:_U(t,n),pattern:cH(r),params:r[0].params,context:a,matches:r},c=o?()=>{throw Error("You cannot call `runClientMiddleware()` from a static handler `dataStrategy`. Middleware is run outside of `dataStrategy` during SSR in order to bubble up the Response. You can enable middleware via the `respond` API in `query`/`queryRoute`")}:e=>{let t=s;return rU(t,()=>e({...t,fetcherKey:i,runClientMiddleware:()=>{throw Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}}))},l=await e({...s,fetcherKey:i,runClientMiddleware:c});try{await Promise.all(r.flatMap(e=>[e._lazyPromises?.handler,e._lazyPromises?.route]))}catch{}return l}async function uU({request:e,path:t,pattern:n,match:r,lazyHandlerPromise:i,lazyRoutePromise:a,handlerOverride:o,scopedContext:s}){let c,l,u=VU(e.method),d=u?`action`:`loader`,f=i=>{let a,c=new Promise((e,t)=>a=t);l=()=>a(),e.signal.addEventListener(`abort`,l);let u=a=>typeof i==`function`?i({request:e,url:_U(e,t),pattern:n,params:r.params,context:s},...a===void 0?[]:[a]):Promise.reject(Error(`You cannot call the handler for a route which defines a boolean "${d}" [routeId: ${r.route.id}]`)),f=(async()=>{try{return{type:`data`,result:await(o?o(e=>u(e)):u())}}catch(e){return{type:`error`,result:e}}})();return Promise.race([f,c])};try{let t=u?r.route.action:r.route.loader;if(i||a)if(t){let e,[n]=await Promise.all([f(t).catch(t=>{e=t}),i,a]);if(e!==void 0)throw e;c=n}else{await i;let t=u?r.route.action:r.route.loader;if(t)[c]=await Promise.all([f(t),a]);else if(d===`action`){let t=new URL(e.url),n=t.pathname+t.search;throw EU(405,{method:e.method,pathname:n,routeId:r.route.id})}else return{type:`data`,result:void 0}}else if(t)c=await f(t);else{let t=new URL(e.url);throw EU(404,{pathname:t.pathname+t.search})}}catch(e){return{type:`error`,result:e}}finally{l&&e.signal.removeEventListener(`abort`,l)}return c}async function dU(e){let t=e.headers.get(`Content-Type`);return t&&/\bapplication\/json\b/.test(t)?e.body==null?null:e.json():e.text()}async function fU(e){let{result:t,type:n}=e;if(LU(t)){let e;try{e=await dU(t)}catch(e){return{type:`error`,error:e}}return n===`error`?{type:`error`,error:new oH(t.status,t.statusText,e),statusCode:t.status,headers:t.headers}:{type:`data`,data:e,statusCode:t.status,headers:t.headers}}return n===`error`?IU(t)?t.data instanceof Error?{type:`error`,error:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`error`,error:AU(t),statusCode:sH(t)?t.status:void 0,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`error`,error:t,statusCode:sH(t)?t.status:void 0}:IU(t)?{type:`data`,data:t.data,statusCode:t.init?.status,headers:t.init?.headers?new Headers(t.init.headers):void 0}:{type:`data`,data:t}}function pU(e,t,n,r,i){let a=e.headers.get(`Location`);if(oV(a,`Redirects returned/thrown from loaders/actions must have a Location header`),!qV(a)){let o=r.slice(0,r.findIndex(e=>e.route.id===n)+1);a=VH(new URL(t.url),o,i,a),e.headers.set(`Location`,a)}return e}var mU=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function hU(e,t,n,r){if(qV(e)){let r=e,i=r.startsWith(`//`)?new URL(t.protocol+r):new URL(r);if(mU.includes(i.protocol))throw Error(`Invalid redirect location`);let a=WV(i.pathname,n)!=null;if(i.origin===t.origin&&a)return eH(i.pathname)+i.search+i.hash}try{let t=r.createURL(e);if(mU.includes(t.protocol))throw Error(`Invalid redirect location`)}catch{}return e}function gU(e,t,n,r){let i=e.createURL(OU(t)).toString(),a={signal:n};if(r&&VU(r.formMethod)){let{formMethod:e,formEncType:t}=r;a.method=e.toUpperCase(),t===`application/json`?(a.headers=new Headers({"Content-Type":t}),a.body=JSON.stringify(r.json)):t===`text/plain`?a.body=r.text:t===`application/x-www-form-urlencoded`&&r.formData?a.body=vU(r.formData):a.body=r.formData}return new Request(i,a)}function _U(e,t){let n=new URL(e.url),r=typeof t==`string`?fV(t):t;if(n.pathname=r.pathname||`/`,r.search){let e=new URLSearchParams(r.search),t=e.getAll(`index`);e.delete(`index`);for(let n of t.filter(Boolean))e.append(`index`,n);n.search=e.size?`?${e.toString()}`:``}else n.search=``;return n.hash=r.hash||``,n}function vU(e){let t=new URLSearchParams;for(let[n,r]of e.entries())t.append(n,typeof r==`string`?r:r.name);return t}function yU(e){let t=new FormData;for(let[n,r]of e.entries())t.append(n,r);return t}function bU(e,t,n,r=!1,i=!1){let a={},o=null,s,c=!1,l={},u=n&&PU(n[1])?n[1].error:void 0;return e.forEach(n=>{if(!(n.route.id in t))return;let d=n.route.id,f=t[d];if(oV(!FU(f),`Cannot handle redirect results in processLoaderData`),PU(f)){let t=f.error;if(u!==void 0&&(t=u,u=void 0),o||={},i)o[d]=t;else{let n=wU(e,d);o[n.route.id]??(o[n.route.id]=t)}r||(a[d]=NH),c||(c=!0,s=sH(f.error)?f.error.status:500),f.headers&&(l[d]=f.headers)}else a[d]=f.data,f.statusCode&&f.statusCode!==200&&!c&&(s=f.statusCode),f.headers&&(l[d]=f.headers)}),u!==void 0&&n&&(o={[n[0]]:u},n[2]&&(a[n[2]]=void 0)),{loaderData:a,errors:o,statusCode:s||200,loaderHeaders:l}}function xU(e,t,n,r,i,a,o){let{loaderData:s,errors:c}=bU(t,n,r);return i.filter(e=>!e.matches||e.matches.some(e=>e.shouldLoad)).forEach(t=>{let{key:n,match:r,controller:i}=t;if(i&&i.signal.aborted)return;let s=a[n];if(oV(s,`Did not find corresponding fetcher result`),PU(s)){let t=wU(e.matches,r?.route.id);c&&c[t.route.id]||(c={...c,[t.route.id]:s.error}),o.delete(n)}else if(FU(s))oV(!1,`Unhandled fetcher revalidation redirect`);else{let e=YU(s.data);o.set(n,e)}}),{loaderData:s,errors:c}}function SU(e,t,n,r){let i=Object.entries(t).filter(([,e])=>e!==NH).reduce((e,[t,n])=>(e[t]=n,e),{});for(let a of n){let n=a.route.id;if(!t.hasOwnProperty(n)&&e.hasOwnProperty(n)&&a.route.loader&&(i[n]=e[n]),r&&r.hasOwnProperty(n))break}return i}function CU(e){return e?PU(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function wU(e,t){return(t?e.slice(0,e.findIndex(e=>e.route.id===t)+1):[...e]).reverse().find(e=>e.route.hasErrorBoundary===!0)||e[0]}function TU(e){let t=e.length===1?e[0]:e.find(e=>e.index||!e.path||e.path===`/`)||{id:`__shim-error-route__`};return{matches:[{params:{},pathname:``,pathnameBase:``,route:t}],route:t}}function EU(e,{pathname:t,routeId:n,method:r,type:i,message:a}={}){let o=`Unknown Server Error`,s=`Unknown @remix-run/router error`;return e===400?(o=`Bad Request`,r&&t&&n?s=`You made a ${r} request to "${t}" but did not provide a \`loader\` for route "${n}", so there is no way to handle the request.`:i===`invalid-body`&&(s=`Unable to encode submission body`)):e===403?(o=`Forbidden`,s=`Route "${n}" does not match URL "${t}"`):e===404?(o=`Not Found`,s=`No route matches URL "${t}"`):e===405&&(o=`Method Not Allowed`,r&&t&&n?s=`You made a ${r.toUpperCase()} request to "${t}" but did not provide an \`action\` for route "${n}", so there is no way to handle the request.`:r&&(s=`Invalid request method "${r.toUpperCase()}"`)),new oH(e||500,o,Error(s),!0)}function DU(e){let t=Object.entries(e);for(let e=t.length-1;e>=0;e--){let[n,r]=t[e];if(FU(r))return{key:n,result:r}}}function OU(e){return dV({...typeof e==`string`?fV(e):e,hash:``})}function kU(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===``?t.hash!==``:e.hash===t.hash?!0:t.hash!==``}function AU(e){return new oH(e.init?.status??500,e.init?.statusText??`Internal Server Error`,e.data)}function jU(e){return typeof e==`object`&&!!e&&Object.entries(e).every(([e,t])=>typeof e==`string`&&MU(t))}function MU(e){return typeof e==`object`&&!!e&&`type`in e&&`result`in e&&(e.type===`data`||e.type===`error`)}function NU(e){return LU(e.result)&&EH.has(e.result.status)}function PU(e){return e.type===`error`}function FU(e){return(e&&e.type)===`redirect`}function IU(e){return typeof e==`object`&&!!e&&`type`in e&&`data`in e&&`init`in e&&e.type===`DataWithResponseInit`}function LU(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.headers==`object`&&e.body!==void 0}function RU(e){return EH.has(e)}function zU(e){return LU(e)&&RU(e.status)&&e.headers.has(`Location`)}function BU(e){return TH.has(e.toUpperCase())}function VU(e){return CH.has(e.toUpperCase())}function HU(e){return new URLSearchParams(e).getAll(`index`).some(e=>e===``)}function UU(e,t){let n=typeof t==`string`?fV(t).search:t.search;if(e[e.length-1].route.index&&HU(n||``))return e[e.length-1];let r=ZV(e);return r[r.length-1]}function WU(e){let{formMethod:t,formAction:n,formEncType:r,text:i,formData:a,json:o}=e;if(!(!t||!n||!r)){if(i!=null)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:void 0,text:i};if(a!=null)return{formMethod:t,formAction:n,formEncType:r,formData:a,json:void 0,text:void 0};if(o!==void 0)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:o,text:void 0}}}function GU(e,t,n,r){return r?{state:`loading`,location:e,matches:t,historyAction:n,formMethod:r.formMethod,formAction:r.formAction,formEncType:r.formEncType,formData:r.formData,json:r.json,text:r.text}:{state:`loading`,location:e,matches:t,historyAction:n,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function KU(e,t,n,r){return{state:`submitting`,location:e,matches:t,historyAction:n,formMethod:r.formMethod,formAction:r.formAction,formEncType:r.formEncType,formData:r.formData,json:r.json,text:r.text}}function qU(e,t){return e?{state:`loading`,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:`loading`,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function JU(e,t){return{state:`submitting`,formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function YU(e){return{state:`idle`,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function XU(e,t){try{let n=e.sessionStorage.getItem(MH);if(n){let e=JSON.parse(n);for(let[n,r]of Object.entries(e||{}))r&&Array.isArray(r)&&t.set(n,new Set(r||[]))}}catch{}}function ZU(e,t){if(t.size>0){let n={};for(let[e,r]of t)n[e]=[...r];try{e.sessionStorage.setItem(MH,JSON.stringify(n))}catch(e){sV(!1,`Failed to save applied view transitions in sessionStorage (${e}).`)}}}function QU(){let e,t,n=new Promise((r,i)=>{e=async e=>{r(e);try{await n}catch{}},t=async e=>{i(e);try{await n}catch{}}});return{promise:n,resolve:e,reject:t}}var $U=b.createContext(null);$U.displayName=`DataRouter`;var eW=b.createContext(null);eW.displayName=`DataRouterState`;var tW=b.createContext(!1);function nW(){return b.useContext(tW)}var rW=b.createContext({isTransitioning:!1});rW.displayName=`ViewTransition`;var iW=b.createContext(new Map);iW.displayName=`Fetchers`;var aW=b.createContext(null);aW.displayName=`Await`;var oW=b.createContext(null);oW.displayName=`Navigation`;var sW=b.createContext(null);sW.displayName=`Location`;var cW=b.createContext({outlet:null,matches:[],isDataRoute:!1});cW.displayName=`Route`;var lW=b.createContext(null);lW.displayName=`RouteError`;var uW=`REACT_ROUTER_ERROR`,dW=`REDIRECT`,fW=`ROUTE_ERROR_RESPONSE`;function pW(e){if(e.startsWith(`${uW}:${dW}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function mW(e){if(e.startsWith(`${uW}:${fW}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new oH(t.status,t.statusText,t.data)}catch{}}function hW(e,{relative:t}={}){oV(gW(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=b.useContext(oW),{hash:i,pathname:a,search:o}=TW(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:tH([n,a])),r.createHref({pathname:s,search:o,hash:i})}function gW(){return b.useContext(sW)!=null}function _W(){return oV(gW(),`useLocation() may be used only in the context of a <Router> component.`),b.useContext(sW).location}var vW=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function yW(e){b.useContext(oW).static||b.useLayoutEffect(e)}function bW(){let{isDataRoute:e}=b.useContext(cW);return e?WW():xW()}function xW(){oV(gW(),`useNavigate() may be used only in the context of a <Router> component.`);let e=b.useContext($U),{basename:t,navigator:n}=b.useContext(oW),{matches:r}=b.useContext(cW),{pathname:i}=_W(),a=JSON.stringify(QV(r)),o=b.useRef(!1);return yW(()=>{o.current=!0}),b.useCallback((r,s={})=>{if(sV(o.current,vW),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=$V(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:tH([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var SW=b.createContext(null);function CW(e){let t=b.useContext(cW).outlet;return b.useMemo(()=>t&&b.createElement(SW.Provider,{value:e},t),[t,e])}function wW(){let{matches:e}=b.useContext(cW);return e[e.length-1]?.params??{}}function TW(e,{relative:t}={}){let{matches:n}=b.useContext(cW),{pathname:r}=_W(),i=JSON.stringify(QV(n));return b.useMemo(()=>$V(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function EW(e,t){return DW(e,t)}function DW(e,t,n){oV(gW(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=b.useContext(oW),{matches:i}=b.useContext(cW),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;KW(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
210
210
 
211
- Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=hW(),d;if(t){let e=typeof t==`string`?uV(t):t;iV(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):SV(e,{pathname:p});aV(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),aV(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=MW(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:$V([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:$V([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?b.createElement(aW.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...d},navigationType:`POP`}},h):h}function EW(){let e=VW(),t=aH(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=b.createElement(b.Fragment,null,b.createElement(`p`,null,`💿 Hey developer 👋`),b.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,b.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,b.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),b.createElement(b.Fragment,null,b.createElement(`h2`,null,`Unexpected Application Error!`),b.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?b.createElement(`pre`,{style:i},n):null,o)}var DW=b.createElement(EW,null),OW=class extends b.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=fW(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:b.createElement(oW.Provider,{value:this.props.routeContext},b.createElement(sW.Provider,{value:e,children:this.props.component}));return this.context?b.createElement(AW,{error:e},t):t}};OW.contextType=$U;var kW=new WeakMap;function AW({children:e,error:t}){let{basename:n}=b.useContext(iW);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=dW(t.digest);if(e){let r=kW.get(t);if(r)throw r;let i=cH(e.location,n);if(sH&&!kW.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw kW.set(t,n),n}return b.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function jW({routeContext:e,match:t,children:n}){let r=b.useContext(ZU);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),b.createElement(oW.Provider,{value:e},n)}function MW(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);iV(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},pattern:oH(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||DW,o&&(s<0&&c===0?(WW(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?b.createElement(n.route.Component,null):n.route.element?n.route.element:e,b.createElement(jW,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?b.createElement(OW,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function NW(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function PW(e){let t=b.useContext(ZU);return iV(t,NW(e)),t}function FW(e){let t=b.useContext(QU);return iV(t,NW(e)),t}function IW(e){let t=b.useContext(oW);return iV(t,NW(e)),t}function LW(e){let t=IW(e),n=t.matches[t.matches.length-1];return iV(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function RW(){return LW(`useRouteId`)}function zW(){let e=FW(`useNavigation`);return b.useMemo(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function BW(){let{matches:e,loaderData:t}=FW(`useMatches`);return b.useMemo(()=>e.map(e=>wV(e,t)),[e,t])}function VW(){let e=b.useContext(sW),t=FW(`useRouteError`),n=LW(`useRouteError`);return e===void 0?t.errors?.[n]:e}function HW(){let{router:e}=PW(`useNavigate`),t=LW(`useNavigate`),n=b.useRef(!1);return _W(()=>{n.current=!0}),b.useCallback(async(r,i={})=>{aV(n.current,gW),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var UW={};function WW(e,t,n){!t&&!UW[e]&&(UW[e]=!0,aV(!1,n))}var GW={};function KW(e,t){!e&&!GW[t]&&(GW[t]=!0,console.warn(t))}var qW=b.useOptimistic,JW=()=>void 0;function YW(e){return qW?qW(e):[e,JW]}function XW(e){let t={hasErrorBoundary:e.hasErrorBoundary||e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&(e.element&&aV(!1,"You should not include both `Component` and `element` on your route - `Component` will be used."),Object.assign(t,{element:b.createElement(e.Component),Component:void 0})),e.HydrateFallback&&(e.hydrateFallbackElement&&aV(!1,"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."),Object.assign(t,{hydrateFallbackElement:b.createElement(e.HydrateFallback),HydrateFallback:void 0})),e.ErrorBoundary&&(e.errorElement&&aV(!1,"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."),Object.assign(t,{errorElement:b.createElement(e.ErrorBoundary),ErrorBoundary:void 0})),t}var ZW=[`HydrateFallback`,`hydrateFallbackElement`],QW=class{constructor(){this.status=`pending`,this.promise=new Promise((e,t)=>{this.resolve=t=>{this.status===`pending`&&(this.status=`resolved`,e(t))},this.reject=e=>{this.status===`pending`&&(this.status=`rejected`,t(e))}})}};function $W({router:e,flushSync:t,onError:n,useTransitions:r}){r=eW()||r;let[i,a]=b.useState(e.state),[o,s]=YW(i),[c,l]=b.useState(),[u,d]=b.useState({isTransitioning:!1}),[f,p]=b.useState(),[m,h]=b.useState(),[g,_]=b.useState(),v=b.useRef(new Map),y=b.useCallback((i,{deletedFetchers:o,newErrors:c,flushSync:u,viewTransitionOpts:g})=>{c&&n&&Object.values(c).forEach(e=>n(e,{location:i.location,params:i.matches[0]?.params??{},pattern:oH(i.matches)})),i.fetchers.forEach((e,t)=>{e.data!==void 0&&v.current.set(t,e.data)}),o.forEach(e=>v.current.delete(e)),KW(u===!1||t!=null,'You provided the `flushSync` option to a router update, but you are not using the `<RouterProvider>` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from "react-router/dom"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.');let y=e.window!=null&&e.window.document!=null&&typeof e.window.document.startViewTransition==`function`;if(KW(g==null||y,"You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."),!g||!y){t&&u?t(()=>a(i)):r===!1?a(i):b.startTransition(()=>{r===!0&&s(e=>eG(e,i)),a(i)});return}if(t&&u){t(()=>{m&&(f?.resolve(),m.skipTransition()),d({isTransitioning:!0,flushSync:!0,currentLocation:g.currentLocation,nextLocation:g.nextLocation})});let n=e.window.document.startViewTransition(()=>{t(()=>a(i))});n.finished.finally(()=>{t(()=>{p(void 0),h(void 0),l(void 0),d({isTransitioning:!1})})}),t(()=>h(n));return}m?(f?.resolve(),m.skipTransition(),_({state:i,currentLocation:g.currentLocation,nextLocation:g.nextLocation})):(l(i),d({isTransitioning:!0,flushSync:!1,currentLocation:g.currentLocation,nextLocation:g.nextLocation}))},[e.window,t,m,f,r,s,n]);b.useLayoutEffect(()=>e.subscribe(y),[e,y]),b.useEffect(()=>{u.isTransitioning&&!u.flushSync&&p(new QW)},[u]),b.useEffect(()=>{if(f&&c&&e.window){let t=c,n=f.promise,i=e.window.document.startViewTransition(async()=>{r===!1?a(t):b.startTransition(()=>{r===!0&&s(e=>eG(e,t)),a(t)}),await n});i.finished.finally(()=>{p(void 0),h(void 0),l(void 0),d({isTransitioning:!1})}),h(i)}},[c,f,e.window,r,s]),b.useEffect(()=>{f&&c&&o.location.key===c.location.key&&f.resolve()},[f,m,o.location,c]),b.useEffect(()=>{!u.isTransitioning&&g&&(l(g.state),d({isTransitioning:!0,flushSync:!1,currentLocation:g.currentLocation,nextLocation:g.nextLocation}),_(void 0))},[u.isTransitioning,g]);let x=b.useMemo(()=>({createHref:e.createHref,encodeLocation:e.encodeLocation,go:t=>e.navigate(t),push:(t,n,r)=>e.navigate(t,{state:n,preventScrollReset:r?.preventScrollReset}),replace:(t,n,r)=>e.navigate(t,{replace:!0,state:n,preventScrollReset:r?.preventScrollReset})}),[e]),S=e.basename||`/`,C=b.useMemo(()=>({router:e,navigator:x,static:!1,basename:S,onError:n}),[e,x,S,n]);return b.createElement(b.Fragment,null,b.createElement(ZU.Provider,{value:C},b.createElement(QU.Provider,{value:o},b.createElement(nW.Provider,{value:v.current},b.createElement(tW.Provider,{value:u},b.createElement(aG,{basename:S,location:o.location,navigationType:o.historyAction,navigator:x,useTransitions:r},b.createElement(tG,{routes:e.routes,manifest:e.manifest,future:e.future,state:o,isStatic:!1,onError:n})))))),null)}function eG(e,t){return{...e,navigation:t.navigation.state===`idle`?e.navigation:t.navigation,revalidation:t.revalidation===`idle`?e.revalidation:t.revalidation,actionData:t.navigation.state===`submitting`?e.actionData:t.actionData,fetchers:t.fetchers}}var tG=b.memo(nG);function nG({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return TW(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function rG({to:e,replace:t,state:n,relative:r}){iV(mW(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=b.useContext(iW);aV(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=b.useContext(oW),{pathname:o}=hW(),s=vW(),c=ZV(e,XV(a),o,r===`path`),l=JSON.stringify(c);return b.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function iG(e){return xW(e.context)}function $(e){iV(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function aG({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,useTransitions:o}){iV(!mW(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=b.useMemo(()=>({basename:s,navigator:i,static:a,useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=uV(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,mask:m}=n,h=b.useMemo(()=>{let e=HV(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return aV(h!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),h==null?null:b.createElement(iW.Provider,{value:c},b.createElement(aW.Provider,{children:t,value:h}))}function oG({children:e,location:t}){return wW(sG(e),t)}b.Component;function sG(e,t=[]){let n=[];return b.Children.forEach(e,(e,r)=>{if(!b.isValidElement(e))return;let i=[...t,r];if(e.type===b.Fragment){n.push.apply(n,sG(e.props.children,i));return}iV(e.type===$,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),iV(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=sG(e.props.children,i)),n.push(a)}),n}var cG=`get`,lG=`application/x-www-form-urlencoded`;function uG(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function dG(e){return uG(e)&&e.tagName.toLowerCase()===`button`}function fG(e){return uG(e)&&e.tagName.toLowerCase()===`form`}function pG(e){return uG(e)&&e.tagName.toLowerCase()===`input`}function mG(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function hG(e,t){return e.button===0&&(!t||t===`_self`)&&!mG(e)}function gG(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function _G(e,t){let n=gG(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var vG=null;function yG(){if(vG===null)try{new FormData(document.createElement(`form`),0),vG=!1}catch{vG=!0}return vG}var bG=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function xG(e){return e!=null&&!bG.has(e)?(aV(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${lG}"`),null):e}function SG(e,t){let n,r,i,a,o;if(fG(e)){let o=e.getAttribute(`action`);r=o?HV(o,t):null,n=e.getAttribute(`method`)||cG,i=xG(e.getAttribute(`enctype`))||lG,a=new FormData(e)}else if(dG(e)||pG(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?HV(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||cG,i=xG(e.getAttribute(`formenctype`))||xG(o.getAttribute(`enctype`))||lG,a=new FormData(o,e),!yG()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(uG(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=cG,r=null,i=lG,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var CG={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},wG=/[&><\u2028\u2029]/g;function TG(e){return e.replace(wG,e=>CG[e])}function EG(e,t){if(e===!1||e==null)throw Error(t)}function DG(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&HV(i.pathname,t)===`/`?i.pathname=`${eH(t)}/_root.${r}`:i.pathname=`${eH(i.pathname)}.${r}`,i}async function OG(e,t){if(e.id in t)return t[e.id];try{let n=await YB(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function kG(e){return e!=null&&typeof e.page==`string`}function AG(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function jG(e,t,n){return IG((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await OG(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(AG).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function MG(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function NG(e,t,{includeHydrateFallback:n}={}){return PG(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function PG(e){return[...new Set(e)]}function FG(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function IG(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!kG(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(FG(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function LG(){let e=b.useContext(ZU);return EG(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function RG(){let e=b.useContext(QU);return EG(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var zG=b.createContext(void 0);zG.displayName=`FrameworkContext`;function BG(){let e=b.useContext(zG);return EG(e,`You must render this element inside a <HydratedRouter> element`),e}function VG(e,t){let n=b.useContext(zG),[r,i]=b.useState(!1),[a,o]=b.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=b.useRef(null);b.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),b.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:HG(s,p),onBlur:HG(c,m),onMouseEnter:HG(l,p),onMouseLeave:HG(u,m),onTouchStart:HG(d,p)}]:[a,f,{}]:[!1,f,{}]}function HG(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function UG({page:e,...t}){let n=eW(),{router:r}=LG(),i=b.useMemo(()=>SV(r.routes,e,r.basename),[r.routes,e,r.basename]);return i?n?b.createElement(GG,{page:e,matches:i,...t}):b.createElement(KG,{page:e,matches:i,...t}):null}function WG(e){let{manifest:t,routeModules:n}=BG(),[r,i]=b.useState([]);return b.useEffect(()=>{let r=!1;return jG(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function GG({page:e,matches:t,...n}){let r=hW(),{future:i}=BG(),{basename:a}=LG(),o=b.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=DG(e,a,i.v8_trailingSlashAwareDataRequests,`rsc`),o=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?o=!0:s.push(e.route.id);return o&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[a,i.v8_trailingSlashAwareDataRequests,e,r,t]);return b.createElement(b.Fragment,null,o.map(e=>b.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function KG({page:e,matches:t,...n}){let r=hW(),{future:i,manifest:a,routeModules:o}=BG(),{basename:s}=LG(),{loaderData:c,matches:l}=RG(),u=b.useMemo(()=>MG(e,t,l,a,r,`data`),[e,t,l,a,r]),d=b.useMemo(()=>MG(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=b.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=DG(e,s,i.v8_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.v8_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=b.useMemo(()=>NG(d,a),[d,a]),m=WG(d);return b.createElement(b.Fragment,null,f.map(e=>b.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>b.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>b.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function qG(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}b.Component;var JG=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{JG&&(window.__reactRouterVersion=`7.17.0`)}catch{}function YG(e,t){return LH({basename:t?.basename,getContext:t?.getContext,future:t?.future,history:rV({window:t?.window}),hydrationData:t?.hydrationData||XG(),routes:e,mapRouteProperties:XW,hydrationRouteProperties:ZW,dataStrategy:t?.dataStrategy,patchRoutesOnNavigation:t?.patchRoutesOnNavigation,window:t?.window,instrumentations:t?.instrumentations}).initialize()}function XG(){let e=window?.__staticRouterHydrationData;return e&&e.errors&&(e={...e,errors:ZG(e.errors)}),e}function ZG(e){if(!e)return null;let t=Object.entries(e),n={};for(let[e,r]of t)if(r&&r.__type===`RouteErrorResponse`)n[e]=new iH(r.status,r.statusText,r.data,r.internal===!0);else if(r&&r.__type===`Error`){if(r.__subType){let t=window[r.__subType];if(typeof t==`function`)try{let i=new t(r.message);i.stack=``,n[e]=i}catch{}}if(n[e]==null){let t=Error(r.message);t.stack=``,n[e]=t}}else n[e]=r;return n}function QG({basename:e,children:t,history:n,useTransitions:r}){let[i,a]=b.useState({action:n.action,location:n.location}),o=b.useCallback(e=>{r===!1?a(e):b.startTransition(()=>a(e))},[r]);return b.useLayoutEffect(()=>n.listen(o),[n,o]),b.createElement(aG,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,useTransitions:r})}QG.displayName=`unstable_HistoryRouter`;var $G=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,eK=b.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m){let{basename:h,navigator:g,useTransitions:_}=b.useContext(iW),v=typeof l==`string`&&$G.test(l),y=cH(l,h);l=y.to;let x=pW(l,{relative:r}),S=hW(),C=null;if(o){let e=ZV(o,[],S.mask?S.mask.pathname:`/`,!0);h!==`/`&&(e.pathname=e.pathname===`/`?h:$V([h,e.pathname])),C=g.createHref(e)}let[w,T,E]=VG(n,p),D=sK(l,{replace:a,mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,defaultShouldRevalidate:f,useTransitions:_});function O(t){e&&e(t),t.defaultPrevented||D(t)}let k=!(y.isExternal||i),A=b.createElement(`a`,{...p,...E,href:(k?C:void 0)||y.absoluteURL||x,onClick:k?O:e,ref:qG(m,T),target:c,"data-discover":!v&&t===`render`?`true`:void 0});return w&&!v?b.createElement(b.Fragment,null,A,b.createElement(UG,{page:x})):A});eK.displayName=`Link`;var tK=b.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=CW(a,{relative:c.relative}),d=hW(),f=b.useContext(QU),{navigator:p,basename:m}=b.useContext(iW),h=f!=null&&vK(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=HV(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,x=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,S=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),C={isActive:x,isPending:S,isTransitioning:h},w=x?e:void 0,T;T=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let E=typeof i==`function`?i(C):i;return b.createElement(eK,{...c,"aria-current":w,className:T,ref:l,style:E,to:a,viewTransition:o},typeof s==`function`?s(C):s)});tK.displayName=`NavLink`;var nK=b.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=cG,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m)=>{let{useTransitions:h}=b.useContext(iW),g=dK(),_=fK(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&$G.test(s);return b.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f});h&&n!==!1?b.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});nK.displayName=`Form`;function rK({getKey:e,storageKey:t,...n}){let r=b.useContext(zG),{basename:i}=b.useContext(iW),a=hW(),o=BW();gK({getKey:e,storageKey:t});let s=b.useMemo(()=>{if(!r||!e)return null;let t=hK(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return b.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${TG(JSON.stringify(t||pK))}, ${TG(JSON.stringify(s))})`}})}rK.displayName=`ScrollRestoration`;function iK(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function aK(e){let t=b.useContext(ZU);return iV(t,iK(e)),t}function oK(e){let t=b.useContext(QU);return iV(t,iK(e)),t}function sK(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:l}={}){let u=vW(),d=hW(),f=CW(e,{relative:o});return b.useCallback(p=>{if(hG(p,t)){p.preventDefault();let t=n===void 0?lV(d)===lV(f):n,m=()=>u(e,{replace:t,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c});l?b.startTransition(()=>m()):m()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}function cK(e){aV(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=b.useRef(gG(e)),n=b.useRef(!1),r=hW(),i=b.useMemo(()=>_G(r.search,n.current?null:t.current),[r.search]),a=vW();return[i,b.useCallback((e,t)=>{let r=gG(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var lK=0,uK=()=>`__${String(++lK)}__`;function dK(){let{router:e}=aK(`useSubmit`),{basename:t}=b.useContext(iW),n=RW(),r=e.fetch,i=e.navigate;return b.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=SG(e,t);a.navigate===!1?await r(a.fetcherKey||uK(),n,a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function fK(e,{relative:t}={}){let{basename:n}=b.useContext(iW),r=b.useContext(oW);iV(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...CW(e||`.`,{relative:t})},o=hW();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:$V([n,a.pathname])),lV(a)}var pK=`react-router-scroll-positions`,mK={};function hK(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:HV(e.pathname,n)||e.pathname},t)),i??=e.key,i}function gK({getKey:e,storageKey:t}={}){let{router:n}=aK(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=oK(`useScrollRestoration`),{basename:a}=b.useContext(iW),o=hW(),s=BW(),c=zW();b.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),_K(b.useCallback(()=>{if(c.state===`idle`){let t=hK(o,s,a,e);mK[t]=window.scrollY}try{sessionStorage.setItem(t||pK,JSON.stringify(mK))}catch(e){aV(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(b.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||pK);e&&(mK=JSON.parse(e))}catch{}},[t]),b.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(mK,()=>window.scrollY,e?(t,n)=>hK(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),b.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{aV(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function _K(e,t){let{capture:n}=t||{};b.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function vK(e,{relative:t}={}){let n=b.useContext(tW);iV(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=aK(`useViewTransitionState`),i=CW(e,{relative:t});if(!n.isTransitioning)return!1;let a=HV(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=HV(n.nextLocation.pathname,r)||n.nextLocation.pathname;return zV(i.pathname,o)!=null||zV(i.pathname,a)!=null}function yK(){let{pathname:e}=hW();return(0,b.useEffect)(()=>{window.scrollTo(0,0)},[e]),null}function bK(e){let{serviceRequest:t,...n}=e;return(0,I.jsx)(qL,{value:t,loadTimelineResources:async(e,t,n)=>{let r=`${t}/${n}`;return Promise.allSettled([e.readHistory(`ServiceRequest`,n),e.search(`Communication`,{"based-on":r,_count:100}),e.search(`DiagnosticReport`,{"based-on":r,_count:100}),e.search(`Media`,{"based-on":r,_count:100}),e.search(`DocumentReference`,{related:r,_count:100}),e.search(`Task`,{_filter:`based-on eq ${r} or focus eq ${r} or subject eq ${r}`,_count:100})])},createCommunication:(e,t,n)=>({resourceType:`Communication`,status:`completed`,basedOn:[aC(e)],subject:e.subject,sender:aC(t),sent:new Date().toISOString(),payload:[{contentString:n}]}),createMedia:(e,t,n)=>({resourceType:`Media`,status:`completed`,basedOn:[aC(e)],subject:e.subject,operator:aC(t),issued:new Date().toISOString(),content:n}),...n})}function xK(e){let t=Z(),{client:n,patient:r,encounter:i,children:a,...o}=e,s=nk(r),c=nk(i);function l(){let a=r,o=i;if(n.launchIdentifierSystems?.length){let e=n.launchIdentifierSystems.find(e=>e.resourceType===`Patient`);if(a&&s&&e?.system){let t=s.identifier?.find(t=>t.system===e.system);t&&(a={...r,identifier:t})}let t=n.launchIdentifierSystems.find(e=>e.resourceType===`Encounter`);if(o&&c&&t?.system){let e=c.identifier?.find(e=>e.system===t.system);e&&(o={...i,identifier:e})}}t.createResource({resourceType:`SmartAppLaunch`,patient:a,encounter:o,fhirContext:e.fhirContext}).then(e=>{let r=new URL(n.launchUri);r.searchParams.set(`iss`,QC(t.fhirUrl().toString())),r.searchParams.set(`launch`,e.id),window.open(r.toString(),`_blank`)}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}return(0,I.jsx)(Pd,{onClick:()=>l(),...o,children:a})}var SK=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),CK=o(((e,t)=>{t.exports=SK()})),wK=o((e=>{var t=CK(),n=m(),r=Zi();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.memo_cache_sentinel`),k=Symbol.iterator;function A(e){return typeof e!=`object`||!e?null:(e=k&&e[k]||e[`@@iterator`],typeof e==`function`?e:null)}var j=Symbol.for(`react.client.reference`);function M(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return t=e.displayName||null,t===null?M(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return M(e(t))}catch{}}return null}var ee=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te={pending:!1,data:null,method:null,action:null},ne=[],re=-1;function ie(e){return{current:e}}function ae(e){0>re||(e.current=ne[re],ne[re]=null,re--)}function oe(e,t){re++,ne[re]=e.current,e.current=t}var se=ie(null),ce=ie(null),le=ie(null),ue=ie(null);function de(e,t){switch(oe(le,t),oe(ce,e),oe(se,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Zd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Zd(t),e=Qd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ae(se),oe(se,e)}function fe(){ae(se),ae(ce),ae(le)}function pe(e){e.memoizedState!==null&&oe(ue,e);var t=se.current,n=Qd(t,e.type);t!==n&&(oe(ce,e),oe(se,n))}function me(e){ce.current===e&&(ae(se),ae(ce)),ue.current===e&&(ae(ue),cp._currentValue=te)}var he,ge;function _e(e){if(he===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);he=t&&t[1]||``,ge=-1<e.stack.indexOf(`
211
+ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=_W(),d;if(t){let e=typeof t==`string`?fV(t):t;oV(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):wV(e,{pathname:p});sV(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),sV(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=PW(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:tH([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:tH([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?b.createElement(sW.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...d},navigationType:`POP`}},h):h}function OW(){let e=UW(),t=sH(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=b.createElement(b.Fragment,null,b.createElement(`p`,null,`💿 Hey developer 👋`),b.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,b.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,b.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),b.createElement(b.Fragment,null,b.createElement(`h2`,null,`Unexpected Application Error!`),b.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?b.createElement(`pre`,{style:i},n):null,o)}var kW=b.createElement(OW,null),AW=class extends b.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=mW(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:b.createElement(cW.Provider,{value:this.props.routeContext},b.createElement(lW.Provider,{value:e,children:this.props.component}));return this.context?b.createElement(MW,{error:e},t):t}};AW.contextType=tW;var jW=new WeakMap;function MW({children:e,error:t}){let{basename:n}=b.useContext(oW);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=pW(t.digest);if(e){let r=jW.get(t);if(r)throw r;let i=uH(e.location,n);if(lH&&!jW.get(t))if(i.isExternal||e.reloadDocument)window.location.href=i.absoluteURL||i.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw jW.set(t,n),n}return b.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${i.absoluteURL||i.to}`})}}return e}function NW({routeContext:e,match:t,children:n}){let r=b.useContext($U);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),b.createElement(cW.Provider,{value:e},n)}function PW(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);oV(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},pattern:cH(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||kW,o&&(s<0&&c===0?(KW(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?b.createElement(n.route.Component,null):n.route.element?n.route.element:e,b.createElement(NW,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?b.createElement(AW,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function FW(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function IW(e){let t=b.useContext($U);return oV(t,FW(e)),t}function LW(e){let t=b.useContext(eW);return oV(t,FW(e)),t}function RW(e){let t=b.useContext(cW);return oV(t,FW(e)),t}function zW(e){let t=RW(e),n=t.matches[t.matches.length-1];return oV(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function BW(){return zW(`useRouteId`)}function VW(){let e=LW(`useNavigation`);return b.useMemo(()=>{let{matches:t,historyAction:n,...r}=e.navigation;return r},[e.navigation])}function HW(){let{matches:e,loaderData:t}=LW(`useMatches`);return b.useMemo(()=>e.map(e=>EV(e,t)),[e,t])}function UW(){let e=b.useContext(lW),t=LW(`useRouteError`),n=zW(`useRouteError`);return e===void 0?t.errors?.[n]:e}function WW(){let{router:e}=IW(`useNavigate`),t=zW(`useNavigate`),n=b.useRef(!1);return yW(()=>{n.current=!0}),b.useCallback(async(r,i={})=>{sV(n.current,vW),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var GW={};function KW(e,t,n){!t&&!GW[e]&&(GW[e]=!0,sV(!1,n))}var qW={};function JW(e,t){!e&&!qW[t]&&(qW[t]=!0,console.warn(t))}var YW=b.useOptimistic,XW=()=>void 0;function ZW(e){return YW?YW(e):[e,XW]}function QW(e){let t={hasErrorBoundary:e.hasErrorBoundary||e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&(e.element&&sV(!1,"You should not include both `Component` and `element` on your route - `Component` will be used."),Object.assign(t,{element:b.createElement(e.Component),Component:void 0})),e.HydrateFallback&&(e.hydrateFallbackElement&&sV(!1,"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."),Object.assign(t,{hydrateFallbackElement:b.createElement(e.HydrateFallback),HydrateFallback:void 0})),e.ErrorBoundary&&(e.errorElement&&sV(!1,"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."),Object.assign(t,{errorElement:b.createElement(e.ErrorBoundary),ErrorBoundary:void 0})),t}var $W=[`HydrateFallback`,`hydrateFallbackElement`],eG=class{constructor(){this.status=`pending`,this.promise=new Promise((e,t)=>{this.resolve=t=>{this.status===`pending`&&(this.status=`resolved`,e(t))},this.reject=e=>{this.status===`pending`&&(this.status=`rejected`,t(e))}})}};function tG({router:e,flushSync:t,onError:n,useTransitions:r}){r=nW()||r;let[i,a]=b.useState(e.state),[o,s]=ZW(i),[c,l]=b.useState(),[u,d]=b.useState({isTransitioning:!1}),[f,p]=b.useState(),[m,h]=b.useState(),[g,_]=b.useState(),v=b.useRef(new Map),y=b.useCallback((i,{deletedFetchers:o,newErrors:c,flushSync:u,viewTransitionOpts:g})=>{c&&n&&Object.values(c).forEach(e=>n(e,{location:i.location,params:i.matches[0]?.params??{},pattern:cH(i.matches)})),i.fetchers.forEach((e,t)=>{e.data!==void 0&&v.current.set(t,e.data)}),o.forEach(e=>v.current.delete(e)),JW(u===!1||t!=null,'You provided the `flushSync` option to a router update, but you are not using the `<RouterProvider>` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from "react-router/dom"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.');let y=e.window!=null&&e.window.document!=null&&typeof e.window.document.startViewTransition==`function`;if(JW(g==null||y,"You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."),!g||!y){t&&u?t(()=>a(i)):r===!1?a(i):b.startTransition(()=>{r===!0&&s(e=>nG(e,i)),a(i)});return}if(t&&u){t(()=>{m&&(f?.resolve(),m.skipTransition()),d({isTransitioning:!0,flushSync:!0,currentLocation:g.currentLocation,nextLocation:g.nextLocation})});let n=e.window.document.startViewTransition(()=>{t(()=>a(i))});n.finished.finally(()=>{t(()=>{p(void 0),h(void 0),l(void 0),d({isTransitioning:!1})})}),t(()=>h(n));return}m?(f?.resolve(),m.skipTransition(),_({state:i,currentLocation:g.currentLocation,nextLocation:g.nextLocation})):(l(i),d({isTransitioning:!0,flushSync:!1,currentLocation:g.currentLocation,nextLocation:g.nextLocation}))},[e.window,t,m,f,r,s,n]);b.useLayoutEffect(()=>e.subscribe(y),[e,y]),b.useEffect(()=>{u.isTransitioning&&!u.flushSync&&p(new eG)},[u]),b.useEffect(()=>{if(f&&c&&e.window){let t=c,n=f.promise,i=e.window.document.startViewTransition(async()=>{r===!1?a(t):b.startTransition(()=>{r===!0&&s(e=>nG(e,t)),a(t)}),await n});i.finished.finally(()=>{p(void 0),h(void 0),l(void 0),d({isTransitioning:!1})}),h(i)}},[c,f,e.window,r,s]),b.useEffect(()=>{f&&c&&o.location.key===c.location.key&&f.resolve()},[f,m,o.location,c]),b.useEffect(()=>{!u.isTransitioning&&g&&(l(g.state),d({isTransitioning:!0,flushSync:!1,currentLocation:g.currentLocation,nextLocation:g.nextLocation}),_(void 0))},[u.isTransitioning,g]);let x=b.useMemo(()=>({createHref:e.createHref,encodeLocation:e.encodeLocation,go:t=>e.navigate(t),push:(t,n,r)=>e.navigate(t,{state:n,preventScrollReset:r?.preventScrollReset}),replace:(t,n,r)=>e.navigate(t,{replace:!0,state:n,preventScrollReset:r?.preventScrollReset})}),[e]),S=e.basename||`/`,C=b.useMemo(()=>({router:e,navigator:x,static:!1,basename:S,onError:n}),[e,x,S,n]);return b.createElement(b.Fragment,null,b.createElement($U.Provider,{value:C},b.createElement(eW.Provider,{value:o},b.createElement(iW.Provider,{value:v.current},b.createElement(rW.Provider,{value:u},b.createElement(sG,{basename:S,location:o.location,navigationType:o.historyAction,navigator:x,useTransitions:r},b.createElement(rG,{routes:e.routes,manifest:e.manifest,future:e.future,state:o,isStatic:!1,onError:n})))))),null)}function nG(e,t){return{...e,navigation:t.navigation.state===`idle`?e.navigation:t.navigation,revalidation:t.revalidation===`idle`?e.revalidation:t.revalidation,actionData:t.navigation.state===`submitting`?e.actionData:t.actionData,fetchers:t.fetchers}}var rG=b.memo(iG);function iG({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return DW(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function aG({to:e,replace:t,state:n,relative:r}){oV(gW(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:i}=b.useContext(oW);sV(!i,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:a}=b.useContext(cW),{pathname:o}=_W(),s=bW(),c=$V(e,QV(a),o,r===`path`),l=JSON.stringify(c);return b.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function oG(e){return CW(e.context)}function $(e){oV(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function sG({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,useTransitions:o}){oV(!gW(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=b.useMemo(()=>({basename:s,navigator:i,static:a,useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=fV(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,mask:m}=n,h=b.useMemo(()=>{let e=WV(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return sV(h!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),h==null?null:b.createElement(oW.Provider,{value:c},b.createElement(sW.Provider,{children:t,value:h}))}function cG({children:e,location:t}){return EW(lG(e),t)}b.Component;function lG(e,t=[]){let n=[];return b.Children.forEach(e,(e,r)=>{if(!b.isValidElement(e))return;let i=[...t,r];if(e.type===b.Fragment){n.push.apply(n,lG(e.props.children,i));return}oV(e.type===$,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),oV(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=lG(e.props.children,i)),n.push(a)}),n}var uG=`get`,dG=`application/x-www-form-urlencoded`;function fG(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function pG(e){return fG(e)&&e.tagName.toLowerCase()===`button`}function mG(e){return fG(e)&&e.tagName.toLowerCase()===`form`}function hG(e){return fG(e)&&e.tagName.toLowerCase()===`input`}function gG(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function _G(e,t){return e.button===0&&(!t||t===`_self`)&&!gG(e)}function vG(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function yG(e,t){let n=vG(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var bG=null;function xG(){if(bG===null)try{new FormData(document.createElement(`form`),0),bG=!1}catch{bG=!0}return bG}var SG=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function CG(e){return e!=null&&!SG.has(e)?(sV(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${dG}"`),null):e}function wG(e,t){let n,r,i,a,o;if(mG(e)){let o=e.getAttribute(`action`);r=o?WV(o,t):null,n=e.getAttribute(`method`)||uG,i=CG(e.getAttribute(`enctype`))||dG,a=new FormData(e)}else if(pG(e)||hG(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?WV(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||uG,i=CG(e.getAttribute(`formenctype`))||CG(o.getAttribute(`enctype`))||dG,a=new FormData(o,e),!xG()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(fG(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=uG,r=null,i=dG,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var TG={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},EG=/[&><\u2028\u2029]/g;function DG(e){return e.replace(EG,e=>TG[e])}function OG(e,t){if(e===!1||e==null)throw Error(t)}function kG(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&WV(i.pathname,t)===`/`?i.pathname=`${nH(t)}/_root.${r}`:i.pathname=`${nH(i.pathname)}.${r}`,i}async function AG(e,t){if(e.id in t)return t[e.id];try{let n=await ZB(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function jG(e){return e!=null&&typeof e.page==`string`}function MG(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function NG(e,t,n){return RG((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await AG(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(MG).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function PG(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function FG(e,t,{includeHydrateFallback:n}={}){return IG(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function IG(e){return[...new Set(e)]}function LG(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function RG(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!jG(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(LG(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function zG(){let e=b.useContext($U);return OG(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function BG(){let e=b.useContext(eW);return OG(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var VG=b.createContext(void 0);VG.displayName=`FrameworkContext`;function HG(){let e=b.useContext(VG);return OG(e,`You must render this element inside a <HydratedRouter> element`),e}function UG(e,t){let n=b.useContext(VG),[r,i]=b.useState(!1),[a,o]=b.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=b.useRef(null);b.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),b.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:WG(s,p),onBlur:WG(c,m),onMouseEnter:WG(l,p),onMouseLeave:WG(u,m),onTouchStart:WG(d,p)}]:[a,f,{}]:[!1,f,{}]}function WG(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function GG({page:e,...t}){let n=nW(),{router:r}=zG(),i=b.useMemo(()=>wV(r.routes,e,r.basename),[r.routes,e,r.basename]);return i?n?b.createElement(qG,{page:e,matches:i,...t}):b.createElement(JG,{page:e,matches:i,...t}):null}function KG(e){let{manifest:t,routeModules:n}=HG(),[r,i]=b.useState([]);return b.useEffect(()=>{let r=!1;return NG(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function qG({page:e,matches:t,...n}){let r=_W(),{future:i}=HG(),{basename:a}=zG(),o=b.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=kG(e,a,i.v8_trailingSlashAwareDataRequests,`rsc`),o=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?o=!0:s.push(e.route.id);return o&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[a,i.v8_trailingSlashAwareDataRequests,e,r,t]);return b.createElement(b.Fragment,null,o.map(e=>b.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function JG({page:e,matches:t,...n}){let r=_W(),{future:i,manifest:a,routeModules:o}=HG(),{basename:s}=zG(),{loaderData:c,matches:l}=BG(),u=b.useMemo(()=>PG(e,t,l,a,r,`data`),[e,t,l,a,r]),d=b.useMemo(()=>PG(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=b.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=kG(e,s,i.v8_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.v8_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=b.useMemo(()=>FG(d,a),[d,a]),m=KG(d);return b.createElement(b.Fragment,null,f.map(e=>b.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>b.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>b.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function YG(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}b.Component;var XG=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{XG&&(window.__reactRouterVersion=`7.17.0`)}catch{}function ZG(e,t){return zH({basename:t?.basename,getContext:t?.getContext,future:t?.future,history:aV({window:t?.window}),hydrationData:t?.hydrationData||QG(),routes:e,mapRouteProperties:QW,hydrationRouteProperties:$W,dataStrategy:t?.dataStrategy,patchRoutesOnNavigation:t?.patchRoutesOnNavigation,window:t?.window,instrumentations:t?.instrumentations}).initialize()}function QG(){let e=window?.__staticRouterHydrationData;return e&&e.errors&&(e={...e,errors:$G(e.errors)}),e}function $G(e){if(!e)return null;let t=Object.entries(e),n={};for(let[e,r]of t)if(r&&r.__type===`RouteErrorResponse`)n[e]=new oH(r.status,r.statusText,r.data,r.internal===!0);else if(r&&r.__type===`Error`){if(r.__subType){let t=window[r.__subType];if(typeof t==`function`)try{let i=new t(r.message);i.stack=``,n[e]=i}catch{}}if(n[e]==null){let t=Error(r.message);t.stack=``,n[e]=t}}else n[e]=r;return n}function eK({basename:e,children:t,history:n,useTransitions:r}){let[i,a]=b.useState({action:n.action,location:n.location}),o=b.useCallback(e=>{r===!1?a(e):b.startTransition(()=>a(e))},[r]);return b.useLayoutEffect(()=>n.listen(o),[n,o]),b.createElement(sG,{basename:e,children:t,location:i.location,navigationType:i.action,navigator:n,useTransitions:r})}eK.displayName=`unstable_HistoryRouter`;var tK=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,nK=b.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m){let{basename:h,navigator:g,useTransitions:_}=b.useContext(oW),v=typeof l==`string`&&tK.test(l),y=uH(l,h);l=y.to;let x=hW(l,{relative:r}),S=_W(),C=null;if(o){let e=$V(o,[],S.mask?S.mask.pathname:`/`,!0);h!==`/`&&(e.pathname=e.pathname===`/`?h:tH([h,e.pathname])),C=g.createHref(e)}let[w,T,E]=UG(n,p),D=lK(l,{replace:a,mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,defaultShouldRevalidate:f,useTransitions:_});function O(t){e&&e(t),t.defaultPrevented||D(t)}let k=!(y.isExternal||i),A=b.createElement(`a`,{...p,...E,href:(k?C:void 0)||y.absoluteURL||x,onClick:k?O:e,ref:YG(m,T),target:c,"data-discover":!v&&t===`render`?`true`:void 0});return w&&!v?b.createElement(b.Fragment,null,A,b.createElement(GG,{page:x})):A});nK.displayName=`Link`;var rK=b.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=TW(a,{relative:c.relative}),d=_W(),f=b.useContext(eW),{navigator:p,basename:m}=b.useContext(oW),h=f!=null&&bK(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=WV(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,x=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,S=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),C={isActive:x,isPending:S,isTransitioning:h},w=x?e:void 0,T;T=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let E=typeof i==`function`?i(C):i;return b.createElement(nK,{...c,"aria-current":w,className:T,ref:l,style:E,to:a,viewTransition:o},typeof s==`function`?s(C):s)});rK.displayName=`NavLink`;var iK=b.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=uG,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m)=>{let{useTransitions:h}=b.useContext(oW),g=pK(),_=mK(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&tK.test(s);return b.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f});h&&n!==!1?b.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});iK.displayName=`Form`;function aK({getKey:e,storageKey:t,...n}){let r=b.useContext(VG),{basename:i}=b.useContext(oW),a=_W(),o=HW();vK({getKey:e,storageKey:t});let s=b.useMemo(()=>{if(!r||!e)return null;let t=_K(a,o,i,e);return t===a.key?null:t},[]);if(!r||r.isSpaMode)return null;let c=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return b.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${c})(${DG(JSON.stringify(t||hK))}, ${DG(JSON.stringify(s))})`}})}aK.displayName=`ScrollRestoration`;function oK(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function sK(e){let t=b.useContext($U);return oV(t,oK(e)),t}function cK(e){let t=b.useContext(eW);return oV(t,oK(e)),t}function lK(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:l}={}){let u=bW(),d=_W(),f=TW(e,{relative:o});return b.useCallback(p=>{if(_G(p,t)){p.preventDefault();let t=n===void 0?dV(d)===dV(f):n,m=()=>u(e,{replace:t,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c});l?b.startTransition(()=>m()):m()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}function uK(e){sV(typeof URLSearchParams<`u`,"You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=b.useRef(vG(e)),n=b.useRef(!1),r=_W(),i=b.useMemo(()=>yG(r.search,n.current?null:t.current),[r.search]),a=bW();return[i,b.useCallback((e,t)=>{let r=vG(typeof e==`function`?e(new URLSearchParams(i)):e);n.current=!0,a(`?`+r,t)},[a,i])]}var dK=0,fK=()=>`__${String(++dK)}__`;function pK(){let{router:e}=sK(`useSubmit`),{basename:t}=b.useContext(oW),n=BW(),r=e.fetch,i=e.navigate;return b.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=wG(e,t);a.navigate===!1?await r(a.fetcherKey||fK(),n,a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync}):await i(a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function mK(e,{relative:t}={}){let{basename:n}=b.useContext(oW),r=b.useContext(cW);oV(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...TW(e||`.`,{relative:t})},o=_W();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:tH([n,a.pathname])),dV(a)}var hK=`react-router-scroll-positions`,gK={};function _K(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:WV(e.pathname,n)||e.pathname},t)),i??=e.key,i}function vK({getKey:e,storageKey:t}={}){let{router:n}=sK(`useScrollRestoration`),{restoreScrollPosition:r,preventScrollReset:i}=cK(`useScrollRestoration`),{basename:a}=b.useContext(oW),o=_W(),s=HW(),c=VW();b.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),yK(b.useCallback(()=>{if(c.state===`idle`){let t=_K(o,s,a,e);gK[t]=window.scrollY}try{sessionStorage.setItem(t||hK,JSON.stringify(gK))}catch(e){sV(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[c.state,e,a,o,s,t])),typeof document<`u`&&(b.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||hK);e&&(gK=JSON.parse(e))}catch{}},[t]),b.useLayoutEffect(()=>{let t=n?.enableScrollRestoration(gK,()=>window.scrollY,e?(t,n)=>_K(t,n,a,e):void 0);return()=>t&&t()},[n,a,e]),b.useLayoutEffect(()=>{if(r!==!1){if(typeof r==`number`){window.scrollTo(0,r);return}try{if(o.hash){let e=document.getElementById(decodeURIComponent(o.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{sV(!1,`"${o.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}i!==!0&&window.scrollTo(0,0)}},[o,r,i]))}function yK(e,t){let{capture:n}=t||{};b.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function bK(e,{relative:t}={}){let n=b.useContext(rW);oV(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=sK(`useViewTransitionState`),i=TW(e,{relative:t});if(!n.isTransitioning)return!1;let a=WV(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=WV(n.nextLocation.pathname,r)||n.nextLocation.pathname;return VV(i.pathname,o)!=null||VV(i.pathname,a)!=null}function xK(){let{pathname:e}=_W();return(0,b.useEffect)(()=>{window.scrollTo(0,0)},[e]),null}function SK(e){let{serviceRequest:t,...n}=e;return(0,I.jsx)(YL,{value:t,loadTimelineResources:async(e,t,n)=>{let r=`${t}/${n}`;return Promise.allSettled([e.readHistory(`ServiceRequest`,n),e.search(`Communication`,{"based-on":r,_count:100}),e.search(`DiagnosticReport`,{"based-on":r,_count:100}),e.search(`Media`,{"based-on":r,_count:100}),e.search(`DocumentReference`,{related:r,_count:100}),e.search(`Task`,{_filter:`based-on eq ${r} or focus eq ${r} or subject eq ${r}`,_count:100})])},createCommunication:(e,t,n)=>({resourceType:`Communication`,status:`completed`,basedOn:[aC(e)],subject:e.subject,sender:aC(t),sent:new Date().toISOString(),payload:[{contentString:n}]}),createMedia:(e,t,n)=>({resourceType:`Media`,status:`completed`,basedOn:[aC(e)],subject:e.subject,operator:aC(t),issued:new Date().toISOString(),content:n}),...n})}function CK(e){let t=Z(),{client:n,patient:r,encounter:i,children:a,...o}=e,s=ik(r),c=ik(i);function l(){let a=r,o=i;if(n.launchIdentifierSystems?.length){let e=n.launchIdentifierSystems.find(e=>e.resourceType===`Patient`);if(a&&s&&e?.system){let t=s.identifier?.find(t=>t.system===e.system);t&&(a={...r,identifier:t})}let t=n.launchIdentifierSystems.find(e=>e.resourceType===`Encounter`);if(o&&c&&t?.system){let e=c.identifier?.find(e=>e.system===t.system);e&&(o={...i,identifier:e})}}t.createResource({resourceType:`SmartAppLaunch`,patient:a,encounter:o,fhirContext:e.fhirContext}).then(e=>{let r=new URL(n.launchUri);r.searchParams.set(`iss`,QC(t.fhirUrl().toString())),r.searchParams.set(`launch`,e.id),window.open(r.toString(),`_blank`)}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}return(0,I.jsx)(Pd,{onClick:()=>l(),...o,children:a})}var wK=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),TK=o(((e,t)=>{t.exports=wK()})),EK=o((e=>{var t=TK(),n=m(),r=Zi();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}var f=Object.assign,p=Symbol.for(`react.element`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.memo_cache_sentinel`),k=Symbol.iterator;function A(e){return typeof e!=`object`||!e?null:(e=k&&e[k]||e[`@@iterator`],typeof e==`function`?e:null)}var j=Symbol.for(`react.client.reference`);function M(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return t=e.displayName||null,t===null?M(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return M(e(t))}catch{}}return null}var ee=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te={pending:!1,data:null,method:null,action:null},ne=[],re=-1;function ie(e){return{current:e}}function ae(e){0>re||(e.current=ne[re],ne[re]=null,re--)}function oe(e,t){re++,ne[re]=e.current,e.current=t}var se=ie(null),ce=ie(null),le=ie(null),ue=ie(null);function de(e,t){switch(oe(le,t),oe(ce,e),oe(se,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Zd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Zd(t),e=Qd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ae(se),oe(se,e)}function fe(){ae(se),ae(ce),ae(le)}function pe(e){e.memoizedState!==null&&oe(ue,e);var t=se.current,n=Qd(t,e.type);t!==n&&(oe(ce,e),oe(se,n))}function me(e){ce.current===e&&(ae(se),ae(ce)),ue.current===e&&(ae(ue),cp._currentValue=te)}var he,ge;function _e(e){if(he===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);he=t&&t[1]||``,ge=-1<e.stack.indexOf(`
212
212
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
213
213
  `+he+e+ge}var ve=!1;function ye(e,t){if(!e||ve)return``;ve=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
214
214
  `),l=s.split(`
@@ -216,14 +216,14 @@ Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}
216
216
  `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{ve=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?_e(n):``}function be(e,t){switch(e.tag){case 26:case 27:case 5:return _e(e.type);case 16:return _e(`Lazy`);case 13:return e.child!==t&&t!==null?_e(`Suspense Fallback`):_e(`Suspense`);case 19:return _e(`SuspenseList`);case 0:case 15:return ye(e.type,!1);case 11:return ye(e.type.render,!1);case 1:return ye(e.type,!0);case 31:return _e(`Activity`);default:return``}}function xe(e){try{var t=``,n=null;do t+=be(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
217
217
  Error generating stack: `+e.message+`
218
218
  `+e.stack}}var Se=Object.prototype.hasOwnProperty,Ce=t.unstable_scheduleCallback,we=t.unstable_cancelCallback,Te=t.unstable_shouldYield,Ee=t.unstable_requestPaint,De=t.unstable_now,Oe=t.unstable_getCurrentPriorityLevel,ke=t.unstable_ImmediatePriority,Ae=t.unstable_UserBlockingPriority,je=t.unstable_NormalPriority,Me=t.unstable_LowPriority,Ne=t.unstable_IdlePriority,Pe=t.log,Fe=t.unstable_setDisableYieldValue,Ie=null,Le=null;function Re(e){if(typeof Pe==`function`&&Fe(e),Le&&typeof Le.setStrictMode==`function`)try{Le.setStrictMode(Ie,e)}catch{}}var ze=Math.clz32?Math.clz32:He,Be=Math.log,Ve=Math.LN2;function He(e){return e>>>=0,e===0?32:31-(Be(e)/Ve|0)|0}var Ue=256,We=262144,Ge=4194304;function Ke(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function qe(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Ke(n))):i=Ke(o):i=Ke(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ke(n))):i=Ke(o)):i=Ke(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Je(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function F(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ye(){var e=Ge;return Ge<<=1,!(Ge&62914560)&&(Ge=4194304),e}function Xe(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ze(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Qe(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-ze(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&$e(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function $e(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-ze(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function I(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-ze(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function et(e,t){var n=t&-t;return n=n&42?1:tt(n),(n&(e.suspendedLanes|t))===0?n:0}function tt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function nt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function rt(){var e=P.p;return e===0?(e=window.event,e===void 0?32:wp(e.type)):e}function it(e,t){var n=P.p;try{return P.p=e,t()}finally{P.p=n}}var at=Math.random().toString(36).slice(2),ot=`__reactFiber$`+at,st=`__reactProps$`+at,ct=`__reactContainer$`+at,lt=`__reactEvents$`+at,ut=`__reactListeners$`+at,dt=`__reactHandles$`+at,ft=`__reactResources$`+at,pt=`__reactMarker$`+at;function mt(e){delete e[ot],delete e[st],delete e[lt],delete e[ut],delete e[dt]}function ht(e){var t=e[ot];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ct]||n[ot]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=xf(e);e!==null;){if(n=e[ot])return n;e=xf(e)}return t}e=n,n=e.parentNode}return null}function gt(e){if(e=e[ot]||e[ct]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function _t(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function vt(e){var t=e[ft];return t||=e[ft]={hoistableStyles:new Map,hoistableScripts:new Map},t}function yt(e){e[pt]=!0}var bt=new Set,xt={};function St(e,t){Ct(e,t),Ct(e+`Capture`,t)}function Ct(e,t){for(xt[e]=t,e=0;e<t.length;e++)bt.add(t[e])}var wt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Tt={},Et={};function Dt(e){return Se.call(Et,e)?!0:Se.call(Tt,e)?!1:wt.test(e)?Et[e]=!0:(Tt[e]=!0,!1)}function Ot(e,t,n){if(Dt(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function kt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function At(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function jt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Mt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Nt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Pt(e){if(!e._valueTracker){var t=Mt(e)?`checked`:`value`;e._valueTracker=Nt(e,t,``+e[t])}}function Ft(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Mt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function It(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Lt=/[\n"\\]/g;function Rt(e){return e.replace(Lt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function zt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+jt(t)):e.value!==``+jt(t)&&(e.value=``+jt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Vt(e,o,jt(n)):Vt(e,o,jt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+jt(s):e.removeAttribute(`name`)}function Bt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Pt(e);return}n=n==null?``:``+jt(n),t=t==null?n:``+jt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Pt(e)}function Vt(e,t,n){t===`number`&&It(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Ht(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+jt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Ut(e,t,n){if(t!=null&&(t=``+jt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+jt(n)}function Wt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(ee(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=jt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Pt(e)}function Gt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Kt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function qt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Kt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Jt(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&qt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&qt(e,o,t[o])}function Yt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Xt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),Zt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Qt(e){return Zt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function $t(){}var en=null;function tn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var nn=null,rn=null;function an(e){var t=gt(e);if(t&&(e=t.stateNode)){var n=e[st]||null;a:switch(e=t.stateNode,t.type){case`input`:if(zt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Rt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[st]||null;if(!a)throw Error(i(90));zt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Ft(r)}break a;case`textarea`:Ut(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Ht(e,!!n.multiple,t,!1)}}}var on=!1;function sn(e,t,n){if(on)return e(t,n);on=!0;try{return e(t)}finally{if(on=!1,(nn!==null||rn!==null)&&(Ou(),nn&&(t=nn,e=rn,rn=nn=null,an(t),e)))for(t=0;t<e.length;t++)an(e[t])}}function cn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[st]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var ln=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),un=!1;if(ln)try{var dn={};Object.defineProperty(dn,"passive",{get:function(){un=!0}}),window.addEventListener(`test`,dn,dn),window.removeEventListener(`test`,dn,dn)}catch{un=!1}var fn=null,pn=null,mn=null;function hn(){if(mn)return mn;var e,t=pn,n=t.length,r,i=`value`in fn?fn.value:fn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return mn=i.slice(e,1<r?1-r:void 0)}function gn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function _n(){return!0}function vn(){return!1}function yn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?_n:vn,this.isPropagationStopped=vn,this}return f(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=_n)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=_n)},persist:function(){},isPersistent:_n}),t}var bn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},xn=yn(bn),Sn=f({},bn,{view:0,detail:0}),Cn=yn(Sn),wn,Tn,En,Dn=f({},Sn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Rn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==En&&(En&&e.type===`mousemove`?(wn=e.screenX-En.screenX,Tn=e.screenY-En.screenY):Tn=wn=0,En=e),wn)},movementY:function(e){return`movementY`in e?e.movementY:Tn}}),On=yn(Dn),kn=yn(f({},Dn,{dataTransfer:0})),An=yn(f({},Sn,{relatedTarget:0})),jn=yn(f({},bn,{animationName:0,elapsedTime:0,pseudoElement:0})),Mn=yn(f({},bn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Nn=yn(f({},bn,{data:0})),Pn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Fn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},In={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Ln(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=In[e])?!!t[e]:!1}function Rn(){return Ln}var zn=yn(f({},Sn,{key:function(e){if(e.key){var t=Pn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=gn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Fn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Rn,charCode:function(e){return e.type===`keypress`?gn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?gn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Bn=yn(f({},Dn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Vn=yn(f({},Sn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Rn})),Hn=yn(f({},bn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Un=yn(f({},Dn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Wn=yn(f({},bn,{newState:0,oldState:0})),Gn=[9,13,27,32],Kn=ln&&`CompositionEvent`in window,qn=null;ln&&`documentMode`in document&&(qn=document.documentMode);var Jn=ln&&`TextEvent`in window&&!qn,Yn=ln&&(!Kn||qn&&8<qn&&11>=qn),Xn=` `,Zn=!1;function Qn(e,t){switch(e){case`keyup`:return Gn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function $n(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var er=!1;function tr(e,t){switch(e){case`compositionend`:return $n(t);case`keypress`:return t.which===32?(Zn=!0,Xn):null;case`textInput`:return e=t.data,e===Xn&&Zn?null:e;default:return null}}function nr(e,t){if(er)return e===`compositionend`||!Kn&&Qn(e,t)?(e=hn(),mn=pn=fn=null,er=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Yn&&t.locale!==`ko`?null:t.data;default:return null}}var rr={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ir(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!rr[e.type]:t===`textarea`}function ar(e,t,n,r){nn?rn?rn.push(r):rn=[r]:nn=r,t=Fd(t,`onChange`),0<t.length&&(n=new xn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var or=null,sr=null;function cr(e){Od(e,0)}function lr(e){if(Ft(_t(e)))return e}function ur(e,t){if(e===`change`)return t}var dr=!1;if(ln){var fr;if(ln){var pr=`oninput`in document;if(!pr){var mr=document.createElement(`div`);mr.setAttribute(`oninput`,`return;`),pr=typeof mr.oninput==`function`}fr=pr}else fr=!1;dr=fr&&(!document.documentMode||9<document.documentMode)}function hr(){or&&(or.detachEvent(`onpropertychange`,gr),sr=or=null)}function gr(e){if(e.propertyName===`value`&&lr(sr)){var t=[];ar(t,sr,e,tn(e)),sn(cr,t)}}function _r(e,t,n){e===`focusin`?(hr(),or=t,sr=n,or.attachEvent(`onpropertychange`,gr)):e===`focusout`&&hr()}function vr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return lr(sr)}function yr(e,t){if(e===`click`)return lr(t)}function br(e,t){if(e===`input`||e===`change`)return lr(t)}function xr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Sr=typeof Object.is==`function`?Object.is:xr;function Cr(e,t){if(Sr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Se.call(t,i)||!Sr(e[i],t[i]))return!1}return!0}function wr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Tr(e,t){var n=wr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=wr(n)}}function Er(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Er(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Dr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=It(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=It(e.document)}return t}function Or(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var kr=ln&&`documentMode`in document&&11>=document.documentMode,Ar=null,jr=null,Mr=null,Nr=!1;function Pr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Nr||Ar==null||Ar!==It(r)||(r=Ar,`selectionStart`in r&&Or(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Mr&&Cr(Mr,r)||(Mr=r,r=Fd(jr,`onSelect`),0<r.length&&(t=new xn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Ar)))}function Fr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Ir={animationend:Fr(`Animation`,`AnimationEnd`),animationiteration:Fr(`Animation`,`AnimationIteration`),animationstart:Fr(`Animation`,`AnimationStart`),transitionrun:Fr(`Transition`,`TransitionRun`),transitionstart:Fr(`Transition`,`TransitionStart`),transitioncancel:Fr(`Transition`,`TransitionCancel`),transitionend:Fr(`Transition`,`TransitionEnd`)},Lr={},Rr={};ln&&(Rr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Ir.animationend.animation,delete Ir.animationiteration.animation,delete Ir.animationstart.animation),`TransitionEvent`in window||delete Ir.transitionend.transition);function zr(e){if(Lr[e])return Lr[e];if(!Ir[e])return e;var t=Ir[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Rr)return Lr[e]=t[n];return e}var Br=zr(`animationend`),Vr=zr(`animationiteration`),Hr=zr(`animationstart`),Ur=zr(`transitionrun`),Wr=zr(`transitionstart`),Gr=zr(`transitioncancel`),Kr=zr(`transitionend`),qr=new Map,Jr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Jr.push(`scrollEnd`);function Yr(e,t){qr.set(e,t),St(t,[e])}var Xr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Zr=[],Qr=0,$r=0;function ei(){for(var e=Qr,t=$r=Qr=0;t<e;){var n=Zr[t];Zr[t++]=null;var r=Zr[t];Zr[t++]=null;var i=Zr[t];Zr[t++]=null;var a=Zr[t];if(Zr[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&ii(n,i,a)}}function ti(e,t,n,r){Zr[Qr++]=e,Zr[Qr++]=t,Zr[Qr++]=n,Zr[Qr++]=r,$r|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function ni(e,t,n,r){return ti(e,t,n,r),ai(e)}function ri(e,t){return ti(e,null,null,t),ai(e)}function ii(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-ze(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function ai(e){if(50<bu)throw bu=0,xu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var L={};function oi(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function si(e,t,n,r){return new oi(e,t,n,r)}function ci(e){return e=e.prototype,!(!e||!e.isReactComponent)}function R(e,t){var n=e.alternate;return n===null?(n=si(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function li(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function ui(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)ci(e)&&(s=1);else if(typeof e==`string`)s=$f(e,n,se.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case D:return e=si(31,n,t,a),e.elementType=D,e.lanes=o,e;case _:return di(n.children,a,o,t);case v:s=8,a|=24;break;case y:return e=si(12,n,t,a|2),e.elementType=y,e.lanes=o,e;case C:return e=si(13,n,t,a),e.elementType=C,e.lanes=o,e;case w:return e=si(19,n,t,a),e.elementType=w,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case x:s=10;break a;case b:s=9;break a;case S:s=11;break a;case T:s=14;break a;case E:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=si(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function di(e,t,n,r){return e=si(7,e,r,t),e.lanes=n,e}function fi(e,t,n){return e=si(6,e,null,t),e.lanes=n,e}function pi(e){var t=si(18,null,null,0);return t.stateNode=e,t}function mi(e,t,n){return t=si(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var hi=new WeakMap;function gi(e,t){if(typeof e==`object`&&e){var n=hi.get(e);return n===void 0?(t={value:e,source:t,stack:xe(t)},hi.set(e,t),t):n}return{value:e,source:t,stack:xe(t)}}var _i=[],vi=0,yi=null,bi=0,xi=[],Si=0,Ci=null,wi=1,Ti=``;function Ei(e,t){_i[vi++]=bi,_i[vi++]=yi,yi=e,bi=t}function Di(e,t,n){xi[Si++]=wi,xi[Si++]=Ti,xi[Si++]=Ci,Ci=e;var r=wi;e=Ti;var i=32-ze(r)-1;r&=~(1<<i),n+=1;var a=32-ze(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,wi=1<<32-ze(t)+i|n<<i|r,Ti=a+e}else wi=1<<a|n<<i|r,Ti=e}function Oi(e){e.return!==null&&(Ei(e,1),Di(e,1,0))}function ki(e){for(;e===yi;)yi=_i[--vi],_i[vi]=null,bi=_i[--vi],_i[vi]=null;for(;e===Ci;)Ci=xi[--Si],xi[Si]=null,Ti=xi[--Si],xi[Si]=null,wi=xi[--Si],xi[Si]=null}function Ai(e,t){xi[Si++]=wi,xi[Si++]=Ti,xi[Si++]=Ci,wi=t.id,Ti=t.overflow,Ci=e}var ji=null,Mi=null,Ni=!1,Pi=null,Fi=!1,Ii=Error(i(519));function Li(e){throw Ui(gi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Ii}function Ri(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[ot]=e,t[st]=r,n){case`dialog`:kd(`cancel`,t),kd(`close`,t);break;case`iframe`:case`object`:case`embed`:kd(`load`,t);break;case`video`:case`audio`:for(n=0;n<Ed.length;n++)kd(Ed[n],t);break;case`source`:kd(`error`,t);break;case`img`:case`image`:case`link`:kd(`error`,t),kd(`load`,t);break;case`details`:kd(`toggle`,t);break;case`input`:kd(`invalid`,t),Bt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:kd(`invalid`,t);break;case`textarea`:kd(`invalid`,t),Wt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Vd(t.textContent,n)?(r.popover!=null&&(kd(`beforetoggle`,t),kd(`toggle`,t)),r.onScroll!=null&&kd(`scroll`,t),r.onScrollEnd!=null&&kd(`scrollend`,t),r.onClick!=null&&(t.onclick=$t),t=!0):t=!1,t||Li(e,!0)}function zi(e){for(ji=e.return;ji;)switch(ji.tag){case 5:case 31:case 13:Fi=!1;return;case 27:case 3:Fi=!0;return;default:ji=ji.return}}function Bi(e){if(e!==ji)return!1;if(!Ni)return zi(e),Ni=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||$d(e.type,e.memoizedProps)),n=!n),n&&Mi&&Li(e),zi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Mi=bf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Mi=bf(e)}else t===27?(t=Mi,cf(e.type)?(e=yf,yf=null,Mi=e):Mi=t):Mi=ji?vf(e.stateNode.nextSibling):null;return!0}function Vi(){Mi=ji=null,Ni=!1}function Hi(){var e=Pi;return e!==null&&(ou===null?ou=e:ou.push.apply(ou,e),Pi=null),e}function Ui(e){Pi===null?Pi=[e]:Pi.push(e)}var Wi=ie(null),z=null,Gi=null;function Ki(e,t,n){oe(Wi,t._currentValue),t._currentValue=n}function B(e){e._currentValue=Wi.current,ae(Wi)}function qi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Ji(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),qi(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),qi(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function Yi(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;Sr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===ue.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[cp]:e.push(cp))}a=a.return}e!==null&&Ji(t,e,n,r),t.flags|=262144}function Xi(e){for(e=e.firstContext;e!==null;){if(!Sr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Qi(e){z=e,Gi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function $i(e){return ta(z,e)}function ea(e,t){return z===null&&Qi(e),ta(e,t)}function ta(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Gi===null){if(e===null)throw Error(i(308));Gi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Gi=Gi.next=t;return n}var na=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ra=t.unstable_scheduleCallback,ia=t.unstable_NormalPriority,aa={$$typeof:x,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function oa(){return{controller:new na,data:new Map,refCount:0}}function sa(e){e.refCount--,e.refCount===0&&ra(ia,function(){e.controller.abort()})}var ca=null,la=0,ua=0,da=null;function fa(e,t){if(ca===null){var n=ca=[];la=0,ua=bd(),da={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return la++,t.then(pa,pa),t}function pa(){if(--la===0&&ca!==null){da!==null&&(da.status=`fulfilled`);var e=ca;ca=null,ua=0,da=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function ma(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var ha=N.S;N.S=function(e,t){lu=De(),typeof t==`object`&&t&&typeof t.then==`function`&&fa(e,t),ha!==null&&ha(e,t)};var ga=ie(null);function _a(){var e=ga.current;return e===null?Wl.pooledCache:e}function va(e,t){t===null?oe(ga,ga.current):oe(ga,t.pool)}function ya(){var e=_a();return e===null?null:{parent:aa._currentValue,pool:e}}var ba=Error(i(460)),xa=Error(i(474)),Sa=Error(i(542)),Ca={then:function(){}};function wa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Ta(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then($t,$t),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ka(e),e;default:if(typeof t.status==`string`)t.then($t,$t);else{if(e=Wl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ka(e),e}throw Da=t,ba}}function Ea(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Da=e,ba):e}}var Da=null;function Oa(){if(Da===null)throw Error(i(459));var e=Da;return Da=null,e}function ka(e){if(e===ba||e===Sa)throw Error(i(483))}var Aa=null,ja=0;function Ma(e){var t=ja;return ja+=1,Aa===null&&(Aa=[]),Ta(Aa,e,t)}function Na(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Pa(e,t){throw t.$$typeof===p?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Fa(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=R(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=fi(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===_?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===E&&Ea(i)===t.type)?(t=a(t,n.props),Na(t,n),t.return=e,t):(t=ui(n.type,n.key,n.props,null,e.mode,r),Na(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=mi(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=di(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=fi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case h:return n=ui(t.type,t.key,t.props,null,e.mode,n),Na(n,t),n.return=e,n;case g:return t=mi(t,e.mode,n),t.return=e,t;case E:return t=Ea(t),f(e,t,n)}if(ee(t)||A(t))return t=di(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Ma(t),n);if(t.$$typeof===x)return f(e,ea(e,t),n);Pa(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case h:return n.key===i?l(e,t,n,r):null;case g:return n.key===i?u(e,t,n,r):null;case E:return n=Ea(n),p(e,t,n,r)}if(ee(n)||A(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Ma(n),r);if(n.$$typeof===x)return p(e,t,ea(e,n),r);Pa(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case h:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case g:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case E:return r=Ea(r),m(e,t,n,r,i)}if(ee(r)||A(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Ma(r),i);if(r.$$typeof===x)return m(e,t,n,ea(t,r),i);Pa(t,r)}return null}function v(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Ni&&Ei(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return Ni&&Ei(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Ni&&Ei(i,h),l}function y(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Ni&&Ei(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Ni&&Ei(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Ni&&Ei(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===_&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case h:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===_){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===E&&Ea(l)===r.type){n(e,r.sibling),c=a(r,o.props),Na(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===_?(c=di(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ui(o.type,o.key,o.props,null,e.mode,c),Na(c,o),c.return=e,e=c)}return s(e);case g:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=mi(o,e.mode,c),c.return=e,e=c}return s(e);case E:return o=Ea(o),b(e,r,o,c)}if(ee(o))return v(e,r,o,c);if(A(o)){if(l=A(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),y(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Ma(o),c);if(o.$$typeof===x)return b(e,r,ea(e,o),c);Pa(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=fi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{ja=0;var i=b(e,t,n,r);return Aa=null,i}catch(t){if(t===ba||t===Sa)throw t;var a=si(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ia=Fa(!0),La=Fa(!1),Ra=!1;function za(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ba(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Va(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ha(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ul&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ai(e),ii(e,null,n),t}return ti(e,r,t,n),ai(e)}function Ua(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,I(e,n)}}function Wa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ga=!1;function Ka(){if(Ga){var e=da;if(e!==null)throw e}}function qa(e,t,n,r){Ga=!1;var i=e.updateQueue;Ra=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var p=s.lane&-536870913,m=p!==s.lane;if(m?(Kl&p)===p:(r&p)===p){p!==0&&p===ua&&(Ga=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;p=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,p);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,p=typeof h==`function`?h.call(_,d,p):h,p==null)break a;d=f({},d,p);break a;case 2:Ra=!0}}p=s.callback,p!==null&&(e.flags|=64,m&&(e.flags|=8192),m=i.callbacks,m===null?i.callbacks=[p]:m.push(p))}else m={lane:p,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=m,c=d):u=u.next=m,o|=p;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;m=s,s=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),eu|=o,e.lanes=o,e.memoizedState=d}}function Ja(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Ya(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ja(n[e],t)}var Xa=ie(null),Za=ie(0);function Qa(e,t){e=Ql,oe(Za,e),oe(Xa,t),Ql=e|t.baseLanes}function $a(){oe(Za,Ql),oe(Xa,Xa.current)}function eo(){Ql=Za.current,ae(Xa),ae(Za)}var to=ie(null),no=null;function ro(e){var t=e.alternate;oe(co,co.current&1),oe(to,e),no===null&&(t===null||Xa.current!==null||t.memoizedState!==null)&&(no=e)}function io(e){oe(co,co.current),oe(to,e),no===null&&(no=e)}function ao(e){e.tag===22?(oe(co,co.current),oe(to,e),no===null&&(no=e)):oo(e)}function oo(){oe(co,co.current),oe(to,to.current)}function so(e){ae(to),no===e&&(no=null),ae(co)}var co=ie(0);function lo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||hf(n)||gf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var uo=0,fo=null,po=null,mo=null,ho=!1,go=!1,_o=!1,vo=0,yo=0,bo=null,xo=0;function So(){throw Error(i(321))}function Co(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Sr(e[n],t[n]))return!1;return!0}function wo(e,t,n,r,i,a){return uo=a,fo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,N.H=e===null||e.memoizedState===null?Vs:Hs,_o=!1,a=n(r,i),_o=!1,go&&(a=Eo(t,n,r,i)),To(e),a}function To(e){N.H=Bs;var t=po!==null&&po.next!==null;if(uo=0,mo=po=fo=null,ho=!1,yo=0,bo=null,t)throw Error(i(300));e===null||ac||(e=e.dependencies,e!==null&&Xi(e)&&(ac=!0))}function Eo(e,t,n,r){fo=e;var a=0;do{if(go&&(bo=null),yo=0,go=!1,25<=a)throw Error(i(301));if(a+=1,mo=po=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}N.H=Us,o=t(n,r)}while(go);return o}function Do(){var e=N.H,t=e.useState()[0];return t=typeof t.then==`function`?Po(t):t,e=e.useState()[0],(po===null?null:po.memoizedState)!==e&&(fo.flags|=1024),t}function Oo(){var e=vo!==0;return vo=0,e}function ko(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Ao(e){if(ho){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}ho=!1}uo=0,mo=po=fo=null,go=!1,yo=vo=0,bo=null}function jo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return mo===null?fo.memoizedState=mo=e:mo=mo.next=e,mo}function Mo(){if(po===null){var e=fo.alternate;e=e===null?null:e.memoizedState}else e=po.next;var t=mo===null?fo.memoizedState:mo.next;if(t!==null)mo=t,po=e;else{if(e===null)throw fo.alternate===null?Error(i(467)):Error(i(310));po=e,e={memoizedState:po.memoizedState,baseState:po.baseState,baseQueue:po.baseQueue,queue:po.queue,next:null},mo===null?fo.memoizedState=mo=e:mo=mo.next=e}return mo}function No(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Po(e){var t=yo;return yo+=1,bo===null&&(bo=[]),e=Ta(bo,e,t),t=fo,(mo===null?t.memoizedState:mo.next)===null&&(t=t.alternate,N.H=t===null||t.memoizedState===null?Vs:Hs),e}function Fo(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Po(e);if(e.$$typeof===x)return $i(e)}throw Error(i(438,String(e)))}function Io(e){var t=null,n=fo.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=fo.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=No(),fo.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=O;return t.index++,n}function Lo(e,t){return typeof t==`function`?t(e):t}function Ro(e){return zo(Mo(),po,e)}function zo(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(uo&f)===f:(Kl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===ua&&(d=!0);else if((uo&p)===p){u=u.next,p===ua&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,fo.lanes|=p,eu|=p;f=u.action,_o&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,fo.lanes|=f,eu|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Sr(o,e.memoizedState)&&(ac=!0,d&&(n=da,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Bo(e){var t=Mo(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Sr(o,t.memoizedState)||(ac=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Vo(e,t,n){var r=fo,a=Mo(),o=Ni;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Sr((po||a).memoizedState,n);if(s&&(a.memoizedState=n,ac=!0),a=a.queue,fs(Wo.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||mo!==null&&mo.memoizedState.tag&1){if(r.flags|=2048,ss(9,{destroy:void 0},Uo.bind(null,r,a,n,t),null),Wl===null)throw Error(i(349));o||uo&127||Ho(r,t,n)}return n}function Ho(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=fo.updateQueue,t===null?(t=No(),fo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Uo(e,t,n,r){t.value=n,t.getSnapshot=r,Go(t)&&Ko(e)}function Wo(e,t,n){return n(function(){Go(t)&&Ko(e)})}function Go(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Sr(e,n)}catch{return!0}}function Ko(e){var t=ri(e,2);t!==null&&wu(t,e,2)}function qo(e){var t=jo();if(typeof e==`function`){var n=e;if(e=n(),_o){Re(!0);try{n()}finally{Re(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:e},t}function Jo(e,t,n,r){return e.baseState=n,zo(e,po,typeof r==`function`?r:Lo)}function Yo(e,t,n,r,a){if(Ls(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};N.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Xo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Xo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=N.T,o={};N.T=o;try{var s=n(i,r),c=N.S;c!==null&&c(o,s),Zo(e,t,s)}catch(n){$o(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),N.T=a}}else try{a=n(i,r),Zo(e,t,a)}catch(n){$o(e,t,n)}}function Zo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Qo(e,t,n)},function(n){return $o(e,t,n)}):Qo(e,t,n)}function Qo(e,t,n){t.status=`fulfilled`,t.value=n,es(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Xo(e,n)))}function $o(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,es(t),t=t.next;while(t!==r)}e.action=null}function es(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function ts(e,t){return t}function ns(e,t){if(Ni){var n=Wl.formState;if(n!==null){a:{var r=fo;if(Ni){if(Mi){b:{for(var i=Mi,a=Fi;i.nodeType!==8;){if(!a){i=null;break b}if(i=vf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Mi=vf(i.nextSibling),r=i.data===`F!`;break a}}Li(r)}r=!1}r&&(t=n[0])}}return n=jo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ts,lastRenderedState:t},n.queue=r,n=Ps.bind(null,fo,r),r.dispatch=n,r=qo(!1),a=Is.bind(null,fo,!1,r.queue),r=jo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Yo.bind(null,fo,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function rs(e){return is(Mo(),po,e)}function is(e,t,n){if(t=zo(e,t,ts)[0],e=Ro(Lo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Po(t)}catch(e){throw e===ba?Sa:e}else r=t;t=Mo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(fo.flags|=2048,ss(9,{destroy:void 0},as.bind(null,i,n),null)),[r,a,e]}function as(e,t){e.action=t}function os(e){var t=Mo(),n=po;if(n!==null)return is(t,n,e);Mo(),t=t.memoizedState,n=Mo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function ss(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=fo.updateQueue,t===null&&(t=No(),fo.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function cs(){return Mo().memoizedState}function ls(e,t,n,r){var i=jo();fo.flags|=e,i.memoizedState=ss(1|t,{destroy:void 0},n,r===void 0?null:r)}function us(e,t,n,r){var i=Mo();r=r===void 0?null:r;var a=i.memoizedState.inst;po!==null&&r!==null&&Co(r,po.memoizedState.deps)?i.memoizedState=ss(t,a,n,r):(fo.flags|=e,i.memoizedState=ss(1|t,a,n,r))}function ds(e,t){ls(8390656,8,e,t)}function fs(e,t){us(2048,8,e,t)}function ps(e){fo.flags|=4;var t=fo.updateQueue;if(t===null)t=No(),fo.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function ms(e){var t=Mo().memoizedState;return ps({ref:t,nextImpl:e}),function(){if(Ul&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function hs(e,t){return us(4,2,e,t)}function gs(e,t){return us(4,4,e,t)}function _s(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function vs(e,t,n){n=n==null?null:n.concat([e]),us(4,4,_s.bind(null,t,e),n)}function ys(){}function bs(e,t){var n=Mo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Co(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function xs(e,t){var n=Mo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Co(t,r[1]))return r[0];if(r=e(),_o){Re(!0);try{e()}finally{Re(!1)}}return n.memoizedState=[r,t],r}function Ss(e,t,n){return n===void 0||uo&1073741824&&!(Kl&261930)?e.memoizedState=t:(e.memoizedState=n,e=Cu(),fo.lanes|=e,eu|=e,n)}function Cs(e,t,n,r){return Sr(n,t)?n:Xa.current===null?!(uo&42)||uo&1073741824&&!(Kl&261930)?(ac=!0,e.memoizedState=n):(e=Cu(),fo.lanes|=e,eu|=e,t):(e=Ss(e,n,r),Sr(e,t)||(ac=!0),e)}function ws(e,t,n,r,i){var a=P.p;P.p=a!==0&&8>a?a:8;var o=N.T,s={};N.T=s,Is(e,!1,t,n);try{var c=i(),l=N.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Fs(e,t,ma(c,r),Su(e)):Fs(e,t,r,Su(e))}catch(n){Fs(e,t,{then:function(){},status:`rejected`,reason:n},Su())}finally{P.p=a,o!==null&&s.types!==null&&(o.types=s.types),N.T=o}}function Ts(){}function Es(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Ds(e).queue;ws(e,a,t,te,n===null?Ts:function(){return Os(e),n(r)})}function Ds(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:te,baseState:te,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:te},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Os(e){var t=Ds(e);t.next===null&&(t=e.alternate.memoizedState),Fs(e,t.next.queue,{},Su())}function ks(){return $i(cp)}function As(){return Mo().memoizedState}function js(){return Mo().memoizedState}function Ms(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Su();e=Va(n);var r=Ha(t,e,n);r!==null&&(wu(r,t,n),Ua(r,t,n)),t={cache:oa()},e.payload=t;return}t=t.return}}function Ns(e,t,n){var r=Su();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ls(e)?Rs(t,n):(n=ni(e,t,n,r),n!==null&&(wu(n,e,r),zs(n,t,r)))}function Ps(e,t,n){Fs(e,t,n,Su())}function Fs(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ls(e))Rs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Sr(s,o))return ti(e,t,i,0),Wl===null&&ei(),!1}catch{}if(n=ni(e,t,i,r),n!==null)return wu(n,e,r),zs(n,t,r),!0}return!1}function Is(e,t,n,r){if(r={lane:2,revertLane:bd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ls(e)){if(t)throw Error(i(479))}else t=ni(e,n,r,2),t!==null&&wu(t,e,2)}function Ls(e){var t=e.alternate;return e===fo||t!==null&&t===fo}function Rs(e,t){go=ho=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function zs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,I(e,n)}}var Bs={readContext:$i,use:Fo,useCallback:So,useContext:So,useEffect:So,useImperativeHandle:So,useLayoutEffect:So,useInsertionEffect:So,useMemo:So,useReducer:So,useRef:So,useState:So,useDebugValue:So,useDeferredValue:So,useTransition:So,useSyncExternalStore:So,useId:So,useHostTransitionStatus:So,useFormState:So,useActionState:So,useOptimistic:So,useMemoCache:So,useCacheRefresh:So};Bs.useEffectEvent=So;var Vs={readContext:$i,use:Fo,useCallback:function(e,t){return jo().memoizedState=[e,t===void 0?null:t],e},useContext:$i,useEffect:ds,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),ls(4194308,4,_s.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ls(4194308,4,e,t)},useInsertionEffect:function(e,t){ls(4,2,e,t)},useMemo:function(e,t){var n=jo();t=t===void 0?null:t;var r=e();if(_o){Re(!0);try{e()}finally{Re(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=jo();if(n!==void 0){var i=n(t);if(_o){Re(!0);try{n(t)}finally{Re(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ns.bind(null,fo,e),[r.memoizedState,e]},useRef:function(e){var t=jo();return e={current:e},t.memoizedState=e},useState:function(e){e=qo(e);var t=e.queue,n=Ps.bind(null,fo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ys,useDeferredValue:function(e,t){return Ss(jo(),e,t)},useTransition:function(){var e=qo(!1);return e=ws.bind(null,fo,e.queue,!0,!1),jo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=fo,a=jo();if(Ni){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Wl===null)throw Error(i(349));Kl&127||Ho(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ds(Wo.bind(null,r,o,e),[e]),r.flags|=2048,ss(9,{destroy:void 0},Uo.bind(null,r,o,n,t),null),n},useId:function(){var e=jo(),t=Wl.identifierPrefix;if(Ni){var n=Ti,r=wi;n=(r&~(1<<32-ze(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=vo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=xo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:ks,useFormState:ns,useActionState:ns,useOptimistic:function(e){var t=jo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Is.bind(null,fo,!0,n),n.dispatch=t,[e,t]},useMemoCache:Io,useCacheRefresh:function(){return jo().memoizedState=Ms.bind(null,fo)},useEffectEvent:function(e){var t=jo(),n={impl:e};return t.memoizedState=n,function(){if(Ul&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Hs={readContext:$i,use:Fo,useCallback:bs,useContext:$i,useEffect:fs,useImperativeHandle:vs,useInsertionEffect:hs,useLayoutEffect:gs,useMemo:xs,useReducer:Ro,useRef:cs,useState:function(){return Ro(Lo)},useDebugValue:ys,useDeferredValue:function(e,t){return Cs(Mo(),po.memoizedState,e,t)},useTransition:function(){var e=Ro(Lo)[0],t=Mo().memoizedState;return[typeof e==`boolean`?e:Po(e),t]},useSyncExternalStore:Vo,useId:As,useHostTransitionStatus:ks,useFormState:rs,useActionState:rs,useOptimistic:function(e,t){return Jo(Mo(),po,e,t)},useMemoCache:Io,useCacheRefresh:js};Hs.useEffectEvent=ms;var Us={readContext:$i,use:Fo,useCallback:bs,useContext:$i,useEffect:fs,useImperativeHandle:vs,useInsertionEffect:hs,useLayoutEffect:gs,useMemo:xs,useReducer:Bo,useRef:cs,useState:function(){return Bo(Lo)},useDebugValue:ys,useDeferredValue:function(e,t){var n=Mo();return po===null?Ss(n,e,t):Cs(n,po.memoizedState,e,t)},useTransition:function(){var e=Bo(Lo)[0],t=Mo().memoizedState;return[typeof e==`boolean`?e:Po(e),t]},useSyncExternalStore:Vo,useId:As,useHostTransitionStatus:ks,useFormState:os,useActionState:os,useOptimistic:function(e,t){var n=Mo();return po===null?(n.baseState=e,[e,n.queue.dispatch]):Jo(n,po,e,t)},useMemoCache:Io,useCacheRefresh:js};Us.useEffectEvent=ms;function Ws(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:f({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Gs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Su(),i=Va(r);i.payload=t,n!=null&&(i.callback=n),t=Ha(e,i,r),t!==null&&(wu(t,e,r),Ua(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Su(),i=Va(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Ha(e,i,r),t!==null&&(wu(t,e,r),Ua(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Su(),r=Va(n);r.tag=2,t!=null&&(r.callback=t),t=Ha(e,r,n),t!==null&&(wu(t,e,n),Ua(t,e,n))}};function Ks(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Cr(n,r)||!Cr(i,a):!0}function qs(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Gs.enqueueReplaceState(t,t.state,null)}function Js(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=f({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Ys(e){Xr(e)}function Xs(e){console.error(e)}function Zs(e){Xr(e)}function Qs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function $s(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function ec(e,t,n){return n=Va(n),n.tag=3,n.payload={element:null},n.callback=function(){Qs(e,t)},n}function tc(e){return e=Va(e),e.tag=3,e}function nc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){$s(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){$s(t,n,r),typeof i!=`function`&&(fu===null?fu=new Set([this]):fu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function rc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&Yi(t,n,a,!0),n=to.current,n!==null){switch(n.tag){case 31:case 13:return no===null?Fu():n.alternate===null&&$l===0&&($l=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Ca?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),ed(e,r,a)),!1;case 22:return n.flags|=65536,r===Ca?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),ed(e,r,a)),!1}throw Error(i(435,n.tag))}return ed(e,r,a),Fu(),!1}if(Ni)return t=to.current,t===null?(r!==Ii&&(t=Error(i(423),{cause:r}),Ui(gi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=gi(r,n),a=ec(e.stateNode,r,a),Wa(e,a),$l!==4&&($l=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Ii&&(e=Error(i(422),{cause:r}),Ui(gi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=gi(o,n),au===null?au=[o]:au.push(o),$l!==4&&($l=2),t===null)return!0;r=gi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=ec(n.stateNode,r,e),Wa(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(fu===null||!fu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=tc(a),nc(a,e,n,r),Wa(n,a),!1}n=n.return}while(n!==null);return!1}var ic=Error(i(461)),ac=!1;function oc(e,t,n,r){t.child=e===null?La(t,null,n,r):Ia(t,e.child,n,r)}function sc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Qi(t),r=wo(e,t,n,o,a,i),s=Oo(),e!==null&&!ac?(ko(e,t,i),jc(e,t,i)):(Ni&&s&&Oi(t),t.flags|=1,oc(e,t,r,i),t.child)}function cc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ci(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,lc(e,t,a,r,i)):(e=ui(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Mc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Cr:n,n(o,r)&&e.ref===t.ref)return jc(e,t,i)}return t.flags|=1,e=R(a,r),e.ref=t.ref,e.return=t,t.child=e}function lc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Cr(a,r)&&e.ref===t.ref)if(ac=!1,t.pendingProps=r=a,Mc(e,i))e.flags&131072&&(ac=!0);else return t.lanes=e.lanes,jc(e,t,i)}return _c(e,t,n,r,i)}function uc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return fc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&va(t,a===null?null:a.cachePool),a===null?$a():Qa(t,a),ao(t);else return r=t.lanes=536870912,fc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&va(t,null),$a(),oo(t)):(va(t,a.cachePool),Qa(t,a),oo(t),t.memoizedState=null);return oc(e,t,i,n),t.child}function dc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function fc(e,t,n,r,i){var a=_a();return a=a===null?null:{parent:aa._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&va(t,null),$a(),ao(t),e!==null&&Yi(e,t,r,!0),t.childLanes=i,null}function pc(e,t){return t=Ec({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function mc(e,t,n){return Ia(t,e.child,null,n),e=pc(t,t.pendingProps),e.flags|=2,so(t),t.memoizedState=null,e}function hc(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Ni){if(r.mode===`hidden`)return e=pc(t,r),t.lanes=536870912,dc(null,e);if(io(t),(e=Mi)?(e=mf(e,Fi),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ci===null?null:{id:wi,overflow:Ti},retryLane:536870912,hydrationErrors:null},n=pi(e),n.return=t,t.child=n,ji=t,Mi=null)):e=null,e===null)throw Li(t);return t.lanes=536870912,null}return pc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(io(t),a)if(t.flags&256)t.flags&=-257,t=mc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(ac||Yi(e,t,n,!1),a=(n&e.childLanes)!==0,ac||a){if(r=Wl,r!==null&&(s=et(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,ri(e,s),wu(r,e,s),ic;Fu(),t=mc(e,t,n)}else e=o.treeContext,Mi=vf(s.nextSibling),ji=t,Ni=!0,Pi=null,Fi=!1,e!==null&&Ai(t,e),t=pc(t,r),t.flags|=4096;return t}return e=R(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function gc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function _c(e,t,n,r,i){return Qi(t),n=wo(e,t,n,r,void 0,i),r=Oo(),e!==null&&!ac?(ko(e,t,i),jc(e,t,i)):(Ni&&r&&Oi(t),t.flags|=1,oc(e,t,n,i),t.child)}function vc(e,t,n,r,i,a){return Qi(t),t.updateQueue=null,n=Eo(t,r,n,i),To(e),r=Oo(),e!==null&&!ac?(ko(e,t,a),jc(e,t,a)):(Ni&&r&&Oi(t),t.flags|=1,oc(e,t,n,a),t.child)}function yc(e,t,n,r,i){if(Qi(t),t.stateNode===null){var a=L,o=n.contextType;typeof o==`object`&&o&&(a=$i(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Gs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},za(t),o=n.contextType,a.context=typeof o==`object`&&o?$i(o):L,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Ws(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Gs.enqueueReplaceState(a,a.state,null),qa(t,r,a,i),Ka(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Js(n,s);a.props=c;var l=a.context,u=n.contextType;o=L,typeof u==`object`&&u&&(o=$i(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&qs(t,a,r,o),Ra=!1;var f=t.memoizedState;a.state=f,qa(t,r,a,i),Ka(),l=t.memoizedState,s||f!==l||Ra?(typeof d==`function`&&(Ws(t,n,d,r),l=t.memoizedState),(c=Ra||Ks(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Ba(e,t),o=t.memoizedProps,u=Js(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=L,typeof l==`object`&&l&&(c=$i(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&qs(t,a,r,c),Ra=!1,f=t.memoizedState,a.state=f,qa(t,r,a,i),Ka();var p=t.memoizedState;o!==d||f!==p||Ra||e!==null&&e.dependencies!==null&&Xi(e.dependencies)?(typeof s==`function`&&(Ws(t,n,s,r),p=t.memoizedState),(u=Ra||Ks(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Xi(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,gc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Ia(t,e.child,null,i),t.child=Ia(t,null,n,i)):oc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=jc(e,t,i),e}function bc(e,t,n,r){return Vi(),t.flags|=256,oc(e,t,n,r),t.child}var xc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Sc(e){return{baseLanes:e,cachePool:ya()}}function Cc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=ru),e}function wc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(co.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Ni){if(a?ro(t):oo(t),(e=Mi)?(e=mf(e,Fi),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ci===null?null:{id:wi,overflow:Ti},retryLane:536870912,hydrationErrors:null},n=pi(e),n.return=t,t.child=n,ji=t,Mi=null)):e=null,e===null)throw Li(t);return gf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(oo(t),a=t.mode,c=Ec({mode:`hidden`,children:c},a),r=di(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=Sc(n),r.childLanes=Cc(e,s,n),t.memoizedState=xc,dc(null,r)):(ro(t),Tc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(ro(t),t.flags&=-257,t=Dc(e,t,n)):t.memoizedState===null?(oo(t),c=r.fallback,a=t.mode,r=Ec({mode:`visible`,children:r.children},a),c=di(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Ia(t,e.child,null,n),r=t.child,r.memoizedState=Sc(n),r.childLanes=Cc(e,s,n),t.memoizedState=xc,t=dc(null,r)):(oo(t),t.child=e.child,t.flags|=128,t=null);else if(ro(t),gf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Ui({value:r,source:null,stack:null}),t=Dc(e,t,n)}else if(ac||Yi(e,t,n,!1),s=(n&e.childLanes)!==0,ac||s){if(s=Wl,s!==null&&(r=et(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,ri(e,r),wu(s,e,r),ic;hf(c)||Fu(),t=Dc(e,t,n)}else hf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Mi=vf(c.nextSibling),ji=t,Ni=!0,Pi=null,Fi=!1,e!==null&&Ai(t,e),t=Tc(t,r.children),t.flags|=4096);return t}return a?(oo(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=R(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=di(c,a,n,null),c.flags|=2):c=R(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,dc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=Sc(n):(a=c.cachePool,a===null?a=ya():(l=aa._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=Cc(e,s,n),t.memoizedState=xc,dc(e.child,r)):(ro(t),n=e.child,e=n.sibling,n=R(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function Tc(e,t){return t=Ec({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Ec(e,t){return e=si(22,e,null,t),e.lanes=0,e}function Dc(e,t,n){return Ia(t,e.child,null,n),e=Tc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Oc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),qi(e.return,t,n)}function kc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Ac(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=co.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,oe(co,o),oc(e,t,r,n),r=Ni?bi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Oc(e,n,t);else if(e.tag===19)Oc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&lo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),kc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&lo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}kc(t,!0,n,null,a,r);break;case`together`:kc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function jc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),eu|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(Yi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=R(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=R(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Mc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Xi(e))):!0}function Nc(e,t,n){switch(t.tag){case 3:de(t,t.stateNode.containerInfo),Ki(t,aa,e.memoizedState.cache),Vi();break;case 27:case 5:pe(t);break;case 4:de(t,t.stateNode.containerInfo);break;case 10:Ki(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,io(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(ro(t),e=jc(e,t,n),e===null?null:e.sibling):wc(e,t,n):(ro(t),t.flags|=128,null);ro(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(Yi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Ac(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),oe(co,co.current),r)break;return null;case 22:return t.lanes=0,uc(e,t,n,t.pendingProps);case 24:Ki(t,aa,e.memoizedState.cache)}return jc(e,t,n)}function Pc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)ac=!0;else{if(!Mc(e,n)&&!(t.flags&128))return ac=!1,Nc(e,t,n);ac=!!(e.flags&131072)}else ac=!1,Ni&&t.flags&1048576&&Di(t,bi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Ea(t.elementType),t.type=e,typeof e==`function`)ci(e)?(r=Js(e,r),t.tag=1,t=yc(null,t,e,r,n)):(t.tag=0,t=_c(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===S){t.tag=11,t=sc(null,t,e,r,n);break a}else if(a===T){t.tag=14,t=cc(null,t,e,r,n);break a}}throw t=M(e)||e,Error(i(306,t,``))}}return t;case 0:return _c(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Js(r,t.pendingProps),yc(e,t,r,a,n);case 3:a:{if(de(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Ba(e,t),qa(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Ki(t,aa,r),r!==o.cache&&Ji(t,[aa],n,!0),Ka(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=bc(e,t,r,n);break a}else if(r!==a){a=gi(Error(i(424)),t),Ui(a),t=bc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Mi=vf(e.firstChild),ji=t,Ni=!0,Pi=null,Fi=!0,n=La(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Vi(),r===a){t=jc(e,t,n);break a}oc(e,t,r,n)}t=t.child}return t;case 26:return gc(e,t),e===null?(n=zf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Ni||(n=t.type,e=t.pendingProps,r=Xd(le.current).createElement(n),r[ot]=t,r[st]=e,Wd(r,n,e),yt(r),t.stateNode=r):t.memoizedState=zf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return pe(t),e===null&&Ni&&(r=t.stateNode=Sf(t.type,t.pendingProps,le.current),ji=t,Fi=!0,a=Mi,cf(t.type)?(yf=a,Mi=vf(r.firstChild)):Mi=a),oc(e,t,t.pendingProps.children,n),gc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ni&&((a=r=Mi)&&(r=ff(r,t.type,t.pendingProps,Fi),r===null?a=!1:(t.stateNode=r,ji=t,Mi=vf(r.firstChild),Fi=!1,a=!0)),a||Li(t)),pe(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,$d(a,o)?r=null:s!==null&&$d(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=wo(e,t,Do,null,null,n),cp._currentValue=a),gc(e,t),oc(e,t,r,n),t.child;case 6:return e===null&&Ni&&((e=n=Mi)&&(n=pf(n,t.pendingProps,Fi),n===null?e=!1:(t.stateNode=n,ji=t,Mi=null,e=!0)),e||Li(t)),null;case 13:return wc(e,t,n);case 4:return de(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ia(t,null,r,n):oc(e,t,r,n),t.child;case 11:return sc(e,t,t.type,t.pendingProps,n);case 7:return oc(e,t,t.pendingProps,n),t.child;case 8:return oc(e,t,t.pendingProps.children,n),t.child;case 12:return oc(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Ki(t,t.type,r.value),oc(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Qi(t),a=$i(a),r=r(a),t.flags|=1,oc(e,t,r,n),t.child;case 14:return cc(e,t,t.type,t.pendingProps,n);case 15:return lc(e,t,t.type,t.pendingProps,n);case 19:return Ac(e,t,n);case 31:return hc(e,t,n);case 22:return uc(e,t,n,t.pendingProps);case 24:return Qi(t),r=$i(aa),e===null?(a=_a(),a===null&&(a=Wl,o=oa(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},za(t),Ki(t,aa,a)):((e.lanes&n)!==0&&(Ba(e,t),qa(t,null,null,n),Ka()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Ki(t,aa,r),r!==a.cache&&Ji(t,[aa],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Ki(t,aa,r))),oc(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Fc(e){e.flags|=4}function Ic(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(Mu())e.flags|=8192;else throw Da=Ca,xa}else e.flags&=-16777217}function Lc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!ep(t))if(Mu())e.flags|=8192;else throw Da=Ca,xa}function Rc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Ye(),e.lanes|=t,iu|=t)}function zc(e,t){if(!Ni)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Bc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Vc(e,t,n){var r=t.pendingProps;switch(ki(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Bc(t),null;case 1:return Bc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),B(aa),fe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Bi(t)?Fc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Hi())),Bc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Fc(t),o===null?(Bc(t),Ic(t,a,null,r,n)):(Bc(t),Lc(t,o))):o?o===e.memoizedState?(Bc(t),t.flags&=-16777217):(Fc(t),Bc(t),Lc(t,o)):(e=e.memoizedProps,e!==r&&Fc(t),Bc(t),Ic(t,a,e,r,n)),null;case 27:if(me(t),n=le.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Fc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Bc(t),null}e=se.current,Bi(t)?Ri(t,e):(e=Sf(a,r,n),t.stateNode=e,Fc(t))}return Bc(t),null;case 5:if(me(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Fc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Bc(t),null}if(o=se.current,Bi(t))Ri(t,o);else{var s=Xd(le.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[ot]=t,o[st]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Wd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Fc(t)}}return Bc(t),Ic(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Fc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=le.current,Bi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=ji,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[ot]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Vd(e.nodeValue,n)),e||Li(t,!0)}else e=Xd(e).createTextNode(r),e[ot]=t,t.stateNode=e}return Bc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Bi(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[ot]=t}else Vi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Bc(t),e=!1}else n=Hi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(so(t),t):(so(t),null);if(t.flags&128)throw Error(i(558))}return Bc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Bi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[ot]=t}else Vi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Bc(t),a=!1}else a=Hi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(so(t),t):(so(t),null)}return so(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Rc(t,t.updateQueue),Bc(t),null);case 4:return fe(),e===null&&H(t.stateNode.containerInfo),Bc(t),null;case 10:return B(t.type),Bc(t),null;case 19:if(ae(co),r=t.memoizedState,r===null)return Bc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)zc(r,!1);else{if($l!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=lo(e),o!==null){for(t.flags|=128,zc(r,!1),e=o.updateQueue,t.updateQueue=e,Rc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)li(n,e),n=n.sibling;return oe(co,co.current&1|2),Ni&&Ei(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&De()>uu&&(t.flags|=128,a=!0,zc(r,!1),t.lanes=4194304)}else{if(!a)if(e=lo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Rc(t,e),zc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Ni)return Bc(t),null}else 2*De()-r.renderingStartTime>uu&&n!==536870912&&(t.flags|=128,a=!0,zc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Bc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=De(),e.sibling=null,n=co.current,oe(co,a?n&1|2:n&1),Ni&&Ei(t,r.treeForkCount),e);case 22:case 23:return so(t),eo(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Bc(t),t.subtreeFlags&6&&(t.flags|=8192)):Bc(t),n=t.updateQueue,n!==null&&Rc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&ae(ga),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),B(aa),Bc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Hc(e,t){switch(ki(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return B(aa),fe(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return me(t),null;case 31:if(t.memoizedState!==null){if(so(t),t.alternate===null)throw Error(i(340));Vi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(so(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Vi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ae(co),null;case 4:return fe(),null;case 10:return B(t.type),null;case 22:case 23:return so(t),eo(),e!==null&&ae(ga),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return B(aa),null;case 25:return null;default:return null}}function Uc(e,t){switch(ki(t),t.tag){case 3:B(aa),fe();break;case 26:case 27:case 5:me(t);break;case 4:fe();break;case 31:t.memoizedState!==null&&so(t);break;case 13:so(t);break;case 19:ae(co);break;case 10:B(t.type);break;case 22:case 23:so(t),eo(),e!==null&&ae(ga);break;case 24:B(aa)}}function Wc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){$u(t,t.return,e)}}function Gc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){$u(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){$u(t,t.return,e)}}function Kc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ya(t,n)}catch(t){$u(e,e.return,t)}}}function qc(e,t,n){n.props=Js(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){$u(e,t,n)}}function Jc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){$u(e,t,n)}}function Yc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){$u(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){$u(e,t,n)}else n.current=null}function Xc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){$u(e,e.return,t)}}function Zc(e,t,n){try{var r=e.stateNode;Gd(r,e.type,n,t),r[st]=t}catch(t){$u(e,e.return,t)}}function Qc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&cf(e.type)||e.tag===4}function $c(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Qc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&cf(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function el(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=$t));else if(r!==4&&(r===27&&cf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(el(e,t,n),e=e.sibling;e!==null;)el(e,t,n),e=e.sibling}function tl(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&cf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(tl(e,t,n),e=e.sibling;e!==null;)tl(e,t,n),e=e.sibling}function nl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Wd(t,r,n),t[ot]=e,t[st]=n}catch(t){$u(e,e.return,t)}}var rl=!1,il=!1,al=!1,ol=typeof WeakSet==`function`?WeakSet:Set,sl=null;function cl(e,t){if(e=e.containerInfo,Jd=_p,e=Dr(e),Or(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Yd={focusedElem:e,selectionRange:n},_p=!1,sl=t;sl!==null;)if(t=sl,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,sl=e;else for(;sl!==null;){switch(t=sl,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Js(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){$u(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)df(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:df(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,sl=e;break}sl=t.return}}function ll(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:wl(e,n),r&4&&Wc(5,n);break;case 1:if(wl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){$u(n,n.return,e)}else{var i=Js(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){$u(n,n.return,e)}}r&64&&Kc(n),r&512&&Jc(n,n.return);break;case 3:if(wl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Ya(e,t)}catch(e){$u(n,n.return,e)}}break;case 27:t===null&&r&4&&nl(n);case 26:case 5:wl(e,n),t===null&&r&4&&Xc(n),r&512&&Jc(n,n.return);break;case 12:wl(e,n);break;case 31:wl(e,n),r&4&&hl(e,n);break;case 13:wl(e,n),r&4&&gl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=rd.bind(null,n),_f(e,n))));break;case 22:if(r=n.memoizedState!==null||rl,!r){t=t!==null&&t.memoizedState!==null||il,i=rl;var a=il;rl=r,(il=t)&&!a?El(e,n,(n.subtreeFlags&8772)!=0):wl(e,n),rl=i,il=a}break;case 30:break;default:wl(e,n)}}function ul(e){var t=e.alternate;t!==null&&(e.alternate=null,ul(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&mt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var dl=null,fl=!1;function pl(e,t,n){for(n=n.child;n!==null;)ml(e,t,n),n=n.sibling}function ml(e,t,n){if(Le&&typeof Le.onCommitFiberUnmount==`function`)try{Le.onCommitFiberUnmount(Ie,n)}catch{}switch(n.tag){case 26:il||Yc(n,t),pl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:il||Yc(n,t);var r=dl,i=fl;cf(n.type)&&(dl=n.stateNode,fl=!1),pl(e,t,n),Cf(n.stateNode),dl=r,fl=i;break;case 5:il||Yc(n,t);case 6:if(r=dl,i=fl,dl=null,pl(e,t,n),dl=r,fl=i,dl!==null)if(fl)try{(dl.nodeType===9?dl.body:dl.nodeName===`HTML`?dl.ownerDocument.body:dl).removeChild(n.stateNode)}catch(e){$u(n,t,e)}else try{dl.removeChild(n.stateNode)}catch(e){$u(n,t,e)}break;case 18:dl!==null&&(fl?(e=dl,lf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Up(e)):lf(dl,n.stateNode));break;case 4:r=dl,i=fl,dl=n.stateNode.containerInfo,fl=!0,pl(e,t,n),dl=r,fl=i;break;case 0:case 11:case 14:case 15:Gc(2,n,t),il||Gc(4,n,t),pl(e,t,n);break;case 1:il||(Yc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&qc(n,t,r)),pl(e,t,n);break;case 21:pl(e,t,n);break;case 22:il=(r=il)||n.memoizedState!==null,pl(e,t,n),il=r;break;default:pl(e,t,n)}}function hl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Up(e)}catch(e){$u(t,t.return,e)}}}function gl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Up(e)}catch(e){$u(t,t.return,e)}}function _l(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new ol),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new ol),t;default:throw Error(i(435,e.tag))}}function vl(e,t){var n=_l(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=id.bind(null,e,t);t.then(r,r)}})}function yl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(cf(c.type)){dl=c.stateNode,fl=!1;break a}break;case 5:dl=c.stateNode,fl=!1;break a;case 3:case 4:dl=c.stateNode.containerInfo,fl=!0;break a}c=c.return}if(dl===null)throw Error(i(160));ml(o,s,a),dl=null,fl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)xl(t,e),t=t.sibling}var bl=null;function xl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:yl(t,e),Sl(e),r&4&&(Gc(3,e,e.return),Wc(3,e),Gc(5,e,e.return));break;case 1:yl(t,e),Sl(e),r&512&&(il||n===null||Yc(n,n.return)),r&64&&rl&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=bl;if(yl(t,e),Sl(e),r&512&&(il||n===null||Yc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[pt]||o[ot]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Wd(o,r,n),o[ot]=e,yt(o),r=o;break a;case`link`:var s=Zf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Wd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Zf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Wd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[ot]=e,yt(o),r=o}e.stateNode=r}else Qf(a,e.type,e.stateNode);else e.stateNode=Kf(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&Zc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Qf(a,e.type,e.stateNode):Kf(a,r,e.memoizedProps))}break;case 27:yl(t,e),Sl(e),r&512&&(il||n===null||Yc(n,n.return)),n!==null&&r&4&&Zc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(yl(t,e),Sl(e),r&512&&(il||n===null||Yc(n,n.return)),e.flags&32){a=e.stateNode;try{Gt(a,``)}catch(t){$u(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Zc(e,a,n===null?a:n.memoizedProps)),r&1024&&(al=!0);break;case 6:if(yl(t,e),Sl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){$u(e,e.return,t)}}break;case 3:if(Xf=null,a=bl,bl=Ef(t.containerInfo),yl(t,e),bl=a,Sl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Up(t.containerInfo)}catch(t){$u(e,e.return,t)}al&&(al=!1,Cl(e));break;case 4:r=bl,bl=Ef(e.stateNode.containerInfo),yl(t,e),Sl(e),bl=r;break;case 12:yl(t,e),Sl(e);break;case 31:yl(t,e),Sl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,vl(e,r)));break;case 13:yl(t,e),Sl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(cu=De()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,vl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=rl,d=il;if(rl=u||a,il=d||l,yl(t,e),il=d,rl=u,Sl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||rl||il||Tl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){$u(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){$u(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?uf(m,!0):uf(l.stateNode,!1)}catch(e){$u(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,vl(e,n))));break;case 19:yl(t,e),Sl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,vl(e,r)));break;case 30:break;case 21:break;default:yl(t,e),Sl(e)}}function Sl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Qc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;tl(e,$c(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Gt(o,``),n.flags&=-33),tl(e,$c(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;el(e,$c(e),s);break;default:throw Error(i(161))}}catch(t){$u(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Cl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Cl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function wl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)ll(e,t.alternate,t),t=t.sibling}function Tl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Gc(4,t,t.return),Tl(t);break;case 1:Yc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&qc(t,t.return,n),Tl(t);break;case 27:Cf(t.stateNode);case 26:case 5:Yc(t,t.return),Tl(t);break;case 22:t.memoizedState===null&&Tl(t);break;case 30:Tl(t);break;default:Tl(t)}e=e.sibling}}function El(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:El(i,a,n),Wc(4,a);break;case 1:if(El(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){$u(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ja(c[i],s)}catch(e){$u(r,r.return,e)}}n&&o&64&&Kc(a),Jc(a,a.return);break;case 27:nl(a);case 26:case 5:El(i,a,n),n&&r===null&&o&4&&Xc(a),Jc(a,a.return);break;case 12:El(i,a,n);break;case 31:El(i,a,n),n&&o&4&&hl(i,a);break;case 13:El(i,a,n),n&&o&4&&gl(i,a);break;case 22:a.memoizedState===null&&El(i,a,n),Jc(a,a.return);break;case 30:break;default:El(i,a,n)}t=t.sibling}}function Dl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&sa(n))}function Ol(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&sa(e))}function kl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Al(e,t,n,r),t=t.sibling}function Al(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:kl(e,t,n,r),i&2048&&Wc(9,t);break;case 1:kl(e,t,n,r);break;case 3:kl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&sa(e)));break;case 12:if(i&2048){kl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){$u(t,t.return,e)}}else kl(e,t,n,r);break;case 31:kl(e,t,n,r);break;case 13:kl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?kl(e,t,n,r):(a._visibility|=2,jl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?kl(e,t,n,r):Ml(e,t),i&2048&&Dl(o,t);break;case 24:kl(e,t,n,r),i&2048&&Ol(t.alternate,t);break;default:kl(e,t,n,r)}}function jl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:jl(a,o,s,c,i),Wc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,jl(a,o,s,c,i)):u._visibility&2?jl(a,o,s,c,i):Ml(a,o),i&&l&2048&&Dl(o.alternate,o);break;case 24:jl(a,o,s,c,i),i&&l&2048&&Ol(o.alternate,o);break;default:jl(a,o,s,c,i)}t=t.sibling}}function Ml(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Ml(n,r),i&2048&&Dl(r.alternate,r);break;case 24:Ml(n,r),i&2048&&Ol(r.alternate,r);break;default:Ml(n,r)}t=t.sibling}}var Nl=8192;function Pl(e,t,n){if(e.subtreeFlags&Nl)for(e=e.child;e!==null;)Fl(e,t,n),e=e.sibling}function Fl(e,t,n){switch(e.tag){case 26:Pl(e,t,n),e.flags&Nl&&e.memoizedState!==null&&tp(n,bl,e.memoizedState,e.memoizedProps);break;case 5:Pl(e,t,n);break;case 3:case 4:var r=bl;bl=Ef(e.stateNode.containerInfo),Pl(e,t,n),bl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Nl,Nl=16777216,Pl(e,t,n),Nl=r):Pl(e,t,n));break;default:Pl(e,t,n)}}function Il(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Ll(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];sl=r,Bl(r,e)}Il(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Rl(e),e=e.sibling}function Rl(e){switch(e.tag){case 0:case 11:case 15:Ll(e),e.flags&2048&&Gc(9,e,e.return);break;case 3:Ll(e);break;case 12:Ll(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,zl(e)):Ll(e);break;default:Ll(e)}}function zl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];sl=r,Bl(r,e)}Il(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Gc(8,t,t.return),zl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,zl(t));break;default:zl(t)}e=e.sibling}}function Bl(e,t){for(;sl!==null;){var n=sl;switch(n.tag){case 0:case 11:case 15:Gc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:sa(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,sl=r;else a:for(n=e;sl!==null;){r=sl;var i=r.sibling,a=r.return;if(ul(r),r===n){sl=null;break a}if(i!==null){i.return=a,sl=i;break a}sl=a}}}var Vl={getCacheForType:function(e){var t=$i(aa),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return $i(aa).controller.signal}},Hl=typeof WeakMap==`function`?WeakMap:Map,Ul=0,Wl=null,Gl=null,Kl=0,ql=0,Jl=null,Yl=!1,Xl=!1,Zl=!1,Ql=0,$l=0,eu=0,tu=0,nu=0,ru=0,iu=0,au=null,ou=null,su=!1,cu=0,lu=0,uu=1/0,du=null,fu=null,pu=0,mu=null,hu=null,gu=0,_u=0,vu=null,yu=null,bu=0,xu=null;function Su(){return Ul&2&&Kl!==0?Kl&-Kl:N.T===null?rt():bd()}function Cu(){if(ru===0)if(!(Kl&536870912)||Ni){var e=We;We<<=1,!(We&3932160)&&(We=262144),ru=e}else ru=536870912;return e=to.current,e!==null&&(e.flags|=32),ru}function wu(e,t,n){(e===Wl&&(ql===2||ql===9)||e.cancelPendingCommit!==null)&&(Au(e,0),Du(e,Kl,ru,!1)),Ze(e,n),(!(Ul&2)||e!==Wl)&&(e===Wl&&(!(Ul&2)&&(tu|=n),$l===4&&Du(e,Kl,ru,!1)),fd(e))}function Tu(e,t,n){if(Ul&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||Je(e,t),a=r?Ru(e,t):Iu(e,t,!0),o=r;do{if(a===0){Xl&&!r&&Du(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!Eu(n)){a=Iu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=au;var l=c.current.memoizedState.isDehydrated;if(l&&(Au(c,s).flags|=256),s=Iu(c,s,!1),s!==2){if(Zl&&!l){c.errorRecoveryDisabledLanes|=o,tu|=o,a=4;break a}o=ou,ou=a,o!==null&&(ou===null?ou=o:ou.push.apply(ou,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Au(e,0),Du(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:Du(r,t,ru,!Yl);break a;case 2:ou=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=cu+300-De(),10<a)){if(Du(r,t,ru,!Yl),qe(r,0,!0)!==0)break a;gu=t,r.timeoutHandle=nf(V.bind(null,r,n,ou,du,su,t,ru,tu,iu,Yl,o,`Throttled`,-0,0),a);break a}V(r,n,ou,du,su,t,ru,tu,iu,Yl,o,null,-0,0)}}break}while(1);fd(e)}function V(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:$t},Fl(t,a,d);var m=(a&62914560)===a?cu-De():(a&4194048)===a?lu-De():0;if(m=rp(d,m),m!==null){gu=a,e.cancelPendingCommit=m(Gu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),Du(e,a,o,!l);return}}Gu(e,t,a,n,r,i,o,s,c)}function Eu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Sr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Du(e,t,n,r){t&=~nu,t&=~tu,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-ze(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&$e(e,n,t)}function Ou(){return Ul&6?!0:(pd(0,!1),!1)}function ku(){if(Gl!==null){if(ql===0)var e=Gl.return;else e=Gl,Gi=z=null,Ao(e),Aa=null,ja=0,e=Gl;for(;e!==null;)Uc(e.alternate,e),e=e.return;Gl=null}}function Au(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,rf(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),gu=0,ku(),Wl=e,Gl=n=R(e.current,null),Kl=t,ql=0,Jl=null,Yl=!1,Xl=Je(e,t),Zl=!1,iu=ru=nu=tu=eu=$l=0,ou=au=null,su=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-ze(r),a=1<<i;t|=e[i],r&=~a}return Ql=t,ei(),n}function ju(e,t){fo=null,N.H=Bs,t===ba||t===Sa?(t=Oa(),ql=3):t===xa?(t=Oa(),ql=4):ql=t===ic?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Jl=t,Gl===null&&($l=1,Qs(e,gi(t,e.current)))}function Mu(){var e=to.current;return e===null?!0:(Kl&4194048)===Kl?no===null:(Kl&62914560)===Kl||Kl&536870912?e===no:!1}function Nu(){var e=N.H;return N.H=Bs,e===null?Bs:e}function Pu(){var e=N.A;return N.A=Vl,e}function Fu(){$l=4,Yl||(Kl&4194048)!==Kl&&to.current!==null||(Xl=!0),!(eu&134217727)&&!(tu&134217727)||Wl===null||Du(Wl,Kl,ru,!1)}function Iu(e,t,n){var r=Ul;Ul|=2;var i=Nu(),a=Pu();(Wl!==e||Kl!==t)&&(du=null,Au(e,t)),t=!1;var o=$l;a:do try{if(ql!==0&&Gl!==null){var s=Gl,c=Jl;switch(ql){case 8:ku(),o=6;break a;case 3:case 2:case 9:case 6:to.current===null&&(t=!0);var l=ql;if(ql=0,Jl=null,Hu(e,s,c,l),n&&Xl){o=0;break a}break;default:l=ql,ql=0,Jl=null,Hu(e,s,c,l)}}Lu(),o=$l;break}catch(t){ju(e,t)}while(1);return t&&e.shellSuspendCounter++,Gi=z=null,Ul=r,N.H=i,N.A=a,Gl===null&&(Wl=null,Kl=0,ei()),o}function Lu(){for(;Gl!==null;)Bu(Gl)}function Ru(e,t){var n=Ul;Ul|=2;var r=Nu(),a=Pu();Wl!==e||Kl!==t?(du=null,uu=De()+500,Au(e,t)):Xl=Je(e,t);a:do try{if(ql!==0&&Gl!==null){t=Gl;var o=Jl;b:switch(ql){case 1:ql=0,Jl=null,Hu(e,t,o,1);break;case 2:case 9:if(wa(o)){ql=0,Jl=null,Vu(t);break}t=function(){ql!==2&&ql!==9||Wl!==e||(ql=7),fd(e)},o.then(t,t);break a;case 3:ql=7;break a;case 4:ql=5;break a;case 7:wa(o)?(ql=0,Jl=null,Vu(t)):(ql=0,Jl=null,Hu(e,t,o,7));break;case 5:var s=null;switch(Gl.tag){case 26:s=Gl.memoizedState;case 5:case 27:var c=Gl;if(s?ep(s):c.stateNode.complete){ql=0,Jl=null;var l=c.sibling;if(l!==null)Gl=l;else{var u=c.return;u===null?Gl=null:(Gl=u,Uu(u))}break b}}ql=0,Jl=null,Hu(e,t,o,5);break;case 6:ql=0,Jl=null,Hu(e,t,o,6);break;case 8:ku(),$l=6;break a;default:throw Error(i(462))}}zu();break}catch(t){ju(e,t)}while(1);return Gi=z=null,N.H=r,N.A=a,Ul=n,Gl===null?(Wl=null,Kl=0,ei(),$l):0}function zu(){for(;Gl!==null&&!Te();)Bu(Gl)}function Bu(e){var t=Pc(e.alternate,e,Ql);e.memoizedProps=e.pendingProps,t===null?Uu(e):Gl=t}function Vu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=vc(n,t,t.pendingProps,t.type,void 0,Kl);break;case 11:t=vc(n,t,t.pendingProps,t.type.render,t.ref,Kl);break;case 5:Ao(t);default:Uc(n,t),t=Gl=li(t,Ql),t=Pc(n,t,Ql)}e.memoizedProps=e.pendingProps,t===null?Uu(e):Gl=t}function Hu(e,t,n,r){Gi=z=null,Ao(t),Aa=null,ja=0;var i=t.return;try{if(rc(e,i,t,n,Kl)){$l=1,Qs(e,gi(n,e.current)),Gl=null;return}}catch(t){if(i!==null)throw Gl=i,t;$l=1,Qs(e,gi(n,e.current)),Gl=null;return}t.flags&32768?(Ni||r===1?e=!0:Xl||Kl&536870912?e=!1:(Yl=e=!0,(r===2||r===9||r===3||r===6)&&(r=to.current,r!==null&&r.tag===13&&(r.flags|=16384))),Wu(t,e)):Uu(t)}function Uu(e){var t=e;do{if(t.flags&32768){Wu(t,Yl);return}e=t.return;var n=Vc(t.alternate,t,Ql);if(n!==null){Gl=n;return}if(t=t.sibling,t!==null){Gl=t;return}Gl=t=e}while(t!==null);$l===0&&($l=5)}function Wu(e,t){do{var n=Hc(e.alternate,e);if(n!==null){n.flags&=32767,Gl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Gl=e;return}Gl=e=n}while(e!==null);$l=6,Gl=null}function Gu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Xu();while(pu!==0);if(Ul&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=$r,Qe(e,n,o,s,c,l),e===Wl&&(Gl=Wl=null,Kl=0),hu=t,mu=e,gu=n,_u=o,vu=a,yu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,ad(je,function(){return Zu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=N.T,N.T=null,a=P.p,P.p=2,s=Ul,Ul|=4;try{cl(e,t,n)}finally{Ul=s,P.p=a,N.T=r}}pu=1,Ku(),qu(),Ju()}}function Ku(){if(pu===1){pu=0;var e=mu,t=hu,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=N.T,N.T=null;var r=P.p;P.p=2;var i=Ul;Ul|=4;try{xl(t,e);var a=Yd,o=Dr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&Er(s.ownerDocument.documentElement,s)){if(c!==null&&Or(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Tr(s,h),v=Tr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}_p=!!Jd,Yd=Jd=null}finally{Ul=i,P.p=r,N.T=n}}e.current=t,pu=2}}function qu(){if(pu===2){pu=0;var e=mu,t=hu,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=N.T,N.T=null;var r=P.p;P.p=2;var i=Ul;Ul|=4;try{ll(e,t.alternate,t)}finally{Ul=i,P.p=r,N.T=n}}pu=3}}function Ju(){if(pu===4||pu===3){pu=0,Ee();var e=mu,t=hu,n=gu,r=yu;t.subtreeFlags&10256||t.flags&10256?pu=5:(pu=0,hu=mu=null,Yu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(fu=null),nt(n),t=t.stateNode,Le&&typeof Le.onCommitFiberRoot==`function`)try{Le.onCommitFiberRoot(Ie,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=N.T,i=P.p,P.p=2,N.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{N.T=t,P.p=i}}gu&3&&Xu(),fd(e),i=e.pendingLanes,n&261930&&i&42?e===xu?bu++:(bu=0,xu=e):bu=0,pd(0,!1)}}function Yu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,sa(t)))}function Xu(){return Ku(),qu(),Ju(),Zu()}function Zu(){if(pu!==5)return!1;var e=mu,t=_u;_u=0;var n=nt(gu),r=N.T,a=P.p;try{P.p=32>n?32:n,N.T=null,n=vu,vu=null;var o=mu,s=gu;if(pu=0,hu=mu=null,gu=0,Ul&6)throw Error(i(331));var c=Ul;if(Ul|=4,Rl(o.current),Al(o,o.current,s,n),Ul=c,pd(0,!1),Le&&typeof Le.onPostCommitFiberRoot==`function`)try{Le.onPostCommitFiberRoot(Ie,o)}catch{}return!0}finally{P.p=a,N.T=r,Yu(e,t)}}function Qu(e,t,n){t=gi(n,t),t=ec(e.stateNode,t,2),e=Ha(e,t,2),e!==null&&(Ze(e,2),fd(e))}function $u(e,t,n){if(e.tag===3)Qu(e,e,n);else for(;t!==null;){if(t.tag===3){Qu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(fu===null||!fu.has(r))){e=gi(n,e),n=tc(2),r=Ha(t,n,2),r!==null&&(nc(n,r,t,e),Ze(r,2),fd(r));break}}t=t.return}}function ed(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Hl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Zl=!0,i.add(n),e=td.bind(null,e,t,n),t.then(e,e))}function td(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Wl===e&&(Kl&n)===n&&($l===4||$l===3&&(Kl&62914560)===Kl&&300>De()-cu?!(Ul&2)&&Au(e,0):nu|=n,iu===Kl&&(iu=0)),fd(e)}function nd(e,t){t===0&&(t=Ye()),e=ri(e,t),e!==null&&(Ze(e,t),fd(e))}function rd(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),nd(e,n)}function id(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),nd(e,n)}function ad(e,t){return Ce(e,t)}var od=null,sd=null,cd=!1,ld=!1,ud=!1,dd=0;function fd(e){e!==sd&&e.next===null&&(sd===null?od=sd=e:sd=sd.next=e),ld=!0,cd||(cd=!0,yd())}function pd(e,t){if(!ud&&ld){ud=!0;do for(var n=!1,r=od;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-ze(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,vd(r,a))}else a=Kl,a=qe(r,r===Wl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Je(r,a)||(n=!0,vd(r,a));r=r.next}while(n);ud=!1}}function md(){hd()}function hd(){ld=cd=!1;var e=0;dd!==0&&tf()&&(e=dd);for(var t=De(),n=null,r=od;r!==null;){var i=r.next,a=gd(r,t);a===0?(r.next=null,n===null?od=i:n.next=i,i===null&&(sd=n)):(n=r,(e!==0||a&3)&&(ld=!0)),r=i}pu!==0&&pu!==5||pd(e,!1),dd!==0&&(dd=0)}function gd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-ze(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=F(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Wl,n=Kl,n=qe(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(ql===2||ql===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&we(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Je(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&we(r),nt(n)){case 2:case 8:n=Ae;break;case 32:n=je;break;case 268435456:n=Ne;break;default:n=je}return r=_d.bind(null,e),n=Ce(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&we(r),e.callbackPriority=2,e.callbackNode=null,2}function _d(e,t){if(pu!==0&&pu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Xu()&&e.callbackNode!==n)return null;var r=Kl;return r=qe(e,e===Wl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Tu(e,r,t),gd(e,De()),e.callbackNode!=null&&e.callbackNode===n?_d.bind(null,e):null)}function vd(e,t){if(Xu())return null;Tu(e,t,!0)}function yd(){of(function(){Ul&6?Ce(ke,md):hd()})}function bd(){if(dd===0){var e=ua;e===0&&(e=Ue,Ue<<=1,!(Ue&261888)&&(Ue=256)),dd=e}return dd}function xd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Qt(``+e)}function Sd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function Cd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=xd((i[st]||null).action),o=r.submitter;o&&(t=(t=o[st]||null)?xd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new xn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(dd!==0){var e=o?Sd(i,o):new FormData(i);Es(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?Sd(i,o):new FormData(i),Es(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var wd=0;wd<Jr.length;wd++){var Td=Jr[wd];Yr(Td.toLowerCase(),`on`+(Td[0].toUpperCase()+Td.slice(1)))}Yr(Br,`onAnimationEnd`),Yr(Vr,`onAnimationIteration`),Yr(Hr,`onAnimationStart`),Yr(`dblclick`,`onDoubleClick`),Yr(`focusin`,`onFocus`),Yr(`focusout`,`onBlur`),Yr(Ur,`onTransitionRun`),Yr(Wr,`onTransitionStart`),Yr(Gr,`onTransitionCancel`),Yr(Kr,`onTransitionEnd`),Ct(`onMouseEnter`,[`mouseout`,`mouseover`]),Ct(`onMouseLeave`,[`mouseout`,`mouseover`]),Ct(`onPointerEnter`,[`pointerout`,`pointerover`]),Ct(`onPointerLeave`,[`pointerout`,`pointerover`]),St(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),St(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),St(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),St(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),St(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),St(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Ed=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Dd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Ed));function Od(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Xr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Xr(e)}i.currentTarget=null,a=c}}}}function kd(e,t){var n=t[lt];n===void 0&&(n=t[lt]=new Set);var r=e+`__bubble`;n.has(r)||(Md(t,e,2,!1),n.add(r))}function Ad(e,t,n){var r=0;t&&(r|=4),Md(n,e,r,t)}var jd=`_reactListening`+Math.random().toString(36).slice(2);function H(e){if(!e[jd]){e[jd]=!0,bt.forEach(function(t){t!==`selectionchange`&&(Dd.has(t)||Ad(t,!1,e),Ad(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[jd]||(t[jd]=!0,Ad(`selectionchange`,!1,t))}}function Md(e,t,n,r){switch(wp(t)){case 2:var i=vp;break;case 8:i=yp;break;default:i=bp}n=i.bind(null,t,n,e),i=void 0,!un||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Nd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=ht(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}sn(function(){var r=a,i=tn(n),s=[];a:{var c=qr.get(e);if(c!==void 0){var l=xn,u=e;switch(e){case`keypress`:if(gn(n)===0)break a;case`keydown`:case`keyup`:l=zn;break;case`focusin`:u=`focus`,l=An;break;case`focusout`:u=`blur`,l=An;break;case`beforeblur`:case`afterblur`:l=An;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=On;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=kn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Vn;break;case Br:case Vr:case Hr:l=jn;break;case Kr:l=Hn;break;case`scroll`:case`scrollend`:l=Cn;break;case`wheel`:l=Un;break;case`copy`:case`cut`:case`paste`:l=Mn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Bn;break;case`toggle`:case`beforetoggle`:l=Wn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=cn(m,p),g!=null&&d.push(Pd(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==en&&(u=n.relatedTarget||n.fromElement)&&(ht(u)||u[ct]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?ht(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=On,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Bn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:_t(l),h=u==null?c:_t(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,ht(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Id,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Ld(s,c,l,d,!1),u!==null&&f!==null&&Ld(s,f,u,d,!0)}}a:{if(c=r?_t(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=ur;else if(ir(c))if(dr)v=br;else{v=vr;var y=_r}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Yt(r.elementType)&&(v=ur):v=yr;if(v&&=v(e,r)){ar(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Vt(c,`number`,c.value)}switch(y=r?_t(r):window,e){case`focusin`:(ir(y)||y.contentEditable===`true`)&&(Ar=y,jr=r,Mr=null);break;case`focusout`:Mr=jr=Ar=null;break;case`mousedown`:Nr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Nr=!1,Pr(s,n,i);break;case`selectionchange`:if(kr)break;case`keydown`:case`keyup`:Pr(s,n,i)}var b;if(Kn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else er?Qn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Yn&&n.locale!==`ko`&&(er||x!==`onCompositionStart`?x===`onCompositionEnd`&&er&&(b=hn()):(fn=i,pn=`value`in fn?fn.value:fn.textContent,er=!0)),y=Fd(r,x),0<y.length&&(x=new Nn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=$n(n),b!==null&&(x.data=b)))),(b=Jn?tr(e,n):nr(e,n))&&(x=Fd(r,`onBeforeInput`),0<x.length&&(y=new Nn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),Cd(s,e,r,n,i)}Od(s,t)})}function Pd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Fd(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=cn(e,n),i!=null&&r.unshift(Pd(e,i,a)),i=cn(e,t),i!=null&&r.push(Pd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Id(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Ld(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=cn(n,a),l!=null&&o.unshift(Pd(n,l,c))):i||(l=cn(n,a),l!=null&&o.push(Pd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Rd=/\r\n?/g,zd=/\u0000|\uFFFD/g;function Bd(e){return(typeof e==`string`?e:``+e).replace(Rd,`
219
- `).replace(zd,``)}function Vd(e,t){return t=Bd(t),Bd(e)===t}function Hd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Gt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Gt(e,``+r);break;case`className`:kt(e,`class`,r);break;case`tabIndex`:kt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:kt(e,n,r);break;case`style`:Jt(e,r,o);break;case`data`:if(t!==`object`){kt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Qt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Hd(e,t,`name`,a.name,a,null),Hd(e,t,`formEncType`,a.formEncType,a,null),Hd(e,t,`formMethod`,a.formMethod,a,null),Hd(e,t,`formTarget`,a.formTarget,a,null)):(Hd(e,t,`encType`,a.encType,a,null),Hd(e,t,`method`,a.method,a,null),Hd(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Qt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=$t);break;case`onScroll`:r!=null&&kd(`scroll`,e);break;case`onScrollEnd`:r!=null&&kd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Qt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:kd(`beforetoggle`,e),kd(`toggle`,e),Ot(e,`popover`,r);break;case`xlinkActuate`:At(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:At(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:At(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:At(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:At(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:At(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:At(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:At(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:At(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Ot(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Xt.get(n)||n,Ot(e,n,r))}}function Ud(e,t,n,r,a,o){switch(n){case`style`:Jt(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Gt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Gt(e,``+r);break;case`onScroll`:r!=null&&kd(`scroll`,e);break;case`onScrollEnd`:r!=null&&kd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=$t);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!xt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[st]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):Ot(e,n,r)}}}function Wd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:kd(`error`,e),kd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Hd(e,t,o,s,n,null)}}a&&Hd(e,t,`srcSet`,n.srcSet,n,null),r&&Hd(e,t,`src`,n.src,n,null);return;case`input`:kd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Hd(e,t,r,d,n,null)}}Bt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in kd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Hd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Ht(e,!!r,n,!0):Ht(e,!!r,t,!1);return;case`textarea`:for(s in kd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Hd(e,t,s,c,n,null)}Wt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Hd(e,t,l,r,n,null)}return;case`dialog`:kd(`beforetoggle`,e),kd(`toggle`,e),kd(`cancel`,e),kd(`close`,e);break;case`iframe`:case`object`:kd(`load`,e);break;case`video`:case`audio`:for(r=0;r<Ed.length;r++)kd(Ed[r],e);break;case`image`:kd(`error`,e),kd(`load`,e);break;case`details`:kd(`toggle`,e);break;case`embed`:case`source`:case`link`:kd(`error`,e),kd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Hd(e,t,u,r,n,null)}return;default:if(Yt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Ud(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Hd(e,t,c,r,n,null))}function Gd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Hd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Hd(e,t,p,m,r,f)}}zt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Hd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Hd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Ht(e,!!n,n?[]:``,!1):Ht(e,!!n,t,!0)):Ht(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Hd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Hd(e,t,s,a,r,o)}Ut(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Hd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Hd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Hd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Hd(e,t,u,p,r,m)}return;default:if(Yt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Ud(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Ud(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Hd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Hd(e,t,f,p,r,m)}function Kd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function qd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Kd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Kd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Jd=null,Yd=null;function Xd(e){return e.nodeType===9?e:e.ownerDocument}function Zd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Qd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function $d(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var ef=null;function tf(){var e=window.event;return e&&e.type===`popstate`?e===ef?!1:(ef=e,!0):(ef=null,!1)}var nf=typeof setTimeout==`function`?setTimeout:void 0,rf=typeof clearTimeout==`function`?clearTimeout:void 0,af=typeof Promise==`function`?Promise:void 0,of=typeof queueMicrotask==`function`?queueMicrotask:af===void 0?nf:function(e){return af.resolve(null).then(e).catch(sf)};function sf(e){setTimeout(function(){throw e})}function cf(e){return e===`head`}function lf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Up(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)Cf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,Cf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[pt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&Cf(e.ownerDocument.body);n=i}while(n);Up(t)}function uf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function df(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:df(n),mt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function ff(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[pt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=vf(e.nextSibling),e===null)break}return null}function pf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=vf(e.nextSibling),e===null))return null;return e}function mf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=vf(e.nextSibling),e===null))return null;return e}function hf(e){return e.data===`$?`||e.data===`$~`}function gf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function _f(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function vf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var yf=null;function bf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return vf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function xf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function Sf(e,t,n){switch(t=Xd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Cf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);mt(e)}var wf=new Map,Tf=new Set;function Ef(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Df=P.d;P.d={f:Of,r:kf,D:Mf,C:Nf,L:Pf,m:Ff,X:Lf,S:If,M:Rf};function Of(){var e=Df.f(),t=Ou();return e||t}function kf(e){var t=gt(e);t!==null&&t.tag===5&&t.type===`form`?Os(t):Df.r(e)}var Af=typeof document>`u`?null:document;function jf(e,t,n){var r=Af;if(r&&typeof t==`string`&&t){var i=Rt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Tf.has(i)||(Tf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Wd(t,`link`,e),yt(t),r.head.appendChild(t)))}}function Mf(e){Df.D(e),jf(`dns-prefetch`,e,null)}function Nf(e,t){Df.C(e,t),jf(`preconnect`,e,t)}function Pf(e,t,n){Df.L(e,t,n);var r=Af;if(r&&e&&t){var i=`link[rel="preload"][as="`+Rt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Rt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Rt(n.imageSizes)+`"]`)):i+=`[href="`+Rt(e)+`"]`;var a=i;switch(t){case`style`:a=Bf(e);break;case`script`:a=Wf(e)}wf.has(a)||(e=f({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),wf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Vf(a))||t===`script`&&r.querySelector(Gf(a))||(t=r.createElement(`link`),Wd(t,`link`,e),yt(t),r.head.appendChild(t)))}}function Ff(e,t){Df.m(e,t);var n=Af;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Rt(r)+`"][href="`+Rt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Wf(e)}if(!wf.has(a)&&(e=f({rel:`modulepreload`,href:e},t),wf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Gf(a)))return}r=n.createElement(`link`),Wd(r,`link`,e),yt(r),n.head.appendChild(r)}}}function If(e,t,n){Df.S(e,t,n);var r=Af;if(r&&e){var i=vt(r).hoistableStyles,a=Bf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Vf(a)))s.loading=5;else{e=f({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=wf.get(a))&&Jf(e,n);var c=o=r.createElement(`link`);yt(c),Wd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,qf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Lf(e,t){Df.X(e,t);var n=Af;if(n&&e){var r=vt(n).hoistableScripts,i=Wf(e),a=r.get(i);a||(a=n.querySelector(Gf(i)),a||(e=f({src:e,async:!0},t),(t=wf.get(i))&&Yf(e,t),a=n.createElement(`script`),yt(a),Wd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Rf(e,t){Df.M(e,t);var n=Af;if(n&&e){var r=vt(n).hoistableScripts,i=Wf(e),a=r.get(i);a||(a=n.querySelector(Gf(i)),a||(e=f({src:e,async:!0,type:`module`},t),(t=wf.get(i))&&Yf(e,t),a=n.createElement(`script`),yt(a),Wd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function zf(e,t,n,r){var a=(a=le.current)?Ef(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Bf(n.href),n=vt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Bf(n.href);var o=vt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Vf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),wf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},wf.set(e,n),o||Uf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Wf(n),n=vt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Bf(e){return`href="`+Rt(e)+`"`}function Vf(e){return`link[rel="stylesheet"][`+e+`]`}function Hf(e){return f({},e,{"data-precedence":e.precedence,precedence:null})}function Uf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Wd(t,`link`,n),yt(t),e.head.appendChild(t))}function Wf(e){return`[src="`+Rt(e)+`"]`}function Gf(e){return`script[async]`+e}function Kf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Rt(n.href)+`"]`);if(r)return t.instance=r,yt(r),r;var a=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),yt(r),Wd(r,`style`,a),qf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Bf(n.href);var o=e.querySelector(Vf(a));if(o)return t.state.loading|=4,t.instance=o,yt(o),o;r=Hf(n),(a=wf.get(a))&&Jf(r,a),o=(e.ownerDocument||e).createElement(`link`),yt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Wd(o,`link`,r),t.state.loading|=4,qf(o,n.precedence,e),t.instance=o;case`script`:return o=Wf(n.src),(a=e.querySelector(Gf(o)))?(t.instance=a,yt(a),a):(r=n,(a=wf.get(o))&&(r=f({},n),Yf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),yt(a),Wd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,qf(r,n.precedence,e));return t.instance}function qf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Jf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Yf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Xf=null;function Zf(e,t,n){if(Xf===null){var r=new Map,i=Xf=new Map;i.set(n,r)}else i=Xf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[pt]||a[ot]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Qf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function $f(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function ep(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function tp(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Bf(r.href),a=t.querySelector(Vf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=ip.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,yt(a);return}a=t.ownerDocument||t,r=Hf(r),(i=wf.get(i))&&Jf(r,i),a=a.createElement(`link`),yt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Wd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=ip.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var np=0;function rp(e,t){return e.stylesheets&&e.count===0&&op(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&op(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&np===0&&(np=62500*qd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&op(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>np?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function ip(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)op(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var ap=null;function op(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ap=new Map,t.forEach(sp,e),ap=null,ip.call(e))}function sp(e,t){if(!(t.state.loading&4)){var n=ap.get(e);if(n)var r=n.get(null);else{n=new Map,ap.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=ip.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var cp={$$typeof:x,Provider:null,Consumer:null,_currentValue:te,_currentValue2:te,_threadCount:0};function lp(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Xe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xe(0),this.hiddenUpdates=Xe(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function up(e,t,n,r,i,a,o,s,c,l,u,d){return e=new lp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=si(3,null,null,t),e.current=a,a.stateNode=e,t=oa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},za(a),e}function dp(e){return e?(e=L,e):L}function fp(e,t,n,r,i,a){i=dp(i),r.context===null?r.context=i:r.pendingContext=i,r=Va(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ha(e,r,t),n!==null&&(wu(n,e,t),Ua(n,e,t))}function pp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function mp(e,t){pp(e,t),(e=e.alternate)&&pp(e,t)}function hp(e){if(e.tag===13||e.tag===31){var t=ri(e,67108864);t!==null&&wu(t,e,67108864),mp(e,67108864)}}function gp(e){if(e.tag===13||e.tag===31){var t=Su();t=tt(t);var n=ri(e,t);n!==null&&wu(n,e,t),mp(e,t)}}var _p=!0;function vp(e,t,n,r){var i=N.T;N.T=null;var a=P.p;try{P.p=2,bp(e,t,n,r)}finally{P.p=a,N.T=i}}function yp(e,t,n,r){var i=N.T;N.T=null;var a=P.p;try{P.p=8,bp(e,t,n,r)}finally{P.p=a,N.T=i}}function bp(e,t,n,r){if(_p){var i=xp(r);if(i===null)Nd(e,t,r,Sp,n),Np(e,r);else if(Fp(i,e,t,n,r))r.stopPropagation();else if(Np(e,r),t&4&&-1<Mp.indexOf(e)){for(;i!==null;){var a=gt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Ke(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-ze(o);s.entanglements[1]|=c,o&=~c}fd(a),!(Ul&6)&&(uu=De()+500,pd(0,!1))}}break;case 31:case 13:s=ri(a,2),s!==null&&wu(s,a,2),Ou(),mp(a,2)}if(a=xp(r),a===null&&Nd(e,t,r,Sp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Nd(e,t,r,null,n)}}function xp(e){return e=tn(e),Cp(e)}var Sp=null;function Cp(e){if(Sp=null,e=ht(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Sp=e,null}function wp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Oe()){case ke:return 2;case Ae:return 8;case je:case Me:return 32;case Ne:return 268435456;default:return 32}default:return 32}}var Tp=!1,Ep=null,Dp=null,Op=null,kp=new Map,Ap=new Map,jp=[],Mp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Np(e,t){switch(e){case`focusin`:case`focusout`:Ep=null;break;case`dragenter`:case`dragleave`:Dp=null;break;case`mouseover`:case`mouseout`:Op=null;break;case`pointerover`:case`pointerout`:kp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Ap.delete(t.pointerId)}}function Pp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=gt(t),t!==null&&hp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Fp(e,t,n,r,i){switch(t){case`focusin`:return Ep=Pp(Ep,e,t,n,r,i),!0;case`dragenter`:return Dp=Pp(Dp,e,t,n,r,i),!0;case`mouseover`:return Op=Pp(Op,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return kp.set(a,Pp(kp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Ap.set(a,Pp(Ap.get(a)||null,e,t,n,r,i)),!0}return!1}function Ip(e){var t=ht(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,it(e.priority,function(){gp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,it(e.priority,function(){gp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Lp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=xp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);en=r,n.target.dispatchEvent(r),en=null}else return t=gt(n),t!==null&&hp(t),e.blockedOn=n,!1;t.shift()}return!0}function Rp(e,t,n){Lp(e)&&n.delete(t)}function zp(){Tp=!1,Ep!==null&&Lp(Ep)&&(Ep=null),Dp!==null&&Lp(Dp)&&(Dp=null),Op!==null&&Lp(Op)&&(Op=null),kp.forEach(Rp),Ap.forEach(Rp)}function Bp(e,n){e.blockedOn===n&&(e.blockedOn=null,Tp||(Tp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,zp)))}var Vp=null;function Hp(e){Vp!==e&&(Vp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Vp===e&&(Vp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Cp(r||n)===null)continue;break}var a=gt(n);a!==null&&(e.splice(t,3),t-=3,Es(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Up(e){function t(t){return Bp(t,e)}Ep!==null&&Bp(Ep,e),Dp!==null&&Bp(Dp,e),Op!==null&&Bp(Op,e),kp.forEach(t),Ap.forEach(t);for(var n=0;n<jp.length;n++){var r=jp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<jp.length&&(n=jp[0],n.blockedOn===null);)Ip(n),n.blockedOn===null&&jp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[st]||null;if(typeof a==`function`)o||Hp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[st]||null)s=o.formAction;else if(Cp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Hp(n)}}}function Wp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function U(e){this._internalRoot=e}Gp.prototype.render=U.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;fp(n,Su(),e,t,null,null)},Gp.prototype.unmount=U.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;fp(e.current,2,null,e,null,null),Ou(),t[ct]=null}};function Gp(e){this._internalRoot=e}Gp.prototype.unstable_scheduleHydration=function(e){if(e){var t=rt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<jp.length&&t!==0&&t<jp[n].priority;n++);jp.splice(n,0,e),n===0&&Ip(e)}};var Kp=n.version;if(Kp!==`19.2.7`)throw Error(i(527,Kp,`19.2.7`));P.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var qp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:N,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Jp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jp.isDisabled&&Jp.supportsFiber)try{Ie=Jp.inject(qp),Le=Jp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Ys,s=Xs,c=Zs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=up(e,1,!1,null,null,n,r,null,o,s,c,Wp),e[ct]=t.current,H(e),new U(t)}})),TK=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=wK()}))();function EK(e){if(e.resourceType===`Patient`)return e;if(e.resourceType===`DiagnosticReport`||e.resourceType===`Encounter`||e.resourceType===`Observation`||e.resourceType===`ServiceRequest`)return e.subject}function DK(e){if(e.resourceType===`Specimen`)return e;if(e.resourceType===`Observation`)return e.specimen;if(e.resourceType===`DiagnosticReport`||e.resourceType===`ServiceRequest`)return e.specimen?.[0]}function OK(e){return sC(e.getActiveLogin()?.project)}function kK(e){let t=OK(Z()),n=vW(),[r,i]=(0,b.useState)(e.profileTypeOptions[0].value),[a,o]=(0,b.useState)({resourceType:`ProjectMembership`,filters:[{code:`project`,operator:X.EQUALS,value:`Project/`+t},{code:`profile-type`,operator:X.EQUALS,value:r}],fields:e.fields,count:100});function s(e){i(e),o({...a,filters:[{code:`project`,operator:X.EQUALS,value:`Project/`+t},{code:`profile-type`,operator:X.EQUALS,value:e}]})}let c=e.profileTypeOptions.length>1;return(0,I.jsxs)(I.Fragment,{children:[(c||e.toolbarLeft!==void 0||e.toolbarRight!==void 0)&&(0,I.jsxs)(V,{justify:`space-between`,align:`center`,mb:`md`,wrap:`nowrap`,children:[(0,I.jsxs)(V,{gap:`md`,wrap:`nowrap`,children:[c&&(0,I.jsx)(uy,{value:r,onChange:s,data:e.profileTypeOptions}),e.toolbarLeft]}),e.toolbarRight]}),(0,I.jsx)(sz,{search:a,onClick:e=>n(`./${e.resource.id}`),onChange:e=>o(e.definition),hideFilters:!0,hideToolbar:!0})]})}function AK(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{children:`ProjectMemberships by Bot`}),(0,I.jsx)(kK,{profileTypeOptions:[{label:`Bot`,value:`Bot`}],fields:[`user`,`profile`,`accessPolicy`,`userConfiguration`,`active`,`admin`],toolbarLeft:(0,I.jsx)(yl,{withBorder:!0,p:`sm`,radius:`sm`,maw:520,children:(0,I.jsxs)(H,{size:`sm`,c:`dimmed`,children:[`Please note that this list is limited to Bots that have a ProjectMembership. Bots that are run as user commonly do not have a ProjectMembership, and are not included, such as most Bots in Medplum-managed integrations. For a complete list of Bots, see `,(0,I.jsx)(Wj,{to:`/Bot`,children:`Bots`}),`. For more information, see`,` `,(0,I.jsx)(Pd,{href:`https://www.medplum.com/docs/bots/bot-run-as-user`,target:`_blank`,rel:`noopener noreferrer`,children:`running Bots as user`}),`.`]})}),toolbarRight:(0,I.jsx)(Pd,{href:`https://www.medplum.com/docs/bots`,target:`_blank`,rel:`noopener noreferrer`,size:`sm`,children:`Learn more about Bots`})}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(Wj,{to:`/admin/bots/new`,children:`Create new bot`})})]})}function jK(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{children:`ProjectMemberships by ClientApplication`}),(0,I.jsx)(kK,{profileTypeOptions:[{label:`ClientApplication`,value:`ClientApplication`}],fields:[`user`,`profile`,`accessPolicy`,`userConfiguration`,`active`,`admin`]}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(Wj,{to:`/admin/clients/new`,children:`Create new client`})})]})}function MK(e){return(0,I.jsx)(sI,{resourceType:`AccessPolicy`,name:e.name,defaultValue:e.defaultValue,placeholder:`Access Policy`,onChange:t=>{Hw(t)?e.onChange(aC(t)):e.onChange(void 0)}})}function NK(){let e=Z(),t=OK(e),[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)(void 0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{children:`Create new Bot`}),(0,I.jsxs)(CN,{onSubmit:()=>{let r={name:n,description:i,accessPolicy:o};e.post(`admin/projects/`+t+`/bot`,r).then(t=>{e.invalidateSearches(`Bot`),e.invalidateSearches(`ProjectMembership`),d(t),J({color:`green`,message:`Bot created`})}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1}),l(Zx(e))})},children:[!u&&(0,I.jsxs)(G,{children:[(0,I.jsx)(AF,{title:`Name`,htmlFor:`name`,outcome:c,children:(0,I.jsx)(yb,{id:`name`,name:`name`,required:!0,autoFocus:!0,onChange:e=>r(e.currentTarget.value),error:bP(c,`name`)})}),(0,I.jsx)(AF,{title:`Description`,htmlFor:`description`,outcome:c,children:(0,I.jsx)(yb,{id:`description`,name:`description`,onChange:e=>a(e.currentTarget.value),error:bP(c,`description`)})}),(0,I.jsx)(AF,{title:`Access Policy`,htmlFor:`accessPolicy`,outcome:c,children:(0,I.jsx)(MK,{name:`accessPolicy`,onChange:s})}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(U,{type:`submit`,children:`Create Bot`})})]}),u&&(0,I.jsxs)(`div`,{"data-testid":`success`,children:[(0,I.jsx)(H,{children:`Bot created`}),(0,I.jsxs)(yh,{children:[(0,I.jsx)(yh.Item,{children:(0,I.jsx)(Wj,{to:u,children:`Go to new bot`})}),(0,I.jsx)(yh.Item,{children:(0,I.jsx)(Wj,{to:`/admin/bots`,children:`Back to bots list`})})]})]})]})]})}function PK(){let e=Z(),t=OK(e),[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)(),[f,p]=(0,b.useState)(void 0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{children:`Create new Client`}),(0,I.jsxs)(CN,{onSubmit:()=>{let r={name:n,description:i,redirectUri:o,accessPolicy:c};e.post(`admin/projects/`+t+`/client`,r).then(t=>{e.invalidateSearches(`ClientApplication`),e.invalidateSearches(`ProjectMembership`),p(t),J({color:`green`,message:`Client created`})}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1}),d(Zx(e))})},children:[!f&&(0,I.jsxs)(G,{children:[(0,I.jsx)(AF,{title:`Name`,htmlFor:`name`,outcome:u,children:(0,I.jsx)(yb,{id:`name`,name:`name`,required:!0,autoFocus:!0,onChange:e=>r(e.currentTarget.value),error:bP(u,`name`)})}),(0,I.jsx)(AF,{title:`Description`,htmlFor:`description`,outcome:u,children:(0,I.jsx)(yb,{id:`description`,name:`description`,onChange:e=>a(e.currentTarget.value),error:bP(u,`description`)})}),(0,I.jsx)(AF,{title:`Redirect URI`,htmlFor:`redirectUri`,outcome:u,children:(0,I.jsx)(yb,{id:`redirectUri`,name:`redirectUri`,onChange:e=>s(e.currentTarget.value),error:bP(u,`redirectUri`)})}),(0,I.jsx)(AF,{title:`Access Policy`,htmlFor:`accessPolicy`,outcome:u,children:(0,I.jsx)(MK,{name:`accessPolicy`,onChange:l})}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(U,{type:`submit`,children:`Create Client`})})]}),f&&(0,I.jsxs)(`div`,{"data-testid":`success`,children:[(0,I.jsx)(H,{children:`Client created`}),(0,I.jsxs)(yh,{children:[(0,I.jsx)(yh.Item,{children:(0,I.jsx)(Wj,{to:f,children:`Go to new client`})}),(0,I.jsx)(yh.Item,{children:(0,I.jsx)(Wj,{to:`/admin/clients`,children:`Back to clients list`})})]})]})]})]})}var FK=1e-10;function IK(e,t){let n=0,r=Math.exp(-t);for(let i=0;i<=e;i++)i>0&&(r*=t/i),n+=r;return n}function LK(e,t,n=FK){let r=0,i=Math.max(t+1,1);for(;IK(t,i)>e;)i*=2;for(;i-r>n;){let n=(r+i)/2;IK(t,n)>e?r=n:i=n}return i}function RK(e,t,n,r){let i=e*300,a=9*t*i/(e*10*1e3/7),o=Math.ceil(a),s=o/i,c=Math.max(r??0,s),l=r?c*i:o,u=l,d=IK(l-1,u),f=Math.log(1-n)/Math.log(d);return{rowsSampled:i,cutoffFrequencyExact:a,cutoffFrequency:o,minimumSelectivity:s,targetSelectivity:c,targetLambda:u,targetPoissonCdf:d,targetM:f,results:[{name:`Floor`,result:zK(Math.floor(f),n,l,i)},{name:`Ceiling`,result:zK(Math.ceil(f),n,l,i)}]}}function zK(e,t,n,r){let i=(1-t)**(1/e),a=LK(i,n-1);return{m:e,poissonCdf:i,lambda:a,f:a/r}}function BK(e,t=`auto`,n=6){return Number.isFinite(e)?t===`scientific`?e.toExponential(n):t===`fixed`?e.toFixed(n):Math.abs(e)<1e-4&&e!==0?e.toExponential(n):Math.abs(e-Math.round(e))<1e-10?Math.round(e).toString():e.toPrecision(8):String(e)}function VK({label:e,value:t,format:n=`auto`,decimals:r=6}){return(0,I.jsxs)(Tm,{children:[(0,I.jsx)(Tm.Col,{span:8,children:(0,I.jsx)(H,{size:`sm`,children:e})}),(0,I.jsx)(Tm.Col,{span:4,children:(0,I.jsx)(H,{size:`sm`,ff:`monospace`,ta:`right`,children:BK(t,n,r)})})]})}function HK({title:e,m:t,poissonCdf:n,lambda:r,f:i}){return(0,I.jsxs)(yl,{withBorder:!0,p:`md`,children:[(0,I.jsx)(q,{order:4,mb:`sm`,children:e}),(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsx)(VK,{label:`M (padding multiplier)`,value:t}),(0,I.jsx)(VK,{label:`Poisson CDF`,value:n}),(0,I.jsx)(VK,{label:`Lambda`,value:r}),(0,I.jsx)(VK,{label:`F (selectivity)`,value:i,format:`scientific`})]})]})}function UK(){let[e,t]=(0,b.useState)(1e3),[n,r]=(0,b.useState)(3),[i,a]=(0,b.useState)(.999999),[o,s]=(0,b.useState)(``),c=(0,b.useMemo)(()=>{let t=typeof e==`number`?e:void 0,r=typeof n==`number`?n:void 0,a=typeof i==`number`?i:void 0,s=typeof o==`number`?o:void 0;if(!(t===void 0||r===void 0||a===void 0))return RK(t,r,a,s)},[e,n,i,o]);return(0,I.jsxs)(G,{gap:`lg`,children:[(0,I.jsxs)(yl,{withBorder:!0,p:`md`,children:[(0,I.jsx)(q,{order:4,mb:`md`,children:`Inputs`}),(0,I.jsxs)(Tm,{children:[(0,I.jsx)(Tm.Col,{span:{base:12,sm:6,md:3},children:(0,I.jsx)(P_,{label:`Statistics Target`,value:e,onChange:t,min:100,max:1e4,step:100})}),(0,I.jsx)(Tm.Col,{span:{base:12,sm:6,md:3},children:(0,I.jsx)(P_,{label:`Elements Per Row`,value:n,onChange:r,min:1,max:1e3,step:1})}),(0,I.jsx)(Tm.Col,{span:{base:12,sm:6,md:3},children:(0,I.jsx)(P_,{label:`Confidence`,value:i,onChange:a,min:0,max:1,step:1e-6,decimalScale:10})}),(0,I.jsx)(Tm.Col,{span:{base:12,sm:6,md:3},children:(0,I.jsx)(P_,{label:`Target Selectivity (optional)`,description:`Overrides minimum selectivity`,value:o,onChange:s,min:0,max:1,step:1e-5,decimalScale:10,placeholder:c?BK(c.minimumSelectivity,`scientific`):``})})]})]}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(yl,{withBorder:!0,p:`md`,children:[(0,I.jsx)(q,{order:4,mb:`sm`,children:`Intermediate Values`}),(0,I.jsxs)(Tm,{children:[(0,I.jsx)(Tm.Col,{span:{base:12,md:6},children:(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsx)(VK,{label:`Rows Sampled`,value:c.rowsSampled}),(0,I.jsx)(VK,{label:`Cutoff Frequency (exact)`,value:c.cutoffFrequencyExact}),(0,I.jsx)(VK,{label:`Cutoff Frequency`,value:c.cutoffFrequency}),(0,I.jsx)(VK,{label:`Min Selectivity`,value:c.minimumSelectivity,format:`scientific`})]})}),(0,I.jsx)(Tm.Col,{span:{base:12,md:6},children:(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsx)(VK,{label:`Target Selectivity`,value:c.targetSelectivity,format:`scientific`}),(0,I.jsx)(VK,{label:`Target Lambda`,value:c.targetLambda}),(0,I.jsx)(VK,{label:`Target Poisson CDF`,value:c.targetPoissonCdf}),(0,I.jsx)(VK,{label:`Target m`,value:c.targetM})]})})]})]}),(0,I.jsx)(Tm,{children:c.results.map(({name:e,result:t})=>(0,I.jsx)(Tm.Col,{span:{base:12,md:6},children:(0,I.jsx)(HK,{title:`${e} Option`,m:t.m,poissonCdf:t.poissonCdf,lambda:t.lambda,f:t.f})},e))})]})]})}var WK=8;function GK({inputProps:e,data:t,onChange:n}){let r=If({onDropdownClose:()=>r.resetSelectedOption()}),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(``),c=(0,b.useMemo)(()=>t.filter(e=>e.toLowerCase().includes(o.toLowerCase().trim())),[t,o]),l=(0,b.useMemo)(()=>{let e=Array(Math.min(c.length,WK));for(let t=0;t<e.length;t++){let n=c[t];e[t]=(0,I.jsx)(zf.Option,{value:n,children:n},n)}return e},[c]);return(0,I.jsxs)(zf,{store:r,withinPortal:!1,onOptionSubmit:e=>{n&&n(e),a(e),s(e),r.closeDropdown()},children:[(0,I.jsx)(zf.Target,{children:(0,I.jsx)(md,{rightSection:(0,I.jsx)(zf.Chevron,{}),value:o,onChange:e=>{r.openDropdown(),r.updateSelectedOptionIndex(),s(e.currentTarget.value)},onClick:()=>r.openDropdown(),onFocus:()=>r.openDropdown(),onBlur:()=>{r.closeDropdown(),s(i||``)},rightSectionPointerEvents:`none`,...e})}),(0,I.jsx)(zf.Dropdown,{children:(0,I.jsx)(zf.Options,{children:l.length>0?l:(0,I.jsx)(zf.Empty,{children:`Nothing found`})})})]})}function KK(e){let t=[];for(let n of e)t.push(n),t.push(n+`_History`),t.push(n+`_References`);return t.push(`Address`),t.push(`ContactPoint`),t.push(`HumanName`),t.push(`Coding`),t.push(`Coding_Property`),t.push(`DatabaseMigration`),t=ZC(t),t}function qK(e){return typeof e==`string`?e.length>50?e.substring(0,50)+`...`:e:typeof e==`boolean`?e.toString().toLocaleUpperCase():e}var JK=({medplum:e,onChange:t,onError:n})=>{(0,b.useEffect)(()=>{async function r(){return(await e.valueSetExpand({url:`https://medplum.com/fhir/ValueSet/resource-types`,count:200})).expansion?.contains?.map(e=>e.code).filter(e=>e!==void 0)??[]}r().then(e=>{t(KK(e))}).catch(e=>{n?n(e):console.error(e)})},[e,t,n])};function YK(){let e=Z(),[t,{open:n,close:r}]=bn(!1),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(void 0),[u,d]=(0,b.useState)(0),[f,p]=(0,b.useState)(!1),[m,h]=(0,b.useState)([]),[g,_]=(0,b.useState)([]),[v,y]=(0,b.useState)(!1),[x,S]=(0,b.useState)(void 0),[C,w]=(0,b.useState)([]),[T,E]=(0,b.useState)(0),[D,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)(!1);JK({medplum:e,onChange:w}),(0,b.useEffect)(()=>{p(!0),e.get(`fhir/R4/$db-column-statistics?tableName=`+encodeURIComponent(c??``),{cache:`no-cache`}).then(e=>{d(e.parameter?.find(e=>e.name===`defaultStatisticsTarget`)?.valueInteger??0);let t=(e.parameter?.find(e=>e.name===`table`)?.part)?.filter(e=>e.name===`column`);h(t??[])}).finally(()=>{p(!1)}).catch(e=>{J({color:`red`,message:e.message})})},[e,c,T]);function j(){if(c){if(g.length===0){J({color:`red`,message:`No columns selected`,autoClose:!0});return}J({title:`Submit`,message:JSON.stringify({resetToDefault:v,newStatisticsTarget:x,selectedRowNames:g}),autoClose:!0}),e.post(`fhir/R4/$db-configure-column-statistics`,{tableName:c,columnNames:g,resetToDefault:v,newStatisticsTarget:v?void 0:x}).then(e=>{J({color:`green`,message:`Done`}),E(e=>e+1)}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}}let M={onClick:e=>{a(`Details`),s((0,I.jsx)(`pre`,{children:e})),n()}},ee=0;return(0,I.jsxs)(CN,{onSubmit:j,children:[(0,I.jsxs)(G,{gap:`sm`,children:[(0,I.jsxs)(V,{children:[(0,I.jsx)(GK,{data:C,inputProps:{placeholder:`Table name`,inputSize:`50`},onChange:e=>{l(e),_([])}}),(0,I.jsx)(U,{loading:f,onClick:()=>E(e=>e+1),children:`Refresh`})]}),(0,I.jsxs)(V,{children:[(0,I.jsx)(H,{span:!0,fw:700,children:`Statistics Target:`}),(0,I.jsx)(P_,{value:v?``:x,disabled:v,required:!v,size:`sm`,w:`100`,min:0,step:100,max:1e4,onChange:e=>{typeof e==`number`&&S(e)}}),(0,I.jsx)(H,{span:!0,fw:700,c:`dimmed`,children:`– or –`}),(0,I.jsx)(lp,{checked:v,onChange:e=>y(e.currentTarget.checked),label:`Reset to default (`+u+`)`,size:`sm`}),(0,I.jsx)(wN,{size:`sm`,children:`Update`})]}),(0,I.jsx)(V,{children:(0,I.jsx)(lp,{checked:k,onChange:e=>A(e.currentTarget.checked),label:`Hide columns with default statistics target`,size:`sm`})}),(0,I.jsx)(V,{children:(0,I.jsx)(lp,{checked:D,onChange:e=>O(e.currentTarget.checked),label:`Show all column stats`,size:`sm`})}),(0,I.jsx)(K.ScrollContainer,{minWidth:500,children:(0,I.jsxs)(K,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:(0,I.jsx)(lp,{size:`sm`,checked:m.length>0&&g.length===m.length,indeterminate:g.length>0&&g.length<m.length,onChange:()=>{g.length===m.length?_([]):_(m.map(e=>e.part?.find(e=>e.name===`name`)?.valueString??``))}})}),(0,I.jsx)(K.Th,{children:`Column`}),(0,I.jsx)(K.Th,{children:`Statistics Target`}),(0,I.jsx)(K.Th,{children:`null_frac`}),(0,I.jsx)(K.Th,{children:`avg_width`}),(0,I.jsx)(K.Th,{children:`n_distinct`}),(0,I.jsx)(K.Th,{children:`correlation`}),D&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(K.Th,{children:`most_common_vals`}),(0,I.jsx)(K.Th,{children:`most_common_freqs`}),(0,I.jsx)(K.Th,{children:`histogram_bounds`}),(0,I.jsx)(K.Th,{children:`most_common_elems`}),(0,I.jsx)(K.Th,{children:`most_common_elem_freqs`}),(0,I.jsx)(K.Th,{children:`elem_count_histogram`})]})]})}),(0,I.jsxs)(K.Tbody,{children:[m?.map(e=>{let t=e.part??[],n=t.find(e=>e.name===`name`)?.valueString,r=t.find(e=>e.name===`statisticsTarget`)?.valueInteger;if(r===-1&&(ee++,k))return null;if(!n)throw Error(`Column missing name`,{cause:e});return(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:(0,I.jsx)(lp,{size:`sm`,checked:g.includes(n),onChange:e=>{_(e.currentTarget.checked?[...g,n]:g.filter(e=>e!==n))}})}),(0,I.jsx)(K.Td,{children:n}),(0,I.jsx)(K.Td,{children:r===-1?(0,I.jsxs)(H,{span:!0,c:`dimmed`,fs:`italic`,children:[`default (`,u,`)`]}):r}),(0,I.jsx)(XK,{value:t.find(e=>e.name===`nullFraction`)?.valueDecimal,...M}),(0,I.jsx)(XK,{value:t.find(e=>e.name===`avgWidth`)?.valueInteger,...M}),(0,I.jsx)(XK,{value:t.find(e=>e.name===`nDistinct`)?.valueDecimal,...M}),(0,I.jsx)(XK,{value:t.find(e=>e.name===`correlation`)?.valueDecimal,...M}),D&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(XK,{value:t.find(e=>e.name===`mostCommonValues`)?.valueString,...M}),(0,I.jsx)(XK,{value:t.find(e=>e.name===`mostCommonFreqs`)?.valueString,...M}),(0,I.jsx)(XK,{value:t.find(e=>e.name===`histogramBounds`)?.valueString,...M}),(0,I.jsx)(XK,{value:t.find(e=>e.name===`mostCommonElems`)?.valueString,...M}),(0,I.jsx)(XK,{value:t.find(e=>e.name===`mostCommonElemFreqs`)?.valueString,...M}),(0,I.jsx)(XK,{value:t.find(e=>e.name===`elemCountHistogram`)?.valueString,...M})]})]},n)}),k&&(0,I.jsx)(K.Tr,{children:(0,I.jsx)(K.Td,{colSpan:D?13:7,children:(0,I.jsxs)(H,{c:`dimmed`,fs:`italic`,children:[ee,` hidden columns with default statistics target`]})})})]})]})})]}),(0,I.jsx)(rg,{opened:t,onClose:r,title:i,centered:!0,size:`auto`,children:o})]})}function XK({value:e,onClick:t}){return(0,I.jsx)(K.Td,{style:{cursor:`pointer`},onClick:()=>t?.(e),children:ZK(e)})}function ZK(e){return typeof e==`string`&&e.length>30?e.substring(0,30)+`...`:e}function QK(e,t,n,r){let i=Date.now().toString();J({id:i,loading:!0,title:t,message:`Running...`,autoClose:!1,withCloseButton:!1});let a={method:`POST`,pollStatusOnAccepted:!0};return r&&(a.body=JSON.stringify(r)),e.startAsyncRequest(n,a).then(e=>{let n=`Done`;return e.resourceType===`AsyncJob`?n=(0,I.jsx)(Wj,{to:e,children:`View AsyncJob`}):e.resourceType===`OperationOutcome`&&e.issue?.[0]?.details?.text&&(n=(0,I.jsx)(H,{children:e.issue[0].details.text})),zb.update({id:i,color:`green`,title:t,message:n,icon:(0,I.jsx)(wA,{size:`1rem`}),loading:!1,autoClose:!1,withCloseButton:!0}),e}).catch(e=>{throw zb.update({id:i,color:`red`,title:t,message:Qx(e),icon:(0,I.jsx)(Nj,{size:`1rem`}),loading:!1,autoClose:!1,withCloseButton:!0}),e})}function $K(e,t,n,r){QK(e,t,n,r).catch(()=>{})}var eq=8;function tq({pillInputProps:e,inputProps:t,data:n,onChange:r}){let i=If({onDropdownClose:()=>i.resetSelectedOption(),onDropdownOpen:()=>i.updateSelectedOptionIndex(`active`)}),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)([]),l=e=>{let t=s.includes(e)?s.filter(t=>t!==e):[...s,e];c(t),r&&r(t)},u=e=>c(t=>t.filter(t=>t!==e)),d=(0,b.useMemo)(()=>s.map(e=>(0,I.jsx)(pg,{withRemoveButton:!0,onRemove:()=>u(e),children:e},e)),[s]),f=(0,b.useMemo)(()=>{let e=a.trim().toLowerCase();return n.filter(t=>t.toLowerCase().includes(e))},[n,a]),p=(0,b.useMemo)(()=>{let e=Array(Math.min(f.length,eq));for(let t=0;t<e.length;t++){let n=f[t];e[t]=(0,I.jsx)(zf.Option,{value:n,active:s.includes(n),children:(0,I.jsxs)(V,{gap:`sm`,children:[s.includes(n)?(0,I.jsx)(tp,{size:12}):null,(0,I.jsx)(`span`,{children:n})]})},n)}return e},[f,s]);return(0,I.jsxs)(zf,{store:i,onOptionSubmit:l,withinPortal:!1,children:[(0,I.jsx)(zf.DropdownTarget,{children:(0,I.jsx)(vg,{onClick:()=>i.openDropdown(),...e,children:(0,I.jsxs)(pg.Group,{children:[d,(0,I.jsx)(zf.EventsTarget,{children:(0,I.jsx)(vg.Field,{onFocus:()=>i.openDropdown(),onBlur:()=>{i.closeDropdown(),o(``)},value:a,onChange:e=>{i.updateSelectedOptionIndex(),o(e.currentTarget.value)},onKeyDown:e=>{e.key===`Backspace`&&a.length===0&&s.length>0&&(e.preventDefault(),u(s[s.length-1]))},...t})})]})})}),(0,I.jsx)(zf.Dropdown,{children:(0,I.jsx)(zf.Options,{children:p.length>0?p:(0,I.jsx)(zf.Empty,{children:`Nothing found...`})})})]})}function nq({defaultGinPendingListLimit:e,availableTables:t,onResponse:n}){let r=Z(),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)([]),[c,l]=(0,b.useState)(`unspecified`),[u,d]=(0,b.useState)(`unspecified`),[f,p]=(0,b.useState)(void 0);return(0,I.jsx)(CN,{onSubmit:()=>{let e={tableName:o};c===`reset`?e.fastUpdateAction=`reset`:c===`on`?(e.fastUpdateAction=`set`,e.fastUpdateValue=!0):c===`off`&&(e.fastUpdateAction=`set`,e.fastUpdateValue=!1),u===`reset`?e.ginPendingListLimitAction=`reset`:u===`set`&&(e.ginPendingListLimitAction=`set`,e.ginPendingListLimitValue=f),a(!0),QK(r,`Configure GIN Indexes`,`fhir/R4/$db-configure-indexes`,e).then(e=>{n(e)}).catch(()=>{}).finally(()=>{a(!1)})},children:(0,I.jsxs)(G,{gap:`sm`,maw:`800`,children:[(0,I.jsx)(cd,{label:`Table(s)`,children:(0,I.jsx)(tq,{data:t,onChange:e=>s(e),inputProps:{name:`tables`,placeholder:`e.g. Observation`}})}),(0,I.jsx)(Pv.Group,{name:`fastUpdate`,label:`fastupdate`,value:c,onChange:e=>l(e),children:(0,I.jsxs)(V,{h:`36`,children:[(0,I.jsx)(Pv,{size:`sm`,value:`unspecified`,label:`unspecified`}),(0,I.jsx)(Pv,{size:`sm`,value:`reset`,label:`reset to default (on)`}),(0,I.jsx)(Pv,{size:`sm`,value:`off`,label:`off`}),(0,I.jsx)(Pv,{size:`sm`,value:`on`,label:`on`})]})}),(0,I.jsx)(Pv.Group,{name:`ginPendingListLimit`,label:`gin_pending_list_limit`,value:u,onChange:e=>{d(e),e!==`set`&&p(void 0)},children:(0,I.jsxs)(V,{h:`36`,children:[(0,I.jsx)(Pv,{size:`sm`,value:`unspecified`,label:`unspecified`}),(0,I.jsx)(Pv,{size:`sm`,value:`reset`,label:`reset to default (${e}kB)`}),(0,I.jsxs)(V,{children:[(0,I.jsx)(Pv,{size:`sm`,value:`set`,label:`Set to (kB)`}),(0,I.jsx)(P_,{title:`gin_pending_list_limit_value`,name:`gin_pending_list_limit_value`,value:(u===`set`?f:``)||``,disabled:u!==`set`,required:u===`set`,size:`sm`,w:`100`,min:64,max:2147483647,onChange:e=>{p(typeof e==`number`?e:void 0)}})]})]})}),(0,I.jsx)(V,{justify:`center`,children:(0,I.jsx)(wN,{size:`sm`,loading:i,children:`Update`})})]})})}function rq(){let e=Z(),[t,{open:n,close:r}]=bn(!1),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(void 0),[u,d]=(0,b.useState)(0),[f,p]=(0,b.useState)(!1),[m,h]=(0,b.useState)(void 0),[g,_]=(0,b.useState)([]),[v,y]=(0,b.useState)(0);JK({medplum:e,onChange:_}),(0,b.useEffect)(()=>{p(!0),e.get(`fhir/R4/$db-indexes?tableName=`+encodeURIComponent(c??``),{cache:`no-cache`}).then(e=>{d(e.parameter?.find(e=>e.name===`defaultGinPendingListLimit`)?.valueInteger??0);let t=e.parameter?.filter(e=>e.name===`index`);h(t??[])}).finally(()=>{p(!1)}).catch(e=>{J({color:`red`,message:e.message})})},[e,c,v]);let x=e=>{a(`Configure results`),s((0,I.jsx)(`pre`,{children:JSON.stringify(e,null,2)})),n(),y(e=>(e+1)%100)},S={onClick:e=>{a(`Details`),s((0,I.jsx)(`pre`,{children:e})),n()}},C;return f?C=`Loading...`:c?m?.length===0&&(C=`No GIN indexes on this table`):C=`Select a table`,(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(G,{gap:`sm`,children:[(0,I.jsx)(`h2`,{children:`Configure GIN indexes`}),(0,I.jsx)(V,{children:(0,I.jsx)(nq,{defaultGinPendingListLimit:u,availableTables:g,onResponse:x})}),(0,I.jsx)(`h2`,{children:`GIN index stats`}),(0,I.jsxs)(V,{children:[(0,I.jsx)(GK,{data:g,inputProps:{placeholder:`Table name`,inputSize:`50`},onChange:e=>{l(e)}}),(0,I.jsx)(U,{loading:f,onClick:()=>y(e=>(e+1)%100),disabled:!c,children:`Refresh`})]}),(0,I.jsx)(K.ScrollContainer,{minWidth:500,children:(0,I.jsxs)(K,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:`Schema`}),(0,I.jsx)(K.Th,{children:`Table`}),(0,I.jsx)(K.Th,{children:`Index`}),(0,I.jsx)(K.Th,{children:`fastupdate`}),(0,I.jsx)(K.Th,{children:`gin_pending_list_limit`}),(0,I.jsx)(K.Th,{children:`options`})]})}),(0,I.jsxs)(K.Tbody,{children:[C&&(0,I.jsx)(K.Tr,{children:(0,I.jsx)(K.Td,{colSpan:16,children:C})}),!C&&m?.map(e=>{let t=e.part??[],n=t.find(e=>e.name===`indexName`)?.valueString;if(!n)throw Error(`Index missing name`,{cause:e});return(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:t.find(e=>e.name===`schemaName`)?.valueString}),(0,I.jsx)(K.Td,{children:t.find(e=>e.name===`tableName`)?.valueString}),(0,I.jsx)(K.Td,{children:n}),(0,I.jsx)(iq,{value:t.find(e=>e.name===`fastUpdate`)?.valueBoolean,defaultValue:(0,I.jsxs)(H,{span:!0,c:`dimmed`,fs:`italic`,children:[`default\xA0(`,qK(!0),`)`]}),...S}),(0,I.jsx)(iq,{value:t.find(e=>e.name===`ginPendingListLimit`)?.valueInteger,defaultValue:(0,I.jsxs)(H,{span:!0,c:`dimmed`,fs:`italic`,children:[`default\xA0(`,u,`)`]}),...S}),(0,I.jsx)(iq,{value:t.find(e=>e.name===`indexOptions`)?.valueString,defaultValue:(0,I.jsx)(H,{span:!0,c:`dimmed`,fs:`italic`,children:`NULL`}),...S})]},n)})]})]})})]}),(0,I.jsx)(rg,{opened:t,onClose:r,title:i,centered:!0,size:`auto`,children:o})]})}function iq({value:e,onClick:t,defaultValue:n}){return(0,I.jsx)(K.Td,{style:{cursor:`pointer`},onClick:()=>t?.(e),children:e===void 0?n:qK(e)})}var aq=[{label:`GIN Indexes`,value:`gin-indexes`},{label:`Column Statistics`,value:`column-statistics`},{label:`Array Column Padding`,value:`array-padding`}];function oq(){let e=Z();return!e.isLoading()&&!e.isSuperAdmin()?(0,I.jsx)(EP,{outcome:Hx}):(0,I.jsx)(hP,{maw:`100%`,children:(0,I.jsxs)(_P,{children:[(0,I.jsx)(q,{order:1,children:`Database Tools`}),(0,I.jsxs)(yz,{baseUrl:`/admin/super/db`,tabs:aq,children:[(0,I.jsx)(vb.Panel,{value:`gin-indexes`,pt:`md`,children:(0,I.jsx)(rq,{})}),(0,I.jsx)(vb.Panel,{value:`column-statistics`,pt:`md`,children:(0,I.jsx)(YK,{})}),(0,I.jsx)(vb.Panel,{value:`array-padding`,pt:`md`,children:(0,I.jsx)(UK,{})})]})]})})}function sq(){let e=Z(),[t,n]=(0,b.useState)(e.getProject()),[r,i]=(0,b.useState)(),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(void 0);return(0,I.jsxs)(CN,{onSubmit:(0,b.useCallback)(n=>{let i={resourceType:n.resourceType,firstName:n.firstName,lastName:n.lastName,email:n.email,sendEmail:n.sendEmail===`on`,accessPolicy:r,admin:n.isAdmin===`on`,scope:n.isProjectScoped===`on`?`project`:`server`,mfaRequired:n.mfaRequired===`on`};return e.invite(t?.id,i).then(t=>{e.invalidateSearches(`Patient`),e.invalidateSearches(`Practitioner`),e.invalidateSearches(`ProjectMembership`),qx(t)?o(t):u(t),c(i.sendEmail??!1),J({color:`green`,message:`Invite success`})}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1}),o(Zx(e))})},[e,t,r]),children:[!l&&!a&&(0,I.jsxs)(G,{children:[(0,I.jsx)(q,{children:`Invite new member`}),e.isSuperAdmin()&&(0,I.jsx)(AF,{title:`Project`,htmlFor:`project`,outcome:a,children:(0,I.jsx)(sI,{resourceType:`Project`,name:`project`,defaultValue:t,onChange:n})}),(0,I.jsx)(Eg,{name:`resourceType`,label:`Role`,defaultValue:`Practitioner`,data:[`Practitioner`,`Patient`,`RelatedPerson`],error:bP(a,`resourceType`)}),(0,I.jsx)(yb,{name:`firstName`,label:`First Name`,required:!0,autoFocus:!0,error:bP(a,`firstName`)}),(0,I.jsx)(yb,{name:`lastName`,label:`Last Name`,required:!0,error:bP(a,`lastName`)}),(0,I.jsx)(yb,{name:`email`,type:`email`,label:`Email`,required:!0,error:bP(a,`email`)}),(0,I.jsx)(AF,{title:`Access Policy`,htmlFor:`accessPolicy`,outcome:a,children:(0,I.jsx)(MK,{name:`accessPolicy`,onChange:i})}),(0,I.jsx)(lp,{name:`sendEmail`,label:`Send email`,defaultChecked:!0}),(0,I.jsx)(lp,{name:`isAdmin`,label:`Admin`}),(0,I.jsx)(lp,{name:`isProjectScoped`,label:`Project scoped`}),(0,I.jsx)(lp,{name:`mfaRequired`,label:`MFA required`}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(wN,{children:`Invite`})})]}),a&&(0,I.jsxs)(`div`,{"data-testid":`success`,children:[(0,I.jsx)(`p`,{children:`User created, email couldn't be sent`}),(0,I.jsx)(`p`,{children:`Could not send email. Make sure you have AWS SES set up.`}),(0,I.jsxs)(`p`,{children:[`Click `,(0,I.jsx)(Wj,{to:`/admin/project`,children:`here`}),` to return to the project admin page.`]})]}),l&&(0,I.jsxs)(`div`,{"data-testid":`success`,children:[(0,I.jsx)(H,{children:`User created`}),s&&(0,I.jsx)(H,{children:`Email sent`}),(0,I.jsxs)(yh,{children:[(0,I.jsx)(yh.Item,{children:(0,I.jsx)(Wj,{to:l,children:`Go to new membership`})}),(0,I.jsx)(yh.Item,{children:(0,I.jsx)(Wj,{to:l.profile,children:`Go to new profile`})}),(0,I.jsx)(yh.Item,{children:(0,I.jsx)(Wj,{to:`/admin/users`,children:`Back to users list`})})]})]})]})}function cq(){let e=Z(),{membershipId:t}=SW(),n=e.readResource(`ProjectMembership`,t).read(),r=nk(n.profile),i=nk(n.user?.reference?.startsWith(`User/`)?{reference:n.user.reference}:void 0);return r?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{children:`ProjectMembership Details`}),(0,I.jsx)(Wj,{to:n,children:`Go to ProjectMembership`}),(0,I.jsx)(RL,{value:n}),(0,I.jsx)(q,{mt:`md`,children:`Profile Details`}),(0,I.jsxs)(Wj,{to:r,children:[`Go to `,r.resourceType]}),(0,I.jsx)(RL,{value:r,ignoreMissingValues:!0}),n.user?.reference?.startsWith(`User/`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{mt:`md`,children:`User Details`}),i?.project?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Wj,{to:`/User/${i.id}/email`,children:`Go to User (change login email)`}),(0,I.jsx)(RL,{value:i,ignoreMissingValues:!0})]}):(0,I.jsx)(Dd,{color:`yellow`,children:`This User is server-scoped and cannot be viewed in this project.`})]})]}):(0,I.jsx)(Ij,{})}function lq(){let e=Z(),t=e.isSuperAdmin(),n=OK(e),[r,{open:i,close:a}]=bn(!1),[o,s]=(0,b.useState)(!t&&n?{reference:`Project/${n}`}:void 0),[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)(`loading`),[f,p]=(0,b.useState)(!1),[m,h]=(0,b.useState)(0),g=o?.reference,_=g?.split(`/`)[1];(0,b.useEffect)(()=>{if(!c?.id){d(`loading`);return}let t=!1;return d(`loading`),e.readResource(`User`,c.id).then(e=>{t||d(e.meta?.project&&e.meta.project===_?`project`:`server`)}).catch(()=>{t||d(`server`)}),()=>{t=!0}},[e,c,_]);let v;u===`project`?v=`server`:u===`server`&&t&&(v=`project`);let y=!!(g&&c?.id&&v);function x(){y&&i()}function S(){if(!c?.id||!v)return;p(!0);let t={resourceType:`Parameters`,parameter:[{name:`scope`,valueCode:v}]};v===`project`&&o&&t.parameter?.push({name:`project`,valueReference:o}),e.post(e.fhirUrl(`User`,c.id,`$rescope`),t).then(()=>{J({color:`green`,message:`User rescoped successfully`}),e.invalidateSearches(`User`),l(void 0),h(e=>e+1),a()}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1})).finally(()=>p(!1))}let C=o?.display??g??`(no project selected)`,w=g?{"_has:ProjectMembership:user:project":g}:void 0,T=c?dq(c):void 0;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{order:2,children:`Rescope User`}),(0,I.jsxs)(`p`,{children:[`Move a User between `,(0,I.jsx)(`strong`,{children:`server`}),` scope (not tied to any Project) and `,(0,I.jsx)(`strong`,{children:`project`}),` scope (owned by a specific Project).`,` `,t?`Selecting a project-scoped User releases them to the server; selecting a server-scoped User assigns them to the chosen Project.`:`Project admins may release a project-scoped User in this Project to server scope. Re-assigning a User to a Project requires a super admin.`]}),(0,I.jsx)(CN,{onSubmit:x,children:(0,I.jsxs)(G,{children:[t&&(0,I.jsx)(AF,{title:`Project (required)`,htmlFor:`rescopeTargetProject`,children:(0,I.jsx)(cI,{name:`rescopeTargetProject`,placeholder:`Select a Project`,targetTypes:[`Project`],onChange:e=>{s(e),l(void 0),h(e=>e+1)}})}),(0,I.jsx)(AF,{title:`User (search by email; filtered to members of the selected Project)`,htmlFor:`rescopeTargetUser`,children:(0,I.jsx)(sI,{name:`rescopeTargetUser`,resourceType:`User`,placeholder:g?`Search by email`:`Select a Project first`,disabled:!g,searchCriteria:w,onChange:e=>l(e??void 0)},m)}),c&&(0,I.jsxs)(V,{gap:`sm`,children:[(0,I.jsx)(H,{children:T}),uq(u)]}),c&&u===`server`&&!t&&(0,I.jsxs)(Dd,{color:`yellow`,children:[`This User is in `,(0,I.jsx)(`strong`,{children:`server`}),` scope. Only a super admin can assign a server-scoped User to a Project.`]}),(0,I.jsx)(`div`,{children:(0,I.jsx)(U,{type:`submit`,disabled:!y,children:v===`project`?`Assign User to Project`:`Release User to Server`})})]})}),(0,I.jsx)(rg,{opened:r,onClose:a,title:`Confirm User Rescope`,centered:!0,size:`auto`,children:(0,I.jsxs)(G,{children:[(0,I.jsxs)(H,{children:[`You are about to change the scope of `,(0,I.jsxs)(`strong`,{children:[`User/`,c?.id]}),`.`]}),v===`server`?(0,I.jsxs)(H,{children:[`This will `,(0,I.jsx)(`strong`,{children:`release`}),` the User from project `,(0,I.jsx)(`strong`,{children:C}),` to`,` `,(0,I.jsx)(`strong`,{children:`server`}),` scope. Any existing ProjectMemberships will be left in place and may be left orphaned.`]}):(0,I.jsxs)(H,{children:[`This will `,(0,I.jsx)(`strong`,{children:`assign`}),` the User to project `,(0,I.jsx)(`strong`,{children:C}),`. The User will become a project-scoped resource belonging to that Project.`]}),v===`server`&&!t&&(0,I.jsxs)(Dd,{color:`red`,title:`This change cannot be reversed by a project admin`,children:[(0,I.jsx)(`strong`,{children:`You will need the help of a super admin to reverse this change.`}),` Once the User is released to server scope, only a super admin can re-assign the User back to this (or any) Project.`]}),(0,I.jsx)(H,{c:`red`,children:`This is a privileged operation. Double-check the User and target before continuing.`}),(0,I.jsxs)(V,{justify:`flex-end`,children:[(0,I.jsx)(U,{variant:`default`,onClick:a,disabled:f,children:`Cancel`}),(0,I.jsx)(U,{color:`red`,onClick:S,loading:f,children:`Confirm Rescope`})]})]})})]})}function uq(e){return e===`loading`?(0,I.jsx)(Sy,{height:22,width:70,radius:`xl`}):e===`project`?(0,I.jsx)(Mp,{color:`blue`,variant:`light`,children:`Project`}):(0,I.jsx)(Mp,{color:`gray`,variant:`light`,children:`Server`})}function dq(e){let t;if(e.firstName||e.lastName){let n={family:e.lastName};e.firstName&&(n.given=[e.firstName]),t=lw(n)}return t&&e.email?`${t} (${e.email})`:t??e.email??`User/${e.id}`}function fq(){let e=Z();if(!e.isLoading()&&!e.isProjectAdmin())return(0,I.jsx)(EP,{outcome:Hx});function t(t){e.post(`admin/projects/setpassword`,t).then(()=>J({color:`green`,message:`Done`})).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}return(0,I.jsxs)(vP,{width:600,children:[(0,I.jsx)(q,{order:1,children:`Project Admin`}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Force Set Password`}),(0,I.jsx)(H,{children:`Sets the password for the specified user in this project.`}),(0,I.jsx)(H,{children:`This action can only be performed by project administrators. Passwords can only be set for users scoped in this project.`}),(0,I.jsx)(CN,{onSubmit:t,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(yb,{name:`email`,label:`Email`,required:!0}),(0,I.jsx)(sv,{name:`password`,label:`Password`,required:!0}),(0,I.jsx)(U,{type:`submit`,children:`Force Set Password`})]})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(lq,{})]})}function pq(){let e=Z(),t=OK(e),n=e.get(`admin/projects/${t}`).read();return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{children:`Details`}),(0,I.jsxs)(cP,{children:[(0,I.jsx)(lP,{term:`ID`,children:n.project.id}),(0,I.jsx)(lP,{term:`Name`,children:n.project.name})]})]})}var mq=[{label:`Details`,value:`details`},{label:`Users`,value:`users`},{label:`Clients`,value:`clients`},{label:`Bots`,value:`bots`},{label:`Secrets`,value:`secrets`},{label:`Sites`,value:`sites`},{label:`Rate Limits`,value:`rate-limits`}];function hq(){let e=Z(),t=OK(e),n=(0,b.useMemo)(()=>e.get(`admin/projects/`+t).read(),[e,t]);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(yl,{children:[(0,I.jsx)(_z,{children:(0,I.jsxs)(_z.Entry,{children:[(0,I.jsx)(_z.Key,{children:`Project`}),(0,I.jsx)(_z.Value,{children:n.project.name})]})}),(0,I.jsx)(ul,{children:(0,I.jsx)(yz,{baseUrl:`/admin`,tabs:mq})})]}),(0,I.jsx)(hP,{maw:`100%`,children:(0,I.jsx)(_P,{children:(0,I.jsx)(iG,{})})})]})}function gq(e,t){return e?.find(e=>e.name===t)?.valueString}function _q(e,t){return e?.find(e=>e.name===t)?.valueInteger}function vq(e,t){return e?.find(e=>e.name===t)?.valueReference}function yq(e){let t=e.parameter?.find(e=>e.name===`project`);return{project:{id:gq(t?.part,`id`)??``,limit:_q(t?.part,`limit`),consumedPoints:_q(t?.part,`consumedPoints`),remainingPoints:_q(t?.part,`remainingPoints`),msBeforeReset:_q(t?.part,`msBeforeReset`)},memberships:(e.parameter?.filter(e=>e.name===`membership`)??[]).map(e=>({membershipId:gq(e.part,`membershipId`)??``,profile:vq(e.part,`profile`),limit:_q(e.part,`limit`),consumedPoints:_q(e.part,`consumedPoints`),remainingPoints:_q(e.part,`remainingPoints`),msBeforeReset:_q(e.part,`msBeforeReset`)}))}}function bq(e){if(!(e.limit===void 0||e.consumedPoints===void 0))return e.limit===0?0:e.consumedPoints/e.limit*100}function xq(e){return e>=90?`red`:e>=70?`yellow`:`green`}function Sq(e){if(e===void 0)return`--`;let t=Math.ceil(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Cq(e){return e===void 0?`--`:e.toLocaleString()}function wq(e){let t=bq(e);return t===void 0?`--`:`${t.toFixed(1)}%`}var Tq=`https://www.medplum.com/docs/api/fhir/operations/project-rate-limits`;function Eq(){let e=Z(),t=OK(e),[n,r]=(0,b.useState)(),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(`desc`),c=(0,b.useCallback)(()=>{a(!0),e.get(e.fhirUrl(`Project`,t,`$rate-limits`),{cache:`no-cache`}).then(e=>{r(yq(e))}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1})}).finally(()=>{a(!1)})},[e,t]),l=(0,b.useCallback)(()=>{s(e=>e===`desc`?`asc`:`desc`)},[]),u=(0,b.useMemo)(()=>n?[...n.memberships].sort((e,t)=>{let n=bq(e)??-1,r=bq(t)??-1;return o===`desc`?r-n:n-r}):[],[n,o]);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(V,{justify:`space-between`,mb:`md`,children:[(0,I.jsx)(q,{children:`Rate Limits`}),(0,I.jsxs)(V,{children:[(0,I.jsx)(Pd,{href:Tq,target:`_blank`,rel:`noopener noreferrer`,size:`sm`,children:`$rate-limits documentation`}),(0,I.jsx)(U,{leftSection:(0,I.jsx)(mj,{size:14}),loading:i,onClick:c,children:`Refresh`})]})]}),!n&&!i&&(0,I.jsx)(H,{c:`dimmed`,children:`Click Refresh to load current rate limit data.`}),n&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Dq,{project:n.project}),u.length===0?(0,I.jsx)(H,{c:`dimmed`,mt:`md`,children:`No membership rate limit data found.`}):(0,I.jsx)(Oq,{memberships:u,sortDirection:o,onToggleSort:l})]})]})}function Dq({project:e}){let t=bq(e);return(0,I.jsxs)(`div`,{style:{marginBottom:`1rem`},children:[(0,I.jsx)(q,{order:4,mb:`xs`,children:`Project Utilization`}),t===void 0?(0,I.jsx)(H,{c:`dimmed`,size:`sm`,children:`No project-level rate limit data recorded yet.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(V,{gap:`xl`,mb:`xs`,children:[(0,I.jsxs)(H,{size:`sm`,children:[(0,I.jsx)(`strong`,{children:`Consumed:`}),` `,Cq(e.consumedPoints),` / `,Cq(e.limit)]}),(0,I.jsxs)(H,{size:`sm`,children:[(0,I.jsx)(`strong`,{children:`Remaining:`}),` `,Cq(e.remainingPoints)]}),(0,I.jsxs)(H,{size:`sm`,children:[(0,I.jsx)(`strong`,{children:`Utilization:`}),` `,wq(e)]}),(0,I.jsxs)(H,{size:`sm`,children:[(0,I.jsx)(`strong`,{children:`Resets in:`}),` `,Sq(e.msBeforeReset)]})]}),(0,I.jsx)(gv,{value:t,color:xq(t),size:`lg`})]})]})}function Oq({memberships:e,sortDirection:t,onToggleSort:n}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{order:4,mt:`lg`,mb:`xs`,children:`Membership Utilization`}),(0,I.jsxs)(K,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:`Membership ID`}),(0,I.jsx)(K.Th,{children:`Profile`}),(0,I.jsx)(K.Th,{children:`Limit`}),(0,I.jsx)(K.Th,{children:`Consumed`}),(0,I.jsx)(K.Th,{children:`Remaining`}),(0,I.jsx)(K.Th,{children:(0,I.jsxs)(ml,{onClick:n,style:{fontWeight:700,display:`flex`,alignItems:`center`,gap:4},children:[`Utilization`,t===`desc`?(0,I.jsx)(dA,{size:14}):(0,I.jsx)(fA,{size:14})]})}),(0,I.jsx)(K.Th,{children:`Resets In`})]})}),(0,I.jsx)(K.Tbody,{children:e.map(e=>(0,I.jsx)(kq,{membership:e},e.membershipId))})]})]})}function kq({membership:e}){let t=vW(),n=bq(e);return(0,I.jsxs)(K.Tr,{onClick:()=>t(`/admin/users/${e.membershipId}`),style:{cursor:`pointer`},children:[(0,I.jsx)(K.Td,{children:e.membershipId}),(0,I.jsx)(K.Td,{children:(0,I.jsx)(dL,{value:e.profile})}),(0,I.jsx)(K.Td,{children:Cq(e.limit)}),(0,I.jsx)(K.Td,{children:Cq(e.consumedPoints)}),(0,I.jsx)(K.Td,{children:Cq(e.remainingPoints)}),(0,I.jsx)(K.Td,{children:n===void 0?`--`:(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(gv,{value:n,color:xq(n),size:`sm`,style:{flex:1,minWidth:60}}),(0,I.jsxs)(H,{size:`sm`,w:50,ta:`right`,children:[n.toFixed(1),`%`]})]})}),(0,I.jsx)(K.Td,{children:Sq(e.msBeforeReset)})]})}function Aq(){let e=Z(),t=OK(e),n=e.get(`admin/projects/${t}`).read(),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)();return(0,b.useEffect)(()=>{e.requestSchema(`Project`).then(()=>i(!0)).catch(console.log)},[e]),(0,b.useEffect)(()=>{n&&o(MC(n.project.secret||[]))},[e,n]),!r||!a?(0,I.jsx)(`div`,{children:`Loading...`}):(0,I.jsxs)(`form`,{noValidate:!0,autoComplete:`off`,onSubmit:n=>{n.preventDefault(),e.post(`admin/projects/${t}/secrets`,a).then(()=>e.get(`admin/projects/${t}`,{cache:`reload`})).then(()=>J({color:`green`,message:`Saved`})).catch(console.log)},children:[(0,I.jsx)(q,{children:`Project Secrets`}),(0,I.jsx)(`p`,{children:`Use project secrets to store sensitive information such as API keys or other access credentials.`}),(0,I.jsx)(TI,{property:Bw(`Project`,`secret`),name:`secret`,path:`Project.secret`,defaultValue:a,onChange:o,outcome:void 0}),(0,I.jsx)(U,{type:`submit`,children:`Save`})]})}function jq(){let e=Z(),t=OK(e),n=e.get(`admin/projects/${t}`).read(),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)();return(0,b.useEffect)(()=>{e.requestSchema(`Project`).then(()=>i(!0)).catch(console.log)},[e]),(0,b.useEffect)(()=>{n&&o(MC(n.project.site||[]))},[e,n]),!r||!a?(0,I.jsx)(`div`,{children:`Loading...`}):(0,I.jsxs)(`form`,{noValidate:!0,autoComplete:`off`,onSubmit:n=>{n.preventDefault(),e.post(`admin/projects/${t}/sites`,a).then(()=>e.get(`admin/projects/${t}`,{cache:`reload`})).then(()=>J({color:`green`,message:`Saved`})).catch(e=>{let t=Zx(e);J({color:`red`,message:`Error ${t.issue?.[0].details?.text} ${t.issue?.[0].expression?.[0]}`,autoClose:!1})})},children:[(0,I.jsx)(q,{children:`Project Sites`}),(0,I.jsx)(`p`,{children:`Use project sites configure your project on a separate domain.`}),(0,I.jsx)(TI,{property:Bw(`Project`,`site`),name:`site`,path:`Project.site`,defaultValue:a,onChange:o,outcome:void 0}),(0,I.jsx)(U,{type:`submit`,children:`Save`})]})}var Mq=[{label:`Post-deploy Migrations`,value:`migrations`},{label:`System AsyncJob`,value:`asyncjob`}];function Nq(){let e=Z();return!e.isLoading()&&!e.isSuperAdmin()?(0,I.jsx)(EP,{outcome:Hx}):(0,I.jsx)(hP,{miw:`1600`,maw:`2000`,children:(0,I.jsxs)(_P,{children:[(0,I.jsx)(q,{order:1,children:`AsyncJob Dashboard`}),(0,I.jsxs)(yz,{baseUrl:`/admin/super/asyncjob`,tabs:Mq,keepMounted:!1,children:[(0,I.jsx)(vb.Panel,{value:`asyncjob`,pt:`md`,children:(0,I.jsx)(Fq,{})}),(0,I.jsx)(vb.Panel,{value:`migrations`,pt:`md`,children:(0,I.jsx)(Lq,{})})]})]})})}var Pq={resourceType:`AsyncJob`,fields:[`id`,`_lastUpdated`,`request`,`status`,`type`],filters:[{code:`_project`,operator:X.MISSING,value:`true`}],sortRules:[{code:`_lastUpdated`,descending:!0}]};function Fq(){let e=vW(),[t]=(0,b.useState)(Pq);return(0,I.jsxs)(G,{children:[(0,I.jsx)(Wj,{to:`/${t.resourceType}/${cE(t)}`,children:`Show in search page`}),(0,I.jsx)(sz,{checkboxesEnabled:!1,search:t,onClick:t=>e(zq(t.resource))?.catch(console.error),onAuxClick:e=>window.open(zq(e.resource),`_blank`)})]})}var Iq={resourceType:`AsyncJob`,fields:[`id`,`_lastUpdated`,`request`,`status`,`type`],filters:[{code:`_project`,operator:X.MISSING,value:`true`},{code:`type`,operator:X.EQUALS,value:`data-migration`}],count:1e3,sortRules:[{code:`_lastUpdated`,descending:!0}]};function Lq(){let e=Z(),[t,n]=(0,b.useState)(),[r,i]=(0,b.useState)(),[a,o]=(0,b.useState)([]),[s,c]=(0,b.useState)(0),[l,u]=(0,b.useState)([]);(0,b.useEffect)(()=>{let t=`info`;u(e=>e.includes(t)?e:[...e,t]),e.get(`admin/super/migrations`,{cache:`no-cache`}).then(e=>{e.postDeployMigrations.sort((e,t)=>t-e),n(e)}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1})}).finally(()=>u(e=>e.filter(e=>e!==t)))},[e,s]),(0,b.useEffect)(()=>{let t=`jobs`;u(e=>e.includes(t)?e:[...e,t]),e.requestSchema(`AsyncJob`).then(()=>e.search(`AsyncJob`,cE({...Iq,total:`accurate`,fields:void 0}),{cache:`no-cache`}).then(e=>{i(e.entry?.map(e=>e.resource))})).catch(e=>{i(void 0),J({color:`red`,message:Qx(e),autoClose:!1})}).finally(()=>u(e=>e.filter(e=>e!==t)))},[e,s]);function d(){c(e=>e+1)}function f(t){QK(e,`Run pending post-deploy migration`,`admin/super/migrate`,{dataVersion:t}).finally(()=>{d()}).catch(()=>{}),d()}let p=l.length>0;function m(e,{isLoading:t}){return(0,I.jsxs)(`div`,{style:{position:`relative`},children:[(0,I.jsx)(Ch,{visible:t}),(0,I.jsxs)(K,{children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:`Version`}),(0,I.jsx)(K.Th,{children:`Action`}),(0,I.jsx)(K.Th,{children:`Status`}),(0,I.jsx)(K.Th,{children:`AsyncJob`}),(0,I.jsx)(K.Th,{children:`Last Updated`}),(0,I.jsx)(K.Th,{children:`Request Time`}),(0,I.jsx)(K.Th,{children:`Duration`}),(0,I.jsx)(K.Th,{children:`Attempts`})]})}),(0,I.jsx)(K.Tbody,{children:e()})]})]})}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(U,{size:`xs`,mb:`xs`,variant:`subtle`,leftSection:(0,I.jsx)(mj,{size:14}),onClick:d,loading:p,children:`Refresh`}),m(()=>{if(!p){if(!t)return(0,I.jsx)(K.Tr,{children:(0,I.jsx)(K.Td,{colSpan:6,children:`Failed to load migration info`})});if(!r)return(0,I.jsx)(K.Tr,{children:(0,I.jsx)(K.Td,{colSpan:6,children:`Failed to load async jobs`})})}return!t||!r?null:t.postDeployMigrations?.map(e=>{let{status:n,asyncJob:i,asyncJobs:s}=Rq(e,r??[],t?.pendingPostDeployMigration),c=a.includes(e),l=e===t?.pendingPostDeployMigration&&(!i||i?.status===`error`),u=[(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:e}),(0,I.jsx)(K.Td,{children:l&&(0,I.jsx)(U,{color:`green`,size:`xs`,onClick:()=>f(e),children:`Start`})}),(0,I.jsx)(K.Td,{children:n}),(0,I.jsx)(K.Td,{children:i&&(0,I.jsx)(Wj,{to:`/AsyncJob/${i?.id}`,children:i?.id})}),(0,I.jsx)(K.Td,{children:i?.meta?.lastUpdated}),(0,I.jsx)(K.Td,{children:i?.requestTime}),(0,I.jsx)(K.Td,{children:Bq(i)}),(0,I.jsx)(K.Td,{display:`flex`,children:(0,I.jsxs)(V,{gap:`xs`,children:[s.length?s.length:``,c&&s.length>1&&(0,I.jsx)(U,{leftSection:(0,I.jsx)(ij,{size:14}),variant:`subtle`,color:`blue`,size:`xs`,radius:`xs`,onClick:()=>o(t=>t.includes(e)?t.filter(t=>t!==e):t),children:`Hide all`}),!c&&s.length>1&&(0,I.jsx)(U,{leftSection:(0,I.jsx)(fj,{size:14}),variant:`subtle`,color:`blue`,size:`xs`,radius:`xs`,onClick:()=>o(t=>t.includes(e)?t:[...t,e]),children:`Show all`})]})})]},e)];return c&&u.push(...s.filter(e=>e.id!==i?.id).map(t=>(0,I.jsxs)(K.Tr,{bg:`gray.1`,children:[(0,I.jsx)(K.Td,{children:e}),(0,I.jsx)(K.Td,{}),(0,I.jsx)(K.Td,{children:t.status}),(0,I.jsx)(K.Td,{children:(0,I.jsx)(Wj,{to:`/AsyncJob/${t.id}`,children:t.id})}),(0,I.jsx)(K.Td,{children:t.meta?.lastUpdated}),(0,I.jsx)(K.Td,{children:t.requestTime}),(0,I.jsx)(K.Td,{children:Bq(t)}),(0,I.jsx)(K.Td,{})]},t.id))),u})},{isLoading:p})]})}function Rq(e,t,n){let r=t.filter(t=>t.dataVersion===e),i=r.find(e=>e.status===`completed`)??r[0],a;return a=n===0?i?.status??`completed`:e>n?i?.status??`pending`:e===n?i?.status??`next`:i?.status??`completed`,{status:a,asyncJob:i,asyncJobs:r}}function zq(e){return`/${e.resourceType}/${e.id}`}function Bq(e){let t=e?.requestTime,n=e?.transactionTime??e?.meta?.lastUpdated;if(!t||!n)return``;let r=new Date(t),i=new Date(n).getTime()-r.getTime();if(i<1e3)return`${i.toFixed(0)}ms`;let a=i/1e3;return a<60?`${a.toFixed(2)}s`:a<3600?`${(a/60).toFixed(2)}m`:`${(a/3600).toFixed(2)}h`}function Vq(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Hq({entry:e}){return(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:(0,I.jsxs)(`div`,{style:{paddingLeft:50},children:[(0,I.jsxs)(H,{size:`xs`,c:`dimmed`,children:[`Subscription: `,(0,I.jsx)(mF,{value:{reference:`Subscription/${e.subscriptionId}`}})]}),(0,I.jsxs)(H,{size:`xs`,c:`dimmed`,children:[`Author:`,` `,(0,I.jsx)(Wj,{to:{reference:e.author},children:(0,I.jsx)(dL,{value:{reference:e.author}})})]}),e.expiration?(0,I.jsxs)(H,{size:`xs`,c:`dimmed`,children:[`Expires at:`,` `,new Date(e.expiration*1e3).toLocaleString(void 0,{timeZoneName:`short`})]}):null]})}),(0,I.jsx)(K.Td,{})]},e.subscriptionId)}function Uq({criteria:e,expanded:t,onToggle:n}){return(0,I.jsxs)(b.Fragment,{children:[(0,I.jsxs)(K.Tr,{onClick:n,style:{cursor:`pointer`},children:[(0,I.jsx)(K.Td,{children:(0,I.jsxs)(V,{gap:`xs`,pl:`xl`,children:[(0,I.jsx)(H,{size:`xs`,children:t?`▼`:`▶`}),(0,I.jsx)(H,{size:`sm`,c:`dimmed`,children:e.criteria})]})}),(0,I.jsx)(K.Td,{children:e.count})]}),t&&e.entries?.map(e=>(0,I.jsx)(Hq,{entry:e},e.subscriptionId))]})}function Wq({projectId:e,rt:t,rtDetail:n,isLoading:r,expanded:i,expandedCriteria:a,onToggle:o,onToggleCriteria:s}){let c=`${e}:${t.resourceType}`;return(0,I.jsxs)(b.Fragment,{children:[(0,I.jsxs)(K.Tr,{onClick:o,style:{cursor:`pointer`},children:[(0,I.jsx)(K.Td,{children:(0,I.jsxs)(V,{gap:`xs`,pl:`md`,children:[(0,I.jsx)(H,{size:`xs`,children:i?`▼`:`▶`}),(0,I.jsx)(H,{children:t.resourceType})]})}),(0,I.jsx)(K.Td,{children:t.count})]}),i&&(0,I.jsxs)(I.Fragment,{children:[r&&!n&&(0,I.jsx)(K.Tr,{children:(0,I.jsx)(K.Td,{colSpan:2,children:(0,I.jsx)(H,{pl:`xl`,size:`sm`,c:`dimmed`,children:`Loading...`})})}),n?.criteria.map(e=>{let t=`${c}:${e.criteria}`;return(0,I.jsx)(Uq,{criteria:e,expanded:a.has(t),onToggle:()=>s(t)},t)})]})]})}function Gq({project:e,expanded:t,expandedResourceTypes:n,expandedCriteria:r,projectDetail:i,isLoadingDetail:a,onToggle:o,onToggleResourceType:s,onToggleCriteria:c}){return(0,I.jsxs)(b.Fragment,{children:[(0,I.jsxs)(K.Tr,{onClick:o,style:{cursor:`pointer`},children:[(0,I.jsx)(K.Td,{children:(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(H,{size:`xs`,children:t?`▼`:`▶`}),(0,I.jsx)(mF,{value:{reference:`Project/${e.projectId}`,display:e.projectName}})]})}),(0,I.jsx)(K.Td,{children:e.subscriptionCount})]}),t&&e.resourceTypes.map(t=>{let o=`${e.projectId}:${t.resourceType}`;return(0,I.jsx)(Wq,{projectId:e.projectId,rt:t,rtDetail:i?.find(e=>e.resourceType===t.resourceType),isLoading:a,expanded:n.has(o),expandedCriteria:r,onToggle:()=>s(e.projectId,t.resourceType),onToggleCriteria:c},o)})]})}function Kq(){let e=Z(),[t,n]=(0,b.useState)(),[r,i]=(0,b.useState)(!1),[a,{open:o,close:s}]=bn(!1),[c,l]=(0,b.useState)(new Set),[u,d]=(0,b.useState)(new Set),[f,p]=(0,b.useState)(new Set),[m,h]=(0,b.useState)(new Map),[g,_]=(0,b.useState)(new Map);function v(){i(!0),e.get(`fhir/R4/$get-ws-sub-stats`,{cache:`no-cache`}).then(e=>{let t=e.parameter?.find(e=>e.name===`stats`)?.valueString;t&&n(JSON.parse(t).projects),o()}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1})).finally(()=>i(!1))}function y(t,n){let r=`${t}:${n}`;m.has(t)||(_(e=>new Map(e).set(t,!0)),e.get(`fhir/R4/$get-ws-sub-project-stats?projectId=${encodeURIComponent(t)}`,{cache:`no-cache`}).then(e=>{let n=e.parameter?.find(e=>e.name===`stats`)?.valueString;if(n){let e=JSON.parse(n);h(n=>new Map(n).set(t,e.resourceTypes))}}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1})).finally(()=>_(e=>{let n=new Map(e);return n.delete(t),n}))),d(e=>Vq(e,r))}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(U,{onClick:v,loading:r,children:`Get WS Sub Stats`}),(0,I.jsxs)(rg,{opened:a,onClose:s,title:`WebSocket Subscription Stats`,size:`xl`,centered:!0,children:[!t?.length&&(0,I.jsx)(H,{children:`No active WebSocket subscriptions found.`}),t&&t.length>0&&(0,I.jsxs)(K,{striped:!0,highlightOnHover:!0,withTableBorder:!0,withColumnBorders:!0,tabularNums:!0,children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:`Project / Resource Type / Criteria`}),(0,I.jsx)(K.Th,{children:`Count`})]})}),(0,I.jsx)(K.Tbody,{children:t.map(e=>(0,I.jsx)(Gq,{project:e,expanded:c.has(e.projectId),expandedResourceTypes:u,expandedCriteria:f,projectDetail:m.get(e.projectId),isLoadingDetail:g.get(e.projectId)===!0,onToggle:()=>l(t=>Vq(t,e.projectId)),onToggleResourceType:y,onToggleCriteria:e=>p(t=>Vq(t,e))},e.projectId))})]})]})]})}function qq(){let e=Z(),[t,{open:n,close:r}]=bn(!1),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)();if(!e.isLoading()&&!e.isSuperAdmin())return(0,I.jsx)(EP,{outcome:Hx});function u(){$K(e,`Rebuilding Structure Definitions`,`admin/super/structuredefinitions`)}function d(){$K(e,`Rebuilding Search Parameters`,`admin/super/searchparameters`)}function f(){$K(e,`Rebuilding Value Sets`,`admin/super/valuesets`)}function p(t){$K(e,`Reindexing Resources`,`admin/super/reindex`,t)}function m(){$K(e,`Reload Cron Resources`,`admin/super/reloadcron`)}function h(){r();let t=sC(c);e.post(`fhir/R4/$clear-all-ws-subs`,t?{resourceType:`Parameters`,parameter:[{name:`projectId`,valueString:t}]}:void 0).then(()=>J({color:`green`,message:`Done`})).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1})),l(void 0)}function g(t){e.post(`admin/super/removebotidjobsfromqueue`,t).then(()=>J({color:`green`,message:`Done`})).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}function _(t){e.post(`admin/super/purge`,{...t,before:HF(t.before)}).then(()=>J({color:`green`,message:`Done`})).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}function v(t){e.post(`admin/super/setpassword`,t).then(()=>J({color:`green`,message:`Done`})).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}function y(t){e.post(`fhir/R4/$db-stats`,t.tableNames?{resourceType:`Parameters`,parameter:[{name:`tableNames`,valueString:t.tableNames}]}:void 0).then(e=>{a(`Database Stats`),s((0,I.jsx)(`pre`,{children:e.parameter?.find(e=>e.name===`tableString`)?.valueString})),n()}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}function x(){e.post(`fhir/R4/$db-invalid-indexes`).then(e=>{a(`Database Invalid Indexes`),s((0,I.jsx)(`pre`,{children:e.parameter?.filter(e=>e.name===`invalidIndex`).map(e=>e.valueString).join(`
220
- `)})),n()}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}function S(){e.post(`fhir/R4/$db-schema-diff`).then(e=>{a(`Schema Diff`),s((0,I.jsx)(`pre`,{children:e.parameter?.find(e=>e.name===`migrationString`)?.valueString})),n()}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}function C(){$K(e,`Reconcile Schema Diff`,`admin/super/reconcile-db-schema-drift`)}return(0,I.jsxs)(vP,{width:600,children:[(0,I.jsx)(q,{order:1,children:`Super Admin`}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Structure Definitions`}),(0,I.jsx)(`p`,{children:`StructureDefinition resources contain the metadata about resource types. They are provided with the FHIR specification. Medplum also includes some custom StructureDefinition resources for internal data types. Press this button to update the database StructureDefinitions from the FHIR specification.`}),(0,I.jsx)(CN,{children:(0,I.jsx)(U,{onClick:u,children:`Rebuild StructureDefinitions`})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Search Parameters`}),(0,I.jsx)(`p`,{children:`SearchParameter resources contain the metadata about filters and sorting. They are provided with the FHIR specification. Medplum also includes some custom SearchParameter resources for internal data types. Press this button to update the database SearchParameters from the FHIR specification.`}),(0,I.jsx)(CN,{children:(0,I.jsx)(U,{onClick:d,children:`Rebuild SearchParameters`})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Value Sets`}),(0,I.jsx)(`p`,{children:`ValueSet resources enum values for a wide variety of use cases. Press this button to update the database ValueSets from the FHIR specification.`}),(0,I.jsx)(CN,{children:(0,I.jsx)(U,{onClick:f,children:`Rebuild ValueSets`})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Reindex Resources`}),(0,I.jsx)(`p`,{children:`When Medplum changes how resources are indexed, the system may require a reindex for old resources to be indexed properly.`}),(0,I.jsx)(Yq,{onSubmit:p}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Purge Resources`}),(0,I.jsx)(`p`,{children:`As system generated resources accumulate, the system may require a purge to remove old resources.`}),(0,I.jsx)(CN,{onSubmit:_,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(AF,{title:`Purge Resource Type`,htmlFor:`purgeResourceType`,children:(0,I.jsx)(Eg,{id:`purgeResourceType`,name:`resourceType`,data:[``,`AuditEvent`,`Login`]})}),(0,I.jsx)(AF,{title:`Purge Before`,htmlFor:`before`,children:(0,I.jsx)(UF,{name:`before`,placeholder:`Before Date`})}),(0,I.jsx)(U,{type:`submit`,children:`Purge`})]})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Remove Bot ID Jobs from Queue`}),(0,I.jsx)(`p`,{children:`Remove all queued jobs for a Bot ID`}),(0,I.jsx)(CN,{onSubmit:g,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(AF,{title:`Bot ID`,children:(0,I.jsx)(yb,{name:`botId`,placeholder:`Bot Id`})}),(0,I.jsx)(U,{type:`submit`,children:`Remove Jobs by Bot ID`})]})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Force Set Password`}),(0,I.jsx)(`p`,{children:`Note that this applies to all projects for the user. Therefore, this should only be used in extreme circumstances. Always prefer to use the "Forgot Password" flow first.`}),(0,I.jsx)(CN,{onSubmit:v,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(yb,{name:`email`,label:`Email`,required:!0}),(0,I.jsx)(sv,{name:`password`,label:`Password`,required:!0}),(0,I.jsx)(yb,{name:`projectId`,label:`Project ID`}),(0,I.jsx)(U,{type:`submit`,children:`Force Set Password`})]})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Database Stats`}),(0,I.jsx)(`p`,{children:`Query current table statistics from the database.`}),(0,I.jsx)(CN,{onSubmit:y,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(AF,{title:`Table Names (comma-delimited)`,htmlFor:`tableNames`,children:(0,I.jsx)(yb,{id:`tableNames`,name:`tableNames`,placeholder:`Observation,Observation_History`})}),(0,I.jsx)(U,{type:`submit`,children:`Get Database Stats`})]})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Database Invalid Indexes`}),(0,I.jsx)(`p`,{children:`Query invalid indexes from the database.`}),(0,I.jsx)(CN,{onSubmit:x,children:(0,I.jsx)(G,{children:(0,I.jsx)(U,{type:`submit`,children:`Get Database Invalid Indexes`})})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Database Schema Drift`}),(0,I.jsx)(`p`,{children:`Show the schema migration needed to match the expected database schema.`}),(0,I.jsxs)(Tm,{children:[(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(CN,{onSubmit:S,children:(0,I.jsx)(G,{children:(0,I.jsx)(U,{type:`submit`,children:`Get Schema Drift`})})})}),(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(CN,{onSubmit:C,children:(0,I.jsx)(G,{children:(0,I.jsx)(U,{type:`submit`,children:`Reconcile Schema Drift`})})})})]}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Reload Cron Resources`}),(0,I.jsx)(`p`,{children:`Obliterates the cron queue and rebuilds all the cron job schedulers for cron resources (eg. cron bots).`}),(0,I.jsx)(CN,{onSubmit:m,children:(0,I.jsx)(G,{children:(0,I.jsx)(U,{type:`submit`,children:`Reload Cron Resources`})})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Database Explain Search`}),(0,I.jsx)(`p`,{children:`Runs an EXPLAIN query on the database to show the query plan for a search.`}),(0,I.jsx)(Xq,{setModalTitle:a,setModalContent:s,openModal:n}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`WebSocket Subscription Stats`}),(0,I.jsx)(`p`,{children:`View active WebSocket subscription statistics by project, resource type, and criteria.`}),(0,I.jsx)(Kq,{}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Clear All WebSocket Subscriptions`}),(0,I.jsx)(`p`,{children:`Removes all active WebSocket subscription records from Redis. This is useful for cleaning up stale subscriptions during maintenance or after a deployment issue. Connected clients will need to re-bind.`}),(0,I.jsxs)(G,{children:[(0,I.jsx)(AF,{title:`Project (optional)`,htmlFor:`clearWsSubsProject`,children:(0,I.jsx)(cI,{name:`clearWsSubsProject`,placeholder:`All projects`,targetTypes:[`Project`],onChange:l})}),(0,I.jsx)(`div`,{children:(0,I.jsx)(U,{onClick:()=>{a(`Clear All WebSocket Subscriptions`),s((0,I.jsxs)(G,{children:[(0,I.jsxs)(H,{children:[`Are you sure you want to completely clear`,` `,(0,I.jsx)(`strong`,{children:c?`WebSocket subscriptions for "${c.display??c.reference}"`:`ALL WebSocket subscriptions`}),`? Connected clients will need to re-bind their subscriptions.`]}),(0,I.jsx)(V,{align:`center`,children:(0,I.jsx)(U,{color:`red`,onClick:h,children:`Clear`})})]})),n()},children:`Clear All WebSocket Subscriptions`})})]}),(0,I.jsx)(rg,{opened:t,onClose:r,title:i,centered:!0,size:`auto`,children:o}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(lq,{})]})}function Jq(){let[e,t]=(0,b.useState)(`outdated`);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Eg,{id:`reindexType`,name:`reindexType`,value:e,onChange:e=>t(e.target.value),data:[{label:`Outdated resources`,value:`outdated`},{label:`All resources`,value:`all`},{label:`Less than or equal to a specific version`,value:`specific`}]}),e===`specific`&&(0,I.jsx)(P_,{required:!0,name:`maxResourceVersion`,placeholder:`Max Resource Version`,min:0})]})}function Yq({onSubmit:e}){let[t,n]=(0,b.useState)(!1);function r(t){let n={};for(let[e,r]of Object.entries(t))r!==``&&(n[e]=r);e(n)}return(0,I.jsx)(CN,{onSubmit:r,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(AF,{title:`Resource Type`,htmlFor:`resourceType`,children:(0,I.jsx)(yb,{id:`resourceType`,name:`resourceType`,placeholder:`Reindex Resource Type`})}),(0,I.jsx)(AF,{title:`Search Filter`,htmlFor:`filter`,children:(0,I.jsx)(yb,{id:`filter`,name:`filter`,placeholder:`e.g. name=Sam&birthdate=lt2000-01-01`})}),(0,I.jsx)(AF,{title:`Max Resource Version`,htmlFor:`maxResourceVersion`,children:(0,I.jsx)(Jq,{})}),(0,I.jsx)(U,{variant:`subtle`,size:`xs`,onClick:()=>n(!t),children:t?`Hide Advanced Options`:`Show Advanced Options`}),t&&(0,I.jsx)(G,{gap:`sm`,children:(0,I.jsxs)(Tm,{children:[(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(P_,{name:`batchSize`,label:`Resources per batch`,description:(0,I.jsx)(`span`,{children:`default: 500`}),placeholder:`500`,min:20,max:1e3})}),(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(P_,{name:`searchStatementTimeout`,label:`Search query timeout (ms)`,description:(0,I.jsx)(`span`,{children:`default: 3,600,000 (1 hour)`}),placeholder:`3600000`,min:1e3})}),(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(P_,{name:`upsertStatementTimeout`,label:`Upsert query timeout (ms)`,description:(0,I.jsx)(`span`,{children:"default: server `database.queryTimeout`"}),placeholder:`database.queryTimeout`,min:1e3})}),(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(P_,{name:`delayBetweenBatches`,label:`Delay between batches (ms)`,description:(0,I.jsx)(`span`,{children:`default: 0`}),placeholder:`0`,min:0,max:6e4})}),(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(P_,{name:`progressLogThreshold`,label:`Log progress every N resources`,description:(0,I.jsx)(`span`,{children:`default: 50,000`}),placeholder:`50000`,min:1})}),(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(P_,{name:`endTimestampBufferMinutes`,label:`End timestamp buffer (minutes)`,description:(0,I.jsx)(`span`,{children:`default: 5`}),placeholder:`5`,min:1})}),(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(P_,{name:`maxIterationAttempts`,label:`Max iteration attempts`,description:(0,I.jsx)(`span`,{children:`default: 3`}),placeholder:`3`,min:1,max:20})})]})}),(0,I.jsx)(U,{type:`submit`,children:`Reindex`})]})})}function Xq({setModalTitle:e,setModalContent:t,openModal:n}){let r=Z(),[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)(),f=(0,b.useMemo)(()=>{if(i?.reference)return{"_has:ProjectMembership:profile:project":i.reference}},[i]);(0,b.useEffect)(()=>{if(d(void 0),!o?.reference&&!i?.reference){l(void 0);return}r.searchResources(`ProjectMembership`,{profile:o?.reference,project:i?.reference,_count:20}).then(e=>{l(e),e.length===1&&d(aC(e[0]))}).catch(e=>{console.error(e),J({color:`red`,message:Qx(e),autoClose:!1})})},[r,o,i]);let p=(0,b.useMemo)(()=>{let e={};return o?.reference&&(e.profile=o?.reference),i?.reference&&(e.project=i?.reference),e},[o,i]);function m(i){if(!i.query){J({color:`red`,message:`Query is required`,autoClose:!1});return}let a=i.onBehalfOfProjectMembership;delete i.onBehalfOfProjectMembership;let o={query:i.query,analyze:i.analyze===`on`,count:i.count===`on`,format:`text`},s={};a&&(s[`x-medplum-on-behalf-of`]=a),r.post(`fhir/R4/$explain`,o,void 0,{headers:s}).then(r=>{e(`Database Explain`);let i=r.parameter?.find(e=>e.name===`explain`)?.valueString,a=r.parameter?.find(e=>e.name===`query`)?.valueString,o=r.parameter?.find(e=>e.name===`parameters`)?.valueString,s=r.parameter?.find(e=>e.name===`countEstimate`)?.valueInteger?.toLocaleString(),c=r.parameter?.find(e=>e.name===`countAccurate`)?.valueInteger?.toLocaleString(),l=[a,o,`
219
+ `).replace(zd,``)}function Vd(e,t){return t=Bd(t),Bd(e)===t}function Hd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Gt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Gt(e,``+r);break;case`className`:kt(e,`class`,r);break;case`tabIndex`:kt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:kt(e,n,r);break;case`style`:Jt(e,r,o);break;case`data`:if(t!==`object`){kt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Qt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Hd(e,t,`name`,a.name,a,null),Hd(e,t,`formEncType`,a.formEncType,a,null),Hd(e,t,`formMethod`,a.formMethod,a,null),Hd(e,t,`formTarget`,a.formTarget,a,null)):(Hd(e,t,`encType`,a.encType,a,null),Hd(e,t,`method`,a.method,a,null),Hd(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Qt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=$t);break;case`onScroll`:r!=null&&kd(`scroll`,e);break;case`onScrollEnd`:r!=null&&kd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Qt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:kd(`beforetoggle`,e),kd(`toggle`,e),Ot(e,`popover`,r);break;case`xlinkActuate`:At(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:At(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:At(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:At(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:At(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:At(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:At(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:At(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:At(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Ot(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Xt.get(n)||n,Ot(e,n,r))}}function Ud(e,t,n,r,a,o){switch(n){case`style`:Jt(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Gt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Gt(e,``+r);break;case`onScroll`:r!=null&&kd(`scroll`,e);break;case`onScrollEnd`:r!=null&&kd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=$t);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!xt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[st]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):Ot(e,n,r)}}}function Wd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:kd(`error`,e),kd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Hd(e,t,o,s,n,null)}}a&&Hd(e,t,`srcSet`,n.srcSet,n,null),r&&Hd(e,t,`src`,n.src,n,null);return;case`input`:kd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Hd(e,t,r,d,n,null)}}Bt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in kd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Hd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Ht(e,!!r,n,!0):Ht(e,!!r,t,!1);return;case`textarea`:for(s in kd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Hd(e,t,s,c,n,null)}Wt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Hd(e,t,l,r,n,null)}return;case`dialog`:kd(`beforetoggle`,e),kd(`toggle`,e),kd(`cancel`,e),kd(`close`,e);break;case`iframe`:case`object`:kd(`load`,e);break;case`video`:case`audio`:for(r=0;r<Ed.length;r++)kd(Ed[r],e);break;case`image`:kd(`error`,e),kd(`load`,e);break;case`details`:kd(`toggle`,e);break;case`embed`:case`source`:case`link`:kd(`error`,e),kd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Hd(e,t,u,r,n,null)}return;default:if(Yt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Ud(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Hd(e,t,c,r,n,null))}function Gd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Hd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Hd(e,t,p,m,r,f)}}zt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Hd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Hd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Ht(e,!!n,n?[]:``,!1):Ht(e,!!n,t,!0)):Ht(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Hd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Hd(e,t,s,a,r,o)}Ut(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Hd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Hd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Hd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Hd(e,t,u,p,r,m)}return;default:if(Yt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Ud(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Ud(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Hd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Hd(e,t,f,p,r,m)}function Kd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function qd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Kd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Kd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Jd=null,Yd=null;function Xd(e){return e.nodeType===9?e:e.ownerDocument}function Zd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Qd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function $d(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var ef=null;function tf(){var e=window.event;return e&&e.type===`popstate`?e===ef?!1:(ef=e,!0):(ef=null,!1)}var nf=typeof setTimeout==`function`?setTimeout:void 0,rf=typeof clearTimeout==`function`?clearTimeout:void 0,af=typeof Promise==`function`?Promise:void 0,of=typeof queueMicrotask==`function`?queueMicrotask:af===void 0?nf:function(e){return af.resolve(null).then(e).catch(sf)};function sf(e){setTimeout(function(){throw e})}function cf(e){return e===`head`}function lf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Up(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)Cf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,Cf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[pt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&Cf(e.ownerDocument.body);n=i}while(n);Up(t)}function uf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function df(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:df(n),mt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function ff(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[pt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=vf(e.nextSibling),e===null)break}return null}function pf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=vf(e.nextSibling),e===null))return null;return e}function mf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=vf(e.nextSibling),e===null))return null;return e}function hf(e){return e.data===`$?`||e.data===`$~`}function gf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function _f(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function vf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var yf=null;function bf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return vf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function xf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function Sf(e,t,n){switch(t=Xd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Cf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);mt(e)}var wf=new Map,Tf=new Set;function Ef(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Df=P.d;P.d={f:Of,r:kf,D:Mf,C:Nf,L:Pf,m:Ff,X:Lf,S:If,M:Rf};function Of(){var e=Df.f(),t=Ou();return e||t}function kf(e){var t=gt(e);t!==null&&t.tag===5&&t.type===`form`?Os(t):Df.r(e)}var Af=typeof document>`u`?null:document;function jf(e,t,n){var r=Af;if(r&&typeof t==`string`&&t){var i=Rt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Tf.has(i)||(Tf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Wd(t,`link`,e),yt(t),r.head.appendChild(t)))}}function Mf(e){Df.D(e),jf(`dns-prefetch`,e,null)}function Nf(e,t){Df.C(e,t),jf(`preconnect`,e,t)}function Pf(e,t,n){Df.L(e,t,n);var r=Af;if(r&&e&&t){var i=`link[rel="preload"][as="`+Rt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Rt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Rt(n.imageSizes)+`"]`)):i+=`[href="`+Rt(e)+`"]`;var a=i;switch(t){case`style`:a=Bf(e);break;case`script`:a=Wf(e)}wf.has(a)||(e=f({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),wf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Vf(a))||t===`script`&&r.querySelector(Gf(a))||(t=r.createElement(`link`),Wd(t,`link`,e),yt(t),r.head.appendChild(t)))}}function Ff(e,t){Df.m(e,t);var n=Af;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Rt(r)+`"][href="`+Rt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Wf(e)}if(!wf.has(a)&&(e=f({rel:`modulepreload`,href:e},t),wf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Gf(a)))return}r=n.createElement(`link`),Wd(r,`link`,e),yt(r),n.head.appendChild(r)}}}function If(e,t,n){Df.S(e,t,n);var r=Af;if(r&&e){var i=vt(r).hoistableStyles,a=Bf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Vf(a)))s.loading=5;else{e=f({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=wf.get(a))&&Jf(e,n);var c=o=r.createElement(`link`);yt(c),Wd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,qf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Lf(e,t){Df.X(e,t);var n=Af;if(n&&e){var r=vt(n).hoistableScripts,i=Wf(e),a=r.get(i);a||(a=n.querySelector(Gf(i)),a||(e=f({src:e,async:!0},t),(t=wf.get(i))&&Yf(e,t),a=n.createElement(`script`),yt(a),Wd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Rf(e,t){Df.M(e,t);var n=Af;if(n&&e){var r=vt(n).hoistableScripts,i=Wf(e),a=r.get(i);a||(a=n.querySelector(Gf(i)),a||(e=f({src:e,async:!0,type:`module`},t),(t=wf.get(i))&&Yf(e,t),a=n.createElement(`script`),yt(a),Wd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function zf(e,t,n,r){var a=(a=le.current)?Ef(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Bf(n.href),n=vt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Bf(n.href);var o=vt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Vf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),wf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},wf.set(e,n),o||Uf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Wf(n),n=vt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Bf(e){return`href="`+Rt(e)+`"`}function Vf(e){return`link[rel="stylesheet"][`+e+`]`}function Hf(e){return f({},e,{"data-precedence":e.precedence,precedence:null})}function Uf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Wd(t,`link`,n),yt(t),e.head.appendChild(t))}function Wf(e){return`[src="`+Rt(e)+`"]`}function Gf(e){return`script[async]`+e}function Kf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Rt(n.href)+`"]`);if(r)return t.instance=r,yt(r),r;var a=f({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),yt(r),Wd(r,`style`,a),qf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Bf(n.href);var o=e.querySelector(Vf(a));if(o)return t.state.loading|=4,t.instance=o,yt(o),o;r=Hf(n),(a=wf.get(a))&&Jf(r,a),o=(e.ownerDocument||e).createElement(`link`),yt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Wd(o,`link`,r),t.state.loading|=4,qf(o,n.precedence,e),t.instance=o;case`script`:return o=Wf(n.src),(a=e.querySelector(Gf(o)))?(t.instance=a,yt(a),a):(r=n,(a=wf.get(o))&&(r=f({},n),Yf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),yt(a),Wd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,qf(r,n.precedence,e));return t.instance}function qf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Jf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Yf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Xf=null;function Zf(e,t,n){if(Xf===null){var r=new Map,i=Xf=new Map;i.set(n,r)}else i=Xf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[pt]||a[ot]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Qf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function $f(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function ep(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function tp(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Bf(r.href),a=t.querySelector(Vf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=ip.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,yt(a);return}a=t.ownerDocument||t,r=Hf(r),(i=wf.get(i))&&Jf(r,i),a=a.createElement(`link`),yt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Wd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=ip.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var np=0;function rp(e,t){return e.stylesheets&&e.count===0&&op(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&op(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&np===0&&(np=62500*qd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&op(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>np?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function ip(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)op(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var ap=null;function op(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ap=new Map,t.forEach(sp,e),ap=null,ip.call(e))}function sp(e,t){if(!(t.state.loading&4)){var n=ap.get(e);if(n)var r=n.get(null);else{n=new Map,ap.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=ip.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var cp={$$typeof:x,Provider:null,Consumer:null,_currentValue:te,_currentValue2:te,_threadCount:0};function lp(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Xe(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xe(0),this.hiddenUpdates=Xe(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function up(e,t,n,r,i,a,o,s,c,l,u,d){return e=new lp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=si(3,null,null,t),e.current=a,a.stateNode=e,t=oa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},za(a),e}function dp(e){return e?(e=L,e):L}function fp(e,t,n,r,i,a){i=dp(i),r.context===null?r.context=i:r.pendingContext=i,r=Va(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ha(e,r,t),n!==null&&(wu(n,e,t),Ua(n,e,t))}function pp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function mp(e,t){pp(e,t),(e=e.alternate)&&pp(e,t)}function hp(e){if(e.tag===13||e.tag===31){var t=ri(e,67108864);t!==null&&wu(t,e,67108864),mp(e,67108864)}}function gp(e){if(e.tag===13||e.tag===31){var t=Su();t=tt(t);var n=ri(e,t);n!==null&&wu(n,e,t),mp(e,t)}}var _p=!0;function vp(e,t,n,r){var i=N.T;N.T=null;var a=P.p;try{P.p=2,bp(e,t,n,r)}finally{P.p=a,N.T=i}}function yp(e,t,n,r){var i=N.T;N.T=null;var a=P.p;try{P.p=8,bp(e,t,n,r)}finally{P.p=a,N.T=i}}function bp(e,t,n,r){if(_p){var i=xp(r);if(i===null)Nd(e,t,r,Sp,n),Np(e,r);else if(Fp(i,e,t,n,r))r.stopPropagation();else if(Np(e,r),t&4&&-1<Mp.indexOf(e)){for(;i!==null;){var a=gt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Ke(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-ze(o);s.entanglements[1]|=c,o&=~c}fd(a),!(Ul&6)&&(uu=De()+500,pd(0,!1))}}break;case 31:case 13:s=ri(a,2),s!==null&&wu(s,a,2),Ou(),mp(a,2)}if(a=xp(r),a===null&&Nd(e,t,r,Sp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Nd(e,t,r,null,n)}}function xp(e){return e=tn(e),Cp(e)}var Sp=null;function Cp(e){if(Sp=null,e=ht(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Sp=e,null}function wp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Oe()){case ke:return 2;case Ae:return 8;case je:case Me:return 32;case Ne:return 268435456;default:return 32}default:return 32}}var Tp=!1,Ep=null,Dp=null,Op=null,kp=new Map,Ap=new Map,jp=[],Mp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Np(e,t){switch(e){case`focusin`:case`focusout`:Ep=null;break;case`dragenter`:case`dragleave`:Dp=null;break;case`mouseover`:case`mouseout`:Op=null;break;case`pointerover`:case`pointerout`:kp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Ap.delete(t.pointerId)}}function Pp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=gt(t),t!==null&&hp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Fp(e,t,n,r,i){switch(t){case`focusin`:return Ep=Pp(Ep,e,t,n,r,i),!0;case`dragenter`:return Dp=Pp(Dp,e,t,n,r,i),!0;case`mouseover`:return Op=Pp(Op,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return kp.set(a,Pp(kp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Ap.set(a,Pp(Ap.get(a)||null,e,t,n,r,i)),!0}return!1}function Ip(e){var t=ht(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,it(e.priority,function(){gp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,it(e.priority,function(){gp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Lp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=xp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);en=r,n.target.dispatchEvent(r),en=null}else return t=gt(n),t!==null&&hp(t),e.blockedOn=n,!1;t.shift()}return!0}function Rp(e,t,n){Lp(e)&&n.delete(t)}function zp(){Tp=!1,Ep!==null&&Lp(Ep)&&(Ep=null),Dp!==null&&Lp(Dp)&&(Dp=null),Op!==null&&Lp(Op)&&(Op=null),kp.forEach(Rp),Ap.forEach(Rp)}function Bp(e,n){e.blockedOn===n&&(e.blockedOn=null,Tp||(Tp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,zp)))}var Vp=null;function Hp(e){Vp!==e&&(Vp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Vp===e&&(Vp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Cp(r||n)===null)continue;break}var a=gt(n);a!==null&&(e.splice(t,3),t-=3,Es(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Up(e){function t(t){return Bp(t,e)}Ep!==null&&Bp(Ep,e),Dp!==null&&Bp(Dp,e),Op!==null&&Bp(Op,e),kp.forEach(t),Ap.forEach(t);for(var n=0;n<jp.length;n++){var r=jp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<jp.length&&(n=jp[0],n.blockedOn===null);)Ip(n),n.blockedOn===null&&jp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[st]||null;if(typeof a==`function`)o||Hp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[st]||null)s=o.formAction;else if(Cp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Hp(n)}}}function Wp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function U(e){this._internalRoot=e}Gp.prototype.render=U.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;fp(n,Su(),e,t,null,null)},Gp.prototype.unmount=U.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;fp(e.current,2,null,e,null,null),Ou(),t[ct]=null}};function Gp(e){this._internalRoot=e}Gp.prototype.unstable_scheduleHydration=function(e){if(e){var t=rt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<jp.length&&t!==0&&t<jp[n].priority;n++);jp.splice(n,0,e),n===0&&Ip(e)}};var Kp=n.version;if(Kp!==`19.2.7`)throw Error(i(527,Kp,`19.2.7`));P.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var qp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:N,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Jp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jp.isDisabled&&Jp.supportsFiber)try{Ie=Jp.inject(qp),Le=Jp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Ys,s=Xs,c=Zs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=up(e,1,!1,null,null,n,r,null,o,s,c,Wp),e[ct]=t.current,H(e),new U(t)}})),DK=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=EK()}))();function OK(e){if(e.resourceType===`Patient`)return e;if(e.resourceType===`DiagnosticReport`||e.resourceType===`Encounter`||e.resourceType===`Observation`||e.resourceType===`ServiceRequest`)return e.subject}function kK(e){if(e.resourceType===`Specimen`)return e;if(e.resourceType===`Observation`)return e.specimen;if(e.resourceType===`DiagnosticReport`||e.resourceType===`ServiceRequest`)return e.specimen?.[0]}function AK(e){return sC(e.getActiveLogin()?.project)}function jK(e){let t=AK(Z()),n=bW(),[r,i]=(0,b.useState)(e.profileTypeOptions[0].value),[a,o]=(0,b.useState)({resourceType:`ProjectMembership`,filters:[{code:`project`,operator:X.EQUALS,value:`Project/`+t},{code:`profile-type`,operator:X.EQUALS,value:r}],fields:e.fields,count:100});function s(e){i(e),o({...a,filters:[{code:`project`,operator:X.EQUALS,value:`Project/`+t},{code:`profile-type`,operator:X.EQUALS,value:e}]})}let c=e.profileTypeOptions.length>1;return(0,I.jsxs)(I.Fragment,{children:[(c||e.toolbarLeft!==void 0||e.toolbarRight!==void 0)&&(0,I.jsxs)(V,{justify:`space-between`,align:`center`,mb:`md`,wrap:`nowrap`,children:[(0,I.jsxs)(V,{gap:`md`,wrap:`nowrap`,children:[c&&(0,I.jsx)(uy,{value:r,onChange:s,data:e.profileTypeOptions}),e.toolbarLeft]}),e.toolbarRight]}),(0,I.jsx)(lz,{search:a,onClick:e=>n(`./${e.resource.id}`),onChange:e=>o(e.definition),hideFilters:!0,hideToolbar:!0})]})}function MK(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{children:`ProjectMemberships by Bot`}),(0,I.jsx)(jK,{profileTypeOptions:[{label:`Bot`,value:`Bot`}],fields:[`user`,`profile`,`accessPolicy`,`userConfiguration`,`active`,`admin`],toolbarLeft:(0,I.jsx)(yl,{withBorder:!0,p:`sm`,radius:`sm`,maw:520,children:(0,I.jsxs)(H,{size:`sm`,c:`dimmed`,children:[`Please note that this list is limited to Bots that have a ProjectMembership. Bots that are run as user commonly do not have a ProjectMembership, and are not included, such as most Bots in Medplum-managed integrations. For a complete list of Bots, see `,(0,I.jsx)(Kj,{to:`/Bot`,children:`Bots`}),`. For more information, see`,` `,(0,I.jsx)(Pd,{href:`https://www.medplum.com/docs/bots/bot-run-as-user`,target:`_blank`,rel:`noopener noreferrer`,children:`running Bots as user`}),`.`]})}),toolbarRight:(0,I.jsx)(Pd,{href:`https://www.medplum.com/docs/bots`,target:`_blank`,rel:`noopener noreferrer`,size:`sm`,children:`Learn more about Bots`})}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(Kj,{to:`/admin/bots/new`,children:`Create new bot`})})]})}function NK(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{children:`ProjectMemberships by ClientApplication`}),(0,I.jsx)(jK,{profileTypeOptions:[{label:`ClientApplication`,value:`ClientApplication`}],fields:[`user`,`profile`,`accessPolicy`,`userConfiguration`,`active`,`admin`]}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(Kj,{to:`/admin/clients/new`,children:`Create new client`})})]})}function PK(e){return(0,I.jsx)(lI,{resourceType:`AccessPolicy`,name:e.name,defaultValue:e.defaultValue,placeholder:`Access Policy`,onChange:t=>{Hw(t)?e.onChange(aC(t)):e.onChange(void 0)}})}function FK(){let e=Z(),t=AK(e),[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)(void 0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{children:`Create new Bot`}),(0,I.jsxs)(TN,{onSubmit:()=>{let r={name:n,description:i,accessPolicy:o};e.post(`admin/projects/`+t+`/bot`,r).then(t=>{e.invalidateSearches(`Bot`),e.invalidateSearches(`ProjectMembership`),d(t),J({color:`green`,message:`Bot created`})}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1}),l(Zx(e))})},children:[!u&&(0,I.jsxs)(G,{children:[(0,I.jsx)(MF,{title:`Name`,htmlFor:`name`,outcome:c,children:(0,I.jsx)(yb,{id:`name`,name:`name`,required:!0,autoFocus:!0,onChange:e=>r(e.currentTarget.value),error:SP(c,`name`)})}),(0,I.jsx)(MF,{title:`Description`,htmlFor:`description`,outcome:c,children:(0,I.jsx)(yb,{id:`description`,name:`description`,onChange:e=>a(e.currentTarget.value),error:SP(c,`description`)})}),(0,I.jsx)(MF,{title:`Access Policy`,htmlFor:`accessPolicy`,outcome:c,children:(0,I.jsx)(PK,{name:`accessPolicy`,onChange:s})}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(U,{type:`submit`,children:`Create Bot`})})]}),u&&(0,I.jsxs)(`div`,{"data-testid":`success`,children:[(0,I.jsx)(H,{children:`Bot created`}),(0,I.jsxs)(yh,{children:[(0,I.jsx)(yh.Item,{children:(0,I.jsx)(Kj,{to:u,children:`Go to new bot`})}),(0,I.jsx)(yh.Item,{children:(0,I.jsx)(Kj,{to:`/admin/bots`,children:`Back to bots list`})})]})]})]})]})}function IK(){let e=Z(),t=AK(e),[n,r]=(0,b.useState)(``),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)(),[f,p]=(0,b.useState)(void 0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{children:`Create new Client`}),(0,I.jsxs)(TN,{onSubmit:()=>{let r={name:n,description:i,redirectUri:o,accessPolicy:c};e.post(`admin/projects/`+t+`/client`,r).then(t=>{e.invalidateSearches(`ClientApplication`),e.invalidateSearches(`ProjectMembership`),p(t),J({color:`green`,message:`Client created`})}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1}),d(Zx(e))})},children:[!f&&(0,I.jsxs)(G,{children:[(0,I.jsx)(MF,{title:`Name`,htmlFor:`name`,outcome:u,children:(0,I.jsx)(yb,{id:`name`,name:`name`,required:!0,autoFocus:!0,onChange:e=>r(e.currentTarget.value),error:SP(u,`name`)})}),(0,I.jsx)(MF,{title:`Description`,htmlFor:`description`,outcome:u,children:(0,I.jsx)(yb,{id:`description`,name:`description`,onChange:e=>a(e.currentTarget.value),error:SP(u,`description`)})}),(0,I.jsx)(MF,{title:`Redirect URI`,htmlFor:`redirectUri`,outcome:u,children:(0,I.jsx)(yb,{id:`redirectUri`,name:`redirectUri`,onChange:e=>s(e.currentTarget.value),error:SP(u,`redirectUri`)})}),(0,I.jsx)(MF,{title:`Access Policy`,htmlFor:`accessPolicy`,outcome:u,children:(0,I.jsx)(PK,{name:`accessPolicy`,onChange:l})}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(U,{type:`submit`,children:`Create Client`})})]}),f&&(0,I.jsxs)(`div`,{"data-testid":`success`,children:[(0,I.jsx)(H,{children:`Client created`}),(0,I.jsxs)(yh,{children:[(0,I.jsx)(yh.Item,{children:(0,I.jsx)(Kj,{to:f,children:`Go to new client`})}),(0,I.jsx)(yh.Item,{children:(0,I.jsx)(Kj,{to:`/admin/clients`,children:`Back to clients list`})})]})]})]})]})}var LK=1e-10;function RK(e,t){let n=0,r=Math.exp(-t);for(let i=0;i<=e;i++)i>0&&(r*=t/i),n+=r;return n}function zK(e,t,n=LK){let r=0,i=Math.max(t+1,1);for(;RK(t,i)>e;)i*=2;for(;i-r>n;){let n=(r+i)/2;RK(t,n)>e?r=n:i=n}return i}function BK(e,t,n,r){let i=e*300,a=9*t*i/(e*10*1e3/7),o=Math.ceil(a),s=o/i,c=Math.max(r??0,s),l=r?c*i:o,u=l,d=RK(l-1,u),f=Math.log(1-n)/Math.log(d);return{rowsSampled:i,cutoffFrequencyExact:a,cutoffFrequency:o,minimumSelectivity:s,targetSelectivity:c,targetLambda:u,targetPoissonCdf:d,targetM:f,results:[{name:`Floor`,result:VK(Math.floor(f),n,l,i)},{name:`Ceiling`,result:VK(Math.ceil(f),n,l,i)}]}}function VK(e,t,n,r){let i=(1-t)**(1/e),a=zK(i,n-1);return{m:e,poissonCdf:i,lambda:a,f:a/r}}function HK(e,t=`auto`,n=6){return Number.isFinite(e)?t===`scientific`?e.toExponential(n):t===`fixed`?e.toFixed(n):Math.abs(e)<1e-4&&e!==0?e.toExponential(n):Math.abs(e-Math.round(e))<1e-10?Math.round(e).toString():e.toPrecision(8):String(e)}function UK({label:e,value:t,format:n=`auto`,decimals:r=6}){return(0,I.jsxs)(Tm,{children:[(0,I.jsx)(Tm.Col,{span:8,children:(0,I.jsx)(H,{size:`sm`,children:e})}),(0,I.jsx)(Tm.Col,{span:4,children:(0,I.jsx)(H,{size:`sm`,ff:`monospace`,ta:`right`,children:HK(t,n,r)})})]})}function WK({title:e,m:t,poissonCdf:n,lambda:r,f:i}){return(0,I.jsxs)(yl,{withBorder:!0,p:`md`,children:[(0,I.jsx)(q,{order:4,mb:`sm`,children:e}),(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsx)(UK,{label:`M (padding multiplier)`,value:t}),(0,I.jsx)(UK,{label:`Poisson CDF`,value:n}),(0,I.jsx)(UK,{label:`Lambda`,value:r}),(0,I.jsx)(UK,{label:`F (selectivity)`,value:i,format:`scientific`})]})]})}function GK(){let[e,t]=(0,b.useState)(1e3),[n,r]=(0,b.useState)(3),[i,a]=(0,b.useState)(.999999),[o,s]=(0,b.useState)(``),c=(0,b.useMemo)(()=>{let t=typeof e==`number`?e:void 0,r=typeof n==`number`?n:void 0,a=typeof i==`number`?i:void 0,s=typeof o==`number`?o:void 0;if(!(t===void 0||r===void 0||a===void 0))return BK(t,r,a,s)},[e,n,i,o]);return(0,I.jsxs)(G,{gap:`lg`,children:[(0,I.jsxs)(yl,{withBorder:!0,p:`md`,children:[(0,I.jsx)(q,{order:4,mb:`md`,children:`Inputs`}),(0,I.jsxs)(Tm,{children:[(0,I.jsx)(Tm.Col,{span:{base:12,sm:6,md:3},children:(0,I.jsx)(P_,{label:`Statistics Target`,value:e,onChange:t,min:100,max:1e4,step:100})}),(0,I.jsx)(Tm.Col,{span:{base:12,sm:6,md:3},children:(0,I.jsx)(P_,{label:`Elements Per Row`,value:n,onChange:r,min:1,max:1e3,step:1})}),(0,I.jsx)(Tm.Col,{span:{base:12,sm:6,md:3},children:(0,I.jsx)(P_,{label:`Confidence`,value:i,onChange:a,min:0,max:1,step:1e-6,decimalScale:10})}),(0,I.jsx)(Tm.Col,{span:{base:12,sm:6,md:3},children:(0,I.jsx)(P_,{label:`Target Selectivity (optional)`,description:`Overrides minimum selectivity`,value:o,onChange:s,min:0,max:1,step:1e-5,decimalScale:10,placeholder:c?HK(c.minimumSelectivity,`scientific`):``})})]})]}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(yl,{withBorder:!0,p:`md`,children:[(0,I.jsx)(q,{order:4,mb:`sm`,children:`Intermediate Values`}),(0,I.jsxs)(Tm,{children:[(0,I.jsx)(Tm.Col,{span:{base:12,md:6},children:(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsx)(UK,{label:`Rows Sampled`,value:c.rowsSampled}),(0,I.jsx)(UK,{label:`Cutoff Frequency (exact)`,value:c.cutoffFrequencyExact}),(0,I.jsx)(UK,{label:`Cutoff Frequency`,value:c.cutoffFrequency}),(0,I.jsx)(UK,{label:`Min Selectivity`,value:c.minimumSelectivity,format:`scientific`})]})}),(0,I.jsx)(Tm.Col,{span:{base:12,md:6},children:(0,I.jsxs)(G,{gap:`xs`,children:[(0,I.jsx)(UK,{label:`Target Selectivity`,value:c.targetSelectivity,format:`scientific`}),(0,I.jsx)(UK,{label:`Target Lambda`,value:c.targetLambda}),(0,I.jsx)(UK,{label:`Target Poisson CDF`,value:c.targetPoissonCdf}),(0,I.jsx)(UK,{label:`Target m`,value:c.targetM})]})})]})]}),(0,I.jsx)(Tm,{children:c.results.map(({name:e,result:t})=>(0,I.jsx)(Tm.Col,{span:{base:12,md:6},children:(0,I.jsx)(WK,{title:`${e} Option`,m:t.m,poissonCdf:t.poissonCdf,lambda:t.lambda,f:t.f})},e))})]})]})}var KK=8;function qK({inputProps:e,data:t,onChange:n}){let r=If({onDropdownClose:()=>r.resetSelectedOption()}),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(``),c=(0,b.useMemo)(()=>t.filter(e=>e.toLowerCase().includes(o.toLowerCase().trim())),[t,o]),l=(0,b.useMemo)(()=>{let e=Array(Math.min(c.length,KK));for(let t=0;t<e.length;t++){let n=c[t];e[t]=(0,I.jsx)(zf.Option,{value:n,children:n},n)}return e},[c]);return(0,I.jsxs)(zf,{store:r,withinPortal:!1,onOptionSubmit:e=>{n&&n(e),a(e),s(e),r.closeDropdown()},children:[(0,I.jsx)(zf.Target,{children:(0,I.jsx)(md,{rightSection:(0,I.jsx)(zf.Chevron,{}),value:o,onChange:e=>{r.openDropdown(),r.updateSelectedOptionIndex(),s(e.currentTarget.value)},onClick:()=>r.openDropdown(),onFocus:()=>r.openDropdown(),onBlur:()=>{r.closeDropdown(),s(i||``)},rightSectionPointerEvents:`none`,...e})}),(0,I.jsx)(zf.Dropdown,{children:(0,I.jsx)(zf.Options,{children:l.length>0?l:(0,I.jsx)(zf.Empty,{children:`Nothing found`})})})]})}function JK(e){let t=[];for(let n of e)t.push(n),t.push(n+`_History`),t.push(n+`_References`);return t.push(`Address`),t.push(`ContactPoint`),t.push(`HumanName`),t.push(`Coding`),t.push(`Coding_Property`),t.push(`DatabaseMigration`),t=ZC(t),t}function YK(e){return typeof e==`string`?e.length>50?e.substring(0,50)+`...`:e:typeof e==`boolean`?e.toString().toLocaleUpperCase():e}var XK=({medplum:e,onChange:t,onError:n})=>{(0,b.useEffect)(()=>{async function r(){return(await e.valueSetExpand({url:`https://medplum.com/fhir/ValueSet/resource-types`,count:200})).expansion?.contains?.map(e=>e.code).filter(e=>e!==void 0)??[]}r().then(e=>{t(JK(e))}).catch(e=>{n?n(e):console.error(e)})},[e,t,n])};function ZK(){let e=Z(),[t,{open:n,close:r}]=bn(!1),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(void 0),[u,d]=(0,b.useState)(0),[f,p]=(0,b.useState)(!1),[m,h]=(0,b.useState)([]),[g,_]=(0,b.useState)([]),[v,y]=(0,b.useState)(!1),[x,S]=(0,b.useState)(void 0),[C,w]=(0,b.useState)([]),[T,E]=(0,b.useState)(0),[D,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)(!1);XK({medplum:e,onChange:w}),(0,b.useEffect)(()=>{p(!0),e.get(`fhir/R4/$db-column-statistics?tableName=`+encodeURIComponent(c??``),{cache:`no-cache`}).then(e=>{d(e.parameter?.find(e=>e.name===`defaultStatisticsTarget`)?.valueInteger??0);let t=(e.parameter?.find(e=>e.name===`table`)?.part)?.filter(e=>e.name===`column`);h(t??[])}).finally(()=>{p(!1)}).catch(e=>{J({color:`red`,message:e.message})})},[e,c,T]);function j(){if(c){if(g.length===0){J({color:`red`,message:`No columns selected`,autoClose:!0});return}J({title:`Submit`,message:JSON.stringify({resetToDefault:v,newStatisticsTarget:x,selectedRowNames:g}),autoClose:!0}),e.post(`fhir/R4/$db-configure-column-statistics`,{tableName:c,columnNames:g,resetToDefault:v,newStatisticsTarget:v?void 0:x}).then(e=>{J({color:`green`,message:`Done`}),E(e=>e+1)}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}}let M={onClick:e=>{a(`Details`),s((0,I.jsx)(`pre`,{children:e})),n()}},ee=0;return(0,I.jsxs)(TN,{onSubmit:j,children:[(0,I.jsxs)(G,{gap:`sm`,children:[(0,I.jsxs)(V,{children:[(0,I.jsx)(qK,{data:C,inputProps:{placeholder:`Table name`,inputSize:`50`},onChange:e=>{l(e),_([])}}),(0,I.jsx)(U,{loading:f,onClick:()=>E(e=>e+1),children:`Refresh`})]}),(0,I.jsxs)(V,{children:[(0,I.jsx)(H,{span:!0,fw:700,children:`Statistics Target:`}),(0,I.jsx)(P_,{value:v?``:x,disabled:v,required:!v,size:`sm`,w:`100`,min:0,step:100,max:1e4,onChange:e=>{typeof e==`number`&&S(e)}}),(0,I.jsx)(H,{span:!0,fw:700,c:`dimmed`,children:`– or –`}),(0,I.jsx)(lp,{checked:v,onChange:e=>y(e.currentTarget.checked),label:`Reset to default (`+u+`)`,size:`sm`}),(0,I.jsx)(EN,{size:`sm`,children:`Update`})]}),(0,I.jsx)(V,{children:(0,I.jsx)(lp,{checked:k,onChange:e=>A(e.currentTarget.checked),label:`Hide columns with default statistics target`,size:`sm`})}),(0,I.jsx)(V,{children:(0,I.jsx)(lp,{checked:D,onChange:e=>O(e.currentTarget.checked),label:`Show all column stats`,size:`sm`})}),(0,I.jsx)(K.ScrollContainer,{minWidth:500,children:(0,I.jsxs)(K,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:(0,I.jsx)(lp,{size:`sm`,checked:m.length>0&&g.length===m.length,indeterminate:g.length>0&&g.length<m.length,onChange:()=>{g.length===m.length?_([]):_(m.map(e=>e.part?.find(e=>e.name===`name`)?.valueString??``))}})}),(0,I.jsx)(K.Th,{children:`Column`}),(0,I.jsx)(K.Th,{children:`Statistics Target`}),(0,I.jsx)(K.Th,{children:`null_frac`}),(0,I.jsx)(K.Th,{children:`avg_width`}),(0,I.jsx)(K.Th,{children:`n_distinct`}),(0,I.jsx)(K.Th,{children:`correlation`}),D&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(K.Th,{children:`most_common_vals`}),(0,I.jsx)(K.Th,{children:`most_common_freqs`}),(0,I.jsx)(K.Th,{children:`histogram_bounds`}),(0,I.jsx)(K.Th,{children:`most_common_elems`}),(0,I.jsx)(K.Th,{children:`most_common_elem_freqs`}),(0,I.jsx)(K.Th,{children:`elem_count_histogram`})]})]})}),(0,I.jsxs)(K.Tbody,{children:[m?.map(e=>{let t=e.part??[],n=t.find(e=>e.name===`name`)?.valueString,r=t.find(e=>e.name===`statisticsTarget`)?.valueInteger;if(r===-1&&(ee++,k))return null;if(!n)throw Error(`Column missing name`,{cause:e});return(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:(0,I.jsx)(lp,{size:`sm`,checked:g.includes(n),onChange:e=>{_(e.currentTarget.checked?[...g,n]:g.filter(e=>e!==n))}})}),(0,I.jsx)(K.Td,{children:n}),(0,I.jsx)(K.Td,{children:r===-1?(0,I.jsxs)(H,{span:!0,c:`dimmed`,fs:`italic`,children:[`default (`,u,`)`]}):r}),(0,I.jsx)(QK,{value:t.find(e=>e.name===`nullFraction`)?.valueDecimal,...M}),(0,I.jsx)(QK,{value:t.find(e=>e.name===`avgWidth`)?.valueInteger,...M}),(0,I.jsx)(QK,{value:t.find(e=>e.name===`nDistinct`)?.valueDecimal,...M}),(0,I.jsx)(QK,{value:t.find(e=>e.name===`correlation`)?.valueDecimal,...M}),D&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(QK,{value:t.find(e=>e.name===`mostCommonValues`)?.valueString,...M}),(0,I.jsx)(QK,{value:t.find(e=>e.name===`mostCommonFreqs`)?.valueString,...M}),(0,I.jsx)(QK,{value:t.find(e=>e.name===`histogramBounds`)?.valueString,...M}),(0,I.jsx)(QK,{value:t.find(e=>e.name===`mostCommonElems`)?.valueString,...M}),(0,I.jsx)(QK,{value:t.find(e=>e.name===`mostCommonElemFreqs`)?.valueString,...M}),(0,I.jsx)(QK,{value:t.find(e=>e.name===`elemCountHistogram`)?.valueString,...M})]})]},n)}),k&&(0,I.jsx)(K.Tr,{children:(0,I.jsx)(K.Td,{colSpan:D?13:7,children:(0,I.jsxs)(H,{c:`dimmed`,fs:`italic`,children:[ee,` hidden columns with default statistics target`]})})})]})]})})]}),(0,I.jsx)(rg,{opened:t,onClose:r,title:i,centered:!0,size:`auto`,children:o})]})}function QK({value:e,onClick:t}){return(0,I.jsx)(K.Td,{style:{cursor:`pointer`},onClick:()=>t?.(e),children:$K(e)})}function $K(e){return typeof e==`string`&&e.length>30?e.substring(0,30)+`...`:e}function eq(e,t,n,r){let i=Date.now().toString();J({id:i,loading:!0,title:t,message:`Running...`,autoClose:!1,withCloseButton:!1});let a={method:`POST`,pollStatusOnAccepted:!0};return r&&(a.body=JSON.stringify(r)),e.startAsyncRequest(n,a).then(e=>{let n=`Done`;return e.resourceType===`AsyncJob`?n=(0,I.jsx)(Kj,{to:e,children:`View AsyncJob`}):e.resourceType===`OperationOutcome`&&e.issue?.[0]?.details?.text&&(n=(0,I.jsx)(H,{children:e.issue[0].details.text})),zb.update({id:i,color:`green`,title:t,message:n,icon:(0,I.jsx)(EA,{size:`1rem`}),loading:!1,autoClose:!1,withCloseButton:!0}),e}).catch(e=>{throw zb.update({id:i,color:`red`,title:t,message:Qx(e),icon:(0,I.jsx)(Fj,{size:`1rem`}),loading:!1,autoClose:!1,withCloseButton:!0}),e})}function tq(e,t,n,r){eq(e,t,n,r).catch(()=>{})}var nq=8;function rq({pillInputProps:e,inputProps:t,data:n,onChange:r}){let i=If({onDropdownClose:()=>i.resetSelectedOption(),onDropdownOpen:()=>i.updateSelectedOptionIndex(`active`)}),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)([]),l=e=>{let t=s.includes(e)?s.filter(t=>t!==e):[...s,e];c(t),r&&r(t)},u=e=>c(t=>t.filter(t=>t!==e)),d=(0,b.useMemo)(()=>s.map(e=>(0,I.jsx)(pg,{withRemoveButton:!0,onRemove:()=>u(e),children:e},e)),[s]),f=(0,b.useMemo)(()=>{let e=a.trim().toLowerCase();return n.filter(t=>t.toLowerCase().includes(e))},[n,a]),p=(0,b.useMemo)(()=>{let e=Array(Math.min(f.length,nq));for(let t=0;t<e.length;t++){let n=f[t];e[t]=(0,I.jsx)(zf.Option,{value:n,active:s.includes(n),children:(0,I.jsxs)(V,{gap:`sm`,children:[s.includes(n)?(0,I.jsx)(tp,{size:12}):null,(0,I.jsx)(`span`,{children:n})]})},n)}return e},[f,s]);return(0,I.jsxs)(zf,{store:i,onOptionSubmit:l,withinPortal:!1,children:[(0,I.jsx)(zf.DropdownTarget,{children:(0,I.jsx)(vg,{onClick:()=>i.openDropdown(),...e,children:(0,I.jsxs)(pg.Group,{children:[d,(0,I.jsx)(zf.EventsTarget,{children:(0,I.jsx)(vg.Field,{onFocus:()=>i.openDropdown(),onBlur:()=>{i.closeDropdown(),o(``)},value:a,onChange:e=>{i.updateSelectedOptionIndex(),o(e.currentTarget.value)},onKeyDown:e=>{e.key===`Backspace`&&a.length===0&&s.length>0&&(e.preventDefault(),u(s[s.length-1]))},...t})})]})})}),(0,I.jsx)(zf.Dropdown,{children:(0,I.jsx)(zf.Options,{children:p.length>0?p:(0,I.jsx)(zf.Empty,{children:`Nothing found...`})})})]})}function iq({defaultGinPendingListLimit:e,availableTables:t,onResponse:n}){let r=Z(),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)([]),[c,l]=(0,b.useState)(`unspecified`),[u,d]=(0,b.useState)(`unspecified`),[f,p]=(0,b.useState)(void 0);return(0,I.jsx)(TN,{onSubmit:()=>{let e={tableName:o};c===`reset`?e.fastUpdateAction=`reset`:c===`on`?(e.fastUpdateAction=`set`,e.fastUpdateValue=!0):c===`off`&&(e.fastUpdateAction=`set`,e.fastUpdateValue=!1),u===`reset`?e.ginPendingListLimitAction=`reset`:u===`set`&&(e.ginPendingListLimitAction=`set`,e.ginPendingListLimitValue=f),a(!0),eq(r,`Configure GIN Indexes`,`fhir/R4/$db-configure-indexes`,e).then(e=>{n(e)}).catch(()=>{}).finally(()=>{a(!1)})},children:(0,I.jsxs)(G,{gap:`sm`,maw:`800`,children:[(0,I.jsx)(cd,{label:`Table(s)`,children:(0,I.jsx)(rq,{data:t,onChange:e=>s(e),inputProps:{name:`tables`,placeholder:`e.g. Observation`}})}),(0,I.jsx)(Pv.Group,{name:`fastUpdate`,label:`fastupdate`,value:c,onChange:e=>l(e),children:(0,I.jsxs)(V,{h:`36`,children:[(0,I.jsx)(Pv,{size:`sm`,value:`unspecified`,label:`unspecified`}),(0,I.jsx)(Pv,{size:`sm`,value:`reset`,label:`reset to default (on)`}),(0,I.jsx)(Pv,{size:`sm`,value:`off`,label:`off`}),(0,I.jsx)(Pv,{size:`sm`,value:`on`,label:`on`})]})}),(0,I.jsx)(Pv.Group,{name:`ginPendingListLimit`,label:`gin_pending_list_limit`,value:u,onChange:e=>{d(e),e!==`set`&&p(void 0)},children:(0,I.jsxs)(V,{h:`36`,children:[(0,I.jsx)(Pv,{size:`sm`,value:`unspecified`,label:`unspecified`}),(0,I.jsx)(Pv,{size:`sm`,value:`reset`,label:`reset to default (${e}kB)`}),(0,I.jsxs)(V,{children:[(0,I.jsx)(Pv,{size:`sm`,value:`set`,label:`Set to (kB)`}),(0,I.jsx)(P_,{title:`gin_pending_list_limit_value`,name:`gin_pending_list_limit_value`,value:(u===`set`?f:``)||``,disabled:u!==`set`,required:u===`set`,size:`sm`,w:`100`,min:64,max:2147483647,onChange:e=>{p(typeof e==`number`?e:void 0)}})]})]})}),(0,I.jsx)(V,{justify:`center`,children:(0,I.jsx)(EN,{size:`sm`,loading:i,children:`Update`})})]})})}function aq(){let e=Z(),[t,{open:n,close:r}]=bn(!1),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(void 0),[u,d]=(0,b.useState)(0),[f,p]=(0,b.useState)(!1),[m,h]=(0,b.useState)(void 0),[g,_]=(0,b.useState)([]),[v,y]=(0,b.useState)(0);XK({medplum:e,onChange:_}),(0,b.useEffect)(()=>{p(!0),e.get(`fhir/R4/$db-indexes?tableName=`+encodeURIComponent(c??``),{cache:`no-cache`}).then(e=>{d(e.parameter?.find(e=>e.name===`defaultGinPendingListLimit`)?.valueInteger??0);let t=e.parameter?.filter(e=>e.name===`index`);h(t??[])}).finally(()=>{p(!1)}).catch(e=>{J({color:`red`,message:e.message})})},[e,c,v]);let x=e=>{a(`Configure results`),s((0,I.jsx)(`pre`,{children:JSON.stringify(e,null,2)})),n(),y(e=>(e+1)%100)},S={onClick:e=>{a(`Details`),s((0,I.jsx)(`pre`,{children:e})),n()}},C;return f?C=`Loading...`:c?m?.length===0&&(C=`No GIN indexes on this table`):C=`Select a table`,(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(G,{gap:`sm`,children:[(0,I.jsx)(`h2`,{children:`Configure GIN indexes`}),(0,I.jsx)(V,{children:(0,I.jsx)(iq,{defaultGinPendingListLimit:u,availableTables:g,onResponse:x})}),(0,I.jsx)(`h2`,{children:`GIN index stats`}),(0,I.jsxs)(V,{children:[(0,I.jsx)(qK,{data:g,inputProps:{placeholder:`Table name`,inputSize:`50`},onChange:e=>{l(e)}}),(0,I.jsx)(U,{loading:f,onClick:()=>y(e=>(e+1)%100),disabled:!c,children:`Refresh`})]}),(0,I.jsx)(K.ScrollContainer,{minWidth:500,children:(0,I.jsxs)(K,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:`Schema`}),(0,I.jsx)(K.Th,{children:`Table`}),(0,I.jsx)(K.Th,{children:`Index`}),(0,I.jsx)(K.Th,{children:`fastupdate`}),(0,I.jsx)(K.Th,{children:`gin_pending_list_limit`}),(0,I.jsx)(K.Th,{children:`options`})]})}),(0,I.jsxs)(K.Tbody,{children:[C&&(0,I.jsx)(K.Tr,{children:(0,I.jsx)(K.Td,{colSpan:16,children:C})}),!C&&m?.map(e=>{let t=e.part??[],n=t.find(e=>e.name===`indexName`)?.valueString;if(!n)throw Error(`Index missing name`,{cause:e});return(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:t.find(e=>e.name===`schemaName`)?.valueString}),(0,I.jsx)(K.Td,{children:t.find(e=>e.name===`tableName`)?.valueString}),(0,I.jsx)(K.Td,{children:n}),(0,I.jsx)(oq,{value:t.find(e=>e.name===`fastUpdate`)?.valueBoolean,defaultValue:(0,I.jsxs)(H,{span:!0,c:`dimmed`,fs:`italic`,children:[`default\xA0(`,YK(!0),`)`]}),...S}),(0,I.jsx)(oq,{value:t.find(e=>e.name===`ginPendingListLimit`)?.valueInteger,defaultValue:(0,I.jsxs)(H,{span:!0,c:`dimmed`,fs:`italic`,children:[`default\xA0(`,u,`)`]}),...S}),(0,I.jsx)(oq,{value:t.find(e=>e.name===`indexOptions`)?.valueString,defaultValue:(0,I.jsx)(H,{span:!0,c:`dimmed`,fs:`italic`,children:`NULL`}),...S})]},n)})]})]})})]}),(0,I.jsx)(rg,{opened:t,onClose:r,title:i,centered:!0,size:`auto`,children:o})]})}function oq({value:e,onClick:t,defaultValue:n}){return(0,I.jsx)(K.Td,{style:{cursor:`pointer`},onClick:()=>t?.(e),children:e===void 0?n:YK(e)})}var sq=[{label:`GIN Indexes`,value:`gin-indexes`},{label:`Column Statistics`,value:`column-statistics`},{label:`Array Column Padding`,value:`array-padding`}];function cq(){let e=Z();return!e.isLoading()&&!e.isSuperAdmin()?(0,I.jsx)(BP,{outcome:Hx}):(0,I.jsx)(_P,{maw:`100%`,children:(0,I.jsxs)(yP,{children:[(0,I.jsx)(q,{order:1,children:`Database Tools`}),(0,I.jsxs)(xz,{baseUrl:`/admin/super/db`,tabs:sq,children:[(0,I.jsx)(vb.Panel,{value:`gin-indexes`,pt:`md`,children:(0,I.jsx)(aq,{})}),(0,I.jsx)(vb.Panel,{value:`column-statistics`,pt:`md`,children:(0,I.jsx)(ZK,{})}),(0,I.jsx)(vb.Panel,{value:`array-padding`,pt:`md`,children:(0,I.jsx)(GK,{})})]})]})})}function lq(){let e=Z(),[t,n]=(0,b.useState)(e.getProject()),[r,i]=(0,b.useState)(),[a,o]=(0,b.useState)(),[s,c]=(0,b.useState)(!1),[l,u]=(0,b.useState)(void 0);return(0,I.jsxs)(TN,{onSubmit:(0,b.useCallback)(n=>{let i={resourceType:n.resourceType,firstName:n.firstName,lastName:n.lastName,email:n.email,sendEmail:n.sendEmail===`on`,accessPolicy:r,admin:n.isAdmin===`on`,scope:n.isProjectScoped===`on`?`project`:`server`,mfaRequired:n.mfaRequired===`on`};return e.invite(t?.id,i).then(t=>{e.invalidateSearches(`Patient`),e.invalidateSearches(`Practitioner`),e.invalidateSearches(`ProjectMembership`),qx(t)?o(t):u(t),c(i.sendEmail??!1),J({color:`green`,message:`Invite success`})}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1}),o(Zx(e))})},[e,t,r]),children:[!l&&!a&&(0,I.jsxs)(G,{children:[(0,I.jsx)(q,{children:`Invite new member`}),e.isSuperAdmin()&&(0,I.jsx)(MF,{title:`Project`,htmlFor:`project`,outcome:a,children:(0,I.jsx)(lI,{resourceType:`Project`,name:`project`,defaultValue:t,onChange:n})}),(0,I.jsx)(Eg,{name:`resourceType`,label:`Role`,defaultValue:`Practitioner`,data:[`Practitioner`,`Patient`,`RelatedPerson`],error:SP(a,`resourceType`)}),(0,I.jsx)(yb,{name:`firstName`,label:`First Name`,required:!0,autoFocus:!0,error:SP(a,`firstName`)}),(0,I.jsx)(yb,{name:`lastName`,label:`Last Name`,required:!0,error:SP(a,`lastName`)}),(0,I.jsx)(yb,{name:`email`,type:`email`,label:`Email`,required:!0,error:SP(a,`email`)}),(0,I.jsx)(MF,{title:`Access Policy`,htmlFor:`accessPolicy`,outcome:a,children:(0,I.jsx)(PK,{name:`accessPolicy`,onChange:i})}),(0,I.jsx)(lp,{name:`sendEmail`,label:`Send email`,defaultChecked:!0}),(0,I.jsx)(lp,{name:`isAdmin`,label:`Admin`}),(0,I.jsx)(lp,{name:`isProjectScoped`,label:`Project scoped`}),(0,I.jsx)(lp,{name:`mfaRequired`,label:`MFA required`}),(0,I.jsx)(V,{justify:`flex-end`,children:(0,I.jsx)(EN,{children:`Invite`})})]}),a&&(0,I.jsxs)(`div`,{"data-testid":`success`,children:[(0,I.jsx)(`p`,{children:`User created, email couldn't be sent`}),(0,I.jsx)(`p`,{children:`Could not send email. Make sure you have AWS SES set up.`}),(0,I.jsxs)(`p`,{children:[`Click `,(0,I.jsx)(Kj,{to:`/admin/project`,children:`here`}),` to return to the project admin page.`]})]}),l&&(0,I.jsxs)(`div`,{"data-testid":`success`,children:[(0,I.jsx)(H,{children:`User created`}),s&&(0,I.jsx)(H,{children:`Email sent`}),(0,I.jsxs)(yh,{children:[(0,I.jsx)(yh.Item,{children:(0,I.jsx)(Kj,{to:l,children:`Go to new membership`})}),(0,I.jsx)(yh.Item,{children:(0,I.jsx)(Kj,{to:l.profile,children:`Go to new profile`})}),(0,I.jsx)(yh.Item,{children:(0,I.jsx)(Kj,{to:`/admin/users`,children:`Back to users list`})})]})]})]})}function uq(){let e=Z(),{membershipId:t}=wW(),n=e.readResource(`ProjectMembership`,t).read(),r=ik(n.profile),i=ik(n.user?.reference?.startsWith(`User/`)?{reference:n.user.reference}:void 0);return r?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{children:`ProjectMembership Details`}),(0,I.jsx)(Kj,{to:n,children:`Go to ProjectMembership`}),(0,I.jsx)(BL,{value:n}),(0,I.jsx)(q,{mt:`md`,children:`Profile Details`}),(0,I.jsxs)(Kj,{to:r,children:[`Go to `,r.resourceType]}),(0,I.jsx)(BL,{value:r,ignoreMissingValues:!0}),n.user?.reference?.startsWith(`User/`)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{mt:`md`,children:`User Details`}),i?.project?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Kj,{to:`/User/${i.id}/email`,children:`Go to User (change login email)`}),(0,I.jsx)(BL,{value:i,ignoreMissingValues:!0})]}):(0,I.jsx)(Dd,{color:`yellow`,children:`This User is server-scoped and cannot be viewed in this project.`})]})]}):(0,I.jsx)(Rj,{})}function dq(){let e=Z(),t=e.isSuperAdmin(),n=AK(e),[r,{open:i,close:a}]=bn(!1),[o,s]=(0,b.useState)(!t&&n?{reference:`Project/${n}`}:void 0),[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)(`loading`),[f,p]=(0,b.useState)(!1),[m,h]=(0,b.useState)(0),g=o?.reference,_=g?.split(`/`)[1];(0,b.useEffect)(()=>{if(!c?.id){d(`loading`);return}let t=!1;return d(`loading`),e.readResource(`User`,c.id).then(e=>{t||d(e.meta?.project&&e.meta.project===_?`project`:`server`)}).catch(()=>{t||d(`server`)}),()=>{t=!0}},[e,c,_]);let v;u===`project`?v=`server`:u===`server`&&t&&(v=`project`);let y=!!(g&&c?.id&&v);function x(){y&&i()}function S(){if(!c?.id||!v)return;p(!0);let t={resourceType:`Parameters`,parameter:[{name:`scope`,valueCode:v}]};v===`project`&&o&&t.parameter?.push({name:`project`,valueReference:o}),e.post(e.fhirUrl(`User`,c.id,`$rescope`),t).then(()=>{J({color:`green`,message:`User rescoped successfully`}),e.invalidateSearches(`User`),l(void 0),h(e=>e+1),a()}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1})).finally(()=>p(!1))}let C=o?.display??g??`(no project selected)`,w=g?{"_has:ProjectMembership:user:project":g}:void 0,T=c?pq(c):void 0;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{order:2,children:`Rescope User`}),(0,I.jsxs)(`p`,{children:[`Move a User between `,(0,I.jsx)(`strong`,{children:`server`}),` scope (not tied to any Project) and `,(0,I.jsx)(`strong`,{children:`project`}),` scope (owned by a specific Project).`,` `,t?`Selecting a project-scoped User releases them to the server; selecting a server-scoped User assigns them to the chosen Project.`:`Project admins may release a project-scoped User in this Project to server scope. Re-assigning a User to a Project requires a super admin.`]}),(0,I.jsx)(TN,{onSubmit:x,children:(0,I.jsxs)(G,{children:[t&&(0,I.jsx)(MF,{title:`Project (required)`,htmlFor:`rescopeTargetProject`,children:(0,I.jsx)(uI,{name:`rescopeTargetProject`,placeholder:`Select a Project`,targetTypes:[`Project`],onChange:e=>{s(e),l(void 0),h(e=>e+1)}})}),(0,I.jsx)(MF,{title:`User (search by email; filtered to members of the selected Project)`,htmlFor:`rescopeTargetUser`,children:(0,I.jsx)(lI,{name:`rescopeTargetUser`,resourceType:`User`,placeholder:g?`Search by email`:`Select a Project first`,disabled:!g,searchCriteria:w,onChange:e=>l(e??void 0)},m)}),c&&(0,I.jsxs)(V,{gap:`sm`,children:[(0,I.jsx)(H,{children:T}),fq(u)]}),c&&u===`server`&&!t&&(0,I.jsxs)(Dd,{color:`yellow`,children:[`This User is in `,(0,I.jsx)(`strong`,{children:`server`}),` scope. Only a super admin can assign a server-scoped User to a Project.`]}),(0,I.jsx)(`div`,{children:(0,I.jsx)(U,{type:`submit`,disabled:!y,children:v===`project`?`Assign User to Project`:`Release User to Server`})})]})}),(0,I.jsx)(rg,{opened:r,onClose:a,title:`Confirm User Rescope`,centered:!0,size:`auto`,children:(0,I.jsxs)(G,{children:[(0,I.jsxs)(H,{children:[`You are about to change the scope of `,(0,I.jsxs)(`strong`,{children:[`User/`,c?.id]}),`.`]}),v===`server`?(0,I.jsxs)(H,{children:[`This will `,(0,I.jsx)(`strong`,{children:`release`}),` the User from project `,(0,I.jsx)(`strong`,{children:C}),` to`,` `,(0,I.jsx)(`strong`,{children:`server`}),` scope. Any existing ProjectMemberships will be left in place and may be left orphaned.`]}):(0,I.jsxs)(H,{children:[`This will `,(0,I.jsx)(`strong`,{children:`assign`}),` the User to project `,(0,I.jsx)(`strong`,{children:C}),`. The User will become a project-scoped resource belonging to that Project.`]}),v===`server`&&!t&&(0,I.jsxs)(Dd,{color:`red`,title:`This change cannot be reversed by a project admin`,children:[(0,I.jsx)(`strong`,{children:`You will need the help of a super admin to reverse this change.`}),` Once the User is released to server scope, only a super admin can re-assign the User back to this (or any) Project.`]}),(0,I.jsx)(H,{c:`red`,children:`This is a privileged operation. Double-check the User and target before continuing.`}),(0,I.jsxs)(V,{justify:`flex-end`,children:[(0,I.jsx)(U,{variant:`default`,onClick:a,disabled:f,children:`Cancel`}),(0,I.jsx)(U,{color:`red`,onClick:S,loading:f,children:`Confirm Rescope`})]})]})})]})}function fq(e){return e===`loading`?(0,I.jsx)(Sy,{height:22,width:70,radius:`xl`}):e===`project`?(0,I.jsx)(Mp,{color:`blue`,variant:`light`,children:`Project`}):(0,I.jsx)(Mp,{color:`gray`,variant:`light`,children:`Server`})}function pq(e){let t;if(e.firstName||e.lastName){let n={family:e.lastName};e.firstName&&(n.given=[e.firstName]),t=lw(n)}return t&&e.email?`${t} (${e.email})`:t??e.email??`User/${e.id}`}function mq(){let e=Z();if(!e.isLoading()&&!e.isProjectAdmin())return(0,I.jsx)(BP,{outcome:Hx});function t(t){e.post(`admin/projects/setpassword`,t).then(()=>J({color:`green`,message:`Done`})).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}return(0,I.jsxs)(bP,{width:600,children:[(0,I.jsx)(q,{order:1,children:`Project Admin`}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Force Set Password`}),(0,I.jsx)(H,{children:`Sets the password for the specified user in this project.`}),(0,I.jsx)(H,{children:`This action can only be performed by project administrators. Passwords can only be set for users scoped in this project.`}),(0,I.jsx)(TN,{onSubmit:t,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(yb,{name:`email`,label:`Email`,required:!0}),(0,I.jsx)(sv,{name:`password`,label:`Password`,required:!0}),(0,I.jsx)(U,{type:`submit`,children:`Force Set Password`})]})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(dq,{})]})}function hq(){let e=Z(),t=AK(e),n=e.get(`admin/projects/${t}`).read();return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{children:`Details`}),(0,I.jsxs)(uP,{children:[(0,I.jsx)(dP,{term:`ID`,children:n.project.id}),(0,I.jsx)(dP,{term:`Name`,children:n.project.name})]})]})}var gq=[{label:`Details`,value:`details`},{label:`Users`,value:`users`},{label:`Clients`,value:`clients`},{label:`Bots`,value:`bots`},{label:`Secrets`,value:`secrets`},{label:`Settings`,value:`settings`},{label:`Sites`,value:`sites`},{label:`Rate Limits`,value:`rate-limits`}];function _q(){let e=Z(),t=AK(e),n=(0,b.useMemo)(()=>e.get(`admin/projects/`+t).read(),[e,t]);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(yl,{children:[(0,I.jsx)(yz,{children:(0,I.jsxs)(yz.Entry,{children:[(0,I.jsx)(yz.Key,{children:`Project`}),(0,I.jsx)(yz.Value,{children:n.project.name})]})}),(0,I.jsx)(ul,{children:(0,I.jsx)(xz,{baseUrl:`/admin`,tabs:gq})})]}),(0,I.jsx)(_P,{maw:`100%`,children:(0,I.jsx)(yP,{children:(0,I.jsx)(oG,{})})})]})}function vq(e,t){return e?.find(e=>e.name===t)?.valueString}function yq(e,t){return e?.find(e=>e.name===t)?.valueInteger}function bq(e,t){return e?.find(e=>e.name===t)?.valueReference}function xq(e){let t=e.parameter?.find(e=>e.name===`project`);return{project:{id:vq(t?.part,`id`)??``,limit:yq(t?.part,`limit`),consumedPoints:yq(t?.part,`consumedPoints`),remainingPoints:yq(t?.part,`remainingPoints`),msBeforeReset:yq(t?.part,`msBeforeReset`)},memberships:(e.parameter?.filter(e=>e.name===`membership`)??[]).map(e=>({membershipId:vq(e.part,`membershipId`)??``,profile:bq(e.part,`profile`),limit:yq(e.part,`limit`),consumedPoints:yq(e.part,`consumedPoints`),remainingPoints:yq(e.part,`remainingPoints`),msBeforeReset:yq(e.part,`msBeforeReset`)}))}}function Sq(e){if(!(e.limit===void 0||e.consumedPoints===void 0))return e.limit===0?0:e.consumedPoints/e.limit*100}function Cq(e){return e>=90?`red`:e>=70?`yellow`:`green`}function wq(e){if(e===void 0)return`--`;let t=Math.ceil(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Tq(e){return e===void 0?`--`:e.toLocaleString()}function Eq(e){let t=Sq(e);return t===void 0?`--`:`${t.toFixed(1)}%`}var Dq=`https://www.medplum.com/docs/api/fhir/operations/project-rate-limits`;function Oq(){let e=Z(),t=AK(e),[n,r]=(0,b.useState)(),[i,a]=(0,b.useState)(!1),[o,s]=(0,b.useState)(`desc`),c=(0,b.useCallback)(()=>{a(!0),e.get(e.fhirUrl(`Project`,t,`$rate-limits`),{cache:`no-cache`}).then(e=>{r(xq(e))}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1})}).finally(()=>{a(!1)})},[e,t]),l=(0,b.useCallback)(()=>{s(e=>e===`desc`?`asc`:`desc`)},[]),u=(0,b.useMemo)(()=>n?[...n.memberships].sort((e,t)=>{let n=Sq(e)??-1,r=Sq(t)??-1;return o===`desc`?r-n:n-r}):[],[n,o]);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(V,{justify:`space-between`,mb:`md`,children:[(0,I.jsx)(q,{children:`Rate Limits`}),(0,I.jsxs)(V,{children:[(0,I.jsx)(Pd,{href:Dq,target:`_blank`,rel:`noopener noreferrer`,size:`sm`,children:`$rate-limits documentation`}),(0,I.jsx)(U,{leftSection:(0,I.jsx)(gj,{size:14}),loading:i,onClick:c,children:`Refresh`})]})]}),!n&&!i&&(0,I.jsx)(H,{c:`dimmed`,children:`Click Refresh to load current rate limit data.`}),n&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(kq,{project:n.project}),u.length===0?(0,I.jsx)(H,{c:`dimmed`,mt:`md`,children:`No membership rate limit data found.`}):(0,I.jsx)(Aq,{memberships:u,sortDirection:o,onToggleSort:l})]})]})}function kq({project:e}){let t=Sq(e);return(0,I.jsxs)(`div`,{style:{marginBottom:`1rem`},children:[(0,I.jsx)(q,{order:4,mb:`xs`,children:`Project Utilization`}),t===void 0?(0,I.jsx)(H,{c:`dimmed`,size:`sm`,children:`No project-level rate limit data recorded yet.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(V,{gap:`xl`,mb:`xs`,children:[(0,I.jsxs)(H,{size:`sm`,children:[(0,I.jsx)(`strong`,{children:`Consumed:`}),` `,Tq(e.consumedPoints),` / `,Tq(e.limit)]}),(0,I.jsxs)(H,{size:`sm`,children:[(0,I.jsx)(`strong`,{children:`Remaining:`}),` `,Tq(e.remainingPoints)]}),(0,I.jsxs)(H,{size:`sm`,children:[(0,I.jsx)(`strong`,{children:`Utilization:`}),` `,Eq(e)]}),(0,I.jsxs)(H,{size:`sm`,children:[(0,I.jsx)(`strong`,{children:`Resets in:`}),` `,wq(e.msBeforeReset)]})]}),(0,I.jsx)(gv,{value:t,color:Cq(t),size:`lg`})]})]})}function Aq({memberships:e,sortDirection:t,onToggleSort:n}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{order:4,mt:`lg`,mb:`xs`,children:`Membership Utilization`}),(0,I.jsxs)(K,{striped:!0,highlightOnHover:!0,children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:`Membership ID`}),(0,I.jsx)(K.Th,{children:`Profile`}),(0,I.jsx)(K.Th,{children:`Limit`}),(0,I.jsx)(K.Th,{children:`Consumed`}),(0,I.jsx)(K.Th,{children:`Remaining`}),(0,I.jsx)(K.Th,{children:(0,I.jsxs)(ml,{onClick:n,style:{fontWeight:700,display:`flex`,alignItems:`center`,gap:4},children:[`Utilization`,t===`desc`?(0,I.jsx)(pA,{size:14}):(0,I.jsx)(mA,{size:14})]})}),(0,I.jsx)(K.Th,{children:`Resets In`})]})}),(0,I.jsx)(K.Tbody,{children:e.map(e=>(0,I.jsx)(jq,{membership:e},e.membershipId))})]})]})}function jq({membership:e}){let t=bW(),n=Sq(e);return(0,I.jsxs)(K.Tr,{onClick:()=>t(`/admin/users/${e.membershipId}`),style:{cursor:`pointer`},children:[(0,I.jsx)(K.Td,{children:e.membershipId}),(0,I.jsx)(K.Td,{children:(0,I.jsx)(pL,{value:e.profile})}),(0,I.jsx)(K.Td,{children:Tq(e.limit)}),(0,I.jsx)(K.Td,{children:Tq(e.consumedPoints)}),(0,I.jsx)(K.Td,{children:Tq(e.remainingPoints)}),(0,I.jsx)(K.Td,{children:n===void 0?`--`:(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(gv,{value:n,color:Cq(n),size:`sm`,style:{flex:1,minWidth:60}}),(0,I.jsxs)(H,{size:`sm`,w:50,ta:`right`,children:[n.toFixed(1),`%`]})]})}),(0,I.jsx)(K.Td,{children:wq(e.msBeforeReset)})]})}function Mq(){let e=Z(),t=AK(e),n=e.get(`admin/projects/${t}`).read(),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)();return(0,b.useEffect)(()=>{e.requestSchema(`Project`).then(()=>i(!0)).catch(console.log)},[e]),(0,b.useEffect)(()=>{n&&o(MC(n.project.secret||[]))},[e,n]),!r||!a?(0,I.jsx)(`div`,{children:`Loading...`}):(0,I.jsxs)(`form`,{noValidate:!0,autoComplete:`off`,onSubmit:n=>{n.preventDefault(),e.post(`admin/projects/${t}/secrets`,a).then(()=>e.get(`admin/projects/${t}`,{cache:`reload`})).then(()=>J({color:`green`,message:`Saved`})).catch(console.log)},children:[(0,I.jsx)(q,{children:`Project Secrets`}),(0,I.jsx)(`p`,{children:`Use project secrets to store sensitive information such as API keys or other access credentials.`}),(0,I.jsx)(DI,{property:Bw(`Project`,`secret`),name:`secret`,path:`Project.secret`,defaultValue:a,onChange:o,outcome:void 0}),(0,I.jsx)(U,{type:`submit`,children:`Save`})]})}function Nq(){let e=Z(),t=AK(e),n=e.get(`admin/projects/${t}`).read(),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)();return(0,b.useEffect)(()=>{e.requestSchema(`Project`).then(()=>i(!0)).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},[e]),(0,b.useEffect)(()=>{n&&o(MC(n.project.setting||[]))},[e,n]),!r||!a?(0,I.jsx)(`div`,{children:`Loading...`}):(0,I.jsxs)(`form`,{noValidate:!0,autoComplete:`off`,onSubmit:n=>{n.preventDefault(),e.post(`admin/projects/${t}/settings`,a).then(()=>e.get(`admin/projects/${t}`,{cache:`reload`})).then(()=>J({color:`green`,message:`Saved`})).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},children:[(0,I.jsx)(q,{children:`Project Settings`}),(0,I.jsxs)(`p`,{children:[`Use project settings to store non-sensitive configuration visible to all project users. For example, set "aiModels" to a JSON array of `,`{ "value", "label" }`,` objects to control the models available in the Spaces AI assistant.`]}),(0,I.jsx)(DI,{property:Bw(`Project`,`setting`),name:`setting`,path:`Project.setting`,defaultValue:a,onChange:o,outcome:void 0}),(0,I.jsx)(U,{type:`submit`,children:`Save`})]})}function Pq(){let e=Z(),t=AK(e),n=e.get(`admin/projects/${t}`).read(),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)();return(0,b.useEffect)(()=>{e.requestSchema(`Project`).then(()=>i(!0)).catch(console.log)},[e]),(0,b.useEffect)(()=>{n&&o(MC(n.project.site||[]))},[e,n]),!r||!a?(0,I.jsx)(`div`,{children:`Loading...`}):(0,I.jsxs)(`form`,{noValidate:!0,autoComplete:`off`,onSubmit:n=>{n.preventDefault(),e.post(`admin/projects/${t}/sites`,a).then(()=>e.get(`admin/projects/${t}`,{cache:`reload`})).then(()=>J({color:`green`,message:`Saved`})).catch(e=>{let t=Zx(e);J({color:`red`,message:`Error ${t.issue?.[0].details?.text} ${t.issue?.[0].expression?.[0]}`,autoClose:!1})})},children:[(0,I.jsx)(q,{children:`Project Sites`}),(0,I.jsx)(`p`,{children:`Use project sites configure your project on a separate domain.`}),(0,I.jsx)(DI,{property:Bw(`Project`,`site`),name:`site`,path:`Project.site`,defaultValue:a,onChange:o,outcome:void 0}),(0,I.jsx)(U,{type:`submit`,children:`Save`})]})}var Fq=[{label:`Post-deploy Migrations`,value:`migrations`},{label:`System AsyncJob`,value:`asyncjob`}];function Iq(){let e=Z();return!e.isLoading()&&!e.isSuperAdmin()?(0,I.jsx)(BP,{outcome:Hx}):(0,I.jsx)(_P,{miw:`1600`,maw:`2000`,children:(0,I.jsxs)(yP,{children:[(0,I.jsx)(q,{order:1,children:`AsyncJob Dashboard`}),(0,I.jsxs)(xz,{baseUrl:`/admin/super/asyncjob`,tabs:Fq,keepMounted:!1,children:[(0,I.jsx)(vb.Panel,{value:`asyncjob`,pt:`md`,children:(0,I.jsx)(Rq,{})}),(0,I.jsx)(vb.Panel,{value:`migrations`,pt:`md`,children:(0,I.jsx)(Bq,{})})]})]})})}var Lq={resourceType:`AsyncJob`,fields:[`id`,`_lastUpdated`,`request`,`status`,`type`],filters:[{code:`_project`,operator:X.MISSING,value:`true`}],sortRules:[{code:`_lastUpdated`,descending:!0}]};function Rq(){let e=bW(),[t]=(0,b.useState)(Lq);return(0,I.jsxs)(G,{children:[(0,I.jsx)(Kj,{to:`/${t.resourceType}/${cE(t)}`,children:`Show in search page`}),(0,I.jsx)(lz,{checkboxesEnabled:!1,search:t,onClick:t=>e(Hq(t.resource))?.catch(console.error),onAuxClick:e=>window.open(Hq(e.resource),`_blank`)})]})}var zq={resourceType:`AsyncJob`,fields:[`id`,`_lastUpdated`,`request`,`status`,`type`],filters:[{code:`_project`,operator:X.MISSING,value:`true`},{code:`type`,operator:X.EQUALS,value:`data-migration`}],count:1e3,sortRules:[{code:`_lastUpdated`,descending:!0}]};function Bq(){let e=Z(),[t,n]=(0,b.useState)(),[r,i]=(0,b.useState)(),[a,o]=(0,b.useState)([]),[s,c]=(0,b.useState)(0),[l,u]=(0,b.useState)([]);(0,b.useEffect)(()=>{let t=`info`;u(e=>e.includes(t)?e:[...e,t]),e.get(`admin/super/migrations`,{cache:`no-cache`}).then(e=>{e.postDeployMigrations.sort((e,t)=>t-e),n(e)}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1})}).finally(()=>u(e=>e.filter(e=>e!==t)))},[e,s]),(0,b.useEffect)(()=>{let t=`jobs`;u(e=>e.includes(t)?e:[...e,t]),e.requestSchema(`AsyncJob`).then(()=>e.search(`AsyncJob`,cE({...zq,total:`accurate`,fields:void 0}),{cache:`no-cache`}).then(e=>{i(e.entry?.map(e=>e.resource))})).catch(e=>{i(void 0),J({color:`red`,message:Qx(e),autoClose:!1})}).finally(()=>u(e=>e.filter(e=>e!==t)))},[e,s]);function d(){c(e=>e+1)}function f(t){eq(e,`Run pending post-deploy migration`,`admin/super/migrate`,{dataVersion:t}).finally(()=>{d()}).catch(()=>{}),d()}let p=l.length>0;function m(e,{isLoading:t}){return(0,I.jsxs)(`div`,{style:{position:`relative`},children:[(0,I.jsx)(Ch,{visible:t}),(0,I.jsxs)(K,{children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:`Version`}),(0,I.jsx)(K.Th,{children:`Action`}),(0,I.jsx)(K.Th,{children:`Status`}),(0,I.jsx)(K.Th,{children:`AsyncJob`}),(0,I.jsx)(K.Th,{children:`Last Updated`}),(0,I.jsx)(K.Th,{children:`Request Time`}),(0,I.jsx)(K.Th,{children:`Duration`}),(0,I.jsx)(K.Th,{children:`Attempts`})]})}),(0,I.jsx)(K.Tbody,{children:e()})]})]})}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(U,{size:`xs`,mb:`xs`,variant:`subtle`,leftSection:(0,I.jsx)(gj,{size:14}),onClick:d,loading:p,children:`Refresh`}),m(()=>{if(!p){if(!t)return(0,I.jsx)(K.Tr,{children:(0,I.jsx)(K.Td,{colSpan:6,children:`Failed to load migration info`})});if(!r)return(0,I.jsx)(K.Tr,{children:(0,I.jsx)(K.Td,{colSpan:6,children:`Failed to load async jobs`})})}return!t||!r?null:t.postDeployMigrations?.map(e=>{let{status:n,asyncJob:i,asyncJobs:s}=Vq(e,r??[],t?.pendingPostDeployMigration),c=a.includes(e),l=e===t?.pendingPostDeployMigration&&(!i||i?.status===`error`),u=[(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:e}),(0,I.jsx)(K.Td,{children:l&&(0,I.jsx)(U,{color:`green`,size:`xs`,onClick:()=>f(e),children:`Start`})}),(0,I.jsx)(K.Td,{children:n}),(0,I.jsx)(K.Td,{children:i&&(0,I.jsx)(Kj,{to:`/AsyncJob/${i?.id}`,children:i?.id})}),(0,I.jsx)(K.Td,{children:i?.meta?.lastUpdated}),(0,I.jsx)(K.Td,{children:i?.requestTime}),(0,I.jsx)(K.Td,{children:Uq(i)}),(0,I.jsx)(K.Td,{display:`flex`,children:(0,I.jsxs)(V,{gap:`xs`,children:[s.length?s.length:``,c&&s.length>1&&(0,I.jsx)(U,{leftSection:(0,I.jsx)(oj,{size:14}),variant:`subtle`,color:`blue`,size:`xs`,radius:`xs`,onClick:()=>o(t=>t.includes(e)?t.filter(t=>t!==e):t),children:`Hide all`}),!c&&s.length>1&&(0,I.jsx)(U,{leftSection:(0,I.jsx)(mj,{size:14}),variant:`subtle`,color:`blue`,size:`xs`,radius:`xs`,onClick:()=>o(t=>t.includes(e)?t:[...t,e]),children:`Show all`})]})})]},e)];return c&&u.push(...s.filter(e=>e.id!==i?.id).map(t=>(0,I.jsxs)(K.Tr,{bg:`gray.1`,children:[(0,I.jsx)(K.Td,{children:e}),(0,I.jsx)(K.Td,{}),(0,I.jsx)(K.Td,{children:t.status}),(0,I.jsx)(K.Td,{children:(0,I.jsx)(Kj,{to:`/AsyncJob/${t.id}`,children:t.id})}),(0,I.jsx)(K.Td,{children:t.meta?.lastUpdated}),(0,I.jsx)(K.Td,{children:t.requestTime}),(0,I.jsx)(K.Td,{children:Uq(t)}),(0,I.jsx)(K.Td,{})]},t.id))),u})},{isLoading:p})]})}function Vq(e,t,n){let r=t.filter(t=>t.dataVersion===e),i=r.find(e=>e.status===`completed`)??r[0],a;return a=n===0?i?.status??`completed`:e>n?i?.status??`pending`:e===n?i?.status??`next`:i?.status??`completed`,{status:a,asyncJob:i,asyncJobs:r}}function Hq(e){return`/${e.resourceType}/${e.id}`}function Uq(e){let t=e?.requestTime,n=e?.transactionTime??e?.meta?.lastUpdated;if(!t||!n)return``;let r=new Date(t),i=new Date(n).getTime()-r.getTime();if(i<1e3)return`${i.toFixed(0)}ms`;let a=i/1e3;return a<60?`${a.toFixed(2)}s`:a<3600?`${(a/60).toFixed(2)}m`:`${(a/3600).toFixed(2)}h`}function Wq(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Gq({entry:e}){return(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:(0,I.jsxs)(`div`,{style:{paddingLeft:50},children:[(0,I.jsxs)(H,{size:`xs`,c:`dimmed`,children:[`Subscription: `,(0,I.jsx)(gF,{value:{reference:`Subscription/${e.subscriptionId}`}})]}),(0,I.jsxs)(H,{size:`xs`,c:`dimmed`,children:[`Author:`,` `,(0,I.jsx)(Kj,{to:{reference:e.author},children:(0,I.jsx)(pL,{value:{reference:e.author}})})]}),e.expiration?(0,I.jsxs)(H,{size:`xs`,c:`dimmed`,children:[`Expires at:`,` `,new Date(e.expiration*1e3).toLocaleString(void 0,{timeZoneName:`short`})]}):null]})}),(0,I.jsx)(K.Td,{})]},e.subscriptionId)}function Kq({criteria:e,expanded:t,onToggle:n}){return(0,I.jsxs)(b.Fragment,{children:[(0,I.jsxs)(K.Tr,{onClick:n,style:{cursor:`pointer`},children:[(0,I.jsx)(K.Td,{children:(0,I.jsxs)(V,{gap:`xs`,pl:`xl`,children:[(0,I.jsx)(H,{size:`xs`,children:t?`▼`:`▶`}),(0,I.jsx)(H,{size:`sm`,c:`dimmed`,children:e.criteria})]})}),(0,I.jsx)(K.Td,{children:e.count})]}),t&&e.entries?.map(e=>(0,I.jsx)(Gq,{entry:e},e.subscriptionId))]})}function qq({projectId:e,rt:t,rtDetail:n,isLoading:r,expanded:i,expandedCriteria:a,onToggle:o,onToggleCriteria:s}){let c=`${e}:${t.resourceType}`;return(0,I.jsxs)(b.Fragment,{children:[(0,I.jsxs)(K.Tr,{onClick:o,style:{cursor:`pointer`},children:[(0,I.jsx)(K.Td,{children:(0,I.jsxs)(V,{gap:`xs`,pl:`md`,children:[(0,I.jsx)(H,{size:`xs`,children:i?`▼`:`▶`}),(0,I.jsx)(H,{children:t.resourceType})]})}),(0,I.jsx)(K.Td,{children:t.count})]}),i&&(0,I.jsxs)(I.Fragment,{children:[r&&!n&&(0,I.jsx)(K.Tr,{children:(0,I.jsx)(K.Td,{colSpan:2,children:(0,I.jsx)(H,{pl:`xl`,size:`sm`,c:`dimmed`,children:`Loading...`})})}),n?.criteria.map(e=>{let t=`${c}:${e.criteria}`;return(0,I.jsx)(Kq,{criteria:e,expanded:a.has(t),onToggle:()=>s(t)},t)})]})]})}function Jq({project:e,expanded:t,expandedResourceTypes:n,expandedCriteria:r,projectDetail:i,isLoadingDetail:a,onToggle:o,onToggleResourceType:s,onToggleCriteria:c}){return(0,I.jsxs)(b.Fragment,{children:[(0,I.jsxs)(K.Tr,{onClick:o,style:{cursor:`pointer`},children:[(0,I.jsx)(K.Td,{children:(0,I.jsxs)(V,{gap:`xs`,children:[(0,I.jsx)(H,{size:`xs`,children:t?`▼`:`▶`}),(0,I.jsx)(gF,{value:{reference:`Project/${e.projectId}`,display:e.projectName}})]})}),(0,I.jsx)(K.Td,{children:e.subscriptionCount})]}),t&&e.resourceTypes.map(t=>{let o=`${e.projectId}:${t.resourceType}`;return(0,I.jsx)(qq,{projectId:e.projectId,rt:t,rtDetail:i?.find(e=>e.resourceType===t.resourceType),isLoading:a,expanded:n.has(o),expandedCriteria:r,onToggle:()=>s(e.projectId,t.resourceType),onToggleCriteria:c},o)})]})}function Yq(){let e=Z(),[t,n]=(0,b.useState)(),[r,i]=(0,b.useState)(!1),[a,{open:o,close:s}]=bn(!1),[c,l]=(0,b.useState)(new Set),[u,d]=(0,b.useState)(new Set),[f,p]=(0,b.useState)(new Set),[m,h]=(0,b.useState)(new Map),[g,_]=(0,b.useState)(new Map);function v(){i(!0),e.get(`fhir/R4/$get-ws-sub-stats`,{cache:`no-cache`}).then(e=>{let t=e.parameter?.find(e=>e.name===`stats`)?.valueString;t&&n(JSON.parse(t).projects),o()}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1})).finally(()=>i(!1))}function y(t,n){let r=`${t}:${n}`;m.has(t)||(_(e=>new Map(e).set(t,!0)),e.get(`fhir/R4/$get-ws-sub-project-stats?projectId=${encodeURIComponent(t)}`,{cache:`no-cache`}).then(e=>{let n=e.parameter?.find(e=>e.name===`stats`)?.valueString;if(n){let e=JSON.parse(n);h(n=>new Map(n).set(t,e.resourceTypes))}}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1})).finally(()=>_(e=>{let n=new Map(e);return n.delete(t),n}))),d(e=>Wq(e,r))}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(U,{onClick:v,loading:r,children:`Get WS Sub Stats`}),(0,I.jsxs)(rg,{opened:a,onClose:s,title:`WebSocket Subscription Stats`,size:`xl`,centered:!0,children:[!t?.length&&(0,I.jsx)(H,{children:`No active WebSocket subscriptions found.`}),t&&t.length>0&&(0,I.jsxs)(K,{striped:!0,highlightOnHover:!0,withTableBorder:!0,withColumnBorders:!0,tabularNums:!0,children:[(0,I.jsx)(K.Thead,{children:(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Th,{children:`Project / Resource Type / Criteria`}),(0,I.jsx)(K.Th,{children:`Count`})]})}),(0,I.jsx)(K.Tbody,{children:t.map(e=>(0,I.jsx)(Jq,{project:e,expanded:c.has(e.projectId),expandedResourceTypes:u,expandedCriteria:f,projectDetail:m.get(e.projectId),isLoadingDetail:g.get(e.projectId)===!0,onToggle:()=>l(t=>Wq(t,e.projectId)),onToggleResourceType:y,onToggleCriteria:e=>p(t=>Wq(t,e))},e.projectId))})]})]})]})}function Xq(){let e=Z(),[t,{open:n,close:r}]=bn(!1),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)();if(!e.isLoading()&&!e.isSuperAdmin())return(0,I.jsx)(BP,{outcome:Hx});function u(){tq(e,`Rebuilding Structure Definitions`,`admin/super/structuredefinitions`)}function d(){tq(e,`Rebuilding Search Parameters`,`admin/super/searchparameters`)}function f(){tq(e,`Rebuilding Value Sets`,`admin/super/valuesets`)}function p(t){tq(e,`Reindexing Resources`,`admin/super/reindex`,t)}function m(){tq(e,`Reload Cron Resources`,`admin/super/reloadcron`)}function h(){r();let t=sC(c);e.post(`fhir/R4/$clear-all-ws-subs`,t?{resourceType:`Parameters`,parameter:[{name:`projectId`,valueString:t}]}:void 0).then(()=>J({color:`green`,message:`Done`})).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1})),l(void 0)}function g(t){e.post(`admin/super/removebotidjobsfromqueue`,t).then(()=>J({color:`green`,message:`Done`})).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}function _(t){e.post(`admin/super/purge`,{...t,before:WF(t.before)}).then(()=>J({color:`green`,message:`Done`})).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}function v(t){e.post(`admin/super/setpassword`,t).then(()=>J({color:`green`,message:`Done`})).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}function y(t){e.post(`fhir/R4/$db-stats`,t.tableNames?{resourceType:`Parameters`,parameter:[{name:`tableNames`,valueString:t.tableNames}]}:void 0).then(e=>{a(`Database Stats`),s((0,I.jsx)(`pre`,{children:e.parameter?.find(e=>e.name===`tableString`)?.valueString})),n()}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}function x(){e.post(`fhir/R4/$db-invalid-indexes`).then(e=>{a(`Database Invalid Indexes`),s((0,I.jsx)(`pre`,{children:e.parameter?.filter(e=>e.name===`invalidIndex`).map(e=>e.valueString).join(`
220
+ `)})),n()}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}function S(){e.post(`fhir/R4/$db-schema-diff`).then(e=>{a(`Schema Diff`),s((0,I.jsx)(`pre`,{children:e.parameter?.find(e=>e.name===`migrationString`)?.valueString})),n()}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))}function C(){tq(e,`Reconcile Schema Diff`,`admin/super/reconcile-db-schema-drift`)}return(0,I.jsxs)(bP,{width:600,children:[(0,I.jsx)(q,{order:1,children:`Super Admin`}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Structure Definitions`}),(0,I.jsx)(`p`,{children:`StructureDefinition resources contain the metadata about resource types. They are provided with the FHIR specification. Medplum also includes some custom StructureDefinition resources for internal data types. Press this button to update the database StructureDefinitions from the FHIR specification.`}),(0,I.jsx)(TN,{children:(0,I.jsx)(U,{onClick:u,children:`Rebuild StructureDefinitions`})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Search Parameters`}),(0,I.jsx)(`p`,{children:`SearchParameter resources contain the metadata about filters and sorting. They are provided with the FHIR specification. Medplum also includes some custom SearchParameter resources for internal data types. Press this button to update the database SearchParameters from the FHIR specification.`}),(0,I.jsx)(TN,{children:(0,I.jsx)(U,{onClick:d,children:`Rebuild SearchParameters`})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Value Sets`}),(0,I.jsx)(`p`,{children:`ValueSet resources enum values for a wide variety of use cases. Press this button to update the database ValueSets from the FHIR specification.`}),(0,I.jsx)(TN,{children:(0,I.jsx)(U,{onClick:f,children:`Rebuild ValueSets`})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Reindex Resources`}),(0,I.jsx)(`p`,{children:`When Medplum changes how resources are indexed, the system may require a reindex for old resources to be indexed properly.`}),(0,I.jsx)(Qq,{onSubmit:p}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Purge Resources`}),(0,I.jsx)(`p`,{children:`As system generated resources accumulate, the system may require a purge to remove old resources.`}),(0,I.jsx)(TN,{onSubmit:_,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(MF,{title:`Purge Resource Type`,htmlFor:`purgeResourceType`,children:(0,I.jsx)(Eg,{id:`purgeResourceType`,name:`resourceType`,data:[``,`AuditEvent`,`Login`]})}),(0,I.jsx)(MF,{title:`Purge Before`,htmlFor:`before`,children:(0,I.jsx)(GF,{name:`before`,placeholder:`Before Date`})}),(0,I.jsx)(U,{type:`submit`,children:`Purge`})]})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Remove Bot ID Jobs from Queue`}),(0,I.jsx)(`p`,{children:`Remove all queued jobs for a Bot ID`}),(0,I.jsx)(TN,{onSubmit:g,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(MF,{title:`Bot ID`,children:(0,I.jsx)(yb,{name:`botId`,placeholder:`Bot Id`})}),(0,I.jsx)(U,{type:`submit`,children:`Remove Jobs by Bot ID`})]})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Force Set Password`}),(0,I.jsx)(`p`,{children:`Note that this applies to all projects for the user. Therefore, this should only be used in extreme circumstances. Always prefer to use the "Forgot Password" flow first.`}),(0,I.jsx)(TN,{onSubmit:v,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(yb,{name:`email`,label:`Email`,required:!0}),(0,I.jsx)(sv,{name:`password`,label:`Password`,required:!0}),(0,I.jsx)(yb,{name:`projectId`,label:`Project ID`}),(0,I.jsx)(U,{type:`submit`,children:`Force Set Password`})]})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Database Stats`}),(0,I.jsx)(`p`,{children:`Query current table statistics from the database.`}),(0,I.jsx)(TN,{onSubmit:y,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(MF,{title:`Table Names (comma-delimited)`,htmlFor:`tableNames`,children:(0,I.jsx)(yb,{id:`tableNames`,name:`tableNames`,placeholder:`Observation,Observation_History`})}),(0,I.jsx)(U,{type:`submit`,children:`Get Database Stats`})]})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Database Invalid Indexes`}),(0,I.jsx)(`p`,{children:`Query invalid indexes from the database.`}),(0,I.jsx)(TN,{onSubmit:x,children:(0,I.jsx)(G,{children:(0,I.jsx)(U,{type:`submit`,children:`Get Database Invalid Indexes`})})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Database Schema Drift`}),(0,I.jsx)(`p`,{children:`Show the schema migration needed to match the expected database schema.`}),(0,I.jsxs)(Tm,{children:[(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(TN,{onSubmit:S,children:(0,I.jsx)(G,{children:(0,I.jsx)(U,{type:`submit`,children:`Get Schema Drift`})})})}),(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(TN,{onSubmit:C,children:(0,I.jsx)(G,{children:(0,I.jsx)(U,{type:`submit`,children:`Reconcile Schema Drift`})})})})]}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Reload Cron Resources`}),(0,I.jsx)(`p`,{children:`Obliterates the cron queue and rebuilds all the cron job schedulers for cron resources (eg. cron bots).`}),(0,I.jsx)(TN,{onSubmit:m,children:(0,I.jsx)(G,{children:(0,I.jsx)(U,{type:`submit`,children:`Reload Cron Resources`})})}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Database Explain Search`}),(0,I.jsx)(`p`,{children:`Runs an EXPLAIN query on the database to show the query plan for a search.`}),(0,I.jsx)($q,{setModalTitle:a,setModalContent:s,openModal:n}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`WebSocket Subscription Stats`}),(0,I.jsx)(`p`,{children:`View active WebSocket subscription statistics by project, resource type, and criteria.`}),(0,I.jsx)(Yq,{}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(q,{order:2,children:`Clear All WebSocket Subscriptions`}),(0,I.jsx)(`p`,{children:`Removes all active WebSocket subscription records from Redis. This is useful for cleaning up stale subscriptions during maintenance or after a deployment issue. Connected clients will need to re-bind.`}),(0,I.jsxs)(G,{children:[(0,I.jsx)(MF,{title:`Project (optional)`,htmlFor:`clearWsSubsProject`,children:(0,I.jsx)(uI,{name:`clearWsSubsProject`,placeholder:`All projects`,targetTypes:[`Project`],onChange:l})}),(0,I.jsx)(`div`,{children:(0,I.jsx)(U,{onClick:()=>{a(`Clear All WebSocket Subscriptions`),s((0,I.jsxs)(G,{children:[(0,I.jsxs)(H,{children:[`Are you sure you want to completely clear`,` `,(0,I.jsx)(`strong`,{children:c?`WebSocket subscriptions for "${c.display??c.reference}"`:`ALL WebSocket subscriptions`}),`? Connected clients will need to re-bind their subscriptions.`]}),(0,I.jsx)(V,{align:`center`,children:(0,I.jsx)(U,{color:`red`,onClick:h,children:`Clear`})})]})),n()},children:`Clear All WebSocket Subscriptions`})})]}),(0,I.jsx)(rg,{opened:t,onClose:r,title:i,centered:!0,size:`auto`,children:o}),(0,I.jsx)(dm,{my:`lg`}),(0,I.jsx)(dq,{})]})}function Zq(){let[e,t]=(0,b.useState)(`outdated`);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Eg,{id:`reindexType`,name:`reindexType`,value:e,onChange:e=>t(e.target.value),data:[{label:`Outdated resources`,value:`outdated`},{label:`All resources`,value:`all`},{label:`Less than or equal to a specific version`,value:`specific`}]}),e===`specific`&&(0,I.jsx)(P_,{required:!0,name:`maxResourceVersion`,placeholder:`Max Resource Version`,min:0})]})}function Qq({onSubmit:e}){let[t,n]=(0,b.useState)(!1);function r(t){let n={};for(let[e,r]of Object.entries(t))r!==``&&(n[e]=r);e(n)}return(0,I.jsx)(TN,{onSubmit:r,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(MF,{title:`Resource Type`,htmlFor:`resourceType`,children:(0,I.jsx)(yb,{id:`resourceType`,name:`resourceType`,placeholder:`Reindex Resource Type`})}),(0,I.jsx)(MF,{title:`Search Filter`,htmlFor:`filter`,children:(0,I.jsx)(yb,{id:`filter`,name:`filter`,placeholder:`e.g. name=Sam&birthdate=lt2000-01-01`})}),(0,I.jsx)(MF,{title:`Max Resource Version`,htmlFor:`maxResourceVersion`,children:(0,I.jsx)(Zq,{})}),(0,I.jsx)(U,{variant:`subtle`,size:`xs`,onClick:()=>n(!t),children:t?`Hide Advanced Options`:`Show Advanced Options`}),t&&(0,I.jsx)(G,{gap:`sm`,children:(0,I.jsxs)(Tm,{children:[(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(P_,{name:`batchSize`,label:`Resources per batch`,description:(0,I.jsx)(`span`,{children:`default: 500`}),placeholder:`500`,min:20,max:1e3})}),(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(P_,{name:`searchStatementTimeout`,label:`Search query timeout (ms)`,description:(0,I.jsx)(`span`,{children:`default: 3,600,000 (1 hour)`}),placeholder:`3600000`,min:1e3})}),(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(P_,{name:`upsertStatementTimeout`,label:`Upsert query timeout (ms)`,description:(0,I.jsx)(`span`,{children:"default: server `database.queryTimeout`"}),placeholder:`database.queryTimeout`,min:1e3})}),(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(P_,{name:`delayBetweenBatches`,label:`Delay between batches (ms)`,description:(0,I.jsx)(`span`,{children:`default: 0`}),placeholder:`0`,min:0,max:6e4})}),(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(P_,{name:`progressLogThreshold`,label:`Log progress every N resources`,description:(0,I.jsx)(`span`,{children:`default: 50,000`}),placeholder:`50000`,min:1})}),(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(P_,{name:`endTimestampBufferMinutes`,label:`End timestamp buffer (minutes)`,description:(0,I.jsx)(`span`,{children:`default: 5`}),placeholder:`5`,min:1})}),(0,I.jsx)(Tm.Col,{span:6,children:(0,I.jsx)(P_,{name:`maxIterationAttempts`,label:`Max iteration attempts`,description:(0,I.jsx)(`span`,{children:`default: 3`}),placeholder:`3`,min:1,max:20})})]})}),(0,I.jsx)(U,{type:`submit`,children:`Reindex`})]})})}function $q({setModalTitle:e,setModalContent:t,openModal:n}){let r=Z(),[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)(),f=(0,b.useMemo)(()=>{if(i?.reference)return{"_has:ProjectMembership:profile:project":i.reference}},[i]);(0,b.useEffect)(()=>{if(d(void 0),!o?.reference&&!i?.reference){l(void 0);return}r.searchResources(`ProjectMembership`,{profile:o?.reference,project:i?.reference,_count:20}).then(e=>{l(e),e.length===1&&d(aC(e[0]))}).catch(e=>{console.error(e),J({color:`red`,message:Qx(e),autoClose:!1})})},[r,o,i]);let p=(0,b.useMemo)(()=>{let e={};return o?.reference&&(e.profile=o?.reference),i?.reference&&(e.project=i?.reference),e},[o,i]);function m(i){if(!i.query){J({color:`red`,message:`Query is required`,autoClose:!1});return}let a=i.onBehalfOfProjectMembership;delete i.onBehalfOfProjectMembership;let o={query:i.query,analyze:i.analyze===`on`,count:i.count===`on`,format:`text`},s={};a&&(s[`x-medplum-on-behalf-of`]=a),r.post(`fhir/R4/$explain`,o,void 0,{headers:s}).then(r=>{e(`Database Explain`);let i=r.parameter?.find(e=>e.name===`explain`)?.valueString,a=r.parameter?.find(e=>e.name===`query`)?.valueString,o=r.parameter?.find(e=>e.name===`parameters`)?.valueString,s=r.parameter?.find(e=>e.name===`countEstimate`)?.valueInteger?.toLocaleString(),c=r.parameter?.find(e=>e.name===`countAccurate`)?.valueInteger?.toLocaleString(),l=[a,o,`
221
221
  `,i].join(`
222
- `);t((0,I.jsxs)(G,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{fw:700,children:`Query`}),(0,I.jsx)(nm,{block:!0,maw:`100%`,style:{whiteSpace:`pre-wrap`},children:l})]}),(s||c)&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{fw:700,children:`Counts`}),s&&(0,I.jsxs)(H,{children:[`Estimate: `,s]}),c&&(0,I.jsxs)(H,{children:[`Accurate: `,c]})]})]})),n()}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1})})}return!r.isLoading()&&!r.isSuperAdmin()?(0,I.jsx)(EP,{outcome:Hx}):(0,I.jsx)(CN,{onSubmit:m,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(yb,{name:`query`,label:`Search`,required:!0,placeholder:`Observation?code=85354-9&_sort=-date&_count=5`}),(0,I.jsxs)(V,{children:[(0,I.jsx)(lp,{name:`analyze`,label:`Analyze`}),(0,I.jsx)(lp,{name:`count`,label:`Total count`})]}),(0,I.jsx)(cd,{label:`On Behalf Of`,children:(0,I.jsxs)(G,{gap:`sm`,children:[(0,I.jsx)(cI,{required:!0,placeholder:`Project`,targetTypes:[`Project`],name:`onBehalfOfProject`,onChange:a}),(0,I.jsx)(cI,{required:!0,placeholder:`Practitioner or Patient`,name:`onBehalfOfProfile`,targetTypes:[`Practitioner`,`Patient`],onChange:s,searchCriteria:f}),c?.length!==1&&(0,I.jsx)(cI,{required:!0,placeholder:`ProjectMembership`,name:`onBehalfOfProjectMembership`,targetTypes:[`ProjectMembership`],onChange:d,searchCriteria:p}),c?.length===1&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{type:`hidden`,name:`onBehalfOfProjectMembership`,value:oC(c[0])}),(0,I.jsx)(mF,{value:aC(c[0])})]}),!u&&(0,I.jsx)(H,{fs:`italic`,children:`On Behalf Of not set. Running as super admin`})]})}),(0,I.jsx)(U,{type:`submit`,children:`Explain Search`})]})})}var Zq=[{label:`All`,value:`Patient,Practitioner,RelatedPerson`},{label:`Practitioner`,value:`Practitioner`},{label:`Patient`,value:`Patient`},{label:`RelatedPerson`,value:`RelatedPerson`}];function Qq(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{children:`ProjectMemberships by User and Profile Type`}),(0,I.jsx)(kK,{profileTypeOptions:Zq,fields:[`user`,`profile`,`profile-type`,`accessPolicy`,`userConfiguration`,`active`,`admin`],toolbarLeft:(0,I.jsx)(U,{component:Wj,to:`/admin/invite`,variant:`outline`,color:`blue`,leftSection:(0,I.jsx)(jj,{size:14}),children:`Invite New User`}),toolbarRight:(0,I.jsx)(Pd,{href:`https://www.medplum.com/docs/user-management`,target:`_blank`,rel:`noopener noreferrer`,size:`sm`,children:`Learn more about roles and user management`})})]})}var $q=new Map([[`1km`,`application/vnd.1000minds.decision-model+xml`],[`3dml`,`text/vnd.in3d.3dml`],[`3ds`,`image/x-3ds`],[`3g2`,`video/3gpp2`],[`3gp`,`video/3gp`],[`3gpp`,`video/3gpp`],[`3mf`,`model/3mf`],[`7z`,`application/x-7z-compressed`],[`7zip`,`application/x-7z-compressed`],[`123`,`application/vnd.lotus-1-2-3`],[`aab`,`application/x-authorware-bin`],[`aac`,`audio/x-acc`],[`aam`,`application/x-authorware-map`],[`aas`,`application/x-authorware-seg`],[`abw`,`application/x-abiword`],[`ac`,`application/vnd.nokia.n-gage.ac+xml`],[`ac3`,`audio/ac3`],[`acc`,`application/vnd.americandynamics.acc`],[`ace`,`application/x-ace-compressed`],[`acu`,`application/vnd.acucobol`],[`acutc`,`application/vnd.acucorp`],[`adp`,`audio/adpcm`],[`aep`,`application/vnd.audiograph`],[`afm`,`application/x-font-type1`],[`afp`,`application/vnd.ibm.modcap`],[`ahead`,`application/vnd.ahead.space`],[`ai`,`application/pdf`],[`aif`,`audio/x-aiff`],[`aifc`,`audio/x-aiff`],[`aiff`,`audio/x-aiff`],[`air`,`application/vnd.adobe.air-application-installer-package+zip`],[`ait`,`application/vnd.dvb.ait`],[`ami`,`application/vnd.amiga.ami`],[`amr`,`audio/amr`],[`apk`,`application/vnd.android.package-archive`],[`apng`,`image/apng`],[`appcache`,`text/cache-manifest`],[`application`,`application/x-ms-application`],[`apr`,`application/vnd.lotus-approach`],[`arc`,`application/x-freearc`],[`arj`,`application/x-arj`],[`asc`,`application/pgp-signature`],[`asf`,`video/x-ms-asf`],[`asm`,`text/x-asm`],[`aso`,`application/vnd.accpac.simply.aso`],[`asx`,`video/x-ms-asf`],[`atc`,`application/vnd.acucorp`],[`atom`,`application/atom+xml`],[`atomcat`,`application/atomcat+xml`],[`atomdeleted`,`application/atomdeleted+xml`],[`atomsvc`,`application/atomsvc+xml`],[`atx`,`application/vnd.antix.game-component`],[`au`,`audio/x-au`],[`avi`,`video/x-msvideo`],[`avif`,`image/avif`],[`aw`,`application/applixware`],[`azf`,`application/vnd.airzip.filesecure.azf`],[`azs`,`application/vnd.airzip.filesecure.azs`],[`azv`,`image/vnd.airzip.accelerator.azv`],[`azw`,`application/vnd.amazon.ebook`],[`b16`,`image/vnd.pco.b16`],[`bat`,`application/x-msdownload`],[`bcpio`,`application/x-bcpio`],[`bdf`,`application/x-font-bdf`],[`bdm`,`application/vnd.syncml.dm+wbxml`],[`bdoc`,`application/x-bdoc`],[`bed`,`application/vnd.realvnc.bed`],[`bh2`,`application/vnd.fujitsu.oasysprs`],[`bin`,`application/octet-stream`],[`blb`,`application/x-blorb`],[`blorb`,`application/x-blorb`],[`bmi`,`application/vnd.bmi`],[`bmml`,`application/vnd.balsamiq.bmml+xml`],[`bmp`,`image/bmp`],[`book`,`application/vnd.framemaker`],[`box`,`application/vnd.previewsystems.box`],[`boz`,`application/x-bzip2`],[`bpk`,`application/octet-stream`],[`bpmn`,`application/octet-stream`],[`bsp`,`model/vnd.valve.source.compiled-map`],[`btif`,`image/prs.btif`],[`buffer`,`application/octet-stream`],[`bz`,`application/x-bzip`],[`bz2`,`application/x-bzip2`],[`c`,`text/x-c`],[`c4d`,`application/vnd.clonk.c4group`],[`c4f`,`application/vnd.clonk.c4group`],[`c4g`,`application/vnd.clonk.c4group`],[`c4p`,`application/vnd.clonk.c4group`],[`c4u`,`application/vnd.clonk.c4group`],[`c11amc`,`application/vnd.cluetrust.cartomobile-config`],[`c11amz`,`application/vnd.cluetrust.cartomobile-config-pkg`],[`cab`,`application/vnd.ms-cab-compressed`],[`caf`,`audio/x-caf`],[`cap`,`application/vnd.tcpdump.pcap`],[`car`,`application/vnd.curl.car`],[`cat`,`application/vnd.ms-pki.seccat`],[`cb7`,`application/x-cbr`],[`cba`,`application/x-cbr`],[`cbr`,`application/x-cbr`],[`cbt`,`application/x-cbr`],[`cbz`,`application/x-cbr`],[`cc`,`text/x-c`],[`cco`,`application/x-cocoa`],[`cct`,`application/x-director`],[`ccxml`,`application/ccxml+xml`],[`cdbcmsg`,`application/vnd.contact.cmsg`],[`cda`,`application/x-cdf`],[`cdf`,`application/x-netcdf`],[`cdfx`,`application/cdfx+xml`],[`cdkey`,`application/vnd.mediastation.cdkey`],[`cdmia`,`application/cdmi-capability`],[`cdmic`,`application/cdmi-container`],[`cdmid`,`application/cdmi-domain`],[`cdmio`,`application/cdmi-object`],[`cdmiq`,`application/cdmi-queue`],[`cdr`,`application/cdr`],[`cdx`,`chemical/x-cdx`],[`cdxml`,`application/vnd.chemdraw+xml`],[`cdy`,`application/vnd.cinderella`],[`cer`,`application/pkix-cert`],[`cfs`,`application/x-cfs-compressed`],[`cgm`,`image/cgm`],[`chat`,`application/x-chat`],[`chm`,`application/vnd.ms-htmlhelp`],[`chrt`,`application/vnd.kde.kchart`],[`cif`,`chemical/x-cif`],[`cii`,`application/vnd.anser-web-certificate-issue-initiation`],[`cil`,`application/vnd.ms-artgalry`],[`cjs`,`application/node`],[`cla`,`application/vnd.claymore`],[`class`,`application/octet-stream`],[`clkk`,`application/vnd.crick.clicker.keyboard`],[`clkp`,`application/vnd.crick.clicker.palette`],[`clkt`,`application/vnd.crick.clicker.template`],[`clkw`,`application/vnd.crick.clicker.wordbank`],[`clkx`,`application/vnd.crick.clicker`],[`clp`,`application/x-msclip`],[`cmc`,`application/vnd.cosmocaller`],[`cmdf`,`chemical/x-cmdf`],[`cml`,`chemical/x-cml`],[`cmp`,`application/vnd.yellowriver-custom-menu`],[`cmx`,`image/x-cmx`],[`cod`,`application/vnd.rim.cod`],[`coffee`,`text/coffeescript`],[`com`,`application/x-msdownload`],[`conf`,`text/plain`],[`cpio`,`application/x-cpio`],[`cpp`,`text/x-c`],[`cpt`,`application/mac-compactpro`],[`crd`,`application/x-mscardfile`],[`crl`,`application/pkix-crl`],[`crt`,`application/x-x509-ca-cert`],[`crx`,`application/x-chrome-extension`],[`cryptonote`,`application/vnd.rig.cryptonote`],[`csh`,`application/x-csh`],[`csl`,`application/vnd.citationstyles.style+xml`],[`csml`,`chemical/x-csml`],[`csp`,`application/vnd.commonspace`],[`csr`,`application/octet-stream`],[`css`,`text/css`],[`cst`,`application/x-director`],[`csv`,`text/csv`],[`cu`,`application/cu-seeme`],[`curl`,`text/vnd.curl`],[`cww`,`application/prs.cww`],[`cxt`,`application/x-director`],[`cxx`,`text/x-c`],[`dae`,`model/vnd.collada+xml`],[`daf`,`application/vnd.mobius.daf`],[`dart`,`application/vnd.dart`],[`dataless`,`application/vnd.fdsn.seed`],[`davmount`,`application/davmount+xml`],[`dbf`,`application/vnd.dbf`],[`dbk`,`application/docbook+xml`],[`dcr`,`application/x-director`],[`dcurl`,`text/vnd.curl.dcurl`],[`dd2`,`application/vnd.oma.dd2+xml`],[`ddd`,`application/vnd.fujixerox.ddd`],[`ddf`,`application/vnd.syncml.dmddf+xml`],[`dds`,`image/vnd.ms-dds`],[`deb`,`application/x-debian-package`],[`def`,`text/plain`],[`deploy`,`application/octet-stream`],[`der`,`application/x-x509-ca-cert`],[`dfac`,`application/vnd.dreamfactory`],[`dgc`,`application/x-dgc-compressed`],[`dic`,`text/x-c`],[`dir`,`application/x-director`],[`dis`,`application/vnd.mobius.dis`],[`disposition-notification`,`message/disposition-notification`],[`dist`,`application/octet-stream`],[`distz`,`application/octet-stream`],[`djv`,`image/vnd.djvu`],[`djvu`,`image/vnd.djvu`],[`dll`,`application/octet-stream`],[`dmg`,`application/x-apple-diskimage`],[`dmn`,`application/octet-stream`],[`dmp`,`application/vnd.tcpdump.pcap`],[`dms`,`application/octet-stream`],[`dna`,`application/vnd.dna`],[`doc`,`application/msword`],[`docm`,`application/vnd.ms-word.template.macroEnabled.12`],[`docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`dot`,`application/msword`],[`dotm`,`application/vnd.ms-word.template.macroEnabled.12`],[`dotx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.template`],[`dp`,`application/vnd.osgi.dp`],[`dpg`,`application/vnd.dpgraph`],[`dra`,`audio/vnd.dra`],[`drle`,`image/dicom-rle`],[`dsc`,`text/prs.lines.tag`],[`dssc`,`application/dssc+der`],[`dtb`,`application/x-dtbook+xml`],[`dtd`,`application/xml-dtd`],[`dts`,`audio/vnd.dts`],[`dtshd`,`audio/vnd.dts.hd`],[`dump`,`application/octet-stream`],[`dvb`,`video/vnd.dvb.file`],[`dvi`,`application/x-dvi`],[`dwd`,`application/atsc-dwd+xml`],[`dwf`,`model/vnd.dwf`],[`dwg`,`image/vnd.dwg`],[`dxf`,`image/vnd.dxf`],[`dxp`,`application/vnd.spotfire.dxp`],[`dxr`,`application/x-director`],[`ear`,`application/java-archive`],[`ecelp4800`,`audio/vnd.nuera.ecelp4800`],[`ecelp7470`,`audio/vnd.nuera.ecelp7470`],[`ecelp9600`,`audio/vnd.nuera.ecelp9600`],[`ecma`,`application/ecmascript`],[`edm`,`application/vnd.novadigm.edm`],[`edx`,`application/vnd.novadigm.edx`],[`efif`,`application/vnd.picsel`],[`ei6`,`application/vnd.pg.osasli`],[`elc`,`application/octet-stream`],[`emf`,`image/emf`],[`eml`,`message/rfc822`],[`emma`,`application/emma+xml`],[`emotionml`,`application/emotionml+xml`],[`emz`,`application/x-msmetafile`],[`eol`,`audio/vnd.digital-winds`],[`eot`,`application/vnd.ms-fontobject`],[`eps`,`application/postscript`],[`epub`,`application/epub+zip`],[`es`,`application/ecmascript`],[`es3`,`application/vnd.eszigno3+xml`],[`esa`,`application/vnd.osgi.subsystem`],[`esf`,`application/vnd.epson.esf`],[`et3`,`application/vnd.eszigno3+xml`],[`etx`,`text/x-setext`],[`eva`,`application/x-eva`],[`evy`,`application/x-envoy`],[`exe`,`application/octet-stream`],[`exi`,`application/exi`],[`exp`,`application/express`],[`exr`,`image/aces`],[`ext`,`application/vnd.novadigm.ext`],[`ez`,`application/andrew-inset`],[`ez2`,`application/vnd.ezpix-album`],[`ez3`,`application/vnd.ezpix-package`],[`f`,`text/x-fortran`],[`f4v`,`video/mp4`],[`f77`,`text/x-fortran`],[`f90`,`text/x-fortran`],[`fbs`,`image/vnd.fastbidsheet`],[`fcdt`,`application/vnd.adobe.formscentral.fcdt`],[`fcs`,`application/vnd.isac.fcs`],[`fdf`,`application/vnd.fdf`],[`fdt`,`application/fdt+xml`],[`fe_launch`,`application/vnd.denovo.fcselayout-link`],[`fg5`,`application/vnd.fujitsu.oasysgp`],[`fgd`,`application/x-director`],[`fh`,`image/x-freehand`],[`fh4`,`image/x-freehand`],[`fh5`,`image/x-freehand`],[`fh7`,`image/x-freehand`],[`fhc`,`image/x-freehand`],[`fig`,`application/x-xfig`],[`fits`,`image/fits`],[`flac`,`audio/x-flac`],[`fli`,`video/x-fli`],[`flo`,`application/vnd.micrografx.flo`],[`flv`,`video/x-flv`],[`flw`,`application/vnd.kde.kivio`],[`flx`,`text/vnd.fmi.flexstor`],[`fly`,`text/vnd.fly`],[`fm`,`application/vnd.framemaker`],[`fnc`,`application/vnd.frogans.fnc`],[`fo`,`application/vnd.software602.filler.form+xml`],[`for`,`text/x-fortran`],[`fpx`,`image/vnd.fpx`],[`frame`,`application/vnd.framemaker`],[`fsc`,`application/vnd.fsc.weblaunch`],[`fst`,`image/vnd.fst`],[`ftc`,`application/vnd.fluxtime.clip`],[`fti`,`application/vnd.anser-web-funds-transfer-initiation`],[`fvt`,`video/vnd.fvt`],[`fxp`,`application/vnd.adobe.fxp`],[`fxpl`,`application/vnd.adobe.fxp`],[`fzs`,`application/vnd.fuzzysheet`],[`g2w`,`application/vnd.geoplan`],[`g3`,`image/g3fax`],[`g3w`,`application/vnd.geospace`],[`gac`,`application/vnd.groove-account`],[`gam`,`application/x-tads`],[`gbr`,`application/rpki-ghostbusters`],[`gca`,`application/x-gca-compressed`],[`gdl`,`model/vnd.gdl`],[`gdoc`,`application/vnd.google-apps.document`],[`geo`,`application/vnd.dynageo`],[`geojson`,`application/geo+json`],[`gex`,`application/vnd.geometry-explorer`],[`ggb`,`application/vnd.geogebra.file`],[`ggt`,`application/vnd.geogebra.tool`],[`ghf`,`application/vnd.groove-help`],[`gif`,`image/gif`],[`gim`,`application/vnd.groove-identity-message`],[`glb`,`model/gltf-binary`],[`gltf`,`model/gltf+json`],[`gml`,`application/gml+xml`],[`gmx`,`application/vnd.gmx`],[`gnumeric`,`application/x-gnumeric`],[`gpg`,`application/gpg-keys`],[`gph`,`application/vnd.flographit`],[`gpx`,`application/gpx+xml`],[`gqf`,`application/vnd.grafeq`],[`gqs`,`application/vnd.grafeq`],[`gram`,`application/srgs`],[`gramps`,`application/x-gramps-xml`],[`gre`,`application/vnd.geometry-explorer`],[`grv`,`application/vnd.groove-injector`],[`grxml`,`application/srgs+xml`],[`gsf`,`application/x-font-ghostscript`],[`gsheet`,`application/vnd.google-apps.spreadsheet`],[`gslides`,`application/vnd.google-apps.presentation`],[`gtar`,`application/x-gtar`],[`gtm`,`application/vnd.groove-tool-message`],[`gtw`,`model/vnd.gtw`],[`gv`,`text/vnd.graphviz`],[`gxf`,`application/gxf`],[`gxt`,`application/vnd.geonext`],[`gz`,`application/gzip`],[`gzip`,`application/gzip`],[`h`,`text/x-c`],[`h261`,`video/h261`],[`h263`,`video/h263`],[`h264`,`video/h264`],[`hal`,`application/vnd.hal+xml`],[`hbci`,`application/vnd.hbci`],[`hbs`,`text/x-handlebars-template`],[`hdd`,`application/x-virtualbox-hdd`],[`hdf`,`application/x-hdf`],[`heic`,`image/heic`],[`heics`,`image/heic-sequence`],[`heif`,`image/heif`],[`heifs`,`image/heif-sequence`],[`hej2`,`image/hej2k`],[`held`,`application/atsc-held+xml`],[`hh`,`text/x-c`],[`hjson`,`application/hjson`],[`hlp`,`application/winhlp`],[`hpgl`,`application/vnd.hp-hpgl`],[`hpid`,`application/vnd.hp-hpid`],[`hps`,`application/vnd.hp-hps`],[`hqx`,`application/mac-binhex40`],[`hsj2`,`image/hsj2`],[`htc`,`text/x-component`],[`htke`,`application/vnd.kenameaapp`],[`htm`,`text/html`],[`html`,`text/html`],[`hvd`,`application/vnd.yamaha.hv-dic`],[`hvp`,`application/vnd.yamaha.hv-voice`],[`hvs`,`application/vnd.yamaha.hv-script`],[`i2g`,`application/vnd.intergeo`],[`icc`,`application/vnd.iccprofile`],[`ice`,`x-conference/x-cooltalk`],[`icm`,`application/vnd.iccprofile`],[`ico`,`image/x-icon`],[`ics`,`text/calendar`],[`ief`,`image/ief`],[`ifb`,`text/calendar`],[`ifm`,`application/vnd.shana.informed.formdata`],[`iges`,`model/iges`],[`igl`,`application/vnd.igloader`],[`igm`,`application/vnd.insors.igm`],[`igs`,`model/iges`],[`igx`,`application/vnd.micrografx.igx`],[`iif`,`application/vnd.shana.informed.interchange`],[`img`,`application/octet-stream`],[`imp`,`application/vnd.accpac.simply.imp`],[`ims`,`application/vnd.ms-ims`],[`in`,`text/plain`],[`ini`,`text/plain`],[`ink`,`application/inkml+xml`],[`inkml`,`application/inkml+xml`],[`install`,`application/x-install-instructions`],[`iota`,`application/vnd.astraea-software.iota`],[`ipfix`,`application/ipfix`],[`ipk`,`application/vnd.shana.informed.package`],[`irm`,`application/vnd.ibm.rights-management`],[`irp`,`application/vnd.irepository.package+xml`],[`iso`,`application/x-iso9660-image`],[`itp`,`application/vnd.shana.informed.formtemplate`],[`its`,`application/its+xml`],[`ivp`,`application/vnd.immervision-ivp`],[`ivu`,`application/vnd.immervision-ivu`],[`jad`,`text/vnd.sun.j2me.app-descriptor`],[`jade`,`text/jade`],[`jam`,`application/vnd.jam`],[`jar`,`application/java-archive`],[`jardiff`,`application/x-java-archive-diff`],[`java`,`text/x-java-source`],[`jhc`,`image/jphc`],[`jisp`,`application/vnd.jisp`],[`jls`,`image/jls`],[`jlt`,`application/vnd.hp-jlyt`],[`jng`,`image/x-jng`],[`jnlp`,`application/x-java-jnlp-file`],[`joda`,`application/vnd.joost.joda-archive`],[`jp2`,`image/jp2`],[`jpe`,`image/jpeg`],[`jpeg`,`image/jpeg`],[`jpf`,`image/jpx`],[`jpg`,`image/jpeg`],[`jpg2`,`image/jp2`],[`jpgm`,`video/jpm`],[`jpgv`,`video/jpeg`],[`jph`,`image/jph`],[`jpm`,`video/jpm`],[`jpx`,`image/jpx`],[`js`,`application/javascript`],[`json`,`application/json`],[`json5`,`application/json5`],[`jsonld`,`application/ld+json`],[`jsonl`,`application/jsonl`],[`jsonml`,`application/jsonml+json`],[`jsx`,`text/jsx`],[`jxr`,`image/jxr`],[`jxra`,`image/jxra`],[`jxrs`,`image/jxrs`],[`jxs`,`image/jxs`],[`jxsc`,`image/jxsc`],[`jxsi`,`image/jxsi`],[`jxss`,`image/jxss`],[`kar`,`audio/midi`],[`karbon`,`application/vnd.kde.karbon`],[`kdb`,`application/octet-stream`],[`kdbx`,`application/x-keepass2`],[`key`,`application/x-iwork-keynote-sffkey`],[`kfo`,`application/vnd.kde.kformula`],[`kia`,`application/vnd.kidspiration`],[`kml`,`application/vnd.google-earth.kml+xml`],[`kmz`,`application/vnd.google-earth.kmz`],[`kne`,`application/vnd.kinar`],[`knp`,`application/vnd.kinar`],[`kon`,`application/vnd.kde.kontour`],[`kpr`,`application/vnd.kde.kpresenter`],[`kpt`,`application/vnd.kde.kpresenter`],[`kpxx`,`application/vnd.ds-keypoint`],[`ksp`,`application/vnd.kde.kspread`],[`ktr`,`application/vnd.kahootz`],[`ktx`,`image/ktx`],[`ktx2`,`image/ktx2`],[`ktz`,`application/vnd.kahootz`],[`kwd`,`application/vnd.kde.kword`],[`kwt`,`application/vnd.kde.kword`],[`lasxml`,`application/vnd.las.las+xml`],[`latex`,`application/x-latex`],[`lbd`,`application/vnd.llamagraphics.life-balance.desktop`],[`lbe`,`application/vnd.llamagraphics.life-balance.exchange+xml`],[`les`,`application/vnd.hhe.lesson-player`],[`less`,`text/less`],[`lgr`,`application/lgr+xml`],[`lha`,`application/octet-stream`],[`link66`,`application/vnd.route66.link66+xml`],[`list`,`text/plain`],[`list3820`,`application/vnd.ibm.modcap`],[`listafp`,`application/vnd.ibm.modcap`],[`litcoffee`,`text/coffeescript`],[`lnk`,`application/x-ms-shortcut`],[`log`,`text/plain`],[`lostxml`,`application/lost+xml`],[`lrf`,`application/octet-stream`],[`lrm`,`application/vnd.ms-lrm`],[`ltf`,`application/vnd.frogans.ltf`],[`lua`,`text/x-lua`],[`luac`,`application/x-lua-bytecode`],[`lvp`,`audio/vnd.lucent.voice`],[`lwp`,`application/vnd.lotus-wordpro`],[`lzh`,`application/octet-stream`],[`m1v`,`video/mpeg`],[`m2a`,`audio/mpeg`],[`m2v`,`video/mpeg`],[`m3a`,`audio/mpeg`],[`m3u`,`text/plain`],[`m3u8`,`application/vnd.apple.mpegurl`],[`m4a`,`audio/x-m4a`],[`m4p`,`application/mp4`],[`m4s`,`video/iso.segment`],[`m4u`,`application/vnd.mpegurl`],[`m4v`,`video/x-m4v`],[`m13`,`application/x-msmediaview`],[`m14`,`application/x-msmediaview`],[`m21`,`application/mp21`],[`ma`,`application/mathematica`],[`mads`,`application/mads+xml`],[`maei`,`application/mmt-aei+xml`],[`mag`,`application/vnd.ecowin.chart`],[`maker`,`application/vnd.framemaker`],[`man`,`text/troff`],[`manifest`,`text/cache-manifest`],[`map`,`application/json`],[`mar`,`application/octet-stream`],[`markdown`,`text/markdown`],[`mathml`,`application/mathml+xml`],[`mb`,`application/mathematica`],[`mbk`,`application/vnd.mobius.mbk`],[`mbox`,`application/mbox`],[`mc1`,`application/vnd.medcalcdata`],[`mcd`,`application/vnd.mcd`],[`mcurl`,`text/vnd.curl.mcurl`],[`md`,`text/markdown`],[`mdb`,`application/x-msaccess`],[`mdi`,`image/vnd.ms-modi`],[`mdx`,`text/mdx`],[`me`,`text/troff`],[`mesh`,`model/mesh`],[`meta4`,`application/metalink4+xml`],[`metalink`,`application/metalink+xml`],[`mets`,`application/mets+xml`],[`mfm`,`application/vnd.mfmp`],[`mft`,`application/rpki-manifest`],[`mgp`,`application/vnd.osgeo.mapguide.package`],[`mgz`,`application/vnd.proteus.magazine`],[`mid`,`audio/midi`],[`midi`,`audio/midi`],[`mie`,`application/x-mie`],[`mif`,`application/vnd.mif`],[`mime`,`message/rfc822`],[`mj2`,`video/mj2`],[`mjp2`,`video/mj2`],[`mjs`,`application/javascript`],[`mk3d`,`video/x-matroska`],[`mka`,`audio/x-matroska`],[`mkd`,`text/x-markdown`],[`mks`,`video/x-matroska`],[`mkv`,`video/x-matroska`],[`mlp`,`application/vnd.dolby.mlp`],[`mmd`,`application/vnd.chipnuts.karaoke-mmd`],[`mmf`,`application/vnd.smaf`],[`mml`,`text/mathml`],[`mmr`,`image/vnd.fujixerox.edmics-mmr`],[`mng`,`video/x-mng`],[`mny`,`application/x-msmoney`],[`mobi`,`application/x-mobipocket-ebook`],[`mods`,`application/mods+xml`],[`mov`,`video/quicktime`],[`movie`,`video/x-sgi-movie`],[`mp2`,`audio/mpeg`],[`mp2a`,`audio/mpeg`],[`mp3`,`audio/mpeg`],[`mp4`,`video/mp4`],[`mp4a`,`audio/mp4`],[`mp4s`,`application/mp4`],[`mp4v`,`video/mp4`],[`mp21`,`application/mp21`],[`mpc`,`application/vnd.mophun.certificate`],[`mpd`,`application/dash+xml`],[`mpe`,`video/mpeg`],[`mpeg`,`video/mpeg`],[`mpg`,`video/mpeg`],[`mpg4`,`video/mp4`],[`mpga`,`audio/mpeg`],[`mpkg`,`application/vnd.apple.installer+xml`],[`mpm`,`application/vnd.blueice.multipass`],[`mpn`,`application/vnd.mophun.application`],[`mpp`,`application/vnd.ms-project`],[`mpt`,`application/vnd.ms-project`],[`mpy`,`application/vnd.ibm.minipay`],[`mqy`,`application/vnd.mobius.mqy`],[`mrc`,`application/marc`],[`mrcx`,`application/marcxml+xml`],[`ms`,`text/troff`],[`mscml`,`application/mediaservercontrol+xml`],[`mseed`,`application/vnd.fdsn.mseed`],[`mseq`,`application/vnd.mseq`],[`msf`,`application/vnd.epson.msf`],[`msg`,`application/vnd.ms-outlook`],[`msh`,`model/mesh`],[`msi`,`application/x-msdownload`],[`msl`,`application/vnd.mobius.msl`],[`msm`,`application/octet-stream`],[`msp`,`application/octet-stream`],[`msty`,`application/vnd.muvee.style`],[`mtl`,`model/mtl`],[`mts`,`model/vnd.mts`],[`mus`,`application/vnd.musician`],[`musd`,`application/mmt-usd+xml`],[`musicxml`,`application/vnd.recordare.musicxml+xml`],[`mvb`,`application/x-msmediaview`],[`mvt`,`application/vnd.mapbox-vector-tile`],[`mwf`,`application/vnd.mfer`],[`mxf`,`application/mxf`],[`mxl`,`application/vnd.recordare.musicxml`],[`mxmf`,`audio/mobile-xmf`],[`mxml`,`application/xv+xml`],[`mxs`,`application/vnd.triscape.mxs`],[`mxu`,`video/vnd.mpegurl`],[`n-gage`,`application/vnd.nokia.n-gage.symbian.install`],[`n3`,`text/n3`],[`nb`,`application/mathematica`],[`nbp`,`application/vnd.wolfram.player`],[`nc`,`application/x-netcdf`],[`ncx`,`application/x-dtbncx+xml`],[`nfo`,`text/x-nfo`],[`ngdat`,`application/vnd.nokia.n-gage.data`],[`nitf`,`application/vnd.nitf`],[`nlu`,`application/vnd.neurolanguage.nlu`],[`nml`,`application/vnd.enliven`],[`nnd`,`application/vnd.noblenet-directory`],[`nns`,`application/vnd.noblenet-sealer`],[`nnw`,`application/vnd.noblenet-web`],[`npx`,`image/vnd.net-fpx`],[`nq`,`application/n-quads`],[`nsc`,`application/x-conference`],[`nsf`,`application/vnd.lotus-notes`],[`nt`,`application/n-triples`],[`ntf`,`application/vnd.nitf`],[`numbers`,`application/x-iwork-numbers-sffnumbers`],[`nzb`,`application/x-nzb`],[`oa2`,`application/vnd.fujitsu.oasys2`],[`oa3`,`application/vnd.fujitsu.oasys3`],[`oas`,`application/vnd.fujitsu.oasys`],[`obd`,`application/x-msbinder`],[`obgx`,`application/vnd.openblox.game+xml`],[`obj`,`model/obj`],[`oda`,`application/oda`],[`odb`,`application/vnd.oasis.opendocument.database`],[`odc`,`application/vnd.oasis.opendocument.chart`],[`odf`,`application/vnd.oasis.opendocument.formula`],[`odft`,`application/vnd.oasis.opendocument.formula-template`],[`odg`,`application/vnd.oasis.opendocument.graphics`],[`odi`,`application/vnd.oasis.opendocument.image`],[`odm`,`application/vnd.oasis.opendocument.text-master`],[`odp`,`application/vnd.oasis.opendocument.presentation`],[`ods`,`application/vnd.oasis.opendocument.spreadsheet`],[`odt`,`application/vnd.oasis.opendocument.text`],[`oga`,`audio/ogg`],[`ogex`,`model/vnd.opengex`],[`ogg`,`audio/ogg`],[`ogv`,`video/ogg`],[`ogx`,`application/ogg`],[`omdoc`,`application/omdoc+xml`],[`onepkg`,`application/onenote`],[`onetmp`,`application/onenote`],[`onetoc`,`application/onenote`],[`onetoc2`,`application/onenote`],[`opf`,`application/oebps-package+xml`],[`opml`,`text/x-opml`],[`oprc`,`application/vnd.palm`],[`opus`,`audio/ogg`],[`org`,`text/x-org`],[`osf`,`application/vnd.yamaha.openscoreformat`],[`osfpvg`,`application/vnd.yamaha.openscoreformat.osfpvg+xml`],[`osm`,`application/vnd.openstreetmap.data+xml`],[`otc`,`application/vnd.oasis.opendocument.chart-template`],[`otf`,`font/otf`],[`otg`,`application/vnd.oasis.opendocument.graphics-template`],[`oth`,`application/vnd.oasis.opendocument.text-web`],[`oti`,`application/vnd.oasis.opendocument.image-template`],[`otp`,`application/vnd.oasis.opendocument.presentation-template`],[`ots`,`application/vnd.oasis.opendocument.spreadsheet-template`],[`ott`,`application/vnd.oasis.opendocument.text-template`],[`ova`,`application/x-virtualbox-ova`],[`ovf`,`application/x-virtualbox-ovf`],[`owl`,`application/rdf+xml`],[`oxps`,`application/oxps`],[`oxt`,`application/vnd.openofficeorg.extension`],[`p`,`text/x-pascal`],[`p7a`,`application/x-pkcs7-signature`],[`p7b`,`application/x-pkcs7-certificates`],[`p7c`,`application/pkcs7-mime`],[`p7m`,`application/pkcs7-mime`],[`p7r`,`application/x-pkcs7-certreqresp`],[`p7s`,`application/pkcs7-signature`],[`p8`,`application/pkcs8`],[`p10`,`application/x-pkcs10`],[`p12`,`application/x-pkcs12`],[`pac`,`application/x-ns-proxy-autoconfig`],[`pages`,`application/x-iwork-pages-sffpages`],[`pas`,`text/x-pascal`],[`paw`,`application/vnd.pawaafile`],[`pbd`,`application/vnd.powerbuilder6`],[`pbm`,`image/x-portable-bitmap`],[`pcap`,`application/vnd.tcpdump.pcap`],[`pcf`,`application/x-font-pcf`],[`pcl`,`application/vnd.hp-pcl`],[`pclxl`,`application/vnd.hp-pclxl`],[`pct`,`image/x-pict`],[`pcurl`,`application/vnd.curl.pcurl`],[`pcx`,`image/x-pcx`],[`pdb`,`application/x-pilot`],[`pde`,`text/x-processing`],[`pdf`,`application/pdf`],[`pem`,`application/x-x509-user-cert`],[`pfa`,`application/x-font-type1`],[`pfb`,`application/x-font-type1`],[`pfm`,`application/x-font-type1`],[`pfr`,`application/font-tdpfr`],[`pfx`,`application/x-pkcs12`],[`pgm`,`image/x-portable-graymap`],[`pgn`,`application/x-chess-pgn`],[`pgp`,`application/pgp`],[`php`,`application/x-httpd-php`],[`php3`,`application/x-httpd-php`],[`php4`,`application/x-httpd-php`],[`phps`,`application/x-httpd-php-source`],[`phtml`,`application/x-httpd-php`],[`pic`,`image/x-pict`],[`pkg`,`application/octet-stream`],[`pki`,`application/pkixcmp`],[`pkipath`,`application/pkix-pkipath`],[`pkpass`,`application/vnd.apple.pkpass`],[`pl`,`application/x-perl`],[`plb`,`application/vnd.3gpp.pic-bw-large`],[`plc`,`application/vnd.mobius.plc`],[`plf`,`application/vnd.pocketlearn`],[`pls`,`application/pls+xml`],[`pm`,`application/x-perl`],[`pml`,`application/vnd.ctc-posml`],[`png`,`image/png`],[`pnm`,`image/x-portable-anymap`],[`portpkg`,`application/vnd.macports.portpkg`],[`pot`,`application/vnd.ms-powerpoint`],[`potm`,`application/vnd.ms-powerpoint.presentation.macroEnabled.12`],[`potx`,`application/vnd.openxmlformats-officedocument.presentationml.template`],[`ppa`,`application/vnd.ms-powerpoint`],[`ppam`,`application/vnd.ms-powerpoint.addin.macroEnabled.12`],[`ppd`,`application/vnd.cups-ppd`],[`ppm`,`image/x-portable-pixmap`],[`pps`,`application/vnd.ms-powerpoint`],[`ppsm`,`application/vnd.ms-powerpoint.slideshow.macroEnabled.12`],[`ppsx`,`application/vnd.openxmlformats-officedocument.presentationml.slideshow`],[`ppt`,`application/powerpoint`],[`pptm`,`application/vnd.ms-powerpoint.presentation.macroEnabled.12`],[`pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`pqa`,`application/vnd.palm`],[`prc`,`application/x-pilot`],[`pre`,`application/vnd.lotus-freelance`],[`prf`,`application/pics-rules`],[`provx`,`application/provenance+xml`],[`ps`,`application/postscript`],[`psb`,`application/vnd.3gpp.pic-bw-small`],[`psd`,`application/x-photoshop`],[`psf`,`application/x-font-linux-psf`],[`pskcxml`,`application/pskc+xml`],[`pti`,`image/prs.pti`],[`ptid`,`application/vnd.pvi.ptid1`],[`pub`,`application/x-mspublisher`],[`pvb`,`application/vnd.3gpp.pic-bw-var`],[`pwn`,`application/vnd.3m.post-it-notes`],[`pya`,`audio/vnd.ms-playready.media.pya`],[`pyv`,`video/vnd.ms-playready.media.pyv`],[`qam`,`application/vnd.epson.quickanime`],[`qbo`,`application/vnd.intu.qbo`],[`qfx`,`application/vnd.intu.qfx`],[`qps`,`application/vnd.publishare-delta-tree`],[`qt`,`video/quicktime`],[`qwd`,`application/vnd.quark.quarkxpress`],[`qwt`,`application/vnd.quark.quarkxpress`],[`qxb`,`application/vnd.quark.quarkxpress`],[`qxd`,`application/vnd.quark.quarkxpress`],[`qxl`,`application/vnd.quark.quarkxpress`],[`qxt`,`application/vnd.quark.quarkxpress`],[`ra`,`audio/x-realaudio`],[`ram`,`audio/x-pn-realaudio`],[`raml`,`application/raml+yaml`],[`rapd`,`application/route-apd+xml`],[`rar`,`application/x-rar`],[`ras`,`image/x-cmu-raster`],[`rcprofile`,`application/vnd.ipunplugged.rcprofile`],[`rdf`,`application/rdf+xml`],[`rdz`,`application/vnd.data-vision.rdz`],[`relo`,`application/p2p-overlay+xml`],[`rep`,`application/vnd.businessobjects`],[`res`,`application/x-dtbresource+xml`],[`rgb`,`image/x-rgb`],[`rif`,`application/reginfo+xml`],[`rip`,`audio/vnd.rip`],[`ris`,`application/x-research-info-systems`],[`rl`,`application/resource-lists+xml`],[`rlc`,`image/vnd.fujixerox.edmics-rlc`],[`rld`,`application/resource-lists-diff+xml`],[`rm`,`audio/x-pn-realaudio`],[`rmi`,`audio/midi`],[`rmp`,`audio/x-pn-realaudio-plugin`],[`rms`,`application/vnd.jcp.javame.midlet-rms`],[`rmvb`,`application/vnd.rn-realmedia-vbr`],[`rnc`,`application/relax-ng-compact-syntax`],[`rng`,`application/xml`],[`roa`,`application/rpki-roa`],[`roff`,`text/troff`],[`rp9`,`application/vnd.cloanto.rp9`],[`rpm`,`audio/x-pn-realaudio-plugin`],[`rpss`,`application/vnd.nokia.radio-presets`],[`rpst`,`application/vnd.nokia.radio-preset`],[`rq`,`application/sparql-query`],[`rs`,`application/rls-services+xml`],[`rsa`,`application/x-pkcs7`],[`rsat`,`application/atsc-rsat+xml`],[`rsd`,`application/rsd+xml`],[`rsheet`,`application/urc-ressheet+xml`],[`rss`,`application/rss+xml`],[`rtf`,`text/rtf`],[`rtx`,`text/richtext`],[`run`,`application/x-makeself`],[`rusd`,`application/route-usd+xml`],[`rv`,`video/vnd.rn-realvideo`],[`s`,`text/x-asm`],[`s3m`,`audio/s3m`],[`saf`,`application/vnd.yamaha.smaf-audio`],[`sass`,`text/x-sass`],[`sbml`,`application/sbml+xml`],[`sc`,`application/vnd.ibm.secure-container`],[`scd`,`application/x-msschedule`],[`scm`,`application/vnd.lotus-screencam`],[`scq`,`application/scvp-cv-request`],[`scs`,`application/scvp-cv-response`],[`scss`,`text/x-scss`],[`scurl`,`text/vnd.curl.scurl`],[`sda`,`application/vnd.stardivision.draw`],[`sdc`,`application/vnd.stardivision.calc`],[`sdd`,`application/vnd.stardivision.impress`],[`sdkd`,`application/vnd.solent.sdkm+xml`],[`sdkm`,`application/vnd.solent.sdkm+xml`],[`sdp`,`application/sdp`],[`sdw`,`application/vnd.stardivision.writer`],[`sea`,`application/octet-stream`],[`see`,`application/vnd.seemail`],[`seed`,`application/vnd.fdsn.seed`],[`sema`,`application/vnd.sema`],[`semd`,`application/vnd.semd`],[`semf`,`application/vnd.semf`],[`senmlx`,`application/senml+xml`],[`sensmlx`,`application/sensml+xml`],[`ser`,`application/java-serialized-object`],[`setpay`,`application/set-payment-initiation`],[`setreg`,`application/set-registration-initiation`],[`sfd-hdstx`,`application/vnd.hydrostatix.sof-data`],[`sfs`,`application/vnd.spotfire.sfs`],[`sfv`,`text/x-sfv`],[`sgi`,`image/sgi`],[`sgl`,`application/vnd.stardivision.writer-global`],[`sgm`,`text/sgml`],[`sgml`,`text/sgml`],[`sh`,`application/x-sh`],[`shar`,`application/x-shar`],[`shex`,`text/shex`],[`shf`,`application/shf+xml`],[`shtml`,`text/html`],[`sid`,`image/x-mrsid-image`],[`sieve`,`application/sieve`],[`sig`,`application/pgp-signature`],[`sil`,`audio/silk`],[`silo`,`model/mesh`],[`sis`,`application/vnd.symbian.install`],[`sisx`,`application/vnd.symbian.install`],[`sit`,`application/x-stuffit`],[`sitx`,`application/x-stuffitx`],[`siv`,`application/sieve`],[`skd`,`application/vnd.koan`],[`skm`,`application/vnd.koan`],[`skp`,`application/vnd.koan`],[`skt`,`application/vnd.koan`],[`sldm`,`application/vnd.ms-powerpoint.slide.macroenabled.12`],[`sldx`,`application/vnd.openxmlformats-officedocument.presentationml.slide`],[`slim`,`text/slim`],[`slm`,`text/slim`],[`sls`,`application/route-s-tsid+xml`],[`slt`,`application/vnd.epson.salt`],[`sm`,`application/vnd.stepmania.stepchart`],[`smf`,`application/vnd.stardivision.math`],[`smi`,`application/smil`],[`smil`,`application/smil`],[`smv`,`video/x-smv`],[`smzip`,`application/vnd.stepmania.package`],[`snd`,`audio/basic`],[`snf`,`application/x-font-snf`],[`so`,`application/octet-stream`],[`spc`,`application/x-pkcs7-certificates`],[`spdx`,`text/spdx`],[`spf`,`application/vnd.yamaha.smaf-phrase`],[`spl`,`application/x-futuresplash`],[`spot`,`text/vnd.in3d.spot`],[`spp`,`application/scvp-vp-response`],[`spq`,`application/scvp-vp-request`],[`spx`,`audio/ogg`],[`sql`,`application/x-sql`],[`src`,`application/x-wais-source`],[`srt`,`application/x-subrip`],[`sru`,`application/sru+xml`],[`srx`,`application/sparql-results+xml`],[`ssdl`,`application/ssdl+xml`],[`sse`,`application/vnd.kodak-descriptor`],[`ssf`,`application/vnd.epson.ssf`],[`ssml`,`application/ssml+xml`],[`sst`,`application/octet-stream`],[`st`,`application/vnd.sailingtracker.track`],[`stc`,`application/vnd.sun.xml.calc.template`],[`std`,`application/vnd.sun.xml.draw.template`],[`stf`,`application/vnd.wt.stf`],[`sti`,`application/vnd.sun.xml.impress.template`],[`stk`,`application/hyperstudio`],[`stl`,`model/stl`],[`stpx`,`model/step+xml`],[`stpxz`,`model/step-xml+zip`],[`stpz`,`model/step+zip`],[`str`,`application/vnd.pg.format`],[`stw`,`application/vnd.sun.xml.writer.template`],[`styl`,`text/stylus`],[`stylus`,`text/stylus`],[`sub`,`text/vnd.dvb.subtitle`],[`sus`,`application/vnd.sus-calendar`],[`susp`,`application/vnd.sus-calendar`],[`sv4cpio`,`application/x-sv4cpio`],[`sv4crc`,`application/x-sv4crc`],[`svc`,`application/vnd.dvb.service`],[`svd`,`application/vnd.svd`],[`svg`,`image/svg+xml`],[`svgz`,`image/svg+xml`],[`swa`,`application/x-director`],[`swf`,`application/x-shockwave-flash`],[`swi`,`application/vnd.aristanetworks.swi`],[`swidtag`,`application/swid+xml`],[`sxc`,`application/vnd.sun.xml.calc`],[`sxd`,`application/vnd.sun.xml.draw`],[`sxg`,`application/vnd.sun.xml.writer.global`],[`sxi`,`application/vnd.sun.xml.impress`],[`sxm`,`application/vnd.sun.xml.math`],[`sxw`,`application/vnd.sun.xml.writer`],[`t`,`text/troff`],[`t3`,`application/x-t3vm-image`],[`t38`,`image/t38`],[`taglet`,`application/vnd.mynfc`],[`tao`,`application/vnd.tao.intent-module-archive`],[`tap`,`image/vnd.tencent.tap`],[`tar`,`application/x-tar`],[`tcap`,`application/vnd.3gpp2.tcap`],[`tcl`,`application/x-tcl`],[`td`,`application/urc-targetdesc+xml`],[`teacher`,`application/vnd.smart.teacher`],[`tei`,`application/tei+xml`],[`teicorpus`,`application/tei+xml`],[`tex`,`application/x-tex`],[`texi`,`application/x-texinfo`],[`texinfo`,`application/x-texinfo`],[`text`,`text/plain`],[`tfi`,`application/thraud+xml`],[`tfm`,`application/x-tex-tfm`],[`tfx`,`image/tiff-fx`],[`tga`,`image/x-tga`],[`tgz`,`application/x-tar`],[`thmx`,`application/vnd.ms-officetheme`],[`tif`,`image/tiff`],[`tiff`,`image/tiff`],[`tk`,`application/x-tcl`],[`tmo`,`application/vnd.tmobile-livetv`],[`toml`,`application/toml`],[`torrent`,`application/x-bittorrent`],[`tpl`,`application/vnd.groove-tool-template`],[`tpt`,`application/vnd.trid.tpt`],[`tr`,`text/troff`],[`tra`,`application/vnd.trueapp`],[`trig`,`application/trig`],[`trm`,`application/x-msterminal`],[`ts`,`video/mp2t`],[`tsd`,`application/timestamped-data`],[`tsv`,`text/tab-separated-values`],[`ttc`,`font/collection`],[`ttf`,`font/ttf`],[`ttl`,`text/turtle`],[`ttml`,`application/ttml+xml`],[`twd`,`application/vnd.simtech-mindmapper`],[`twds`,`application/vnd.simtech-mindmapper`],[`txd`,`application/vnd.genomatix.tuxedo`],[`txf`,`application/vnd.mobius.txf`],[`txt`,`text/plain`],[`u8dsn`,`message/global-delivery-status`],[`u8hdr`,`message/global-headers`],[`u8mdn`,`message/global-disposition-notification`],[`u8msg`,`message/global`],[`u32`,`application/x-authorware-bin`],[`ubj`,`application/ubjson`],[`udeb`,`application/x-debian-package`],[`ufd`,`application/vnd.ufdl`],[`ufdl`,`application/vnd.ufdl`],[`ulx`,`application/x-glulx`],[`umj`,`application/vnd.umajin`],[`unityweb`,`application/vnd.unity`],[`uoml`,`application/vnd.uoml+xml`],[`uri`,`text/uri-list`],[`uris`,`text/uri-list`],[`urls`,`text/uri-list`],[`usdz`,`model/vnd.usdz+zip`],[`ustar`,`application/x-ustar`],[`utz`,`application/vnd.uiq.theme`],[`uu`,`text/x-uuencode`],[`uva`,`audio/vnd.dece.audio`],[`uvd`,`application/vnd.dece.data`],[`uvf`,`application/vnd.dece.data`],[`uvg`,`image/vnd.dece.graphic`],[`uvh`,`video/vnd.dece.hd`],[`uvi`,`image/vnd.dece.graphic`],[`uvm`,`video/vnd.dece.mobile`],[`uvp`,`video/vnd.dece.pd`],[`uvs`,`video/vnd.dece.sd`],[`uvt`,`application/vnd.dece.ttml+xml`],[`uvu`,`video/vnd.uvvu.mp4`],[`uvv`,`video/vnd.dece.video`],[`uvva`,`audio/vnd.dece.audio`],[`uvvd`,`application/vnd.dece.data`],[`uvvf`,`application/vnd.dece.data`],[`uvvg`,`image/vnd.dece.graphic`],[`uvvh`,`video/vnd.dece.hd`],[`uvvi`,`image/vnd.dece.graphic`],[`uvvm`,`video/vnd.dece.mobile`],[`uvvp`,`video/vnd.dece.pd`],[`uvvs`,`video/vnd.dece.sd`],[`uvvt`,`application/vnd.dece.ttml+xml`],[`uvvu`,`video/vnd.uvvu.mp4`],[`uvvv`,`video/vnd.dece.video`],[`uvvx`,`application/vnd.dece.unspecified`],[`uvvz`,`application/vnd.dece.zip`],[`uvx`,`application/vnd.dece.unspecified`],[`uvz`,`application/vnd.dece.zip`],[`vbox`,`application/x-virtualbox-vbox`],[`vbox-extpack`,`application/x-virtualbox-vbox-extpack`],[`vcard`,`text/vcard`],[`vcd`,`application/x-cdlink`],[`vcf`,`text/x-vcard`],[`vcg`,`application/vnd.groove-vcard`],[`vcs`,`text/x-vcalendar`],[`vcx`,`application/vnd.vcx`],[`vdi`,`application/x-virtualbox-vdi`],[`vds`,`model/vnd.sap.vds`],[`vhd`,`application/x-virtualbox-vhd`],[`vis`,`application/vnd.visionary`],[`viv`,`video/vnd.vivo`],[`vlc`,`application/videolan`],[`vmdk`,`application/x-virtualbox-vmdk`],[`vob`,`video/x-ms-vob`],[`vor`,`application/vnd.stardivision.writer`],[`vox`,`application/x-authorware-bin`],[`vrml`,`model/vrml`],[`vsd`,`application/vnd.visio`],[`vsf`,`application/vnd.vsf`],[`vss`,`application/vnd.visio`],[`vst`,`application/vnd.visio`],[`vsw`,`application/vnd.visio`],[`vtf`,`image/vnd.valve.source.texture`],[`vtt`,`text/vtt`],[`vtu`,`model/vnd.vtu`],[`vxml`,`application/voicexml+xml`],[`w3d`,`application/x-director`],[`wad`,`application/x-doom`],[`wadl`,`application/vnd.sun.wadl+xml`],[`war`,`application/java-archive`],[`wasm`,`application/wasm`],[`wav`,`audio/x-wav`],[`wax`,`audio/x-ms-wax`],[`wbmp`,`image/vnd.wap.wbmp`],[`wbs`,`application/vnd.criticaltools.wbs+xml`],[`wbxml`,`application/wbxml`],[`wcm`,`application/vnd.ms-works`],[`wdb`,`application/vnd.ms-works`],[`wdp`,`image/vnd.ms-photo`],[`weba`,`audio/webm`],[`webapp`,`application/x-web-app-manifest+json`],[`webm`,`video/webm`],[`webmanifest`,`application/manifest+json`],[`webp`,`image/webp`],[`wg`,`application/vnd.pmi.widget`],[`wgt`,`application/widget`],[`wks`,`application/vnd.ms-works`],[`wm`,`video/x-ms-wm`],[`wma`,`audio/x-ms-wma`],[`wmd`,`application/x-ms-wmd`],[`wmf`,`image/wmf`],[`wml`,`text/vnd.wap.wml`],[`wmlc`,`application/wmlc`],[`wmls`,`text/vnd.wap.wmlscript`],[`wmlsc`,`application/vnd.wap.wmlscriptc`],[`wmv`,`video/x-ms-wmv`],[`wmx`,`video/x-ms-wmx`],[`wmz`,`application/x-msmetafile`],[`woff`,`font/woff`],[`woff2`,`font/woff2`],[`word`,`application/msword`],[`wpd`,`application/vnd.wordperfect`],[`wpl`,`application/vnd.ms-wpl`],[`wps`,`application/vnd.ms-works`],[`wqd`,`application/vnd.wqd`],[`wri`,`application/x-mswrite`],[`wrl`,`model/vrml`],[`wsc`,`message/vnd.wfa.wsc`],[`wsdl`,`application/wsdl+xml`],[`wspolicy`,`application/wspolicy+xml`],[`wtb`,`application/vnd.webturbo`],[`wvx`,`video/x-ms-wvx`],[`x3d`,`model/x3d+xml`],[`x3db`,`model/x3d+fastinfoset`],[`x3dbz`,`model/x3d+binary`],[`x3dv`,`model/x3d-vrml`],[`x3dvz`,`model/x3d+vrml`],[`x3dz`,`model/x3d+xml`],[`x32`,`application/x-authorware-bin`],[`x_b`,`model/vnd.parasolid.transmit.binary`],[`x_t`,`model/vnd.parasolid.transmit.text`],[`xaml`,`application/xaml+xml`],[`xap`,`application/x-silverlight-app`],[`xar`,`application/vnd.xara`],[`xav`,`application/xcap-att+xml`],[`xbap`,`application/x-ms-xbap`],[`xbd`,`application/vnd.fujixerox.docuworks.binder`],[`xbm`,`image/x-xbitmap`],[`xca`,`application/xcap-caps+xml`],[`xcs`,`application/calendar+xml`],[`xdf`,`application/xcap-diff+xml`],[`xdm`,`application/vnd.syncml.dm+xml`],[`xdp`,`application/vnd.adobe.xdp+xml`],[`xdssc`,`application/dssc+xml`],[`xdw`,`application/vnd.fujixerox.docuworks`],[`xel`,`application/xcap-el+xml`],[`xenc`,`application/xenc+xml`],[`xer`,`application/patch-ops-error+xml`],[`xfdf`,`application/vnd.adobe.xfdf`],[`xfdl`,`application/vnd.xfdl`],[`xht`,`application/xhtml+xml`],[`xhtml`,`application/xhtml+xml`],[`xhvml`,`application/xv+xml`],[`xif`,`image/vnd.xiff`],[`xl`,`application/excel`],[`xla`,`application/vnd.ms-excel`],[`xlam`,`application/vnd.ms-excel.addin.macroEnabled.12`],[`xlc`,`application/vnd.ms-excel`],[`xlf`,`application/xliff+xml`],[`xlm`,`application/vnd.ms-excel`],[`xls`,`application/vnd.ms-excel`],[`xlsb`,`application/vnd.ms-excel.sheet.binary.macroEnabled.12`],[`xlsm`,`application/vnd.ms-excel.sheet.macroEnabled.12`],[`xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`xlt`,`application/vnd.ms-excel`],[`xltm`,`application/vnd.ms-excel.template.macroEnabled.12`],[`xltx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.template`],[`xlw`,`application/vnd.ms-excel`],[`xm`,`audio/xm`],[`xml`,`application/xml`],[`xns`,`application/xcap-ns+xml`],[`xo`,`application/vnd.olpc-sugar`],[`xop`,`application/xop+xml`],[`xpi`,`application/x-xpinstall`],[`xpl`,`application/xproc+xml`],[`xpm`,`image/x-xpixmap`],[`xpr`,`application/vnd.is-xpr`],[`xps`,`application/vnd.ms-xpsdocument`],[`xpw`,`application/vnd.intercon.formnet`],[`xpx`,`application/vnd.intercon.formnet`],[`xsd`,`application/xml`],[`xsl`,`application/xml`],[`xslt`,`application/xslt+xml`],[`xsm`,`application/vnd.syncml+xml`],[`xspf`,`application/xspf+xml`],[`xul`,`application/vnd.mozilla.xul+xml`],[`xvm`,`application/xv+xml`],[`xvml`,`application/xv+xml`],[`xwd`,`image/x-xwindowdump`],[`xyz`,`chemical/x-xyz`],[`xz`,`application/x-xz`],[`yaml`,`text/yaml`],[`yang`,`application/yang`],[`yin`,`application/yin+xml`],[`yml`,`text/yaml`],[`ymp`,`text/x-suse-ymp`],[`z`,`application/x-compress`],[`z1`,`application/x-zmachine`],[`z2`,`application/x-zmachine`],[`z3`,`application/x-zmachine`],[`z4`,`application/x-zmachine`],[`z5`,`application/x-zmachine`],[`z6`,`application/x-zmachine`],[`z7`,`application/x-zmachine`],[`z8`,`application/x-zmachine`],[`zaz`,`application/vnd.zzazz.deck+xml`],[`zip`,`application/zip`],[`zir`,`application/vnd.zul`],[`zirz`,`application/vnd.zul`],[`zmm`,`application/vnd.handheld-entertainment+xml`],[`zsh`,`text/x-scriptzsh`]]);function eJ(e,t,n){let r=tJ(e),{webkitRelativePath:i}=e,a=typeof t==`string`?t:typeof i==`string`&&i.length>0?i:`./${e.name}`;return typeof r.path!=`string`&&nJ(r,`path`,a),n!==void 0&&Object.defineProperty(r,"handle",{value:n,writable:!1,configurable:!1,enumerable:!0}),nJ(r,`relativePath`,a),r}function tJ(e){let{name:t}=e;if(t&&t.lastIndexOf(`.`)!==-1&&!e.type){let n=t.split(`.`).pop().toLowerCase(),r=$q.get(n);r&&Object.defineProperty(e,"type",{value:r,writable:!1,configurable:!1,enumerable:!0})}return e}function nJ(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}var rJ=[`.DS_Store`,`Thumbs.db`];function iJ(e){return d(this,void 0,void 0,function*(){return sJ(e)&&aJ(e.dataTransfer)?uJ(e.dataTransfer,e.type):oJ(e)?cJ(e):Array.isArray(e)&&e.every(e=>`getFile`in e&&typeof e.getFile==`function`)?lJ(e):[]})}function aJ(e){return sJ(e)}function oJ(e){return sJ(e)&&sJ(e.target)}function sJ(e){return typeof e==`object`&&!!e}function cJ(e){return fJ(e.target.files).map(e=>eJ(e))}function lJ(e){return d(this,void 0,void 0,function*(){return(yield Promise.all(e.map(e=>e.getFile()))).map(e=>eJ(e))})}function uJ(e,t){return d(this,void 0,void 0,function*(){if(e.items){let n=fJ(e.items).filter(e=>e.kind===`file`);return t===`drop`?dJ(mJ(yield Promise.all(n.map(pJ)))):n}return dJ(fJ(e.files).map(e=>eJ(e)))})}function dJ(e){return e.filter(e=>rJ.indexOf(e.name)===-1)}function fJ(e){if(e===null)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n];t.push(r)}return t}function pJ(e){if(typeof e.webkitGetAsEntry!=`function`)return hJ(e);let t=e.webkitGetAsEntry();return t&&t.isDirectory?_J(t):hJ(e,t)}function mJ(e){return e.reduce((e,t)=>[...e,...Array.isArray(t)?mJ(t):[t]],[])}function hJ(e,t){return d(this,void 0,void 0,function*(){if(globalThis.isSecureContext&&typeof e.getAsFileSystemHandle==`function`){let t=yield e.getAsFileSystemHandle();if(t===null)throw Error(`${e} is not a File`);if(t!==void 0){let e=yield t.getFile();return e.handle=t,eJ(e)}}let n=e.getAsFile();if(!n)throw Error(`${e} is not a File`);return eJ(n,t?.fullPath??void 0)})}function gJ(e){return d(this,void 0,void 0,function*(){return e.isDirectory?_J(e):vJ(e)})}function _J(e){let t=e.createReader();return new Promise((e,n)=>{let r=[];function i(){t.readEntries(t=>d(this,void 0,void 0,function*(){if(t.length){let e=Promise.all(t.map(gJ));r.push(e),i()}else try{e(yield Promise.all(r))}catch(e){n(e)}}),e=>{n(e)})}i()})}function vJ(e){return d(this,void 0,void 0,function*(){return new Promise((t,n)=>{e.file(n=>{t(eJ(n,e.fullPath))},e=>{n(e)})})})}var yJ=c(o((e=>{e.__esModule=!0,e.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(`,`);if(n.length===0)return!0;var r=e.name||``,i=(e.type||``).toLowerCase(),a=i.replace(/\/.*$/,``);return n.some(function(e){var t=e.trim().toLowerCase();return t.charAt(0)===`.`?r.toLowerCase().endsWith(t):t.endsWith(`/*`)?a===t.replace(/\/.*$/,``):i===t})}return!0}}))());function bJ(e){return CJ(e)||SJ(e)||kJ(e)||xJ()}function xJ(){throw TypeError(`Invalid attempt to spread non-iterable instance.
223
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function SJ(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function CJ(e){if(Array.isArray(e))return AJ(e)}function wJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function TJ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?wJ(Object(n),!0).forEach(function(t){EJ(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wJ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function EJ(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function DJ(e,t){return MJ(e)||jJ(e,t)||kJ(e,t)||OJ()}function OJ(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
224
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kJ(e,t){if(e){if(typeof e==`string`)return AJ(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return AJ(e,t)}}function AJ(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function jJ(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function MJ(e){if(Array.isArray(e))return e}var NJ=typeof yJ.default==`function`?yJ.default:yJ.default.default,PJ=`file-invalid-type`,FJ=`file-too-large`,IJ=`file-too-small`,LJ=`too-many-files`,RJ=function(){var e=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:``).split(`,`);return{code:PJ,message:`File type must be ${e.length>1?`one of ${e.join(`, `)}`:e[0]}`}},zJ=function(e){return{code:FJ,message:`File is larger than ${e} ${e===1?`byte`:`bytes`}`}},BJ=function(e){return{code:IJ,message:`File is smaller than ${e} ${e===1?`byte`:`bytes`}`}},VJ={code:LJ,message:`Too many files`};function HJ(e){return e.type===``&&typeof e.getAsFile==`function`}function UJ(e,t){var n=e.type===`application/x-moz-file`||NJ(e,t)||HJ(e);return[n,n?null:RJ(t)]}function WJ(e,t,n){if(GJ(e.size)){if(GJ(t)&&GJ(n)){if(e.size>n)return[!1,zJ(n)];if(e.size<t)return[!1,BJ(t)]}else if(GJ(t)&&e.size<t)return[!1,BJ(t)];else if(GJ(n)&&e.size>n)return[!1,zJ(n)]}return[!0,null]}function GJ(e){return e!=null}function KJ(e){var t=e.files,n=e.accept,r=e.minSize,i=e.maxSize,a=e.multiple,o=e.maxFiles,s=e.validator;return!a&&t.length>1||a&&o>=1&&t.length>o?!1:t.every(function(e){var t=DJ(UJ(e,n),1)[0],a=DJ(WJ(e,r,i),1)[0],o=s?s(e):null;return t&&a&&!o})}function qJ(e){return typeof e.isPropagationStopped==`function`?e.isPropagationStopped():e.cancelBubble===void 0?!1:e.cancelBubble}function JJ(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(e){return e===`Files`||e===`application/x-moz-file`}):!!e.target&&!!e.target.files}function YJ(e){e.preventDefault()}function XJ(e){return e.indexOf(`MSIE`)!==-1||e.indexOf(`Trident/`)!==-1}function ZJ(e){return e.indexOf(`Edge/`)!==-1}function QJ(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return XJ(e)||ZJ(e)}function $J(){var e=[...arguments];return function(t){var n=[...arguments].slice(1);return e.some(function(e){return!qJ(t)&&e&&e.apply(void 0,[t].concat(n)),qJ(t)})}}function eY(){return`showOpenFilePicker`in window}function tY(e){return GJ(e)?[{description:`Files`,accept:Object.entries(e).filter(function(e){var t=DJ(e,2),n=t[0],r=t[1],i=!0;return aY(n)||(console.warn(`Skipped "${n}" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.`),i=!1),(!Array.isArray(r)||!r.every(oY))&&(console.warn(`Skipped "${n}" because an invalid file extension was provided.`),i=!1),i}).reduce(function(e,t){var n=DJ(t,2),r=n[0],i=n[1];return TJ(TJ({},e),{},EJ({},r,i))},{})}]:e}function nY(e){if(GJ(e))return Object.entries(e).reduce(function(e,t){var n=DJ(t,2),r=n[0],i=n[1];return[].concat(bJ(e),[r],bJ(i))},[]).filter(function(e){return aY(e)||oY(e)}).join(`,`)}function rY(e){return e instanceof DOMException&&(e.name===`AbortError`||e.code===e.ABORT_ERR)}function iY(e){return e instanceof DOMException&&(e.name===`SecurityError`||e.code===e.SECURITY_ERR)}function aY(e){return e===`audio/*`||e===`video/*`||e===`image/*`||e===`text/*`||e===`application/*`||/\w+\/[-+.\w]+/g.test(e)}function oY(e){return/^.*\.[\w]+$/.test(e)}var sY=c(Wb()),cY=[`children`],lY=[`open`],uY=[`refKey`,`role`,`onKeyDown`,`onFocus`,`onBlur`,`onClick`,`onDragEnter`,`onDragOver`,`onDragLeave`,`onDrop`],dY=[`refKey`,`onChange`,`onClick`];function fY(e){return hY(e)||mY(e)||vY(e)||pY()}function pY(){throw TypeError(`Invalid attempt to spread non-iterable instance.
225
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mY(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function hY(e){if(Array.isArray(e))return yY(e)}function gY(e,t){return xY(e)||bY(e,t)||vY(e,t)||_Y()}function _Y(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
226
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vY(e,t){if(e){if(typeof e==`string`)return yY(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return yY(e,t)}}function yY(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function bY(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function xY(e){if(Array.isArray(e))return e}function SY(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function CY(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?SY(Object(n),!0).forEach(function(t){wY(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):SY(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wY(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function TY(e,t){if(e==null)return{};var n=EY(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function EY(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}var DY=(0,b.forwardRef)(function(e,t){var n=e.children,r=AY(TY(e,cY)),i=r.open,a=TY(r,lY);return(0,b.useImperativeHandle)(t,function(){return{open:i}},[i]),b.createElement(b.Fragment,null,n(CY(CY({},a),{},{open:i})))});DY.displayName=`Dropzone`;var OY={disabled:!1,getFilesFromEvent:iJ,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};DY.defaultProps=OY,DY.propTypes={children:sY.default.func,accept:sY.default.objectOf(sY.default.arrayOf(sY.default.string)),multiple:sY.default.bool,preventDropOnDocument:sY.default.bool,noClick:sY.default.bool,noKeyboard:sY.default.bool,noDrag:sY.default.bool,noDragEventsBubbling:sY.default.bool,minSize:sY.default.number,maxSize:sY.default.number,maxFiles:sY.default.number,disabled:sY.default.bool,getFilesFromEvent:sY.default.func,onFileDialogCancel:sY.default.func,onFileDialogOpen:sY.default.func,useFsAccessApi:sY.default.bool,autoFocus:sY.default.bool,onDragEnter:sY.default.func,onDragLeave:sY.default.func,onDragOver:sY.default.func,onDrop:sY.default.func,onDropAccepted:sY.default.func,onDropRejected:sY.default.func,onError:sY.default.func,validator:sY.default.func};var kY={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragGlobal:!1,acceptedFiles:[],fileRejections:[]};function AY(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=CY(CY({},OY),e),n=t.accept,r=t.disabled,i=t.getFilesFromEvent,a=t.maxSize,o=t.minSize,s=t.multiple,c=t.maxFiles,l=t.onDragEnter,u=t.onDragLeave,d=t.onDragOver,f=t.onDrop,p=t.onDropAccepted,m=t.onDropRejected,h=t.onFileDialogCancel,g=t.onFileDialogOpen,_=t.useFsAccessApi,v=t.autoFocus,y=t.preventDropOnDocument,x=t.noClick,S=t.noKeyboard,C=t.noDrag,w=t.noDragEventsBubbling,T=t.onError,E=t.validator,D=(0,b.useMemo)(function(){return nY(n)},[n]),O=(0,b.useMemo)(function(){return tY(n)},[n]),k=(0,b.useMemo)(function(){return typeof g==`function`?g:MY},[g]),A=(0,b.useMemo)(function(){return typeof h==`function`?h:MY},[h]),j=(0,b.useRef)(null),M=(0,b.useRef)(null),ee=gY((0,b.useReducer)(jY,kY),2),N=ee[0],P=ee[1],te=N.isFocused,ne=N.isFileDialogActive,re=(0,b.useRef)(typeof window<`u`&&window.isSecureContext&&_&&eY()),ie=function(){!re.current&&ne&&setTimeout(function(){M.current&&(M.current.files.length||(P({type:`closeDialog`}),A()))},300)};(0,b.useEffect)(function(){return window.addEventListener(`focus`,ie,!1),function(){window.removeEventListener(`focus`,ie,!1)}},[M,ne,A,re]);var ae=(0,b.useRef)([]),oe=(0,b.useRef)([]),se=function(e){j.current&&j.current.contains(e.target)||(e.preventDefault(),ae.current=[])};(0,b.useEffect)(function(){return y&&(document.addEventListener(`dragover`,YJ,!1),document.addEventListener(`drop`,se,!1)),function(){y&&(document.removeEventListener(`dragover`,YJ),document.removeEventListener(`drop`,se))}},[j,y]),(0,b.useEffect)(function(){var e=function(e){oe.current=[].concat(fY(oe.current),[e.target]),JJ(e)&&P({isDragGlobal:!0,type:`setDragGlobal`})},t=function(e){oe.current=oe.current.filter(function(t){return t!==e.target&&t!==null}),!(oe.current.length>0)&&P({isDragGlobal:!1,type:`setDragGlobal`})},n=function(){oe.current=[],P({isDragGlobal:!1,type:`setDragGlobal`})},r=function(){oe.current=[],P({isDragGlobal:!1,type:`setDragGlobal`})};return document.addEventListener(`dragenter`,e,!1),document.addEventListener(`dragleave`,t,!1),document.addEventListener(`dragend`,n,!1),document.addEventListener(`drop`,r,!1),function(){document.removeEventListener(`dragenter`,e),document.removeEventListener(`dragleave`,t),document.removeEventListener(`dragend`,n),document.removeEventListener(`drop`,r)}},[j]),(0,b.useEffect)(function(){return!r&&v&&j.current&&j.current.focus(),function(){}},[j,v,r]);var ce=(0,b.useCallback)(function(e){T?T(e):console.error(e)},[T]),le=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),Se(e),ae.current=[].concat(fY(ae.current),[e.target]),JJ(e)&&Promise.resolve(i(e)).then(function(t){if(!(qJ(e)&&!w)){var n=t.length,r=n>0&&KJ({files:t,accept:D,minSize:o,maxSize:a,multiple:s,maxFiles:c,validator:E});P({isDragAccept:r,isDragReject:n>0&&!r,isDragActive:!0,type:`setDraggedFiles`}),l&&l(e)}}).catch(function(e){return ce(e)})},[i,l,ce,w,D,o,a,s,c,E]),ue=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),Se(e);var t=JJ(e);if(t&&e.dataTransfer)try{e.dataTransfer.dropEffect=`copy`}catch{}return t&&d&&d(e),!1},[d,w]),de=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),Se(e);var t=ae.current.filter(function(e){return j.current&&j.current.contains(e)}),n=t.indexOf(e.target);n!==-1&&t.splice(n,1),ae.current=t,!(t.length>0)&&(P({type:`setDraggedFiles`,isDragActive:!1,isDragAccept:!1,isDragReject:!1}),JJ(e)&&u&&u(e))},[j,u,w]),fe=(0,b.useCallback)(function(e,t){var n=[],r=[];e.forEach(function(e){var t=gY(UJ(e,D),2),i=t[0],s=t[1],c=gY(WJ(e,o,a),2),l=c[0],u=c[1],d=E?E(e):null;if(i&&l&&!d)n.push(e);else{var f=[s,u];d&&(f=f.concat(d)),r.push({file:e,errors:f.filter(function(e){return e})})}}),(!s&&n.length>1||s&&c>=1&&n.length>c)&&(n.forEach(function(e){r.push({file:e,errors:[VJ]})}),n.splice(0)),P({acceptedFiles:n,fileRejections:r,type:`setFiles`}),f&&f(n,r,t),r.length>0&&m&&m(r,t),n.length>0&&p&&p(n,t)},[P,s,D,o,a,c,f,p,m,E]),pe=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),Se(e),ae.current=[],JJ(e)&&Promise.resolve(i(e)).then(function(t){qJ(e)&&!w||fe(t,e)}).catch(function(e){return ce(e)}),P({type:`reset`})},[i,fe,ce,w]),me=(0,b.useCallback)(function(){if(re.current){P({type:`openDialog`}),k();var e={multiple:s,types:O};window.showOpenFilePicker(e).then(function(e){return i(e)}).then(function(e){fe(e,null),P({type:`closeDialog`})}).catch(function(e){rY(e)?(A(e),P({type:`closeDialog`})):iY(e)?(re.current=!1,M.current?(M.current.value=null,M.current.click()):ce(Error(`Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided.`))):ce(e)});return}M.current&&(P({type:`openDialog`}),k(),M.current.value=null,M.current.click())},[P,k,A,_,fe,ce,O,s]),he=(0,b.useCallback)(function(e){!j.current||!j.current.isEqualNode(e.target)||(e.key===` `||e.key===`Enter`||e.keyCode===32||e.keyCode===13)&&(e.preventDefault(),me())},[j,me]),ge=(0,b.useCallback)(function(){P({type:`focus`})},[]),_e=(0,b.useCallback)(function(){P({type:`blur`})},[]),ve=(0,b.useCallback)(function(){x||(QJ()?setTimeout(me,0):me())},[x,me]),ye=function(e){return r?null:e},be=function(e){return S?null:ye(e)},xe=function(e){return C?null:ye(e)},Se=function(e){w&&e.stopPropagation()},Ce=(0,b.useMemo)(function(){return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.refKey,n=t===void 0?`ref`:t,i=e.role,a=e.onKeyDown,o=e.onFocus,s=e.onBlur,c=e.onClick,l=e.onDragEnter,u=e.onDragOver,d=e.onDragLeave,f=e.onDrop,p=TY(e,uY);return CY(CY(wY({onKeyDown:be($J(a,he)),onFocus:be($J(o,ge)),onBlur:be($J(s,_e)),onClick:ye($J(c,ve)),onDragEnter:xe($J(l,le)),onDragOver:xe($J(u,ue)),onDragLeave:xe($J(d,de)),onDrop:xe($J(f,pe)),role:typeof i==`string`&&i!==``?i:`presentation`},n,j),!r&&!S?{tabIndex:0}:{}),p)}},[j,he,ge,_e,ve,le,ue,de,pe,S,C,r]),we=(0,b.useCallback)(function(e){e.stopPropagation()},[]),Te=(0,b.useMemo)(function(){return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.refKey,n=t===void 0?`ref`:t,r=e.onChange,i=e.onClick,a=TY(e,dY);return CY(CY({},wY({accept:D,multiple:s,type:`file`,style:{border:0,clip:`rect(0, 0, 0, 0)`,clipPath:`inset(50%)`,height:`1px`,margin:`0 -1px -1px 0`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`},onChange:ye($J(r,pe)),onClick:ye($J(i,we)),tabIndex:-1},n,M)),a)}},[M,n,s,pe,r]);return CY(CY({},N),{},{isFocused:te&&!r,getRootProps:Ce,getInputProps:Te,rootRef:j,inputRef:M,open:ye(me)})}function jY(e,t){switch(t.type){case`focus`:return CY(CY({},e),{},{isFocused:!0});case`blur`:return CY(CY({},e),{},{isFocused:!1});case`openDialog`:return CY(CY({},kY),{},{isFileDialogActive:!0});case`closeDialog`:return CY(CY({},e),{},{isFileDialogActive:!1});case`setDraggedFiles`:return CY(CY({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case`setFiles`:return CY(CY({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:!1});case`setDragGlobal`:return CY(CY({},e),{},{isDragGlobal:t.isDragGlobal});case`reset`:return CY({},kY);default:return e}}function MY(){}var[NY,PY]=et(`Dropzone component was not found in tree`),FY={root:`m_d46a4834`,inner:`m_b85f7144`,fullScreen:`m_96f6e9ad`,dropzone:`m_7946116d`};function IY(e){let t=t=>{let{children:n,...r}=R(`Dropzone${Et(e)}`,{},t),i=PY(),a=Qe(n)?n:(0,I.jsx)(`span`,{children:n});return i[e]?(0,b.cloneElement)(a,r):null};return t.displayName=`@mantine/dropzone/${Et(e)}`,t}var LY=IY(`accept`),RY=IY(`reject`),zY=IY(`idle`),BY={multiple:!0,maxSize:1/0,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,useFsAccessApi:!0,variant:`light`,rejectColor:`red`},VY=An((e,{radius:t,variant:n,acceptColor:r,rejectColor:i})=>{let a=e.variantColorResolver({color:r||e.primaryColor,theme:e,variant:n}),o=e.variantColorResolver({color:i||`red`,theme:e,variant:n});return{root:{"--dropzone-radius":mt(t),"--dropzone-accept-color":a.color,"--dropzone-accept-bg":a.background,"--dropzone-reject-color":o.color,"--dropzone-reject-bg":o.background}}}),HY=B((e,t)=>{let n=R(`Dropzone`,BY,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,radius:l,disabled:u,loading:d,multiple:f,maxSize:p,accept:m,children:h,onDropAny:g,onDrop:_,onReject:v,openRef:y,name:b,maxFiles:x,autoFocus:S,activateOnClick:C,activateOnDrag:w,dragEventsBubbling:T,activateOnKeyboard:E,onDragEnter:D,onDragLeave:O,onDragOver:k,onFileDialogCancel:A,onFileDialogOpen:j,preventDropOnDocument:M,useFsAccessApi:ee,getFilesFromEvent:N,validator:P,rejectColor:te,acceptColor:ne,enablePointerEvents:re,loaderProps:ie,inputProps:ae,mod:oe,attributes:se,...ce}=n,le=L({name:`Dropzone`,classes:FY,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:se,vars:c,varsResolver:VY}),{getRootProps:ue,getInputProps:de,isDragAccept:fe,isDragReject:pe,isDragActive:me,open:he}=AY({onDrop:g,onDropAccepted:_,onDropRejected:v,disabled:u||d,accept:Array.isArray(m)?m.reduce((e,t)=>({...e,[t]:[]}),{}):m,multiple:f,maxSize:p,maxFiles:x,autoFocus:S,noClick:!C,noDrag:!w,noDragEventsBubbling:!T,noKeyboard:!E,onDragEnter:D,onDragLeave:O,onDragOver:k,onFileDialogCancel:A,onFileDialogOpen:j,preventDropOnDocument:M,useFsAccessApi:ee,validator:P,...N?{getFilesFromEvent:N}:null});tn(y,he);let ge=me&&fe,_e=me&&pe,ve=!ge&&!_e;return(0,I.jsx)(NY,{value:{accept:ge,reject:_e,idle:ve},children:(0,I.jsxs)(z,{...ue(),...le(`root`,{focusable:!0}),...ce,mod:[{accept:ge,reject:_e,idle:ve,disabled:u,loading:d,"activate-on-click":C},oe],children:[(0,I.jsx)(Ch,{visible:d,overlayProps:{radius:l},unstyled:s,loaderProps:ie}),(0,I.jsx)(`input`,{...de(ae),name:b}),(0,I.jsx)(`div`,{...le(`inner`),ref:t,"data-enable-pointer-events":re||void 0,children:h})]})})});HY.classes=FY,HY.displayName=`@mantine/dropzone/Dropzone`,HY.Accept=LY,HY.Idle=zY,HY.Reject=RY;var UY={maxSize:1/0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,active:!0,zIndex:lt(`max`),withinPortal:!0},WY=B((e,t)=>{let n=R(`DropzoneFullScreen`,UY,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,active:l,onDrop:u,onReject:d,zIndex:f,withinPortal:p,portalProps:m,attributes:h,...g}=n,_=L({name:`DropzoneFullScreen`,classes:FY,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:h,rootSelector:`fullScreen`}),{resolvedClassNames:v,resolvedStyles:y}=Ur({classNames:r,styles:o,props:n}),[x,S]=(0,b.useState)(0),[C,{open:w,close:T}]=bn(!1),E=e=>{e.dataTransfer?.types.includes(`Files`)&&(S(e=>e+1),w())},D=()=>{S(e=>e-1)};return(0,b.useEffect)(()=>{x===0&&T()},[x]),(0,b.useEffect)(()=>{if(l)return document.addEventListener(`dragenter`,E,!1),document.addEventListener(`dragleave`,D,!1),()=>{document.removeEventListener(`dragenter`,E,!1),document.removeEventListener(`dragleave`,D,!1)}},[l]),(0,I.jsx)(Pl,{...m,withinPortal:p,children:(0,I.jsx)(z,{ref:t,..._(`fullScreen`,{style:{opacity:+!!C,pointerEvents:C?`all`:`none`,zIndex:f}}),children:(0,I.jsx)(HY,{activateOnClick:!1,...g,classNames:v,styles:y,unstyled:s,className:FY.dropzone,onDrop:e=>{u?.(e),T(),S(0)},onReject:e=>{d?.(e),T(),S(0)}})})})});WY.classes=FY,WY.displayName=`@mantine/dropzone/DropzoneFullScreen`,HY.FullScreen=WY;var GY=HY,KY=`{"resourceType": "Bundle"}`;function qY({id:e,title:t,message:n,color:r,icon:i,withCloseButton:a=!1,method:o=`show`,loading:s}){zb[o]({id:e,loading:s,title:t,message:n,color:r,icon:i,withCloseButton:a,autoClose:!1})}function JY(){let e=Sr(),t=Z(),[n,r]=(0,b.useState)({}),i=(0,b.useCallback)(async(e,n)=>{let i=`batch-upload`;qY({id:i,title:`Batch Upload in Progress`,message:`Your batch data is being uploaded. This may take a moment...`,method:`show`,loading:!0});try{r({});let a=JSON.parse(e);a.type!==`batch`&&a.type!==`transaction`&&(a=WE(a));let o=await t.executeBatch(a);r(e=>({...e,[n]:o})),qY({id:i,title:`Batch Upload Successful`,message:`Your batch data was successfully uploaded.`,color:`green`,method:`update`,icon:(0,I.jsx)(wA,{size:`1rem`}),withCloseButton:!0})}catch(e){qY({id:i,title:`Batch Upload Failed`,color:`red`,message:Qx(e),method:`update`,icon:(0,I.jsx)(Nj,{size:`1rem`}),withCloseButton:!0})}},[t]),a=(0,b.useCallback)(async e=>{for(let t of e){let e=new FileReader;e.onload=e=>i(e.target?.result,t.name),e.readAsText(t)}},[i]),o=(0,b.useCallback)(async e=>{await i(e.input,`JSON Data`)},[i]);return(0,I.jsxs)(vP,{children:[(0,I.jsx)(q,{children:`Batch Create`}),(0,I.jsxs)(H,{children:[`Use this page to create, read, or update multiple resources. For more details, see`,` `,(0,I.jsx)(Pd,{href:`https://www.hl7.org/fhir/http.html#transaction`,children:`FHIR Batch and Transaction`}),`.`]}),Object.keys(n).length===0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`h3`,{children:`Input`}),(0,I.jsxs)(vb,{defaultValue:`upload`,children:[(0,I.jsxs)(vb.List,{children:[(0,I.jsx)(vb.Tab,{value:`upload`,children:`File Upload`}),(0,I.jsx)(vb.Tab,{value:`json`,children:`JSON`})]}),(0,I.jsx)(vb.Panel,{value:`upload`,pt:`xs`,children:(0,I.jsx)(GY,{onDrop:a,accept:[`application/json`],children:(0,I.jsxs)(V,{justify:`center`,gap:`xl`,style:{minHeight:220,pointerEvents:`none`},children:[(0,I.jsx)(GY.Accept,{children:(0,I.jsx)(Aj,{size:50,stroke:1.5,color:e.colors[e.primaryColor][5]})}),(0,I.jsx)(GY.Reject,{children:(0,I.jsx)(Nj,{size:50,stroke:1.5,color:e.colors.red[5]})}),(0,I.jsx)(GY.Idle,{children:(0,I.jsx)(Aj,{size:50,stroke:1.5})}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{size:`xl`,inline:!0,children:`Drag files here or click to select files`}),(0,I.jsx)(H,{size:`sm`,color:`dimmed`,inline:!0,mt:7,children:`Attach as many files as you like`})]})]})})}),(0,I.jsx)(vb.Panel,{value:`json`,pt:`xs`,children:(0,I.jsxs)(CN,{onSubmit:o,children:[(0,I.jsx)(lh,{"data-testid":`batch-input`,name:`input`,autosize:!0,minRows:20,defaultValue:KY,deserialize:JSON.parse}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,children:(0,I.jsx)(U,{type:`submit`,children:`Submit`})})]})})]})]}),Object.keys(n).length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`h3`,{children:`Output`}),(0,I.jsxs)(vb,{defaultValue:Object.keys(n)[0],children:[(0,I.jsx)(vb.List,{children:Object.keys(n).map(e=>(0,I.jsx)(vb.Tab,{value:e,children:e},e))}),Object.keys(n).map(e=>(0,I.jsx)(vb.Panel,{value:e,children:(0,I.jsx)(`pre`,{style:{border:`1px solid #888`},children:JSON.stringify(n[e],void 0,2)})},e))]}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,children:(0,I.jsx)(U,{onClick:()=>r({}),children:`Start over`})})]})]})}function YY(){let{resourceType:e}=SW(),t=(Object.fromEntries(new URLSearchParams(location.search).entries()).ids||``).split(`,`).filter(e=>!!e),[n]=Yk(`Questionnaire`,`subject-type=${e}`);return n?n.length===0?(0,I.jsxs)(vP,{children:[(0,I.jsxs)(q,{children:[`No apps for `,e]}),(0,I.jsx)(Wj,{to:`/${e}`,children:`Return to search page`})]}):(0,I.jsx)(vP,{children:(0,I.jsx)(`div`,{children:n.map(n=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{children:(0,I.jsx)(Wj,{to:`/forms/${n.id}?subject=`+t.map(t=>`${e}/${t}`).join(`,`),children:n.name})}),(0,I.jsx)(`p`,{children:n.description})]},n.id))})}):(0,I.jsx)(Ij,{})}function XY(){return(0,I.jsx)(wP,{})}var ZY=[`Form`,`JSON`,`Profiles`];function QY(){let{resourceType:e}=SW();return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(yl,{children:[(0,I.jsxs)(H,{p:`md`,fw:500,children:[`New\xA0`,e]}),(0,I.jsx)(ul,{children:(0,I.jsx)(yz,{baseUrl:`/${e}/new`,tabs:ZY})})]}),(0,I.jsx)(iG,{})]})}function $Y(){return(0,I.jsx)(vP,{children:(0,I.jsxs)(G,{children:[(0,I.jsx)(q,{order:1,children:`Unexpected Error`}),(0,I.jsx)(H,{children:`We're sorry, something went wrong.`}),(0,I.jsxs)(H,{children:[`Please contact `,(0,I.jsx)(Pd,{href:`mailto:support@medplum.com`,children:`support`}),` for assistance.`]})]})})}function eX(e){let t=nk(e.resource);if(!t)return null;let n=[{key:`Type`,value:(0,I.jsx)(Wj,{to:`/${t.resourceType}`,children:t.resourceType})}];function r(e,t){e&&t&&n.push({key:e,value:t})}function i(e){e&&r(e.system,e.value)}function a(e,t){Array.isArray(t)?t.forEach(t=>a(e,t)):typeof t==`string`?r(e,t):t&&(Array.isArray(t.coding)?r(e,t.coding.map(e=>e.display||e.code).join(`, `)):r(e,t.text))}if(`name`in t){let e=uC(t);e!==oC(t)&&r(`Name`,e)}return`category`in t&&a(`Category`,t.category),t.resourceType!==`Bot`&&`code`in t&&a(`Code`,t.code),`identifier`in t&&(Array.isArray(t.identifier)?t.identifier.forEach(i):i(t.identifier)),n.length===1&&n.push({key:`ID`,value:t.id}),(0,I.jsx)(_z,{children:n.map((e,t)=>(0,I.jsxs)(_z.Entry,{children:[(0,I.jsx)(_z.Key,{children:e.key}),(0,I.jsx)(_z.Value,{children:e.value})]},`${e.key}-${t}`))})}function tX(){let{id:e}=SW(),t=hW(),n=Object.fromEntries(new URLSearchParams(t.search).entries()).subject,r=Z(),[i,a]=(0,b.useState)(!0),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)(),[f,p]=(0,b.useState)(),[m,h]=(0,b.useState)();if((0,b.useEffect)(()=>{let t={resourceType:`Bundle`,type:`batch`,entry:[{request:{method:`GET`,url:`Questionnaire/${e}`}}]};if(n){let e=n.split(`,`).filter(e=>!!e);e.length===1&&t.entry.push({request:{method:`GET`,url:e[0]}}),l(e)}r.executeBatch(t).then(e=>{e.entry?.[0]?.response?.status===`200`?(s(e.entry[0]?.resource),d(e.entry[1]?.resource)):p(e.entry?.[0]?.response?.outcome),a(!1)}).catch(e=>{p(e),a(!1)})},[r,e,n]),f)return(0,I.jsx)(vP,{children:(0,I.jsx)(`pre`,{"data-testid":`error`,children:JSON.stringify(f,void 0,2)})});if(m)return(0,I.jsxs)(vP,{children:[(0,I.jsx)(q,{children:o?.title}),(0,I.jsx)(`p`,{children:`Your response has been recorded.`}),(0,I.jsxs)(`ul`,{children:[m.length===1&&(0,I.jsx)(`li`,{children:(0,I.jsx)(Wj,{to:m[0],children:`Review your answers`})}),m.length>1&&(0,I.jsxs)(`li`,{children:[`Review your answers:`,(0,I.jsx)(`ul`,{children:m.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(Wj,{to:e,children:oC(e)})},e.id))})]}),u&&(0,I.jsx)(`li`,{children:(0,I.jsxs)(Wj,{to:u,children:[`Back to\xA0`,uC(u)]})}),(0,I.jsx)(`li`,{children:(0,I.jsx)(Wj,{to:`/`,children:`Go back home`})})]})]});if(i||!o)return(0,I.jsx)(Ij,{});let g=u&&EK(u);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(yl,{shadow:`xs`,radius:0,children:[g&&(0,I.jsx)(Bz,{patient:g}),u&&u.resourceType!==`Patient`&&(0,I.jsx)(eX,{resource:u}),(0,I.jsx)(z,{px:`xl`,py:`md`,children:(0,I.jsxs)(H,{children:[uC(o),c&&c.length>1&&(0,I.jsxs)(I.Fragment,{children:[`\xA0(for `,c.length,` resources)`]})]})})]}),(0,I.jsx)(vP,{children:(0,I.jsx)(oL,{questionnaire:o,subject:u&&aC(u),onSubmit:_})})]});async function _(e){let t=[];if(!c||c.length===0)t.push(await r.createResource(e));else for(let n of c)t.push(await r.createResource({...e,subject:{reference:n}}));h(t)}}var nX={paper:`_paper_unw9o_1`},rX={Bot:`/admin/bots/new`,ClientApplication:`/admin/clients/new`};function iX(e,t){let n=e.resourceType||aX(t),r=e.fields??oX(n),i=e.filters??(e.resourceType?void 0:sX(n)),a=e.sortRules??cX(n),o=e.offset??0,s=e.count??20;return{...e,resourceType:n,fields:r,filters:i,sortRules:a,offset:o,count:s}}function aX(e){return localStorage.getItem(`defaultResourceType`)??e?.option?.find(e=>e.id===`defaultResourceType`)?.valueString??`Patient`}function oX(e){let t=lX(e);if(t?.fields)return t.fields;let n=[`id`,`_lastUpdated`];switch(e){case`Patient`:n.push(`name`,`birthDate`,`gender`);break;case`AsyncJob`:n.push(`status`,`dataVersion`);break;case`AccessPolicy`:case`Bot`:case`ClientApplication`:case`Practitioner`:case`Project`:case`Organization`:case`Questionnaire`:case`UserConfiguration`:n.push(`name`);break;case`CodeSystem`:case`ValueSet`:n.push(`name`,`title`,`status`);break;case`Condition`:n.push(`subject`,`code`,`clinicalStatus`);break;case`Device`:n.push(`manufacturer`,`deviceName`,`patient`);break;case`DeviceDefinition`:n.push(`manufacturer[x]`,`deviceName`);break;case`DeviceRequest`:n.push(`code[x]`,`subject`);break;case`DiagnosticReport`:case`Observation`:n.push(`subject`,`code`,`status`);break;case`Encounter`:n.push(`subject`);break;case`ServiceRequest`:n.push(`subject`,`code`,`status`,`orderDetail`);break;case`Subscription`:n.push(`criteria`);break;case`User`:n.push(`email`);break}return n}function sX(e){return lX(e)?.filters}function cX(e){let t=lX(e);return t?.sortRules?t.sortRules:[{code:`_lastUpdated`,descending:!0}]}function lX(e){let t=localStorage.getItem(e+`-defaultSearch`);return t?JSON.parse(t):void 0}function uX(e){localStorage.setItem(`defaultResourceType`,e.resourceType),localStorage.setItem(e.resourceType+`-defaultSearch`,JSON.stringify(e))}async function dX(e,t){let n=iX({...e,count:1e3,offset:0},t.getUserConfiguration());return WE(await t.search(n.resourceType,cE({...n,total:`accurate`,fields:void 0})))}function fX(){let e=Z(),t=vW(),n=hW(),[r,i]=(0,b.useState)();return(0,b.useEffect)(()=>{let r=iX(ZT(n.pathname+n.search),e.getUserConfiguration());n.pathname===`/${r.resourceType}`&&n.search===cE(r)?(uX(r),i(r)):t(`/${r.resourceType}${cE(r)}`,{replace:!0})?.catch(console.error)},[e,t,n]),!r?.resourceType||!r.fields||r.fields.length===0?(0,I.jsx)(Ij,{}):(0,I.jsx)(yl,{shadow:`xs`,m:`md`,p:`xs`,className:nX.paper,children:(0,I.jsx)(sz,{checkboxesEnabled:!0,search:r,onClick:e=>t(`/${e.resource.resourceType}/${e.resource.id}`)?.catch(console.error),onAuxClick:e=>window.open(`/${e.resource.resourceType}/${e.resource.id}`,`_blank`),onChange:e=>{t(`/${r.resourceType}${cE(e.definition)}`)?.catch(console.error)},onNew:()=>{t(rX[r.resourceType]??`/${r.resourceType}/new`)?.catch(console.error)},onExportCsv:()=>{let t=e.fhirUrl(r.resourceType,`$csv`)+cE(r);e.download(t).then(e=>{window.open(window.URL.createObjectURL(e),`_blank`)}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},onExportTransactionBundle:async()=>{dX(r,e).then(e=>Uj(JSON.stringify(e,void 0,2))).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},onDelete:t=>{window.confirm(`Are you sure you want to delete these resources?`)&&(e.invalidateSearches(r.resourceType),e.executeBatch({resourceType:`Bundle`,type:`batch`,entry:t.map(e=>({request:{method:`DELETE`,url:`${r.resourceType}/${e}`}}))}).then(()=>i({...r})).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1})))},onBulk:e=>{t(`/bulk/${r.resourceType}?ids=${e.join(`,`)}`)?.catch(console.error)}})})}function pX(){let[e]=Yk(`ObservationDefinition`,`_count=100`);return e?(0,I.jsxs)(K,{withTableBorder:!0,withRowBorders:!0,withColumnBorders:!0,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:`Category`}),(0,I.jsx)(`th`,{children:`Code`}),(0,I.jsx)(`th`,{children:`Method`}),(0,I.jsx)(`th`,{children:`Unit`}),(0,I.jsx)(`th`,{children:`Precision`}),(0,I.jsx)(`th`,{children:`Ranges`})]})}),(0,I.jsx)(`tbody`,{children:e.map(e=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:(0,I.jsx)(tF,{value:e.category?.[0]})}),(0,I.jsx)(`td`,{children:(0,I.jsx)(tF,{value:e.code})}),(0,I.jsx)(`td`,{children:(0,I.jsx)(tF,{value:e.method})}),(0,I.jsx)(`td`,{children:e.quantitativeDetails?.unit?.text}),(0,I.jsx)(`td`,{children:e.quantitativeDetails?.decimalPrecision}),(0,I.jsx)(`td`,{children:(0,I.jsx)(mX,{ranges:e.qualifiedInterval})})]},e.id))})]}):(0,I.jsx)(Ij,{})}function mX(e){let{ranges:t}=e;if(!t)return null;let n=hX(t.map(e=>e.gender));if(n.length>1)return ZC(n),(0,I.jsx)(I.Fragment,{children:n.map(t=>(0,I.jsxs)(b.Fragment,{children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`strong`,{children:UC(t)})}),(0,I.jsx)(mX,{ranges:e.ranges?.filter(e=>e.gender===t)})]},t))});let r=hX(t.map(e=>e.age&&yw(e.age)));return r.length>1?(ZC(r),(0,I.jsx)(I.Fragment,{children:r.map(t=>(0,I.jsxs)(b.Fragment,{children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`strong`,{children:UC(t)})}),(0,I.jsx)(mX,{ranges:e.ranges?.filter(e=>yw(e.age)===t)})]},t))})):(0,I.jsx)(I.Fragment,{children:t.map(e=>(0,I.jsx)(`table`,{children:(0,I.jsx)(`tbody`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:e.condition}),(0,I.jsx)(`td`,{children:(0,I.jsx)(fF,{value:e.range})})]})})},`range-${e.condition}`))})}function hX(e){return[...new Set(e.filter(e=>!!e))]}function gX(){let[e]=Yk(`ActivityDefinition`,`_count=100`),[t]=Yk(`ObservationDefinition`,`_count=100`);return!e||!t?(0,I.jsx)(Ij,{}):(0,I.jsxs)(K,{withTableBorder:!0,withRowBorders:!0,withColumnBorders:!0,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:`Category`}),(0,I.jsx)(`th`,{children:`Assay`}),e.map(e=>(0,I.jsx)(`th`,{children:e.name},e.id))]})}),(0,I.jsx)(`tbody`,{children:t.map(t=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:(0,I.jsx)(tF,{value:t.category?.[0]})}),(0,I.jsx)(`td`,{children:(0,I.jsx)(tF,{value:t.code})}),e.map(e=>(0,I.jsx)(`td`,{children:e.observationResultRequirement?.find(e=>e.reference?.includes(t.id))?`✅`:``},e.id))]},t.id))})]})}function _X(){let e=Z(),[t,n]=(0,b.useState)(),[r,i]=(0,b.useState)(void 0),[a,o]=(0,b.useState)(!1),s=(0,b.useCallback)(()=>{e.get(`auth/mfa/status`,{cache:`no-cache`}).then(e=>{n(e.enrollQrCode),i(e.enrolled)}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},[e]);(0,b.useEffect)(()=>{s()},[s]);let c=(0,b.useCallback)(t=>{e.post(`auth/mfa/enroll`,t).then(()=>{i(!0),J({color:`green`,message:`Success`})}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},[e]),l=(0,b.useCallback)(async t=>e.post(`auth/mfa/disable`,{token:t.token}),[e]);return r===void 0?null:r?(0,I.jsxs)(vP,{children:[(0,I.jsx)(rg,{title:`Disable MFA`,opened:a,onClose:()=>o(!1),children:(0,I.jsx)(TP,{title:`Disable MFA`,buttonText:`Submit code`,onSubmit:async e=>{await l(e),o(!1),i(!1),J({id:`mfa-disabled`,color:`green`,title:`Success`,message:`MFA disabled`,icon:(0,I.jsx)(DA,{})}),s()}})}),(0,I.jsxs)(V,{children:[(0,I.jsx)(q,{children:`MFA is enabled`}),(0,I.jsx)(U,{onClick:()=>o(!0),children:`Disable MFA`})]})]}):(0,I.jsx)(vP,{width:400,children:(0,I.jsx)(TP,{title:`Multi Factor Auth Setup`,buttonText:`Enroll`,qrCodeUrl:t,onSubmit:c})})}var vX={baseUrl:`__MEDPLUM_BASE_URL__`,clientId:`__MEDPLUM_CLIENT_ID__`,googleClientId:`__GOOGLE_CLIENT_ID__`,recaptchaSiteKey:`__RECAPTCHA_SITE_KEY__`,registerEnabled:`__MEDPLUM_REGISTER_ENABLED__`,awsTextractEnabled:void 0};function yX(){return vX}function bX(){return SX(`registerEnabled`)}function xX(){return SX(`awsTextractEnabled`)}function SX(e){try{return vX[e]!==!1&&vX[e]!==`false`}catch{return!0}}function CX(){let e=vW(),[t]=cK(),n=Z(),r=t.get(`scope`)||`openid`,[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)(!0),c=t.get(`client_id`),l=t.get(`login`);if((0,b.useEffect)(()=>{if(!c||c===`medplum-cli`)return;async function e(){try{a(await n.get(`/auth/clientinfo/${c}`))}catch(e){J({id:`clientinfofail`,title:`Failed to retrieve client information.`,color:`red`,message:Qx(e),withCloseButton:!0})}finally{s(!1)}}e().catch(console.error)},[n,c]),!c)return null;function u(e){let n=new URL(t.get(`redirect_uri`));for(let e of[`scope`,`state`,`nonce`])t.has(e)&&n.searchParams.set(e,t.get(e));n.searchParams.set(`code`,e),LE.assign(n.toString())}return(0,I.jsx)(eF,{onCode:u,onForgotPassword:()=>e(`/resetpassword`)?.catch(console.error),onRegister:()=>e(`/register`)?.catch(console.error),googleClientId:yX().googleClientId,clientId:c||void 0,redirectUri:t.get(`redirect_uri`)||void 0,scope:r,nonce:t.get(`nonce`)||void 0,launch:t.get(`launch`)||void 0,codeChallenge:t.get(`code_challenge`)||void 0,codeChallengeMethod:t.get(`code_challenge_method`)||void 0,chooseScopes:r!==`openid`,login:l||void 0,children:!o&&(0,I.jsxs)(I.Fragment,{children:[i?.logo?.url?(0,I.jsx)(`img`,{src:i?.logo?.url,alt:`Welcome Logo`,height:60,style:{width:`auto`}}):(0,I.jsx)(yP,{size:32}),(0,I.jsx)(q,{children:i?.welcomeString??`Sign in to Medplum`})]})})}function wX(){let e=Z(),t=vW(),[n]=cK(),r=yX();return(0,b.useEffect)(()=>{e.getProfile()&&t(`/signin?project=new`)?.catch(console.error)},[e,t]),bX()?(0,I.jsxs)(PP,{type:`project`,projectId:`new`,onSuccess:()=>{window.location.href=`/`},googleClientId:r.googleClientId,recaptchaSiteKey:r.recaptchaSiteKey,login:n.get(`login`)||void 0,children:[(0,I.jsx)(yP,{size:32}),(0,I.jsx)(q,{order:3,py:`lg`,children:`Register a new account`})]}):(0,I.jsx)(vP,{width:450,children:(0,I.jsx)(Dd,{icon:(0,I.jsx)(uA,{size:16}),title:`New projects disabled`,color:`red`,children:`New projects are disabled on this server.`})})}function TX(){let e=vW(),[t]=cK(),n=yX();return(0,I.jsx)(FP,{projectId:t.get(`project`)||void 0,recaptchaSiteKey:n.recaptchaSiteKey,onSignIn:()=>e(`/signin`)?.catch(console.error),onRegister:bX()?()=>e(`/register`)?.catch(console.error):void 0})}function EX(){let{resourceType:e,id:t}=SW(),n=nk({reference:e+`/`+t}),r=vW(),i=(0,b.useCallback)(()=>{r(0)?.catch(console.error)},[r]);return n?(0,I.jsx)(vP,{maw:700,children:n.resourceType===`Patient`?(0,I.jsx)(Mz,{patient:n,onSaved:i}):(0,I.jsx)(Dd,{icon:(0,I.jsx)(uA,{size:16}),title:`Unsupported resource type`,color:`red`,children:`Account management is only supported for Patient resources`})}):null}function DX(e){let t=Z(),[n,r]=(0,b.useState)(),[i,a]=(0,b.useState)();return i?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{children:`Request group created successfully.`}),(0,I.jsxs)(`ul`,{children:[(0,I.jsxs)(`li`,{children:[`Go to the`,` `,(0,I.jsx)(Wj,{to:i,suffix:`checklist`,children:`Request Group`})]}),(0,I.jsxs)(`li`,{children:[`Back to the `,(0,I.jsx)(Wj,{to:e.planDefinition,children:`Plan Definition`})]})]})]}):(0,I.jsx)(CN,{onSubmit:()=>{t.post(t.fhirUrl(`PlanDefinition`,e.planDefinition.id,`$apply`),{resourceType:`Parameters`,parameter:[{name:`subject`,valueString:n?.reference}]}).then(a).catch(console.log)},children:(0,I.jsxs)(G,{children:[(0,I.jsxs)(q,{children:[`Start "`,e.planDefinition.title,`"`]}),(0,I.jsxs)(H,{children:[`Use the `,(0,I.jsx)(`strong`,{children:`Apply`}),` operation to create a group of tasks for a workflow.`]}),(0,I.jsx)(H,{children:`The following tasks will be created:`}),(0,I.jsx)(`ul`,{children:e.planDefinition.action?.map((e,t)=>(0,I.jsxs)(`li`,{children:[e.definitionCanonical?.startsWith(`Questionnaire/`)&&`Questionnaire request: `,e.title&&(0,I.jsx)(I.Fragment,{children:e.title}),e.code&&(0,I.jsx)(tF,{value:e.code[0]})]},`action-${t}`))}),(0,I.jsx)(AF,{title:`Subject`,children:(0,I.jsx)(cI,{name:`subject`,targetTypes:[`Patient`,`Practitioner`],defaultValue:n,onChange:r})}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,children:(0,I.jsx)(U,{type:`submit`,children:`Go`})})]})})}function OX(){let{resourceType:e,id:t}=SW(),n=nk({reference:e+`/`+t});return n?(0,I.jsx)(vP,{children:(0,I.jsx)(DX,{planDefinition:n})}):null}function kX(){let{resourceType:e,id:t}=SW(),n=nk({reference:e+`/`+t}),[r,i]=Yk(`Questionnaire`,`subject-type=`+e),[a,o]=Yk(`ClientApplication`,{_count:1e3});if(!n||i||o)return(0,I.jsx)(Ij,{});let s=a?.filter(t=>AX(e)&&!!t.launchUri);if((!r||r.length===0)&&(!s||s.length===0))return(0,I.jsxs)(vP,{children:[(0,I.jsx)(q,{children:`Apps`}),(0,I.jsxs)(`p`,{children:[`No apps found. Contact your administrator or `,(0,I.jsx)(`a`,{href:`mailto:support@medplum.com`,children:`Medplum Support`}),` to add automation here.`]})]});let c,l;return n.resourceType===`Patient`?c=aC(n):n.resourceType===`Encounter`&&(c=n.subject,l=aC(n)),(0,I.jsxs)(vP,{children:[r?.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(q,{order:3,children:(0,I.jsx)(Wj,{to:`/forms/${e.id}?subject=${oC(n)}`,children:e.title||e.name})}),(0,I.jsx)(H,{children:e.description})]},e.id)),s?.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(q,{order:3,children:(0,I.jsx)(xK,{client:e,patient:c,encounter:l,children:e.name})}),(0,I.jsx)(H,{children:e.description})]},e.id))]})}function AX(e){return e===`Patient`||e===`Encounter`}function jX(){let{resourceType:e,id:t}=SW(),n=vW(),[r,i]=(0,b.useState)({resourceType:`AuditEvent`,filters:[{code:`entity`,operator:X.EQUALS,value:`${e}/${t}`}],fields:[`id`,`outcome`,`outcomeDesc`,`_lastUpdated`],sortRules:[{code:`-_lastUpdated`}],count:20});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 MX(){let e=Z(),{resourceType:t,id:n}=SW();return(0,I.jsx)(am,{maw:1200,children:(0,I.jsx)(_P,{children:(0,I.jsx)(LB,{history:e.readHistory(t,n).read()})})})}var NX={hl7Input:`_hl7Input_k5xm3_1`};function PX(e){return(0,I.jsx)(`iframe`,{title:`Bot Runner`,frameBorder:`0`,src:`https://codeeditor.medplum.com/bot-runner.html`,className:e.className,ref:e.iframeRef,"data-testid":e.testId,style:{width:`100%`,height:`100%`,minHeight:e.minHeight}})}function FX(e){let t=e.defaultValue,n=new URL(`https://codeeditor.medplum.com/${e.language}-editor.html`);return e.module&&n.searchParams.set(`module`,e.module),(0,I.jsx)(`iframe`,{title:`Code Editor`,frameBorder:`0`,src:n.toString(),style:{width:`100%`,height:`100%`,minHeight:e.minHeight},ref:e.iframeRef,"data-testid":e.testId,onLoad:e=>{Hj(e.currentTarget,{command:`setValue`,value:t}).catch(console.error)}})}var IX=`{
222
+ `);t((0,I.jsxs)(G,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{fw:700,children:`Query`}),(0,I.jsx)(nm,{block:!0,maw:`100%`,style:{whiteSpace:`pre-wrap`},children:l})]}),(s||c)&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{fw:700,children:`Counts`}),s&&(0,I.jsxs)(H,{children:[`Estimate: `,s]}),c&&(0,I.jsxs)(H,{children:[`Accurate: `,c]})]})]})),n()}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1})})}return!r.isLoading()&&!r.isSuperAdmin()?(0,I.jsx)(BP,{outcome:Hx}):(0,I.jsx)(TN,{onSubmit:m,children:(0,I.jsxs)(G,{children:[(0,I.jsx)(yb,{name:`query`,label:`Search`,required:!0,placeholder:`Observation?code=85354-9&_sort=-date&_count=5`}),(0,I.jsxs)(V,{children:[(0,I.jsx)(lp,{name:`analyze`,label:`Analyze`}),(0,I.jsx)(lp,{name:`count`,label:`Total count`})]}),(0,I.jsx)(cd,{label:`On Behalf Of`,children:(0,I.jsxs)(G,{gap:`sm`,children:[(0,I.jsx)(uI,{required:!0,placeholder:`Project`,targetTypes:[`Project`],name:`onBehalfOfProject`,onChange:a}),(0,I.jsx)(uI,{required:!0,placeholder:`Practitioner or Patient`,name:`onBehalfOfProfile`,targetTypes:[`Practitioner`,`Patient`],onChange:s,searchCriteria:f}),c?.length!==1&&(0,I.jsx)(uI,{required:!0,placeholder:`ProjectMembership`,name:`onBehalfOfProjectMembership`,targetTypes:[`ProjectMembership`],onChange:d,searchCriteria:p}),c?.length===1&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{type:`hidden`,name:`onBehalfOfProjectMembership`,value:oC(c[0])}),(0,I.jsx)(gF,{value:aC(c[0])})]}),!u&&(0,I.jsx)(H,{fs:`italic`,children:`On Behalf Of not set. Running as super admin`})]})}),(0,I.jsx)(U,{type:`submit`,children:`Explain Search`})]})})}var eJ=[{label:`All`,value:`Patient,Practitioner,RelatedPerson`},{label:`Practitioner`,value:`Practitioner`},{label:`Patient`,value:`Patient`},{label:`RelatedPerson`,value:`RelatedPerson`}];function tJ(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(q,{children:`ProjectMemberships by User and Profile Type`}),(0,I.jsx)(jK,{profileTypeOptions:eJ,fields:[`user`,`profile`,`profile-type`,`accessPolicy`,`userConfiguration`,`active`,`admin`],toolbarLeft:(0,I.jsx)(U,{component:Kj,to:`/admin/invite`,variant:`outline`,color:`blue`,leftSection:(0,I.jsx)(Nj,{size:14}),children:`Invite New User`}),toolbarRight:(0,I.jsx)(Pd,{href:`https://www.medplum.com/docs/user-management`,target:`_blank`,rel:`noopener noreferrer`,size:`sm`,children:`Learn more about roles and user management`})})]})}var nJ=new Map([[`1km`,`application/vnd.1000minds.decision-model+xml`],[`3dml`,`text/vnd.in3d.3dml`],[`3ds`,`image/x-3ds`],[`3g2`,`video/3gpp2`],[`3gp`,`video/3gp`],[`3gpp`,`video/3gpp`],[`3mf`,`model/3mf`],[`7z`,`application/x-7z-compressed`],[`7zip`,`application/x-7z-compressed`],[`123`,`application/vnd.lotus-1-2-3`],[`aab`,`application/x-authorware-bin`],[`aac`,`audio/x-acc`],[`aam`,`application/x-authorware-map`],[`aas`,`application/x-authorware-seg`],[`abw`,`application/x-abiword`],[`ac`,`application/vnd.nokia.n-gage.ac+xml`],[`ac3`,`audio/ac3`],[`acc`,`application/vnd.americandynamics.acc`],[`ace`,`application/x-ace-compressed`],[`acu`,`application/vnd.acucobol`],[`acutc`,`application/vnd.acucorp`],[`adp`,`audio/adpcm`],[`aep`,`application/vnd.audiograph`],[`afm`,`application/x-font-type1`],[`afp`,`application/vnd.ibm.modcap`],[`ahead`,`application/vnd.ahead.space`],[`ai`,`application/pdf`],[`aif`,`audio/x-aiff`],[`aifc`,`audio/x-aiff`],[`aiff`,`audio/x-aiff`],[`air`,`application/vnd.adobe.air-application-installer-package+zip`],[`ait`,`application/vnd.dvb.ait`],[`ami`,`application/vnd.amiga.ami`],[`amr`,`audio/amr`],[`apk`,`application/vnd.android.package-archive`],[`apng`,`image/apng`],[`appcache`,`text/cache-manifest`],[`application`,`application/x-ms-application`],[`apr`,`application/vnd.lotus-approach`],[`arc`,`application/x-freearc`],[`arj`,`application/x-arj`],[`asc`,`application/pgp-signature`],[`asf`,`video/x-ms-asf`],[`asm`,`text/x-asm`],[`aso`,`application/vnd.accpac.simply.aso`],[`asx`,`video/x-ms-asf`],[`atc`,`application/vnd.acucorp`],[`atom`,`application/atom+xml`],[`atomcat`,`application/atomcat+xml`],[`atomdeleted`,`application/atomdeleted+xml`],[`atomsvc`,`application/atomsvc+xml`],[`atx`,`application/vnd.antix.game-component`],[`au`,`audio/x-au`],[`avi`,`video/x-msvideo`],[`avif`,`image/avif`],[`aw`,`application/applixware`],[`azf`,`application/vnd.airzip.filesecure.azf`],[`azs`,`application/vnd.airzip.filesecure.azs`],[`azv`,`image/vnd.airzip.accelerator.azv`],[`azw`,`application/vnd.amazon.ebook`],[`b16`,`image/vnd.pco.b16`],[`bat`,`application/x-msdownload`],[`bcpio`,`application/x-bcpio`],[`bdf`,`application/x-font-bdf`],[`bdm`,`application/vnd.syncml.dm+wbxml`],[`bdoc`,`application/x-bdoc`],[`bed`,`application/vnd.realvnc.bed`],[`bh2`,`application/vnd.fujitsu.oasysprs`],[`bin`,`application/octet-stream`],[`blb`,`application/x-blorb`],[`blorb`,`application/x-blorb`],[`bmi`,`application/vnd.bmi`],[`bmml`,`application/vnd.balsamiq.bmml+xml`],[`bmp`,`image/bmp`],[`book`,`application/vnd.framemaker`],[`box`,`application/vnd.previewsystems.box`],[`boz`,`application/x-bzip2`],[`bpk`,`application/octet-stream`],[`bpmn`,`application/octet-stream`],[`bsp`,`model/vnd.valve.source.compiled-map`],[`btif`,`image/prs.btif`],[`buffer`,`application/octet-stream`],[`bz`,`application/x-bzip`],[`bz2`,`application/x-bzip2`],[`c`,`text/x-c`],[`c4d`,`application/vnd.clonk.c4group`],[`c4f`,`application/vnd.clonk.c4group`],[`c4g`,`application/vnd.clonk.c4group`],[`c4p`,`application/vnd.clonk.c4group`],[`c4u`,`application/vnd.clonk.c4group`],[`c11amc`,`application/vnd.cluetrust.cartomobile-config`],[`c11amz`,`application/vnd.cluetrust.cartomobile-config-pkg`],[`cab`,`application/vnd.ms-cab-compressed`],[`caf`,`audio/x-caf`],[`cap`,`application/vnd.tcpdump.pcap`],[`car`,`application/vnd.curl.car`],[`cat`,`application/vnd.ms-pki.seccat`],[`cb7`,`application/x-cbr`],[`cba`,`application/x-cbr`],[`cbr`,`application/x-cbr`],[`cbt`,`application/x-cbr`],[`cbz`,`application/x-cbr`],[`cc`,`text/x-c`],[`cco`,`application/x-cocoa`],[`cct`,`application/x-director`],[`ccxml`,`application/ccxml+xml`],[`cdbcmsg`,`application/vnd.contact.cmsg`],[`cda`,`application/x-cdf`],[`cdf`,`application/x-netcdf`],[`cdfx`,`application/cdfx+xml`],[`cdkey`,`application/vnd.mediastation.cdkey`],[`cdmia`,`application/cdmi-capability`],[`cdmic`,`application/cdmi-container`],[`cdmid`,`application/cdmi-domain`],[`cdmio`,`application/cdmi-object`],[`cdmiq`,`application/cdmi-queue`],[`cdr`,`application/cdr`],[`cdx`,`chemical/x-cdx`],[`cdxml`,`application/vnd.chemdraw+xml`],[`cdy`,`application/vnd.cinderella`],[`cer`,`application/pkix-cert`],[`cfs`,`application/x-cfs-compressed`],[`cgm`,`image/cgm`],[`chat`,`application/x-chat`],[`chm`,`application/vnd.ms-htmlhelp`],[`chrt`,`application/vnd.kde.kchart`],[`cif`,`chemical/x-cif`],[`cii`,`application/vnd.anser-web-certificate-issue-initiation`],[`cil`,`application/vnd.ms-artgalry`],[`cjs`,`application/node`],[`cla`,`application/vnd.claymore`],[`class`,`application/octet-stream`],[`clkk`,`application/vnd.crick.clicker.keyboard`],[`clkp`,`application/vnd.crick.clicker.palette`],[`clkt`,`application/vnd.crick.clicker.template`],[`clkw`,`application/vnd.crick.clicker.wordbank`],[`clkx`,`application/vnd.crick.clicker`],[`clp`,`application/x-msclip`],[`cmc`,`application/vnd.cosmocaller`],[`cmdf`,`chemical/x-cmdf`],[`cml`,`chemical/x-cml`],[`cmp`,`application/vnd.yellowriver-custom-menu`],[`cmx`,`image/x-cmx`],[`cod`,`application/vnd.rim.cod`],[`coffee`,`text/coffeescript`],[`com`,`application/x-msdownload`],[`conf`,`text/plain`],[`cpio`,`application/x-cpio`],[`cpp`,`text/x-c`],[`cpt`,`application/mac-compactpro`],[`crd`,`application/x-mscardfile`],[`crl`,`application/pkix-crl`],[`crt`,`application/x-x509-ca-cert`],[`crx`,`application/x-chrome-extension`],[`cryptonote`,`application/vnd.rig.cryptonote`],[`csh`,`application/x-csh`],[`csl`,`application/vnd.citationstyles.style+xml`],[`csml`,`chemical/x-csml`],[`csp`,`application/vnd.commonspace`],[`csr`,`application/octet-stream`],[`css`,`text/css`],[`cst`,`application/x-director`],[`csv`,`text/csv`],[`cu`,`application/cu-seeme`],[`curl`,`text/vnd.curl`],[`cww`,`application/prs.cww`],[`cxt`,`application/x-director`],[`cxx`,`text/x-c`],[`dae`,`model/vnd.collada+xml`],[`daf`,`application/vnd.mobius.daf`],[`dart`,`application/vnd.dart`],[`dataless`,`application/vnd.fdsn.seed`],[`davmount`,`application/davmount+xml`],[`dbf`,`application/vnd.dbf`],[`dbk`,`application/docbook+xml`],[`dcr`,`application/x-director`],[`dcurl`,`text/vnd.curl.dcurl`],[`dd2`,`application/vnd.oma.dd2+xml`],[`ddd`,`application/vnd.fujixerox.ddd`],[`ddf`,`application/vnd.syncml.dmddf+xml`],[`dds`,`image/vnd.ms-dds`],[`deb`,`application/x-debian-package`],[`def`,`text/plain`],[`deploy`,`application/octet-stream`],[`der`,`application/x-x509-ca-cert`],[`dfac`,`application/vnd.dreamfactory`],[`dgc`,`application/x-dgc-compressed`],[`dic`,`text/x-c`],[`dir`,`application/x-director`],[`dis`,`application/vnd.mobius.dis`],[`disposition-notification`,`message/disposition-notification`],[`dist`,`application/octet-stream`],[`distz`,`application/octet-stream`],[`djv`,`image/vnd.djvu`],[`djvu`,`image/vnd.djvu`],[`dll`,`application/octet-stream`],[`dmg`,`application/x-apple-diskimage`],[`dmn`,`application/octet-stream`],[`dmp`,`application/vnd.tcpdump.pcap`],[`dms`,`application/octet-stream`],[`dna`,`application/vnd.dna`],[`doc`,`application/msword`],[`docm`,`application/vnd.ms-word.template.macroEnabled.12`],[`docx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`],[`dot`,`application/msword`],[`dotm`,`application/vnd.ms-word.template.macroEnabled.12`],[`dotx`,`application/vnd.openxmlformats-officedocument.wordprocessingml.template`],[`dp`,`application/vnd.osgi.dp`],[`dpg`,`application/vnd.dpgraph`],[`dra`,`audio/vnd.dra`],[`drle`,`image/dicom-rle`],[`dsc`,`text/prs.lines.tag`],[`dssc`,`application/dssc+der`],[`dtb`,`application/x-dtbook+xml`],[`dtd`,`application/xml-dtd`],[`dts`,`audio/vnd.dts`],[`dtshd`,`audio/vnd.dts.hd`],[`dump`,`application/octet-stream`],[`dvb`,`video/vnd.dvb.file`],[`dvi`,`application/x-dvi`],[`dwd`,`application/atsc-dwd+xml`],[`dwf`,`model/vnd.dwf`],[`dwg`,`image/vnd.dwg`],[`dxf`,`image/vnd.dxf`],[`dxp`,`application/vnd.spotfire.dxp`],[`dxr`,`application/x-director`],[`ear`,`application/java-archive`],[`ecelp4800`,`audio/vnd.nuera.ecelp4800`],[`ecelp7470`,`audio/vnd.nuera.ecelp7470`],[`ecelp9600`,`audio/vnd.nuera.ecelp9600`],[`ecma`,`application/ecmascript`],[`edm`,`application/vnd.novadigm.edm`],[`edx`,`application/vnd.novadigm.edx`],[`efif`,`application/vnd.picsel`],[`ei6`,`application/vnd.pg.osasli`],[`elc`,`application/octet-stream`],[`emf`,`image/emf`],[`eml`,`message/rfc822`],[`emma`,`application/emma+xml`],[`emotionml`,`application/emotionml+xml`],[`emz`,`application/x-msmetafile`],[`eol`,`audio/vnd.digital-winds`],[`eot`,`application/vnd.ms-fontobject`],[`eps`,`application/postscript`],[`epub`,`application/epub+zip`],[`es`,`application/ecmascript`],[`es3`,`application/vnd.eszigno3+xml`],[`esa`,`application/vnd.osgi.subsystem`],[`esf`,`application/vnd.epson.esf`],[`et3`,`application/vnd.eszigno3+xml`],[`etx`,`text/x-setext`],[`eva`,`application/x-eva`],[`evy`,`application/x-envoy`],[`exe`,`application/octet-stream`],[`exi`,`application/exi`],[`exp`,`application/express`],[`exr`,`image/aces`],[`ext`,`application/vnd.novadigm.ext`],[`ez`,`application/andrew-inset`],[`ez2`,`application/vnd.ezpix-album`],[`ez3`,`application/vnd.ezpix-package`],[`f`,`text/x-fortran`],[`f4v`,`video/mp4`],[`f77`,`text/x-fortran`],[`f90`,`text/x-fortran`],[`fbs`,`image/vnd.fastbidsheet`],[`fcdt`,`application/vnd.adobe.formscentral.fcdt`],[`fcs`,`application/vnd.isac.fcs`],[`fdf`,`application/vnd.fdf`],[`fdt`,`application/fdt+xml`],[`fe_launch`,`application/vnd.denovo.fcselayout-link`],[`fg5`,`application/vnd.fujitsu.oasysgp`],[`fgd`,`application/x-director`],[`fh`,`image/x-freehand`],[`fh4`,`image/x-freehand`],[`fh5`,`image/x-freehand`],[`fh7`,`image/x-freehand`],[`fhc`,`image/x-freehand`],[`fig`,`application/x-xfig`],[`fits`,`image/fits`],[`flac`,`audio/x-flac`],[`fli`,`video/x-fli`],[`flo`,`application/vnd.micrografx.flo`],[`flv`,`video/x-flv`],[`flw`,`application/vnd.kde.kivio`],[`flx`,`text/vnd.fmi.flexstor`],[`fly`,`text/vnd.fly`],[`fm`,`application/vnd.framemaker`],[`fnc`,`application/vnd.frogans.fnc`],[`fo`,`application/vnd.software602.filler.form+xml`],[`for`,`text/x-fortran`],[`fpx`,`image/vnd.fpx`],[`frame`,`application/vnd.framemaker`],[`fsc`,`application/vnd.fsc.weblaunch`],[`fst`,`image/vnd.fst`],[`ftc`,`application/vnd.fluxtime.clip`],[`fti`,`application/vnd.anser-web-funds-transfer-initiation`],[`fvt`,`video/vnd.fvt`],[`fxp`,`application/vnd.adobe.fxp`],[`fxpl`,`application/vnd.adobe.fxp`],[`fzs`,`application/vnd.fuzzysheet`],[`g2w`,`application/vnd.geoplan`],[`g3`,`image/g3fax`],[`g3w`,`application/vnd.geospace`],[`gac`,`application/vnd.groove-account`],[`gam`,`application/x-tads`],[`gbr`,`application/rpki-ghostbusters`],[`gca`,`application/x-gca-compressed`],[`gdl`,`model/vnd.gdl`],[`gdoc`,`application/vnd.google-apps.document`],[`geo`,`application/vnd.dynageo`],[`geojson`,`application/geo+json`],[`gex`,`application/vnd.geometry-explorer`],[`ggb`,`application/vnd.geogebra.file`],[`ggt`,`application/vnd.geogebra.tool`],[`ghf`,`application/vnd.groove-help`],[`gif`,`image/gif`],[`gim`,`application/vnd.groove-identity-message`],[`glb`,`model/gltf-binary`],[`gltf`,`model/gltf+json`],[`gml`,`application/gml+xml`],[`gmx`,`application/vnd.gmx`],[`gnumeric`,`application/x-gnumeric`],[`gpg`,`application/gpg-keys`],[`gph`,`application/vnd.flographit`],[`gpx`,`application/gpx+xml`],[`gqf`,`application/vnd.grafeq`],[`gqs`,`application/vnd.grafeq`],[`gram`,`application/srgs`],[`gramps`,`application/x-gramps-xml`],[`gre`,`application/vnd.geometry-explorer`],[`grv`,`application/vnd.groove-injector`],[`grxml`,`application/srgs+xml`],[`gsf`,`application/x-font-ghostscript`],[`gsheet`,`application/vnd.google-apps.spreadsheet`],[`gslides`,`application/vnd.google-apps.presentation`],[`gtar`,`application/x-gtar`],[`gtm`,`application/vnd.groove-tool-message`],[`gtw`,`model/vnd.gtw`],[`gv`,`text/vnd.graphviz`],[`gxf`,`application/gxf`],[`gxt`,`application/vnd.geonext`],[`gz`,`application/gzip`],[`gzip`,`application/gzip`],[`h`,`text/x-c`],[`h261`,`video/h261`],[`h263`,`video/h263`],[`h264`,`video/h264`],[`hal`,`application/vnd.hal+xml`],[`hbci`,`application/vnd.hbci`],[`hbs`,`text/x-handlebars-template`],[`hdd`,`application/x-virtualbox-hdd`],[`hdf`,`application/x-hdf`],[`heic`,`image/heic`],[`heics`,`image/heic-sequence`],[`heif`,`image/heif`],[`heifs`,`image/heif-sequence`],[`hej2`,`image/hej2k`],[`held`,`application/atsc-held+xml`],[`hh`,`text/x-c`],[`hjson`,`application/hjson`],[`hlp`,`application/winhlp`],[`hpgl`,`application/vnd.hp-hpgl`],[`hpid`,`application/vnd.hp-hpid`],[`hps`,`application/vnd.hp-hps`],[`hqx`,`application/mac-binhex40`],[`hsj2`,`image/hsj2`],[`htc`,`text/x-component`],[`htke`,`application/vnd.kenameaapp`],[`htm`,`text/html`],[`html`,`text/html`],[`hvd`,`application/vnd.yamaha.hv-dic`],[`hvp`,`application/vnd.yamaha.hv-voice`],[`hvs`,`application/vnd.yamaha.hv-script`],[`i2g`,`application/vnd.intergeo`],[`icc`,`application/vnd.iccprofile`],[`ice`,`x-conference/x-cooltalk`],[`icm`,`application/vnd.iccprofile`],[`ico`,`image/x-icon`],[`ics`,`text/calendar`],[`ief`,`image/ief`],[`ifb`,`text/calendar`],[`ifm`,`application/vnd.shana.informed.formdata`],[`iges`,`model/iges`],[`igl`,`application/vnd.igloader`],[`igm`,`application/vnd.insors.igm`],[`igs`,`model/iges`],[`igx`,`application/vnd.micrografx.igx`],[`iif`,`application/vnd.shana.informed.interchange`],[`img`,`application/octet-stream`],[`imp`,`application/vnd.accpac.simply.imp`],[`ims`,`application/vnd.ms-ims`],[`in`,`text/plain`],[`ini`,`text/plain`],[`ink`,`application/inkml+xml`],[`inkml`,`application/inkml+xml`],[`install`,`application/x-install-instructions`],[`iota`,`application/vnd.astraea-software.iota`],[`ipfix`,`application/ipfix`],[`ipk`,`application/vnd.shana.informed.package`],[`irm`,`application/vnd.ibm.rights-management`],[`irp`,`application/vnd.irepository.package+xml`],[`iso`,`application/x-iso9660-image`],[`itp`,`application/vnd.shana.informed.formtemplate`],[`its`,`application/its+xml`],[`ivp`,`application/vnd.immervision-ivp`],[`ivu`,`application/vnd.immervision-ivu`],[`jad`,`text/vnd.sun.j2me.app-descriptor`],[`jade`,`text/jade`],[`jam`,`application/vnd.jam`],[`jar`,`application/java-archive`],[`jardiff`,`application/x-java-archive-diff`],[`java`,`text/x-java-source`],[`jhc`,`image/jphc`],[`jisp`,`application/vnd.jisp`],[`jls`,`image/jls`],[`jlt`,`application/vnd.hp-jlyt`],[`jng`,`image/x-jng`],[`jnlp`,`application/x-java-jnlp-file`],[`joda`,`application/vnd.joost.joda-archive`],[`jp2`,`image/jp2`],[`jpe`,`image/jpeg`],[`jpeg`,`image/jpeg`],[`jpf`,`image/jpx`],[`jpg`,`image/jpeg`],[`jpg2`,`image/jp2`],[`jpgm`,`video/jpm`],[`jpgv`,`video/jpeg`],[`jph`,`image/jph`],[`jpm`,`video/jpm`],[`jpx`,`image/jpx`],[`js`,`application/javascript`],[`json`,`application/json`],[`json5`,`application/json5`],[`jsonld`,`application/ld+json`],[`jsonl`,`application/jsonl`],[`jsonml`,`application/jsonml+json`],[`jsx`,`text/jsx`],[`jxr`,`image/jxr`],[`jxra`,`image/jxra`],[`jxrs`,`image/jxrs`],[`jxs`,`image/jxs`],[`jxsc`,`image/jxsc`],[`jxsi`,`image/jxsi`],[`jxss`,`image/jxss`],[`kar`,`audio/midi`],[`karbon`,`application/vnd.kde.karbon`],[`kdb`,`application/octet-stream`],[`kdbx`,`application/x-keepass2`],[`key`,`application/x-iwork-keynote-sffkey`],[`kfo`,`application/vnd.kde.kformula`],[`kia`,`application/vnd.kidspiration`],[`kml`,`application/vnd.google-earth.kml+xml`],[`kmz`,`application/vnd.google-earth.kmz`],[`kne`,`application/vnd.kinar`],[`knp`,`application/vnd.kinar`],[`kon`,`application/vnd.kde.kontour`],[`kpr`,`application/vnd.kde.kpresenter`],[`kpt`,`application/vnd.kde.kpresenter`],[`kpxx`,`application/vnd.ds-keypoint`],[`ksp`,`application/vnd.kde.kspread`],[`ktr`,`application/vnd.kahootz`],[`ktx`,`image/ktx`],[`ktx2`,`image/ktx2`],[`ktz`,`application/vnd.kahootz`],[`kwd`,`application/vnd.kde.kword`],[`kwt`,`application/vnd.kde.kword`],[`lasxml`,`application/vnd.las.las+xml`],[`latex`,`application/x-latex`],[`lbd`,`application/vnd.llamagraphics.life-balance.desktop`],[`lbe`,`application/vnd.llamagraphics.life-balance.exchange+xml`],[`les`,`application/vnd.hhe.lesson-player`],[`less`,`text/less`],[`lgr`,`application/lgr+xml`],[`lha`,`application/octet-stream`],[`link66`,`application/vnd.route66.link66+xml`],[`list`,`text/plain`],[`list3820`,`application/vnd.ibm.modcap`],[`listafp`,`application/vnd.ibm.modcap`],[`litcoffee`,`text/coffeescript`],[`lnk`,`application/x-ms-shortcut`],[`log`,`text/plain`],[`lostxml`,`application/lost+xml`],[`lrf`,`application/octet-stream`],[`lrm`,`application/vnd.ms-lrm`],[`ltf`,`application/vnd.frogans.ltf`],[`lua`,`text/x-lua`],[`luac`,`application/x-lua-bytecode`],[`lvp`,`audio/vnd.lucent.voice`],[`lwp`,`application/vnd.lotus-wordpro`],[`lzh`,`application/octet-stream`],[`m1v`,`video/mpeg`],[`m2a`,`audio/mpeg`],[`m2v`,`video/mpeg`],[`m3a`,`audio/mpeg`],[`m3u`,`text/plain`],[`m3u8`,`application/vnd.apple.mpegurl`],[`m4a`,`audio/x-m4a`],[`m4p`,`application/mp4`],[`m4s`,`video/iso.segment`],[`m4u`,`application/vnd.mpegurl`],[`m4v`,`video/x-m4v`],[`m13`,`application/x-msmediaview`],[`m14`,`application/x-msmediaview`],[`m21`,`application/mp21`],[`ma`,`application/mathematica`],[`mads`,`application/mads+xml`],[`maei`,`application/mmt-aei+xml`],[`mag`,`application/vnd.ecowin.chart`],[`maker`,`application/vnd.framemaker`],[`man`,`text/troff`],[`manifest`,`text/cache-manifest`],[`map`,`application/json`],[`mar`,`application/octet-stream`],[`markdown`,`text/markdown`],[`mathml`,`application/mathml+xml`],[`mb`,`application/mathematica`],[`mbk`,`application/vnd.mobius.mbk`],[`mbox`,`application/mbox`],[`mc1`,`application/vnd.medcalcdata`],[`mcd`,`application/vnd.mcd`],[`mcurl`,`text/vnd.curl.mcurl`],[`md`,`text/markdown`],[`mdb`,`application/x-msaccess`],[`mdi`,`image/vnd.ms-modi`],[`mdx`,`text/mdx`],[`me`,`text/troff`],[`mesh`,`model/mesh`],[`meta4`,`application/metalink4+xml`],[`metalink`,`application/metalink+xml`],[`mets`,`application/mets+xml`],[`mfm`,`application/vnd.mfmp`],[`mft`,`application/rpki-manifest`],[`mgp`,`application/vnd.osgeo.mapguide.package`],[`mgz`,`application/vnd.proteus.magazine`],[`mid`,`audio/midi`],[`midi`,`audio/midi`],[`mie`,`application/x-mie`],[`mif`,`application/vnd.mif`],[`mime`,`message/rfc822`],[`mj2`,`video/mj2`],[`mjp2`,`video/mj2`],[`mjs`,`application/javascript`],[`mk3d`,`video/x-matroska`],[`mka`,`audio/x-matroska`],[`mkd`,`text/x-markdown`],[`mks`,`video/x-matroska`],[`mkv`,`video/x-matroska`],[`mlp`,`application/vnd.dolby.mlp`],[`mmd`,`application/vnd.chipnuts.karaoke-mmd`],[`mmf`,`application/vnd.smaf`],[`mml`,`text/mathml`],[`mmr`,`image/vnd.fujixerox.edmics-mmr`],[`mng`,`video/x-mng`],[`mny`,`application/x-msmoney`],[`mobi`,`application/x-mobipocket-ebook`],[`mods`,`application/mods+xml`],[`mov`,`video/quicktime`],[`movie`,`video/x-sgi-movie`],[`mp2`,`audio/mpeg`],[`mp2a`,`audio/mpeg`],[`mp3`,`audio/mpeg`],[`mp4`,`video/mp4`],[`mp4a`,`audio/mp4`],[`mp4s`,`application/mp4`],[`mp4v`,`video/mp4`],[`mp21`,`application/mp21`],[`mpc`,`application/vnd.mophun.certificate`],[`mpd`,`application/dash+xml`],[`mpe`,`video/mpeg`],[`mpeg`,`video/mpeg`],[`mpg`,`video/mpeg`],[`mpg4`,`video/mp4`],[`mpga`,`audio/mpeg`],[`mpkg`,`application/vnd.apple.installer+xml`],[`mpm`,`application/vnd.blueice.multipass`],[`mpn`,`application/vnd.mophun.application`],[`mpp`,`application/vnd.ms-project`],[`mpt`,`application/vnd.ms-project`],[`mpy`,`application/vnd.ibm.minipay`],[`mqy`,`application/vnd.mobius.mqy`],[`mrc`,`application/marc`],[`mrcx`,`application/marcxml+xml`],[`ms`,`text/troff`],[`mscml`,`application/mediaservercontrol+xml`],[`mseed`,`application/vnd.fdsn.mseed`],[`mseq`,`application/vnd.mseq`],[`msf`,`application/vnd.epson.msf`],[`msg`,`application/vnd.ms-outlook`],[`msh`,`model/mesh`],[`msi`,`application/x-msdownload`],[`msl`,`application/vnd.mobius.msl`],[`msm`,`application/octet-stream`],[`msp`,`application/octet-stream`],[`msty`,`application/vnd.muvee.style`],[`mtl`,`model/mtl`],[`mts`,`model/vnd.mts`],[`mus`,`application/vnd.musician`],[`musd`,`application/mmt-usd+xml`],[`musicxml`,`application/vnd.recordare.musicxml+xml`],[`mvb`,`application/x-msmediaview`],[`mvt`,`application/vnd.mapbox-vector-tile`],[`mwf`,`application/vnd.mfer`],[`mxf`,`application/mxf`],[`mxl`,`application/vnd.recordare.musicxml`],[`mxmf`,`audio/mobile-xmf`],[`mxml`,`application/xv+xml`],[`mxs`,`application/vnd.triscape.mxs`],[`mxu`,`video/vnd.mpegurl`],[`n-gage`,`application/vnd.nokia.n-gage.symbian.install`],[`n3`,`text/n3`],[`nb`,`application/mathematica`],[`nbp`,`application/vnd.wolfram.player`],[`nc`,`application/x-netcdf`],[`ncx`,`application/x-dtbncx+xml`],[`nfo`,`text/x-nfo`],[`ngdat`,`application/vnd.nokia.n-gage.data`],[`nitf`,`application/vnd.nitf`],[`nlu`,`application/vnd.neurolanguage.nlu`],[`nml`,`application/vnd.enliven`],[`nnd`,`application/vnd.noblenet-directory`],[`nns`,`application/vnd.noblenet-sealer`],[`nnw`,`application/vnd.noblenet-web`],[`npx`,`image/vnd.net-fpx`],[`nq`,`application/n-quads`],[`nsc`,`application/x-conference`],[`nsf`,`application/vnd.lotus-notes`],[`nt`,`application/n-triples`],[`ntf`,`application/vnd.nitf`],[`numbers`,`application/x-iwork-numbers-sffnumbers`],[`nzb`,`application/x-nzb`],[`oa2`,`application/vnd.fujitsu.oasys2`],[`oa3`,`application/vnd.fujitsu.oasys3`],[`oas`,`application/vnd.fujitsu.oasys`],[`obd`,`application/x-msbinder`],[`obgx`,`application/vnd.openblox.game+xml`],[`obj`,`model/obj`],[`oda`,`application/oda`],[`odb`,`application/vnd.oasis.opendocument.database`],[`odc`,`application/vnd.oasis.opendocument.chart`],[`odf`,`application/vnd.oasis.opendocument.formula`],[`odft`,`application/vnd.oasis.opendocument.formula-template`],[`odg`,`application/vnd.oasis.opendocument.graphics`],[`odi`,`application/vnd.oasis.opendocument.image`],[`odm`,`application/vnd.oasis.opendocument.text-master`],[`odp`,`application/vnd.oasis.opendocument.presentation`],[`ods`,`application/vnd.oasis.opendocument.spreadsheet`],[`odt`,`application/vnd.oasis.opendocument.text`],[`oga`,`audio/ogg`],[`ogex`,`model/vnd.opengex`],[`ogg`,`audio/ogg`],[`ogv`,`video/ogg`],[`ogx`,`application/ogg`],[`omdoc`,`application/omdoc+xml`],[`onepkg`,`application/onenote`],[`onetmp`,`application/onenote`],[`onetoc`,`application/onenote`],[`onetoc2`,`application/onenote`],[`opf`,`application/oebps-package+xml`],[`opml`,`text/x-opml`],[`oprc`,`application/vnd.palm`],[`opus`,`audio/ogg`],[`org`,`text/x-org`],[`osf`,`application/vnd.yamaha.openscoreformat`],[`osfpvg`,`application/vnd.yamaha.openscoreformat.osfpvg+xml`],[`osm`,`application/vnd.openstreetmap.data+xml`],[`otc`,`application/vnd.oasis.opendocument.chart-template`],[`otf`,`font/otf`],[`otg`,`application/vnd.oasis.opendocument.graphics-template`],[`oth`,`application/vnd.oasis.opendocument.text-web`],[`oti`,`application/vnd.oasis.opendocument.image-template`],[`otp`,`application/vnd.oasis.opendocument.presentation-template`],[`ots`,`application/vnd.oasis.opendocument.spreadsheet-template`],[`ott`,`application/vnd.oasis.opendocument.text-template`],[`ova`,`application/x-virtualbox-ova`],[`ovf`,`application/x-virtualbox-ovf`],[`owl`,`application/rdf+xml`],[`oxps`,`application/oxps`],[`oxt`,`application/vnd.openofficeorg.extension`],[`p`,`text/x-pascal`],[`p7a`,`application/x-pkcs7-signature`],[`p7b`,`application/x-pkcs7-certificates`],[`p7c`,`application/pkcs7-mime`],[`p7m`,`application/pkcs7-mime`],[`p7r`,`application/x-pkcs7-certreqresp`],[`p7s`,`application/pkcs7-signature`],[`p8`,`application/pkcs8`],[`p10`,`application/x-pkcs10`],[`p12`,`application/x-pkcs12`],[`pac`,`application/x-ns-proxy-autoconfig`],[`pages`,`application/x-iwork-pages-sffpages`],[`pas`,`text/x-pascal`],[`paw`,`application/vnd.pawaafile`],[`pbd`,`application/vnd.powerbuilder6`],[`pbm`,`image/x-portable-bitmap`],[`pcap`,`application/vnd.tcpdump.pcap`],[`pcf`,`application/x-font-pcf`],[`pcl`,`application/vnd.hp-pcl`],[`pclxl`,`application/vnd.hp-pclxl`],[`pct`,`image/x-pict`],[`pcurl`,`application/vnd.curl.pcurl`],[`pcx`,`image/x-pcx`],[`pdb`,`application/x-pilot`],[`pde`,`text/x-processing`],[`pdf`,`application/pdf`],[`pem`,`application/x-x509-user-cert`],[`pfa`,`application/x-font-type1`],[`pfb`,`application/x-font-type1`],[`pfm`,`application/x-font-type1`],[`pfr`,`application/font-tdpfr`],[`pfx`,`application/x-pkcs12`],[`pgm`,`image/x-portable-graymap`],[`pgn`,`application/x-chess-pgn`],[`pgp`,`application/pgp`],[`php`,`application/x-httpd-php`],[`php3`,`application/x-httpd-php`],[`php4`,`application/x-httpd-php`],[`phps`,`application/x-httpd-php-source`],[`phtml`,`application/x-httpd-php`],[`pic`,`image/x-pict`],[`pkg`,`application/octet-stream`],[`pki`,`application/pkixcmp`],[`pkipath`,`application/pkix-pkipath`],[`pkpass`,`application/vnd.apple.pkpass`],[`pl`,`application/x-perl`],[`plb`,`application/vnd.3gpp.pic-bw-large`],[`plc`,`application/vnd.mobius.plc`],[`plf`,`application/vnd.pocketlearn`],[`pls`,`application/pls+xml`],[`pm`,`application/x-perl`],[`pml`,`application/vnd.ctc-posml`],[`png`,`image/png`],[`pnm`,`image/x-portable-anymap`],[`portpkg`,`application/vnd.macports.portpkg`],[`pot`,`application/vnd.ms-powerpoint`],[`potm`,`application/vnd.ms-powerpoint.presentation.macroEnabled.12`],[`potx`,`application/vnd.openxmlformats-officedocument.presentationml.template`],[`ppa`,`application/vnd.ms-powerpoint`],[`ppam`,`application/vnd.ms-powerpoint.addin.macroEnabled.12`],[`ppd`,`application/vnd.cups-ppd`],[`ppm`,`image/x-portable-pixmap`],[`pps`,`application/vnd.ms-powerpoint`],[`ppsm`,`application/vnd.ms-powerpoint.slideshow.macroEnabled.12`],[`ppsx`,`application/vnd.openxmlformats-officedocument.presentationml.slideshow`],[`ppt`,`application/powerpoint`],[`pptm`,`application/vnd.ms-powerpoint.presentation.macroEnabled.12`],[`pptx`,`application/vnd.openxmlformats-officedocument.presentationml.presentation`],[`pqa`,`application/vnd.palm`],[`prc`,`application/x-pilot`],[`pre`,`application/vnd.lotus-freelance`],[`prf`,`application/pics-rules`],[`provx`,`application/provenance+xml`],[`ps`,`application/postscript`],[`psb`,`application/vnd.3gpp.pic-bw-small`],[`psd`,`application/x-photoshop`],[`psf`,`application/x-font-linux-psf`],[`pskcxml`,`application/pskc+xml`],[`pti`,`image/prs.pti`],[`ptid`,`application/vnd.pvi.ptid1`],[`pub`,`application/x-mspublisher`],[`pvb`,`application/vnd.3gpp.pic-bw-var`],[`pwn`,`application/vnd.3m.post-it-notes`],[`pya`,`audio/vnd.ms-playready.media.pya`],[`pyv`,`video/vnd.ms-playready.media.pyv`],[`qam`,`application/vnd.epson.quickanime`],[`qbo`,`application/vnd.intu.qbo`],[`qfx`,`application/vnd.intu.qfx`],[`qps`,`application/vnd.publishare-delta-tree`],[`qt`,`video/quicktime`],[`qwd`,`application/vnd.quark.quarkxpress`],[`qwt`,`application/vnd.quark.quarkxpress`],[`qxb`,`application/vnd.quark.quarkxpress`],[`qxd`,`application/vnd.quark.quarkxpress`],[`qxl`,`application/vnd.quark.quarkxpress`],[`qxt`,`application/vnd.quark.quarkxpress`],[`ra`,`audio/x-realaudio`],[`ram`,`audio/x-pn-realaudio`],[`raml`,`application/raml+yaml`],[`rapd`,`application/route-apd+xml`],[`rar`,`application/x-rar`],[`ras`,`image/x-cmu-raster`],[`rcprofile`,`application/vnd.ipunplugged.rcprofile`],[`rdf`,`application/rdf+xml`],[`rdz`,`application/vnd.data-vision.rdz`],[`relo`,`application/p2p-overlay+xml`],[`rep`,`application/vnd.businessobjects`],[`res`,`application/x-dtbresource+xml`],[`rgb`,`image/x-rgb`],[`rif`,`application/reginfo+xml`],[`rip`,`audio/vnd.rip`],[`ris`,`application/x-research-info-systems`],[`rl`,`application/resource-lists+xml`],[`rlc`,`image/vnd.fujixerox.edmics-rlc`],[`rld`,`application/resource-lists-diff+xml`],[`rm`,`audio/x-pn-realaudio`],[`rmi`,`audio/midi`],[`rmp`,`audio/x-pn-realaudio-plugin`],[`rms`,`application/vnd.jcp.javame.midlet-rms`],[`rmvb`,`application/vnd.rn-realmedia-vbr`],[`rnc`,`application/relax-ng-compact-syntax`],[`rng`,`application/xml`],[`roa`,`application/rpki-roa`],[`roff`,`text/troff`],[`rp9`,`application/vnd.cloanto.rp9`],[`rpm`,`audio/x-pn-realaudio-plugin`],[`rpss`,`application/vnd.nokia.radio-presets`],[`rpst`,`application/vnd.nokia.radio-preset`],[`rq`,`application/sparql-query`],[`rs`,`application/rls-services+xml`],[`rsa`,`application/x-pkcs7`],[`rsat`,`application/atsc-rsat+xml`],[`rsd`,`application/rsd+xml`],[`rsheet`,`application/urc-ressheet+xml`],[`rss`,`application/rss+xml`],[`rtf`,`text/rtf`],[`rtx`,`text/richtext`],[`run`,`application/x-makeself`],[`rusd`,`application/route-usd+xml`],[`rv`,`video/vnd.rn-realvideo`],[`s`,`text/x-asm`],[`s3m`,`audio/s3m`],[`saf`,`application/vnd.yamaha.smaf-audio`],[`sass`,`text/x-sass`],[`sbml`,`application/sbml+xml`],[`sc`,`application/vnd.ibm.secure-container`],[`scd`,`application/x-msschedule`],[`scm`,`application/vnd.lotus-screencam`],[`scq`,`application/scvp-cv-request`],[`scs`,`application/scvp-cv-response`],[`scss`,`text/x-scss`],[`scurl`,`text/vnd.curl.scurl`],[`sda`,`application/vnd.stardivision.draw`],[`sdc`,`application/vnd.stardivision.calc`],[`sdd`,`application/vnd.stardivision.impress`],[`sdkd`,`application/vnd.solent.sdkm+xml`],[`sdkm`,`application/vnd.solent.sdkm+xml`],[`sdp`,`application/sdp`],[`sdw`,`application/vnd.stardivision.writer`],[`sea`,`application/octet-stream`],[`see`,`application/vnd.seemail`],[`seed`,`application/vnd.fdsn.seed`],[`sema`,`application/vnd.sema`],[`semd`,`application/vnd.semd`],[`semf`,`application/vnd.semf`],[`senmlx`,`application/senml+xml`],[`sensmlx`,`application/sensml+xml`],[`ser`,`application/java-serialized-object`],[`setpay`,`application/set-payment-initiation`],[`setreg`,`application/set-registration-initiation`],[`sfd-hdstx`,`application/vnd.hydrostatix.sof-data`],[`sfs`,`application/vnd.spotfire.sfs`],[`sfv`,`text/x-sfv`],[`sgi`,`image/sgi`],[`sgl`,`application/vnd.stardivision.writer-global`],[`sgm`,`text/sgml`],[`sgml`,`text/sgml`],[`sh`,`application/x-sh`],[`shar`,`application/x-shar`],[`shex`,`text/shex`],[`shf`,`application/shf+xml`],[`shtml`,`text/html`],[`sid`,`image/x-mrsid-image`],[`sieve`,`application/sieve`],[`sig`,`application/pgp-signature`],[`sil`,`audio/silk`],[`silo`,`model/mesh`],[`sis`,`application/vnd.symbian.install`],[`sisx`,`application/vnd.symbian.install`],[`sit`,`application/x-stuffit`],[`sitx`,`application/x-stuffitx`],[`siv`,`application/sieve`],[`skd`,`application/vnd.koan`],[`skm`,`application/vnd.koan`],[`skp`,`application/vnd.koan`],[`skt`,`application/vnd.koan`],[`sldm`,`application/vnd.ms-powerpoint.slide.macroenabled.12`],[`sldx`,`application/vnd.openxmlformats-officedocument.presentationml.slide`],[`slim`,`text/slim`],[`slm`,`text/slim`],[`sls`,`application/route-s-tsid+xml`],[`slt`,`application/vnd.epson.salt`],[`sm`,`application/vnd.stepmania.stepchart`],[`smf`,`application/vnd.stardivision.math`],[`smi`,`application/smil`],[`smil`,`application/smil`],[`smv`,`video/x-smv`],[`smzip`,`application/vnd.stepmania.package`],[`snd`,`audio/basic`],[`snf`,`application/x-font-snf`],[`so`,`application/octet-stream`],[`spc`,`application/x-pkcs7-certificates`],[`spdx`,`text/spdx`],[`spf`,`application/vnd.yamaha.smaf-phrase`],[`spl`,`application/x-futuresplash`],[`spot`,`text/vnd.in3d.spot`],[`spp`,`application/scvp-vp-response`],[`spq`,`application/scvp-vp-request`],[`spx`,`audio/ogg`],[`sql`,`application/x-sql`],[`src`,`application/x-wais-source`],[`srt`,`application/x-subrip`],[`sru`,`application/sru+xml`],[`srx`,`application/sparql-results+xml`],[`ssdl`,`application/ssdl+xml`],[`sse`,`application/vnd.kodak-descriptor`],[`ssf`,`application/vnd.epson.ssf`],[`ssml`,`application/ssml+xml`],[`sst`,`application/octet-stream`],[`st`,`application/vnd.sailingtracker.track`],[`stc`,`application/vnd.sun.xml.calc.template`],[`std`,`application/vnd.sun.xml.draw.template`],[`stf`,`application/vnd.wt.stf`],[`sti`,`application/vnd.sun.xml.impress.template`],[`stk`,`application/hyperstudio`],[`stl`,`model/stl`],[`stpx`,`model/step+xml`],[`stpxz`,`model/step-xml+zip`],[`stpz`,`model/step+zip`],[`str`,`application/vnd.pg.format`],[`stw`,`application/vnd.sun.xml.writer.template`],[`styl`,`text/stylus`],[`stylus`,`text/stylus`],[`sub`,`text/vnd.dvb.subtitle`],[`sus`,`application/vnd.sus-calendar`],[`susp`,`application/vnd.sus-calendar`],[`sv4cpio`,`application/x-sv4cpio`],[`sv4crc`,`application/x-sv4crc`],[`svc`,`application/vnd.dvb.service`],[`svd`,`application/vnd.svd`],[`svg`,`image/svg+xml`],[`svgz`,`image/svg+xml`],[`swa`,`application/x-director`],[`swf`,`application/x-shockwave-flash`],[`swi`,`application/vnd.aristanetworks.swi`],[`swidtag`,`application/swid+xml`],[`sxc`,`application/vnd.sun.xml.calc`],[`sxd`,`application/vnd.sun.xml.draw`],[`sxg`,`application/vnd.sun.xml.writer.global`],[`sxi`,`application/vnd.sun.xml.impress`],[`sxm`,`application/vnd.sun.xml.math`],[`sxw`,`application/vnd.sun.xml.writer`],[`t`,`text/troff`],[`t3`,`application/x-t3vm-image`],[`t38`,`image/t38`],[`taglet`,`application/vnd.mynfc`],[`tao`,`application/vnd.tao.intent-module-archive`],[`tap`,`image/vnd.tencent.tap`],[`tar`,`application/x-tar`],[`tcap`,`application/vnd.3gpp2.tcap`],[`tcl`,`application/x-tcl`],[`td`,`application/urc-targetdesc+xml`],[`teacher`,`application/vnd.smart.teacher`],[`tei`,`application/tei+xml`],[`teicorpus`,`application/tei+xml`],[`tex`,`application/x-tex`],[`texi`,`application/x-texinfo`],[`texinfo`,`application/x-texinfo`],[`text`,`text/plain`],[`tfi`,`application/thraud+xml`],[`tfm`,`application/x-tex-tfm`],[`tfx`,`image/tiff-fx`],[`tga`,`image/x-tga`],[`tgz`,`application/x-tar`],[`thmx`,`application/vnd.ms-officetheme`],[`tif`,`image/tiff`],[`tiff`,`image/tiff`],[`tk`,`application/x-tcl`],[`tmo`,`application/vnd.tmobile-livetv`],[`toml`,`application/toml`],[`torrent`,`application/x-bittorrent`],[`tpl`,`application/vnd.groove-tool-template`],[`tpt`,`application/vnd.trid.tpt`],[`tr`,`text/troff`],[`tra`,`application/vnd.trueapp`],[`trig`,`application/trig`],[`trm`,`application/x-msterminal`],[`ts`,`video/mp2t`],[`tsd`,`application/timestamped-data`],[`tsv`,`text/tab-separated-values`],[`ttc`,`font/collection`],[`ttf`,`font/ttf`],[`ttl`,`text/turtle`],[`ttml`,`application/ttml+xml`],[`twd`,`application/vnd.simtech-mindmapper`],[`twds`,`application/vnd.simtech-mindmapper`],[`txd`,`application/vnd.genomatix.tuxedo`],[`txf`,`application/vnd.mobius.txf`],[`txt`,`text/plain`],[`u8dsn`,`message/global-delivery-status`],[`u8hdr`,`message/global-headers`],[`u8mdn`,`message/global-disposition-notification`],[`u8msg`,`message/global`],[`u32`,`application/x-authorware-bin`],[`ubj`,`application/ubjson`],[`udeb`,`application/x-debian-package`],[`ufd`,`application/vnd.ufdl`],[`ufdl`,`application/vnd.ufdl`],[`ulx`,`application/x-glulx`],[`umj`,`application/vnd.umajin`],[`unityweb`,`application/vnd.unity`],[`uoml`,`application/vnd.uoml+xml`],[`uri`,`text/uri-list`],[`uris`,`text/uri-list`],[`urls`,`text/uri-list`],[`usdz`,`model/vnd.usdz+zip`],[`ustar`,`application/x-ustar`],[`utz`,`application/vnd.uiq.theme`],[`uu`,`text/x-uuencode`],[`uva`,`audio/vnd.dece.audio`],[`uvd`,`application/vnd.dece.data`],[`uvf`,`application/vnd.dece.data`],[`uvg`,`image/vnd.dece.graphic`],[`uvh`,`video/vnd.dece.hd`],[`uvi`,`image/vnd.dece.graphic`],[`uvm`,`video/vnd.dece.mobile`],[`uvp`,`video/vnd.dece.pd`],[`uvs`,`video/vnd.dece.sd`],[`uvt`,`application/vnd.dece.ttml+xml`],[`uvu`,`video/vnd.uvvu.mp4`],[`uvv`,`video/vnd.dece.video`],[`uvva`,`audio/vnd.dece.audio`],[`uvvd`,`application/vnd.dece.data`],[`uvvf`,`application/vnd.dece.data`],[`uvvg`,`image/vnd.dece.graphic`],[`uvvh`,`video/vnd.dece.hd`],[`uvvi`,`image/vnd.dece.graphic`],[`uvvm`,`video/vnd.dece.mobile`],[`uvvp`,`video/vnd.dece.pd`],[`uvvs`,`video/vnd.dece.sd`],[`uvvt`,`application/vnd.dece.ttml+xml`],[`uvvu`,`video/vnd.uvvu.mp4`],[`uvvv`,`video/vnd.dece.video`],[`uvvx`,`application/vnd.dece.unspecified`],[`uvvz`,`application/vnd.dece.zip`],[`uvx`,`application/vnd.dece.unspecified`],[`uvz`,`application/vnd.dece.zip`],[`vbox`,`application/x-virtualbox-vbox`],[`vbox-extpack`,`application/x-virtualbox-vbox-extpack`],[`vcard`,`text/vcard`],[`vcd`,`application/x-cdlink`],[`vcf`,`text/x-vcard`],[`vcg`,`application/vnd.groove-vcard`],[`vcs`,`text/x-vcalendar`],[`vcx`,`application/vnd.vcx`],[`vdi`,`application/x-virtualbox-vdi`],[`vds`,`model/vnd.sap.vds`],[`vhd`,`application/x-virtualbox-vhd`],[`vis`,`application/vnd.visionary`],[`viv`,`video/vnd.vivo`],[`vlc`,`application/videolan`],[`vmdk`,`application/x-virtualbox-vmdk`],[`vob`,`video/x-ms-vob`],[`vor`,`application/vnd.stardivision.writer`],[`vox`,`application/x-authorware-bin`],[`vrml`,`model/vrml`],[`vsd`,`application/vnd.visio`],[`vsf`,`application/vnd.vsf`],[`vss`,`application/vnd.visio`],[`vst`,`application/vnd.visio`],[`vsw`,`application/vnd.visio`],[`vtf`,`image/vnd.valve.source.texture`],[`vtt`,`text/vtt`],[`vtu`,`model/vnd.vtu`],[`vxml`,`application/voicexml+xml`],[`w3d`,`application/x-director`],[`wad`,`application/x-doom`],[`wadl`,`application/vnd.sun.wadl+xml`],[`war`,`application/java-archive`],[`wasm`,`application/wasm`],[`wav`,`audio/x-wav`],[`wax`,`audio/x-ms-wax`],[`wbmp`,`image/vnd.wap.wbmp`],[`wbs`,`application/vnd.criticaltools.wbs+xml`],[`wbxml`,`application/wbxml`],[`wcm`,`application/vnd.ms-works`],[`wdb`,`application/vnd.ms-works`],[`wdp`,`image/vnd.ms-photo`],[`weba`,`audio/webm`],[`webapp`,`application/x-web-app-manifest+json`],[`webm`,`video/webm`],[`webmanifest`,`application/manifest+json`],[`webp`,`image/webp`],[`wg`,`application/vnd.pmi.widget`],[`wgt`,`application/widget`],[`wks`,`application/vnd.ms-works`],[`wm`,`video/x-ms-wm`],[`wma`,`audio/x-ms-wma`],[`wmd`,`application/x-ms-wmd`],[`wmf`,`image/wmf`],[`wml`,`text/vnd.wap.wml`],[`wmlc`,`application/wmlc`],[`wmls`,`text/vnd.wap.wmlscript`],[`wmlsc`,`application/vnd.wap.wmlscriptc`],[`wmv`,`video/x-ms-wmv`],[`wmx`,`video/x-ms-wmx`],[`wmz`,`application/x-msmetafile`],[`woff`,`font/woff`],[`woff2`,`font/woff2`],[`word`,`application/msword`],[`wpd`,`application/vnd.wordperfect`],[`wpl`,`application/vnd.ms-wpl`],[`wps`,`application/vnd.ms-works`],[`wqd`,`application/vnd.wqd`],[`wri`,`application/x-mswrite`],[`wrl`,`model/vrml`],[`wsc`,`message/vnd.wfa.wsc`],[`wsdl`,`application/wsdl+xml`],[`wspolicy`,`application/wspolicy+xml`],[`wtb`,`application/vnd.webturbo`],[`wvx`,`video/x-ms-wvx`],[`x3d`,`model/x3d+xml`],[`x3db`,`model/x3d+fastinfoset`],[`x3dbz`,`model/x3d+binary`],[`x3dv`,`model/x3d-vrml`],[`x3dvz`,`model/x3d+vrml`],[`x3dz`,`model/x3d+xml`],[`x32`,`application/x-authorware-bin`],[`x_b`,`model/vnd.parasolid.transmit.binary`],[`x_t`,`model/vnd.parasolid.transmit.text`],[`xaml`,`application/xaml+xml`],[`xap`,`application/x-silverlight-app`],[`xar`,`application/vnd.xara`],[`xav`,`application/xcap-att+xml`],[`xbap`,`application/x-ms-xbap`],[`xbd`,`application/vnd.fujixerox.docuworks.binder`],[`xbm`,`image/x-xbitmap`],[`xca`,`application/xcap-caps+xml`],[`xcs`,`application/calendar+xml`],[`xdf`,`application/xcap-diff+xml`],[`xdm`,`application/vnd.syncml.dm+xml`],[`xdp`,`application/vnd.adobe.xdp+xml`],[`xdssc`,`application/dssc+xml`],[`xdw`,`application/vnd.fujixerox.docuworks`],[`xel`,`application/xcap-el+xml`],[`xenc`,`application/xenc+xml`],[`xer`,`application/patch-ops-error+xml`],[`xfdf`,`application/vnd.adobe.xfdf`],[`xfdl`,`application/vnd.xfdl`],[`xht`,`application/xhtml+xml`],[`xhtml`,`application/xhtml+xml`],[`xhvml`,`application/xv+xml`],[`xif`,`image/vnd.xiff`],[`xl`,`application/excel`],[`xla`,`application/vnd.ms-excel`],[`xlam`,`application/vnd.ms-excel.addin.macroEnabled.12`],[`xlc`,`application/vnd.ms-excel`],[`xlf`,`application/xliff+xml`],[`xlm`,`application/vnd.ms-excel`],[`xls`,`application/vnd.ms-excel`],[`xlsb`,`application/vnd.ms-excel.sheet.binary.macroEnabled.12`],[`xlsm`,`application/vnd.ms-excel.sheet.macroEnabled.12`],[`xlsx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`],[`xlt`,`application/vnd.ms-excel`],[`xltm`,`application/vnd.ms-excel.template.macroEnabled.12`],[`xltx`,`application/vnd.openxmlformats-officedocument.spreadsheetml.template`],[`xlw`,`application/vnd.ms-excel`],[`xm`,`audio/xm`],[`xml`,`application/xml`],[`xns`,`application/xcap-ns+xml`],[`xo`,`application/vnd.olpc-sugar`],[`xop`,`application/xop+xml`],[`xpi`,`application/x-xpinstall`],[`xpl`,`application/xproc+xml`],[`xpm`,`image/x-xpixmap`],[`xpr`,`application/vnd.is-xpr`],[`xps`,`application/vnd.ms-xpsdocument`],[`xpw`,`application/vnd.intercon.formnet`],[`xpx`,`application/vnd.intercon.formnet`],[`xsd`,`application/xml`],[`xsl`,`application/xml`],[`xslt`,`application/xslt+xml`],[`xsm`,`application/vnd.syncml+xml`],[`xspf`,`application/xspf+xml`],[`xul`,`application/vnd.mozilla.xul+xml`],[`xvm`,`application/xv+xml`],[`xvml`,`application/xv+xml`],[`xwd`,`image/x-xwindowdump`],[`xyz`,`chemical/x-xyz`],[`xz`,`application/x-xz`],[`yaml`,`text/yaml`],[`yang`,`application/yang`],[`yin`,`application/yin+xml`],[`yml`,`text/yaml`],[`ymp`,`text/x-suse-ymp`],[`z`,`application/x-compress`],[`z1`,`application/x-zmachine`],[`z2`,`application/x-zmachine`],[`z3`,`application/x-zmachine`],[`z4`,`application/x-zmachine`],[`z5`,`application/x-zmachine`],[`z6`,`application/x-zmachine`],[`z7`,`application/x-zmachine`],[`z8`,`application/x-zmachine`],[`zaz`,`application/vnd.zzazz.deck+xml`],[`zip`,`application/zip`],[`zir`,`application/vnd.zul`],[`zirz`,`application/vnd.zul`],[`zmm`,`application/vnd.handheld-entertainment+xml`],[`zsh`,`text/x-scriptzsh`]]);function rJ(e,t,n){let r=iJ(e),{webkitRelativePath:i}=e,a=typeof t==`string`?t:typeof i==`string`&&i.length>0?i:`./${e.name}`;return typeof r.path!=`string`&&aJ(r,`path`,a),n!==void 0&&Object.defineProperty(r,"handle",{value:n,writable:!1,configurable:!1,enumerable:!0}),aJ(r,`relativePath`,a),r}function iJ(e){let{name:t}=e;if(t&&t.lastIndexOf(`.`)!==-1&&!e.type){let n=t.split(`.`).pop().toLowerCase(),r=nJ.get(n);r&&Object.defineProperty(e,"type",{value:r,writable:!1,configurable:!1,enumerable:!0})}return e}function aJ(e,t,n){Object.defineProperty(e,t,{value:n,writable:!1,configurable:!1,enumerable:!0})}var oJ=[`.DS_Store`,`Thumbs.db`];function sJ(e){return d(this,void 0,void 0,function*(){return uJ(e)&&cJ(e.dataTransfer)?pJ(e.dataTransfer,e.type):lJ(e)?dJ(e):Array.isArray(e)&&e.every(e=>`getFile`in e&&typeof e.getFile==`function`)?fJ(e):[]})}function cJ(e){return uJ(e)}function lJ(e){return uJ(e)&&uJ(e.target)}function uJ(e){return typeof e==`object`&&!!e}function dJ(e){return hJ(e.target.files).map(e=>rJ(e))}function fJ(e){return d(this,void 0,void 0,function*(){return(yield Promise.all(e.map(e=>e.getFile()))).map(e=>rJ(e))})}function pJ(e,t){return d(this,void 0,void 0,function*(){if(e.items){let n=hJ(e.items).filter(e=>e.kind===`file`);return t===`drop`?mJ(_J(yield Promise.all(n.map(gJ)))):n}return mJ(hJ(e.files).map(e=>rJ(e)))})}function mJ(e){return e.filter(e=>oJ.indexOf(e.name)===-1)}function hJ(e){if(e===null)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n];t.push(r)}return t}function gJ(e){if(typeof e.webkitGetAsEntry!=`function`)return vJ(e);let t=e.webkitGetAsEntry();return t&&t.isDirectory?bJ(t):vJ(e,t)}function _J(e){return e.reduce((e,t)=>[...e,...Array.isArray(t)?_J(t):[t]],[])}function vJ(e,t){return d(this,void 0,void 0,function*(){if(globalThis.isSecureContext&&typeof e.getAsFileSystemHandle==`function`){let t=yield e.getAsFileSystemHandle();if(t===null)throw Error(`${e} is not a File`);if(t!==void 0){let e=yield t.getFile();return e.handle=t,rJ(e)}}let n=e.getAsFile();if(!n)throw Error(`${e} is not a File`);return rJ(n,t?.fullPath??void 0)})}function yJ(e){return d(this,void 0,void 0,function*(){return e.isDirectory?bJ(e):xJ(e)})}function bJ(e){let t=e.createReader();return new Promise((e,n)=>{let r=[];function i(){t.readEntries(t=>d(this,void 0,void 0,function*(){if(t.length){let e=Promise.all(t.map(yJ));r.push(e),i()}else try{e(yield Promise.all(r))}catch(e){n(e)}}),e=>{n(e)})}i()})}function xJ(e){return d(this,void 0,void 0,function*(){return new Promise((t,n)=>{e.file(n=>{t(rJ(n,e.fullPath))},e=>{n(e)})})})}var SJ=c(o((e=>{e.__esModule=!0,e.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(`,`);if(n.length===0)return!0;var r=e.name||``,i=(e.type||``).toLowerCase(),a=i.replace(/\/.*$/,``);return n.some(function(e){var t=e.trim().toLowerCase();return t.charAt(0)===`.`?r.toLowerCase().endsWith(t):t.endsWith(`/*`)?a===t.replace(/\/.*$/,``):i===t})}return!0}}))());function CJ(e){return EJ(e)||TJ(e)||MJ(e)||wJ()}function wJ(){throw TypeError(`Invalid attempt to spread non-iterable instance.
223
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function TJ(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function EJ(e){if(Array.isArray(e))return NJ(e)}function DJ(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function OJ(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?DJ(Object(n),!0).forEach(function(t){kJ(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):DJ(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function kJ(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function AJ(e,t){return FJ(e)||PJ(e,t)||MJ(e,t)||jJ()}function jJ(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
224
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function MJ(e,t){if(e){if(typeof e==`string`)return NJ(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return NJ(e,t)}}function NJ(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function PJ(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function FJ(e){if(Array.isArray(e))return e}var IJ=typeof SJ.default==`function`?SJ.default:SJ.default.default,LJ=`file-invalid-type`,RJ=`file-too-large`,zJ=`file-too-small`,BJ=`too-many-files`,VJ=function(){var e=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:``).split(`,`);return{code:LJ,message:`File type must be ${e.length>1?`one of ${e.join(`, `)}`:e[0]}`}},HJ=function(e){return{code:RJ,message:`File is larger than ${e} ${e===1?`byte`:`bytes`}`}},UJ=function(e){return{code:zJ,message:`File is smaller than ${e} ${e===1?`byte`:`bytes`}`}},WJ={code:BJ,message:`Too many files`};function GJ(e){return e.type===``&&typeof e.getAsFile==`function`}function KJ(e,t){var n=e.type===`application/x-moz-file`||IJ(e,t)||GJ(e);return[n,n?null:VJ(t)]}function qJ(e,t,n){if(JJ(e.size)){if(JJ(t)&&JJ(n)){if(e.size>n)return[!1,HJ(n)];if(e.size<t)return[!1,UJ(t)]}else if(JJ(t)&&e.size<t)return[!1,UJ(t)];else if(JJ(n)&&e.size>n)return[!1,HJ(n)]}return[!0,null]}function JJ(e){return e!=null}function YJ(e){var t=e.files,n=e.accept,r=e.minSize,i=e.maxSize,a=e.multiple,o=e.maxFiles,s=e.validator;return!a&&t.length>1||a&&o>=1&&t.length>o?!1:t.every(function(e){var t=AJ(KJ(e,n),1)[0],a=AJ(qJ(e,r,i),1)[0],o=s?s(e):null;return t&&a&&!o})}function XJ(e){return typeof e.isPropagationStopped==`function`?e.isPropagationStopped():e.cancelBubble===void 0?!1:e.cancelBubble}function ZJ(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(e){return e===`Files`||e===`application/x-moz-file`}):!!e.target&&!!e.target.files}function QJ(e){e.preventDefault()}function $J(e){return e.indexOf(`MSIE`)!==-1||e.indexOf(`Trident/`)!==-1}function eY(e){return e.indexOf(`Edge/`)!==-1}function tY(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return $J(e)||eY(e)}function nY(){var e=[...arguments];return function(t){var n=[...arguments].slice(1);return e.some(function(e){return!XJ(t)&&e&&e.apply(void 0,[t].concat(n)),XJ(t)})}}function rY(){return`showOpenFilePicker`in window}function iY(e){return JJ(e)?[{description:`Files`,accept:Object.entries(e).filter(function(e){var t=AJ(e,2),n=t[0],r=t[1],i=!0;return cY(n)||(console.warn(`Skipped "${n}" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.`),i=!1),(!Array.isArray(r)||!r.every(lY))&&(console.warn(`Skipped "${n}" because an invalid file extension was provided.`),i=!1),i}).reduce(function(e,t){var n=AJ(t,2),r=n[0],i=n[1];return OJ(OJ({},e),{},kJ({},r,i))},{})}]:e}function aY(e){if(JJ(e))return Object.entries(e).reduce(function(e,t){var n=AJ(t,2),r=n[0],i=n[1];return[].concat(CJ(e),[r],CJ(i))},[]).filter(function(e){return cY(e)||lY(e)}).join(`,`)}function oY(e){return e instanceof DOMException&&(e.name===`AbortError`||e.code===e.ABORT_ERR)}function sY(e){return e instanceof DOMException&&(e.name===`SecurityError`||e.code===e.SECURITY_ERR)}function cY(e){return e===`audio/*`||e===`video/*`||e===`image/*`||e===`text/*`||e===`application/*`||/\w+\/[-+.\w]+/g.test(e)}function lY(e){return/^.*\.[\w]+$/.test(e)}var uY=c(Wb()),dY=[`children`],fY=[`open`],pY=[`refKey`,`role`,`onKeyDown`,`onFocus`,`onBlur`,`onClick`,`onDragEnter`,`onDragOver`,`onDragLeave`,`onDrop`],mY=[`refKey`,`onChange`,`onClick`];function hY(e){return vY(e)||_Y(e)||xY(e)||gY()}function gY(){throw TypeError(`Invalid attempt to spread non-iterable instance.
225
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _Y(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function vY(e){if(Array.isArray(e))return SY(e)}function yY(e,t){return wY(e)||CY(e,t)||xY(e,t)||bY()}function bY(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
226
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xY(e,t){if(e){if(typeof e==`string`)return SY(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return SY(e,t)}}function SY(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function CY(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r=[],i=!0,a=!1,o,s;try{for(n=n.call(e);!(i=(o=n.next()).done)&&(r.push(o.value),!(t&&r.length===t));i=!0);}catch(e){a=!0,s=e}finally{try{!i&&n.return!=null&&n.return()}finally{if(a)throw s}}return r}}function wY(e){if(Array.isArray(e))return e}function TY(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function EY(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?TY(Object(n),!0).forEach(function(t){DY(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):TY(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function DY(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function OY(e,t){if(e==null)return{};var n=kY(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function kY(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,a;for(a=0;a<r.length;a++)i=r[a],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}var AY=(0,b.forwardRef)(function(e,t){var n=e.children,r=NY(OY(e,dY)),i=r.open,a=OY(r,fY);return(0,b.useImperativeHandle)(t,function(){return{open:i}},[i]),b.createElement(b.Fragment,null,n(EY(EY({},a),{},{open:i})))});AY.displayName=`Dropzone`;var jY={disabled:!1,getFilesFromEvent:sJ,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};AY.defaultProps=jY,AY.propTypes={children:uY.default.func,accept:uY.default.objectOf(uY.default.arrayOf(uY.default.string)),multiple:uY.default.bool,preventDropOnDocument:uY.default.bool,noClick:uY.default.bool,noKeyboard:uY.default.bool,noDrag:uY.default.bool,noDragEventsBubbling:uY.default.bool,minSize:uY.default.number,maxSize:uY.default.number,maxFiles:uY.default.number,disabled:uY.default.bool,getFilesFromEvent:uY.default.func,onFileDialogCancel:uY.default.func,onFileDialogOpen:uY.default.func,useFsAccessApi:uY.default.bool,autoFocus:uY.default.bool,onDragEnter:uY.default.func,onDragLeave:uY.default.func,onDragOver:uY.default.func,onDrop:uY.default.func,onDropAccepted:uY.default.func,onDropRejected:uY.default.func,onError:uY.default.func,validator:uY.default.func};var MY={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragGlobal:!1,acceptedFiles:[],fileRejections:[]};function NY(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=EY(EY({},jY),e),n=t.accept,r=t.disabled,i=t.getFilesFromEvent,a=t.maxSize,o=t.minSize,s=t.multiple,c=t.maxFiles,l=t.onDragEnter,u=t.onDragLeave,d=t.onDragOver,f=t.onDrop,p=t.onDropAccepted,m=t.onDropRejected,h=t.onFileDialogCancel,g=t.onFileDialogOpen,_=t.useFsAccessApi,v=t.autoFocus,y=t.preventDropOnDocument,x=t.noClick,S=t.noKeyboard,C=t.noDrag,w=t.noDragEventsBubbling,T=t.onError,E=t.validator,D=(0,b.useMemo)(function(){return aY(n)},[n]),O=(0,b.useMemo)(function(){return iY(n)},[n]),k=(0,b.useMemo)(function(){return typeof g==`function`?g:FY},[g]),A=(0,b.useMemo)(function(){return typeof h==`function`?h:FY},[h]),j=(0,b.useRef)(null),M=(0,b.useRef)(null),ee=yY((0,b.useReducer)(PY,MY),2),N=ee[0],P=ee[1],te=N.isFocused,ne=N.isFileDialogActive,re=(0,b.useRef)(typeof window<`u`&&window.isSecureContext&&_&&rY()),ie=function(){!re.current&&ne&&setTimeout(function(){M.current&&(M.current.files.length||(P({type:`closeDialog`}),A()))},300)};(0,b.useEffect)(function(){return window.addEventListener(`focus`,ie,!1),function(){window.removeEventListener(`focus`,ie,!1)}},[M,ne,A,re]);var ae=(0,b.useRef)([]),oe=(0,b.useRef)([]),se=function(e){j.current&&j.current.contains(e.target)||(e.preventDefault(),ae.current=[])};(0,b.useEffect)(function(){return y&&(document.addEventListener(`dragover`,QJ,!1),document.addEventListener(`drop`,se,!1)),function(){y&&(document.removeEventListener(`dragover`,QJ),document.removeEventListener(`drop`,se))}},[j,y]),(0,b.useEffect)(function(){var e=function(e){oe.current=[].concat(hY(oe.current),[e.target]),ZJ(e)&&P({isDragGlobal:!0,type:`setDragGlobal`})},t=function(e){oe.current=oe.current.filter(function(t){return t!==e.target&&t!==null}),!(oe.current.length>0)&&P({isDragGlobal:!1,type:`setDragGlobal`})},n=function(){oe.current=[],P({isDragGlobal:!1,type:`setDragGlobal`})},r=function(){oe.current=[],P({isDragGlobal:!1,type:`setDragGlobal`})};return document.addEventListener(`dragenter`,e,!1),document.addEventListener(`dragleave`,t,!1),document.addEventListener(`dragend`,n,!1),document.addEventListener(`drop`,r,!1),function(){document.removeEventListener(`dragenter`,e),document.removeEventListener(`dragleave`,t),document.removeEventListener(`dragend`,n),document.removeEventListener(`drop`,r)}},[j]),(0,b.useEffect)(function(){return!r&&v&&j.current&&j.current.focus(),function(){}},[j,v,r]);var ce=(0,b.useCallback)(function(e){T?T(e):console.error(e)},[T]),le=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),Se(e),ae.current=[].concat(hY(ae.current),[e.target]),ZJ(e)&&Promise.resolve(i(e)).then(function(t){if(!(XJ(e)&&!w)){var n=t.length,r=n>0&&YJ({files:t,accept:D,minSize:o,maxSize:a,multiple:s,maxFiles:c,validator:E});P({isDragAccept:r,isDragReject:n>0&&!r,isDragActive:!0,type:`setDraggedFiles`}),l&&l(e)}}).catch(function(e){return ce(e)})},[i,l,ce,w,D,o,a,s,c,E]),ue=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),Se(e);var t=ZJ(e);if(t&&e.dataTransfer)try{e.dataTransfer.dropEffect=`copy`}catch{}return t&&d&&d(e),!1},[d,w]),de=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),Se(e);var t=ae.current.filter(function(e){return j.current&&j.current.contains(e)}),n=t.indexOf(e.target);n!==-1&&t.splice(n,1),ae.current=t,!(t.length>0)&&(P({type:`setDraggedFiles`,isDragActive:!1,isDragAccept:!1,isDragReject:!1}),ZJ(e)&&u&&u(e))},[j,u,w]),fe=(0,b.useCallback)(function(e,t){var n=[],r=[];e.forEach(function(e){var t=yY(KJ(e,D),2),i=t[0],s=t[1],c=yY(qJ(e,o,a),2),l=c[0],u=c[1],d=E?E(e):null;if(i&&l&&!d)n.push(e);else{var f=[s,u];d&&(f=f.concat(d)),r.push({file:e,errors:f.filter(function(e){return e})})}}),(!s&&n.length>1||s&&c>=1&&n.length>c)&&(n.forEach(function(e){r.push({file:e,errors:[WJ]})}),n.splice(0)),P({acceptedFiles:n,fileRejections:r,type:`setFiles`}),f&&f(n,r,t),r.length>0&&m&&m(r,t),n.length>0&&p&&p(n,t)},[P,s,D,o,a,c,f,p,m,E]),pe=(0,b.useCallback)(function(e){e.preventDefault(),e.persist(),Se(e),ae.current=[],ZJ(e)&&Promise.resolve(i(e)).then(function(t){XJ(e)&&!w||fe(t,e)}).catch(function(e){return ce(e)}),P({type:`reset`})},[i,fe,ce,w]),me=(0,b.useCallback)(function(){if(re.current){P({type:`openDialog`}),k();var e={multiple:s,types:O};window.showOpenFilePicker(e).then(function(e){return i(e)}).then(function(e){fe(e,null),P({type:`closeDialog`})}).catch(function(e){oY(e)?(A(e),P({type:`closeDialog`})):sY(e)?(re.current=!1,M.current?(M.current.value=null,M.current.click()):ce(Error(`Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided.`))):ce(e)});return}M.current&&(P({type:`openDialog`}),k(),M.current.value=null,M.current.click())},[P,k,A,_,fe,ce,O,s]),he=(0,b.useCallback)(function(e){!j.current||!j.current.isEqualNode(e.target)||(e.key===` `||e.key===`Enter`||e.keyCode===32||e.keyCode===13)&&(e.preventDefault(),me())},[j,me]),ge=(0,b.useCallback)(function(){P({type:`focus`})},[]),_e=(0,b.useCallback)(function(){P({type:`blur`})},[]),ve=(0,b.useCallback)(function(){x||(tY()?setTimeout(me,0):me())},[x,me]),ye=function(e){return r?null:e},be=function(e){return S?null:ye(e)},xe=function(e){return C?null:ye(e)},Se=function(e){w&&e.stopPropagation()},Ce=(0,b.useMemo)(function(){return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.refKey,n=t===void 0?`ref`:t,i=e.role,a=e.onKeyDown,o=e.onFocus,s=e.onBlur,c=e.onClick,l=e.onDragEnter,u=e.onDragOver,d=e.onDragLeave,f=e.onDrop,p=OY(e,pY);return EY(EY(DY({onKeyDown:be(nY(a,he)),onFocus:be(nY(o,ge)),onBlur:be(nY(s,_e)),onClick:ye(nY(c,ve)),onDragEnter:xe(nY(l,le)),onDragOver:xe(nY(u,ue)),onDragLeave:xe(nY(d,de)),onDrop:xe(nY(f,pe)),role:typeof i==`string`&&i!==``?i:`presentation`},n,j),!r&&!S?{tabIndex:0}:{}),p)}},[j,he,ge,_e,ve,le,ue,de,pe,S,C,r]),we=(0,b.useCallback)(function(e){e.stopPropagation()},[]),Te=(0,b.useMemo)(function(){return function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=e.refKey,n=t===void 0?`ref`:t,r=e.onChange,i=e.onClick,a=OY(e,mY);return EY(EY({},DY({accept:D,multiple:s,type:`file`,style:{border:0,clip:`rect(0, 0, 0, 0)`,clipPath:`inset(50%)`,height:`1px`,margin:`0 -1px -1px 0`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`},onChange:ye(nY(r,pe)),onClick:ye(nY(i,we)),tabIndex:-1},n,M)),a)}},[M,n,s,pe,r]);return EY(EY({},N),{},{isFocused:te&&!r,getRootProps:Ce,getInputProps:Te,rootRef:j,inputRef:M,open:ye(me)})}function PY(e,t){switch(t.type){case`focus`:return EY(EY({},e),{},{isFocused:!0});case`blur`:return EY(EY({},e),{},{isFocused:!1});case`openDialog`:return EY(EY({},MY),{},{isFileDialogActive:!0});case`closeDialog`:return EY(EY({},e),{},{isFileDialogActive:!1});case`setDraggedFiles`:return EY(EY({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case`setFiles`:return EY(EY({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:!1});case`setDragGlobal`:return EY(EY({},e),{},{isDragGlobal:t.isDragGlobal});case`reset`:return EY({},MY);default:return e}}function FY(){}var[IY,LY]=et(`Dropzone component was not found in tree`),RY={root:`m_d46a4834`,inner:`m_b85f7144`,fullScreen:`m_96f6e9ad`,dropzone:`m_7946116d`};function zY(e){let t=t=>{let{children:n,...r}=R(`Dropzone${Et(e)}`,{},t),i=LY(),a=Qe(n)?n:(0,I.jsx)(`span`,{children:n});return i[e]?(0,b.cloneElement)(a,r):null};return t.displayName=`@mantine/dropzone/${Et(e)}`,t}var BY=zY(`accept`),VY=zY(`reject`),HY=zY(`idle`),UY={multiple:!0,maxSize:1/0,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,useFsAccessApi:!0,variant:`light`,rejectColor:`red`},WY=An((e,{radius:t,variant:n,acceptColor:r,rejectColor:i})=>{let a=e.variantColorResolver({color:r||e.primaryColor,theme:e,variant:n}),o=e.variantColorResolver({color:i||`red`,theme:e,variant:n});return{root:{"--dropzone-radius":mt(t),"--dropzone-accept-color":a.color,"--dropzone-accept-bg":a.background,"--dropzone-reject-color":o.color,"--dropzone-reject-bg":o.background}}}),GY=B((e,t)=>{let n=R(`Dropzone`,UY,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,radius:l,disabled:u,loading:d,multiple:f,maxSize:p,accept:m,children:h,onDropAny:g,onDrop:_,onReject:v,openRef:y,name:b,maxFiles:x,autoFocus:S,activateOnClick:C,activateOnDrag:w,dragEventsBubbling:T,activateOnKeyboard:E,onDragEnter:D,onDragLeave:O,onDragOver:k,onFileDialogCancel:A,onFileDialogOpen:j,preventDropOnDocument:M,useFsAccessApi:ee,getFilesFromEvent:N,validator:P,rejectColor:te,acceptColor:ne,enablePointerEvents:re,loaderProps:ie,inputProps:ae,mod:oe,attributes:se,...ce}=n,le=L({name:`Dropzone`,classes:RY,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:se,vars:c,varsResolver:WY}),{getRootProps:ue,getInputProps:de,isDragAccept:fe,isDragReject:pe,isDragActive:me,open:he}=NY({onDrop:g,onDropAccepted:_,onDropRejected:v,disabled:u||d,accept:Array.isArray(m)?m.reduce((e,t)=>({...e,[t]:[]}),{}):m,multiple:f,maxSize:p,maxFiles:x,autoFocus:S,noClick:!C,noDrag:!w,noDragEventsBubbling:!T,noKeyboard:!E,onDragEnter:D,onDragLeave:O,onDragOver:k,onFileDialogCancel:A,onFileDialogOpen:j,preventDropOnDocument:M,useFsAccessApi:ee,validator:P,...N?{getFilesFromEvent:N}:null});tn(y,he);let ge=me&&fe,_e=me&&pe,ve=!ge&&!_e;return(0,I.jsx)(IY,{value:{accept:ge,reject:_e,idle:ve},children:(0,I.jsxs)(z,{...ue(),...le(`root`,{focusable:!0}),...ce,mod:[{accept:ge,reject:_e,idle:ve,disabled:u,loading:d,"activate-on-click":C},oe],children:[(0,I.jsx)(Ch,{visible:d,overlayProps:{radius:l},unstyled:s,loaderProps:ie}),(0,I.jsx)(`input`,{...de(ae),name:b}),(0,I.jsx)(`div`,{...le(`inner`),ref:t,"data-enable-pointer-events":re||void 0,children:h})]})})});GY.classes=RY,GY.displayName=`@mantine/dropzone/Dropzone`,GY.Accept=BY,GY.Idle=HY,GY.Reject=VY;var KY={maxSize:1/0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,active:!0,zIndex:lt(`max`),withinPortal:!0},qY=B((e,t)=>{let n=R(`DropzoneFullScreen`,KY,e),{classNames:r,className:i,style:a,styles:o,unstyled:s,vars:c,active:l,onDrop:u,onReject:d,zIndex:f,withinPortal:p,portalProps:m,attributes:h,...g}=n,_=L({name:`DropzoneFullScreen`,classes:RY,props:n,className:i,style:a,classNames:r,styles:o,unstyled:s,attributes:h,rootSelector:`fullScreen`}),{resolvedClassNames:v,resolvedStyles:y}=Ur({classNames:r,styles:o,props:n}),[x,S]=(0,b.useState)(0),[C,{open:w,close:T}]=bn(!1),E=e=>{e.dataTransfer?.types.includes(`Files`)&&(S(e=>e+1),w())},D=()=>{S(e=>e-1)};return(0,b.useEffect)(()=>{x===0&&T()},[x]),(0,b.useEffect)(()=>{if(l)return document.addEventListener(`dragenter`,E,!1),document.addEventListener(`dragleave`,D,!1),()=>{document.removeEventListener(`dragenter`,E,!1),document.removeEventListener(`dragleave`,D,!1)}},[l]),(0,I.jsx)(Pl,{...m,withinPortal:p,children:(0,I.jsx)(z,{ref:t,..._(`fullScreen`,{style:{opacity:+!!C,pointerEvents:C?`all`:`none`,zIndex:f}}),children:(0,I.jsx)(GY,{activateOnClick:!1,...g,classNames:v,styles:y,unstyled:s,className:RY.dropzone,onDrop:e=>{u?.(e),T(),S(0)},onReject:e=>{d?.(e),T(),S(0)}})})})});qY.classes=RY,qY.displayName=`@mantine/dropzone/DropzoneFullScreen`,GY.FullScreen=qY;var JY=GY,YY=`{"resourceType": "Bundle"}`;function XY({id:e,title:t,message:n,color:r,icon:i,withCloseButton:a=!1,method:o=`show`,loading:s}){zb[o]({id:e,loading:s,title:t,message:n,color:r,icon:i,withCloseButton:a,autoClose:!1})}function ZY(){let e=Sr(),t=Z(),[n,r]=(0,b.useState)({}),i=(0,b.useCallback)(async(e,n)=>{let i=`batch-upload`;XY({id:i,title:`Batch Upload in Progress`,message:`Your batch data is being uploaded. This may take a moment...`,method:`show`,loading:!0});try{r({});let a=JSON.parse(e);a.type!==`batch`&&a.type!==`transaction`&&(a=WE(a));let o=await t.executeBatch(a);r(e=>({...e,[n]:o})),XY({id:i,title:`Batch Upload Successful`,message:`Your batch data was successfully uploaded.`,color:`green`,method:`update`,icon:(0,I.jsx)(EA,{size:`1rem`}),withCloseButton:!0})}catch(e){XY({id:i,title:`Batch Upload Failed`,color:`red`,message:Qx(e),method:`update`,icon:(0,I.jsx)(Fj,{size:`1rem`}),withCloseButton:!0})}},[t]),a=(0,b.useCallback)(async e=>{for(let t of e){let e=new FileReader;e.onload=e=>i(e.target?.result,t.name),e.readAsText(t)}},[i]),o=(0,b.useCallback)(async e=>{await i(e.input,`JSON Data`)},[i]);return(0,I.jsxs)(bP,{children:[(0,I.jsx)(q,{children:`Batch Create`}),(0,I.jsxs)(H,{children:[`Use this page to create, read, or update multiple resources. For more details, see`,` `,(0,I.jsx)(Pd,{href:`https://www.hl7.org/fhir/http.html#transaction`,children:`FHIR Batch and Transaction`}),`.`]}),Object.keys(n).length===0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`h3`,{children:`Input`}),(0,I.jsxs)(vb,{defaultValue:`upload`,children:[(0,I.jsxs)(vb.List,{children:[(0,I.jsx)(vb.Tab,{value:`upload`,children:`File Upload`}),(0,I.jsx)(vb.Tab,{value:`json`,children:`JSON`})]}),(0,I.jsx)(vb.Panel,{value:`upload`,pt:`xs`,children:(0,I.jsx)(JY,{onDrop:a,accept:[`application/json`],children:(0,I.jsxs)(V,{justify:`center`,gap:`xl`,style:{minHeight:220,pointerEvents:`none`},children:[(0,I.jsx)(JY.Accept,{children:(0,I.jsx)(Mj,{size:50,stroke:1.5,color:e.colors[e.primaryColor][5]})}),(0,I.jsx)(JY.Reject,{children:(0,I.jsx)(Fj,{size:50,stroke:1.5,color:e.colors.red[5]})}),(0,I.jsx)(JY.Idle,{children:(0,I.jsx)(Mj,{size:50,stroke:1.5})}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(H,{size:`xl`,inline:!0,children:`Drag files here or click to select files`}),(0,I.jsx)(H,{size:`sm`,color:`dimmed`,inline:!0,mt:7,children:`Attach as many files as you like`})]})]})})}),(0,I.jsx)(vb.Panel,{value:`json`,pt:`xs`,children:(0,I.jsxs)(TN,{onSubmit:o,children:[(0,I.jsx)(lh,{"data-testid":`batch-input`,name:`input`,autosize:!0,minRows:20,defaultValue:YY,deserialize:JSON.parse}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,children:(0,I.jsx)(U,{type:`submit`,children:`Submit`})})]})})]})]}),Object.keys(n).length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`h3`,{children:`Output`}),(0,I.jsxs)(vb,{defaultValue:Object.keys(n)[0],children:[(0,I.jsx)(vb.List,{children:Object.keys(n).map(e=>(0,I.jsx)(vb.Tab,{value:e,children:e},e))}),Object.keys(n).map(e=>(0,I.jsx)(vb.Panel,{value:e,children:(0,I.jsx)(`pre`,{style:{border:`1px solid #888`},children:JSON.stringify(n[e],void 0,2)})},e))]}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,wrap:`nowrap`,children:(0,I.jsx)(U,{onClick:()=>r({}),children:`Start over`})})]})]})}function QY(){let{resourceType:e}=wW(),t=(Object.fromEntries(new URLSearchParams(location.search).entries()).ids||``).split(`,`).filter(e=>!!e),[n]=Zk(`Questionnaire`,`subject-type=${e}`);return n?n.length===0?(0,I.jsxs)(bP,{children:[(0,I.jsxs)(q,{children:[`No apps for `,e]}),(0,I.jsx)(Kj,{to:`/${e}`,children:`Return to search page`})]}):(0,I.jsx)(bP,{children:(0,I.jsx)(`div`,{children:n.map(n=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{children:(0,I.jsx)(Kj,{to:`/forms/${n.id}?subject=`+t.map(t=>`${e}/${t}`).join(`,`),children:n.name})}),(0,I.jsx)(`p`,{children:n.description})]},n.id))})}):(0,I.jsx)(Rj,{})}function $Y(){return(0,I.jsx)(EP,{})}var eX=[`Form`,`JSON`,`Profiles`];function tX(){let{resourceType:e}=wW();return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(yl,{children:[(0,I.jsxs)(H,{p:`md`,fw:500,children:[`New\xA0`,e]}),(0,I.jsx)(ul,{children:(0,I.jsx)(xz,{baseUrl:`/${e}/new`,tabs:eX})})]}),(0,I.jsx)(oG,{})]})}function nX(){return(0,I.jsx)(bP,{children:(0,I.jsxs)(G,{children:[(0,I.jsx)(q,{order:1,children:`Unexpected Error`}),(0,I.jsx)(H,{children:`We're sorry, something went wrong.`}),(0,I.jsxs)(H,{children:[`Please contact `,(0,I.jsx)(Pd,{href:`mailto:support@medplum.com`,children:`support`}),` for assistance.`]})]})})}function rX(e){let t=ik(e.resource);if(!t)return null;let n=[{key:`Type`,value:(0,I.jsx)(Kj,{to:`/${t.resourceType}`,children:t.resourceType})}];function r(e,t){e&&t&&n.push({key:e,value:t})}function i(e){e&&r(e.system,e.value)}function a(e,t){Array.isArray(t)?t.forEach(t=>a(e,t)):typeof t==`string`?r(e,t):t&&(Array.isArray(t.coding)?r(e,t.coding.map(e=>e.display||e.code).join(`, `)):r(e,t.text))}if(`name`in t){let e=uC(t);e!==oC(t)&&r(`Name`,e)}return`category`in t&&a(`Category`,t.category),t.resourceType!==`Bot`&&`code`in t&&a(`Code`,t.code),`identifier`in t&&(Array.isArray(t.identifier)?t.identifier.forEach(i):i(t.identifier)),n.length===1&&n.push({key:`ID`,value:t.id}),(0,I.jsx)(yz,{children:n.map((e,t)=>(0,I.jsxs)(yz.Entry,{children:[(0,I.jsx)(yz.Key,{children:e.key}),(0,I.jsx)(yz.Value,{children:e.value})]},`${e.key}-${t}`))})}function iX(){let{id:e}=wW(),t=_W(),n=Object.fromEntries(new URLSearchParams(t.search).entries()).subject,r=Z(),[i,a]=(0,b.useState)(!0),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(),[u,d]=(0,b.useState)(),[f,p]=(0,b.useState)(),[m,h]=(0,b.useState)();if((0,b.useEffect)(()=>{let t={resourceType:`Bundle`,type:`batch`,entry:[{request:{method:`GET`,url:`Questionnaire/${e}`}}]};if(n){let e=n.split(`,`).filter(e=>!!e);e.length===1&&t.entry.push({request:{method:`GET`,url:e[0]}}),l(e)}r.executeBatch(t).then(e=>{e.entry?.[0]?.response?.status===`200`?(s(e.entry[0]?.resource),d(e.entry[1]?.resource)):p(e.entry?.[0]?.response?.outcome),a(!1)}).catch(e=>{p(e),a(!1)})},[r,e,n]),f)return(0,I.jsx)(bP,{children:(0,I.jsx)(`pre`,{"data-testid":`error`,children:JSON.stringify(f,void 0,2)})});if(m)return(0,I.jsxs)(bP,{children:[(0,I.jsx)(q,{children:o?.title}),(0,I.jsx)(`p`,{children:`Your response has been recorded.`}),(0,I.jsxs)(`ul`,{children:[m.length===1&&(0,I.jsx)(`li`,{children:(0,I.jsx)(Kj,{to:m[0],children:`Review your answers`})}),m.length>1&&(0,I.jsxs)(`li`,{children:[`Review your answers:`,(0,I.jsx)(`ul`,{children:m.map(e=>(0,I.jsx)(`li`,{children:(0,I.jsx)(Kj,{to:e,children:oC(e)})},e.id))})]}),u&&(0,I.jsx)(`li`,{children:(0,I.jsxs)(Kj,{to:u,children:[`Back to\xA0`,uC(u)]})}),(0,I.jsx)(`li`,{children:(0,I.jsx)(Kj,{to:`/`,children:`Go back home`})})]})]});if(i||!o)return(0,I.jsx)(Rj,{});let g=u&&OK(u);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(yl,{shadow:`xs`,radius:0,children:[g&&(0,I.jsx)(Hz,{patient:g}),u&&u.resourceType!==`Patient`&&(0,I.jsx)(rX,{resource:u}),(0,I.jsx)(z,{px:`xl`,py:`md`,children:(0,I.jsxs)(H,{children:[uC(o),c&&c.length>1&&(0,I.jsxs)(I.Fragment,{children:[`\xA0(for `,c.length,` resources)`]})]})})]}),(0,I.jsx)(bP,{children:(0,I.jsx)(cL,{questionnaire:o,subject:u&&aC(u),onSubmit:_})})]});async function _(e){let t=[];if(!c||c.length===0)t.push(await r.createResource(e));else for(let n of c)t.push(await r.createResource({...e,subject:{reference:n}}));h(t)}}var aX={paper:`_paper_unw9o_1`},oX={Bot:`/admin/bots/new`,ClientApplication:`/admin/clients/new`};function sX(e,t){let n=e.resourceType||cX(t),r=e.fields??lX(n),i=e.filters??(e.resourceType?void 0:uX(n)),a=e.sortRules??dX(n),o=e.offset??0,s=e.count??20;return{...e,resourceType:n,fields:r,filters:i,sortRules:a,offset:o,count:s}}function cX(e){return localStorage.getItem(`defaultResourceType`)??e?.option?.find(e=>e.id===`defaultResourceType`)?.valueString??`Patient`}function lX(e){let t=fX(e);if(t?.fields)return t.fields;let n=[`id`,`_lastUpdated`];switch(e){case`Patient`:n.push(`name`,`birthDate`,`gender`);break;case`AsyncJob`:n.push(`status`,`dataVersion`);break;case`AccessPolicy`:case`Bot`:case`ClientApplication`:case`Practitioner`:case`Project`:case`Organization`:case`Questionnaire`:case`UserConfiguration`:n.push(`name`);break;case`CodeSystem`:case`ValueSet`:n.push(`name`,`title`,`status`);break;case`Condition`:n.push(`subject`,`code`,`clinicalStatus`);break;case`Device`:n.push(`manufacturer`,`deviceName`,`patient`);break;case`DeviceDefinition`:n.push(`manufacturer[x]`,`deviceName`);break;case`DeviceRequest`:n.push(`code[x]`,`subject`);break;case`DiagnosticReport`:case`Observation`:n.push(`subject`,`code`,`status`);break;case`Encounter`:n.push(`subject`);break;case`ServiceRequest`:n.push(`subject`,`code`,`status`,`orderDetail`);break;case`Subscription`:n.push(`criteria`);break;case`User`:n.push(`email`);break}return n}function uX(e){return fX(e)?.filters}function dX(e){let t=fX(e);return t?.sortRules?t.sortRules:[{code:`_lastUpdated`,descending:!0}]}function fX(e){let t=localStorage.getItem(e+`-defaultSearch`);return t?JSON.parse(t):void 0}function pX(e){localStorage.setItem(`defaultResourceType`,e.resourceType),localStorage.setItem(e.resourceType+`-defaultSearch`,JSON.stringify(e))}async function mX(e,t){let n=sX({...e,count:1e3,offset:0},t.getUserConfiguration());return WE(await t.search(n.resourceType,cE({...n,total:`accurate`,fields:void 0})))}function hX(){let e=Z(),t=bW(),n=_W(),[r,i]=(0,b.useState)();return(0,b.useEffect)(()=>{let r=sX(ZT(n.pathname+n.search),e.getUserConfiguration());n.pathname===`/${r.resourceType}`&&n.search===cE(r)?(pX(r),i(r)):t(`/${r.resourceType}${cE(r)}`,{replace:!0})?.catch(console.error)},[e,t,n]),!r?.resourceType||!r.fields||r.fields.length===0?(0,I.jsx)(Rj,{}):(0,I.jsx)(yl,{shadow:`xs`,m:`md`,p:`xs`,className:aX.paper,children:(0,I.jsx)(lz,{checkboxesEnabled:!0,search:r,onClick:e=>t(`/${e.resource.resourceType}/${e.resource.id}`)?.catch(console.error),onAuxClick:e=>window.open(`/${e.resource.resourceType}/${e.resource.id}`,`_blank`),onChange:e=>{t(`/${r.resourceType}${cE(e.definition)}`)?.catch(console.error)},onNew:()=>{t(oX[r.resourceType]??`/${r.resourceType}/new`)?.catch(console.error)},onExportCsv:()=>{let t=e.fhirUrl(r.resourceType,`$csv`)+cE(r);e.download(t).then(e=>{window.open(window.URL.createObjectURL(e),`_blank`)}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},onExportTransactionBundle:async()=>{mX(r,e).then(e=>Gj(JSON.stringify(e,void 0,2))).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},onDelete:t=>{window.confirm(`Are you sure you want to delete these resources?`)&&(e.invalidateSearches(r.resourceType),e.executeBatch({resourceType:`Bundle`,type:`batch`,entry:t.map(e=>({request:{method:`DELETE`,url:`${r.resourceType}/${e}`}}))}).then(()=>i({...r})).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1})))},onBulk:e=>{t(`/bulk/${r.resourceType}?ids=${e.join(`,`)}`)?.catch(console.error)}})})}function gX(){let[e]=Zk(`ObservationDefinition`,`_count=100`);return e?(0,I.jsxs)(K,{withTableBorder:!0,withRowBorders:!0,withColumnBorders:!0,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:`Category`}),(0,I.jsx)(`th`,{children:`Code`}),(0,I.jsx)(`th`,{children:`Method`}),(0,I.jsx)(`th`,{children:`Unit`}),(0,I.jsx)(`th`,{children:`Precision`}),(0,I.jsx)(`th`,{children:`Ranges`})]})}),(0,I.jsx)(`tbody`,{children:e.map(e=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:(0,I.jsx)(rF,{value:e.category?.[0]})}),(0,I.jsx)(`td`,{children:(0,I.jsx)(rF,{value:e.code})}),(0,I.jsx)(`td`,{children:(0,I.jsx)(rF,{value:e.method})}),(0,I.jsx)(`td`,{children:e.quantitativeDetails?.unit?.text}),(0,I.jsx)(`td`,{children:e.quantitativeDetails?.decimalPrecision}),(0,I.jsx)(`td`,{children:(0,I.jsx)(_X,{ranges:e.qualifiedInterval})})]},e.id))})]}):(0,I.jsx)(Rj,{})}function _X(e){let{ranges:t}=e;if(!t)return null;let n=vX(t.map(e=>e.gender));if(n.length>1)return ZC(n),(0,I.jsx)(I.Fragment,{children:n.map(t=>(0,I.jsxs)(b.Fragment,{children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`strong`,{children:UC(t)})}),(0,I.jsx)(_X,{ranges:e.ranges?.filter(e=>e.gender===t)})]},t))});let r=vX(t.map(e=>e.age&&yw(e.age)));return r.length>1?(ZC(r),(0,I.jsx)(I.Fragment,{children:r.map(t=>(0,I.jsxs)(b.Fragment,{children:[(0,I.jsx)(`div`,{children:(0,I.jsx)(`strong`,{children:UC(t)})}),(0,I.jsx)(_X,{ranges:e.ranges?.filter(e=>yw(e.age)===t)})]},t))})):(0,I.jsx)(I.Fragment,{children:t.map(e=>(0,I.jsx)(`table`,{children:(0,I.jsx)(`tbody`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:e.condition}),(0,I.jsx)(`td`,{children:(0,I.jsx)(mF,{value:e.range})})]})})},`range-${e.condition}`))})}function vX(e){return[...new Set(e.filter(e=>!!e))]}function yX(){let[e]=Zk(`ActivityDefinition`,`_count=100`),[t]=Zk(`ObservationDefinition`,`_count=100`);return!e||!t?(0,I.jsx)(Rj,{}):(0,I.jsxs)(K,{withTableBorder:!0,withRowBorders:!0,withColumnBorders:!0,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:`Category`}),(0,I.jsx)(`th`,{children:`Assay`}),e.map(e=>(0,I.jsx)(`th`,{children:e.name},e.id))]})}),(0,I.jsx)(`tbody`,{children:t.map(t=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:(0,I.jsx)(rF,{value:t.category?.[0]})}),(0,I.jsx)(`td`,{children:(0,I.jsx)(rF,{value:t.code})}),e.map(e=>(0,I.jsx)(`td`,{children:e.observationResultRequirement?.find(e=>e.reference?.includes(t.id))?`✅`:``},e.id))]},t.id))})]})}function bX(){let e=Z(),[t,n]=(0,b.useState)(),[r,i]=(0,b.useState)(void 0),[a,o]=(0,b.useState)(!1),s=(0,b.useCallback)(()=>{e.get(`auth/mfa/status`,{cache:`no-cache`}).then(e=>{n(e.enrollQrCode),i(e.enrolled)}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},[e]);(0,b.useEffect)(()=>{s()},[s]);let c=(0,b.useCallback)(t=>{e.post(`auth/mfa/enroll`,t).then(()=>{i(!0),J({color:`green`,message:`Success`})}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},[e]),l=(0,b.useCallback)(async t=>e.post(`auth/mfa/disable`,{token:t.token}),[e]);return r===void 0?null:r?(0,I.jsxs)(bP,{children:[(0,I.jsx)(rg,{title:`Disable MFA`,opened:a,onClose:()=>o(!1),children:(0,I.jsx)(zP,{title:`Disable MFA`,buttonText:`Submit code`,onSubmit:async e=>{await l(e),o(!1),i(!1),J({id:`mfa-disabled`,color:`green`,title:`Success`,message:`MFA disabled`,icon:(0,I.jsx)(kA,{})}),s()}})}),(0,I.jsxs)(V,{children:[(0,I.jsx)(q,{children:`MFA is enabled`}),(0,I.jsx)(U,{onClick:()=>o(!0),children:`Disable MFA`})]})]}):(0,I.jsx)(bP,{width:400,children:(0,I.jsx)(zP,{title:`Multi Factor Auth Setup`,buttonText:`Enroll`,qrCodeUrl:t,onSubmit:c})})}var xX={baseUrl:`__MEDPLUM_BASE_URL__`,clientId:`__MEDPLUM_CLIENT_ID__`,googleClientId:`__GOOGLE_CLIENT_ID__`,recaptchaSiteKey:`__RECAPTCHA_SITE_KEY__`,registerEnabled:`__MEDPLUM_REGISTER_ENABLED__`,awsTextractEnabled:void 0};function SX(){return xX}function CX(){return TX(`registerEnabled`)}function wX(){return TX(`awsTextractEnabled`)}function TX(e){try{return xX[e]!==!1&&xX[e]!==`false`}catch{return!0}}function EX(){let e=bW(),[t]=uK(),n=Z(),r=t.get(`scope`)||`openid`,[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)(!0),c=t.get(`client_id`),l=t.get(`login`);if((0,b.useEffect)(()=>{if(!c||c===`medplum-cli`)return;async function e(){try{a(await n.get(`/auth/clientinfo/${c}`))}catch(e){J({id:`clientinfofail`,title:`Failed to retrieve client information.`,color:`red`,message:Qx(e),withCloseButton:!0})}finally{s(!1)}}e().catch(console.error)},[n,c]),!c)return null;function u(e){let n=new URL(t.get(`redirect_uri`));for(let e of[`scope`,`state`,`nonce`])t.has(e)&&n.searchParams.set(e,t.get(e));n.searchParams.set(`code`,e),LE.assign(n.toString())}return(0,I.jsx)(nF,{onCode:u,onForgotPassword:()=>e(`/resetpassword`)?.catch(console.error),onRegister:()=>e(`/register`)?.catch(console.error),googleClientId:SX().googleClientId,clientId:c||void 0,redirectUri:t.get(`redirect_uri`)||void 0,scope:r,nonce:t.get(`nonce`)||void 0,launch:t.get(`launch`)||void 0,codeChallenge:t.get(`code_challenge`)||void 0,codeChallengeMethod:t.get(`code_challenge_method`)||void 0,chooseScopes:r!==`openid`,login:l||void 0,children:!o&&(0,I.jsxs)(I.Fragment,{children:[i?.logo?.url?(0,I.jsx)(`img`,{src:i?.logo?.url,alt:`Welcome Logo`,height:60,style:{width:`auto`}}):(0,I.jsx)(xP,{size:32}),(0,I.jsx)(q,{children:i?.welcomeString??`Sign in to Medplum`})]})})}function DX(){let e=Z(),t=bW(),[n]=uK(),r=SX();return(0,b.useEffect)(()=>{e.getProfile()&&t(`/signin?project=new`)?.catch(console.error)},[e,t]),CX()?(0,I.jsxs)(JP,{type:`project`,projectId:`new`,onSuccess:()=>{window.location.href=`/`},googleClientId:r.googleClientId,recaptchaSiteKey:r.recaptchaSiteKey,login:n.get(`login`)||void 0,children:[(0,I.jsx)(xP,{size:32}),(0,I.jsx)(q,{order:3,py:`lg`,children:`Register a new account`})]}):(0,I.jsx)(bP,{width:450,children:(0,I.jsx)(Dd,{icon:(0,I.jsx)(fA,{size:16}),title:`New projects disabled`,color:`red`,children:`New projects are disabled on this server.`})})}function OX(){let e=bW(),[t]=uK(),n=SX();return(0,I.jsx)(YP,{projectId:t.get(`project`)||void 0,recaptchaSiteKey:n.recaptchaSiteKey,onSignIn:()=>e(`/signin`)?.catch(console.error),onRegister:CX()?()=>e(`/register`)?.catch(console.error):void 0})}function kX(){let{resourceType:e,id:t}=wW(),n=ik({reference:e+`/`+t}),r=bW(),i=(0,b.useCallback)(()=>{r(0)?.catch(console.error)},[r]);return n?(0,I.jsx)(bP,{maw:700,children:n.resourceType===`Patient`?(0,I.jsx)(Pz,{patient:n,onSaved:i}):(0,I.jsx)(Dd,{icon:(0,I.jsx)(fA,{size:16}),title:`Unsupported resource type`,color:`red`,children:`Account management is only supported for Patient resources`})}):null}function AX(e){let t=Z(),[n,r]=(0,b.useState)(),[i,a]=(0,b.useState)();return i?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{children:`Request group created successfully.`}),(0,I.jsxs)(`ul`,{children:[(0,I.jsxs)(`li`,{children:[`Go to the`,` `,(0,I.jsx)(Kj,{to:i,suffix:`checklist`,children:`Request Group`})]}),(0,I.jsxs)(`li`,{children:[`Back to the `,(0,I.jsx)(Kj,{to:e.planDefinition,children:`Plan Definition`})]})]})]}):(0,I.jsx)(TN,{onSubmit:()=>{t.post(t.fhirUrl(`PlanDefinition`,e.planDefinition.id,`$apply`),{resourceType:`Parameters`,parameter:[{name:`subject`,valueString:n?.reference}]}).then(a).catch(console.log)},children:(0,I.jsxs)(G,{children:[(0,I.jsxs)(q,{children:[`Start "`,e.planDefinition.title,`"`]}),(0,I.jsxs)(H,{children:[`Use the `,(0,I.jsx)(`strong`,{children:`Apply`}),` operation to create a group of tasks for a workflow.`]}),(0,I.jsx)(H,{children:`The following tasks will be created:`}),(0,I.jsx)(`ul`,{children:e.planDefinition.action?.map((e,t)=>(0,I.jsxs)(`li`,{children:[e.definitionCanonical?.startsWith(`Questionnaire/`)&&`Questionnaire request: `,e.title&&(0,I.jsx)(I.Fragment,{children:e.title}),e.code&&(0,I.jsx)(rF,{value:e.code[0]})]},`action-${t}`))}),(0,I.jsx)(MF,{title:`Subject`,children:(0,I.jsx)(uI,{name:`subject`,targetTypes:[`Patient`,`Practitioner`],defaultValue:n,onChange:r})}),(0,I.jsx)(V,{justify:`flex-end`,mt:`xl`,children:(0,I.jsx)(U,{type:`submit`,children:`Go`})})]})})}function jX(){let{resourceType:e,id:t}=wW(),n=ik({reference:e+`/`+t});return n?(0,I.jsx)(bP,{children:(0,I.jsx)(AX,{planDefinition:n})}):null}function MX(){let{resourceType:e,id:t}=wW(),n=ik({reference:e+`/`+t}),[r,i]=Zk(`Questionnaire`,`subject-type=`+e),[a,o]=Zk(`ClientApplication`,{_count:1e3});if(!n||i||o)return(0,I.jsx)(Rj,{});let s=a?.filter(t=>NX(e)&&!!t.launchUri);if((!r||r.length===0)&&(!s||s.length===0))return(0,I.jsxs)(bP,{children:[(0,I.jsx)(q,{children:`Apps`}),(0,I.jsxs)(`p`,{children:[`No apps found. Contact your administrator or `,(0,I.jsx)(`a`,{href:`mailto:support@medplum.com`,children:`Medplum Support`}),` to add automation here.`]})]});let c,l;return n.resourceType===`Patient`?c=aC(n):n.resourceType===`Encounter`&&(c=n.subject,l=aC(n)),(0,I.jsxs)(bP,{children:[r?.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(q,{order:3,children:(0,I.jsx)(Kj,{to:`/forms/${e.id}?subject=${oC(n)}`,children:e.title||e.name})}),(0,I.jsx)(H,{children:e.description})]},e.id)),s?.map(e=>(0,I.jsxs)(`div`,{children:[(0,I.jsx)(q,{order:3,children:(0,I.jsx)(CK,{client:e,patient:c,encounter:l,children:e.name})}),(0,I.jsx)(H,{children:e.description})]},e.id))]})}function NX(e){return e===`Patient`||e===`Encounter`}function PX(){let{resourceType:e,id:t}=wW(),n=bW(),[r,i]=(0,b.useState)({resourceType:`AuditEvent`,filters:[{code:`entity`,operator:X.EQUALS,value:`${e}/${t}`}],fields:[`id`,`outcome`,`outcomeDesc`,`_lastUpdated`],sortRules:[{code:`-_lastUpdated`}],count:20});return(0,I.jsx)(bP,{children:(0,I.jsx)(lz,{search:r,onClick:e=>n(`/${e.resource.resourceType}/${e.resource.id}`)?.catch(console.error),onChange:e=>i(e.definition),hideFilters:!0})})}function FX(){let e=Z(),{resourceType:t,id:n}=wW();return(0,I.jsx)(am,{maw:1200,children:(0,I.jsx)(yP,{children:(0,I.jsx)(zB,{history:e.readHistory(t,n).read()})})})}var IX={hl7Input:`_hl7Input_k5xm3_1`};function LX(e){return(0,I.jsx)(`iframe`,{title:`Bot Runner`,frameBorder:`0`,src:`https://codeeditor.medplum.com/bot-runner.html`,className:e.className,ref:e.iframeRef,"data-testid":e.testId,style:{width:`100%`,height:`100%`,minHeight:e.minHeight}})}function RX(e){let t=e.defaultValue,n=new URL(`https://codeeditor.medplum.com/${e.language}-editor.html`);return e.module&&n.searchParams.set(`module`,e.module),(0,I.jsx)(`iframe`,{title:`Code Editor`,frameBorder:`0`,src:n.toString(),style:{width:`100%`,height:`100%`,minHeight:e.minHeight},ref:e.iframeRef,"data-testid":e.testId,onLoad:e=>{Wj(e.currentTarget,{command:`setValue`,value:t}).catch(console.error)}})}var zX=`{
227
227
  "resourceType": "Patient",
228
228
  "name": [
229
229
  {
@@ -233,5 +233,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
233
233
  "family": "Smith"
234
234
  }
235
235
  ]
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-BZEDQTgb.js.map
236
+ }`,BX=`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 VX(){let e=Z(),{id:t}=wW(),[n,r]=(0,b.useState)(),[i,a]=(0,b.useState)(),[o,s]=(0,b.useState)(),[c,l]=(0,b.useState)(zX),[u,d]=(0,b.useState)(BX),[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 HX(e,t))}).catch(e=>J({color:`red`,message:Qx(e),autoClose:!1}))},[e,t]);let v=(0,b.useCallback)(async()=>Wj(m.current,{command:`getValue`}),[]),y=(0,b.useCallback)(async()=>Wj(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 Wj(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)(RX,{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)(RA,{size:`1rem`}),children:`Save`}),(0,I.jsx)(U,{type:`button`,onClick:C,loading:g,leftSection:(0,I.jsx)(MA,{size:`1rem`}),children:`Deploy`}),(0,I.jsx)(U,{type:`button`,onClick:w,loading:g,leftSection:(0,I.jsx)(pj,{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:IX.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)(LX,{iframeRef:h,className:`medplum-bot-output-frame`,testId:`output-frame`,minHeight:`200px`})})]})]})}async function HX(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 UX(e){let t=e.meta;return t&&={...t,lastUpdated:void 0,versionId:void 0,author:void 0},{...e,meta:t}}function WX(){let e=Z(),{resourceType:t,id:n}=wW(),r={reference:t+`/`+n},i=(0,b.useCallback)(t=>{e.updateResource(UX(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)(bP,{children:(0,I.jsx)(Gz,{value:r,onSubmit:i})});case`Questionnaire`:return(0,I.jsx)(bP,{children:(0,I.jsx)(nB,{questionnaire:r,onSubmit:i})});default:return null}}function GX(){let{resourceType:e,id:t}=wW(),n=ik({reference:e+`/`+t}),r=bW();return n?(0,I.jsx)(bP,{children:(0,I.jsx)(DB,{value:n,onStart:(e,t)=>r(`/forms/${sC(t)}`)?.catch(console.error),onEdit:(e,t,n)=>r(`/${n.reference}}`)?.catch(console.error)})}):null}function KX(){let e=Z(),{resourceType:t,id:n}=wW(),r=ik({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(UX({...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)(bP,{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 qX(){let e=Z(),{resourceType:t,id:n}=wW(),r=bW();return(0,I.jsxs)(bP,{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 JX={selectProfileBtn:`_selectProfileBtn_tbaz6_1`,chevron:`_chevron_tbaz6_13`};function YX(){let{resourceType:e,id:t}=wW(),n=ik({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:JX.selectProfileBtn,children:[(0,I.jsx)(`span`,{children:`Pick profile`}),(0,I.jsx)(OA,{stroke:1.5,className:JX.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)(bP,{children:(0,I.jsxs)(G,{gap:`xl`,children:[s,(0,I.jsx)(BL,{value:n,profileUrl:r})]})})}function XX(){let e=Z(),{resourceType:t,id:n}=wW(),[r,i]=(0,b.useState)(),[a,o]=(0,b.useState)(),s=bW(),[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(UX(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,NL.createPatch)(r,UX(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)(bP,{children:(0,I.jsx)(WB,{defaultValue:a,onSubmit:u,onPatch:d,onDelete:f,outcome:c})}):null}function ZX(){let{resourceType:e,id:t}=wW(),n=ik({reference:e+`/`+t});return n?(0,I.jsx)(bP,{maw:700,children:n.resourceType===`Patient`?(0,I.jsx)(zz,{patient:n}):(0,I.jsx)(Dd,{icon:(0,I.jsx)(fA,{size:16}),title:`Unsupported export type`,color:`red`,children:`This page is only supported for Patient resources`})}):null}function QX({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(PF))}).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)(Ij,{size:`90%`})}),children:t.title||t.name},t.url)})})})}function $X(e,t){let n=Z(),r=bW();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 eZ(){let{resourceType:e}=wW(),t=_W(),[n,r]=(0,b.useState)(),{defaultValue:i,handleSubmit:a}=$X(e,r),[o,s]=(0,b.useState)(),c=t.pathname.toLowerCase().endsWith(`profiles`),l=(0,b.useCallback)(e=>{let t=UX(e);o&&rw(t,o.url),a(t)},[o,a]);return c?(0,I.jsx)(bP,{children:(0,I.jsxs)(G,{children:[(0,I.jsx)(QX,{resource:i,currentProfile:o,onChange:s}),o?(0,I.jsx)(WB,{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)(bP,{children:(0,I.jsx)(WB,{defaultValue:i,onSubmit:a,outcome:n})})}function tZ(){let e=Z(),{resourceType:t,id:n}=wW();return(0,I.jsx)(bP,{children:(0,I.jsx)(GB,{history:e.readHistory(t,n).read()})})}function nZ(){let{resourceType:e}=wW(),[t,n]=(0,b.useState)(),{defaultValue:r,handleSubmit:i}=$X(e,n),a=(0,b.useCallback)(e=>{i(JSON.parse(e[`new-resource`]))},[i]);return(0,I.jsxs)(bP,{children:[t&&(0,I.jsx)(BP,{outcome:t}),(0,I.jsxs)(TN,{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 rZ(){let e=Z(),{resourceType:t,id:n}=wW(),r=ik({reference:t+`/`+n}),i=bW(),[a,o]=(0,b.useState)(),s=(0,b.useCallback)(r=>{e.updateResource(UX(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)(bP,{children:[a&&(0,I.jsx)(BP,{outcome:a}),(0,I.jsxs)(TN,{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 iZ(e){let{resourceType:t,id:n}=e;return(0,I.jsxs)(bP,{children:[(0,I.jsxs)(Dd,{icon:(0,I.jsx)(fA,{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)(cL,{questionnaire:{reference:t+`/`+n},onSubmit:()=>alert(`You submitted the preview`)})]})}var aZ={propertyTable:`_propertyTable_1xts4_1`,propertiesTitle:`_propertiesTitle_1xts4_17`};function oZ(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 sZ(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=oZ(e))}),{code:t,description:n,value:r}});return(0,I.jsxs)(K,{className:aZ.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 cZ(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)(bP,{children:(0,I.jsxs)(G,{gap:`xl`,children:[(0,I.jsx)(NN,{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)(uP,{children:[(0,I.jsx)(dP,{term:`Code`,children:i.code}),i.system&&(0,I.jsx)(dP,{term:`System`,children:i.system}),i.display&&(0,I.jsx)(dP,{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)(fA,{size:16}),title:`Lookup Failed`,color:`red`,children:[`Failed to retrieve code information: `,Qx(u)]}),!c&&!u&&m&&(0,I.jsx)(Lj,{children:(0,I.jsxs)(G,{gap:`xs`,mt:`lg`,children:[(0,I.jsx)(H,{fw:500,size:`sm`,c:`dimmed`,className:aZ.propertiesTitle,children:`Properties`}),(0,I.jsx)(sZ,{properties:p})]})})]}):null]})})}function lZ(){let{resourceType:e,id:t}=wW(),n=ik({reference:e+`/`+t});return n?n.resourceType===`Questionnaire`?(0,I.jsx)(iZ,{resourceType:e,id:t}):n.resourceType===`ValueSet`?(0,I.jsx)(cZ,{valueSet:n}):null:null}function uZ(){let e=Z(),{resourceType:t,id:n}=wW(),[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)(bP,{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)(QX,{resource:r,currentProfile:a,onChange:o}),a?(0,I.jsx)(dZ,{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 dZ=({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=UX(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)(WB,{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`})})})]})},fZ={"Create Only":`create`,"Update Only":`update`,"Delete Only":`delete`,"All Interactions":void 0},pZ=Object.keys(fZ);function mZ(){let e=Z(),{id:t}=wW(),n=ik({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=>hZ(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)(bP,{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)(pL,{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)(lI,{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:pZ,onChange:e=>o(fZ[e.target.value])})})]}),(0,I.jsx)(`div`,{style:{display:`none`},children:s})]})}function hZ(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 gZ(){let{id:e}=wW(),t=bW(),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)(bP,{children:(0,I.jsx)(lz,{search:r,onClick:e=>t(`/${e.resource.resourceType}/${e.resource.id}`)?.catch(console.error),onChange:e=>i(e.definition),hideFilters:!0,hideToolbar:!0})})}function _Z(){let e=Z(),{resourceType:t,id:n}=wW(),r=ik({reference:t+`/`+n}),i=(0,b.useCallback)(t=>{e.updateResource(UX(t)).then(()=>{J({color:`green`,message:`Success`})}).catch(e=>{J({color:`red`,message:Qx(e),autoClose:!1})})},[e]);return r?(0,I.jsx)(bP,{children:(0,I.jsx)(yB,{onSubmit:i,definition:r})}):null}function vZ(){let{resourceType:e,id:t}=wW(),n=ik({reference:e+`/`+t});return n?(0,I.jsx)(bP,{children:e===`MeasureReport`?(0,I.jsx)(Az,{measureReport:n}):(0,I.jsx)(gL,{value:n})}):null}var yZ={container:`_container_1ue98_1`,entry:`_entry_1ue98_14`,active:`_active_1ue98_21`};function bZ(e){let t=Z(),n=ik(e.value),[r,i]=(0,b.useState)();return(0,b.useEffect)(()=>{if(!n)return;let e=OK(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);WL(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:yZ.container,children:r.map(e=>(0,I.jsxs)(`div`,{className:Mn(yZ.entry,{[yZ.active]:e.id===n?.id}),children:[(0,I.jsx)(`p`,{children:(0,I.jsx)(Kj,{to:e,children:xZ(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:SZ(e)})]},e.id))}):null}function xZ(e){if(e.identifier){for(let t of e.identifier)if(t.value)return t.value}return e.id||``}function SZ(e){return e.authoredOn?e.authoredOn.substring(0,10):e.meta?.lastUpdated?e.meta.lastUpdated.substring(0,10):``}var CZ={container:`_container_1l2dh_1`};function wZ(e){let t=ik(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:CZ.container,children:(0,I.jsx)(Eg,{defaultValue:e.defaultValue,onChange:t=>e.onChange(t.currentTarget.value),data:n})})}function TZ(e){let t=ik(e.specimen);return t?(0,I.jsxs)(yz,{children:[(0,I.jsxs)(yz.Entry,{children:[(0,I.jsx)(yz.Key,{children:`Type`}),(0,I.jsx)(yz.Value,{children:`Specimen`})]}),(0,I.jsxs)(yz.Entry,{children:[(0,I.jsx)(yz.Key,{children:`Collected`}),(0,I.jsx)(yz.Value,{children:fw(t.collection?.collectedDateTime)})]}),(0,I.jsxs)(yz.Entry,{children:[(0,I.jsx)(yz.Key,{children:`Specimen Age`}),(0,I.jsx)(yz.Value,{children:EZ(t)})]}),t.collection?.collectedDateTime&&t.receivedTime?(0,I.jsxs)(yz.Entry,{children:[(0,I.jsx)(yz.Key,{children:`Specimen Stability`}),(0,I.jsx)(yz.Value,{children:DZ(t)})]}):(0,I.jsx)(I.Fragment,{})]}):null}function EZ(e){let t=e.collection?.collectedDateTime;if(t)return OZ(kZ(new Date(t),new Date))}function DZ(e){if(!(!e.collection?.collectedDateTime||!e.receivedTime))return OZ(kZ(new Date(e.collection.collectedDateTime),new Date(e.receivedTime)))}function OZ(e){return e.toString().padStart(3,`0`)+`D`}function kZ(e,t){let n=t.getTime()-e.getTime();return Math.floor(n/(1e3*3600*24))}function AZ(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 jZ(){let e=Z(),{resourceType:t,id:n}=wW(),r={reference:t+`/`+n},[i,a]=(0,b.useState)(),o=ik(r,a),s=AZ(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(UX(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)(bP,{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)(BP,{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&&OK(o),f=o&&kK(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)(wZ,{valueSet:{reference:p},defaultValue:o.orderDetail?.[0]?.text,onChange:u},oC(o)+`-`+o.orderDetail?.[0]?.text),o&&(0,I.jsx)(bZ,{value:o}),o&&(0,I.jsxs)(yl,{children:[d&&(0,I.jsx)(Hz,{patient:d}),f&&(0,I.jsx)(TZ,{specimen:f}),t!==`Patient`&&(0,I.jsx)(rX,{resource:r}),(0,I.jsx)(ul,{children:(0,I.jsx)(xz,{baseUrl:`/${t}/${n}`,tabs:s})})]}),(0,I.jsx)(oG,{})]})}function MZ(){let e=bW(),{resourceType:t,id:n,versionId:r,tab:i}=wW(),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)(Rj,{});let f=c?.entry??[],p=f.findIndex(e=>e.resource?.meta?.versionId===r);if(p===-1)return(0,I.jsxs)(bP,{children:[(0,I.jsx)(q,{children:`Version not found`}),(0,I.jsx)(Kj,{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)(yP,{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:nz,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)(uP,{compact:!0,children:[(0,I.jsx)(dP,{term:`Version ID`,children:m.meta?.versionId}),(0,I.jsx)(dP,{term:`Author`,children:(0,I.jsx)(mL,{value:m.meta?.author,link:!0},m.meta?.author?.reference)}),(0,I.jsx)(dP,{term:`Date/Time`,children:fw(m.meta?.lastUpdated)})]})}),_===`diff`&&(0,I.jsx)(VB,{original:h??{},revised:m}),_===`raw`&&(0,I.jsx)(`pre`,{style:{fontSize:`9pt`},children:JSON.stringify(m,void 0,2)})]})})})}function NZ(){let{resourceType:e,id:t}=wW(),n=bW(),[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)(bP,{children:(0,I.jsx)(lz,{search:r,onClick:e=>n(`/${e.resource.resourceType}/${e.resource.id}`)?.catch(console.error),onChange:e=>i(e.definition),hideFilters:!0})})}function PZ(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)(TN,{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)(lI,{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 FZ(){let e=Z(),t=JO(),{resourceType:n,id:r}=wW(),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)(EA,{size:`1rem`}),loading:!1,withCloseButton:!0})}).catch(e=>Ib({id:r,title:`AWS Textract Error`,color:`red`,message:Qx(e),icon:(0,I.jsx)(Fj,{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=wX()&&(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)(dj,{size:14}),onClick:()=>l(r,i),"aria-label":`Pin ${oC(r)}`,children:`Pin`}),s&&(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(fj,{size:14}),onClick:()=>u(r,i),"aria-label":`Unpin ${oC(r)}`,children:`Unpin`}),_&&(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(QA,{size:14}),onClick:()=>d(r),"aria-label":`Details ${oC(r)}`,children:`Details`}),c&&(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(QA,{size:14}),onClick:()=>h(r),"aria-label":`Details ${oC(r)}`,children:`Details`}),v&&(0,I.jsx)(W.Item,{leftSection:(0,I.jsx)(BA,{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)(_j,{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)(Aj,{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)(jj,{size:14}),onClick:()=>p(r),"aria-label":`Delete ${oC(r)}`,children:`Delete`})]})]})}return(0,I.jsxs)(I.Fragment,{children:[n===`Encounter`&&(0,I.jsx)(aR,{encounter:i,getMenu:_}),n===`Patient`&&(0,I.jsx)(Uz,{patient:i,getMenu:_}),n===`ServiceRequest`&&(0,I.jsx)(SK,{serviceRequest:i,getMenu:_}),n!==`Encounter`&&n!==`Patient`&&n!==`ServiceRequest`&&(0,I.jsx)(iR,{resource:i,getMenu:_}),(0,I.jsx)(PZ,{resource:a,opened:s[0],onClose:s[1].close},`resend-subscriptions-${a?.id}`)]})}function IZ(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||GO(`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)(Rj,{})}var LZ=[`live`,`ping`,`hl7ConnectionsOpen`,`hl7ClientCount`,`hl7QueueDepth`,`webSocketQueueDepth`,`outstandingHeartbeats`];function RZ(e){return e==null?``:typeof e==`object`?JSON.stringify(e):typeof e==`number`?e.toLocaleString():e.toString()}function zZ(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 BZ(e){let{stats:t}=e,n=new Set([...LZ,`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:[LZ.map(e=>(0,I.jsxs)(K.Tr,{children:[(0,I.jsx)(K.Td,{children:e}),(0,I.jsx)(K.Td,{children:RZ(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:RZ(t)})]},e))]})}),(0,I.jsx)(zZ,{title:`Channel Stats`,entries:t.channelStats}),(0,I.jsx)(zZ,{title:`Client Stats`,entries:t.clientStats})]})}function VZ(){let e=Z(),{id:t}=wW(),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)(EA,{size:`1rem`}),message:e})}function ie(e){J({color:`red`,title:`Error`,message:e,autoClose:!1})}return(0,I.jsxs)(bP,{children:[(0,I.jsx)(rg,{opened:O,onClose:A,title:`Upgrade Agent`,centered:!0,children:(0,I.jsx)(IZ,{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)(pL,{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)(uL,{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)(TN,{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)(BZ,{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)(TN,{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)(yj,{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 HZ(){let e=Z(),{id:t}=wW(),n=ik({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)(bP,{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)(bP,{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 UZ(){let e=bW(),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)(bP,{children:[(0,I.jsx)(q,{children:`Security`}),(0,I.jsxs)(uP,{children:[(0,I.jsx)(dP,{term:`ID`,children:(0,I.jsx)(Pd,{href:`/${oC(n.profile)}`,children:n.profile.id})}),(0,I.jsx)(dP,{term:`Resource Type`,children:n.profile.resourceType}),(0,I.jsx)(dP,{term:`Name`,children:lw(n.profile.name?.[0])})]})]}),(0,I.jsxs)(bP,{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)(bP,{children:[(0,I.jsx)(q,{children:`Password`}),(0,I.jsx)(U,{onClick:()=>e(`/changepassword`)?.catch(console.error),children:`Change password`})]}),(0,I.jsxs)(bP,{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 WZ(){let{id:e,secret:t}=wW(),n=bW();return(0,I.jsx)(XP,{id:e,secret:t,onSignIn:()=>n(`/signin`)?.catch(console.error)})}function GZ(){let e=YO(),t=bW(),[n]=uK(),r=SX(),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)(nF,{onSuccess:()=>i(),onForgotPassword:()=>t(`/resetpassword`)?.catch(console.error),onRegister:CX()?()=>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)(xP,{size:32}),n.get(`project`)!==`new`&&(0,I.jsxs)(q,{order:3,py:`lg`,ta:`center`,children:[`Sign in to `,rM()]}),n.get(`project`)===`new`&&(0,I.jsx)(q,{order:3,py:`lg`,ta:`center`,children:`Sign in again to create a new project`})]})}function KZ(){let e=bW(),t=_W(),[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)(_z,{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 qZ(){let{id:e,secret:t}=wW(),n=Z(),[r,i]=(0,b.useState)(),[a,o]=(0,b.useState)(!1);return(0,I.jsxs)(bP,{width:450,children:[(0,I.jsx)(BP,{issues:CP(r,void 0)}),(0,I.jsxs)(TN,{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)(xP,{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)(EN,{children:`Verify email`})})]}),a&&(0,I.jsxs)(`div`,{"data-testid":`success`,children:[`Email verified. You can now\xA0`,(0,I.jsx)(Kj,{to:`/signin`,children:`sign in`}),`.`]})]})]})}function JZ(){return(0,I.jsx)(cG,{children:(0,I.jsxs)($,{errorElement:(0,I.jsx)(nX,{}),children:[(0,I.jsx)($,{path:`/signin`,element:(0,I.jsx)(GZ,{})}),(0,I.jsx)($,{path:`/oauth`,element:(0,I.jsx)(EX,{})}),(0,I.jsx)($,{path:`/resetpassword`,element:(0,I.jsx)(OX,{})}),(0,I.jsx)($,{path:`/setpassword/:id/:secret`,element:(0,I.jsx)(WZ,{})}),(0,I.jsx)($,{path:`/verifyemail/:id/:secret`,element:(0,I.jsx)(qZ,{})}),(0,I.jsx)($,{path:`/register`,element:(0,I.jsx)(DX,{})}),(0,I.jsx)($,{path:`/changepassword`,element:(0,I.jsx)($Y,{})}),(0,I.jsx)($,{path:`/security`,element:(0,I.jsx)(UZ,{})}),(0,I.jsx)($,{path:`/mfa`,element:(0,I.jsx)(bX,{})}),(0,I.jsx)($,{path:`/batch`,element:(0,I.jsx)(ZY,{})}),(0,I.jsx)($,{path:`/bulk/:resourceType`,element:(0,I.jsx)(QY,{})}),(0,I.jsx)($,{path:`/smart`,element:(0,I.jsx)(KZ,{})}),(0,I.jsx)($,{path:`/forms/:id`,element:(0,I.jsx)(iX,{})}),(0,I.jsx)($,{path:`/admin/super`,element:(0,I.jsx)(Xq,{})}),(0,I.jsx)($,{path:`/admin/super/asyncjob/:tab`,element:(0,I.jsx)(Iq,{})}),(0,I.jsx)($,{path:`/admin/super/asyncjob`,element:(0,I.jsx)(Iq,{})}),(0,I.jsx)($,{path:`/admin/super/db/:tab`,element:(0,I.jsx)(cq,{})}),(0,I.jsx)($,{path:`/admin/super/db`,element:(0,I.jsx)(cq,{})}),(0,I.jsx)($,{path:`/admin/config`,element:(0,I.jsx)(mq,{})}),(0,I.jsxs)($,{path:`/admin`,element:(0,I.jsx)(_q,{}),children:[(0,I.jsx)($,{path:`bots/:membershipId`,element:(0,I.jsx)(uq,{})}),(0,I.jsx)($,{path:`bots/new`,element:(0,I.jsx)(FK,{})}),(0,I.jsx)($,{path:`bots`,element:(0,I.jsx)(MK,{})}),(0,I.jsx)($,{path:`clients/:membershipId`,element:(0,I.jsx)(uq,{})}),(0,I.jsx)($,{path:`clients/new`,element:(0,I.jsx)(IK,{})}),(0,I.jsx)($,{path:`clients`,element:(0,I.jsx)(NK,{})}),(0,I.jsx)($,{path:`details`,element:(0,I.jsx)(hq,{})}),(0,I.jsx)($,{path:`invite`,element:(0,I.jsx)(lq,{})}),(0,I.jsx)($,{path:`patients`,element:(0,I.jsx)(aG,{to:`/admin/users`,replace:!0})}),(0,I.jsx)($,{path:`users/:membershipId`,element:(0,I.jsx)(uq,{})}),(0,I.jsx)($,{path:`users`,element:(0,I.jsx)(tJ,{})}),(0,I.jsx)($,{path:`project`,element:(0,I.jsx)(hq,{})}),(0,I.jsx)($,{path:`secrets`,element:(0,I.jsx)(Mq,{})}),(0,I.jsx)($,{path:`settings`,element:(0,I.jsx)(Nq,{})}),(0,I.jsx)($,{path:`sites`,element:(0,I.jsx)(Pq,{})}),(0,I.jsx)($,{path:`rate-limits`,element:(0,I.jsx)(Oq,{})})]}),(0,I.jsx)($,{path:`/lab/assays`,element:(0,I.jsx)(gX,{})}),(0,I.jsx)($,{path:`/lab/panels`,element:(0,I.jsx)(yX,{})}),(0,I.jsxs)($,{path:`/:resourceType/new`,element:(0,I.jsx)(tX,{}),children:[(0,I.jsx)($,{index:!0,element:(0,I.jsx)(eZ,{})}),(0,I.jsx)($,{path:`form`,element:(0,I.jsx)(eZ,{})}),(0,I.jsx)($,{path:`json`,element:(0,I.jsx)(nZ,{})}),(0,I.jsx)($,{path:`profiles`,element:(0,I.jsx)(eZ,{})})]}),(0,I.jsxs)($,{path:`/:resourceType/:id`,element:(0,I.jsx)(jZ,{}),children:[(0,I.jsx)($,{index:!0,element:(0,I.jsx)(FZ,{})}),(0,I.jsx)($,{path:`apply`,element:(0,I.jsx)(jX,{})}),(0,I.jsx)($,{path:`apps`,element:(0,I.jsx)(MX,{})}),(0,I.jsx)($,{path:`event`,element:(0,I.jsx)(PX,{})}),(0,I.jsx)($,{path:`blame`,element:(0,I.jsx)(FX,{})}),(0,I.jsx)($,{path:`bots`,element:(0,I.jsx)(mZ,{})}),(0,I.jsx)($,{path:`builder`,element:(0,I.jsx)(WX,{})}),(0,I.jsx)($,{path:`checklist`,element:(0,I.jsx)(GX,{})}),(0,I.jsx)($,{path:`delete`,element:(0,I.jsx)(qX,{})}),(0,I.jsx)($,{path:`details`,element:(0,I.jsx)(YX,{})}),(0,I.jsx)($,{path:`edit`,element:(0,I.jsx)(XX,{})}),(0,I.jsx)($,{path:`editor`,element:(0,I.jsx)(VX,{})}),(0,I.jsxs)($,{path:`history`,children:[(0,I.jsx)($,{index:!0,element:(0,I.jsx)(tZ,{})}),(0,I.jsx)($,{path:`:versionId/:tab`,element:(0,I.jsx)(MZ,{})}),(0,I.jsx)($,{path:`:versionId`,element:(0,I.jsx)(MZ,{})})]}),(0,I.jsxs)($,{path:`_history`,children:[(0,I.jsx)($,{index:!0,element:(0,I.jsx)(tZ,{})}),(0,I.jsx)($,{path:`:versionId/:tab`,element:(0,I.jsx)(MZ,{})}),(0,I.jsx)($,{path:`:versionId`,element:(0,I.jsx)(MZ,{})})]}),(0,I.jsx)($,{path:`json`,element:(0,I.jsx)(rZ,{})}),(0,I.jsx)($,{path:`preview`,element:(0,I.jsx)(lZ,{})}),(0,I.jsx)($,{path:`responses`,element:(0,I.jsx)(gZ,{})}),(0,I.jsx)($,{path:`report`,element:(0,I.jsx)(vZ,{})}),(0,I.jsx)($,{path:`ranges`,element:(0,I.jsx)(_Z,{})}),(0,I.jsx)($,{path:`subscriptions`,element:(0,I.jsx)(NZ,{})}),(0,I.jsx)($,{path:`timeline`,element:(0,I.jsx)(FZ,{})}),(0,I.jsx)($,{path:`tools`,element:(0,I.jsx)(VZ,{})}),(0,I.jsx)($,{path:`email`,element:(0,I.jsx)(HZ,{})}),(0,I.jsx)($,{path:`payload`,element:(0,I.jsx)(KX,{})}),(0,I.jsx)($,{path:`profiles`,element:(0,I.jsx)(uZ,{})}),(0,I.jsx)($,{path:`accounts`,element:(0,I.jsx)(kX,{})}),(0,I.jsx)($,{path:`export`,element:(0,I.jsx)(ZX,{})})]}),(0,I.jsx)($,{path:`/:resourceType`,element:(0,I.jsx)(hX,{})}),(0,I.jsx)($,{path:`/`,element:(0,I.jsx)(hX,{})})]})})}function YZ(){let e=Z(),t=e.getUserConfiguration(),n=_W(),[r]=uK();return e.isLoading()?(0,I.jsx)(Rj,{}):(0,I.jsxs)(nP,{logo:(0,I.jsx)(xP,{size:24}),pathname:n.pathname,searchParams:r,version:BD,menus:XZ(t),displayAddBookmark:!!t?.id,children:[(0,I.jsx)(xK,{}),(0,I.jsx)(b.Suspense,{fallback:(0,I.jsx)(Rj,{}),children:(0,I.jsx)(JZ,{})})]})}function XZ(e){let t=e?.menu?.map(e=>({title:e.title,links:e.link?.map(e=>({label:e.name,href:e.target,icon:QZ(e.target)}))||[]}))||[];return t.push({title:`Settings`,links:[{label:`Security`,href:`/security`,icon:(0,I.jsx)(ej,{})}]}),t}var ZZ={Patient:Tj,Practitioner:XA,Organization:wA,ServiceRequest:hj,DiagnosticReport:vj,Questionnaire:YA,Project:JA,admin:bA,AccessPolicy:$A,Subscription:Pj,batch:cj,Observation:aj};function QZ(e){if(e.includes(`admin/super/db`))return(0,I.jsx)(IA,{});try{let t=new URL(e,`https://app.medplum.com`).pathname.split(`/`)[1];if(t in ZZ){let e=ZZ[t];return(0,I.jsx)(e,{})}}catch{}}async function $Z(){let e=SX(),t=new QD({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=ZG([{path:`*`,element:(0,I.jsx)(YZ,{})}]);(0,DK.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(b.StrictMode,{children:(0,I.jsx)(ZO,{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)(tG,{router:r})]})})}))}$Z().catch(console.error);
237
+ //# sourceMappingURL=index-D7StjELE.js.map