/** * The creation fields of a crop camera (#611): the source camera, then the crop * drawn on its snapshot. The name is the wizard's own field above these. * A source is a `(addonId, stableId)` ref in the draft; the picker works in * device ids, so the fleet row translates between the two. */ import { DeviceType } from '@camstack/types' import { DeviceValuePicker } from '@camstack/ui-library' import { type ReactNode } from 'react' import { useTranslation } from 'react-i18next' import { useCandidateDevices } from '../device/customize/assignments/use-source-candidates' import { CropCameraEditor } from './CropCameraEditor' import { fleetRowOf } from './command-sources' import type { CropFormDraft } from './helper-form-model' const CAMERA_TYPES: readonly string[] = [DeviceType.Camera] export interface CropCameraFieldsProps { readonly draft: CropFormDraft readonly onChange: (draft: CropFormDraft) => void } export function CropCameraFields({ draft, onChange }: CropCameraFieldsProps): ReactNode { const { t } = useTranslation() const fleet = useCandidateDevices(true) const known = fleet.kind === 'known' ? fleet.value : null const row = draft.source === null || known === null ? null : fleetRowOf(known, draft.source) return (