@medplum/react 5.1.30 → 5.1.32

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.
@@ -1,4 +1,4 @@
1
- var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);export*from"@medplum/react-hooks";import{formatAddress}from"@medplum/core";import{Fragment,jsx}from"react/jsx-runtime";function AddressDisplay(props){let address=props.value;return address?jsx(Fragment,{children:formatAddress(address,props.options)}):null}import{Group,NativeSelect,TextInput}from"@mantine/core";import{trimTrailingEmptyElements}from"@medplum/core";import{useContext,useMemo,useState}from"react";import{isPopulated}from"@medplum/core";import{createContext}from"react";var DEFAULT_IGNORED_PROPERTIES=["meta","implicitRules","contained","extension","modifierExtension"],DEFAULT_IGNORED_NON_NESTED_PROPERTIES=["language","text"];var ElementsContext=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});ElementsContext.displayName="ElementsContext";var EXTENSION_KEYS=["extension","modifierExtension"],IGNORED_PROPERTIES=["id",...DEFAULT_IGNORED_PROPERTIES].filter(prop=>!EXTENSION_KEYS.includes(prop));function getElementsToRender(inputElements){return Object.entries(inputElements).filter(([key,element])=>!isPopulated(element.type)||element.max===0||element.path.toLowerCase().endsWith("extension.url")&&element.fixed||EXTENSION_KEYS.includes(key)&&!isPopulated(element.slicing?.slices)||IGNORED_PROPERTIES.includes(key)?!1:!(DEFAULT_IGNORED_NON_NESTED_PROPERTIES.includes(key)&&element.path.split(".").length===2||key.includes(".")))}import{jsx as jsx2,jsxs}from"react/jsx-runtime";function getLine(address,index){return address.line&&address.line.length>index?address.line[index]:""}function setLine(address,index,str){let line=address.line||[];for(;line.length<=index;)line.push("");return line[index]=str,{...address,line:trimTrailingEmptyElements(line)}}function AddressInput(props){let[value,setValue]=useState(props.defaultValue||{}),{getExtendedProps}=useContext(ElementsContext),[useProps,typeProps,line1Props,line2Props,cityProps,stateProps,postalCodeProps]=useMemo(()=>["use","type","line1","line2","city","state","postalCode"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(prevValue=>({...prevValue,...newValue})),props.onChange&&props.onChange({...value,...newValue})}function setUse(use){setValueWrapper({use})}function setType(type){setValueWrapper({type})}function setLine1(line1){setValueWrapper(setLine(value,0,line1))}function setLine2(line2){setValueWrapper(setLine(value,1,line2))}function setCity(city){setValueWrapper({city})}function setState(state){setValueWrapper({state})}function setPostalCode(postalCode){setValueWrapper({postalCode})}return jsxs(Group,{gap:"xs",wrap:"nowrap",grow:!0,children:[jsx2(NativeSelect,{disabled:props.disabled||useProps?.readonly,"data-testid":"address-use",defaultValue:value.use,onChange:e=>setUse(e.currentTarget.value),data:["","home","work","temp","old","billing"]}),jsx2(NativeSelect,{disabled:props.disabled||typeProps?.readonly,"data-testid":"address-type",defaultValue:value.type,onChange:e=>setType(e.currentTarget.value),data:["","postal","physical","both"]}),jsx2(TextInput,{disabled:props.disabled||line1Props?.readonly,placeholder:"Line 1",defaultValue:getLine(value,0),onChange:e=>setLine1(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||line2Props?.readonly,placeholder:"Line 2",defaultValue:getLine(value,1),onChange:e=>setLine2(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||cityProps?.readonly,placeholder:"City",defaultValue:value.city,onChange:e=>setCity(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||stateProps?.readonly,placeholder:"State",defaultValue:value.state,onChange:e=>setState(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||postalCodeProps?.readonly,placeholder:"Postal Code",defaultValue:value.postalCode,onChange:e=>setPostalCode(e.currentTarget.value)})]})}import{TextInput as TextInput2}from"@mantine/core";import{createReference}from"@medplum/core";import{useMedplumProfile}from"@medplum/react-hooks";import{useState as useState2}from"react";import{jsx as jsx3}from"react/jsx-runtime";function AnnotationInput(props){let author=useMedplumProfile(),[value,setValue]=useState2(props.defaultValue||{});function setText(text){let newValue=text?{text,authorReference:author&&createReference(author),time:new Date().toISOString()}:{};setValue(newValue),props.onChange&&props.onChange(newValue)}return jsx3(TextInput2,{disabled:props.disabled,name:props.name,placeholder:"Annotation text",defaultValue:value.text,onChange:e=>setText(e.currentTarget.value)})}import{AppShell as MantineAppShell3}from"@mantine/core";import{useMedplum as useMedplum7,useMedplumProfile as useMedplumProfile4}from"@medplum/react-hooks";import{Suspense,useState as useState12}from"react";import{Alert}from"@mantine/core";import{locationUtils,normalizeErrorString}from"@medplum/core";import{forwardRef,createElement}from"react";var defaultAttributes={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"}};var createReactComponent=(type,iconName,iconNamePascal,iconNode)=>{let Component2=forwardRef(({color="currentColor",size=24,stroke=2,title,className,children,...rest},ref)=>createElement("svg",{ref,...defaultAttributes[type],width:size,height:size,className:["tabler-icon",`tabler-icon-${iconName}`,className].join(" "),...type==="filled"?{fill:color}:{strokeWidth:stroke,stroke:color},...rest},[title&&createElement("title",{key:"svg-title"},title),...iconNode.map(([tag,attrs])=>createElement(tag,attrs)),...Array.isArray(children)?children:[children]]));return Component2.displayName=`${iconNamePascal}`,Component2};var __iconNode=[["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"}]],IconAdjustmentsHorizontal=createReactComponent("outline","adjustments-horizontal","AdjustmentsHorizontal",__iconNode);var __iconNode2=[["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"}]],IconAlertCircle=createReactComponent("outline","alert-circle","AlertCircle",__iconNode2);var __iconNode3=[["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"}]],IconArrowDown=createReactComponent("outline","arrow-down","ArrowDown",__iconNode3);var __iconNode4=[["path",{d:"M5 12l14 0",key:"svg-0"}],["path",{d:"M13 18l6 -6",key:"svg-1"}],["path",{d:"M13 6l6 6",key:"svg-2"}]],IconArrowRight=createReactComponent("outline","arrow-right","ArrowRight",__iconNode4);var __iconNode5=[["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"}]],IconArrowUp=createReactComponent("outline","arrow-up","ArrowUp",__iconNode5);var __iconNode6=[["path",{d:"M6 20a2 2 0 1 0 -4 0a2 2 0 0 0 4 0",key:"svg-0"}],["path",{d:"M16 4a2 2 0 1 0 -4 0a2 2 0 0 0 4 0",key:"svg-1"}],["path",{d:"M16 20a2 2 0 1 0 -4 0a2 2 0 0 0 4 0",key:"svg-2"}],["path",{d:"M11 12a2 2 0 1 0 -4 0a2 2 0 0 0 4 0",key:"svg-3"}],["path",{d:"M21 12a2 2 0 1 0 -4 0a2 2 0 0 0 4 0",key:"svg-4"}],["path",{d:"M5.058 18.306l2.88 -4.606",key:"svg-5"}],["path",{d:"M10.061 10.303l2.877 -4.604",key:"svg-6"}],["path",{d:"M10.065 13.705l2.876 4.6",key:"svg-7"}],["path",{d:"M15.063 5.7l2.881 4.61",key:"svg-8"}]],IconBinaryTree=createReactComponent("outline","binary-tree","BinaryTree",__iconNode6);var __iconNode7=[["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"}]],IconBleachOff=createReactComponent("outline","bleach-off","BleachOff",__iconNode7);var __iconNode8=[["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"}]],IconBleach=createReactComponent("outline","bleach","Bleach",__iconNode8);var __iconNode9=[["path",{d:"M18 7v14l-6 -4l-6 4v-14a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4",key:"svg-0"}]],IconBookmark=createReactComponent("outline","bookmark","Bookmark",__iconNode9);var __iconNode10=[["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"}]],IconBoxMultiple=createReactComponent("outline","box-multiple","BoxMultiple",__iconNode10);var __iconNode11=[["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"}]],IconBracketsContain=createReactComponent("outline","brackets-contain","BracketsContain",__iconNode11);var __iconNode12=[["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"}]],IconBriefcase=createReactComponent("outline","briefcase","Briefcase",__iconNode12);var __iconNode13=[["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"}]],IconBucketOff=createReactComponent("outline","bucket-off","BucketOff",__iconNode13);var __iconNode14=[["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"}]],IconBucket=createReactComponent("outline","bucket","Bucket",__iconNode14);var __iconNode15=[["path",{d:"M3 20h18v-8a3 3 0 0 0 -3 -3h-12a3 3 0 0 0 -3 3v8",key:"svg-0"}],["path",{d:"M3 14.803c.312 .135 .654 .204 1 .197a2.4 2.4 0 0 0 2 -1a2.4 2.4 0 0 1 2 -1a2.4 2.4 0 0 1 2 1a2.4 2.4 0 0 0 2 1a2.4 2.4 0 0 0 2 -1a2.4 2.4 0 0 1 2 -1a2.4 2.4 0 0 1 2 1a2.4 2.4 0 0 0 2 1c.35 .007 .692 -.062 1 -.197",key:"svg-1"}],["path",{d:"M12 4l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737",key:"svg-2"}]],IconCake=createReactComponent("outline","cake","Cake",__iconNode15);var __iconNode16=[["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"}]],IconCalendar=createReactComponent("outline","calendar","Calendar",__iconNode16);var __iconNode17=[["path",{d:"M5 12l5 5l10 -10",key:"svg-0"}]],IconCheck=createReactComponent("outline","check","Check",__iconNode17);var __iconNode18=[["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"}]],IconCheckbox=createReactComponent("outline","checkbox","Checkbox",__iconNode18);var __iconNode19=[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]],IconChevronDown=createReactComponent("outline","chevron-down","ChevronDown",__iconNode19);var __iconNode20=[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]],IconChevronRight=createReactComponent("outline","chevron-right","ChevronRight",__iconNode20);var __iconNode21=[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]],IconChevronUp=createReactComponent("outline","chevron-up","ChevronUp",__iconNode21);var __iconNode22=[["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"}]],IconCircleMinus=createReactComponent("outline","circle-minus","CircleMinus",__iconNode22);var __iconNode23=[["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"}]],IconCirclePlus=createReactComponent("outline","circle-plus","CirclePlus",__iconNode23);var __iconNode24=[["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"}]],IconCloudUpload=createReactComponent("outline","cloud-upload","CloudUpload",__iconNode24);var __iconNode25=[["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"}]],IconColumns=createReactComponent("outline","columns","Columns",__iconNode25);var __iconNode26=[["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"}]],IconCopy=createReactComponent("outline","copy","Copy",__iconNode26);var __iconNode27=[["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"}]],IconCurrencyDollar=createReactComponent("outline","currency-dollar","CurrencyDollar",__iconNode27);var __iconNode28=[["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"}]],IconDeviceDesktop=createReactComponent("outline","device-desktop","DeviceDesktop",__iconNode28);var __iconNode29=[["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"}]],IconDots=createReactComponent("outline","dots","Dots",__iconNode29);var __iconNode30=[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 11l5 5l5 -5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]],IconDownload=createReactComponent("outline","download","Download",__iconNode30);var __iconNode31=[["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"}]],IconEdit=createReactComponent("outline","edit","Edit",__iconNode31);var __iconNode32=[["path",{d:"M9.5 5.5a2.5 2.5 0 1 0 5 0a2.5 2.5 0 1 0 -5 0",key:"svg-0"}],["path",{d:"M12 21.368l5.095 -5.096a3.088 3.088 0 1 0 -4.367 -4.367l-.728 .727l-.728 -.727a3.088 3.088 0 1 0 -4.367 4.367l5.095 5.096",key:"svg-1"}]],IconEmpathize=createReactComponent("outline","empathize","Empathize",__iconNode32);var __iconNode33=[["path",{d:"M5 10h14",key:"svg-0"}],["path",{d:"M5 14h14",key:"svg-1"}],["path",{d:"M5 19l14 -14",key:"svg-2"}]],IconEqualNot=createReactComponent("outline","equal-not","EqualNot",__iconNode33);var __iconNode34=[["path",{d:"M5 10h14",key:"svg-0"}],["path",{d:"M5 14h14",key:"svg-1"}]],IconEqual=createReactComponent("outline","equal","Equal",__iconNode34);var __iconNode35=[["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"}]],IconEyeOff=createReactComponent("outline","eye-off","EyeOff",__iconNode35);var __iconNode36=[["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"}]],IconEye=createReactComponent("outline","eye","Eye",__iconNode36);var __iconNode37=[["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"}]],IconFileAlert=createReactComponent("outline","file-alert","FileAlert",__iconNode37);var __iconNode38=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M11.5 21h-4.5a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v5m-5 6h7m-3 -3l3 3l-3 3",key:"svg-1"}]],IconFileExport=createReactComponent("outline","file-export","FileExport",__iconNode38);var __iconNode39=[["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"}]],IconFilePlus=createReactComponent("outline","file-plus","FilePlus",__iconNode39);var __iconNode40=[["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:"M9 9l1 0",key:"svg-2"}],["path",{d:"M9 13l6 0",key:"svg-3"}],["path",{d:"M9 17l6 0",key:"svg-4"}]],IconFileText=createReactComponent("outline","file-text","FileText",__iconNode40);var __iconNode41=[["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"}]],IconFilter=createReactComponent("outline","filter","Filter",__iconNode41);var __iconNode42=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 9h.01",key:"svg-1"}],["path",{d:"M11 12h1v4h1",key:"svg-2"}]],IconInfoCircle=createReactComponent("outline","info-circle","InfoCircle",__iconNode42);var __iconNode43=[["path",{d:"M9 6.371c0 4.418 -2.239 6.629 -5 6.629",key:"svg-0"}],["path",{d:"M4 6.371h7",key:"svg-1"}],["path",{d:"M5 9c0 2.144 2.252 3.908 6 4",key:"svg-2"}],["path",{d:"M12 20l4 -9l4 9",key:"svg-3"}],["path",{d:"M19.1 18h-6.2",key:"svg-4"}],["path",{d:"M6.694 3l.793 .582",key:"svg-5"}]],IconLanguage=createReactComponent("outline","language","Language",__iconNode43);var __iconNode44=[["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"}]],IconLayoutSidebar=createReactComponent("outline","layout-sidebar","LayoutSidebar",__iconNode44);var __iconNode45=[["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"}]],IconLogout=createReactComponent("outline","logout","Logout",__iconNode45);var __iconNode46=[["path",{d:"M9 11a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-0"}],["path",{d:"M17.657 16.657l-4.243 4.243a2 2 0 0 1 -2.827 0l-4.244 -4.243a8 8 0 1 1 11.314 0",key:"svg-1"}]],IconMapPin=createReactComponent("outline","map-pin","MapPin",__iconNode46);var __iconNode47=[["path",{d:"M5 18l14 -6l-14 -6",key:"svg-0"}]],IconMathGreater=createReactComponent("outline","math-greater","MathGreater",__iconNode47);var __iconNode48=[["path",{d:"M19 18l-14 -6l14 -6",key:"svg-0"}]],IconMathLower=createReactComponent("outline","math-lower","MathLower",__iconNode48);var __iconNode49=[["path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1",key:"svg-0"}]],IconMessageCircle=createReactComponent("outline","message-circle","MessageCircle",__iconNode49);var __iconNode50=[["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"}]],IconMessage=createReactComponent("outline","message","Message",__iconNode50);var __iconNode51=[["path",{d:"M9 5a3 3 0 0 1 3 -3a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3a3 3 0 0 1 -3 -3l0 -5",key:"svg-0"}],["path",{d:"M5 10a7 7 0 0 0 14 0",key:"svg-1"}],["path",{d:"M8 21l8 0",key:"svg-2"}],["path",{d:"M12 17l0 4",key:"svg-3"}]],IconMicrophone=createReactComponent("outline","microphone","Microphone",__iconNode51);var __iconNode52=[["path",{d:"M5 12l14 0",key:"svg-0"}]],IconMinus=createReactComponent("outline","minus","Minus",__iconNode52);var __iconNode53=[["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"}]],IconMoon=createReactComponent("outline","moon","Moon",__iconNode53);var __iconNode54=[["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"}]],IconPalette=createReactComponent("outline","palette","Palette",__iconNode54);var __iconNode55=[["path",{d:"M15 7l-6.5 6.5a1.5 1.5 0 0 0 3 3l6.5 -6.5a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9l6.5 -6.5",key:"svg-0"}]],IconPaperclip=createReactComponent("outline","paperclip","Paperclip",__iconNode55);var __iconNode56=[["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"}]],IconPencil=createReactComponent("outline","pencil","Pencil",__iconNode56);var __iconNode57=[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]],IconPlus=createReactComponent("outline","plus","Plus",__iconNode57);var __iconNode58=[["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"}]],IconRefresh=createReactComponent("outline","refresh","Refresh",__iconNode58);var __iconNode59=[["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"}]],IconSearch=createReactComponent("outline","search","Search",__iconNode59);var __iconNode60=[["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"}]],IconSettings=createReactComponent("outline","settings","Settings",__iconNode60);var __iconNode61=[["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"}]],IconSortAscending=createReactComponent("outline","sort-ascending","SortAscending",__iconNode61);var __iconNode62=[["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"}]],IconSortDescending=createReactComponent("outline","sort-descending","SortDescending",__iconNode62);var __iconNode63=[["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"}]],IconSquare=createReactComponent("outline","square","Square",__iconNode63);var __iconNode64=[["path",{d:"M6 4h-1a2 2 0 0 0 -2 2v3.5a5.5 5.5 0 0 0 11 0v-3.5a2 2 0 0 0 -2 -2h-1",key:"svg-0"}],["path",{d:"M8 15a6 6 0 1 0 12 0v-3",key:"svg-1"}],["path",{d:"M11 3v2",key:"svg-2"}],["path",{d:"M6 3v2",key:"svg-3"}],["path",{d:"M18 10a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-4"}]],IconStethoscope=createReactComponent("outline","stethoscope","Stethoscope",__iconNode64);var __iconNode65=[["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"}]],IconSunHigh=createReactComponent("outline","sun-high","SunHigh",__iconNode65);var __iconNode66=[["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"}]],IconSwitchHorizontal=createReactComponent("outline","switch-horizontal","SwitchHorizontal",__iconNode66);var __iconNode67=[["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"}]],IconTableExport=createReactComponent("outline","table-export","TableExport",__iconNode67);var __iconNode68=[["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"}]],IconTable=createReactComponent("outline","table","Table",__iconNode68);var __iconNode69=[["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"}]],IconTrash=createReactComponent("outline","trash","Trash",__iconNode69);var __iconNode70=[["path",{d:"M5 7a4 4 0 1 0 8 0a4 4 0 1 0 -8 0",key:"svg-0"}],["path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2",key:"svg-1"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"svg-2"}],["path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85",key:"svg-3"}]],IconUsers=createReactComponent("outline","users","Users",__iconNode70);var __iconNode71=[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]],IconX=createReactComponent("outline","x","X",__iconNode71);var __iconNode72=[["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"}]],IconCircleFilled=createReactComponent("filled","circle-filled","CircleFilled",__iconNode72);import{Component}from"react";import{jsx as jsx4}from"react/jsx-runtime";var ErrorBoundary=class extends Component{constructor(props){super(props);__publicField(this,"state");this.state={lastLocation:locationUtils.getLocation()}}static getDerivedStateFromError(error){return{error,lastLocation:locationUtils.getLocation()}}componentDidUpdate(_prevProps,_prevState){locationUtils.getLocation()!==this.state.lastLocation&&this.setState({lastLocation:locationUtils.getLocation(),error:void 0})}shouldComponentUpdate(nextProps,nextState){return!!(this.props.children!==nextProps.children||nextState.error&&!this.state.error||this.state.lastLocation!==locationUtils.getLocation())}componentDidCatch(error,errorInfo){console.error("Uncaught error:",error,errorInfo)}render(){return this.state.error?jsx4(Alert,{icon:jsx4(IconAlertCircle,{size:16}),title:"Something went wrong",color:"red",children:normalizeErrorString(this.state.error)}):this.props.children}};import{Center,Loader}from"@mantine/core";import{jsx as jsx5}from"react/jsx-runtime";function Loading(){return jsx5(Center,{style:{width:"100%",height:"100vh"},children:jsx5(Loader,{})})}import{Box,CloseButton,Group as Group2,Text}from"@mantine/core";var AppShell_default={main:"AppShell_main",announcement:"AppShell_announcement"};import{Fragment as Fragment2,jsx as jsx6,jsxs as jsxs2}from"react/jsx-runtime";function AnnouncementBanners(props){return jsx6(Fragment2,{children:props.announcements.map((announcement,index)=>jsx6(Box,{className:AppShell_default.announcement,style:{backgroundColor:`var(--mantine-color-${announcement.color??"yellow"}-light)`,color:`var(--mantine-color-${announcement.color??"yellow"}-light-color)`},role:announcement.role??"status",children:jsxs2(Group2,{gap:"xs",wrap:"nowrap",h:"100%",px:"md",children:[announcement.icon,jsx6(Text,{size:"sm",fw:500,truncate:!0,children:announcement.message}),announcement.dismissible&&jsx6(CloseButton,{size:"sm",variant:"subtle","aria-label":"Dismiss announcement",onClick:()=>props.onDismiss(announcement),ml:"auto"})]})},announcement.id??index))})}import{Box as Box4,Group as Group6,AppShell as MantineAppShell,Menu as Menu2,Stack,Text as Text5,UnstyledButton}from"@mantine/core";import{formatHumanName as formatHumanName3}from"@medplum/core";import{useMedplum as useMedplum2,useMedplumProfile as useMedplumProfile2}from"@medplum/react-hooks";import{useState as useState5}from"react";import{Avatar}from"@mantine/core";import{getDisplayString,getImageSrc}from"@medplum/core";import{useCachedBinaryUrl,useResource}from"@medplum/react-hooks";import{Anchor}from"@mantine/core";import{isReference,isResource}from"@medplum/core";import{useMedplumNavigate}from"@medplum/react-hooks";import{ContentType}from"@medplum/core";function killEvent(e){e.preventDefault(),e.stopPropagation()}function isAuxClick(e){return e.button===1||e.ctrlKey||e.metaKey}function isCheckboxCell(el){if(isCheckboxElement(el))return!0;if(el instanceof HTMLTableCellElement){let children=el.children;if(children.length===1&&isCheckboxElement(children[0]))return!0}return!1}function isCheckboxElement(el){return el instanceof HTMLInputElement&&el.type==="checkbox"}async function sendCommand(frame,command){return new Promise((resolve,reject)=>{let channel=new MessageChannel;channel.port1.onmessage=({data:data2})=>{channel.port1.close(),data2.error?reject(data2.error):resolve(data2.result)},frame.contentWindow?.postMessage(command,new URL(frame.src).origin,[channel.port2])})}function exportJsonFile(jsonString,fileName){let blobForExport=new Blob([jsonString],{type:ContentType.JSON}),url=URL.createObjectURL(blobForExport),link=document.createElement("a");link.href=url;let linkName=fileName??new Date().toISOString().replaceAll(/\D/g,"");link.download=`${linkName}.json`,document.body.appendChild(link),link.click(),URL.revokeObjectURL(url)}import{jsx as jsx7}from"react/jsx-runtime";function MedplumLink(props){let navigate=useMedplumNavigate(),{to,suffix,label,onClick,children,...rest}=props,href=getHref(to);return suffix&&(href+="/"+suffix),jsx7(Anchor,{href,"aria-label":label,onAuxClick:e=>{e.stopPropagation()},onClick:e=>{e.stopPropagation(),onClick?(e.preventDefault(),onClick(e)):to&&(isAuxClick(e)||(e.preventDefault(),navigate(href)))},...rest,children})}function getHref(to){if(to){if(typeof to=="string")return getStringHref(to);if(isResource(to))return getResourceHref(to);if(isReference(to))return getReferenceHref(to)}return"#"}function getStringHref(to){return to.startsWith("http://")||to.startsWith("https://")||to.startsWith("/")?to:"/"+to}function getResourceHref(to){return`/${to.resourceType}/${to.id}`}function getReferenceHref(to){return`/${to.reference}`}function getInitials(input){let words=input.split(" ").filter(Boolean);return words.length>1?words[0][0]+words.at(-1)?.at(0):words.length===1?words[0][0]:""}import{jsx as jsx8}from"react/jsx-runtime";function ResourceAvatar(props){let resource=useResource(props.value),text=resource?getDisplayString(resource):props.alt??"",initials=getInitials(text),uncachedImageUrl=(resource&&getImageSrc(resource))??props.src,imageUrl=useCachedBinaryUrl(uncachedImageUrl??void 0),radius=props.radius??"xl",avatarProps={...props,value:void 0,link:void 0};return props.link?jsx8(MedplumLink,{to:resource,children:jsx8(Avatar,{src:imageUrl,alt:text,radius,...avatarProps,children:initials})}):jsx8(Avatar,{src:imageUrl,alt:text,radius,...avatarProps,children:initials})}var Header_default={logoButton:"Header_logoButton",user:"Header_user",userInfo:"Header_userInfo",userName:"Header_userName",userProject:"Header_userProject"};import{Box as Box3,Divider,Flex,Menu,SegmentedControl,Text as Text3,useMantineColorScheme}from"@mantine/core";import{formatHumanName,getReferenceString,locationUtils as locationUtils2}from"@medplum/core";import{useMedplumContext}from"@medplum/react-hooks";function r(e){var t,f,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}var clsx_default=clsx;import{useState as useState3}from"react";import{Box as Box2,Group as Group3,Text as Text2}from"@mantine/core";var ProjectLoginOption_default={iconBox:"ProjectLoginOption_iconBox",subtitle:"ProjectLoginOption_subtitle",interactive:"ProjectLoginOption_interactive"};import{jsx as jsx9,jsxs as jsxs3}from"react/jsx-runtime";function ProjectLoginOption(props){let{projectDisplay,profileDisplay,label,selected}=props,projectTitle=label?`${projectDisplay} - ${label}`:projectDisplay;return jsxs3(Group3,{gap:"xs",align:"center",wrap:"nowrap",style:{width:"100%",minWidth:0},children:[jsx9(Box2,{className:ProjectLoginOption_default.iconBox,children:jsx9(IconBriefcase,{size:16,stroke:2})}),jsxs3("div",{style:{flex:1,minWidth:0},children:[jsx9(Text2,{size:"sm",fw:500,truncate:!0,children:projectTitle}),jsx9(Text2,{size:"xs",className:ProjectLoginOption_default.subtitle,truncate:!0,children:profileDisplay})]}),selected&&jsx9(IconCheck,{size:16,stroke:2,color:"var(--mantine-color-blue-6)"})]})}function ProjectMembershipLoginOption(props){let{membership,label}=props;return jsx9(ProjectLoginOption,{projectDisplay:membership.project?.display,profileDisplay:membership.profile?.display,label})}function getAppName(){return import.meta.env.MEDPLUM_APP_NAME||"Medplum"}var HeaderDropdown_default={divider:"HeaderDropdown_divider",accountSection:"HeaderDropdown_accountSection",projectOption:"HeaderDropdown_projectOption",recentProjectItem:"HeaderDropdown_recentProjectItem",dropdown:"HeaderDropdown_dropdown",settingsRow:"HeaderDropdown_settingsRow",settingsControlWrapper:"HeaderDropdown_settingsControlWrapper",segmentedControl:"HeaderDropdown_segmentedControl",appearanceControl:"HeaderDropdown_appearanceControl",layoutControl:"HeaderDropdown_layoutControl"};import{Fragment as Fragment3,jsx as jsx10,jsxs as jsxs4}from"react/jsx-runtime";var MENU_ICON_COLOR="var(--mantine-color-dimmed)",THEME_OPTIONS=[{value:"light",label:jsx10(ThemeOptionLabel,{Icon:IconSunHigh,label:"Light"})},{value:"auto",label:jsx10(ThemeOptionLabel,{Icon:IconDeviceDesktop,label:"System"})},{value:"dark",label:jsx10(ThemeOptionLabel,{Icon:IconMoon,label:"Dark"})}],LAYOUT_OPTIONS=[{label:"v1",value:"v1"},{label:"v2",value:"v2"}];function ThemeOptionLabel({Icon,label}){return jsx10("span",{"aria-label":label,style:{display:"flex"},children:jsx10(Icon,{size:16,color:MENU_ICON_COLOR,"aria-hidden":!0})})}function HeaderDropdownDivider(){return jsx10(Divider,{my:4,mx:4,className:HeaderDropdown_default.divider})}function isSameLogin(a,b){return b?a.project.reference===b.project.reference&&a.profile.reference===b.profile.reference:!1}function getLoginKey(login){return`${login.project.reference}-${login.profile.reference}`}function HeaderDropdown(props){let context=useMedplumContext(),{medplum,profile,navigate}=context,activeLogin=medplum.getActiveLogin(),recentLogins=medplum.getLogins().filter(login=>!isSameLogin(login,activeLogin)),project=medplum.getProject(),{colorScheme,setColorScheme}=useMantineColorScheme(),[layoutVersion]=useState3(()=>localStorage.appShellLayoutVersion??"v1"),showLayoutToggle=props.showLayoutVersionToggle??!0,projectDisplay=project?.name??medplum.getActiveLogin()?.project.display,profileDisplay=activeLogin?.profile.display??(profile?formatHumanName(profile.name?.[0]):void 0);function switchLogin(login){medplum.setActiveLogin(login).then(()=>locationUtils2.reload()).catch(console.error)}return jsxs4(Fragment3,{children:[jsx10(Box3,{className:HeaderDropdown_default.accountSection,children:jsx10(Box3,{className:HeaderDropdown_default.projectOption,children:jsx10(ProjectLoginOption,{projectDisplay,profileDisplay,selected:!0})})}),recentLogins.length>0&&jsxs4(Fragment3,{children:[jsx10(HeaderDropdownDivider,{}),recentLogins.map(login=>jsx10(Menu.Item,{className:HeaderDropdown_default.recentProjectItem,onClick:()=>switchLogin(login),children:jsx10(Box3,{className:HeaderDropdown_default.projectOption,children:jsx10(ProjectLoginOption,{projectDisplay:login.project.display,profileDisplay:login.profile.display})})},getLoginKey(login)))]}),jsx10(HeaderDropdownDivider,{}),jsx10(Menu.Item,{leftSection:jsx10(IconSwitchHorizontal,{size:16,color:MENU_ICON_COLOR}),onClick:()=>navigate("/signin"),children:jsx10(Text3,{size:"sm",children:"Switch to another project"})}),jsx10(Menu.Item,{leftSection:jsx10(IconSettings,{size:16,color:MENU_ICON_COLOR}),onClick:()=>navigate(`/${getReferenceString(profile)}`),children:jsx10(Text3,{size:"sm",children:"Account settings"})}),jsxs4(Flex,{className:HeaderDropdown_default.settingsRow,align:"center",pl:"sm",pr:"xs",py:"xs",children:[jsxs4(Flex,{align:"center",gap:"xs",children:[jsx10(IconPalette,{size:16,color:MENU_ICON_COLOR}),jsx10(Text3,{size:"sm",children:"Appearance"})]}),jsx10(Box3,{className:HeaderDropdown_default.settingsControlWrapper,children:jsx10(SegmentedControl,{classNames:{root:clsx_default(HeaderDropdown_default.segmentedControl,HeaderDropdown_default.appearanceControl)},size:"xs",radius:"xl",withItemsBorders:!1,value:colorScheme,onChange:newValue=>setColorScheme(newValue),data:THEME_OPTIONS,"aria-label":"Color scheme"})})]}),showLayoutToggle&&jsxs4(Flex,{className:HeaderDropdown_default.settingsRow,align:"center",pl:"sm",pr:"xs",py:"xs",children:[jsxs4(Flex,{align:"center",gap:"xs",children:[jsx10(IconTable,{size:16,color:MENU_ICON_COLOR}),jsx10(Text3,{size:"sm",children:"Layout"})]}),jsx10(Box3,{className:HeaderDropdown_default.settingsControlWrapper,children:jsx10(SegmentedControl,{classNames:{root:clsx_default(HeaderDropdown_default.segmentedControl,HeaderDropdown_default.layoutControl)},size:"xs",radius:"xl",withItemsBorders:!1,value:layoutVersion,onChange:newValue=>{localStorage.appShellLayoutVersion=newValue,locationUtils2.reload()},data:LAYOUT_OPTIONS,"aria-label":"App shell layout version"})})]}),jsx10(Menu.Item,{leftSection:jsx10(IconLogout,{size:16,color:MENU_ICON_COLOR}),onClick:async()=>{await medplum.signOut(),navigate("/signin")},children:jsx10(Text3,{size:"sm",children:"Sign out"})}),jsx10(HeaderDropdownDivider,{}),jsxs4(Text3,{size:"xs",c:"dimmed",fw:500,my:"sm",ta:"center",children:[getAppName()," ",props.version]})]})}import{Group as Group5,Text as Text4}from"@mantine/core";import{formatHumanName as formatHumanName2,getDisplayString as getDisplayString2,getReferenceString as getReferenceString2,isUUID}from"@medplum/core";import{useMedplum,useMedplumNavigate as useMedplumNavigate2}from"@medplum/react-hooks";import{forwardRef as forwardRef2,useCallback as useCallback2}from"react";import{Combobox,Group as Group4,Loader as Loader2,Pill,PillsInput,ScrollAreaAutosize,useCombobox}from"@mantine/core";import{showNotification}from"@mantine/notifications";import{normalizeErrorString as normalizeErrorString2}from"@medplum/core";import{useCallback,useEffect,useLayoutEffect,useMemo as useMemo2,useRef,useState as useState4}from"react";var AsyncAutocompleteTestIds={selectedItems:"selected-items",options:"options"};import{jsx as jsx11,jsxs as jsxs5}from"react/jsx-runtime";function AsyncAutocomplete(props){let combobox=useCombobox({onDropdownClose:()=>combobox.resetSelectedOption(),onDropdownOpen:()=>combobox.updateSelectedOptionIndex("active")}),{name,label,description,error,defaultValue:defaultValue2,toOption:toOption4,loadOptions,itemComponent,pillComponent,emptyComponent,onChange,onCreate,creatable,clearable,required,placeholder,leftSection,maxValues,optionsDropdownMaxHeight=320,minInputLength=0,...rest}=props,disabled=rest.disabled,defaultItems=toDefaultItems(defaultValue2),[search,setSearch]=useState4(""),[timer,setTimer]=useState4(),[abortController,setAbortController]=useState4(),[autoSubmit,setAutoSubmit]=useState4(),[selected,setSelected]=useState4(defaultItems.map(toOption4)),[options,setOptions]=useState4([]),ItemComponent3=itemComponent??DefaultItemComponent,PillComponent=pillComponent??DefaultPillComponent,EmptyComponent=emptyComponent??DefaultEmptyComponent,searchRef=useRef(search),lastLoadOptionsRef=useRef(void 0),lastValueRef=useRef(void 0),timerRef=useRef(timer),abortControllerRef=useRef(abortController),autoSubmitRef=useRef(autoSubmit);useLayoutEffect(()=>{searchRef.current=search,timerRef.current=timer,abortControllerRef.current=abortController,autoSubmitRef.current=autoSubmit});let handleTimer=useCallback(()=>{if(setTimer(void 0),searchRef.current===lastValueRef.current&&loadOptions===lastLoadOptionsRef.current||(searchRef.current?.length??0)<minInputLength)return;lastValueRef.current=searchRef.current,lastLoadOptionsRef.current=loadOptions;let newAbortController=new AbortController;setAbortController(newAbortController),loadOptions(searchRef.current??"",newAbortController.signal).then(newValues=>{newAbortController.signal.aborted||(setOptions(newValues.map(toOption4)),autoSubmitRef.current?(newValues.length>0&&onChange(newValues.slice(0,1)),setAutoSubmit(!1)):newValues.length>0&&combobox.openDropdown())}).catch(err=>{newAbortController.signal.aborted||err.message.includes("aborted")||showNotification({color:"red",message:normalizeErrorString2(err)})}).finally(()=>{newAbortController.signal.aborted||setAbortController(void 0)})},[combobox,loadOptions,onChange,toOption4,minInputLength]),handleSearchChange=useCallback(e=>{(options&&options.length>0||creatable)&&combobox.openDropdown(),combobox.updateSelectedOptionIndex(),setSearch(e.currentTarget.value),abortControllerRef.current&&(abortControllerRef.current.abort(),setAbortController(void 0)),timerRef.current!==void 0&&window.clearTimeout(timerRef.current);let newTimer=window.setTimeout(()=>handleTimer(),100);setTimer(newTimer)},[combobox,options,creatable,handleTimer]),addSelected=useCallback(newValue=>{let alreadySelected=selected.some(v=>v.value===newValue),newSelected=alreadySelected?selected.filter(v=>v.value!==newValue):[...selected],option=options?.find(option2=>option2.value===newValue);if(!option&&creatable!==!1&&onCreate){let createdResource=onCreate(newValue);option=toOption4(createdResource)}if(option){if(maxValues===0){onChange([option.resource]),selected.length>0&&setSelected([]);return}alreadySelected||newSelected.push(option)}if(maxValues!==void 0)for(;newSelected.length>maxValues;)newSelected.shift();onChange(newSelected.map(v=>v.resource)),setSelected(newSelected)},[creatable,options,selected,maxValues,onChange,onCreate,toOption4]),handleValueSelect=useMemo2(()=>{if(!disabled)return val=>{disabled||(maxValues===1&&(setSearch(""),setOptions([]),combobox.closeDropdown()),lastValueRef.current=void 0,val==="$create"?(setSearch(""),addSelected(search)):addSelected(val))}},[addSelected,combobox,disabled,maxValues,search]),handleValueRemove=useCallback(item=>{let newSelected=selected.filter(v=>v.value!==item.value);onChange(newSelected.map(v=>v.resource)),setSelected(newSelected)},[selected,onChange]),handleKeyDown=useCallback(e=>{e.key==="Enter"?(timer||abortController)&&setAutoSubmit(!0):e.key==="Backspace"&&search.length===0&&(killEvent(e),handleValueRemove(selected[selected.length-1]))},[abortController,handleValueRemove,search.length,selected,timer]);useEffect(()=>()=>{abortControllerRef.current&&abortControllerRef.current.abort()},[]);let clearButton=!disabled&&clearable&&selected.length>0&&jsx11(Combobox.ClearButton,{title:"Clear all",size:"sm",onClear:()=>{setSearch(""),setSelected([]),onChange([]),combobox.closeDropdown()}}),createVisible=creatable&&search.trim().length>0,comboboxVisible=options.length>0||createVisible;return jsxs5(Combobox,{store:combobox,onOptionSubmit:handleValueSelect,withinPortal:!0,shadow:"xl",...rest,children:[jsx11(Combobox.DropdownTarget,{children:jsx11(PillsInput,{label,description,error,className:props.className,leftSection,rightSection:abortController?jsx11(Loader2,{size:16}):clearButton,required,disabled,children:jsxs5(Pill.Group,{"data-testid":AsyncAutocompleteTestIds.selectedItems,children:[selected.map(item=>jsx11(PillComponent,{item,disabled,onRemove:()=>handleValueRemove(item)},item.value)),!disabled&&(maxValues===void 0||maxValues===0||selected.length<maxValues)&&jsx11(Combobox.EventsTarget,{children:jsx11(PillsInput.Field,{role:"searchbox",name,value:search,placeholder,onFocus:handleSearchChange,onBlur:()=>{combobox.closeDropdown(),setSearch("")},onKeyDown:handleKeyDown,onChange:handleSearchChange})})]})})}),jsx11(Combobox.Dropdown,{hidden:!comboboxVisible,"data-testid":AsyncAutocompleteTestIds.options,children:jsx11(Combobox.Options,{children:jsxs5(ScrollAreaAutosize,{type:"scroll",mah:optionsDropdownMaxHeight,children:[options.map(item=>{let active=selected.some(v=>v.value===item.value);return jsx11(Combobox.Option,{value:item.value,active,children:jsx11(ItemComponent3,{...item,active})},item.value)}),createVisible&&jsxs5(Combobox.Option,{value:"$create",children:["+ Create ",search]}),!creatable&&search.trim().length>0&&options.length===0&&jsx11(EmptyComponent,{search})]})})})]})}function toDefaultItems(defaultValue2){return defaultValue2?Array.isArray(defaultValue2)?defaultValue2:[defaultValue2]:[]}function DefaultItemComponent(props){return jsxs5(Group4,{gap:"xs",children:[props.active&&jsx11(IconCheck,{size:12}),jsx11("span",{children:props.label})]})}function DefaultPillComponent({item,disabled,onRemove}){return jsx11(Pill,{withRemoveButton:!disabled,onRemove,children:item.label})}function DefaultEmptyComponent(){return jsx11(Combobox.Empty,{children:"Nothing found"})}var HeaderSearchInput_default={searchInput:"HeaderSearchInput_searchInput"};import{jsx as jsx12,jsxs as jsxs6}from"react/jsx-runtime";function toOption(resource){return{value:resource.id,label:getDisplayString2(resource),resource}}function HeaderSearchInput(props){let navigate=useMedplumNavigate2(),medplum=useMedplum(),loadData=useCallback2(async(input,signal)=>{let query=buildGraphQLQuery(input),options={signal},response=await medplum.graphql(query,void 0,void 0,options);return getResourcesFromResponse(response,input)},[medplum]),handleSelect=useCallback2(item=>{item.length>0&&navigate(`/${getReferenceString2(item[0])}`)},[navigate]);return jsx12(AsyncAutocomplete,{size:"sm",radius:"md",className:HeaderSearchInput_default.searchInput,leftSection:jsx12(IconSearch,{size:16}),placeholder:"Search",itemComponent:ItemComponent,toOption,onChange:handleSelect,loadOptions:loadData,maxValues:0,clearable:!1},`${props.pathname}?${props.searchParams}`)}var ItemComponent=forwardRef2(({resource,active:_active,...others},ref)=>{let helpText;return resource.resourceType==="Patient"?helpText=resource.birthDate:resource.resourceType==="ServiceRequest"&&(helpText=resource.subject?.display),jsx12("div",{ref,...others,children:jsxs6(Group5,{wrap:"nowrap",children:[jsx12(ResourceAvatar,{value:resource}),jsxs6("div",{children:[jsx12(Text4,{children:getDisplayString2(resource)}),jsx12(Text4,{size:"xs",c:"dimmed",children:helpText})]})]})})});function buildGraphQLQuery(input){let escaped=JSON.stringify(input);return isUUID(input)?`{
1
+ var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value);export*from"@medplum/react-hooks";import{formatAddress}from"@medplum/core";import{Fragment,jsx}from"react/jsx-runtime";function AddressDisplay(props){let address=props.value;return address?jsx(Fragment,{children:formatAddress(address,props.options)}):null}import{Group,NativeSelect,TextInput}from"@mantine/core";import{trimTrailingEmptyElements}from"@medplum/core";import{useContext,useMemo,useState}from"react";import{isPopulated}from"@medplum/core";import{createContext}from"react";var DEFAULT_IGNORED_PROPERTIES=["meta","implicitRules","contained","extension","modifierExtension"],DEFAULT_IGNORED_NON_NESTED_PROPERTIES=["language","text"];var ElementsContext=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});ElementsContext.displayName="ElementsContext";var EXTENSION_KEYS=["extension","modifierExtension"],IGNORED_PROPERTIES=["id",...DEFAULT_IGNORED_PROPERTIES].filter(prop=>!EXTENSION_KEYS.includes(prop));function getElementsToRender(inputElements){return Object.entries(inputElements).filter(([key,element])=>!isPopulated(element.type)||element.max===0||element.path.toLowerCase().endsWith("extension.url")&&element.fixed||EXTENSION_KEYS.includes(key)&&!isPopulated(element.slicing?.slices)||IGNORED_PROPERTIES.includes(key)?!1:!(DEFAULT_IGNORED_NON_NESTED_PROPERTIES.includes(key)&&element.path.split(".").length===2||key.includes(".")))}import{jsx as jsx2,jsxs}from"react/jsx-runtime";function getLine(address,index){return address.line&&address.line.length>index?address.line[index]:""}function setLine(address,index,str){let line=address.line||[];for(;line.length<=index;)line.push("");return line[index]=str,{...address,line:trimTrailingEmptyElements(line)}}function AddressInput(props){let[value,setValue]=useState(props.defaultValue||{}),{getExtendedProps}=useContext(ElementsContext),[useProps,typeProps,line1Props,line2Props,cityProps,stateProps,postalCodeProps]=useMemo(()=>["use","type","line1","line2","city","state","postalCode"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(prevValue=>({...prevValue,...newValue})),props.onChange&&props.onChange({...value,...newValue})}function setUse(use){setValueWrapper({use})}function setType(type){setValueWrapper({type})}function setLine1(line1){setValueWrapper(setLine(value,0,line1))}function setLine2(line2){setValueWrapper(setLine(value,1,line2))}function setCity(city){setValueWrapper({city})}function setState(state){setValueWrapper({state})}function setPostalCode(postalCode){setValueWrapper({postalCode})}return jsxs(Group,{gap:"xs",wrap:"nowrap",grow:!0,children:[jsx2(NativeSelect,{disabled:props.disabled||useProps?.readonly,"data-testid":"address-use",defaultValue:value.use,onChange:e=>setUse(e.currentTarget.value),data:["","home","work","temp","old","billing"]}),jsx2(NativeSelect,{disabled:props.disabled||typeProps?.readonly,"data-testid":"address-type",defaultValue:value.type,onChange:e=>setType(e.currentTarget.value),data:["","postal","physical","both"]}),jsx2(TextInput,{disabled:props.disabled||line1Props?.readonly,placeholder:"Line 1",defaultValue:getLine(value,0),onChange:e=>setLine1(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||line2Props?.readonly,placeholder:"Line 2",defaultValue:getLine(value,1),onChange:e=>setLine2(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||cityProps?.readonly,placeholder:"City",defaultValue:value.city,onChange:e=>setCity(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||stateProps?.readonly,placeholder:"State",defaultValue:value.state,onChange:e=>setState(e.currentTarget.value)}),jsx2(TextInput,{disabled:props.disabled||postalCodeProps?.readonly,placeholder:"Postal Code",defaultValue:value.postalCode,onChange:e=>setPostalCode(e.currentTarget.value)})]})}import{TextInput as TextInput2}from"@mantine/core";import{createReference}from"@medplum/core";import{useMedplumProfile}from"@medplum/react-hooks";import{useState as useState2}from"react";import{jsx as jsx3}from"react/jsx-runtime";function AnnotationInput(props){let author=useMedplumProfile(),[value,setValue]=useState2(props.defaultValue||{});function setText(text){let newValue=text?{text,authorReference:author&&createReference(author),time:new Date().toISOString()}:{};setValue(newValue),props.onChange&&props.onChange(newValue)}return jsx3(TextInput2,{disabled:props.disabled,name:props.name,placeholder:"Annotation text",defaultValue:value.text,onChange:e=>setText(e.currentTarget.value)})}import{AppShell as MantineAppShell3}from"@mantine/core";import{useMedplum as useMedplum7,useMedplumProfile as useMedplumProfile4}from"@medplum/react-hooks";import{Suspense,useState as useState12}from"react";import{Alert}from"@mantine/core";import{locationUtils,normalizeErrorString}from"@medplum/core";import{forwardRef,createElement}from"react";var defaultAttributes={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"}};var createReactComponent=(type,iconName,iconNamePascal,iconNode)=>{let Component2=forwardRef(({color="currentColor",size=24,stroke=2,title,className,children,...rest},ref)=>createElement("svg",{ref,...defaultAttributes[type],width:size,height:size,className:["tabler-icon",`tabler-icon-${iconName}`,className].join(" "),...type==="filled"?{fill:color}:{strokeWidth:stroke,stroke:color},...rest},[title&&createElement("title",{key:"svg-title"},title),...iconNode.map(([tag,attrs])=>createElement(tag,attrs)),...Array.isArray(children)?children:[children]]));return Component2.displayName=`${iconNamePascal}`,Component2};var __iconNode=[["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"}]],IconAdjustmentsHorizontal=createReactComponent("outline","adjustments-horizontal","AdjustmentsHorizontal",__iconNode);var __iconNode2=[["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"}]],IconAlertCircle=createReactComponent("outline","alert-circle","AlertCircle",__iconNode2);var __iconNode3=[["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"}]],IconArrowDown=createReactComponent("outline","arrow-down","ArrowDown",__iconNode3);var __iconNode4=[["path",{d:"M5 12l14 0",key:"svg-0"}],["path",{d:"M13 18l6 -6",key:"svg-1"}],["path",{d:"M13 6l6 6",key:"svg-2"}]],IconArrowRight=createReactComponent("outline","arrow-right","ArrowRight",__iconNode4);var __iconNode5=[["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"}]],IconArrowUp=createReactComponent("outline","arrow-up","ArrowUp",__iconNode5);var __iconNode6=[["path",{d:"M6 20a2 2 0 1 0 -4 0a2 2 0 0 0 4 0",key:"svg-0"}],["path",{d:"M16 4a2 2 0 1 0 -4 0a2 2 0 0 0 4 0",key:"svg-1"}],["path",{d:"M16 20a2 2 0 1 0 -4 0a2 2 0 0 0 4 0",key:"svg-2"}],["path",{d:"M11 12a2 2 0 1 0 -4 0a2 2 0 0 0 4 0",key:"svg-3"}],["path",{d:"M21 12a2 2 0 1 0 -4 0a2 2 0 0 0 4 0",key:"svg-4"}],["path",{d:"M5.058 18.306l2.88 -4.606",key:"svg-5"}],["path",{d:"M10.061 10.303l2.877 -4.604",key:"svg-6"}],["path",{d:"M10.065 13.705l2.876 4.6",key:"svg-7"}],["path",{d:"M15.063 5.7l2.881 4.61",key:"svg-8"}]],IconBinaryTree=createReactComponent("outline","binary-tree","BinaryTree",__iconNode6);var __iconNode7=[["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"}]],IconBleachOff=createReactComponent("outline","bleach-off","BleachOff",__iconNode7);var __iconNode8=[["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"}]],IconBleach=createReactComponent("outline","bleach","Bleach",__iconNode8);var __iconNode9=[["path",{d:"M18 7v14l-6 -4l-6 4v-14a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4",key:"svg-0"}]],IconBookmark=createReactComponent("outline","bookmark","Bookmark",__iconNode9);var __iconNode10=[["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"}]],IconBoxMultiple=createReactComponent("outline","box-multiple","BoxMultiple",__iconNode10);var __iconNode11=[["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"}]],IconBracketsContain=createReactComponent("outline","brackets-contain","BracketsContain",__iconNode11);var __iconNode12=[["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"}]],IconBriefcase=createReactComponent("outline","briefcase","Briefcase",__iconNode12);var __iconNode13=[["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"}]],IconBucketOff=createReactComponent("outline","bucket-off","BucketOff",__iconNode13);var __iconNode14=[["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"}]],IconBucket=createReactComponent("outline","bucket","Bucket",__iconNode14);var __iconNode15=[["path",{d:"M3 20h18v-8a3 3 0 0 0 -3 -3h-12a3 3 0 0 0 -3 3v8",key:"svg-0"}],["path",{d:"M3 14.803c.312 .135 .654 .204 1 .197a2.4 2.4 0 0 0 2 -1a2.4 2.4 0 0 1 2 -1a2.4 2.4 0 0 1 2 1a2.4 2.4 0 0 0 2 1a2.4 2.4 0 0 0 2 -1a2.4 2.4 0 0 1 2 -1a2.4 2.4 0 0 1 2 1a2.4 2.4 0 0 0 2 1c.35 .007 .692 -.062 1 -.197",key:"svg-1"}],["path",{d:"M12 4l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737",key:"svg-2"}]],IconCake=createReactComponent("outline","cake","Cake",__iconNode15);var __iconNode16=[["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"}]],IconCalendar=createReactComponent("outline","calendar","Calendar",__iconNode16);var __iconNode17=[["path",{d:"M5 12l5 5l10 -10",key:"svg-0"}]],IconCheck=createReactComponent("outline","check","Check",__iconNode17);var __iconNode18=[["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"}]],IconCheckbox=createReactComponent("outline","checkbox","Checkbox",__iconNode18);var __iconNode19=[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]],IconChevronDown=createReactComponent("outline","chevron-down","ChevronDown",__iconNode19);var __iconNode20=[["path",{d:"M9 6l6 6l-6 6",key:"svg-0"}]],IconChevronRight=createReactComponent("outline","chevron-right","ChevronRight",__iconNode20);var __iconNode21=[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]],IconChevronUp=createReactComponent("outline","chevron-up","ChevronUp",__iconNode21);var __iconNode22=[["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"}]],IconCircleMinus=createReactComponent("outline","circle-minus","CircleMinus",__iconNode22);var __iconNode23=[["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"}]],IconCirclePlus=createReactComponent("outline","circle-plus","CirclePlus",__iconNode23);var __iconNode24=[["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"}]],IconCloudUpload=createReactComponent("outline","cloud-upload","CloudUpload",__iconNode24);var __iconNode25=[["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"}]],IconColumns=createReactComponent("outline","columns","Columns",__iconNode25);var __iconNode26=[["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"}]],IconCopy=createReactComponent("outline","copy","Copy",__iconNode26);var __iconNode27=[["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"}]],IconCurrencyDollar=createReactComponent("outline","currency-dollar","CurrencyDollar",__iconNode27);var __iconNode28=[["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"}]],IconDeviceDesktop=createReactComponent("outline","device-desktop","DeviceDesktop",__iconNode28);var __iconNode29=[["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"}]],IconDots=createReactComponent("outline","dots","Dots",__iconNode29);var __iconNode30=[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 11l5 5l5 -5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]],IconDownload=createReactComponent("outline","download","Download",__iconNode30);var __iconNode31=[["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"}]],IconEdit=createReactComponent("outline","edit","Edit",__iconNode31);var __iconNode32=[["path",{d:"M9.5 5.5a2.5 2.5 0 1 0 5 0a2.5 2.5 0 1 0 -5 0",key:"svg-0"}],["path",{d:"M12 21.368l5.095 -5.096a3.088 3.088 0 1 0 -4.367 -4.367l-.728 .727l-.728 -.727a3.088 3.088 0 1 0 -4.367 4.367l5.095 5.096",key:"svg-1"}]],IconEmpathize=createReactComponent("outline","empathize","Empathize",__iconNode32);var __iconNode33=[["path",{d:"M5 10h14",key:"svg-0"}],["path",{d:"M5 14h14",key:"svg-1"}],["path",{d:"M5 19l14 -14",key:"svg-2"}]],IconEqualNot=createReactComponent("outline","equal-not","EqualNot",__iconNode33);var __iconNode34=[["path",{d:"M5 10h14",key:"svg-0"}],["path",{d:"M5 14h14",key:"svg-1"}]],IconEqual=createReactComponent("outline","equal","Equal",__iconNode34);var __iconNode35=[["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"}]],IconEyeOff=createReactComponent("outline","eye-off","EyeOff",__iconNode35);var __iconNode36=[["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"}]],IconEye=createReactComponent("outline","eye","Eye",__iconNode36);var __iconNode37=[["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"}]],IconFileAlert=createReactComponent("outline","file-alert","FileAlert",__iconNode37);var __iconNode38=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M11.5 21h-4.5a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v5m-5 6h7m-3 -3l3 3l-3 3",key:"svg-1"}]],IconFileExport=createReactComponent("outline","file-export","FileExport",__iconNode38);var __iconNode39=[["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"}]],IconFilePlus=createReactComponent("outline","file-plus","FilePlus",__iconNode39);var __iconNode40=[["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:"M9 9l1 0",key:"svg-2"}],["path",{d:"M9 13l6 0",key:"svg-3"}],["path",{d:"M9 17l6 0",key:"svg-4"}]],IconFileText=createReactComponent("outline","file-text","FileText",__iconNode40);var __iconNode41=[["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"}]],IconFilter=createReactComponent("outline","filter","Filter",__iconNode41);var __iconNode42=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 9h.01",key:"svg-1"}],["path",{d:"M11 12h1v4h1",key:"svg-2"}]],IconInfoCircle=createReactComponent("outline","info-circle","InfoCircle",__iconNode42);var __iconNode43=[["path",{d:"M9 6.371c0 4.418 -2.239 6.629 -5 6.629",key:"svg-0"}],["path",{d:"M4 6.371h7",key:"svg-1"}],["path",{d:"M5 9c0 2.144 2.252 3.908 6 4",key:"svg-2"}],["path",{d:"M12 20l4 -9l4 9",key:"svg-3"}],["path",{d:"M19.1 18h-6.2",key:"svg-4"}],["path",{d:"M6.694 3l.793 .582",key:"svg-5"}]],IconLanguage=createReactComponent("outline","language","Language",__iconNode43);var __iconNode44=[["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"}]],IconLayoutSidebar=createReactComponent("outline","layout-sidebar","LayoutSidebar",__iconNode44);var __iconNode45=[["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"}]],IconLogout=createReactComponent("outline","logout","Logout",__iconNode45);var __iconNode46=[["path",{d:"M9 11a3 3 0 1 0 6 0a3 3 0 0 0 -6 0",key:"svg-0"}],["path",{d:"M17.657 16.657l-4.243 4.243a2 2 0 0 1 -2.827 0l-4.244 -4.243a8 8 0 1 1 11.314 0",key:"svg-1"}]],IconMapPin=createReactComponent("outline","map-pin","MapPin",__iconNode46);var __iconNode47=[["path",{d:"M5 18l14 -6l-14 -6",key:"svg-0"}]],IconMathGreater=createReactComponent("outline","math-greater","MathGreater",__iconNode47);var __iconNode48=[["path",{d:"M19 18l-14 -6l14 -6",key:"svg-0"}]],IconMathLower=createReactComponent("outline","math-lower","MathLower",__iconNode48);var __iconNode49=[["path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1",key:"svg-0"}]],IconMessageCircle=createReactComponent("outline","message-circle","MessageCircle",__iconNode49);var __iconNode50=[["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"}]],IconMessage=createReactComponent("outline","message","Message",__iconNode50);var __iconNode51=[["path",{d:"M9 5a3 3 0 0 1 3 -3a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3a3 3 0 0 1 -3 -3l0 -5",key:"svg-0"}],["path",{d:"M5 10a7 7 0 0 0 14 0",key:"svg-1"}],["path",{d:"M8 21l8 0",key:"svg-2"}],["path",{d:"M12 17l0 4",key:"svg-3"}]],IconMicrophone=createReactComponent("outline","microphone","Microphone",__iconNode51);var __iconNode52=[["path",{d:"M5 12l14 0",key:"svg-0"}]],IconMinus=createReactComponent("outline","minus","Minus",__iconNode52);var __iconNode53=[["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"}]],IconMoon=createReactComponent("outline","moon","Moon",__iconNode53);var __iconNode54=[["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"}]],IconPalette=createReactComponent("outline","palette","Palette",__iconNode54);var __iconNode55=[["path",{d:"M15 7l-6.5 6.5a1.5 1.5 0 0 0 3 3l6.5 -6.5a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9l6.5 -6.5",key:"svg-0"}]],IconPaperclip=createReactComponent("outline","paperclip","Paperclip",__iconNode55);var __iconNode56=[["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"}]],IconPencil=createReactComponent("outline","pencil","Pencil",__iconNode56);var __iconNode57=[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]],IconPlus=createReactComponent("outline","plus","Plus",__iconNode57);var __iconNode58=[["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"}]],IconRefresh=createReactComponent("outline","refresh","Refresh",__iconNode58);var __iconNode59=[["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"}]],IconSearch=createReactComponent("outline","search","Search",__iconNode59);var __iconNode60=[["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"}]],IconSettings=createReactComponent("outline","settings","Settings",__iconNode60);var __iconNode61=[["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"}]],IconSortAscending=createReactComponent("outline","sort-ascending","SortAscending",__iconNode61);var __iconNode62=[["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"}]],IconSortDescending=createReactComponent("outline","sort-descending","SortDescending",__iconNode62);var __iconNode63=[["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"}]],IconSquare=createReactComponent("outline","square","Square",__iconNode63);var __iconNode64=[["path",{d:"M6 4h-1a2 2 0 0 0 -2 2v3.5a5.5 5.5 0 0 0 11 0v-3.5a2 2 0 0 0 -2 -2h-1",key:"svg-0"}],["path",{d:"M8 15a6 6 0 1 0 12 0v-3",key:"svg-1"}],["path",{d:"M11 3v2",key:"svg-2"}],["path",{d:"M6 3v2",key:"svg-3"}],["path",{d:"M18 10a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-4"}]],IconStethoscope=createReactComponent("outline","stethoscope","Stethoscope",__iconNode64);var __iconNode65=[["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"}]],IconSunHigh=createReactComponent("outline","sun-high","SunHigh",__iconNode65);var __iconNode66=[["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"}]],IconSwitchHorizontal=createReactComponent("outline","switch-horizontal","SwitchHorizontal",__iconNode66);var __iconNode67=[["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"}]],IconTableExport=createReactComponent("outline","table-export","TableExport",__iconNode67);var __iconNode68=[["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"}]],IconTable=createReactComponent("outline","table","Table",__iconNode68);var __iconNode69=[["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"}]],IconTrash=createReactComponent("outline","trash","Trash",__iconNode69);var __iconNode70=[["path",{d:"M5 7a4 4 0 1 0 8 0a4 4 0 1 0 -8 0",key:"svg-0"}],["path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2",key:"svg-1"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"svg-2"}],["path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85",key:"svg-3"}]],IconUsers=createReactComponent("outline","users","Users",__iconNode70);var __iconNode71=[["path",{d:"M18 6l-12 12",key:"svg-0"}],["path",{d:"M6 6l12 12",key:"svg-1"}]],IconX=createReactComponent("outline","x","X",__iconNode71);var __iconNode72=[["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"}]],IconCircleFilled=createReactComponent("filled","circle-filled","CircleFilled",__iconNode72);import{Component}from"react";import{jsx as jsx4}from"react/jsx-runtime";var ErrorBoundary=class extends Component{constructor(props){super(props);__publicField(this,"state");this.state={lastLocation:locationUtils.getLocation()}}static getDerivedStateFromError(error){return{error,lastLocation:locationUtils.getLocation()}}componentDidUpdate(_prevProps,_prevState){locationUtils.getLocation()!==this.state.lastLocation&&this.setState({lastLocation:locationUtils.getLocation(),error:void 0})}shouldComponentUpdate(nextProps,nextState){return!!(this.props.children!==nextProps.children||nextState.error&&!this.state.error||this.state.lastLocation!==locationUtils.getLocation())}componentDidCatch(error,errorInfo){console.error("Uncaught error:",error,errorInfo)}render(){return this.state.error?jsx4(Alert,{icon:jsx4(IconAlertCircle,{size:16}),title:"Something went wrong",color:"red",children:normalizeErrorString(this.state.error)}):this.props.children}};import{Center,Loader}from"@mantine/core";import{jsx as jsx5}from"react/jsx-runtime";function Loading(){return jsx5(Center,{style:{width:"100%",height:"100vh"},children:jsx5(Loader,{})})}import{Box,CloseButton,Group as Group2,Text}from"@mantine/core";var AppShell_default={main:"AppShell_main",announcement:"AppShell_announcement"};import{Fragment as Fragment2,jsx as jsx6,jsxs as jsxs2}from"react/jsx-runtime";function AnnouncementBanners(props){return jsx6(Fragment2,{children:props.announcements.map((announcement,index)=>jsx6(Box,{className:AppShell_default.announcement,style:{backgroundColor:`var(--mantine-color-${announcement.color??"yellow"}-light)`,color:`var(--mantine-color-${announcement.color??"yellow"}-light-color)`},role:announcement.role??"status",children:jsxs2(Group2,{gap:"xs",wrap:"nowrap",h:"100%",px:"md",children:[announcement.icon,jsx6(Text,{size:"sm",fw:500,truncate:!0,children:announcement.message}),announcement.dismissible&&jsx6(CloseButton,{size:"sm",variant:"subtle","aria-label":"Dismiss announcement",onClick:()=>props.onDismiss(announcement),ml:"auto"})]})},announcement.id??index))})}import{Box as Box4,Group as Group6,AppShell as MantineAppShell,Menu as Menu2,Stack,Text as Text5,UnstyledButton}from"@mantine/core";import{formatHumanName as formatHumanName3}from"@medplum/core";import{useMedplum as useMedplum2,useMedplumProfile as useMedplumProfile2}from"@medplum/react-hooks";import{useState as useState5}from"react";import{Avatar}from"@mantine/core";import{getDisplayString,getImageSrc}from"@medplum/core";import{useCachedBinaryUrl,useResource}from"@medplum/react-hooks";import{Anchor}from"@mantine/core";import{isReference,isResource}from"@medplum/core";import{useMedplumNavigate}from"@medplum/react-hooks";import{ContentType}from"@medplum/core";function killEvent(e){e.preventDefault(),e.stopPropagation()}function isAuxClick(e){return e.button===1||e.ctrlKey||e.metaKey}function isCheckboxCell(el){if(isCheckboxElement(el))return!0;if(el instanceof HTMLTableCellElement){let children=el.children;if(children.length===1&&isCheckboxElement(children[0]))return!0}return!1}function isCheckboxElement(el){return el instanceof HTMLInputElement&&el.type==="checkbox"}async function sendCommand(frame,command){return new Promise((resolve,reject)=>{let channel=new MessageChannel;channel.port1.onmessage=({data:data2})=>{channel.port1.close(),data2.error?reject(data2.error):resolve(data2.result)},frame.contentWindow?.postMessage(command,new URL(frame.src).origin,[channel.port2])})}function exportJsonFile(jsonString,fileName){let blobForExport=new Blob([jsonString],{type:ContentType.JSON}),url=URL.createObjectURL(blobForExport),link=document.createElement("a");link.href=url;let linkName=fileName??new Date().toISOString().replaceAll(/\D/g,"");link.download=`${linkName}.json`,document.body.appendChild(link),link.click(),URL.revokeObjectURL(url)}import{jsx as jsx7}from"react/jsx-runtime";function MedplumLink(props){let navigate=useMedplumNavigate(),{to,suffix,label,onClick,children,...rest}=props,href=getHref(to);return suffix&&(href+="/"+suffix),jsx7(Anchor,{href,"aria-label":label,onAuxClick:e=>{e.stopPropagation()},onClick:e=>{e.stopPropagation(),onClick?(e.preventDefault(),onClick(e)):to&&(isAuxClick(e)||(e.preventDefault(),navigate(href)))},...rest,children})}function getHref(to){if(to){if(typeof to=="string")return getStringHref(to);if(isResource(to))return getResourceHref(to);if(isReference(to))return getReferenceHref(to)}return"#"}function getStringHref(to){return to.startsWith("http://")||to.startsWith("https://")||to.startsWith("/")?to:"/"+to}function getResourceHref(to){return`/${to.resourceType}/${to.id}`}function getReferenceHref(to){return`/${to.reference}`}function getInitials(input){let words=input.split(" ").filter(Boolean);return words.length>1?words[0][0]+words.at(-1)?.at(0):words.length===1?words[0][0]:""}import{jsx as jsx8}from"react/jsx-runtime";function ResourceAvatar(props){let resource=useResource(props.value),text=resource?getDisplayString(resource):props.alt??"",initials=getInitials(text),uncachedImageUrl=(resource&&getImageSrc(resource))??props.src,imageUrl=useCachedBinaryUrl(uncachedImageUrl??void 0),radius=props.radius??"xl",avatarProps={...props,value:void 0,link:void 0};return props.link?jsx8(MedplumLink,{to:resource,children:jsx8(Avatar,{src:imageUrl,alt:text,radius,...avatarProps,children:initials})}):jsx8(Avatar,{src:imageUrl,alt:text,radius,...avatarProps,children:initials})}var Header_default={logoButton:"Header_logoButton",user:"Header_user",userInfo:"Header_userInfo",userName:"Header_userName",userProject:"Header_userProject"};import{Box as Box3,Divider,Flex,Menu,SegmentedControl,Text as Text3,useMantineColorScheme}from"@mantine/core";import{formatHumanName,getReferenceString,locationUtils as locationUtils2}from"@medplum/core";import{useMedplumContext}from"@medplum/react-hooks";function r(e){var t,f,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}var clsx_default=clsx;import{useState as useState3}from"react";import{Box as Box2,Group as Group3,Text as Text2}from"@mantine/core";var ProjectLoginOption_default={iconBox:"ProjectLoginOption_iconBox",subtitle:"ProjectLoginOption_subtitle",interactive:"ProjectLoginOption_interactive"};import{jsx as jsx9,jsxs as jsxs3}from"react/jsx-runtime";function ProjectLoginOption(props){let{projectDisplay,profileDisplay,label,selected}=props,projectTitle=label?`${projectDisplay} - ${label}`:projectDisplay;return jsxs3(Group3,{gap:"xs",align:"center",wrap:"nowrap",style:{width:"100%",minWidth:0},children:[jsx9(Box2,{className:ProjectLoginOption_default.iconBox,children:jsx9(IconBriefcase,{size:16,stroke:2})}),jsxs3("div",{style:{flex:1,minWidth:0},children:[jsx9(Text2,{size:"sm",fw:500,truncate:!0,children:projectTitle}),jsx9(Text2,{size:"xs",className:ProjectLoginOption_default.subtitle,truncate:!0,children:profileDisplay})]}),selected&&jsx9(IconCheck,{size:16,stroke:2,color:"var(--mantine-color-blue-6)"})]})}function ProjectMembershipLoginOption(props){let{membership,label}=props;return jsx9(ProjectLoginOption,{projectDisplay:membership.project?.display,profileDisplay:membership.profile?.display,label})}function getAppName(){return import.meta.env.MEDPLUM_APP_NAME||"Medplum"}var HeaderDropdown_default={divider:"HeaderDropdown_divider",accountSection:"HeaderDropdown_accountSection",projectOption:"HeaderDropdown_projectOption",recentProjectItem:"HeaderDropdown_recentProjectItem",dropdown:"HeaderDropdown_dropdown",settingsRow:"HeaderDropdown_settingsRow",settingsControlWrapper:"HeaderDropdown_settingsControlWrapper",segmentedControl:"HeaderDropdown_segmentedControl",appearanceControl:"HeaderDropdown_appearanceControl",layoutControl:"HeaderDropdown_layoutControl"};import{Fragment as Fragment3,jsx as jsx10,jsxs as jsxs4}from"react/jsx-runtime";var MENU_ICON_COLOR="var(--mantine-color-dimmed)",THEME_OPTIONS=[{value:"light",label:jsx10(ThemeOptionLabel,{Icon:IconSunHigh,label:"Light"})},{value:"auto",label:jsx10(ThemeOptionLabel,{Icon:IconDeviceDesktop,label:"System"})},{value:"dark",label:jsx10(ThemeOptionLabel,{Icon:IconMoon,label:"Dark"})}],LAYOUT_OPTIONS=[{label:"v1",value:"v1"},{label:"v2",value:"v2"}];function ThemeOptionLabel({Icon,label}){return jsx10("span",{"aria-label":label,style:{display:"flex"},children:jsx10(Icon,{size:16,color:MENU_ICON_COLOR,"aria-hidden":!0})})}function HeaderDropdownDivider(){return jsx10(Divider,{my:4,mx:4,className:HeaderDropdown_default.divider})}function isSameLogin(a,b){return b?a.project.reference===b.project.reference&&a.profile.reference===b.profile.reference:!1}function getLoginKey(login){return`${login.project.reference}-${login.profile.reference}`}function HeaderDropdown(props){let context=useMedplumContext(),{medplum,profile,navigate}=context,activeLogin=medplum.getActiveLogin(),recentLogins=medplum.getLogins().filter(login=>!isSameLogin(login,activeLogin)),project=medplum.getProject(),{colorScheme,setColorScheme}=useMantineColorScheme(),[layoutVersion]=useState3(()=>localStorage.appShellLayoutVersion??"v1"),showLayoutToggle=props.showLayoutVersionToggle??!0,projectDisplay=project?.name??medplum.getActiveLogin()?.project.display,profileDisplay=activeLogin?.profile.display??(profile?formatHumanName(profile.name?.[0]):void 0);function switchLogin(login){medplum.setActiveLogin(login).then(()=>locationUtils2.reload()).catch(console.error)}return jsxs4(Fragment3,{children:[jsx10(Box3,{className:HeaderDropdown_default.accountSection,children:jsx10(Box3,{className:HeaderDropdown_default.projectOption,children:jsx10(ProjectLoginOption,{projectDisplay,profileDisplay,selected:!0})})}),recentLogins.length>0&&jsxs4(Fragment3,{children:[jsx10(HeaderDropdownDivider,{}),recentLogins.map(login=>jsx10(Menu.Item,{className:HeaderDropdown_default.recentProjectItem,onClick:()=>switchLogin(login),children:jsx10(Box3,{className:HeaderDropdown_default.projectOption,children:jsx10(ProjectLoginOption,{projectDisplay:login.project.display,profileDisplay:login.profile.display})})},getLoginKey(login)))]}),jsx10(HeaderDropdownDivider,{}),jsx10(Menu.Item,{leftSection:jsx10(IconSwitchHorizontal,{size:16,color:MENU_ICON_COLOR}),onClick:()=>navigate("/signin"),children:jsx10(Text3,{size:"sm",children:"Switch to another project"})}),jsx10(Menu.Item,{leftSection:jsx10(IconSettings,{size:16,color:MENU_ICON_COLOR}),onClick:()=>navigate(`/${getReferenceString(profile)}`),children:jsx10(Text3,{size:"sm",children:"Account settings"})}),jsxs4(Flex,{className:HeaderDropdown_default.settingsRow,align:"center",pl:"sm",pr:"xs",py:"xs",children:[jsxs4(Flex,{align:"center",gap:"xs",children:[jsx10(IconPalette,{size:16,color:MENU_ICON_COLOR}),jsx10(Text3,{size:"sm",children:"Appearance"})]}),jsx10(Box3,{className:HeaderDropdown_default.settingsControlWrapper,children:jsx10(SegmentedControl,{classNames:{root:clsx_default(HeaderDropdown_default.segmentedControl,HeaderDropdown_default.appearanceControl)},size:"xs",radius:"xl",withItemsBorders:!1,value:colorScheme,onChange:newValue=>setColorScheme(newValue),data:THEME_OPTIONS,"aria-label":"Color scheme"})})]}),showLayoutToggle&&jsxs4(Flex,{className:HeaderDropdown_default.settingsRow,align:"center",pl:"sm",pr:"xs",py:"xs",children:[jsxs4(Flex,{align:"center",gap:"xs",children:[jsx10(IconTable,{size:16,color:MENU_ICON_COLOR}),jsx10(Text3,{size:"sm",children:"Layout"})]}),jsx10(Box3,{className:HeaderDropdown_default.settingsControlWrapper,children:jsx10(SegmentedControl,{classNames:{root:clsx_default(HeaderDropdown_default.segmentedControl,HeaderDropdown_default.layoutControl)},size:"xs",radius:"xl",withItemsBorders:!1,value:layoutVersion,onChange:newValue=>{localStorage.appShellLayoutVersion=newValue,locationUtils2.reload()},data:LAYOUT_OPTIONS,"aria-label":"App shell layout version"})})]}),jsx10(Menu.Item,{leftSection:jsx10(IconLogout,{size:16,color:MENU_ICON_COLOR}),onClick:async()=>{await medplum.signOut(),navigate("/signin")},children:jsx10(Text3,{size:"sm",children:"Sign out"})}),jsx10(HeaderDropdownDivider,{}),jsxs4(Text3,{size:"xs",c:"dimmed",fw:500,my:"sm",ta:"center",children:[getAppName()," ",props.version]})]})}import{Group as Group5,Text as Text4}from"@mantine/core";import{formatHumanName as formatHumanName2,getDisplayString as getDisplayString2,getReferenceString as getReferenceString2,isUUID}from"@medplum/core";import{useMedplum,useMedplumNavigate as useMedplumNavigate2}from"@medplum/react-hooks";import{forwardRef as forwardRef2,useCallback as useCallback2}from"react";import{Combobox,Group as Group4,Loader as Loader2,Pill,PillsInput,ScrollAreaAutosize,useCombobox}from"@mantine/core";import{showNotification}from"@mantine/notifications";import{normalizeErrorString as normalizeErrorString2}from"@medplum/core";import{useCallback,useEffect,useLayoutEffect,useMemo as useMemo2,useRef,useState as useState4}from"react";var AsyncAutocompleteTestIds={selectedItems:"selected-items",options:"options"};import{jsx as jsx11,jsxs as jsxs5}from"react/jsx-runtime";function AsyncAutocomplete(props){let combobox=useCombobox({onDropdownClose:()=>combobox.resetSelectedOption(),onDropdownOpen:()=>combobox.updateSelectedOptionIndex("active")}),{name,label,description,error,defaultValue:defaultValue2,toOption:toOption4,loadOptions,itemComponent,pillComponent,emptyComponent,onChange,onCreate,creatable,clearable,required,placeholder,leftSection,maxValues,optionsDropdownMaxHeight=320,minInputLength=0,...rest}=props,disabled=rest.disabled,defaultItems=toDefaultItems(defaultValue2),[search,setSearch]=useState4(""),[timer,setTimer]=useState4(),[abortController,setAbortController]=useState4(),[selected,setSelected]=useState4(defaultItems.map(toOption4)),[options,setOptions]=useState4([]),ItemComponent3=itemComponent??DefaultItemComponent,PillComponent=pillComponent??DefaultPillComponent,EmptyComponent=emptyComponent??DefaultEmptyComponent,searchRef=useRef(search),lastLoadOptionsRef=useRef(void 0),lastValueRef=useRef(void 0),timerRef=useRef(timer),abortControllerRef=useRef(abortController),autoSubmitRef=useRef(!1),selectedRef=useRef(selected);useLayoutEffect(()=>{searchRef.current=search,timerRef.current=timer,abortControllerRef.current=abortController,selectedRef.current=selected});let handleValueAdd=useCallback(item=>{let selected2=selectedRef.current;if(selected2.some(v=>v.value===item.value))return;if(maxValues===0){onChange([item.resource]),setSelected([]);return}let newSelected=[...selected2,item];if(maxValues!==void 0){for(;newSelected.length>maxValues;)newSelected.shift();newSelected.length>=maxValues&&(setSearch(""),setOptions([]),combobox.closeDropdown())}onChange(newSelected.map(v=>v.resource)),setSelected(newSelected)},[maxValues,onChange,combobox,setSearch,setOptions]),handleTimer=useCallback(()=>{if(setTimer(void 0),searchRef.current===lastValueRef.current&&loadOptions===lastLoadOptionsRef.current||(searchRef.current?.length??0)<minInputLength)return;lastValueRef.current=searchRef.current,lastLoadOptionsRef.current=loadOptions;let newAbortController=new AbortController;setAbortController(newAbortController),loadOptions(searchRef.current??"",newAbortController.signal).then(newValues=>{if(!newAbortController.signal.aborted){let newOptions=newValues.map(toOption4);setOptions(newOptions),autoSubmitRef.current?(newOptions.length>0&&handleValueAdd(newOptions[0]),autoSubmitRef.current=!1):newValues.length>0&&combobox.openDropdown()}}).catch(err=>{newAbortController.signal.aborted||err.message.includes("aborted")||showNotification({color:"red",message:normalizeErrorString2(err)})}).finally(()=>{newAbortController.signal.aborted||setAbortController(void 0)})},[combobox,loadOptions,handleValueAdd,toOption4,minInputLength,setTimer,setAbortController]),handleSearchChange=useCallback(e=>{(options&&options.length>0||creatable)&&combobox.openDropdown(),combobox.updateSelectedOptionIndex(),setSearch(e.currentTarget.value),abortControllerRef.current&&(abortControllerRef.current.abort(),setAbortController(void 0)),timerRef.current!==void 0&&window.clearTimeout(timerRef.current);let newTimer=window.setTimeout(()=>handleTimer(),100);setTimer(newTimer)},[combobox,options,creatable,handleTimer,setTimer,setSearch,setAbortController]),toggleSelected=useCallback(newValue=>{if(selected.some(v=>v.value===newValue)){let newSelected=selected.filter(v=>v.value!==newValue);onChange(newSelected.map(v=>v.resource)),setSelected(newSelected)}else{let option=options?.find(option2=>option2.value===newValue);if(!option&&creatable!==!1&&onCreate){let createdResource=onCreate(newValue);option=toOption4(createdResource)}option&&handleValueAdd(option)}},[selected,onChange,handleValueAdd,onCreate,toOption4,options,creatable]),handleValueSelect=useMemo2(()=>{if(!disabled)return val=>{disabled||(lastValueRef.current=void 0,val==="$create"?(setSearch(""),toggleSelected(search)):toggleSelected(val))}},[toggleSelected,disabled,search,setSearch]),handleValueRemove=useCallback(item=>{let newSelected=selected.filter(v=>v.value!==item.value);onChange(newSelected.map(v=>v.resource)),setSelected(newSelected)},[selected,onChange]),handleKeyDown=useCallback(e=>{e.key==="Enter"?(timer||abortController)&&(autoSubmitRef.current=!0):e.key==="Backspace"&&search.length===0&&(killEvent(e),handleValueRemove(selected[selected.length-1]))},[abortController,handleValueRemove,search.length,selected,timer]);useEffect(()=>()=>{abortControllerRef.current&&abortControllerRef.current.abort()},[]);let clearButton=!disabled&&clearable&&selected.length>0&&jsx11(Combobox.ClearButton,{title:"Clear all",size:"sm",onClear:()=>{setSearch(""),setSelected([]),onChange([]),combobox.closeDropdown()}}),createVisible=creatable&&search.trim().length>0,comboboxVisible=options.length>0||createVisible;return jsxs5(Combobox,{store:combobox,onOptionSubmit:handleValueSelect,withinPortal:!0,shadow:"xl",...rest,children:[jsx11(Combobox.DropdownTarget,{children:jsx11(PillsInput,{label,description,error,className:props.className,leftSection,rightSection:abortController?jsx11(Loader2,{size:16}):clearButton,required,disabled,children:jsxs5(Pill.Group,{"data-testid":AsyncAutocompleteTestIds.selectedItems,children:[selected.map(item=>jsx11(PillComponent,{item,disabled,onRemove:()=>handleValueRemove(item)},item.value)),!disabled&&(maxValues===void 0||maxValues===0||selected.length<maxValues)&&jsx11(Combobox.EventsTarget,{children:jsx11(PillsInput.Field,{role:"searchbox",name,value:search,placeholder,onFocus:handleSearchChange,onBlur:()=>{combobox.closeDropdown(),setSearch("")},onKeyDown:handleKeyDown,onChange:handleSearchChange})})]})})}),jsx11(Combobox.Dropdown,{hidden:!comboboxVisible,"data-testid":AsyncAutocompleteTestIds.options,children:jsx11(Combobox.Options,{children:jsxs5(ScrollAreaAutosize,{type:"scroll",mah:optionsDropdownMaxHeight,children:[options.map(item=>{let active=selected.some(v=>v.value===item.value);return jsx11(Combobox.Option,{value:item.value,active,children:jsx11(ItemComponent3,{...item,active})},item.value)}),createVisible&&jsxs5(Combobox.Option,{value:"$create",children:["+ Create ",search]}),!creatable&&search.trim().length>0&&options.length===0&&jsx11(EmptyComponent,{search})]})})})]})}function toDefaultItems(defaultValue2){return defaultValue2?Array.isArray(defaultValue2)?defaultValue2:[defaultValue2]:[]}function DefaultItemComponent(props){return jsxs5(Group4,{gap:"xs",children:[props.active&&jsx11(IconCheck,{size:12}),jsx11("span",{children:props.label})]})}function DefaultPillComponent({item,disabled,onRemove}){return jsx11(Pill,{withRemoveButton:!disabled,onRemove,children:item.label})}function DefaultEmptyComponent(){return jsx11(Combobox.Empty,{children:"Nothing found"})}var HeaderSearchInput_default={searchInput:"HeaderSearchInput_searchInput"};import{jsx as jsx12,jsxs as jsxs6}from"react/jsx-runtime";function toOption(resource){return{value:resource.id,label:getDisplayString2(resource),resource}}function HeaderSearchInput(props){let navigate=useMedplumNavigate2(),medplum=useMedplum(),loadData=useCallback2(async(input,signal)=>{let query=buildGraphQLQuery(input),options={signal},response=await medplum.graphql(query,void 0,void 0,options);return getResourcesFromResponse(response,input)},[medplum]),handleSelect=useCallback2(item=>{item.length>0&&navigate(`/${getReferenceString2(item[0])}`)},[navigate]);return jsx12(AsyncAutocomplete,{size:"sm",radius:"md",className:HeaderSearchInput_default.searchInput,leftSection:jsx12(IconSearch,{size:16}),placeholder:"Search",itemComponent:ItemComponent,toOption,onChange:handleSelect,loadOptions:loadData,maxValues:0,clearable:!1},`${props.pathname}?${props.searchParams}`)}var ItemComponent=forwardRef2(({resource,active:_active,...others},ref)=>{let helpText;return resource.resourceType==="Patient"?helpText=resource.birthDate:resource.resourceType==="ServiceRequest"&&(helpText=resource.subject?.display),jsx12("div",{ref,...others,children:jsxs6(Group5,{wrap:"nowrap",children:[jsx12(ResourceAvatar,{value:resource}),jsxs6("div",{children:[jsx12(Text4,{children:getDisplayString2(resource)}),jsx12(Text4,{size:"xs",c:"dimmed",children:helpText})]})]})})});function buildGraphQLQuery(input){let escaped=JSON.stringify(input);return isUUID(input)?`{
2
2
  Patients1: PatientList(_id: ${escaped}, _count: 1) {
3
3
  resourceType
4
4
  id
@@ -100,7 +100,7 @@ var __defProp=Object.defineProperty;var __defNormalProp=(obj,key,value)=>key in
100
100
  subject { display }
101
101
  }
102
102
  }`.replaceAll(/\s+/g," ")}function getResourcesFromResponse2(response){let resources=[];return response.data.Patients1&&resources.push(...response.data.Patients1),response.data.Patients2&&resources.push(...response.data.Patients2),response.data.ServiceRequestList&&resources.push(...response.data.ServiceRequestList),dedupeResources2(resources)}function dedupeResources2(resources){let ids=new Set,result=[];for(let resource of resources)resource.id&&!ids.has(resource.id)&&(ids.add(resource.id),result.push(resource));return result}function patientToAction(patient){return{id:patient.id,href:`/Patient/${patient.id}`,label:patient.name?formatHumanName4(patient.name[0]):patient.id,description:patient.birthDate,leftSection:jsx21(ResourceAvatar,{value:patient,radius:"xl",size:24})}}function patientsToActions(patients){let patientActions=patients.filter(p=>!!p.id).map(patientToAction);return patientActions.length>0?[{group:"Patients",actions:patientActions}]:[]}function resourcesToActions(resources,resourceTypes){let result=[],resourceTypeActions=resourceTypes.map(rt=>({id:`resource-type-${rt.code}`,href:`/${rt.code}`,label:rt.display??rt.code??"",description:"Resource Type"}));resourceTypeActions.length>0&&result.push({group:"Resource Types",actions:resourceTypeActions});let patientActions=[],serviceRequestActions=[];for(let resource of resources)resource.resourceType==="Patient"&&resource.id?patientActions.push(patientToAction(resource)):resource.resourceType==="ServiceRequest"&&resource.id&&serviceRequestActions.push({id:resource.id,href:`/ServiceRequest/${resource.id}`,label:resource.id,description:resource.subject?.display});return patientActions.length>0&&result.push({group:"Patients",actions:patientActions}),serviceRequestActions.length>0&&result.push({group:"Service Requests",actions:serviceRequestActions}),result}import{Fragment as Fragment6,jsx as jsx22,jsxs as jsxs12}from"react/jsx-runtime";function Navbar(props){let medplum=useMedplum6(),navigate=useMedplumNavigate4(),profile=useMedplumProfile3(),activeLink=getActiveLink(props.pathname,props.searchParams,props.menus),[userMenuOpened,setUserMenuOpened]=useState11(!1),[bookmarkDialogVisible,setBookmarkDialogVisible]=useState11(!1),projectDisplay=medplum.getProject()?.name??medplum.getActiveLogin()?.project.display;function onLinkClick2(e,to){e.stopPropagation(),e.preventDefault(),navigate(to),window.innerWidth<768&&props.closeNavbar()}function navigateResourceType(resourceType){resourceType&&navigate(`/${resourceType}`)}let opened=props.opened??!0;return jsxs12(Fragment6,{children:[jsxs12(MantineAppShell2.Navbar,{id:"navbar",className:Navbar_default.navbar,children:[props.logo&&jsx22(MantineAppShell2.Section,{px:"xs",pt:"xs",pb:"4px",children:jsx22(UnstyledButton2,{className:Navbar_default.logoButton,onClick:props.navbarToggle,"aria-expanded":opened,"aria-controls":"navbar","aria-label":"Medplum Logo",children:props.logo})}),jsx22(ScrollArea,{px:"xs",pb:"xs",pt:"sm",h:"100%",children:jsxs12(MantineAppShell2.Section,{grow:!0,children:[props.spotlightEnabled&&jsx22(Box6,{mb:2,children:jsx22(Tooltip2,{label:"Search",position:"right",transitionProps:{duration:0},disabled:opened,children:jsxs12(UnstyledButton2,{className:Navbar_default.link,onClick:()=>spotlight2.open(),"aria-label":"Search",children:[jsx22(IconSearch,{size:"1.2rem"}),jsx22("span",{className:Navbar_default.linkLabel,"data-opened":opened||void 0,children:"Search"})]})})}),props.spotlightEnabled&&jsx22(Spotlight,{patientsOnly:props.patientsOnly,staticActions:props.spotlightActions}),!props.resourceTypeSearchDisabled&&jsx22(MantineAppShell2.Section,{mb:"sm",children:jsx22(ResourceTypeInput,{name:"resourceType",placeholder:"Resource Type",maxValues:0,onChange:newValue=>navigateResourceType(newValue)},window.location.pathname)}),props.menus?.map((menu,index)=>jsxs12(Fragment5,{children:[menu.title&&jsx22(Text9,{className:Navbar_default.menuTitle,"data-opened":opened||void 0,children:menu.title}),jsx22(Stack4,{gap:"2",children:menu.links?.map(link=>link.notificationCount?jsx22(NavbarLinkWithSubscription,{to:link.href,active:link.href===activeLink?.href,onClick:e=>onLinkClick2(e,link.href),icon:link.icon,label:link.label??"",opened,alert:link.alert,notificationCount:link.notificationCount,onDismiss:link.onDismiss},link.href):jsx22(NavbarLinkContent,{to:link.href,active:link.href===activeLink?.href,onClick:e=>onLinkClick2(e,link.href),icon:link.icon,label:link.label??"",opened,alert:link.alert,count:link.count,onDismiss:link.onDismiss},link.href))})]},`menu-${menu.title??index}`)),props.displayAddBookmark&&jsx22(Tooltip2,{label:"Add Bookmark",position:"right",transitionProps:{duration:0},disabled:opened,children:jsxs12(UnstyledButton2,{className:`${Navbar_default.link} ${Navbar_default.addBookmarkLink}`,onClick:()=>setBookmarkDialogVisible(!0),children:[jsx22(IconCirclePlus,{}),jsx22("span",{className:Navbar_default.linkLabel,"data-opened":opened||void 0,children:"Add Bookmark"})]})})]})}),props.userMenuEnabled&&jsxs12(MantineAppShell2.Section,{px:"xs",py:"xs",children:[jsx22(Tooltip2,{label:opened?"Close Sidebar":"Open Sidebar",position:"right",transitionProps:{duration:0},children:jsx22(UnstyledButton2,{className:Navbar_default.toggleButton,"data-opened":opened||void 0,"aria-label":opened?"Close Sidebar":"Open Sidebar",onClick:props.navbarToggle,"aria-expanded":opened,"aria-controls":"navbar",children:jsx22(IconLayoutSidebar,{})})}),jsx22(Divider2,{my:"xs",className:Navbar_default.divider}),jsxs12(Menu3,{width:260,shadow:"md",radius:"md",position:"top-start",transitionProps:{transition:"fade-up"},opened:userMenuOpened,onClose:()=>setUserMenuOpened(!1),children:[jsx22(Menu3.Target,{children:jsxs12(UnstyledButton2,{className:`${Navbar_default.link} ${Navbar_default.userLink}`,pl:"7","aria-label":"User menu","data-active":userMenuOpened||void 0,onClick:()=>setUserMenuOpened(o=>!o),bd:"1px 0 0 0 solid var(--mantine-color-gray-200)",children:[jsx22(ResourceAvatar,{value:profile,radius:"xl",size:24}),jsxs12("span",{className:Navbar_default.userLinkLabel,"data-opened":opened||void 0,children:[jsx22(Text9,{span:!0,inherit:!0,truncate:!0,children:formatHumanName5(profile?.name?.[0])}),projectDisplay&&jsx22(Text9,{span:!0,inherit:!0,fz:"xs",c:"dimmed",truncate:!0,title:projectDisplay,children:projectDisplay})]})]})}),jsx22(Menu3.Dropdown,{className:HeaderDropdown_default.dropdown,children:jsx22(HeaderDropdown,{version:props.version,showLayoutVersionToggle:props.showLayoutVersionToggle})})]})]})]}),props.pathname&&props.searchParams&&jsx22(BookmarkDialog,{pathname:props.pathname,searchParams:props.searchParams,visible:bookmarkDialogVisible,onOk:()=>setBookmarkDialogVisible(!1),onCancel:()=>setBookmarkDialogVisible(!1)})]})}function NavbarLinkContent(props){let{to,icon,label,onClick,active,count,alert,opened,onDismiss}=props,showCount=count!==void 0&&count>0,iconElement=icon??jsx22(IconBookmark,{}),showDot=showCount&&alert&&!opened;function handleDismiss(e){e.preventDefault(),e.stopPropagation(),onDismiss?.()}return jsx22(Tooltip2,{label,position:"right",transitionProps:{duration:0},disabled:opened,children:jsxs12(MedplumLink,{to,onClick,className:Navbar_default.link,"data-active":active||void 0,children:[jsxs12("span",{className:Navbar_default.iconWrapper,children:[iconElement,showDot&&jsx22("span",{className:Navbar_default.alertDot})]}),jsx22("span",{className:Navbar_default.linkLabel,"data-opened":opened||void 0,children:label}),showCount&&jsx22("span",{className:Navbar_default.linkCount,"data-opened":opened||void 0,"data-alert":alert||void 0,children:count.toLocaleString()}),onDismiss&&opened&&jsx22(Tooltip2,{label:"Dismiss",openDelay:500,children:jsx22(UnstyledButton2,{"aria-label":"Dismiss",className:Navbar_default.dismissButton,onClick:handleDismiss,children:jsx22(IconX,{size:14})})})]})})}function NavbarLinkWithSubscription(props){let count=useNotificationCount(props.notificationCount);return jsx22(NavbarLinkContent,{to:props.to,active:props.active,onClick:props.onClick,icon:props.icon,label:props.label,opened:props.opened,alert:props.alert,count,onDismiss:props.onDismiss})}function getActiveLink(currentPathname,currentSearchParams,menus){if(!currentPathname||!currentSearchParams||!menus)return;let bestLink,bestScore=0;for(let menu of menus)if(menu.links)for(let link of menu.links){let score=getLinkScore(currentPathname,currentSearchParams,link.href);score>bestScore&&(bestScore=score,bestLink=link)}return bestLink}function getLinkScore(currentPathname,currentSearchParams,linkHref){let linkUrl=new URL(linkHref,"https://example.com");if(currentPathname!==linkUrl.pathname)return 0;let ignoredParams=["_count","_offset"];for(let[key,value]of linkUrl.searchParams.entries())if(!ignoredParams.includes(key)&&currentSearchParams.get(key)!==value)return 0;let count=1;for(let[key,value]of currentSearchParams.entries())ignoredParams.includes(key)||linkUrl.searchParams.get(key)===value&&count++;return count}import{jsx as jsx23,jsxs as jsxs13}from"react/jsx-runtime";var OPEN_WIDTH=250,CLOSED_WIDTH=59,HEADER_HEIGHT=60,ANNOUNCEMENT_HEIGHT=36;function AppShell(props){let[navbarOpen,setNavbarOpen]=useState12(localStorage.navbarOpen==="true"),[layoutVersion]=useState12(props.layoutVersion??localStorage.appShellLayoutVersion??"v1"),medplum=useMedplum7(),profile=useMedplumProfile4(),[dismissedAnnouncementIds,setDismissedAnnouncementIds]=useState12(()=>{try{let dismissed=localStorage.appShellDismissedAnnouncements;return new Set(dismissed?JSON.parse(dismissed):[])}catch{return new Set}}),visibleAnnouncements=props.announcements?.filter(announcement=>!announcement.id||!dismissedAnnouncementIds.has(announcement.id)),announcementHeight=visibleAnnouncements?.length?visibleAnnouncements.length*ANNOUNCEMENT_HEIGHT:0;function setNavbarOpenWrapper(open){localStorage.navbarOpen=open.toString(),setNavbarOpen(open)}function dismissAnnouncement(announcement){announcement.id&&setDismissedAnnouncementIds(dismissedIds=>{let updated=new Set(dismissedIds);return updated.add(announcement.id),localStorage.appShellDismissedAnnouncements=JSON.stringify([...updated]),updated}),announcement.onDismiss?.(announcement)}function closeNavbar(){setNavbarOpenWrapper(!1)}function toggleNavbar(){setNavbarOpenWrapper(!navbarOpen)}if(medplum.isLoading())return jsx23(Loading,{});let headerProp,navbarProp,headerComponent,navbarComponent;return layoutVersion==="v2"?(headerProp={height:announcementHeight},navbarProp={width:navbarOpen?OPEN_WIDTH:CLOSED_WIDTH,breakpoint:0,collapsed:{desktop:!profile,mobile:!profile}},headerComponent=visibleAnnouncements?.length?jsx23(MantineAppShell3.Header,{style:{zIndex:101},children:jsx23(AnnouncementBanners,{announcements:visibleAnnouncements,onDismiss:dismissAnnouncement})}):void 0,navbarComponent=profile?jsx23(Navbar,{logo:props.logo,pathname:props.pathname,searchParams:props.searchParams,menus:props.menus,navbarToggle:toggleNavbar,closeNavbar,displayAddBookmark:props.displayAddBookmark,resourceTypeSearchDisabled:!0,opened:navbarOpen,spotlightEnabled:!0,patientsOnly:props.spotlightPatientsOnly,spotlightActions:props.spotlightActions,userMenuEnabled:!0,version:props.version,showLayoutVersionToggle:props.showLayoutVersionToggle}):void 0):(headerProp={height:HEADER_HEIGHT+announcementHeight},navbarProp={width:OPEN_WIDTH,breakpoint:"sm",collapsed:{desktop:!profile||!navbarOpen,mobile:!profile||!navbarOpen}},headerComponent=profile&&jsx23(Header,{pathname:props.pathname,searchParams:props.searchParams,headerSearchDisabled:props.headerSearchDisabled,logo:props.logo,version:props.version,navbarOpen,navbarToggle:toggleNavbar,notifications:props.notifications,announcements:visibleAnnouncements,onDismissAnnouncement:dismissAnnouncement}),navbarComponent=profile&&navbarOpen?jsx23(Navbar,{pathname:props.pathname,searchParams:props.searchParams,menus:props.menus,navbarToggle:toggleNavbar,closeNavbar,displayAddBookmark:props.displayAddBookmark,resourceTypeSearchDisabled:props.resourceTypeSearchDisabled,patientsOnly:props.spotlightPatientsOnly,spotlightActions:props.spotlightActions}):void 0),jsxs13(MantineAppShell3,{header:headerProp,navbar:navbarProp,padding:0,children:[headerComponent,navbarComponent,jsx23(MantineAppShell3.Main,{className:AppShell_default.main,children:jsx23(ErrorBoundary,{children:jsx23(Suspense,{fallback:jsx23(Loading,{}),children:props.children})})})]})}import{getPathDisplayName,isPopulated as isPopulated2}from"@medplum/core";import{Anchor as Anchor2}from"@mantine/core";import{ContentType as ContentType2}from"@medplum/core";import{useCachedBinaryUrl as useCachedBinaryUrl2}from"@medplum/react-hooks";import{Button as Button2}from"@mantine/core";import{useEffect as useEffect2,useRef as useRef2,useState as useState13}from"react";import{Fragment as Fragment7,jsx as jsx24,jsxs as jsxs14}from"react/jsx-runtime";var CCDA_VIEWER_URL="https://ccda.medplum.com",BASE_VALIDATION_URL="https://ccda-validator.medplum.com/";function CcdaDisplay(props){let{url}=props,[shouldSend,setShouldSend]=useState13(!1),iframeRef=useRef2(null),[validationResult,setValidationResult]=useState13(),[validating,setValidating]=useState13(!1);useEffect2(()=>{url&&shouldSend&&iframeRef.current&&(sendCommand(iframeRef.current,{command:"loadCcdaXml",value:url}).catch(console.error),setShouldSend(!1))},[url,shouldSend]);let validateCcda=async()=>{if(url)try{setValidating(!0);let ccdaContent=await(await fetch(url)).text(),formData=new FormData;formData.append("ccdaFile",new Blob([ccdaContent],{type:"text/xml"}),"ccda.xml");let validationUrl=`${BASE_VALIDATION_URL}referenceccdaservice/?validationObjective=C-CDA_IG_Plus_Vocab&referenceFileName=No%20scenario%20File&curesUpdate=true&severityLevel=WARNING`,validationResponse=await fetch(validationUrl,{method:"POST",body:formData,credentials:"omit",redirect:"manual"});if(!validationResponse.ok)throw new Error(`Validation failed: ${validationResponse.status} ${validationResponse.statusText}`);let validationResult2=await validationResponse.json();setValidationResult(validationResult2)}catch(error){setValidationResult(void 0),console.error("CCDA validation error:",error)}finally{setValidating(!1)}},downloadResults=()=>{if(!validationResult)return;let resultsJson=JSON.stringify(validationResult,null,2);exportJsonFile(resultsJson,"ccda-validation-results")},getErrorCount=()=>validationResult?validationResult.resultsMetaData.resultMetaData.filter(item=>item?.type.includes("Error")).reduce((sum,item)=>sum+(item.count||0),0):0;return url?jsxs14("div",{"data-testid":"ccda-iframe",style:{maxWidth:props.maxWidth},children:[jsx24("div",{style:{minHeight:400},children:jsx24("iframe",{title:"C-CDA Viewer",width:"100%",height:"400",ref:iframeRef,src:CCDA_VIEWER_URL,allowFullScreen:!0,frameBorder:0,seamless:!0,onLoad:()=>setShouldSend(!0)})}),jsxs14("div",{style:{marginTop:"10px",marginBottom:"10px",display:"flex",alignItems:"center"},children:[jsx24(Button2,{type:"button",onClick:validateCcda,disabled:validating,children:validating?"Validating...":"Validate"}),validationResult&&jsxs14(Fragment7,{children:[jsxs14("div",{style:{marginLeft:"15px"},children:[jsx24("strong",{children:"Validation Results:"})," ",getErrorCount()," errors found"]}),jsx24(Button2,{type:"button",onClick:downloadResults,color:"green",style:{marginLeft:"auto"},children:"Download Full Results"})]})]})]}):null}import{Loader as Loader3}from"@mantine/core";import{useEffect as useEffect3,useRef as useRef3,useState as useState14}from"react";import{jsx as jsx25}from"react/jsx-runtime";function ScannedImage(props){let{maxRetries=5,...rest}=props,[attempt,setAttempt]=useState14(0),[status,setStatus]=useState14("fetching"),timeoutRef=useRef3(void 0);useEffect3(()=>()=>{timeoutRef.current!==void 0&&clearTimeout(timeoutRef.current)},[]);let handleError=()=>{if(attempt>=maxRetries){setStatus("failed");return}setStatus("backoff");let delay=Math.min(1e3*2**attempt,16e3);timeoutRef.current=setTimeout(()=>{setAttempt(a=>a+1),setStatus("fetching"),timeoutRef.current=void 0},delay)};return status==="failed"?jsx25("div",{className:"image-placeholder",children:"Image unavailable"}):status==="backoff"?jsx25(Loader3,{}):jsx25("img",{onLoad:()=>setStatus("loaded"),onError:handleError,...rest})}import{jsx as jsx26,jsxs as jsxs15}from"react/jsx-runtime";function AttachmentDisplay(props){let{contentType,data:data2,url:uncachedUrl,title}=props.value??{},cachedUrl=useCachedBinaryUrl2(uncachedUrl);if(!cachedUrl&&!data2)return null;let url=cachedUrl??`data:${contentType};base64,${data2}`;return jsxs15("div",{"data-testid":"attachment-display",children:[contentType?.startsWith("image/")&&jsx26(ScannedImage,{"data-testid":"attachment-image",style:{maxWidth:props.maxWidth},src:url,alt:title}),contentType?.startsWith("video/")&&jsx26("video",{"data-testid":"attachment-video",style:{maxWidth:props.maxWidth},controls:!0,children:jsx26("source",{type:contentType,src:url})}),(contentType?.startsWith("text/")||contentType==="application/json"||contentType==="application/pdf")&&jsx26("div",{"data-testid":"attachment-iframe",style:{maxWidth:props.maxWidth,minHeight:400},children:jsx26("iframe",{title:"Attachment",width:"100%",height:"400",src:url+"#navpanes=0",allowFullScreen:!0,frameBorder:0,seamless:!0})}),contentType===ContentType2.CDA_XML&&jsx26(CcdaDisplay,{url}),jsx26("div",{"data-testid":"download-link",style:{padding:"2px 16px 16px 16px"},children:jsx26(Anchor2,{href:uncachedUrl,"data-testid":"attachment-details",target:"_blank",rel:"noopener noreferrer",download:getDownloadName(title),children:title||"Download"})})]})}function getDownloadName(title){return title?.includes(".")?title:void 0}var DescriptionList_default={root:"DescriptionList_root",compact:"DescriptionList_compact"};import{Fragment as Fragment8,jsx as jsx27,jsxs as jsxs16}from"react/jsx-runtime";function DescriptionList(props){let{children,compact}=props;return jsx27("dl",{className:clsx_default(DescriptionList_default.root,{[DescriptionList_default.compact]:compact}),children})}function DescriptionListEntry(props){return jsxs16(Fragment8,{children:[jsx27("dt",{children:props.term}),jsx27("dd",{children:props.children})]})}import{Fragment as Fragment9,jsx as jsx28}from"react/jsx-runtime";function AttachmentArrayDisplay(props){let attachmentElements=props.values?.map((v,index)=>jsx28("div",{children:jsx28(AttachmentDisplay,{value:v,maxWidth:props.maxWidth})},"attatchment-"+index)),content;if(props.includeDescriptionListEntry){if(props.property===void 0)throw new Error("props.property is required when includeDescriptionListEntry is true");if(!isPopulated2(props.path))throw new Error("props.path is required when includeDescriptionListEntry is true");let key=props.path.split(".").pop();content=jsx28(DescriptionListEntry,{term:getPathDisplayName(key),children:attachmentElements})}else content=jsx28(Fragment9,{children:attachmentElements});return content}import{ActionIcon as ActionIcon2}from"@mantine/core";import{useState as useState15}from"react";import{normalizeOperationOutcome}from"@medplum/core";import{useMedplum as useMedplum8}from"@medplum/react-hooks";import{useRef as useRef4}from"react";import{Fragment as Fragment10,jsx as jsx29,jsxs as jsxs17}from"react/jsx-runtime";function AttachmentButton(props){let medplum=useMedplum8(),fileInputRef=useRef4(null);function onClick(e){killEvent(e),fileInputRef.current?.click()}function onFileChange(e){killEvent(e);let files=e.target.files;files&&Array.from(files).forEach(processFile)}function processFile(file){!file||!file.name||(props.onUploadStart&&props.onUploadStart(),medplum.createAttachment({data:file,contentType:file.type||"application/octet-stream",filename:file.name,securityContext:props.securityContext,onProgress:props.onUploadProgress}).then(attachment=>props.onUpload(attachment)).catch(err=>{props.onUploadError&&props.onUploadError(normalizeOperationOutcome(err))}))}return jsxs17(Fragment10,{children:[jsx29("input",{disabled:props.disabled,type:"file","data-testid":"upload-file-input",style:{display:"none"},ref:fileInputRef,onChange:e=>onFileChange(e)}),props.children({onClick,disabled:props.disabled})]})}import{jsx as jsx30,jsxs as jsxs18}from"react/jsx-runtime";function AttachmentArrayInput(props){let[values,setValues]=useState15(props.defaultValue??[]);function setValuesWrapper(newValues){setValues(newValues),props.onChange&&props.onChange(newValues)}return jsxs18("table",{style:{width:"100%"},children:[jsxs18("colgroup",{children:[jsx30("col",{width:"97%"}),jsx30("col",{width:"3%"})]}),jsxs18("tbody",{children:[values.map((v,index)=>jsxs18("tr",{children:[jsx30("td",{children:jsx30(AttachmentDisplay,{value:v,maxWidth:200})}),jsx30("td",{children:jsx30(ActionIcon2,{disabled:props.disabled,title:"Remove",variant:"subtle",size:"sm",color:"gray",onClick:e=>{killEvent(e);let copy=values.slice();copy.splice(index,1),setValuesWrapper(copy)},children:jsx30(IconCircleMinus,{})})})]},`${index}-${values.length}`)),jsxs18("tr",{children:[jsx30("td",{}),jsx30("td",{children:jsx30(AttachmentButton,{disabled:props.disabled,onUpload:attachment=>{setValuesWrapper([...values,attachment])},children:props2=>jsx30(ActionIcon2,{...props2,title:"Add",variant:"subtle",size:"sm",color:props2.disabled?"gray":"green",children:jsx30(IconCloudUpload,{})})})})]})]})]})}import{Button as Button3}from"@mantine/core";import{useState as useState16}from"react";import{Fragment as Fragment11,jsx as jsx31,jsxs as jsxs19}from"react/jsx-runtime";function AttachmentInput(props){let[value,setValue]=useState16(props.defaultValue);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}return value?jsxs19(Fragment11,{children:[jsx31(AttachmentDisplay,{value,maxWidth:200}),jsx31(Button3,{disabled:props.disabled,onClick:e=>{killEvent(e),setValueWrapper(void 0)},children:"Remove"})]}):jsx31(AttachmentButton,{disabled:props.disabled,securityContext:props.securityContext,onUpload:setValueWrapper,children:props2=>jsx31(Button3,{...props2,children:"Upload..."})})}import{Button as Button4,Flex as Flex2,Group as Group10,Stack as Stack5,Title}from"@mantine/core";import{normalizeOperationOutcome as normalizeOperationOutcome2}from"@medplum/core";import{useMedplum as useMedplum9}from"@medplum/react-hooks";import{useState as useState17}from"react";import{Container as MantineContainer}from"@mantine/core";var Container_default={root:"Container_root"};import{jsx as jsx32}from"react/jsx-runtime";function Container(props){let{children,...others}=props;return jsx32(MantineContainer,{className:Container_default.root,...others,children})}import{Paper}from"@mantine/core";var Panel_default={paper:"Panel_paper",fill:"Panel_fill"};import{jsx as jsx33}from"react/jsx-runtime";function Panel(props){let{width,fill,className,children,...rest}=props,style=width?{maxWidth:width}:void 0;return jsx33(Paper,{className:clsx_default(Panel_default.paper,fill&&Panel_default.fill,className),style,shadow:"sm",radius:"sm",withBorder:!0,...rest,children})}import{jsx as jsx34}from"react/jsx-runtime";function Document(props){let{children,...others}=props;return jsx34(Container,{children:jsx34(Panel,{...others,children})})}import{jsx as jsx35,jsxs as jsxs20}from"react/jsx-runtime";function Logo(props){let overrideUrl=import.meta.env.MEDPLUM_LOGO_URL;return overrideUrl?jsx35("img",{src:overrideUrl,alt:"Logo",style:{maxHeight:props.size}}):jsxs20("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 180 180",style:{width:props.size,height:props.size},children:[jsx35("title",{children:"Medplum Logo"}),jsx35("path",{fill:props.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"})]})}import{PasswordInput as MantinePasswordInput}from"@mantine/core";import{jsx as jsx36}from"react/jsx-runtime";function PasswordInput(props){let{visibilityToggleButtonProps,...rest}=props;return jsx36(MantinePasswordInput,{...rest,visibilityToggleButtonProps:{"aria-label":"Toggle password visibility",tabIndex:0,...visibilityToggleButtonProps}})}function getErrorsForInput(outcome,expression){return outcome?.issue?.filter(issue=>isExpressionMatch(issue.expression?.[0],expression))?.map(issue=>issue.details?.text)?.join(`
103
- `)}function getIssuesForExpression(outcome,expression){return outcome?.issue?.filter(issue=>isExpressionMatch(issue.expression?.[0],expression))}var ARRAY_INDEX_REGEX=/\[\d+\]/;function isExpressionMatch(expr1,expr2){let isExpr1Indexed=typeof expr1=="string"&&ARRAY_INDEX_REGEX.test(expr1),isExpr2Indexed=typeof expr2=="string"&&ARRAY_INDEX_REGEX.test(expr2);if(isExpr1Indexed!==isExpr2Indexed&&(expr1=expr1?.replace(ARRAY_INDEX_REGEX,""),expr2=expr2?.replace(ARRAY_INDEX_REGEX,"")),expr1===expr2)return!0;if(!expr1||!expr2)return!1;let dot1=expr1.indexOf(".");if(dot1>=0&&expr1.substring(dot1+1)===expr2)return!0;let dot2=expr2.indexOf(".");return dot2>=0&&expr2.substring(dot2+1)===expr1}import{jsx as jsx37,jsxs as jsxs21}from"react/jsx-runtime";function ChangePasswordForm(props){let{onSuccess}=props,medplum=useMedplum9(),[outcome,setOutcome]=useState17(),[success,setSuccess]=useState17(!1);return jsx37(Document,{width:450,children:jsxs21(Form,{onSubmit:formData=>{setOutcome(void 0),medplum.post("auth/changepassword",formData).then(()=>{setSuccess(!0),onSuccess?.()}).catch(err=>setOutcome(normalizeOperationOutcome2(err)))},children:[jsxs21(Flex2,{direction:"column",align:"center",justify:"center",children:[jsx37(Logo,{size:32}),jsx37(Title,{children:"Change password"})]}),!success&&jsxs21(Stack5,{gap:"xl",mt:"xl",children:[jsx37(PasswordInput,{name:"oldPassword",label:"Old password",required:!0,autoFocus:!0,error:getErrorsForInput(outcome,"oldPassword")}),jsx37(PasswordInput,{name:"newPassword",label:"New password",required:!0,error:getErrorsForInput(outcome,"newPassword")}),jsx37(PasswordInput,{name:"confirmPassword",label:"Confirm new password",required:!0,error:getErrorsForInput(outcome,"confirmPassword")}),jsx37(Group10,{justify:"flex-end",mt:"xl",wrap:"nowrap",children:jsx37(Button4,{type:"submit",children:"Change password"})})]}),success&&jsx37("div",{"data-testid":"success",children:"Password changed successfully"})]})})}import{Checkbox,Flex as Flex3,Group as Group11,Stack as Stack6,Title as Title2}from"@mantine/core";import{useMedplum as useMedplum10}from"@medplum/react-hooks";import{Fragment as Fragment12}from"react/jsx-runtime";import{jsx as jsx38,jsxs as jsxs22}from"react/jsx-runtime";var openConditionScope=/^patient\/Condition\.(?:\*|c?r?u?d?s?)$/,encounterDiagnosis="?category=http://terminology.hl7.org/CodeSystem/condition-category|encounter-diagnosis",problemListItem="?category=http://terminology.hl7.org/CodeSystem/condition-category|problem-list-item",healthConcern="?category=http://hl7.org/fhir/us/core/CodeSystem/condition-category|health-concern",openObservationScope=/^patient\/Observation\.(?:\*|c?r?u?d?s?)$/,clinicalTest="?category=http://hl7.org/fhir/us/core/CodeSystem/us-core-observation-category|clinical-test",laboratory="?category=http://terminology.hl7.org/CodeSystem/observation-category|laboratory",socialHistory="?category=http://terminology.hl7.org/CodeSystem/observation-category|social-history",sdoh="?category=http://hl7.org/fhir/us/core/CodeSystem/us-core-category|sdoh",survey="?category=http://terminology.hl7.org/CodeSystem/observation-category|survey",vitalSigns="?category=http://terminology.hl7.org/CodeSystem/observation-category|vital-signs";function ChooseScopeForm(props){let medplum=useMedplum10();return jsx38(Form,{onSubmit:formData=>{medplum.post("auth/scope",{login:props.login,scope:Object.keys(formData).join(" ")}).then(props.handleAuthResponse).catch(console.log)},children:jsxs22(Stack6,{children:[jsxs22(Flex3,{direction:"column",align:"center",justify:"center",children:[props.logo??jsx38(Logo,{size:32}),jsx38(Title2,{order:3,py:"lg",children:props.title??"Choose scope"}),props.children]}),jsx38(Stack6,{children:(props.scope??"openid").split(" ").map(scopeName=>{let additionalScopes;return openConditionScope.test(scopeName)?additionalScopes=[scopeName+encounterDiagnosis,scopeName+problemListItem,scopeName+healthConcern]:openObservationScope.test(scopeName)&&(additionalScopes=[scopeName+clinicalTest,scopeName+laboratory,scopeName+socialHistory,scopeName+sdoh,scopeName+survey,scopeName+vitalSigns]),jsxs22(Fragment12,{children:[jsx38(Checkbox,{id:scopeName,name:scopeName,label:scopeName,defaultChecked:!0},scopeName),additionalScopes?.map(scope=>jsx38(Checkbox,{id:scope,name:scope,label:scope},scope))]},scopeName+"_group")})}),jsx38(Group11,{justify:"flex-end",mt:"xl",children:jsx38(SubmitButton,{fullWidth:!0,children:props.submitLabel??"Set Scope"})})]})})}import{Button as Button5,Center as Center3,Stack as Stack8,Text as Text11,Title as Title4}from"@mantine/core";import{useState as useState19}from"react";import{Alert as Alert2,Center as Center2,Image as Image2,Stack as Stack7,Text as Text10,TextInput as TextInput4,Title as Title3}from"@mantine/core";import{normalizeErrorString as normalizeErrorString5}from"@medplum/core";import{useState as useState18}from"react";import{jsx as jsx39,jsxs as jsxs23}from"react/jsx-runtime";function MfaForm(props){let[errorMessage,setErrorMessage]=useState18();return jsxs23(Form,{onSubmit:formData=>{setErrorMessage(void 0),props.onSubmit(formData)?.catch(err=>setErrorMessage(normalizeErrorString5(err)))},children:[jsxs23(Center2,{style:{flexDirection:"column"},children:[jsx39(Logo,{size:32}),jsx39(Title3,{order:3,py:"lg",children:props.title}),!props.qrCodeUrl&&props.description&&jsx39(Text10,{c:"dimmed",mb:"lg",mt:"-lg",ta:"center",children:props.description})]}),errorMessage&&jsx39(Alert2,{icon:jsx39(IconAlertCircle,{size:16}),title:"Error",color:"red",mb:"lg",children:errorMessage}),props.qrCodeUrl&&jsx39(Center2,{children:jsxs23(Stack7,{mb:"xl",justify:"center",children:[props.description&&jsx39(Text10,{c:"dimmed",mb:"md",mt:"-lg",ta:"center",children:props.description}),jsx39(Image2,{src:props.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))"}})]})}),jsx39(Stack7,{gap:"sm",children:jsx39(TextInput4,{name:"token",label:"MFA code",autoComplete:"one-time-code",required:!0,autoFocus:!0})}),jsxs23(Stack7,{gap:"xs",pt:"md",children:[jsx39(SubmitButton,{fullWidth:!0,children:props.buttonText}),props.footer]})]})}import{jsx as jsx40,jsxs as jsxs24}from"react/jsx-runtime";function MfaEnrollForm(props){let{allowedMethods,qrCodeUrl,onEnrollEmail,onEnrollTotp}=props,[selected,setSelected]=useState19(),emailAllowed=allowedMethods.includes("email"),totpAllowed=allowedMethods.includes("totp");return emailAllowed&&totpAllowed&&!selected?jsxs24(Center3,{style:{flexDirection:"column"},children:[jsx40(Logo,{size:32}),jsx40(Title4,{order:3,py:"lg",ta:"center",children:"Set up multi-factor authentication"}),jsxs24(Stack8,{w:"100%",children:[jsx40(Text11,{c:"dimmed",ta:"center",children:"Choose how you want to verify your identity when you sign in."}),jsx40(Button5,{fullWidth:!0,onClick:()=>setSelected("totp"),children:"Use an authenticator app (recommended)"}),jsx40(Button5,{fullWidth:!0,variant:"default",onClick:onEnrollEmail,children:"Continue with email-based MFA"})]})]}):emailAllowed&&!totpAllowed?jsxs24(Center3,{style:{flexDirection:"column"},children:[jsx40(Logo,{size:32}),jsx40(Title4,{order:3,py:"lg",children:"Set up email-based MFA"}),jsxs24(Stack8,{w:"100%",children:[jsx40(Text11,{c:"dimmed",ta:"center",children:"When you sign in, we'll email you a verification code to confirm your identity."}),jsx40(Button5,{fullWidth:!0,onClick:onEnrollEmail,children:"Enable email-based MFA"})]})]}):jsx40(MfaForm,{title:props.totpTitle,description:props.totpDescription,buttonText:props.totpButtonText??"Enroll",qrCodeUrl,onSubmit:fields=>onEnrollTotp(fields.token)})}import{Anchor as Anchor3}from"@mantine/core";import{showNotification as showNotification3}from"@mantine/notifications";import{normalizeErrorString as normalizeErrorString6}from"@medplum/core";import{useState as useState20}from"react";import{Fragment as Fragment13,jsx as jsx41,jsxs as jsxs25}from"react/jsx-runtime";function MfaVerificationForm(props){let{methods,email,onRequestEmailCode,onSubmit}=props,[emailMode,setEmailMode]=useState20(!!props.initialEmailMode),requestEmailCode=()=>{Promise.resolve(onRequestEmailCode()).then(()=>setEmailMode(!0)).catch(err=>showNotification3({color:"red",message:normalizeErrorString6(err)}))},footer;return emailMode?footer=jsx41(Anchor3,{component:"button",type:"button",size:"sm",ta:"center",onClick:requestEmailCode,children:"Resend code"}):methods.includes("email")&&(footer=jsx41(Anchor3,{component:"button",type:"button",size:"sm",ta:"center",onClick:requestEmailCode,children:"Get a code by email instead"})),jsx41(MfaForm,{title:emailMode?"Enter verification code":"Enter MFA code",description:emailMode?jsxs25(Fragment13,{children:["Enter the 6-digit code we emailed",email?" to ":"",email&&jsx41("strong",{children:email})]}):"Enter the code from your authenticator app.",buttonText:props.buttonText??"Submit code",onSubmit:fields=>onSubmit(fields.token),footer})}import{normalizeOperationOutcome as normalizeOperationOutcome5}from"@medplum/core";import{useMedplum as useMedplum13}from"@medplum/react-hooks";import{useEffect as useEffect6,useState as useState24}from"react";import{Alert as Alert3}from"@mantine/core";import{isOk,operationOutcomeIssueToString}from"@medplum/core";import{jsx as jsx42}from"react/jsx-runtime";function OperationOutcomeAlert(props){let{outcome,issues:issuesProp,displayOkOutcomes,...spacingProps}=props,issues=outcome?.issue||issuesProp;return!issues||issues.length===0||outcome&&isOk(outcome)&&!displayOkOutcomes?null:jsx42(Alert3,{icon:jsx42(IconAlertCircle,{size:16}),color:"red",...spacingProps,children:issues.map(issue=>jsx42("div",{"data-testid":"text-field-error",children:operationOutcomeIssueToString(issue)},issue.details?.text))})}import{Anchor as Anchor4,Flex as Flex4,Stack as Stack9,Text as Text12,TextInput as TextInput5,Title as Title5}from"@mantine/core";import{normalizeOperationOutcome as normalizeOperationOutcome3}from"@medplum/core";import{useMedplum as useMedplum11}from"@medplum/react-hooks";import{useState as useState21}from"react";import{jsx as jsx43,jsxs as jsxs26}from"react/jsx-runtime";function NewProjectForm(props){let medplum=useMedplum11(),[outcome,setOutcome]=useState21(),issues=getIssuesForExpression(outcome,void 0);return jsxs26(Form,{onSubmit:async formData=>{try{props.handleAuthResponse(await medplum.startNewProject({login:props.login,projectName:formData.projectName}))}catch(err){setOutcome(normalizeOperationOutcome3(err))}},children:[jsxs26(Flex4,{direction:"column",align:"center",justify:"center",children:[jsx43(Logo,{size:32}),jsx43(Title5,{order:3,py:"lg",children:"Create a new project"})]}),jsx43(OperationOutcomeAlert,{issues,mb:"lg"}),jsx43(Stack9,{gap:"sm",children:jsx43(TextInput5,{name:"projectName",label:"Project Name",placeholder:"My Project",required:!0,autoFocus:!0,error:getErrorsForInput(outcome,"projectName")})}),jsxs26(Stack9,{gap:"xs",mt:"md",children:[jsx43(SubmitButton,{fullWidth:!0,children:"Create Project"}),jsxs26(Text12,{c:"dimmed",size:"xs",pt:"lg",ta:"center",children:['By clicking "Create Project" you agree to the Medplum'," ",jsx43(Anchor4,{href:"https://www.medplum.com/privacy",children:"Privacy\xA0Policy"})," and ",jsx43(Anchor4,{href:"https://www.medplum.com/terms",children:"Terms\xA0of\xA0Service"}),"."]})]})]})}import{Anchor as Anchor5,Box as Box8,Checkbox as Checkbox2,Divider as Divider3,Flex as Flex5,Stack as Stack10,Text as Text13,TextInput as TextInput6}from"@mantine/core";import{normalizeOperationOutcome as normalizeOperationOutcome4}from"@medplum/core";import{useMedplum as useMedplum12}from"@medplum/react-hooks";import{useEffect as useEffect5,useState as useState23}from"react";import{Box as Box7}from"@mantine/core";import{useEffect as useEffect4,useRef as useRef5,useState as useState22}from"react";function createScriptTag(src,onload){let head=document.getElementsByTagName("head")[0],script=document.createElement("script");script.async=!0,script.src=src,script.onload=onload??null,head.appendChild(script)}import{jsx as jsx44}from"react/jsx-runtime";function GoogleButton(props){let{googleClientId,handleGoogleCredential}=props,parentRef=useRef5(null),[scriptLoaded,setScriptLoaded]=useState22(typeof google<"u"),initializedRef=useRef5(!1),buttonRenderedRef=useRef5(!1);return useEffect4(()=>{if(typeof google>"u"){createScriptTag("https://accounts.google.com/gsi/client",()=>setScriptLoaded(!0));return}initializedRef.current||(google.accounts.id.initialize({client_id:googleClientId,callback:handleGoogleCredential}),initializedRef.current=!0),parentRef.current&&!buttonRenderedRef.current&&(google.accounts.id.renderButton(parentRef.current,{type:"standard",logo_alignment:"center",width:parentRef.current.clientWidth}),buttonRenderedRef.current=!0)},[googleClientId,scriptLoaded,handleGoogleCredential]),googleClientId?jsx44(Box7,{ref:parentRef,w:"100%",h:40,display:"flex",style:{justifyContent:"center"}}):null}import{locationUtils as locationUtils3}from"@medplum/core";function getGoogleClientId(clientId){if(clientId)return clientId;let origin=locationUtils3.getOrigin();if(origin&&("undefined"?.split(",")??[]).includes(origin))return"__GOOGLE_CLIENT_ID__"}function initRecaptcha(siteKey){typeof grecaptcha>"u"&&createScriptTag("https://www.google.com/recaptcha/api.js?render="+siteKey)}function getRecaptcha(siteKey){return new Promise((resolve,reject)=>{grecaptcha.ready(async()=>{try{resolve(await grecaptcha.execute(siteKey,{action:"submit"}))}catch(err){reject(err)}})})}import{Fragment as Fragment14,jsx as jsx45,jsxs as jsxs27}from"react/jsx-runtime";function NewUserForm(props){let googleClientId=getGoogleClientId(props.googleClientId),recaptchaSiteKey=props.recaptchaSiteKey,medplum=useMedplum12(),[outcome,setOutcome]=useState23(),issues=getIssuesForExpression(outcome,void 0);return useEffect5(()=>{recaptchaSiteKey&&initRecaptcha(recaptchaSiteKey)},[recaptchaSiteKey]),jsxs27(Form,{onSubmit:async formData=>{setOutcome(void 0);try{let recaptchaToken="";recaptchaSiteKey&&(recaptchaToken=await getRecaptcha(recaptchaSiteKey)),props.handleAuthResponse(await medplum.startNewUser({projectId:props.projectId,clientId:props.clientId,firstName:formData.firstName,lastName:formData.lastName,email:formData.email,password:formData.password,remember:formData.remember==="true",recaptchaSiteKey,recaptchaToken}))}catch(err){setOutcome(normalizeOperationOutcome4(err))}},children:[jsx45(Flex5,{direction:"column",align:"center",justify:"center",children:props.children}),jsx45(OperationOutcomeAlert,{issues,mb:"lg"}),googleClientId&&jsxs27(Fragment14,{children:[jsx45(Box8,{style:{minHeight:40},children:jsx45(GoogleButton,{googleClientId,handleGoogleCredential:async response=>{try{props.handleAuthResponse(await medplum.startGoogleLogin({googleClientId:response.clientId,googleCredential:response.credential,projectId:props.projectId,createUser:!0}))}catch(err){setOutcome(normalizeOperationOutcome4(err))}}})}),jsx45(Divider3,{label:"or",labelPosition:"center",my:"lg"})]}),jsxs27(Stack10,{gap:"sm",children:[jsx45(TextInput6,{name:"firstName",type:"text",label:"First name",placeholder:"First name",required:!0,autoFocus:!0,error:getErrorsForInput(outcome,"firstName")}),jsx45(TextInput6,{name:"lastName",type:"text",label:"Last name",placeholder:"Last name",required:!0,error:getErrorsForInput(outcome,"lastName")}),jsx45(TextInput6,{name:"email",type:"email",label:"Email",placeholder:"name@domain.com",required:!0,error:getErrorsForInput(outcome,"email")}),jsx45(PasswordInput,{name:"password",label:"Password",autoComplete:"off",required:!0,error:getErrorsForInput(outcome,"password")})]}),jsxs27(Stack10,{gap:"xs",children:[jsx45(Checkbox2,{id:"remember",name:"remember",label:"Remember me",size:"xs",style:{lineHeight:1},pt:"md",pb:"xs"}),jsx45(SubmitButton,{fullWidth:!0,children:"Register Account"}),props.onSignIn&&jsxs27(Text13,{size:"sm",mt:"lg",c:"dimmed",ta:"center","data-dashlane-ignore":"true","data-lp-ignore":"true","data-no-autofill":"true","data-form-type":"navigation",children:["Already have an account?"," ",jsx45(Anchor5,{component:"button",type:"button",onClick:props.onSignIn,children:"Sign In"})]}),jsxs27(Text13,{c:"dimmed",size:"xs",pt:"lg",ta:"center",children:['By clicking "Register Account" you agree to the Medplum'," ",jsx45(Anchor5,{href:"https://www.medplum.com/privacy",children:"Privacy\xA0Policy"})," and ",jsx45(Anchor5,{href:"https://www.medplum.com/terms",children:"Terms\xA0of\xA0Service"}),"."]}),jsxs27(Text13,{c:"dimmed",size:"xs",ta:"center",children:["This site is protected by reCAPTCHA and the Google"," ",jsx45(Anchor5,{href:"https://policies.google.com/privacy",children:"Privacy\xA0Policy"})," and ",jsx45(Anchor5,{href:"https://policies.google.com/terms",children:"Terms\xA0of\xA0Service"})," apply."]})]})]})}import{jsx as jsx46,jsxs as jsxs28}from"react/jsx-runtime";function RegisterForm(props){let{type,projectId,clientId,googleClientId,recaptchaSiteKey,onSuccess,onSignIn}=props,medplum=useMedplum13(),[login,setLogin]=useState24(props.login),[outcome,setOutcome]=useState24(),[emailVerificationRequired,setEmailVerificationRequired]=useState24(!1);useEffect6(()=>{type==="patient"&&login&&medplum.startNewPatient({login,projectId}).then(response=>medplum.processCode(response.code)).then(()=>onSuccess()).catch(err=>setOutcome(normalizeOperationOutcome5(err)))},[medplum,type,projectId,login,onSuccess]);function handleAuthResponse(response){response.code&&medplum.processCode(response.code).then(()=>onSuccess()).catch(err=>setOutcome(normalizeOperationOutcome5(err))),response.login&&setLogin(response.login),response.emailVerificationRequired&&setEmailVerificationRequired(!0)}let issues=getIssuesForExpression(outcome,void 0);return jsxs28(Document,{width:400,px:"xl",py:"xl",bdrs:"md",children:[jsx46(OperationOutcomeAlert,{issues,mb:"lg"}),!login&&jsx46(NewUserForm,{projectId,clientId,googleClientId,recaptchaSiteKey,onSignIn,handleAuthResponse,children:props.children}),emailVerificationRequired&&jsx46("div",{children:"Please check your email for a verification link. Click the link to continue setting up your account."}),login&&!emailVerificationRequired&&type==="project"&&jsx46(NewProjectForm,{login,handleAuthResponse})]})}import{Anchor as Anchor6,Flex as Flex6,Stack as Stack11,Text as Text14,TextInput as TextInput7,Title as Title6}from"@mantine/core";import{normalizeOperationOutcome as normalizeOperationOutcome6}from"@medplum/core";import{useMedplum as useMedplum14}from"@medplum/react-hooks";import{useEffect as useEffect7,useState as useState25}from"react";import{Fragment as Fragment15,jsx as jsx47,jsxs as jsxs29}from"react/jsx-runtime";function ResetPasswordForm(props){let{projectId,recaptchaSiteKey,onSuccess,onSignIn,onRegister}=props,medplum=useMedplum14(),[outcome,setOutcome]=useState25(),[success,setSuccess]=useState25(!1);return useEffect7(()=>{recaptchaSiteKey&&initRecaptcha(recaptchaSiteKey)},[recaptchaSiteKey]),jsx47(Document,{width:400,px:"xl",py:"xl",bdrs:"md",children:jsxs29(Form,{onSubmit:async formData=>{setOutcome(void 0);try{let recaptchaToken="";recaptchaSiteKey&&(recaptchaToken=await getRecaptcha(recaptchaSiteKey)),await medplum.post("auth/resetpassword",{...formData,projectId,recaptchaToken}),setSuccess(!0),onSuccess?.()}catch(err){setOutcome(normalizeOperationOutcome6(err))}},children:[jsxs29(Flex6,{direction:"column",align:"center",justify:"center",children:[jsx47(Logo,{size:32}),jsx47(Title6,{order:3,py:"lg",children:"Reset your password"})]}),jsx47(OperationOutcomeAlert,{issues:getIssuesForExpression(outcome,void 0),mb:"lg"}),!success&&jsxs29(Fragment15,{children:[jsx47(Stack11,{gap:"sm",mb:"md",children:jsx47(TextInput7,{name:"email",type:"email",label:"Email",placeholder:"name@domain.com",required:!0,autoFocus:!0,error:getErrorsForInput(outcome,"email")})}),jsxs29(Stack11,{gap:"xs",children:[jsx47(SubmitButton,{fullWidth:!0,children:"Reset Password"}),onSignIn&&jsx47(Text14,{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:jsx47(Anchor6,{onClick:onSignIn,children:"Back to Sign In"})}),onRegister&&jsxs29(Text14,{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? ",jsx47(Anchor6,{onClick:onRegister,children:"Sign Up"})]})]})]}),success&&jsx47(Text14,{c:"dimmed",size:"sm",ta:"center",mt:"md",children:"If the account exists on our system, a password reset email will be sent."})]})})}import{Anchor as Anchor7,Button as Button6,Flex as Flex7,Group as Group12,Stack as Stack12,Title as Title7}from"@mantine/core";import{badRequest,normalizeOperationOutcome as normalizeOperationOutcome7}from"@medplum/core";import{useMedplum as useMedplum15}from"@medplum/react-hooks";import{useState as useState26}from"react";import{jsx as jsx48,jsxs as jsxs30}from"react/jsx-runtime";function SetPasswordForm(props){let{id,secret,onSuccess,onSignIn}=props,medplum=useMedplum15(),[outcome,setOutcome]=useState26(),[success,setSuccess]=useState26(!1),issues=getIssuesForExpression(outcome,void 0);return jsxs30(Document,{width:450,children:[jsx48(OperationOutcomeAlert,{issues}),jsxs30(Form,{onSubmit:formData=>{if(formData.password!==formData.confirmPassword){setOutcome(badRequest("Passwords do not match","confirmPassword"));return}setOutcome(void 0),medplum.post("auth/setpassword",{id,secret,password:formData.password}).then(()=>{setSuccess(!0),onSuccess?.()}).catch(err=>setOutcome(normalizeOperationOutcome7(err)))},children:[jsxs30(Flex7,{direction:"column",align:"center",justify:"center",children:[jsx48(Logo,{size:32}),jsx48(Title7,{children:"Set password"})]}),!success&&jsxs30(Stack12,{children:[jsx48(PasswordInput,{name:"password",label:"New password",required:!0,error:getErrorsForInput(outcome,"password")}),jsx48(PasswordInput,{name:"confirmPassword",label:"Confirm new password",required:!0,error:getErrorsForInput(outcome,"confirmPassword")}),jsx48(Group12,{justify:"flex-end",mt:"xl",children:jsx48(Button6,{type:"submit",children:"Set password"})})]}),success&&jsxs30("div",{"data-testid":"success",children:["Password set. You can now\xA0",onSignIn?jsx48(Anchor7,{component:"button",type:"button",onClick:onSignIn,children:"sign in"}):"sign in","."]})]})]})}import{showNotification as showNotification4}from"@mantine/notifications";import{normalizeErrorString as normalizeErrorString7}from"@medplum/core";import{useMedplum as useMedplum18}from"@medplum/react-hooks";import{useCallback as useCallback6,useEffect as useEffect8,useRef as useRef6,useState as useState29}from"react";import{ActionIcon as ActionIcon3,Anchor as Anchor8,Box as Box9,Checkbox as Checkbox3,Divider as Divider4,Flex as Flex8,Stack as Stack13,Text as Text15,TextInput as TextInput8}from"@mantine/core";import{locationUtils as locationUtils4,normalizeOperationOutcome as normalizeOperationOutcome8}from"@medplum/core";import{useMedplum as useMedplum16}from"@medplum/react-hooks";import{useCallback as useCallback5,useState as useState27}from"react";import{Fragment as Fragment16,jsx as jsx49,jsxs as jsxs31}from"react/jsx-runtime";function AuthenticationForm(props){let[email,setEmail]=useState27();return email?jsx49(PasswordForm,{email,resetEmail:()=>setEmail(void 0),...props}):jsx49(EmailForm,{setEmail,...props})}function EmailForm(props){let{setEmail,onRegister,handleAuthResponse,children,disableEmailAuth,...baseLoginRequest}=props,medplum=useMedplum16(),googleClientId=!props.disableGoogleAuth&&getGoogleClientId(props.googleClientId),[outcome,setOutcome]=useState27(),issues=getIssuesForExpression(outcome,void 0),isExternalAuth=useCallback5(async authMethod=>{if(!authMethod.authorizeUrl)return!1;let state=JSON.stringify({...await medplum.ensureCodeChallenge(baseLoginRequest),domain:authMethod.domain,returnTo:locationUtils4.getLocation()}),url=new URL(authMethod.authorizeUrl);return url.searchParams.set("state",state),locationUtils4.assign(url.toString()),!0},[medplum,baseLoginRequest]),handleSubmit=useCallback5(async formData=>{let authMethod=await medplum.post("auth/method",{email:formData.email});await isExternalAuth(authMethod)||setEmail(formData.email)},[medplum,isExternalAuth,setEmail]),handleGoogleCredential=useCallback5(async response=>{try{let authResponse=await medplum.startGoogleLogin({...baseLoginRequest,googleCredential:response.credential});await isExternalAuth(authResponse)||handleAuthResponse(authResponse)}catch(err){setOutcome(normalizeOperationOutcome8(err))}},[medplum,baseLoginRequest,isExternalAuth,handleAuthResponse]);return jsxs31(Form,{onSubmit:handleSubmit,children:[jsx49(Flex8,{direction:"column",align:"center",justify:"center",children}),jsx49(OperationOutcomeAlert,{issues,mb:"lg"}),googleClientId&&jsxs31(Fragment16,{children:[jsx49(Box9,{style:{minHeight:40},children:jsx49(GoogleButton,{googleClientId,handleGoogleCredential})}),!disableEmailAuth&&jsx49(Divider4,{label:"or",labelPosition:"center",my:"lg"})]}),!disableEmailAuth&&jsx49(TextInput8,{name:"email",type:"email",label:"Email",mb:"md",placeholder:"name@domain.com",required:!0,autoFocus:!0,error:getErrorsForInput(outcome,"email"),"data-testid":"auth.email"}),jsxs31(Stack13,{gap:"xs",children:[!disableEmailAuth&&jsx49(SubmitButton,{fullWidth:!0,children:"Continue"}),onRegister&&jsxs31(Text15,{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\u2019t have an account? ",jsx49(Anchor8,{onClick:onRegister,children:"Register"})]})]})]})}function PasswordForm(props){let{onForgotPassword,handleAuthResponse,children,...baseLoginRequest}=props,medplum=useMedplum16(),[outcome,setOutcome]=useState27(),issues=getIssuesForExpression(outcome,void 0),handleSubmit=useCallback5(formData=>medplum.startLogin({...baseLoginRequest,password:formData.password,remember:formData.remember==="on"}).then(handleAuthResponse).catch(err=>setOutcome(normalizeOperationOutcome8(err))),[medplum,baseLoginRequest,handleAuthResponse]);return jsxs31(Form,{onSubmit:handleSubmit,children:[jsx49(Flex8,{direction:"column",align:"center",justify:"center",children}),jsx49(OperationOutcomeAlert,{issues,mb:"lg"}),jsxs31(Stack13,{gap:"sm",children:[jsx49(TextInput8,{label:"Email",value:props.email,disabled:!0,rightSectionWidth:36,rightSection:jsx49(ActionIcon3,{variant:"subtle",color:"gray",onClick:props.resetEmail,"aria-label":"Change email",children:jsx49(IconPencil,{size:"1rem",stroke:1.5})})}),jsx49(PasswordInput,{name:"password",label:"Password",autoComplete:"off",required:!0,autoFocus:!0,error:getErrorsForInput(outcome,"password"),"data-testid":"auth.password"})]}),jsxs31(Stack13,{gap:"xs",children:[jsx49(Checkbox3,{id:"remember",name:"remember",label:"Remember me",size:"xs",style:{lineHeight:1},pt:"md",pb:"xs"}),jsx49(SubmitButton,{children:"Sign In"}),onForgotPassword&&jsx49(Text15,{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:jsx49(Anchor8,{onClick:onForgotPassword,children:"Reset Password"})})]})]})}import{Anchor as Anchor9,Combobox as Combobox2,Flex as Flex9,Stack as Stack14,Text as Text16,TextInput as TextInput9,Title as Title8,useCombobox as useCombobox2}from"@mantine/core";import{getIdentifier,normalizeOperationOutcome as normalizeOperationOutcome9}from"@medplum/core";import{useMedplum as useMedplum17}from"@medplum/react-hooks";import{useState as useState28}from"react";import{jsx as jsx50,jsxs as jsxs32}from"react/jsx-runtime";function ChooseProfileForm(props){let medplum=useMedplum17(),combobox=useCombobox2(),[search,setSearch]=useState28(""),[outcome,setOutcome]=useState28();function filterDisplay(display){return!!display?.toLowerCase()?.includes(search.toLowerCase())}function filterMembership(membership){return filterDisplay(membership.profile?.display)||filterDisplay(membership.project?.display)||filterDisplay(getMembershipLabel(membership))}function handleValueSelect(membershipId){medplum.post("auth/profile",{login:props.login,profile:membershipId}).then(props.handleAuthResponse).catch(err=>setOutcome(normalizeOperationOutcome9(err)))}let options=props.memberships.filter(filterMembership).slice(0,10).map(item=>jsx50(Combobox2.Option,{value:item.id,className:ProjectLoginOption_default.interactive,children:jsx50(ProjectMembershipLoginOption,{membership:item,label:getMembershipLabel(item)})},item.id));return jsxs32(Stack14,{gap:"0",children:[jsxs32(Flex9,{justify:"center",align:"center",direction:"column",wrap:"nowrap",children:[jsx50(Logo,{size:32}),jsx50(Title8,{order:3,py:"lg",children:"Choose a Project"})]}),jsx50(OperationOutcomeAlert,{outcome,mb:"lg"}),jsxs32(Combobox2,{store:combobox,onOptionSubmit:handleValueSelect,children:[jsx50(Combobox2.EventsTarget,{children:jsx50(TextInput9,{placeholder:"Search",value:search,mb:"md",autoFocus:!0,leftSection:jsx50(IconSearch,{size:16}),onChange:event=>{setSearch(event.currentTarget.value),combobox.updateSelectedOptionIndex()}})}),jsx50("div",{children:jsx50(Combobox2.Options,{style:{marginLeft:"-10px",marginRight:"-10px",marginBottom:"-10px"},children:options.length>0?options:jsx50(Combobox2.Empty,{children:"Nothing found..."})})})]}),jsx50(Text16,{size:"sm",ta:"center",mt:"md",children:jsx50(Anchor9,{component:"button",type:"button",onClick:()=>{window.location.href=`/signin?project=new&login=${props.login}`},children:"Create a new project"})})]})}function getMembershipLabel(membership){return getIdentifier(membership,"https://medplum.com/identifier/label")}import{jsx as jsx51}from"react/jsx-runtime";function SignInForm(props){let{login:loginCode,chooseScopes,chooseScopeFormProps,onSuccess,onForgotPassword,onRegister,onCode,...baseLoginRequest}=props,medplum=useMedplum18(),[login,setLogin]=useState29(),loginRequested=useRef6(!1),[mfaEnrollRequired,setMfaEnrollRequired]=useState29(!1),[enrollQrCode,setEnrollQrCode]=useState29(),[enrollMethods,setEnrollMethods]=useState29(),[mfaRequired,setMfaRequired]=useState29(!1),[mfaMethods,setMfaMethods]=useState29(),[mfaEmail,setMfaEmail]=useState29(),[mfaEmailMode,setMfaEmailMode]=useState29(!1),[memberships,setMemberships]=useState29(),handleCode=useCallback6(code=>{onCode?onCode(code):medplum.processCode(code).then(()=>{onSuccess&&onSuccess()}).catch(err=>showNotification4({color:"red",message:normalizeErrorString7(err)}))},[medplum,onCode,onSuccess]),handleAuthResponse=useCallback6(response=>{if(setMfaEnrollRequired(!!response.mfaEnrollRequired),setEnrollQrCode(response.enrollQrCode),setEnrollMethods(response.allowedMfaMethods),setMfaRequired(!!response.mfaRequired),response.mfaRequired){let methods=response.mfaMethods;setMfaMethods(methods),setMfaEmail(response.email),methods?.length===1&&methods[0]==="email"&&setMfaEmailMode(!0)}else setMfaMethods(void 0),setMfaEmail(void 0),setMfaEmailMode(!1);response.login&&setLogin(response.login),response.memberships&&setMemberships(response.memberships),response.code&&(chooseScopes?setMemberships(void 0):handleCode(response.code))},[chooseScopes,handleCode]),requestEmailCode=useCallback6(async()=>{login&&await medplum.post("auth/mfa/send-email",{login})},[medplum,login]),enrollEmail=useCallback6(()=>{login&&medplum.post("auth/mfa/login-enroll",{login,method:"email"}).then(handleAuthResponse).catch(err=>showNotification4({color:"red",message:normalizeErrorString7(err)}))},[medplum,login,handleAuthResponse]),handleScopeResponse=useCallback6(response=>{handleCode(response.code)},[handleCode]);return useEffect8(()=>{loginCode&&!loginRequested.current&&!login&&(loginRequested.current=!0,medplum.get("auth/login/"+loginCode).then(handleAuthResponse).catch(err=>showNotification4({color:"red",message:normalizeErrorString7(err)})))},[medplum,loginCode,loginRequested,login,handleAuthResponse]),jsx51(Document,{width:400,px:"xl",py:"xl",bdrs:"md",children:login?mfaEnrollRequired?jsx51(MfaEnrollForm,{allowedMethods:enrollMethods??["totp"],qrCodeUrl:enrollQrCode,onEnrollEmail:enrollEmail,totpTitle:"Enroll in MFA",totpDescription:"Scan this QR code with your authenticator app.",onEnrollTotp:async token=>{let res=await medplum.post("auth/mfa/login-enroll",{login,method:"totp",token});handleAuthResponse(res)}}):mfaRequired?jsx51(MfaVerificationForm,{methods:mfaMethods??[],email:mfaEmail,initialEmailMode:mfaEmailMode,onRequestEmailCode:requestEmailCode,onSubmit:async token=>{let res=await medplum.post("auth/mfa/verify",{login,token});handleAuthResponse(res)}}):props.projectId==="new"?jsx51(NewProjectForm,{login,handleAuthResponse}):memberships?jsx51(ChooseProfileForm,{login,memberships,handleAuthResponse}):props.chooseScopes?jsx51(ChooseScopeForm,{login,scope:props.scope,handleAuthResponse:handleScopeResponse,...chooseScopeFormProps}):jsx51("div",{children:"Success"}):jsx51(AuthenticationForm,{onForgotPassword,onRegister,handleAuthResponse,disableGoogleAuth:props.disableGoogleAuth,disableEmailAuth:props.disableEmailAuth,...baseLoginRequest,children:props.children})})}import{buildElementsContext as buildElementsContext2,getPathDisplayName as getPathDisplayName3,isEmpty as isEmpty2,tryGetDataType}from"@medplum/core";import{useContext as useContext6,useMemo as useMemo6}from"react";import{ActionIcon as ActionIcon4,CopyButton,Flex as Flex10,Tooltip as Tooltip3}from"@mantine/core";import{formatDateTime,formatPeriod,formatTiming,formatWallTime,isEmpty,isObject,isString,PropertyType}from"@medplum/core";import{useState as useState32}from"react";import{formatCodeableConcept}from"@medplum/core";import{Fragment as Fragment17,jsx as jsx52}from"react/jsx-runtime";function CodeableConceptDisplay(props){return jsx52(Fragment17,{children:formatCodeableConcept(props.value)})}import{formatCoding}from"@medplum/core";import{Fragment as Fragment18,jsx as jsx53}from"react/jsx-runtime";function CodingDisplay(props){return jsx53(Fragment18,{children:formatCoding(props.value,props.includeCode)})}import{Fragment as Fragment19,jsx as jsx54}from"react/jsx-runtime";function ContactPointDisplay(props){let contactPoint=props.value;if(!contactPoint)return null;let builder=[];return contactPoint.value&&builder.push(contactPoint.value),(contactPoint.use||contactPoint.system)&&(builder.push(" ["),contactPoint.use&&builder.push(contactPoint.use),contactPoint.use&&contactPoint.system&&builder.push(" "),contactPoint.system&&builder.push(contactPoint.system),builder.push("]")),jsx54(Fragment19,{children:builder.join("").trim()})}import{Fragment as Fragment20,jsx as jsx55,jsxs as jsxs33}from"react/jsx-runtime";function ContactDetailDisplay(props){let contactDetail=props.value;return contactDetail?jsxs33(Fragment20,{children:[contactDetail.name,contactDetail.name&&": ",contactDetail.telecom?.map(telecom=>jsx55(ContactPointDisplay,{value:telecom},`telecom-${contactDetail.name}-${telecom.value}`))]}):null}import{getDataType,isPopulated as isPopulated3,isProfileLoaded,tryGetProfile}from"@medplum/core";import{useMedplum as useMedplum19}from"@medplum/react-hooks";import{useContext as useContext3,useEffect as useEffect9,useMemo as useMemo3,useState as useState30}from"react";import{getTypedPropertyValue,getTypedPropertyValueWithSchema}from"@medplum/core";function getValueAndType(context,path,profileUrl){let typedResult=getTypedPropertyValue(context,path,{profileUrl});return typedResult?Array.isArray(typedResult)?[typedResult.map(e=>e.value),typedResult[0].type]:[typedResult.value,typedResult.type]:[void 0,"undefined"]}function getValueAndTypeFromElement(typedValue,path,element){let typedResult=getTypedPropertyValueWithSchema(typedValue,path,element);return typedResult?Array.isArray(typedResult)?[typedResult.map(e=>e.value),typedResult[0].type]:[typedResult.value,typedResult.type]:[void 0,"undefined"]}import{jsx as jsx56}from"react/jsx-runtime";function ExtensionDisplay(props){let{elementDefinitionType}=props,medplum=useMedplum19(),ctx=useContext3(ElementsContext),[typeSchema,setTypeSchema]=useState30(getDataType("Extension")),profileUrl=useMemo3(()=>{if(isPopulated3(elementDefinitionType?.profile))return elementDefinitionType.profile[0]},[elementDefinitionType]),[loadingProfile,setLoadingProfile]=useState30(profileUrl!==void 0);if(useEffect9(()=>{profileUrl&&(setLoadingProfile(!0),medplum.requestProfileSchema(profileUrl).then(()=>{let profile=tryGetProfile(profileUrl);setLoadingProfile(!1),profile&&setTypeSchema(profile)}).catch(reason=>{setLoadingProfile(!1),console.warn(reason)}))},[medplum,profileUrl]),profileUrl&&(loadingProfile||!isProfileLoaded(profileUrl)))return jsx56("div",{children:"Loading..."});if(typeSchema.elements["value[x]"]?.max!==0){let[propertyValue,propertyType]=getValueAndType({type:"Extension",value:props.value},"value[x]",profileUrl??ctx.profileUrl);return jsx56(ResourcePropertyDisplay,{propertyType,value:propertyValue})}return jsx56(BackboneElementDisplay,{path:props.path,value:{type:typeSchema.type,value:props.value},compact:props.compact,ignoreMissingValues:props.ignoreMissingValues,link:props.link,profileUrl})}import{formatHumanName as formatHumanName6}from"@medplum/core";import{Fragment as Fragment21,jsx as jsx57}from"react/jsx-runtime";function HumanNameDisplay(props){let name=props.value;return name?jsx57(Fragment21,{children:formatHumanName6(name,props.options)}):null}import{jsxs as jsxs34}from"react/jsx-runtime";function IdentifierDisplay(props){return jsxs34("div",{children:[props.value?.system,": ",props.value?.value]})}import{formatMoney}from"@medplum/core";import{Fragment as Fragment22,jsx as jsx58}from"react/jsx-runtime";function MoneyDisplay(props){return jsx58(Fragment22,{children:formatMoney(props.value)})}import{formatQuantity}from"@medplum/core";import{Fragment as Fragment23,jsx as jsx59}from"react/jsx-runtime";function QuantityDisplay(props){return jsx59(Fragment23,{children:formatQuantity(props.value,props.precision)})}import{formatRange}from"@medplum/core";import{Fragment as Fragment24,jsx as jsx60}from"react/jsx-runtime";function RangeDisplay(props){return jsx60(Fragment24,{children:formatRange(props.value,props.precision,props.exclusive)})}import{Fragment as Fragment25,jsx as jsx61,jsxs as jsxs35}from"react/jsx-runtime";function RatioDisplay(props){let value=props.value;return value?jsxs35(Fragment25,{children:[jsx61(QuantityDisplay,{value:value.numerator,precision:props.precision}),"\xA0/\xA0",jsx61(QuantityDisplay,{value:value.denominator,precision:props.precision})]}):null}import{stringify}from"@medplum/core";import{Fragment as Fragment26,jsx as jsx62}from"react/jsx-runtime";function ReferenceDisplay(props){if(!props.value)return null;let displayString=props.value.display||props.value.reference||stringify(props.value);return props.link!==!1&&props.value.reference?jsx62(MedplumLink,{to:props.value,children:displayString}):jsx62(Fragment26,{children:displayString})}import{Group as Group13,Text as Text17}from"@mantine/core";import{getPathDisplayName as getPathDisplayName2,isPopulated as isPopulated6}from"@medplum/core";import{useMedplum as useMedplum20}from"@medplum/react-hooks";import{useContext as useContext5,useEffect as useEffect10,useMemo as useMemo5,useState as useState31}from"react";import{getValueSliceName,isPopulated as isPopulated4,isSliceDefinitionWithTypes,tryGetProfile as tryGetProfile2}from"@medplum/core";function assignValuesIntoSlices(values,slices,slicing,profileUrl){if(!isPopulated4(slicing?.slices))return[values];let slicedValues=new Array(slices.length+1);for(let i=0;i<slicedValues.length;i++)slicedValues[i]=[];for(let value of values){let sliceName=getValueSliceName(value,slices,slicing.discriminator,profileUrl),sliceIndex=sliceName?slices.findIndex(slice=>slice.name===sliceName):-1;sliceIndex===-1&&(sliceIndex=slices.length),slicedValues[sliceIndex].push(value)}return slicedValues}async function prepareSlices({medplum,property}){return new Promise((resolve,reject)=>{if(!property.slicing){resolve([]);return}let supportedSlices=[],profileUrls=[],promises=[];for(let slice of property.slicing.slices){if(!isSliceDefinitionWithTypes(slice)){console.debug("Unsupported slice definition",slice);continue}let profileUrl;isPopulated4(slice.elements)||(profileUrl=slice.type[0]?.profile?.[0]),supportedSlices.push(slice),profileUrls.push(profileUrl),profileUrl&&promises.push(medplum.requestProfileSchema(profileUrl))}Promise.all(promises).then(()=>{for(let i=0;i<supportedSlices.length;i++){let slice=supportedSlices[i],profileUrl=profileUrls[i];if(profileUrl){let typeSchema=tryGetProfile2(profileUrl);slice.typeSchema=typeSchema}}resolve(supportedSlices)}).catch(reject)})}import{buildElementsContext,isPopulated as isPopulated5}from"@medplum/core";import{useContext as useContext4,useMemo as useMemo4}from"react";import{jsx as jsx63}from"react/jsx-runtime";function maybeWrapWithContext(ContextProvider,contextValue,contents){return contextValue!==void 0?jsx63(ContextProvider,{value:contextValue,children:contents}):contents}import{Fragment as Fragment27,jsx as jsx64}from"react/jsx-runtime";function SliceDisplay(props){let{slice,property}=props,sliceElements=slice.typeSchema?.elements??slice.elements,parentContext=useContext4(ElementsContext),contextValue=useMemo4(()=>{if(isPopulated5(sliceElements))return buildElementsContext({parentContext,elements:sliceElements,path:props.path,profileUrl:slice.typeSchema?.url})},[parentContext,props.path,slice.typeSchema?.url,sliceElements]);return maybeWrapWithContext(ElementsContext.Provider,contextValue,jsx64(Fragment27,{children:props.value.map((value,valueIndex)=>jsx64("div",{children:jsx64(ResourcePropertyDisplay,{property,path:props.path,arrayElement:!0,elementDefinitionType:slice.type[0],propertyType:slice.type[0].code,value,ignoreMissingValues:props.ignoreMissingValues,link:props.link})},`${valueIndex}-${props.value.length}`))}))}import{Fragment as Fragment28,jsx as jsx65,jsxs as jsxs36}from"react/jsx-runtime";var MAX_ARRAY_SIZE=50;function ResourceArrayDisplay(props){let{property,propertyType}=props,medplum=useMedplum20(),values=useMemo5(()=>Array.isArray(props.values)?props.values:[],[props.values]),[loading,setLoading]=useState31(!0),[slices,setSlices]=useState31([]),[slicedValues,setSlicedValues]=useState31(()=>[values]),[valuesLength,setValuesLength]=useState31(0),ctx=useContext5(ElementsContext);if(useEffect10(()=>{prepareSlices({medplum,property}).then(slices2=>{setValuesLength(values.length),setSlices(slices2);let limitedValues=values.slice(0,MAX_ARRAY_SIZE),slicedValues2=assignValuesIntoSlices(limitedValues,slices2,property.slicing,ctx.profileUrl);setSlicedValues(slicedValues2),setLoading(!1)}).catch(reason=>{console.error(reason),setLoading(!1)})},[medplum,property,ctx.profileUrl,setSlicedValues,values]),loading)return jsx65("div",{children:"Loading..."});let nonSliceContent;if(property.type[0]?.code!=="Extension"){let nonSliceValues=slicedValues[slices.length],nonSliceElements=nonSliceValues.map((value,valueIndex)=>jsx65("div",{children:jsx65(ResourcePropertyDisplay,{path:props.path,arrayElement:!0,property,propertyType,value,ignoreMissingValues:props.ignoreMissingValues,link:props.link})},`${valueIndex}-${nonSliceValues.length}`));if(props.includeDescriptionListEntry){if(!isPopulated6(props.path))throw new Error("props.path is required when includeDescriptionListEntry is true");let key=props.path.split(".").pop();nonSliceContent=jsx65(DescriptionListEntry,{term:getPathDisplayName2(key),children:nonSliceElements})}else nonSliceContent=jsx65(Fragment28,{children:nonSliceElements})}return jsxs36(Fragment28,{children:[slices.map((slice,sliceIndex)=>{if(!props.path)throw new Error(`Displaying a resource property with slices of type ${props.propertyType} requires path`);let sliceDisplay=jsx65(SliceDisplay,{path:props.path,slice,property,value:slicedValues[sliceIndex],ignoreMissingValues:props.ignoreMissingValues,link:props.link},slice.name);return props.includeDescriptionListEntry&&(sliceDisplay=jsx65(DescriptionListEntry,{term:getPathDisplayName2(slice.name),children:sliceDisplay},slice.name)),sliceDisplay}),nonSliceContent,valuesLength>MAX_ARRAY_SIZE&&jsx65(Group13,{justify:"right",children:jsxs36(Text17,{children:["... ",valuesLength," total values"]})})]})}import{Fragment as Fragment29,jsx as jsx66,jsxs as jsxs37}from"react/jsx-runtime";function ResourcePropertyDisplay(props){let{property,propertyType,value}=props;if(property?.path?.endsWith(".id"))return jsxs37(Flex10,{gap:3,align:"center",children:[value,!isEmpty(value)&&jsx66(CopyButton,{value,timeout:2e3,children:({copied,copy})=>jsx66(Tooltip3,{label:copied?"Copied":"Copy",withArrow:!0,position:"right",children:jsx66(ActionIcon4,{variant:"subtle",color:copied?"teal":"gray",onClick:copy,children:copied?jsx66(IconCheck,{size:"1rem"}):jsx66(IconCopy,{size:"1rem"})})})})]});if(property&&(property.isArray||property.max>1)&&!props.arrayElement)return propertyType===PropertyType.Attachment?jsx66(AttachmentArrayDisplay,{values:value,maxWidth:props.maxWidth,includeDescriptionListEntry:props.includeArrayDescriptionListEntry,property,path:props.path}):jsx66(ResourceArrayDisplay,{path:props.path,property,propertyType,values:value,includeDescriptionListEntry:props.includeArrayDescriptionListEntry,ignoreMissingValues:props.ignoreMissingValues,link:props.link});switch(propertyType){case PropertyType.boolean:return jsx66(Fragment29,{children:value===void 0?"":(!!value).toString()});case PropertyType.SystemString:case PropertyType.string:return props.property?.path?.toLowerCase().includes("secret")?jsx66(SecretFieldDisplay,{value}):jsx66("div",{style:{whiteSpace:"pre-wrap"},children:value});case PropertyType.code:case PropertyType.date:case PropertyType.decimal:case PropertyType.id:case PropertyType.integer:case PropertyType.positiveInt:case PropertyType.unsignedInt:case PropertyType.uri:case PropertyType.url:case PropertyType.xhtml:return isObject(value)&&!isString(value)?(console.warn("Non-standard FHIR data or missing primitive value with extension",{path:props.path,propertyType,value}),null):jsx66(Fragment29,{children:value?.toString()});case PropertyType.canonical:return jsx66(ReferenceDisplay,{value:{reference:value},link:props.link});case PropertyType.dateTime:case PropertyType.instant:return jsx66(Fragment29,{children:formatDateTime(value)});case PropertyType.time:return jsx66(Fragment29,{children:formatWallTime(value)});case PropertyType.markdown:return jsx66("pre",{children:value});case PropertyType.Address:return jsx66(AddressDisplay,{value});case PropertyType.Annotation:return jsx66(Fragment29,{children:value?.text});case PropertyType.Attachment:return jsx66(AttachmentDisplay,{value,maxWidth:props.maxWidth});case PropertyType.CodeableConcept:return jsx66(CodeableConceptDisplay,{value});case PropertyType.Coding:return jsx66(CodingDisplay,{value});case PropertyType.ContactDetail:return jsx66(ContactDetailDisplay,{value});case PropertyType.ContactPoint:return jsx66(ContactPointDisplay,{value});case PropertyType.HumanName:return jsx66(HumanNameDisplay,{value});case PropertyType.Identifier:return jsx66(IdentifierDisplay,{value});case PropertyType.Money:return jsx66(MoneyDisplay,{value});case PropertyType.Period:return jsx66(Fragment29,{children:formatPeriod(value)});case PropertyType.Quantity:case PropertyType.Duration:return jsx66(QuantityDisplay,{value});case PropertyType.Range:return jsx66(RangeDisplay,{value});case PropertyType.Ratio:return jsx66(RatioDisplay,{value});case PropertyType.Reference:return jsx66(ReferenceDisplay,{value,link:props.link});case PropertyType.Timing:return jsx66(Fragment29,{children:formatTiming(value)});case PropertyType.Dosage:case PropertyType.UsageContext:if(!props.path)throw new Error(`Displaying property of type ${props.propertyType} requires path`);return jsx66(BackboneElementDisplay,{path:props.path,value:{type:propertyType,value},compact:!0,ignoreMissingValues:props.ignoreMissingValues});case PropertyType.Extension:if(!props.path)throw new Error(`Displaying property of type ${props.propertyType} requires path`);return jsx66(ExtensionDisplay,{path:props.path,value,compact:!0,ignoreMissingValues:props.ignoreMissingValues,elementDefinitionType:props.elementDefinitionType});default:if(!property)throw new Error(`Displaying property of type ${props.propertyType} requires element schema`);if(!props.path)throw new Error(`Displaying property of type ${props.propertyType} requires path`);return jsx66(BackboneElementDisplay,{path:props.path,value:{type:property.type[0].code,value},compact:!0,ignoreMissingValues:props.ignoreMissingValues})}}function SecretFieldDisplay(props){let[isVisible,setIsVisible]=useState32(!1),secretValue=props.value??"",hasValue=!isEmpty(secretValue),MASK="\u2022".repeat(8);return jsxs37(Flex10,{gap:3,align:"center",children:[isVisible?jsx66("div",{style:{whiteSpace:"pre-wrap"},children:secretValue}):jsx66("div",{style:{whiteSpace:"pre-wrap"},"aria-hidden":"true",children:hasValue?MASK:""}),hasValue&&jsxs37(Fragment29,{children:[jsx66(CopyButton,{value:props.value,timeout:2e3,children:({copied,copy})=>jsx66(Tooltip3,{label:copied?"Copied":"Copy secret",withArrow:!0,position:"right",children:jsx66(ActionIcon4,{variant:"subtle",color:copied?"teal":"gray",onClick:copy,"aria-label":copied?"Copied":"Copy secret",children:copied?jsx66(IconCheck,{size:"1rem"}):jsx66(IconCopy,{size:"1rem"})})})}),jsx66(Tooltip3,{label:isVisible?"Hide secret":"Show secret",withArrow:!0,position:"right",children:jsx66(ActionIcon4,{variant:"subtle",color:"gray",onClick:()=>setIsVisible(!isVisible),"aria-label":isVisible?"Hide secret":"Show secret",children:isVisible?jsx66(IconEyeOff,{size:"1rem"}):jsx66(IconEye,{size:"1rem"})})})]})]})}import{jsx as jsx67,jsxs as jsxs38}from"react/jsx-runtime";var EXTENSION_KEYS2=["extension","modifierExtension"],IGNORED_PROPERTIES2=DEFAULT_IGNORED_PROPERTIES.filter(prop=>!EXTENSION_KEYS2.includes(prop));function BackboneElementDisplay(props){let typedValue=props.value,{value,type:typeName}=typedValue,parentElementsContext=useContext6(ElementsContext),profileUrl=props.profileUrl??parentElementsContext?.profileUrl,typeSchema=useMemo6(()=>tryGetDataType(typeName,profileUrl),[profileUrl,typeName]),newElementsContext=useMemo6(()=>{if(typeSchema)return buildElementsContext2({parentContext:parentElementsContext,elements:typeSchema.elements,path:props.path,profileUrl:typeSchema.url,accessPolicyResource:props.accessPolicyResource})},[typeSchema,parentElementsContext,props.path,props.accessPolicyResource]);if(isEmpty2(value))return null;if(!typeSchema)return jsxs38("div",{children:[typeName,"\xA0not implemented"]});if(typeof value=="object"&&"name"in value&&Object.keys(value).length===1&&typeof value.name=="string")return jsx67("div",{children:value.name});let elementsContext=newElementsContext??parentElementsContext;return maybeWrapWithContext(ElementsContext.Provider,newElementsContext,jsx67(DescriptionList,{compact:props.compact,children:Object.entries(elementsContext.elements).map(([key,property])=>{if(EXTENSION_KEYS2.includes(key)&&isEmpty2(property.slicing?.slices))return null;if(IGNORED_PROPERTIES2.includes(key))return null;if(DEFAULT_IGNORED_NON_NESTED_PROPERTIES.includes(key)&&property.path.split(".").length===2||key.includes("."))return null;let[propertyValue,propertyType]=getValueAndType(typedValue,key,elementsContext.profileUrl);if((props.ignoreMissingValues||property.max===0)&&isEmpty2(propertyValue)||props.path.endsWith(".extension")&&(key==="url"||key==="id"))return null;let isArrayProperty=property.max>1||property.isArray,resourcePropertyDisplay=jsx67(ResourcePropertyDisplay,{property,propertyType,path:props.path+"."+key,value:propertyValue,ignoreMissingValues:props.ignoreMissingValues,includeArrayDescriptionListEntry:isArrayProperty,link:props.link},key);return isArrayProperty?resourcePropertyDisplay:jsx67(DescriptionListEntry,{term:getPathDisplayName3(key),children:resourcePropertyDisplay},key)})}))}import{Box as Box11}from"@mantine/core";import{buildElementsContext as buildElementsContext4,tryGetDataType as tryGetDataType2}from"@medplum/core";import{useContext as useContext23,useMemo as useMemo22,useState as useState53}from"react";import{Stack as Stack18}from"@mantine/core";import{getPathDisplayName as getPathDisplayName5}from"@medplum/core";import{useContext as useContext22,useMemo as useMemo21,useState as useState52}from"react";import{Group as Group14,Input}from"@mantine/core";import{useContext as useContext7}from"react";var FormSection_default={dimmed:"FormSection_dimmed",preserveBreaks:"FormSection_preserveBreaks"};import{Tooltip as Tooltip4}from"@mantine/core";import{jsx as jsx68}from"react/jsx-runtime";var READ_ONLY_TOOLTIP_TEXT="Read Only";function maybeWrapWithTooltip(tooltipText,children){return tooltipText?jsx68(Tooltip4.Floating,{label:tooltipText,children}):children}import{jsx as jsx69,jsxs as jsxs39}from"react/jsx-runtime";function CheckboxFormSection(props){let{debugMode}=useContext7(ElementsContext),label;return debugMode&&props.fhirPath?label=`${props.title} - ${props.fhirPath}`:label=props.title,maybeWrapWithTooltip(props?.readonly?READ_ONLY_TOOLTIP_TEXT:void 0,jsxs39(Group14,{wrap:"nowrap","data-testid":props.testId,children:[jsx69("div",{children:props.children}),jsx69("div",{children:jsx69(Input.Wrapper,{id:props.htmlFor,label,classNames:{label:props?.readonly?FormSection_default.dimmed:void 0},description:props.description,withAsterisk:props.withAsterisk,children:null})})]}))}import{Input as Input2}from"@mantine/core";import{useContext as useContext8}from"react";import{jsx as jsx70}from"react/jsx-runtime";function FormSection(props){let{debugMode}=useContext8(ElementsContext),label;return debugMode&&props.fhirPath?label=`${props.title} - ${props.fhirPath}`:label=props.title,maybeWrapWithTooltip(props?.readonly?READ_ONLY_TOOLTIP_TEXT:void 0,jsx70(Input2.Wrapper,{id:props.htmlFor,label,classNames:{label:clsx_default({[FormSection_default.dimmed]:props?.readonly},FormSection_default.preserveBreaks)},description:props.description,withAsterisk:props.withAsterisk,error:getErrorsForInput(props.outcome,props.errorExpression??props.htmlFor),"data-testid":props.testId,children:props.children}))}import{capitalize,isEmpty as isEmpty3}from"@medplum/core";function setPropertyValue(obj,key,propName,elementDefinition,value){let types=elementDefinition.type;if(types.length>1)for(let type of types){let compoundKey=key.replace("[x]",capitalize(type.code));compoundKey in obj&&delete obj[compoundKey]}return isEmpty3(value)?obj[propName]=void 0:obj[propName]=value,obj}function isSupportedProfileStructureDefinition(profile){return!!profile&&!isEmpty3(profile.url)&&!isEmpty3(profile.name)}import{Checkbox as Checkbox4,Group as Group28,NativeSelect as NativeSelect9,Textarea as Textarea2,TextInput as TextInput18}from"@mantine/core";import{applyDefaultValuesToElement,capitalize as capitalize2,getPathDifference,HTTP_HL7_ORG,isComplexTypeCode,isEmpty as isEmpty6,isPopulated as isPopulated10,PropertyType as PropertyType2}from"@medplum/core";import{useContext as useContext21,useMemo as useMemo20,useState as useState51}from"react";import{useState as useState33}from"react";import{jsx as jsx71}from"react/jsx-runtime";function CodeableConceptInput(props){let{defaultValue:defaultValue2,onChange,withHelpText,outcome:_outcome,path:_path,valuePath:_valuePath,...rest}=props,[value,setValue]=useState33(defaultValue2);function handleChange(newValues){let newConcept=valueSetElementToCodeableConcept(newValues);setValue(newConcept),onChange&&onChange(newConcept)}return jsx71(ValueSetAutocomplete,{defaultValue:value&&codeableConceptToValueSetElement(value),onChange:handleChange,withHelpText:withHelpText??!0,...rest})}function codeableConceptToValueSetElement(concept){return concept.coding?.map(c=>({system:c.system,code:c.code,display:c.display}))}function valueSetElementToCodeableConcept(elements){if(elements.length!==0)return{coding:elements.map(e=>({system:e.system,code:e.code,display:e.display}))}}import{useState as useState34}from"react";import{jsx as jsx72}from"react/jsx-runtime";function CodingInput(props){let{defaultValue:defaultValue2,onChange,withHelpText,response,...rest}=props,[value,setValue]=useState34(response?.answer?.[0]?.valueCoding??defaultValue2);function handleChange(newValues){let newValue=newValues[0],newConcept=newValue&&valueSetElementToCoding(newValue);setValue(newConcept),onChange&&onChange(newConcept)}return jsx72(ValueSetAutocomplete,{defaultValue:value?codingToValueSetElement(value):void 0,maxValues:1,onChange:handleChange,withHelpText:withHelpText??!0,...rest})}function codingToValueSetElement(coding){return{system:coding.system,code:coding.code,display:coding.display}}function valueSetElementToCoding(element){return{system:element.system,code:element.code,display:element.display}}import{Group as Group16,TextInput as TextInput11}from"@mantine/core";import{useContext as useContext10,useMemo as useMemo8,useState as useState36}from"react";import{Group as Group15,NativeSelect as NativeSelect3,TextInput as TextInput10}from"@mantine/core";import{useContext as useContext9,useMemo as useMemo7,useState as useState35}from"react";import{jsx as jsx73,jsxs as jsxs40}from"react/jsx-runtime";function ContactPointInput(props){let{path,outcome}=props,{elementsByPath,getExtendedProps}=useContext9(ElementsContext),[contactPoint,setContactPoint]=useState35(props.defaultValue),[systemElement,useElement,valueElement]=useMemo7(()=>["system","use","value"].map(field=>elementsByPath[path+"."+field]),[elementsByPath,path]),[systemProps,useProps,valueProps]=useMemo7(()=>["system","use","value"].map(field=>getExtendedProps(path+"."+field)),[getExtendedProps,path]);function setContactPointWrapper(newValue){newValue&&Object.keys(newValue).length===0&&(newValue=void 0),setContactPoint(newValue),props.onChange&&props.onChange(newValue)}function setSystem(system){let newValue={...contactPoint,system};system||delete newValue.system,setContactPointWrapper(newValue)}function setUse(use){let newValue={...contactPoint,use};use||delete newValue.use,setContactPointWrapper(newValue)}function setValue(value){let newValue={...contactPoint,value};value||delete newValue.value,setContactPointWrapper(newValue)}let errorPath=props.valuePath??path;return jsxs40(Group15,{gap:"xs",grow:!0,wrap:"nowrap",align:"flex-start",children:[jsx73(NativeSelect3,{disabled:props.disabled||systemProps?.readonly,"data-testid":"system",defaultValue:contactPoint?.system,required:(systemElement?.min??0)>0,onChange:e=>setSystem(e.currentTarget.value),data:["","email","phone","fax","pager","sms","url","other"],error:getErrorsForInput(outcome,errorPath+".system")}),jsx73(NativeSelect3,{disabled:props.disabled||useProps?.readonly,"data-testid":"use",defaultValue:contactPoint?.use,required:(useElement?.min??0)>0,onChange:e=>setUse(e.currentTarget.value),data:["","home","work","temp","old","mobile"],error:getErrorsForInput(outcome,errorPath+".use")}),jsx73(TextInput10,{disabled:props.disabled||valueProps?.readonly,placeholder:"Value",defaultValue:contactPoint?.value,required:(valueElement?.min??0)>0,onChange:e=>setValue(e.currentTarget.value),error:getErrorsForInput(outcome,errorPath+".value")})]})}import{jsx as jsx74,jsxs as jsxs41}from"react/jsx-runtime";function ContactDetailInput(props){let[contactDetail,setContactDetail]=useState36(props.defaultValue),{getExtendedProps}=useContext10(ElementsContext),[nameProps,telecomProps]=useMemo8(()=>["name","telecom"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setContactDetailWrapper(newValue){setContactDetail(newValue),props.onChange&&props.onChange(newValue)}function setName(name){let newValue={...contactDetail,name};name||delete newValue.name,setContactDetailWrapper(newValue)}function setTelecom(telecom){let newValue={...contactDetail,telecom:telecom&&[telecom]};telecom||delete newValue.telecom,setContactDetailWrapper(newValue)}return jsxs41(Group16,{gap:"xs",grow:!0,wrap:"nowrap",children:[jsx74(TextInput11,{disabled:props.disabled||nameProps?.readonly,"data-testid":props.name+"-name",name:props.name+"-name",placeholder:"Name",style:{width:180},defaultValue:contactDetail?.name,onChange:e=>setName(e.currentTarget.value)}),jsx74(ContactPointInput,{disabled:props.disabled||telecomProps?.readonly,name:props.name+"-telecom",path:props.path+".telecom",defaultValue:contactDetail?.telecom?.[0],onChange:setTelecom,outcome:props.outcome})]})}import{TextInput as TextInput12}from"@mantine/core";import{isValidDate}from"@medplum/core";function convertIsoToLocal(isoString){if(!isoString)return"";let date=new Date(isoString);return isValidDate(date)?date.toLocaleDateString("sv")+"T"+date.toLocaleTimeString("sv"):""}function convertLocalToIso(localString){if(!localString)return"";let date=new Date(localString);return isValidDate(date)?date.toISOString():""}import{jsx as jsx75}from"react/jsx-runtime";function DateTimeInput(props){return jsx75(TextInput12,{id:props.name,name:props.name,label:props.label,"data-autofocus":props.autoFocus,"data-testid":props["data-testid"]??props.name,placeholder:props.placeholder,required:props.required,disabled:props.disabled,type:getInputType(),step:1,defaultValue:convertIsoToLocal(props.defaultValue),autoFocus:props.autoFocus,error:getErrorsForInput(props.outcome,props.name),onChange:e=>{if(props.onChange){let newValue=e.currentTarget.value;props.onChange(convertLocalToIso(newValue))}}})}function getInputType(){return"datetime-local"}import{isPopulated as isPopulated7,isProfileLoaded as isProfileLoaded2}from"@medplum/core";import{useMedplum as useMedplum21}from"@medplum/react-hooks";import{useEffect as useEffect11,useMemo as useMemo9,useState as useState37}from"react";import{jsx as jsx76}from"react/jsx-runtime";function ExtensionInput(props){let{propertyType}=props,medplum=useMedplum21(),profileUrl=useMemo9(()=>{if(isPopulated7(propertyType.profile))return propertyType.profile[0]},[propertyType]),[loadingProfile,setLoadingProfile]=useState37(profileUrl!==void 0);return useEffect11(()=>{profileUrl&&(setLoadingProfile(!0),medplum.requestProfileSchema(profileUrl).then(()=>setLoadingProfile(!1)).catch(reason=>{setLoadingProfile(!1),console.warn(reason)}))},[medplum,profileUrl]),profileUrl&&(loadingProfile||!isProfileLoaded2(profileUrl))?jsx76("div",{children:"Loading..."}):jsx76(BackboneElementInput,{profileUrl,path:props.path,typeName:"Extension",defaultValue:props.defaultValue,onChange:props.onChange})}import{Group as Group17,NativeSelect as NativeSelect4,TextInput as TextInput13}from"@mantine/core";import{useContext as useContext11,useMemo as useMemo10,useState as useState38}from"react";import{jsx as jsx77,jsxs as jsxs42}from"react/jsx-runtime";function HumanNameInput(props){let{outcome,path}=props,[value,setValue]=useState38(props.defaultValue),{getExtendedProps}=useContext11(ElementsContext),[useProps,prefixProps,givenProps,familyProps,suffixProps]=useMemo10(()=>["use","prefix","given","family","suffix"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}function setUse(use){setValueWrapper({...value,use:use||void 0})}function setPrefix(prefix){setValueWrapper({...value,prefix:prefix?prefix.split(" "):void 0})}function setGiven(given){setValueWrapper({...value,given:given?given.split(" "):void 0})}function setFamily(family){setValueWrapper({...value,family:family||void 0})}function setSuffix(suffix){setValueWrapper({...value,suffix:suffix?suffix.split(" "):void 0})}let errorPath=props.valuePath??path;return jsxs42(Group17,{gap:"xs",grow:!0,wrap:"nowrap",children:[jsx77(NativeSelect4,{disabled:props.disabled||useProps?.readonly,defaultValue:value?.use,name:props.name+"-use","data-testid":"use",onChange:e=>setUse(e.currentTarget.value),data:["","temp","old","usual","official","nickname","anonymous","maiden"],error:getErrorsForInput(outcome,errorPath+".use")}),jsx77(TextInput13,{disabled:props.disabled||prefixProps?.readonly,placeholder:"Prefix",name:props.name+"-prefix",defaultValue:value?.prefix?.join(" "),onChange:e=>setPrefix(e.currentTarget.value),error:getErrorsForInput(outcome,errorPath+".prefix")}),jsx77(TextInput13,{disabled:props.disabled||givenProps?.readonly,placeholder:"Given",name:props.name+"-given",defaultValue:value?.given?.join(" "),onChange:e=>setGiven(e.currentTarget.value),error:getErrorsForInput(outcome,errorPath+".given")}),jsx77(TextInput13,{disabled:props.disabled||familyProps?.readonly,name:props.name+"-family",placeholder:"Family",defaultValue:value?.family,onChange:e=>setFamily(e.currentTarget.value),error:getErrorsForInput(outcome,errorPath+".family")}),jsx77(TextInput13,{disabled:props.disabled||suffixProps?.readonly,placeholder:"Suffix",name:props.name+"-suffix",defaultValue:value?.suffix?.join(" "),onChange:e=>setSuffix(e.currentTarget.value),error:getErrorsForInput(outcome,errorPath+".suffix")})]})}import{Group as Group18,TextInput as TextInput14}from"@mantine/core";import{useContext as useContext12,useMemo as useMemo11,useState as useState39}from"react";import{jsx as jsx78,jsxs as jsxs43}from"react/jsx-runtime";function IdentifierInput(props){let[value,setValue]=useState39(props.defaultValue),{elementsByPath,getExtendedProps}=useContext12(ElementsContext),[systemElement,valueElement]=useMemo11(()=>["system","value"].map(field=>elementsByPath[props.path+"."+field]),[elementsByPath,props.path]),[systemProps,valueProps]=useMemo11(()=>["system","value"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}let errorPath=props.valuePath??props.path;return jsxs43(Group18,{gap:"xs",grow:!0,wrap:"nowrap",align:"flex-start",children:[jsx78(TextInput14,{disabled:props.disabled||systemProps?.readonly,placeholder:"System",required:(systemElement?.min??0)>0,defaultValue:value?.system,onChange:e=>setValueWrapper({...value,system:e.currentTarget.value}),error:getErrorsForInput(props.outcome,errorPath+".system")}),jsx78(TextInput14,{disabled:props.disabled||valueProps?.readonly,placeholder:"Value",required:(valueElement?.min??0)>0,defaultValue:value?.value,onChange:e=>setValueWrapper({...value,value:e.currentTarget.value}),error:getErrorsForInput(props.outcome,errorPath+".value")})]})}import{NativeSelect as NativeSelect5,TextInput as TextInput15}from"@mantine/core";import{useCallback as useCallback7,useContext as useContext13,useMemo as useMemo12,useState as useState40}from"react";import{jsx as jsx79}from"react/jsx-runtime";var data=["USD","EUR","CAD","GBP","AUD"];function MoneyInput(props){let{onChange}=props,[value,setValue]=useState40(props.defaultValue),{getExtendedProps}=useContext13(ElementsContext),[currencyProps,valueProps]=useMemo12(()=>["currency","value"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]),setValueWrapper=useCallback7(newValue=>{setValue(newValue),onChange&&onChange(newValue)},[onChange]),handleCurrencyChange=useCallback7(e=>{setValueWrapper({...value,currency:e.currentTarget.value})},[value,setValueWrapper]),handleValueChange=useCallback7(e=>{setValueWrapper({...value,value:e.currentTarget.valueAsNumber})},[value,setValueWrapper]),select=jsx79(NativeSelect5,{disabled:props.disabled||currencyProps?.readonly,defaultValue:value?.currency,data,styles:{input:{fontWeight:500,borderTopLeftRadius:0,borderBottomLeftRadius:0,width:92}},onChange:handleCurrencyChange});return jsx79(TextInput15,{disabled:props.disabled||valueProps?.readonly,type:"number",name:props.name,label:props.label,placeholder:props.placeholder??"Value",defaultValue:value?.value?.toString()??"USD",leftSection:jsx79(IconCurrencyDollar,{size:14}),rightSection:select,rightSectionWidth:92,onChange:handleValueChange})}import{Group as Group19}from"@mantine/core";import{useContext as useContext14,useMemo as useMemo13,useState as useState41}from"react";import{jsx as jsx80,jsxs as jsxs44}from"react/jsx-runtime";function PeriodInput(props){let[value,setValue]=useState41(props.defaultValue),{getExtendedProps}=useContext14(ElementsContext),[startProps,endProps]=useMemo13(()=>["start","end"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}return jsxs44(Group19,{gap:"xs",grow:!0,wrap:"nowrap",children:[jsx80(DateTimeInput,{disabled:props.disabled||startProps?.readonly,name:props.name+".start",placeholder:"Start",defaultValue:value?.start,onChange:newValue=>setValueWrapper({...value,start:newValue})}),jsx80(DateTimeInput,{disabled:props.disabled||endProps?.readonly,name:props.name+".end",placeholder:"End",defaultValue:value?.end,onChange:newValue=>setValueWrapper({...value,end:newValue})})]})}import{Group as Group20,NativeSelect as NativeSelect6,TextInput as TextInput16}from"@mantine/core";import{useContext as useContext15,useMemo as useMemo14,useState as useState42}from"react";import{jsx as jsx81,jsxs as jsxs45}from"react/jsx-runtime";function QuantityInput(props){let[value,setValue]=useState42(props.defaultValue),{getExtendedProps}=useContext15(ElementsContext),[comparatorProps,valueProps,unitProps]=useMemo14(()=>["comparator","value","unit"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}return jsxs45(Group20,{gap:"xs",grow:!0,wrap:"nowrap",children:[jsx81(NativeSelect6,{disabled:props.disabled||comparatorProps?.readonly,style:{width:80},"data-testid":props.name+"-comparator",defaultValue:value?.comparator,data:["","<","<=",">=",">"],onChange:e=>setValueWrapper({...value,comparator:e.currentTarget.value})}),jsx81(TextInput16,{disabled:props.disabled||valueProps?.readonly,id:props.name,name:props.name,required:props.required,"data-autofocus":props.autoFocus,"data-testid":props.name+"-value",type:"number",placeholder:"Value",defaultValue:value?.value,autoFocus:props.autoFocus,step:"any",onWheel:e=>{props.disableWheel&&e.currentTarget.blur()},onChange:e=>{setValueWrapper({...value,value:tryParseNumber(e.currentTarget.value)})}}),jsx81(TextInput16,{disabled:props.disabled||unitProps?.readonly,placeholder:"Unit","data-testid":props.name+"-unit",defaultValue:value?.unit,onChange:e=>setValueWrapper({...value,unit:e.currentTarget.value})})]})}function tryParseNumber(str){if(str)return Number.parseFloat(str)}import{Group as Group21}from"@mantine/core";import{useContext as useContext16,useMemo as useMemo15,useState as useState43}from"react";import{jsx as jsx82,jsxs as jsxs46}from"react/jsx-runtime";function RangeInput(props){let[value,setValue]=useState43(props.defaultValue),{getExtendedProps}=useContext16(ElementsContext),[lowProps,highProps]=useMemo15(()=>["low","high"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}return jsxs46(Group21,{gap:"xs",grow:!0,wrap:"nowrap",children:[jsx82(QuantityInput,{path:props.path+".low",disabled:props.disabled||lowProps?.readonly,name:props.name+"-low",defaultValue:value?.low,onChange:v=>setValueWrapper({...value,low:v})}),jsx82(QuantityInput,{path:props.path+".high",disabled:props.disabled||highProps?.readonly,name:props.name+"-high",defaultValue:value?.high,onChange:v=>setValueWrapper({...value,high:v})})]})}import{Group as Group22}from"@mantine/core";import{useContext as useContext17,useMemo as useMemo16,useState as useState44}from"react";import{jsx as jsx83,jsxs as jsxs47}from"react/jsx-runtime";function RatioInput(props){let[value,setValue]=useState44(props.defaultValue),{getExtendedProps}=useContext17(ElementsContext),[numeratorProps,denominatorProps]=useMemo16(()=>["numerator","denominator"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}return jsxs47(Group22,{gap:"xs",grow:!0,wrap:"nowrap",children:[jsx83(QuantityInput,{path:props.path+".numerator",disabled:props.disabled||numeratorProps?.readonly,name:props.name+"-numerator",defaultValue:value?.numerator,onChange:v=>setValueWrapper({...value,numerator:v})}),jsx83(QuantityInput,{path:props.path+".denominator",disabled:props.disabled||denominatorProps?.readonly,name:props.name+"-denominator",defaultValue:value?.denominator,onChange:v=>setValueWrapper({...value,denominator:v})})]})}import{Group as Group24,NativeSelect as NativeSelect7}from"@mantine/core";import{LRUCache,ReadablePromise,createReference as createReference2,isEmpty as isEmpty4,isPopulated as isPopulated8,tryGetProfile as tryGetProfile3}from"@medplum/core";import{useMedplum as useMedplum23}from"@medplum/react-hooks";import{useCallback as useCallback10,useEffect as useEffect13,useMemo as useMemo17,useRef as useRef8,useState as useState46}from"react";import{useCallback as useCallback9}from"react";import{Group as Group23,Text as Text18}from"@mantine/core";import{getDisplayString as getDisplayString3,getReferenceString as getReferenceString3,isReference as isReference2,isResource as isResource2}from"@medplum/core";import{useMedplum as useMedplum22}from"@medplum/react-hooks";import{forwardRef as forwardRef4,useCallback as useCallback8,useEffect as useEffect12,useRef as useRef7,useState as useState45}from"react";import{jsx as jsx84,jsxs as jsxs48}from"react/jsx-runtime";var SEARCH_CODES={Device:"device-name",Observation:"code",Subscription:"criteria",User:"email:contains"},NAME_RESOURCE_TYPES=["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"];function toOption3(resource){return{value:getReferenceString3(resource)??"",label:getDisplayString3(resource),resource}}function getSearchParamForResourceType(resourceType){return SEARCH_CODES[resourceType]??(NAME_RESOURCE_TYPES.includes(resourceType)?"name":"_id")}var DefaultResourceItemComponent=forwardRef4(({label,resource,active:_active,...others},ref)=>jsx84("div",{ref,...others,children:jsxs48(Group23,{wrap:"nowrap",children:[jsx84(ResourceAvatar,{value:resource}),jsxs48("div",{children:[jsx84(Text18,{children:label}),jsx84(Text18,{size:"xs",c:"dimmed",children:resource.birthDate||resource.id})]})]})}));DefaultResourceItemComponent.displayName="DefaultResourceItemComponent";function MultiResourceInput(props){let medplum=useMedplum22(),{resourceType,searchCriteria}=props,ItemComponent3=props.itemComponent??DefaultResourceItemComponent,onChange=props.onChange,initialDefaultValue=useRef7(props.defaultValue),[defaultResources,setDefaultResources]=useState45(!props.defaultValue||props.defaultValue.length===0?[]:void 0);useEffect12(()=>{let cancelled=!1,items=initialDefaultValue.current;return items&&items.length>0&&Promise.allSettled(items.map(item=>{if(isResource2(item))return Promise.resolve(item);if(isReference2(item)){let ref=item;return medplum.readReference(ref)}return Promise.reject(new Error("Not a resolvable item"))})).then(settled=>{cancelled||setDefaultResources(settled.filter(r2=>r2.status==="fulfilled").map(r2=>r2.value))}).catch(()=>{}),()=>{cancelled=!0}},[medplum]);let loadValues=useCallback8(async(input,signal)=>{let searchCode=getSearchParamForResourceType(resourceType),searchParams=new URLSearchParams({[searchCode]:input??"",_count:"10",...searchCriteria});return await medplum.searchResources(resourceType,searchParams,{signal})},[medplum,resourceType,searchCriteria]),handleChange=useCallback8(newResources=>{onChange&&onChange(newResources)},[onChange]);return defaultResources===void 0?null:jsx84(AsyncAutocomplete,{disabled:props.disabled,name:props.name,label:props.label,error:props.error,required:props.required,itemComponent:ItemComponent3,defaultValue:defaultResources,placeholder:props.placeholder,maxValues:props.maxValues,toOption:toOption3,loadOptions:loadValues,onChange:handleChange,clearable:!0})}import{jsx as jsx85}from"react/jsx-runtime";function ResourceInput(props){let onChange=props.onChange,handleChange=useCallback9(newResources=>{onChange&&onChange(newResources[0])},[onChange]);return jsx85(MultiResourceInput,{resourceType:props.resourceType,name:props.name,defaultValue:props.defaultValue?[props.defaultValue]:void 0,searchCriteria:props.searchCriteria,placeholder:props.placeholder,required:props.required,itemComponent:props.itemComponent,onChange:handleChange,disabled:props.disabled,label:props.label,error:props.error,maxValues:1})}import{Fragment as Fragment30,jsx as jsx86,jsxs as jsxs49}from"react/jsx-runtime";function ReferenceInput(props){let{onChange}=props,medplum=useMedplum23(),[value,setValue]=useState46(props.defaultValue),[targetTypes,setTargetTypes]=useState46(()=>createTargetTypes(props.targetTypes)),[targetType,setTargetType]=useState46(()=>getInitialTargetType(props.defaultValue,targetTypes)),promiseCache=useRef8(new LRUCache),searchCriteria=useMemo17(()=>targetType?.type==="profile"?{...props.searchCriteria,_profile:targetType.value}:props.searchCriteria,[props.searchCriteria,targetType]);useEffect13(()=>{let anyToFetch=!1,newTargetTypePromises=targetTypes?.map(tt=>{if(!shouldFetchResourceType(tt))return Promise.resolve(tt);anyToFetch=!0;let cacheKey=tt.value,cached=promiseCache.current.get(cacheKey);if(cached)return cached;let promise=fetchResourceTypeOfProfile(medplum,tt.value).then(profile=>{let newTargetType={...tt};return profile?isPopulated8(profile.type)?(newTargetType.resourceType=profile.type,newTargetType.name=profile.name,newTargetType.title=profile.title):(console.error(`StructureDefinition.type missing for ${tt.value}`),newTargetType.error="StructureDefinition.type missing"):(console.error(`StructureDefinition not found for ${tt.value}`),newTargetType.error="StructureDefinition not found"),newTargetType}).catch(reason=>(console.error(reason),{...tt,error:reason})),readablePromise=new ReadablePromise(promise);return promiseCache.current.set(cacheKey,readablePromise),readablePromise});!newTargetTypePromises||!anyToFetch||Promise.all(newTargetTypePromises).then(newTargetTypes=>{if(setTargetTypes(newTargetTypes),!targetType)return;let index=newTargetTypes.findIndex(tt=>tt.value===targetType.value||tt.resourceType===targetType.resourceType);if(index===-1){console.debug(`defaultValue had unexpected resourceType: ${targetType.resourceType}`);return}setTargetType(newTargetTypes[index])}).catch(console.error)},[medplum,targetType,targetTypes]);let setValueHelper=useCallback10(item=>{let newValue=item?createReference2(item):void 0;setValue(newValue),onChange&&onChange(newValue)},[onChange]),typeSelectOptions=useMemo17(()=>targetTypes?targetTypes.map(tt=>({value:tt.value,label:tt.type==="profile"?tt.title??tt.name??tt.resourceType??tt.value:tt.value})):[],[targetTypes]);return jsxs49(Fragment30,{children:[props.name&&jsx86("input",{type:"hidden",name:props.name,value:value?.reference??""}),jsxs49(Group24,{gap:"xs",grow:!0,wrap:"nowrap",children:[targetTypes&&targetTypes.length>1&&jsx86(NativeSelect7,{name:props.name+"-resourceType",disabled:props.disabled,"data-autofocus":props.autoFocus,"data-testid":"reference-input-resource-type-select",defaultValue:targetType?.resourceType,autoFocus:props.autoFocus,onChange:e=>{let newValue=e.currentTarget.value,newTargetType=targetTypes.find(tt=>tt.value===newValue);setTargetType(newTargetType)},data:typeSelectOptions}),!targetTypes&&jsx86(ResourceTypeInput,{disabled:props.disabled,autoFocus:props.autoFocus,testId:"reference-input-resource-type-input",defaultValue:targetType?.resourceType,onChange:newResourceType=>{setTargetType(newResourceType?{type:"resourceType",value:newResourceType,resourceType:newResourceType}:void 0)},name:props.name+"-resourceType",placeholder:"Resource Type"}),jsx86(ResourceInput,{resourceType:targetType?.resourceType,name:props.name+"-id",required:props.required,placeholder:props.placeholder,defaultValue:value,searchCriteria,onChange:setValueHelper,disabled:props.disabled})]})]})}function createTargetTypes(resourceTypesAndProfileUrls){if(!resourceTypesAndProfileUrls||resourceTypesAndProfileUrls.length===0||resourceTypesAndProfileUrls.length===1&&resourceTypesAndProfileUrls[0]==="Resource")return;let results=[];for(let value of resourceTypesAndProfileUrls)value.includes("/")?results.push({type:"profile",value}):results.push({type:"resourceType",value,resourceType:value});return results}function getInitialTargetType(defaultValue2,targetTypes){let defaultValueResourceType=defaultValue2?.reference?.split("/")[0];if(defaultValueResourceType){let targetType=targetTypes?.find(tt=>tt.resourceType===defaultValueResourceType);return targetType||{type:"resourceType",value:defaultValueResourceType,resourceType:defaultValueResourceType}}if(targetTypes&&targetTypes.length>0)return targetTypes[0]}async function fetchResourceTypeOfProfile(medplum,profileUrl){let profile=tryGetProfile3(profileUrl);if(profile)return{type:profile.type,name:profile.name,title:profile.title};let query=`{
103
+ `)}function getIssuesForExpression(outcome,expression){return outcome?.issue?.filter(issue=>isExpressionMatch(issue.expression?.[0],expression))}var ARRAY_INDEX_REGEX=/\[\d+\]/;function isExpressionMatch(expr1,expr2){let isExpr1Indexed=typeof expr1=="string"&&ARRAY_INDEX_REGEX.test(expr1),isExpr2Indexed=typeof expr2=="string"&&ARRAY_INDEX_REGEX.test(expr2);if(isExpr1Indexed!==isExpr2Indexed&&(expr1=expr1?.replace(ARRAY_INDEX_REGEX,""),expr2=expr2?.replace(ARRAY_INDEX_REGEX,"")),expr1===expr2)return!0;if(!expr1||!expr2)return!1;let dot1=expr1.indexOf(".");if(dot1>=0&&expr1.substring(dot1+1)===expr2)return!0;let dot2=expr2.indexOf(".");return dot2>=0&&expr2.substring(dot2+1)===expr1}import{jsx as jsx37,jsxs as jsxs21}from"react/jsx-runtime";function ChangePasswordForm(props){let{onSuccess}=props,medplum=useMedplum9(),[outcome,setOutcome]=useState17(),[success,setSuccess]=useState17(!1);return jsx37(Document,{width:450,children:jsxs21(Form,{onSubmit:formData=>{setOutcome(void 0),medplum.post("auth/changepassword",formData).then(()=>{setSuccess(!0),onSuccess?.()}).catch(err=>setOutcome(normalizeOperationOutcome2(err)))},children:[jsxs21(Flex2,{direction:"column",align:"center",justify:"center",children:[jsx37(Logo,{size:32}),jsx37(Title,{children:"Change password"})]}),!success&&jsxs21(Stack5,{gap:"xl",mt:"xl",children:[jsx37(PasswordInput,{name:"oldPassword",label:"Old password",required:!0,autoFocus:!0,error:getErrorsForInput(outcome,"oldPassword")}),jsx37(PasswordInput,{name:"newPassword",label:"New password",required:!0,error:getErrorsForInput(outcome,"newPassword")}),jsx37(PasswordInput,{name:"confirmPassword",label:"Confirm new password",required:!0,error:getErrorsForInput(outcome,"confirmPassword")}),jsx37(Group10,{justify:"flex-end",mt:"xl",wrap:"nowrap",children:jsx37(Button4,{type:"submit",children:"Change password"})})]}),success&&jsx37("div",{"data-testid":"success",children:"Password changed successfully"})]})})}import{Checkbox,Flex as Flex3,Group as Group11,Stack as Stack6,Title as Title2}from"@mantine/core";import{useMedplum as useMedplum10}from"@medplum/react-hooks";import{Fragment as Fragment12}from"react/jsx-runtime";import{jsx as jsx38,jsxs as jsxs22}from"react/jsx-runtime";var openConditionScope=/^patient\/Condition\.(?:\*|c?r?u?d?s?)$/,encounterDiagnosis="?category=http://terminology.hl7.org/CodeSystem/condition-category|encounter-diagnosis",problemListItem="?category=http://terminology.hl7.org/CodeSystem/condition-category|problem-list-item",healthConcern="?category=http://hl7.org/fhir/us/core/CodeSystem/condition-category|health-concern",openObservationScope=/^patient\/Observation\.(?:\*|c?r?u?d?s?)$/,clinicalTest="?category=http://hl7.org/fhir/us/core/CodeSystem/us-core-observation-category|clinical-test",laboratory="?category=http://terminology.hl7.org/CodeSystem/observation-category|laboratory",socialHistory="?category=http://terminology.hl7.org/CodeSystem/observation-category|social-history",sdoh="?category=http://hl7.org/fhir/us/core/CodeSystem/us-core-category|sdoh",survey="?category=http://terminology.hl7.org/CodeSystem/observation-category|survey",vitalSigns="?category=http://terminology.hl7.org/CodeSystem/observation-category|vital-signs";function ChooseScopeForm(props){let medplum=useMedplum10();return jsx38(Form,{onSubmit:formData=>{medplum.post("auth/scope",{login:props.login,scope:Object.keys(formData).join(" ")}).then(props.handleAuthResponse).catch(console.log)},children:jsxs22(Stack6,{children:[jsxs22(Flex3,{direction:"column",align:"center",justify:"center",children:[props.logo??jsx38(Logo,{size:32}),jsx38(Title2,{order:3,py:"lg",children:props.title??"Choose scope"}),props.children]}),jsx38(Stack6,{children:(props.scope??"openid").split(" ").map(scopeName=>{let additionalScopes;return openConditionScope.test(scopeName)?additionalScopes=[scopeName+encounterDiagnosis,scopeName+problemListItem,scopeName+healthConcern]:openObservationScope.test(scopeName)&&(additionalScopes=[scopeName+clinicalTest,scopeName+laboratory,scopeName+socialHistory,scopeName+sdoh,scopeName+survey,scopeName+vitalSigns]),jsxs22(Fragment12,{children:[jsx38(Checkbox,{id:scopeName,name:scopeName,label:scopeName,defaultChecked:!0},scopeName),additionalScopes?.map(scope=>jsx38(Checkbox,{id:scope,name:scope,label:scope},scope))]},scopeName+"_group")})}),jsx38(Group11,{justify:"flex-end",mt:"xl",children:jsx38(SubmitButton,{fullWidth:!0,children:props.submitLabel??"Set Scope"})})]})})}import{Button as Button5,Center as Center3,Stack as Stack8,Text as Text11,Title as Title4}from"@mantine/core";import{useState as useState19}from"react";import{Alert as Alert2,Center as Center2,Image as Image2,Stack as Stack7,Text as Text10,TextInput as TextInput4,Title as Title3}from"@mantine/core";import{normalizeErrorString as normalizeErrorString5}from"@medplum/core";import{useState as useState18}from"react";import{jsx as jsx39,jsxs as jsxs23}from"react/jsx-runtime";function MfaForm(props){let[errorMessage,setErrorMessage]=useState18();return jsxs23(Form,{onSubmit:formData=>{setErrorMessage(void 0),props.onSubmit(formData)?.catch(err=>setErrorMessage(normalizeErrorString5(err)))},children:[jsxs23(Center2,{style:{flexDirection:"column"},children:[jsx39(Logo,{size:32}),jsx39(Title3,{order:3,py:"lg",children:props.title}),!props.qrCodeUrl&&props.description&&jsx39(Text10,{c:"dimmed",mb:"lg",mt:"-lg",ta:"center",children:props.description})]}),errorMessage&&jsx39(Alert2,{icon:jsx39(IconAlertCircle,{size:16}),title:"Error",color:"red",mb:"lg",children:errorMessage}),props.qrCodeUrl&&jsx39(Center2,{children:jsxs23(Stack7,{mb:"xl",justify:"center",children:[props.description&&jsx39(Text10,{c:"dimmed",mb:"md",mt:"-lg",ta:"center",children:props.description}),jsx39(Image2,{src:props.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))"}})]})}),jsx39(Stack7,{gap:"sm",children:jsx39(TextInput4,{name:"token",label:"MFA code",autoComplete:"one-time-code",required:!0,autoFocus:!0})}),jsxs23(Stack7,{gap:"xs",pt:"md",children:[jsx39(SubmitButton,{fullWidth:!0,children:props.buttonText}),props.footer]})]})}import{jsx as jsx40,jsxs as jsxs24}from"react/jsx-runtime";function MfaEnrollForm(props){let{allowedMethods,qrCodeUrl,onEnrollEmail,onEnrollTotp}=props,[selected,setSelected]=useState19(),emailAllowed=allowedMethods.includes("email"),totpAllowed=allowedMethods.includes("totp");return emailAllowed&&totpAllowed&&!selected?jsxs24(Center3,{style:{flexDirection:"column"},children:[jsx40(Logo,{size:32}),jsx40(Title4,{order:3,py:"lg",ta:"center",children:"Set up multi-factor authentication"}),jsxs24(Stack8,{w:"100%",children:[jsx40(Text11,{c:"dimmed",ta:"center",children:"Choose how you want to verify your identity when you sign in."}),jsx40(Button5,{fullWidth:!0,onClick:()=>setSelected("totp"),children:"Use an authenticator app (recommended)"}),jsx40(Button5,{fullWidth:!0,variant:"default",onClick:onEnrollEmail,children:"Continue with email-based MFA"})]})]}):emailAllowed&&!totpAllowed?jsxs24(Center3,{style:{flexDirection:"column"},children:[jsx40(Logo,{size:32}),jsx40(Title4,{order:3,py:"lg",children:"Set up email-based MFA"}),jsxs24(Stack8,{w:"100%",children:[jsx40(Text11,{c:"dimmed",ta:"center",children:"When you sign in, we'll email you a verification code to confirm your identity."}),jsx40(Button5,{fullWidth:!0,onClick:onEnrollEmail,children:"Enable email-based MFA"})]})]}):jsx40(MfaForm,{title:props.totpTitle,description:props.totpDescription,buttonText:props.totpButtonText??"Enroll",qrCodeUrl,onSubmit:fields=>onEnrollTotp(fields.token)})}import{Anchor as Anchor3}from"@mantine/core";import{showNotification as showNotification3}from"@mantine/notifications";import{normalizeErrorString as normalizeErrorString6}from"@medplum/core";import{useState as useState20}from"react";import{Fragment as Fragment13,jsx as jsx41,jsxs as jsxs25}from"react/jsx-runtime";function MfaVerificationForm(props){let{methods,email,onRequestEmailCode,onSubmit}=props,[emailMode,setEmailMode]=useState20(!!props.initialEmailMode),requestEmailCode=()=>{Promise.resolve(onRequestEmailCode()).then(()=>setEmailMode(!0)).catch(err=>showNotification3({color:"red",message:normalizeErrorString6(err)}))},footer;return emailMode?footer=jsx41(Anchor3,{component:"button",type:"button",size:"sm",ta:"center",onClick:requestEmailCode,children:"Resend code"}):methods.includes("email")&&(footer=jsx41(Anchor3,{component:"button",type:"button",size:"sm",ta:"center",onClick:requestEmailCode,children:"Get a code by email instead"})),jsx41(MfaForm,{title:emailMode?"Enter verification code":"Enter MFA code",description:emailMode?jsxs25(Fragment13,{children:["Enter the 6-digit code we emailed",email?" to ":"",email&&jsx41("strong",{children:email})]}):"Enter the code from your authenticator app.",buttonText:props.buttonText??"Submit code",onSubmit:fields=>onSubmit(fields.token),footer})}import{normalizeOperationOutcome as normalizeOperationOutcome5}from"@medplum/core";import{useMedplum as useMedplum13}from"@medplum/react-hooks";import{useEffect as useEffect6,useState as useState24}from"react";import{Alert as Alert3}from"@mantine/core";import{isOk,operationOutcomeIssueToString}from"@medplum/core";import{jsx as jsx42}from"react/jsx-runtime";function OperationOutcomeAlert(props){let{outcome,issues:issuesProp,displayOkOutcomes,...spacingProps}=props,issues=outcome?.issue||issuesProp;return!issues||issues.length===0||outcome&&isOk(outcome)&&!displayOkOutcomes?null:jsx42(Alert3,{icon:jsx42(IconAlertCircle,{size:16}),color:"red",...spacingProps,children:issues.map(issue=>jsx42("div",{"data-testid":"text-field-error",children:operationOutcomeIssueToString(issue)},issue.details?.text))})}import{Anchor as Anchor4,Flex as Flex4,Stack as Stack9,Text as Text12,TextInput as TextInput5,Title as Title5}from"@mantine/core";import{normalizeOperationOutcome as normalizeOperationOutcome3}from"@medplum/core";import{useMedplum as useMedplum11}from"@medplum/react-hooks";import{useState as useState21}from"react";import{jsx as jsx43,jsxs as jsxs26}from"react/jsx-runtime";function NewProjectForm(props){let medplum=useMedplum11(),[outcome,setOutcome]=useState21(),issues=getIssuesForExpression(outcome,void 0);return jsxs26(Form,{onSubmit:async formData=>{try{props.handleAuthResponse(await medplum.startNewProject({login:props.login,projectName:formData.projectName}))}catch(err){setOutcome(normalizeOperationOutcome3(err))}},children:[jsxs26(Flex4,{direction:"column",align:"center",justify:"center",children:[jsx43(Logo,{size:32}),jsx43(Title5,{order:3,py:"lg",children:"Create a new project"})]}),jsx43(OperationOutcomeAlert,{issues,mb:"lg"}),jsx43(Stack9,{gap:"sm",children:jsx43(TextInput5,{name:"projectName",label:"Project Name",placeholder:"My Project",required:!0,autoFocus:!0,error:getErrorsForInput(outcome,"projectName")})}),jsxs26(Stack9,{gap:"xs",mt:"md",children:[jsx43(SubmitButton,{fullWidth:!0,children:"Create Project"}),jsxs26(Text12,{c:"dimmed",size:"xs",pt:"lg",ta:"center",children:['By clicking "Create Project" you agree to the Medplum'," ",jsx43(Anchor4,{href:"https://www.medplum.com/privacy",children:"Privacy\xA0Policy"})," and ",jsx43(Anchor4,{href:"https://www.medplum.com/terms",children:"Terms\xA0of\xA0Service"}),"."]})]})]})}import{Anchor as Anchor5,Box as Box8,Checkbox as Checkbox2,Divider as Divider3,Flex as Flex5,Stack as Stack10,Text as Text13,TextInput as TextInput6}from"@mantine/core";import{normalizeOperationOutcome as normalizeOperationOutcome4}from"@medplum/core";import{useMedplum as useMedplum12}from"@medplum/react-hooks";import{useEffect as useEffect5,useState as useState23}from"react";import{Box as Box7}from"@mantine/core";import{useEffect as useEffect4,useRef as useRef5,useState as useState22}from"react";function createScriptTag(src,onload){let head=document.getElementsByTagName("head")[0],script=document.createElement("script");script.async=!0,script.src=src,script.onload=onload??null,head.appendChild(script)}import{jsx as jsx44}from"react/jsx-runtime";function GoogleButton(props){let{googleClientId,handleGoogleCredential}=props,parentRef=useRef5(null),[scriptLoaded,setScriptLoaded]=useState22(typeof google<"u"),initializedRef=useRef5(!1),buttonRenderedRef=useRef5(!1);return useEffect4(()=>{if(typeof google>"u"){createScriptTag("https://accounts.google.com/gsi/client",()=>setScriptLoaded(!0));return}initializedRef.current||(google.accounts.id.initialize({client_id:googleClientId,callback:handleGoogleCredential}),initializedRef.current=!0),parentRef.current&&!buttonRenderedRef.current&&(google.accounts.id.renderButton(parentRef.current,{type:"standard",logo_alignment:"center",width:parentRef.current.clientWidth}),buttonRenderedRef.current=!0)},[googleClientId,scriptLoaded,handleGoogleCredential]),googleClientId?jsx44(Box7,{ref:parentRef,w:"100%",h:40,display:"flex",style:{justifyContent:"center"}}):null}import{locationUtils as locationUtils3}from"@medplum/core";function getGoogleClientId(clientId){if(clientId)return clientId;let origin=locationUtils3.getOrigin();if(origin&&("undefined"?.split(",")??[]).includes(origin))return"__GOOGLE_CLIENT_ID__"}function initRecaptcha(siteKey){typeof grecaptcha>"u"&&createScriptTag("https://www.google.com/recaptcha/api.js?render="+siteKey)}function getRecaptcha(siteKey){return new Promise((resolve,reject)=>{grecaptcha.ready(async()=>{try{resolve(await grecaptcha.execute(siteKey,{action:"submit"}))}catch(err){reject(err)}})})}import{Fragment as Fragment14,jsx as jsx45,jsxs as jsxs27}from"react/jsx-runtime";function NewUserForm(props){let googleClientId=getGoogleClientId(props.googleClientId),recaptchaSiteKey=props.recaptchaSiteKey,medplum=useMedplum12(),[outcome,setOutcome]=useState23(),issues=getIssuesForExpression(outcome,void 0);return useEffect5(()=>{recaptchaSiteKey&&initRecaptcha(recaptchaSiteKey)},[recaptchaSiteKey]),jsxs27(Form,{onSubmit:async formData=>{setOutcome(void 0);try{let recaptchaToken="";recaptchaSiteKey&&(recaptchaToken=await getRecaptcha(recaptchaSiteKey)),props.handleAuthResponse(await medplum.startNewUser({projectId:props.projectId,clientId:props.clientId,firstName:formData.firstName,lastName:formData.lastName,email:formData.email,password:formData.password,remember:formData.remember==="true",recaptchaSiteKey,recaptchaToken}))}catch(err){setOutcome(normalizeOperationOutcome4(err))}},children:[jsx45(Flex5,{direction:"column",align:"center",justify:"center",children:props.children}),jsx45(OperationOutcomeAlert,{issues,mb:"lg"}),googleClientId&&jsxs27(Fragment14,{children:[jsx45(Box8,{style:{minHeight:40},children:jsx45(GoogleButton,{googleClientId,handleGoogleCredential:async response=>{try{props.handleAuthResponse(await medplum.startGoogleLogin({googleClientId:response.clientId,googleCredential:response.credential,projectId:props.projectId,createUser:!0}))}catch(err){setOutcome(normalizeOperationOutcome4(err))}}})}),jsx45(Divider3,{label:"or",labelPosition:"center",my:"lg"})]}),jsxs27(Stack10,{gap:"sm",children:[jsx45(TextInput6,{name:"firstName",type:"text",label:"First name",placeholder:"First name",required:!0,autoFocus:!0,error:getErrorsForInput(outcome,"firstName")}),jsx45(TextInput6,{name:"lastName",type:"text",label:"Last name",placeholder:"Last name",required:!0,error:getErrorsForInput(outcome,"lastName")}),jsx45(TextInput6,{name:"email",type:"email",label:"Email",placeholder:"name@domain.com",required:!0,error:getErrorsForInput(outcome,"email")}),jsx45(PasswordInput,{name:"password",label:"Password",autoComplete:"off",required:!0,error:getErrorsForInput(outcome,"password")})]}),jsxs27(Stack10,{gap:"xs",children:[jsx45(Checkbox2,{id:"remember",name:"remember",label:"Remember me",size:"xs",style:{lineHeight:1},pt:"md",pb:"xs"}),jsx45(SubmitButton,{fullWidth:!0,children:"Register Account"}),props.onSignIn&&jsxs27(Text13,{size:"sm",mt:"lg",c:"dimmed",ta:"center","data-dashlane-ignore":"true","data-lp-ignore":"true","data-no-autofill":"true","data-form-type":"navigation",children:["Already have an account?"," ",jsx45(Anchor5,{component:"button",type:"button",onClick:props.onSignIn,children:"Sign In"})]}),jsxs27(Text13,{c:"dimmed",size:"xs",pt:"lg",ta:"center",children:['By clicking "Register Account" you agree to the Medplum'," ",jsx45(Anchor5,{href:"https://www.medplum.com/privacy",children:"Privacy\xA0Policy"})," and ",jsx45(Anchor5,{href:"https://www.medplum.com/terms",children:"Terms\xA0of\xA0Service"}),"."]}),jsxs27(Text13,{c:"dimmed",size:"xs",ta:"center",children:["This site is protected by reCAPTCHA and the Google"," ",jsx45(Anchor5,{href:"https://policies.google.com/privacy",children:"Privacy\xA0Policy"})," and ",jsx45(Anchor5,{href:"https://policies.google.com/terms",children:"Terms\xA0of\xA0Service"})," apply."]})]})]})}import{jsx as jsx46,jsxs as jsxs28}from"react/jsx-runtime";function RegisterForm(props){let{type,projectId,clientId,googleClientId,recaptchaSiteKey,onSuccess,onSignIn}=props,medplum=useMedplum13(),[login,setLogin]=useState24(props.login),[outcome,setOutcome]=useState24(),[emailVerificationRequired,setEmailVerificationRequired]=useState24(!1);useEffect6(()=>{type==="patient"&&login&&medplum.startNewPatient({login,projectId}).then(response=>medplum.processCode(response.code)).then(()=>onSuccess()).catch(err=>setOutcome(normalizeOperationOutcome5(err)))},[medplum,type,projectId,login,onSuccess]);function handleAuthResponse(response){response.code&&medplum.processCode(response.code).then(()=>onSuccess()).catch(err=>setOutcome(normalizeOperationOutcome5(err))),response.login&&setLogin(response.login),response.emailVerificationRequired&&setEmailVerificationRequired(!0)}let issues=getIssuesForExpression(outcome,void 0);return jsxs28(Document,{width:400,px:"xl",py:"xl",bdrs:"md",children:[jsx46(OperationOutcomeAlert,{issues,mb:"lg"}),!login&&jsx46(NewUserForm,{projectId,clientId,googleClientId,recaptchaSiteKey,onSignIn,handleAuthResponse,children:props.children}),emailVerificationRequired&&jsx46("div",{children:"Please check your email for a verification link. Click the link to continue setting up your account."}),login&&!emailVerificationRequired&&type==="project"&&jsx46(NewProjectForm,{login,handleAuthResponse})]})}import{Anchor as Anchor6,Flex as Flex6,Stack as Stack11,Text as Text14,TextInput as TextInput7,Title as Title6}from"@mantine/core";import{normalizeOperationOutcome as normalizeOperationOutcome6}from"@medplum/core";import{useMedplum as useMedplum14}from"@medplum/react-hooks";import{useEffect as useEffect7,useState as useState25}from"react";import{Fragment as Fragment15,jsx as jsx47,jsxs as jsxs29}from"react/jsx-runtime";function ResetPasswordForm(props){let{projectId,recaptchaSiteKey,onSuccess,onSignIn,onRegister}=props,medplum=useMedplum14(),[outcome,setOutcome]=useState25(),[success,setSuccess]=useState25(!1);return useEffect7(()=>{recaptchaSiteKey&&initRecaptcha(recaptchaSiteKey)},[recaptchaSiteKey]),jsx47(Document,{width:400,px:"xl",py:"xl",bdrs:"md",children:jsxs29(Form,{onSubmit:async formData=>{setOutcome(void 0);try{let recaptchaToken="";recaptchaSiteKey&&(recaptchaToken=await getRecaptcha(recaptchaSiteKey)),await medplum.post("auth/resetpassword",{...formData,projectId,recaptchaToken}),setSuccess(!0),onSuccess?.()}catch(err){setOutcome(normalizeOperationOutcome6(err))}},children:[jsxs29(Flex6,{direction:"column",align:"center",justify:"center",children:[jsx47(Logo,{size:32}),jsx47(Title6,{order:3,py:"lg",children:"Reset your password"})]}),jsx47(OperationOutcomeAlert,{issues:getIssuesForExpression(outcome,void 0),mb:"lg"}),!success&&jsxs29(Fragment15,{children:[jsx47(Stack11,{gap:"sm",mb:"md",children:jsx47(TextInput7,{name:"email",type:"email",label:"Email",placeholder:"name@domain.com",required:!0,autoFocus:!0,error:getErrorsForInput(outcome,"email")})}),jsxs29(Stack11,{gap:"xs",children:[jsx47(SubmitButton,{fullWidth:!0,children:"Reset Password"}),onSignIn&&jsx47(Text14,{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:jsx47(Anchor6,{onClick:onSignIn,children:"Back to Sign In"})}),onRegister&&jsxs29(Text14,{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? ",jsx47(Anchor6,{onClick:onRegister,children:"Sign Up"})]})]})]}),success&&jsx47(Text14,{c:"dimmed",size:"sm",ta:"center",mt:"md",children:"If the account exists on our system, a password reset email will be sent."})]})})}import{Anchor as Anchor7,Button as Button6,Flex as Flex7,Group as Group12,Stack as Stack12,Title as Title7}from"@mantine/core";import{badRequest,normalizeOperationOutcome as normalizeOperationOutcome7}from"@medplum/core";import{useMedplum as useMedplum15}from"@medplum/react-hooks";import{useState as useState26}from"react";import{jsx as jsx48,jsxs as jsxs30}from"react/jsx-runtime";function SetPasswordForm(props){let{id,secret,onSuccess,onSignIn}=props,medplum=useMedplum15(),[outcome,setOutcome]=useState26(),[success,setSuccess]=useState26(!1),issues=getIssuesForExpression(outcome,void 0);return jsxs30(Document,{width:450,children:[jsx48(OperationOutcomeAlert,{issues}),jsxs30(Form,{onSubmit:formData=>{if(formData.password!==formData.confirmPassword){setOutcome(badRequest("Passwords do not match","confirmPassword"));return}setOutcome(void 0),medplum.post("auth/setpassword",{id,secret,password:formData.password}).then(()=>{setSuccess(!0),onSuccess?.()}).catch(err=>setOutcome(normalizeOperationOutcome7(err)))},children:[jsxs30(Flex7,{direction:"column",align:"center",justify:"center",children:[jsx48(Logo,{size:32}),jsx48(Title7,{children:"Set password"})]}),!success&&jsxs30(Stack12,{children:[jsx48(PasswordInput,{name:"password",label:"New password",required:!0,error:getErrorsForInput(outcome,"password")}),jsx48(PasswordInput,{name:"confirmPassword",label:"Confirm new password",required:!0,error:getErrorsForInput(outcome,"confirmPassword")}),jsx48(Group12,{justify:"flex-end",mt:"xl",children:jsx48(Button6,{type:"submit",children:"Set password"})})]}),success&&jsxs30("div",{"data-testid":"success",children:["Password set. You can now\xA0",onSignIn?jsx48(Anchor7,{component:"button",type:"button",onClick:onSignIn,children:"sign in"}):"sign in","."]})]})]})}import{showNotification as showNotification4}from"@mantine/notifications";import{normalizeErrorString as normalizeErrorString7}from"@medplum/core";import{useMedplum as useMedplum18}from"@medplum/react-hooks";import{useCallback as useCallback6,useEffect as useEffect8,useRef as useRef6,useState as useState29}from"react";import{ActionIcon as ActionIcon3,Anchor as Anchor8,Box as Box9,Checkbox as Checkbox3,Divider as Divider4,Flex as Flex8,Stack as Stack13,Text as Text15,TextInput as TextInput8}from"@mantine/core";import{locationUtils as locationUtils4,normalizeOperationOutcome as normalizeOperationOutcome8}from"@medplum/core";import{useMedplum as useMedplum16}from"@medplum/react-hooks";import{useCallback as useCallback5,useState as useState27}from"react";import{Fragment as Fragment16,jsx as jsx49,jsxs as jsxs31}from"react/jsx-runtime";function AuthenticationForm(props){let[email,setEmail]=useState27();return email?jsx49(PasswordForm,{email,resetEmail:()=>setEmail(void 0),...props}):jsx49(EmailForm,{setEmail,...props})}function EmailForm(props){let{setEmail,onRegister,handleAuthResponse,children,disableEmailAuth,...baseLoginRequest}=props,medplum=useMedplum16(),googleClientId=!props.disableGoogleAuth&&getGoogleClientId(props.googleClientId),[outcome,setOutcome]=useState27(),issues=getIssuesForExpression(outcome,void 0),isExternalAuth=useCallback5(async authMethod=>{if(!authMethod.authorizeUrl)return!1;let state=JSON.stringify({...await medplum.ensureCodeChallenge(baseLoginRequest),domain:authMethod.domain,returnTo:locationUtils4.getLocation()}),url=new URL(authMethod.authorizeUrl);return url.searchParams.set("state",state),locationUtils4.assign(url.toString()),!0},[medplum,baseLoginRequest]),handleSubmit=useCallback5(async formData=>{let authMethod=await medplum.post("auth/method",{email:formData.email});await isExternalAuth(authMethod)||setEmail(formData.email)},[medplum,isExternalAuth,setEmail]),handleGoogleCredential=useCallback5(async response=>{try{let authResponse=await medplum.startGoogleLogin({...baseLoginRequest,googleCredential:response.credential});await isExternalAuth(authResponse)||handleAuthResponse(authResponse)}catch(err){setOutcome(normalizeOperationOutcome8(err))}},[medplum,baseLoginRequest,isExternalAuth,handleAuthResponse]);return jsxs31(Form,{onSubmit:handleSubmit,children:[jsx49(Flex8,{direction:"column",align:"center",justify:"center",children}),jsx49(OperationOutcomeAlert,{issues,mb:"lg"}),googleClientId&&jsxs31(Fragment16,{children:[jsx49(Box9,{style:{minHeight:40},children:jsx49(GoogleButton,{googleClientId,handleGoogleCredential})}),!disableEmailAuth&&jsx49(Divider4,{label:"or",labelPosition:"center",my:"lg"})]}),!disableEmailAuth&&jsx49(TextInput8,{name:"email",type:"email",label:"Email",mb:"md",placeholder:"name@domain.com",required:!0,autoFocus:!0,error:getErrorsForInput(outcome,"email"),"data-testid":"auth.email"}),jsxs31(Stack13,{gap:"xs",children:[!disableEmailAuth&&jsx49(SubmitButton,{fullWidth:!0,children:"Continue"}),onRegister&&jsxs31(Text15,{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\u2019t have an account? ",jsx49(Anchor8,{onClick:onRegister,children:"Register"})]})]})]})}function PasswordForm(props){let{onForgotPassword,handleAuthResponse,children,...baseLoginRequest}=props,medplum=useMedplum16(),[outcome,setOutcome]=useState27(),issues=getIssuesForExpression(outcome,void 0),handleSubmit=useCallback5(formData=>medplum.startLogin({...baseLoginRequest,password:formData.password,remember:formData.remember==="on"}).then(handleAuthResponse).catch(err=>setOutcome(normalizeOperationOutcome8(err))),[medplum,baseLoginRequest,handleAuthResponse]);return jsxs31(Form,{onSubmit:handleSubmit,children:[jsx49(Flex8,{direction:"column",align:"center",justify:"center",children}),jsx49(OperationOutcomeAlert,{issues,mb:"lg"}),jsxs31(Stack13,{gap:"sm",children:[jsx49(TextInput8,{label:"Email",value:props.email,disabled:!0,rightSectionWidth:36,rightSection:jsx49(ActionIcon3,{variant:"subtle",color:"gray",onClick:props.resetEmail,"aria-label":"Change email",children:jsx49(IconPencil,{size:"1rem",stroke:1.5})})}),jsx49(PasswordInput,{name:"password",label:"Password",autoComplete:"off",required:!0,autoFocus:!0,error:getErrorsForInput(outcome,"password"),"data-testid":"auth.password"})]}),jsxs31(Stack13,{gap:"xs",children:[jsx49(Checkbox3,{id:"remember",name:"remember",label:"Remember me",size:"xs",style:{lineHeight:1},pt:"md",pb:"xs"}),jsx49(SubmitButton,{children:"Sign In"}),onForgotPassword&&jsx49(Text15,{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:jsx49(Anchor8,{onClick:onForgotPassword,children:"Reset Password"})})]})]})}import{Anchor as Anchor9,Combobox as Combobox2,Flex as Flex9,Stack as Stack14,Text as Text16,TextInput as TextInput9,Title as Title8,useCombobox as useCombobox2}from"@mantine/core";import{useLocalStorage}from"@mantine/hooks";import{getIdentifier,normalizeOperationOutcome as normalizeOperationOutcome9}from"@medplum/core";import{useMedplum as useMedplum17}from"@medplum/react-hooks";import{useState as useState28}from"react";import{jsx as jsx50,jsxs as jsxs32}from"react/jsx-runtime";var RECENT_PROJECTS_KEY="medplum.recentProjects",MAX_RECENT_PROJECTS=10;function ChooseProfileForm(props){let medplum=useMedplum17(),combobox=useCombobox2(),[search,setSearch]=useState28(""),[outcome,setOutcome]=useState28(),[recentProjects,setRecentProjects]=useLocalStorage({key:RECENT_PROJECTS_KEY,defaultValue:{},getInitialValueInEffect:!1});function filterDisplay(display){return!!display?.toLowerCase()?.includes(search.toLowerCase())}function filterMembership(membership){return filterDisplay(membership.profile?.display)||filterDisplay(membership.project?.display)||filterDisplay(getMembershipLabel(membership))}function compareMembershipRecency(m1,m2){let t1=m1.id&&recentProjects[m1.id]||0;return(m2.id&&recentProjects[m2.id]||0)-t1}function handleValueSelect(membershipId){medplum.post("auth/profile",{login:props.login,profile:membershipId}).then(response=>{setRecentProjects(prev=>{let next={...prev,[membershipId]:Date.now()},entries=Object.entries(next).sort((a,b)=>b[1]-a[1]);return Object.fromEntries(entries.slice(0,MAX_RECENT_PROJECTS))}),props.handleAuthResponse(response)}).catch(err=>setOutcome(normalizeOperationOutcome9(err)))}let options=props.memberships.filter(filterMembership).sort(compareMembershipRecency).slice(0,10).map(item=>jsx50(Combobox2.Option,{value:item.id,className:ProjectLoginOption_default.interactive,children:jsx50(ProjectMembershipLoginOption,{membership:item,label:getMembershipLabel(item)})},item.id));return jsxs32(Stack14,{gap:"0",children:[jsxs32(Flex9,{justify:"center",align:"center",direction:"column",wrap:"nowrap",children:[jsx50(Logo,{size:32}),jsx50(Title8,{order:3,py:"lg",children:"Choose a Project"})]}),jsx50(OperationOutcomeAlert,{outcome,mb:"lg"}),jsxs32(Combobox2,{store:combobox,onOptionSubmit:handleValueSelect,children:[jsx50(Combobox2.EventsTarget,{children:jsx50(TextInput9,{placeholder:"Search",value:search,mb:"md",autoFocus:!0,leftSection:jsx50(IconSearch,{size:16}),onChange:event=>{setSearch(event.currentTarget.value),combobox.updateSelectedOptionIndex()}})}),jsx50("div",{children:jsx50(Combobox2.Options,{style:{marginLeft:"-10px",marginRight:"-10px",marginBottom:"-10px"},children:options.length>0?options:jsx50(Combobox2.Empty,{children:"Nothing found..."})})})]}),jsx50(Text16,{size:"sm",ta:"center",mt:"md",children:jsx50(Anchor9,{component:"button",type:"button",onClick:()=>{window.location.href=`/signin?project=new&login=${props.login}`},children:"Create a new project"})})]})}function getMembershipLabel(membership){return getIdentifier(membership,"https://medplum.com/identifier/label")}import{jsx as jsx51}from"react/jsx-runtime";function SignInForm(props){let{login:loginCode,chooseScopes,chooseScopeFormProps,onSuccess,onForgotPassword,onRegister,onCode,...baseLoginRequest}=props,medplum=useMedplum18(),[login,setLogin]=useState29(),loginRequested=useRef6(!1),[mfaEnrollRequired,setMfaEnrollRequired]=useState29(!1),[enrollQrCode,setEnrollQrCode]=useState29(),[enrollMethods,setEnrollMethods]=useState29(),[mfaRequired,setMfaRequired]=useState29(!1),[mfaMethods,setMfaMethods]=useState29(),[mfaEmail,setMfaEmail]=useState29(),[mfaEmailMode,setMfaEmailMode]=useState29(!1),[memberships,setMemberships]=useState29(),handleCode=useCallback6(code=>{onCode?onCode(code):medplum.processCode(code).then(()=>{onSuccess&&onSuccess()}).catch(err=>showNotification4({color:"red",message:normalizeErrorString7(err)}))},[medplum,onCode,onSuccess]),handleAuthResponse=useCallback6(response=>{if(setMfaEnrollRequired(!!response.mfaEnrollRequired),setEnrollQrCode(response.enrollQrCode),setEnrollMethods(response.allowedMfaMethods),setMfaRequired(!!response.mfaRequired),response.mfaRequired){let methods=response.mfaMethods;setMfaMethods(methods),setMfaEmail(response.email),methods?.length===1&&methods[0]==="email"&&setMfaEmailMode(!0)}else setMfaMethods(void 0),setMfaEmail(void 0),setMfaEmailMode(!1);response.login&&setLogin(response.login),response.memberships&&setMemberships(response.memberships),response.code&&(chooseScopes?setMemberships(void 0):handleCode(response.code))},[chooseScopes,handleCode]),requestEmailCode=useCallback6(async()=>{login&&await medplum.post("auth/mfa/send-email",{login})},[medplum,login]),enrollEmail=useCallback6(()=>{login&&medplum.post("auth/mfa/login-enroll",{login,method:"email"}).then(handleAuthResponse).catch(err=>showNotification4({color:"red",message:normalizeErrorString7(err)}))},[medplum,login,handleAuthResponse]),handleScopeResponse=useCallback6(response=>{handleCode(response.code)},[handleCode]);return useEffect8(()=>{loginCode&&!loginRequested.current&&!login&&(loginRequested.current=!0,medplum.get("auth/login/"+loginCode).then(handleAuthResponse).catch(err=>showNotification4({color:"red",message:normalizeErrorString7(err)})))},[medplum,loginCode,loginRequested,login,handleAuthResponse]),jsx51(Document,{width:400,px:"xl",py:"xl",bdrs:"md",children:login?mfaEnrollRequired?jsx51(MfaEnrollForm,{allowedMethods:enrollMethods??["totp"],qrCodeUrl:enrollQrCode,onEnrollEmail:enrollEmail,totpTitle:"Enroll in MFA",totpDescription:"Scan this QR code with your authenticator app.",onEnrollTotp:async token=>{let res=await medplum.post("auth/mfa/login-enroll",{login,method:"totp",token});handleAuthResponse(res)}}):mfaRequired?jsx51(MfaVerificationForm,{methods:mfaMethods??[],email:mfaEmail,initialEmailMode:mfaEmailMode,onRequestEmailCode:requestEmailCode,onSubmit:async token=>{let res=await medplum.post("auth/mfa/verify",{login,token});handleAuthResponse(res)}}):props.projectId==="new"?jsx51(NewProjectForm,{login,handleAuthResponse}):memberships?jsx51(ChooseProfileForm,{login,memberships,handleAuthResponse}):props.chooseScopes?jsx51(ChooseScopeForm,{login,scope:props.scope,handleAuthResponse:handleScopeResponse,...chooseScopeFormProps}):jsx51("div",{children:"Success"}):jsx51(AuthenticationForm,{onForgotPassword,onRegister,handleAuthResponse,disableGoogleAuth:props.disableGoogleAuth,disableEmailAuth:props.disableEmailAuth,...baseLoginRequest,children:props.children})})}import{buildElementsContext as buildElementsContext2,getPathDisplayName as getPathDisplayName3,isEmpty as isEmpty2,tryGetDataType}from"@medplum/core";import{useContext as useContext6,useMemo as useMemo6}from"react";import{ActionIcon as ActionIcon4,CopyButton,Flex as Flex10,Tooltip as Tooltip3}from"@mantine/core";import{formatDateTime,formatPeriod,formatTiming,formatWallTime,isEmpty,isObject,isString,PropertyType}from"@medplum/core";import{useState as useState32}from"react";import{formatCodeableConcept}from"@medplum/core";import{Fragment as Fragment17,jsx as jsx52}from"react/jsx-runtime";function CodeableConceptDisplay(props){return jsx52(Fragment17,{children:formatCodeableConcept(props.value)})}import{formatCoding}from"@medplum/core";import{Fragment as Fragment18,jsx as jsx53}from"react/jsx-runtime";function CodingDisplay(props){return jsx53(Fragment18,{children:formatCoding(props.value,props.includeCode)})}import{Fragment as Fragment19,jsx as jsx54}from"react/jsx-runtime";function ContactPointDisplay(props){let contactPoint=props.value;if(!contactPoint)return null;let builder=[];return contactPoint.value&&builder.push(contactPoint.value),(contactPoint.use||contactPoint.system)&&(builder.push(" ["),contactPoint.use&&builder.push(contactPoint.use),contactPoint.use&&contactPoint.system&&builder.push(" "),contactPoint.system&&builder.push(contactPoint.system),builder.push("]")),jsx54(Fragment19,{children:builder.join("").trim()})}import{Fragment as Fragment20,jsx as jsx55,jsxs as jsxs33}from"react/jsx-runtime";function ContactDetailDisplay(props){let contactDetail=props.value;return contactDetail?jsxs33(Fragment20,{children:[contactDetail.name,contactDetail.name&&": ",contactDetail.telecom?.map(telecom=>jsx55(ContactPointDisplay,{value:telecom},`telecom-${contactDetail.name}-${telecom.value}`))]}):null}import{getDataType,isPopulated as isPopulated3,isProfileLoaded,tryGetProfile}from"@medplum/core";import{useMedplum as useMedplum19}from"@medplum/react-hooks";import{useContext as useContext3,useEffect as useEffect9,useMemo as useMemo3,useState as useState30}from"react";import{getTypedPropertyValue,getTypedPropertyValueWithSchema}from"@medplum/core";function getValueAndType(context,path,profileUrl){let typedResult=getTypedPropertyValue(context,path,{profileUrl});return typedResult?Array.isArray(typedResult)?[typedResult.map(e=>e.value),typedResult[0].type]:[typedResult.value,typedResult.type]:[void 0,"undefined"]}function getValueAndTypeFromElement(typedValue,path,element){let typedResult=getTypedPropertyValueWithSchema(typedValue,path,element);return typedResult?Array.isArray(typedResult)?[typedResult.map(e=>e.value),typedResult[0].type]:[typedResult.value,typedResult.type]:[void 0,"undefined"]}import{jsx as jsx56}from"react/jsx-runtime";function ExtensionDisplay(props){let{elementDefinitionType}=props,medplum=useMedplum19(),ctx=useContext3(ElementsContext),[typeSchema,setTypeSchema]=useState30(getDataType("Extension")),profileUrl=useMemo3(()=>{if(isPopulated3(elementDefinitionType?.profile))return elementDefinitionType.profile[0]},[elementDefinitionType]),[loadingProfile,setLoadingProfile]=useState30(profileUrl!==void 0);if(useEffect9(()=>{profileUrl&&(setLoadingProfile(!0),medplum.requestProfileSchema(profileUrl).then(()=>{let profile=tryGetProfile(profileUrl);setLoadingProfile(!1),profile&&setTypeSchema(profile)}).catch(reason=>{setLoadingProfile(!1),console.warn(reason)}))},[medplum,profileUrl]),profileUrl&&(loadingProfile||!isProfileLoaded(profileUrl)))return jsx56("div",{children:"Loading..."});if(typeSchema.elements["value[x]"]?.max!==0){let[propertyValue,propertyType]=getValueAndType({type:"Extension",value:props.value},"value[x]",profileUrl??ctx.profileUrl);return jsx56(ResourcePropertyDisplay,{propertyType,value:propertyValue})}return jsx56(BackboneElementDisplay,{path:props.path,value:{type:typeSchema.type,value:props.value},compact:props.compact,ignoreMissingValues:props.ignoreMissingValues,link:props.link,profileUrl})}import{formatHumanName as formatHumanName6}from"@medplum/core";import{Fragment as Fragment21,jsx as jsx57}from"react/jsx-runtime";function HumanNameDisplay(props){let name=props.value;return name?jsx57(Fragment21,{children:formatHumanName6(name,props.options)}):null}import{jsxs as jsxs34}from"react/jsx-runtime";function IdentifierDisplay(props){return jsxs34("div",{children:[props.value?.system,": ",props.value?.value]})}import{formatMoney}from"@medplum/core";import{Fragment as Fragment22,jsx as jsx58}from"react/jsx-runtime";function MoneyDisplay(props){return jsx58(Fragment22,{children:formatMoney(props.value)})}import{formatQuantity}from"@medplum/core";import{Fragment as Fragment23,jsx as jsx59}from"react/jsx-runtime";function QuantityDisplay(props){return jsx59(Fragment23,{children:formatQuantity(props.value,props.precision)})}import{formatRange}from"@medplum/core";import{Fragment as Fragment24,jsx as jsx60}from"react/jsx-runtime";function RangeDisplay(props){return jsx60(Fragment24,{children:formatRange(props.value,props.precision,props.exclusive)})}import{Fragment as Fragment25,jsx as jsx61,jsxs as jsxs35}from"react/jsx-runtime";function RatioDisplay(props){let value=props.value;return value?jsxs35(Fragment25,{children:[jsx61(QuantityDisplay,{value:value.numerator,precision:props.precision}),"\xA0/\xA0",jsx61(QuantityDisplay,{value:value.denominator,precision:props.precision})]}):null}import{stringify}from"@medplum/core";import{Fragment as Fragment26,jsx as jsx62}from"react/jsx-runtime";function ReferenceDisplay(props){if(!props.value)return null;let displayString=props.value.display||props.value.reference||stringify(props.value);return props.link!==!1&&props.value.reference?jsx62(MedplumLink,{to:props.value,children:displayString}):jsx62(Fragment26,{children:displayString})}import{Group as Group13,Text as Text17}from"@mantine/core";import{getPathDisplayName as getPathDisplayName2,isPopulated as isPopulated6}from"@medplum/core";import{useMedplum as useMedplum20}from"@medplum/react-hooks";import{useContext as useContext5,useEffect as useEffect10,useMemo as useMemo5,useState as useState31}from"react";import{getValueSliceName,isPopulated as isPopulated4,isSliceDefinitionWithTypes,tryGetProfile as tryGetProfile2}from"@medplum/core";function assignValuesIntoSlices(values,slices,slicing,profileUrl){if(!isPopulated4(slicing?.slices))return[values];let slicedValues=new Array(slices.length+1);for(let i=0;i<slicedValues.length;i++)slicedValues[i]=[];for(let value of values){let sliceName=getValueSliceName(value,slices,slicing.discriminator,profileUrl),sliceIndex=sliceName?slices.findIndex(slice=>slice.name===sliceName):-1;sliceIndex===-1&&(sliceIndex=slices.length),slicedValues[sliceIndex].push(value)}return slicedValues}async function prepareSlices({medplum,property}){return new Promise((resolve,reject)=>{if(!property.slicing){resolve([]);return}let supportedSlices=[],profileUrls=[],promises=[];for(let slice of property.slicing.slices){if(!isSliceDefinitionWithTypes(slice)){console.debug("Unsupported slice definition",slice);continue}let profileUrl;isPopulated4(slice.elements)||(profileUrl=slice.type[0]?.profile?.[0]),supportedSlices.push(slice),profileUrls.push(profileUrl),profileUrl&&promises.push(medplum.requestProfileSchema(profileUrl))}Promise.all(promises).then(()=>{for(let i=0;i<supportedSlices.length;i++){let slice=supportedSlices[i],profileUrl=profileUrls[i];if(profileUrl){let typeSchema=tryGetProfile2(profileUrl);slice.typeSchema=typeSchema}}resolve(supportedSlices)}).catch(reject)})}import{buildElementsContext,isPopulated as isPopulated5}from"@medplum/core";import{useContext as useContext4,useMemo as useMemo4}from"react";import{jsx as jsx63}from"react/jsx-runtime";function maybeWrapWithContext(ContextProvider,contextValue,contents){return contextValue!==void 0?jsx63(ContextProvider,{value:contextValue,children:contents}):contents}import{Fragment as Fragment27,jsx as jsx64}from"react/jsx-runtime";function SliceDisplay(props){let{slice,property}=props,sliceElements=slice.typeSchema?.elements??slice.elements,parentContext=useContext4(ElementsContext),contextValue=useMemo4(()=>{if(isPopulated5(sliceElements))return buildElementsContext({parentContext,elements:sliceElements,path:props.path,profileUrl:slice.typeSchema?.url})},[parentContext,props.path,slice.typeSchema?.url,sliceElements]);return maybeWrapWithContext(ElementsContext.Provider,contextValue,jsx64(Fragment27,{children:props.value.map((value,valueIndex)=>jsx64("div",{children:jsx64(ResourcePropertyDisplay,{property,path:props.path,arrayElement:!0,elementDefinitionType:slice.type[0],propertyType:slice.type[0].code,value,ignoreMissingValues:props.ignoreMissingValues,link:props.link})},`${valueIndex}-${props.value.length}`))}))}import{Fragment as Fragment28,jsx as jsx65,jsxs as jsxs36}from"react/jsx-runtime";var MAX_ARRAY_SIZE=50;function ResourceArrayDisplay(props){let{property,propertyType}=props,medplum=useMedplum20(),values=useMemo5(()=>Array.isArray(props.values)?props.values:[],[props.values]),[loading,setLoading]=useState31(!0),[slices,setSlices]=useState31([]),[slicedValues,setSlicedValues]=useState31(()=>[values]),[valuesLength,setValuesLength]=useState31(0),ctx=useContext5(ElementsContext);if(useEffect10(()=>{prepareSlices({medplum,property}).then(slices2=>{setValuesLength(values.length),setSlices(slices2);let limitedValues=values.slice(0,MAX_ARRAY_SIZE),slicedValues2=assignValuesIntoSlices(limitedValues,slices2,property.slicing,ctx.profileUrl);setSlicedValues(slicedValues2),setLoading(!1)}).catch(reason=>{console.error(reason),setLoading(!1)})},[medplum,property,ctx.profileUrl,setSlicedValues,values]),loading)return jsx65("div",{children:"Loading..."});let nonSliceContent;if(property.type[0]?.code!=="Extension"){let nonSliceValues=slicedValues[slices.length],nonSliceElements=nonSliceValues.map((value,valueIndex)=>jsx65("div",{children:jsx65(ResourcePropertyDisplay,{path:props.path,arrayElement:!0,property,propertyType,value,ignoreMissingValues:props.ignoreMissingValues,link:props.link})},`${valueIndex}-${nonSliceValues.length}`));if(props.includeDescriptionListEntry){if(!isPopulated6(props.path))throw new Error("props.path is required when includeDescriptionListEntry is true");let key=props.path.split(".").pop();nonSliceContent=jsx65(DescriptionListEntry,{term:getPathDisplayName2(key),children:nonSliceElements})}else nonSliceContent=jsx65(Fragment28,{children:nonSliceElements})}return jsxs36(Fragment28,{children:[slices.map((slice,sliceIndex)=>{if(!props.path)throw new Error(`Displaying a resource property with slices of type ${props.propertyType} requires path`);let sliceDisplay=jsx65(SliceDisplay,{path:props.path,slice,property,value:slicedValues[sliceIndex],ignoreMissingValues:props.ignoreMissingValues,link:props.link},slice.name);return props.includeDescriptionListEntry&&(sliceDisplay=jsx65(DescriptionListEntry,{term:getPathDisplayName2(slice.name),children:sliceDisplay},slice.name)),sliceDisplay}),nonSliceContent,valuesLength>MAX_ARRAY_SIZE&&jsx65(Group13,{justify:"right",children:jsxs36(Text17,{children:["... ",valuesLength," total values"]})})]})}import{Fragment as Fragment29,jsx as jsx66,jsxs as jsxs37}from"react/jsx-runtime";function ResourcePropertyDisplay(props){let{property,propertyType,value}=props;if(property?.path?.endsWith(".id"))return jsxs37(Flex10,{gap:3,align:"center",children:[value,!isEmpty(value)&&jsx66(CopyButton,{value,timeout:2e3,children:({copied,copy})=>jsx66(Tooltip3,{label:copied?"Copied":"Copy",withArrow:!0,position:"right",children:jsx66(ActionIcon4,{variant:"subtle",color:copied?"teal":"gray",onClick:copy,children:copied?jsx66(IconCheck,{size:"1rem"}):jsx66(IconCopy,{size:"1rem"})})})})]});if(property&&(property.isArray||property.max>1)&&!props.arrayElement)return propertyType===PropertyType.Attachment?jsx66(AttachmentArrayDisplay,{values:value,maxWidth:props.maxWidth,includeDescriptionListEntry:props.includeArrayDescriptionListEntry,property,path:props.path}):jsx66(ResourceArrayDisplay,{path:props.path,property,propertyType,values:value,includeDescriptionListEntry:props.includeArrayDescriptionListEntry,ignoreMissingValues:props.ignoreMissingValues,link:props.link});switch(propertyType){case PropertyType.boolean:return jsx66(Fragment29,{children:value===void 0?"":(!!value).toString()});case PropertyType.SystemString:case PropertyType.string:return props.property?.path?.toLowerCase().includes("secret")?jsx66(SecretFieldDisplay,{value}):jsx66("div",{style:{whiteSpace:"pre-wrap"},children:value});case PropertyType.code:case PropertyType.date:case PropertyType.decimal:case PropertyType.id:case PropertyType.integer:case PropertyType.positiveInt:case PropertyType.unsignedInt:case PropertyType.uri:case PropertyType.url:case PropertyType.xhtml:return isObject(value)&&!isString(value)?(console.warn("Non-standard FHIR data or missing primitive value with extension",{path:props.path,propertyType,value}),null):jsx66(Fragment29,{children:value?.toString()});case PropertyType.canonical:return jsx66(ReferenceDisplay,{value:{reference:value},link:props.link});case PropertyType.dateTime:case PropertyType.instant:return jsx66(Fragment29,{children:formatDateTime(value)});case PropertyType.time:return jsx66(Fragment29,{children:formatWallTime(value)});case PropertyType.markdown:return jsx66("pre",{children:value});case PropertyType.Address:return jsx66(AddressDisplay,{value});case PropertyType.Annotation:return jsx66(Fragment29,{children:value?.text});case PropertyType.Attachment:return jsx66(AttachmentDisplay,{value,maxWidth:props.maxWidth});case PropertyType.CodeableConcept:return jsx66(CodeableConceptDisplay,{value});case PropertyType.Coding:return jsx66(CodingDisplay,{value});case PropertyType.ContactDetail:return jsx66(ContactDetailDisplay,{value});case PropertyType.ContactPoint:return jsx66(ContactPointDisplay,{value});case PropertyType.HumanName:return jsx66(HumanNameDisplay,{value});case PropertyType.Identifier:return jsx66(IdentifierDisplay,{value});case PropertyType.Money:return jsx66(MoneyDisplay,{value});case PropertyType.Period:return jsx66(Fragment29,{children:formatPeriod(value)});case PropertyType.Quantity:case PropertyType.Duration:return jsx66(QuantityDisplay,{value});case PropertyType.Range:return jsx66(RangeDisplay,{value});case PropertyType.Ratio:return jsx66(RatioDisplay,{value});case PropertyType.Reference:return jsx66(ReferenceDisplay,{value,link:props.link});case PropertyType.Timing:return jsx66(Fragment29,{children:formatTiming(value)});case PropertyType.Dosage:case PropertyType.UsageContext:if(!props.path)throw new Error(`Displaying property of type ${props.propertyType} requires path`);return jsx66(BackboneElementDisplay,{path:props.path,value:{type:propertyType,value},compact:!0,ignoreMissingValues:props.ignoreMissingValues});case PropertyType.Extension:if(!props.path)throw new Error(`Displaying property of type ${props.propertyType} requires path`);return jsx66(ExtensionDisplay,{path:props.path,value,compact:!0,ignoreMissingValues:props.ignoreMissingValues,elementDefinitionType:props.elementDefinitionType});default:if(!property)throw new Error(`Displaying property of type ${props.propertyType} requires element schema`);if(!props.path)throw new Error(`Displaying property of type ${props.propertyType} requires path`);return jsx66(BackboneElementDisplay,{path:props.path,value:{type:property.type[0].code,value},compact:!0,ignoreMissingValues:props.ignoreMissingValues})}}function SecretFieldDisplay(props){let[isVisible,setIsVisible]=useState32(!1),secretValue=props.value??"",hasValue=!isEmpty(secretValue),MASK="\u2022".repeat(8);return jsxs37(Flex10,{gap:3,align:"center",children:[isVisible?jsx66("div",{style:{whiteSpace:"pre-wrap"},children:secretValue}):jsx66("div",{style:{whiteSpace:"pre-wrap"},"aria-hidden":"true",children:hasValue?MASK:""}),hasValue&&jsxs37(Fragment29,{children:[jsx66(CopyButton,{value:props.value,timeout:2e3,children:({copied,copy})=>jsx66(Tooltip3,{label:copied?"Copied":"Copy secret",withArrow:!0,position:"right",children:jsx66(ActionIcon4,{variant:"subtle",color:copied?"teal":"gray",onClick:copy,"aria-label":copied?"Copied":"Copy secret",children:copied?jsx66(IconCheck,{size:"1rem"}):jsx66(IconCopy,{size:"1rem"})})})}),jsx66(Tooltip3,{label:isVisible?"Hide secret":"Show secret",withArrow:!0,position:"right",children:jsx66(ActionIcon4,{variant:"subtle",color:"gray",onClick:()=>setIsVisible(!isVisible),"aria-label":isVisible?"Hide secret":"Show secret",children:isVisible?jsx66(IconEyeOff,{size:"1rem"}):jsx66(IconEye,{size:"1rem"})})})]})]})}import{jsx as jsx67,jsxs as jsxs38}from"react/jsx-runtime";var EXTENSION_KEYS2=["extension","modifierExtension"],IGNORED_PROPERTIES2=DEFAULT_IGNORED_PROPERTIES.filter(prop=>!EXTENSION_KEYS2.includes(prop));function BackboneElementDisplay(props){let typedValue=props.value,{value,type:typeName}=typedValue,parentElementsContext=useContext6(ElementsContext),profileUrl=props.profileUrl??parentElementsContext?.profileUrl,typeSchema=useMemo6(()=>tryGetDataType(typeName,profileUrl),[profileUrl,typeName]),newElementsContext=useMemo6(()=>{if(typeSchema)return buildElementsContext2({parentContext:parentElementsContext,elements:typeSchema.elements,path:props.path,profileUrl:typeSchema.url,accessPolicyResource:props.accessPolicyResource})},[typeSchema,parentElementsContext,props.path,props.accessPolicyResource]);if(isEmpty2(value))return null;if(!typeSchema)return jsxs38("div",{children:[typeName,"\xA0not implemented"]});if(typeof value=="object"&&"name"in value&&Object.keys(value).length===1&&typeof value.name=="string")return jsx67("div",{children:value.name});let elementsContext=newElementsContext??parentElementsContext;return maybeWrapWithContext(ElementsContext.Provider,newElementsContext,jsx67(DescriptionList,{compact:props.compact,children:Object.entries(elementsContext.elements).map(([key,property])=>{if(EXTENSION_KEYS2.includes(key)&&isEmpty2(property.slicing?.slices))return null;if(IGNORED_PROPERTIES2.includes(key))return null;if(DEFAULT_IGNORED_NON_NESTED_PROPERTIES.includes(key)&&property.path.split(".").length===2||key.includes("."))return null;let[propertyValue,propertyType]=getValueAndType(typedValue,key,elementsContext.profileUrl);if((props.ignoreMissingValues||property.max===0)&&isEmpty2(propertyValue)||props.path.endsWith(".extension")&&(key==="url"||key==="id"))return null;let isArrayProperty=property.max>1||property.isArray,resourcePropertyDisplay=jsx67(ResourcePropertyDisplay,{property,propertyType,path:props.path+"."+key,value:propertyValue,ignoreMissingValues:props.ignoreMissingValues,includeArrayDescriptionListEntry:isArrayProperty,link:props.link},key);return isArrayProperty?resourcePropertyDisplay:jsx67(DescriptionListEntry,{term:getPathDisplayName3(key),children:resourcePropertyDisplay},key)})}))}import{Box as Box11}from"@mantine/core";import{buildElementsContext as buildElementsContext4,tryGetDataType as tryGetDataType2}from"@medplum/core";import{useContext as useContext23,useMemo as useMemo22,useState as useState53}from"react";import{Stack as Stack18}from"@mantine/core";import{getPathDisplayName as getPathDisplayName5}from"@medplum/core";import{useContext as useContext22,useMemo as useMemo21,useState as useState52}from"react";import{Group as Group14,Input}from"@mantine/core";import{useContext as useContext7}from"react";var FormSection_default={dimmed:"FormSection_dimmed",preserveBreaks:"FormSection_preserveBreaks"};import{Tooltip as Tooltip4}from"@mantine/core";import{jsx as jsx68}from"react/jsx-runtime";var READ_ONLY_TOOLTIP_TEXT="Read Only";function maybeWrapWithTooltip(tooltipText,children){return tooltipText?jsx68(Tooltip4.Floating,{label:tooltipText,children}):children}import{jsx as jsx69,jsxs as jsxs39}from"react/jsx-runtime";function CheckboxFormSection(props){let{debugMode}=useContext7(ElementsContext),label;return debugMode&&props.fhirPath?label=`${props.title} - ${props.fhirPath}`:label=props.title,maybeWrapWithTooltip(props?.readonly?READ_ONLY_TOOLTIP_TEXT:void 0,jsxs39(Group14,{wrap:"nowrap","data-testid":props.testId,children:[jsx69("div",{children:props.children}),jsx69("div",{children:jsx69(Input.Wrapper,{id:props.htmlFor,label,classNames:{label:props?.readonly?FormSection_default.dimmed:void 0},description:props.description,withAsterisk:props.withAsterisk,children:null})})]}))}import{Input as Input2}from"@mantine/core";import{useContext as useContext8}from"react";import{jsx as jsx70}from"react/jsx-runtime";function FormSection(props){let{debugMode}=useContext8(ElementsContext),label;return debugMode&&props.fhirPath?label=`${props.title} - ${props.fhirPath}`:label=props.title,maybeWrapWithTooltip(props?.readonly?READ_ONLY_TOOLTIP_TEXT:void 0,jsx70(Input2.Wrapper,{id:props.htmlFor,label,classNames:{label:clsx_default({[FormSection_default.dimmed]:props?.readonly},FormSection_default.preserveBreaks)},description:props.description,withAsterisk:props.withAsterisk,error:getErrorsForInput(props.outcome,props.errorExpression??props.htmlFor),"data-testid":props.testId,children:props.children}))}import{capitalize,isEmpty as isEmpty3}from"@medplum/core";function setPropertyValue(obj,key,propName,elementDefinition,value){let types=elementDefinition.type;if(types.length>1)for(let type of types){let compoundKey=key.replace("[x]",capitalize(type.code));compoundKey in obj&&delete obj[compoundKey]}return isEmpty3(value)?obj[propName]=void 0:obj[propName]=value,obj}function isSupportedProfileStructureDefinition(profile){return!!profile&&!isEmpty3(profile.url)&&!isEmpty3(profile.name)}import{Checkbox as Checkbox4,Group as Group28,NativeSelect as NativeSelect9,Textarea as Textarea2,TextInput as TextInput18}from"@mantine/core";import{applyDefaultValuesToElement,capitalize as capitalize2,getPathDifference,HTTP_HL7_ORG,isComplexTypeCode,isEmpty as isEmpty6,isPopulated as isPopulated10,PropertyType as PropertyType2}from"@medplum/core";import{useContext as useContext21,useMemo as useMemo20,useState as useState51}from"react";import{useState as useState33}from"react";import{jsx as jsx71}from"react/jsx-runtime";function CodeableConceptInput(props){let{defaultValue:defaultValue2,onChange,withHelpText,outcome:_outcome,path:_path,valuePath:_valuePath,...rest}=props,[value,setValue]=useState33(defaultValue2);function handleChange(newValues){let newConcept=valueSetElementToCodeableConcept(newValues);setValue(newConcept),onChange&&onChange(newConcept)}return jsx71(ValueSetAutocomplete,{defaultValue:value&&codeableConceptToValueSetElement(value),onChange:handleChange,withHelpText:withHelpText??!0,...rest})}function codeableConceptToValueSetElement(concept){return concept.coding?.map(c=>({system:c.system,code:c.code,display:c.display}))}function valueSetElementToCodeableConcept(elements){if(elements.length!==0)return{coding:elements.map(e=>({system:e.system,code:e.code,display:e.display}))}}import{useState as useState34}from"react";import{jsx as jsx72}from"react/jsx-runtime";function CodingInput(props){let{defaultValue:defaultValue2,onChange,withHelpText,response,...rest}=props,[value,setValue]=useState34(response?.answer?.[0]?.valueCoding??defaultValue2);function handleChange(newValues){let newValue=newValues[0],newConcept=newValue&&valueSetElementToCoding(newValue);setValue(newConcept),onChange&&onChange(newConcept)}return jsx72(ValueSetAutocomplete,{defaultValue:value?codingToValueSetElement(value):void 0,maxValues:1,onChange:handleChange,withHelpText:withHelpText??!0,...rest})}function codingToValueSetElement(coding){return{system:coding.system,code:coding.code,display:coding.display}}function valueSetElementToCoding(element){return{system:element.system,code:element.code,display:element.display}}import{Group as Group16,TextInput as TextInput11}from"@mantine/core";import{useContext as useContext10,useMemo as useMemo8,useState as useState36}from"react";import{Group as Group15,NativeSelect as NativeSelect3,TextInput as TextInput10}from"@mantine/core";import{useContext as useContext9,useMemo as useMemo7,useState as useState35}from"react";import{jsx as jsx73,jsxs as jsxs40}from"react/jsx-runtime";function ContactPointInput(props){let{path,outcome}=props,{elementsByPath,getExtendedProps}=useContext9(ElementsContext),[contactPoint,setContactPoint]=useState35(props.defaultValue),[systemElement,useElement,valueElement]=useMemo7(()=>["system","use","value"].map(field=>elementsByPath[path+"."+field]),[elementsByPath,path]),[systemProps,useProps,valueProps]=useMemo7(()=>["system","use","value"].map(field=>getExtendedProps(path+"."+field)),[getExtendedProps,path]);function setContactPointWrapper(newValue){newValue&&Object.keys(newValue).length===0&&(newValue=void 0),setContactPoint(newValue),props.onChange&&props.onChange(newValue)}function setSystem(system){let newValue={...contactPoint,system};system||delete newValue.system,setContactPointWrapper(newValue)}function setUse(use){let newValue={...contactPoint,use};use||delete newValue.use,setContactPointWrapper(newValue)}function setValue(value){let newValue={...contactPoint,value};value||delete newValue.value,setContactPointWrapper(newValue)}let errorPath=props.valuePath??path;return jsxs40(Group15,{gap:"xs",grow:!0,wrap:"nowrap",align:"flex-start",children:[jsx73(NativeSelect3,{disabled:props.disabled||systemProps?.readonly,"data-testid":"system",defaultValue:contactPoint?.system,required:(systemElement?.min??0)>0,onChange:e=>setSystem(e.currentTarget.value),data:["","email","phone","fax","pager","sms","url","other"],error:getErrorsForInput(outcome,errorPath+".system")}),jsx73(NativeSelect3,{disabled:props.disabled||useProps?.readonly,"data-testid":"use",defaultValue:contactPoint?.use,required:(useElement?.min??0)>0,onChange:e=>setUse(e.currentTarget.value),data:["","home","work","temp","old","mobile"],error:getErrorsForInput(outcome,errorPath+".use")}),jsx73(TextInput10,{disabled:props.disabled||valueProps?.readonly,placeholder:"Value",defaultValue:contactPoint?.value,required:(valueElement?.min??0)>0,onChange:e=>setValue(e.currentTarget.value),error:getErrorsForInput(outcome,errorPath+".value")})]})}import{jsx as jsx74,jsxs as jsxs41}from"react/jsx-runtime";function ContactDetailInput(props){let[contactDetail,setContactDetail]=useState36(props.defaultValue),{getExtendedProps}=useContext10(ElementsContext),[nameProps,telecomProps]=useMemo8(()=>["name","telecom"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setContactDetailWrapper(newValue){setContactDetail(newValue),props.onChange&&props.onChange(newValue)}function setName(name){let newValue={...contactDetail,name};name||delete newValue.name,setContactDetailWrapper(newValue)}function setTelecom(telecom){let newValue={...contactDetail,telecom:telecom&&[telecom]};telecom||delete newValue.telecom,setContactDetailWrapper(newValue)}return jsxs41(Group16,{gap:"xs",grow:!0,wrap:"nowrap",children:[jsx74(TextInput11,{disabled:props.disabled||nameProps?.readonly,"data-testid":props.name+"-name",name:props.name+"-name",placeholder:"Name",style:{width:180},defaultValue:contactDetail?.name,onChange:e=>setName(e.currentTarget.value)}),jsx74(ContactPointInput,{disabled:props.disabled||telecomProps?.readonly,name:props.name+"-telecom",path:props.path+".telecom",defaultValue:contactDetail?.telecom?.[0],onChange:setTelecom,outcome:props.outcome})]})}import{TextInput as TextInput12}from"@mantine/core";import{isValidDate}from"@medplum/core";function convertIsoToLocal(isoString){if(!isoString)return"";let date=new Date(isoString);return isValidDate(date)?date.toLocaleDateString("sv")+"T"+date.toLocaleTimeString("sv"):""}function convertLocalToIso(localString){if(!localString)return"";let date=new Date(localString);return isValidDate(date)?date.toISOString():""}import{jsx as jsx75}from"react/jsx-runtime";function DateTimeInput(props){return jsx75(TextInput12,{id:props.name,name:props.name,label:props.label,"data-autofocus":props.autoFocus,"data-testid":props["data-testid"]??props.name,placeholder:props.placeholder,required:props.required,disabled:props.disabled,type:getInputType(),step:1,defaultValue:convertIsoToLocal(props.defaultValue),autoFocus:props.autoFocus,error:getErrorsForInput(props.outcome,props.name),onChange:e=>{if(props.onChange){let newValue=e.currentTarget.value;props.onChange(convertLocalToIso(newValue))}}})}function getInputType(){return"datetime-local"}import{isPopulated as isPopulated7,isProfileLoaded as isProfileLoaded2}from"@medplum/core";import{useMedplum as useMedplum21}from"@medplum/react-hooks";import{useEffect as useEffect11,useMemo as useMemo9,useState as useState37}from"react";import{jsx as jsx76}from"react/jsx-runtime";function ExtensionInput(props){let{propertyType}=props,medplum=useMedplum21(),profileUrl=useMemo9(()=>{if(isPopulated7(propertyType.profile))return propertyType.profile[0]},[propertyType]),[loadingProfile,setLoadingProfile]=useState37(profileUrl!==void 0);return useEffect11(()=>{profileUrl&&(setLoadingProfile(!0),medplum.requestProfileSchema(profileUrl).then(()=>setLoadingProfile(!1)).catch(reason=>{setLoadingProfile(!1),console.warn(reason)}))},[medplum,profileUrl]),profileUrl&&(loadingProfile||!isProfileLoaded2(profileUrl))?jsx76("div",{children:"Loading..."}):jsx76(BackboneElementInput,{profileUrl,path:props.path,typeName:"Extension",defaultValue:props.defaultValue,onChange:props.onChange})}import{Group as Group17,NativeSelect as NativeSelect4,TextInput as TextInput13}from"@mantine/core";import{useContext as useContext11,useMemo as useMemo10,useState as useState38}from"react";import{jsx as jsx77,jsxs as jsxs42}from"react/jsx-runtime";function HumanNameInput(props){let{outcome,path}=props,[value,setValue]=useState38(props.defaultValue),{getExtendedProps}=useContext11(ElementsContext),[useProps,prefixProps,givenProps,familyProps,suffixProps]=useMemo10(()=>["use","prefix","given","family","suffix"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}function setUse(use){setValueWrapper({...value,use:use||void 0})}function setPrefix(prefix){setValueWrapper({...value,prefix:prefix?prefix.split(" "):void 0})}function setGiven(given){setValueWrapper({...value,given:given?given.split(" "):void 0})}function setFamily(family){setValueWrapper({...value,family:family||void 0})}function setSuffix(suffix){setValueWrapper({...value,suffix:suffix?suffix.split(" "):void 0})}let errorPath=props.valuePath??path;return jsxs42(Group17,{gap:"xs",grow:!0,wrap:"nowrap",children:[jsx77(NativeSelect4,{disabled:props.disabled||useProps?.readonly,defaultValue:value?.use,name:props.name+"-use","data-testid":"use",onChange:e=>setUse(e.currentTarget.value),data:["","temp","old","usual","official","nickname","anonymous","maiden"],error:getErrorsForInput(outcome,errorPath+".use")}),jsx77(TextInput13,{disabled:props.disabled||prefixProps?.readonly,placeholder:"Prefix",name:props.name+"-prefix",defaultValue:value?.prefix?.join(" "),onChange:e=>setPrefix(e.currentTarget.value),error:getErrorsForInput(outcome,errorPath+".prefix")}),jsx77(TextInput13,{disabled:props.disabled||givenProps?.readonly,placeholder:"Given",name:props.name+"-given",defaultValue:value?.given?.join(" "),onChange:e=>setGiven(e.currentTarget.value),error:getErrorsForInput(outcome,errorPath+".given")}),jsx77(TextInput13,{disabled:props.disabled||familyProps?.readonly,name:props.name+"-family",placeholder:"Family",defaultValue:value?.family,onChange:e=>setFamily(e.currentTarget.value),error:getErrorsForInput(outcome,errorPath+".family")}),jsx77(TextInput13,{disabled:props.disabled||suffixProps?.readonly,placeholder:"Suffix",name:props.name+"-suffix",defaultValue:value?.suffix?.join(" "),onChange:e=>setSuffix(e.currentTarget.value),error:getErrorsForInput(outcome,errorPath+".suffix")})]})}import{Group as Group18,TextInput as TextInput14}from"@mantine/core";import{useContext as useContext12,useMemo as useMemo11,useState as useState39}from"react";import{jsx as jsx78,jsxs as jsxs43}from"react/jsx-runtime";function IdentifierInput(props){let[value,setValue]=useState39(props.defaultValue),{elementsByPath,getExtendedProps}=useContext12(ElementsContext),[systemElement,valueElement]=useMemo11(()=>["system","value"].map(field=>elementsByPath[props.path+"."+field]),[elementsByPath,props.path]),[systemProps,valueProps]=useMemo11(()=>["system","value"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}let errorPath=props.valuePath??props.path;return jsxs43(Group18,{gap:"xs",grow:!0,wrap:"nowrap",align:"flex-start",children:[jsx78(TextInput14,{disabled:props.disabled||systemProps?.readonly,placeholder:"System",required:(systemElement?.min??0)>0,defaultValue:value?.system,onChange:e=>setValueWrapper({...value,system:e.currentTarget.value}),error:getErrorsForInput(props.outcome,errorPath+".system")}),jsx78(TextInput14,{disabled:props.disabled||valueProps?.readonly,placeholder:"Value",required:(valueElement?.min??0)>0,defaultValue:value?.value,onChange:e=>setValueWrapper({...value,value:e.currentTarget.value}),error:getErrorsForInput(props.outcome,errorPath+".value")})]})}import{NativeSelect as NativeSelect5,TextInput as TextInput15}from"@mantine/core";import{useCallback as useCallback7,useContext as useContext13,useMemo as useMemo12,useState as useState40}from"react";import{jsx as jsx79}from"react/jsx-runtime";var data=["USD","EUR","CAD","GBP","AUD"];function MoneyInput(props){let{onChange}=props,[value,setValue]=useState40(props.defaultValue),{getExtendedProps}=useContext13(ElementsContext),[currencyProps,valueProps]=useMemo12(()=>["currency","value"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]),setValueWrapper=useCallback7(newValue=>{setValue(newValue),onChange&&onChange(newValue)},[onChange]),handleCurrencyChange=useCallback7(e=>{setValueWrapper({...value,currency:e.currentTarget.value})},[value,setValueWrapper]),handleValueChange=useCallback7(e=>{setValueWrapper({...value,value:e.currentTarget.valueAsNumber})},[value,setValueWrapper]),select=jsx79(NativeSelect5,{disabled:props.disabled||currencyProps?.readonly,defaultValue:value?.currency,data,styles:{input:{fontWeight:500,borderTopLeftRadius:0,borderBottomLeftRadius:0,width:92}},onChange:handleCurrencyChange});return jsx79(TextInput15,{disabled:props.disabled||valueProps?.readonly,type:"number",name:props.name,label:props.label,placeholder:props.placeholder??"Value",defaultValue:value?.value?.toString()??"USD",leftSection:jsx79(IconCurrencyDollar,{size:14}),rightSection:select,rightSectionWidth:92,onChange:handleValueChange})}import{Group as Group19}from"@mantine/core";import{useContext as useContext14,useMemo as useMemo13,useState as useState41}from"react";import{jsx as jsx80,jsxs as jsxs44}from"react/jsx-runtime";function PeriodInput(props){let[value,setValue]=useState41(props.defaultValue),{getExtendedProps}=useContext14(ElementsContext),[startProps,endProps]=useMemo13(()=>["start","end"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}return jsxs44(Group19,{gap:"xs",grow:!0,wrap:"nowrap",children:[jsx80(DateTimeInput,{disabled:props.disabled||startProps?.readonly,name:props.name+".start",placeholder:"Start",defaultValue:value?.start,onChange:newValue=>setValueWrapper({...value,start:newValue})}),jsx80(DateTimeInput,{disabled:props.disabled||endProps?.readonly,name:props.name+".end",placeholder:"End",defaultValue:value?.end,onChange:newValue=>setValueWrapper({...value,end:newValue})})]})}import{Group as Group20,NativeSelect as NativeSelect6,TextInput as TextInput16}from"@mantine/core";import{useContext as useContext15,useMemo as useMemo14,useState as useState42}from"react";import{jsx as jsx81,jsxs as jsxs45}from"react/jsx-runtime";function QuantityInput(props){let[value,setValue]=useState42(props.defaultValue),{getExtendedProps}=useContext15(ElementsContext),[comparatorProps,valueProps,unitProps]=useMemo14(()=>["comparator","value","unit"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}return jsxs45(Group20,{gap:"xs",grow:!0,wrap:"nowrap",children:[jsx81(NativeSelect6,{disabled:props.disabled||comparatorProps?.readonly,style:{width:80},"data-testid":props.name+"-comparator",defaultValue:value?.comparator,data:["","<","<=",">=",">"],onChange:e=>setValueWrapper({...value,comparator:e.currentTarget.value})}),jsx81(TextInput16,{disabled:props.disabled||valueProps?.readonly,id:props.name,name:props.name,required:props.required,"data-autofocus":props.autoFocus,"data-testid":props.name+"-value",type:"number",placeholder:"Value",defaultValue:value?.value,autoFocus:props.autoFocus,step:"any",onWheel:e=>{props.disableWheel&&e.currentTarget.blur()},onChange:e=>{setValueWrapper({...value,value:tryParseNumber(e.currentTarget.value)})}}),jsx81(TextInput16,{disabled:props.disabled||unitProps?.readonly,placeholder:"Unit","data-testid":props.name+"-unit",defaultValue:value?.unit,onChange:e=>setValueWrapper({...value,unit:e.currentTarget.value})})]})}function tryParseNumber(str){if(str)return Number.parseFloat(str)}import{Group as Group21}from"@mantine/core";import{useContext as useContext16,useMemo as useMemo15,useState as useState43}from"react";import{jsx as jsx82,jsxs as jsxs46}from"react/jsx-runtime";function RangeInput(props){let[value,setValue]=useState43(props.defaultValue),{getExtendedProps}=useContext16(ElementsContext),[lowProps,highProps]=useMemo15(()=>["low","high"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}return jsxs46(Group21,{gap:"xs",grow:!0,wrap:"nowrap",children:[jsx82(QuantityInput,{path:props.path+".low",disabled:props.disabled||lowProps?.readonly,name:props.name+"-low",defaultValue:value?.low,onChange:v=>setValueWrapper({...value,low:v})}),jsx82(QuantityInput,{path:props.path+".high",disabled:props.disabled||highProps?.readonly,name:props.name+"-high",defaultValue:value?.high,onChange:v=>setValueWrapper({...value,high:v})})]})}import{Group as Group22}from"@mantine/core";import{useContext as useContext17,useMemo as useMemo16,useState as useState44}from"react";import{jsx as jsx83,jsxs as jsxs47}from"react/jsx-runtime";function RatioInput(props){let[value,setValue]=useState44(props.defaultValue),{getExtendedProps}=useContext17(ElementsContext),[numeratorProps,denominatorProps]=useMemo16(()=>["numerator","denominator"].map(field=>getExtendedProps(props.path+"."+field)),[getExtendedProps,props.path]);function setValueWrapper(newValue){setValue(newValue),props.onChange&&props.onChange(newValue)}return jsxs47(Group22,{gap:"xs",grow:!0,wrap:"nowrap",children:[jsx83(QuantityInput,{path:props.path+".numerator",disabled:props.disabled||numeratorProps?.readonly,name:props.name+"-numerator",defaultValue:value?.numerator,onChange:v=>setValueWrapper({...value,numerator:v})}),jsx83(QuantityInput,{path:props.path+".denominator",disabled:props.disabled||denominatorProps?.readonly,name:props.name+"-denominator",defaultValue:value?.denominator,onChange:v=>setValueWrapper({...value,denominator:v})})]})}import{Group as Group24,NativeSelect as NativeSelect7}from"@mantine/core";import{LRUCache,ReadablePromise,createReference as createReference2,isEmpty as isEmpty4,isPopulated as isPopulated8,tryGetProfile as tryGetProfile3}from"@medplum/core";import{useMedplum as useMedplum23}from"@medplum/react-hooks";import{useCallback as useCallback10,useEffect as useEffect13,useMemo as useMemo17,useRef as useRef8,useState as useState46}from"react";import{useCallback as useCallback9}from"react";import{Group as Group23,Text as Text18}from"@mantine/core";import{getDisplayString as getDisplayString3,getReferenceString as getReferenceString3,isReference as isReference2,isResource as isResource2}from"@medplum/core";import{useMedplum as useMedplum22}from"@medplum/react-hooks";import{forwardRef as forwardRef4,useCallback as useCallback8,useEffect as useEffect12,useRef as useRef7,useState as useState45}from"react";import{jsx as jsx84,jsxs as jsxs48}from"react/jsx-runtime";var SEARCH_CODES={Device:"device-name",Observation:"code",Subscription:"criteria",User:"email:contains"},NAME_RESOURCE_TYPES=["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"];function toOption3(resource){return{value:getReferenceString3(resource)??"",label:getDisplayString3(resource),resource}}function getSearchParamForResourceType(resourceType){return SEARCH_CODES[resourceType]??(NAME_RESOURCE_TYPES.includes(resourceType)?"name":"_id")}var DefaultResourceItemComponent=forwardRef4(({label,resource,active:_active,...others},ref)=>jsx84("div",{ref,...others,children:jsxs48(Group23,{wrap:"nowrap",children:[jsx84(ResourceAvatar,{value:resource}),jsxs48("div",{children:[jsx84(Text18,{children:label}),jsx84(Text18,{size:"xs",c:"dimmed",children:resource.birthDate||resource.id})]})]})}));DefaultResourceItemComponent.displayName="DefaultResourceItemComponent";function MultiResourceInput(props){let medplum=useMedplum22(),{resourceType,searchCriteria}=props,ItemComponent3=props.itemComponent??DefaultResourceItemComponent,onChange=props.onChange,initialDefaultValue=useRef7(props.defaultValue),[defaultResources,setDefaultResources]=useState45(!props.defaultValue||props.defaultValue.length===0?[]:void 0);useEffect12(()=>{let cancelled=!1,items=initialDefaultValue.current;return items&&items.length>0&&Promise.allSettled(items.map(item=>{if(isResource2(item))return Promise.resolve(item);if(isReference2(item)){let ref=item;return medplum.readReference(ref)}return Promise.reject(new Error("Not a resolvable item"))})).then(settled=>{cancelled||setDefaultResources(settled.filter(r2=>r2.status==="fulfilled").map(r2=>r2.value))}).catch(()=>{}),()=>{cancelled=!0}},[medplum]);let loadValues=useCallback8(async(input,signal)=>{let searchCode=getSearchParamForResourceType(resourceType),searchParams=new URLSearchParams({[searchCode]:input??"",_count:"10",...searchCriteria});return await medplum.searchResources(resourceType,searchParams,{signal})},[medplum,resourceType,searchCriteria]),handleChange=useCallback8(newResources=>{onChange&&onChange(newResources)},[onChange]);return defaultResources===void 0?null:jsx84(AsyncAutocomplete,{disabled:props.disabled,name:props.name,label:props.label,error:props.error,required:props.required,itemComponent:ItemComponent3,defaultValue:defaultResources,placeholder:props.placeholder,maxValues:props.maxValues,toOption:toOption3,loadOptions:loadValues,onChange:handleChange,clearable:!0})}import{jsx as jsx85}from"react/jsx-runtime";function ResourceInput(props){let onChange=props.onChange,handleChange=useCallback9(newResources=>{onChange&&onChange(newResources[0])},[onChange]);return jsx85(MultiResourceInput,{resourceType:props.resourceType,name:props.name,defaultValue:props.defaultValue?[props.defaultValue]:void 0,searchCriteria:props.searchCriteria,placeholder:props.placeholder,required:props.required,itemComponent:props.itemComponent,onChange:handleChange,disabled:props.disabled,label:props.label,error:props.error,maxValues:1})}import{Fragment as Fragment30,jsx as jsx86,jsxs as jsxs49}from"react/jsx-runtime";function ReferenceInput(props){let{onChange}=props,medplum=useMedplum23(),[value,setValue]=useState46(props.defaultValue),[targetTypes,setTargetTypes]=useState46(()=>createTargetTypes(props.targetTypes)),[targetType,setTargetType]=useState46(()=>getInitialTargetType(props.defaultValue,targetTypes)),promiseCache=useRef8(new LRUCache),searchCriteria=useMemo17(()=>targetType?.type==="profile"?{...props.searchCriteria,_profile:targetType.value}:props.searchCriteria,[props.searchCriteria,targetType]);useEffect13(()=>{let anyToFetch=!1,newTargetTypePromises=targetTypes?.map(tt=>{if(!shouldFetchResourceType(tt))return Promise.resolve(tt);anyToFetch=!0;let cacheKey=tt.value,cached=promiseCache.current.get(cacheKey);if(cached)return cached;let promise=fetchResourceTypeOfProfile(medplum,tt.value).then(profile=>{let newTargetType={...tt};return profile?isPopulated8(profile.type)?(newTargetType.resourceType=profile.type,newTargetType.name=profile.name,newTargetType.title=profile.title):(console.error(`StructureDefinition.type missing for ${tt.value}`),newTargetType.error="StructureDefinition.type missing"):(console.error(`StructureDefinition not found for ${tt.value}`),newTargetType.error="StructureDefinition not found"),newTargetType}).catch(reason=>(console.error(reason),{...tt,error:reason})),readablePromise=new ReadablePromise(promise);return promiseCache.current.set(cacheKey,readablePromise),readablePromise});!newTargetTypePromises||!anyToFetch||Promise.all(newTargetTypePromises).then(newTargetTypes=>{if(setTargetTypes(newTargetTypes),!targetType)return;let index=newTargetTypes.findIndex(tt=>tt.value===targetType.value||tt.resourceType===targetType.resourceType);if(index===-1){console.debug(`defaultValue had unexpected resourceType: ${targetType.resourceType}`);return}setTargetType(newTargetTypes[index])}).catch(console.error)},[medplum,targetType,targetTypes]);let setValueHelper=useCallback10(item=>{let newValue=item?createReference2(item):void 0;setValue(newValue),onChange&&onChange(newValue)},[onChange]),typeSelectOptions=useMemo17(()=>targetTypes?targetTypes.map(tt=>({value:tt.value,label:tt.type==="profile"?tt.title??tt.name??tt.resourceType??tt.value:tt.value})):[],[targetTypes]);return jsxs49(Fragment30,{children:[props.name&&jsx86("input",{type:"hidden",name:props.name,value:value?.reference??""}),jsxs49(Group24,{gap:"xs",grow:!0,wrap:"nowrap",children:[targetTypes&&targetTypes.length>1&&jsx86(NativeSelect7,{name:props.name+"-resourceType",disabled:props.disabled,"data-autofocus":props.autoFocus,"data-testid":"reference-input-resource-type-select",defaultValue:targetType?.resourceType,autoFocus:props.autoFocus,onChange:e=>{let newValue=e.currentTarget.value,newTargetType=targetTypes.find(tt=>tt.value===newValue);setTargetType(newTargetType)},data:typeSelectOptions}),!targetTypes&&jsx86(ResourceTypeInput,{disabled:props.disabled,autoFocus:props.autoFocus,testId:"reference-input-resource-type-input",defaultValue:targetType?.resourceType,onChange:newResourceType=>{setTargetType(newResourceType?{type:"resourceType",value:newResourceType,resourceType:newResourceType}:void 0)},name:props.name+"-resourceType",placeholder:"Resource Type"}),jsx86(ResourceInput,{resourceType:targetType?.resourceType,name:props.name+"-id",required:props.required,placeholder:props.placeholder,defaultValue:value,searchCriteria,onChange:setValueHelper,disabled:props.disabled})]})]})}function createTargetTypes(resourceTypesAndProfileUrls){if(!resourceTypesAndProfileUrls||resourceTypesAndProfileUrls.length===0||resourceTypesAndProfileUrls.length===1&&resourceTypesAndProfileUrls[0]==="Resource")return;let results=[];for(let value of resourceTypesAndProfileUrls)value.includes("/")?results.push({type:"profile",value}):results.push({type:"resourceType",value,resourceType:value});return results}function getInitialTargetType(defaultValue2,targetTypes){let defaultValueResourceType=defaultValue2?.reference?.split("/")[0];if(defaultValueResourceType){let targetType=targetTypes?.find(tt=>tt.resourceType===defaultValueResourceType);return targetType||{type:"resourceType",value:defaultValueResourceType,resourceType:defaultValueResourceType}}if(targetTypes&&targetTypes.length>0)return targetTypes[0]}async function fetchResourceTypeOfProfile(medplum,profileUrl){let profile=tryGetProfile3(profileUrl);if(profile)return{type:profile.type,name:profile.name,title:profile.title};let query=`{
104
104
  StructureDefinitionList(url: "${profileUrl}", _sort: "_lastUpdated", _count: 1) {
105
105
  type,
106
106
  name,