import { fabric } from 'fabric'; export interface IBbox { bbox: [number, number][]; content: string; no: number; score: number; type: string; } export type ShapeType = 'rect'; export interface Shape { name: ShapeType; x: number; y: number; width: number; height: number; } export interface Region { id: string; name?: string; shape: Shape; content: Record; image?: string; textLayouts?: IBbox[]; ocrRegionShape?: Shape; } export interface VLMSample { id: string; fileUrl: string; labels?: Region[]; sampleFileName?: { originalName?: string; name?: string; }; versionId?: string; fileKey?: string; fileSize?: number; countSubsection?: number; statusSubsection?: number; recordId?: string; textContent?: { instruction: string; input: string; output: string; }; subsectionId?: string; createdAt?: string; updatedAt?: string; deletedAt?: string; creator?: string; metadata?: { height: string; width: string; charactersCount?: number; }; operator?: { creatorName?: string; creatorUserName?: string; updaterName?: string; updaterUserName?: string; }; updater?: string; confirmStatus?: number; } export type VLMLabelType = 'text'; export interface VLMLabel { id: string; name: string; type: VLMLabelType; } export interface VLMAnnotationProps { sample: VLMSample; labelDefinitions: VLMLabel[]; onChange?: (sample: VLMSample) => void; leftRatio?: number; resizable?: boolean; minLeftRatio?: number; maxLeftRatio?: number; minLeftWidth?: number; onRatioChange?: (ratio: number) => void; aiAssistantEnabled?: boolean; ocrRecognize: (image: string) => Promise; coordinateType?: 'top-left' | 'center'; hideRightSide?: boolean; readOnly?: boolean; } export interface VLMLabelMakerRef { performOCRById: (regionId: string) => void; ocrRecognizingRef: React.MutableRefObject>; ocrErrorRef: React.MutableRefObject>; } export interface VLMLabelMakerProps { sample?: VLMSample; labelDefinitions?: VLMLabel[]; /** * Optional external labels state to keep canvas regions in sync * (e.g. text edits from TextAnnotationPanel). */ labels?: Region[]; onImageLoad?: VoidFunction; onChange?: (labels: Region[]) => void; onRegionSelect?: (region: Region | null) => void; onRegionChange?: (region: Region | null, action: 'create' | 'update' | 'delete') => void; ocrRecognize?: (image: string) => Promise; activeLabelValue?: { label: VLMLabel; region: Region; } | null; onClearActive?: () => void; selectedRegion?: Region | null; onAppendTextToActive?: (text: string) => void; readOnly?: boolean; hideDrawRect?: boolean; } export interface ToolbarProps { drawingMode: boolean; draggable: boolean; scale: number; onToggleDrawingMode: () => void; onToggleDrag: () => void; onZoom: (delta: number) => void; onFitToScreen: () => void; readOnly?: boolean; hideDrawRect?: boolean; } export interface ZoomControlsProps { scale: number; onZoomIn: () => void; onZoomOut: () => void; } export interface TextAnnotationPanelProps { labelDefinitions?: VLMLabel[]; labels?: Region[]; selectedRegion?: Region | null; activeLabelValue?: { label: VLMLabel; region: Region; } | null; activeRegionNumber?: number | null; onChange?: (activeLabelValue: { label: VLMLabel; region: Region; } | null, index?: number) => void; onInputActive?: (activeLabelValue: { label: VLMLabel; region: Region; }, index?: number) => void; onBlur?: (activeLabelValue: { label: VLMLabel; region: Region; }, index?: number) => void; onDelete?: (regionId: string) => void; onRegionClick?: (region: Region) => void; onOCR?: (regionId: string) => void; ocrRecognizing?: Set; ocrErrors?: Set; readOnly?: boolean; } export interface RegionItemProps { name: string; labelDefinitions: VLMLabel[]; region: Region; isSelected?: boolean; isActive?: boolean; activeLabelId?: string; onChange?: (labelId: string, value: string) => void; onFocus?: (labelId: string, value: string) => void; onBlur?: (labelId: string, value: string) => void; onDelete?: (regionId: string) => void; onRegionClick?: (region: Region) => void; onOCR?: (regionId: string) => void; isOCRRecognizing?: boolean; hasOCRError?: boolean; readOnly?: boolean; } export interface ImageAnnotationDebuggerProps { sample?: VLMSample; activeRegionNumber: number | null; activeLabelValue?: { label: VLMLabel; region: Region; } | null; selectedRegion?: Region | null; } export interface ExtendedCanvas extends fabric.Canvas { uniScaleKey?: string; uniformScaling?: boolean; } export interface ExtendedRect extends fabric.Rect { uniformScaling?: boolean; }