import type { FlowPanelControl, FlowPanelMarker, } from './types' import { idFromName } from './builderIdUtils' export function normalizeFlowMarker( marker: Partial & { marker: string }, index: number ): FlowPanelMarker { return { id: marker.id ?? idFromName(marker.marker, `marker-${index + 1}`), marker: marker.marker, fluorophore: marker.fluorophore ?? 'unassigned', detector: marker.detector, clone: marker.clone, reagentId: marker.reagentId, purpose: marker.purpose ?? 'phenotype', compensationRequired: marker.compensationRequired ?? true, metadata: marker.metadata ?? {}, } } export function normalizeFlowControl( control: Partial & { name: string }, index: number ): FlowPanelControl { return { id: control.id ?? idFromName(control.name, `control-${index + 1}`), name: control.name, kind: control.kind ?? 'other', markerId: control.markerId, required: control.required ?? true, metadata: control.metadata ?? {}, } } export function defaultFlowControls(markers: FlowPanelMarker[]): FlowPanelControl[] { return [ { id: 'unstained', name: 'Unstained', kind: 'unstained', required: true, metadata: {}, }, ...markers .filter(marker => marker.compensationRequired) .map(marker => ({ id: `${marker.id}-single-stain`, name: `${marker.marker} single stain`, kind: 'single-stain' as const, markerId: marker.id, required: true, metadata: {}, })), ] }