'use client' import { useState } from 'react' const A4_WIDTH_MM = 210 const A4_HEIGHT_MM = 297 interface ImageCompareViewProps { originalUrl: string | null deskewedUrl: string | null showGrid: boolean showGridLeft?: boolean showBinarized: boolean binarizedUrl: string | null leftLabel?: string rightLabel?: string } function MmGridOverlay() { const lines: React.ReactNode[] = [] // Vertical lines every 10mm for (let mm = 0; mm <= A4_WIDTH_MM; mm += 10) { const x = (mm / A4_WIDTH_MM) * 100 const is50 = mm % 50 === 0 lines.push( ) // Label every 50mm if (is50 && mm > 0) { lines.push( {mm} ) } } // Horizontal lines every 10mm for (let mm = 0; mm <= A4_HEIGHT_MM; mm += 10) { const y = (mm / A4_HEIGHT_MM) * 100 const is50 = mm % 50 === 0 lines.push( ) if (is50 && mm > 0) { lines.push( {mm} ) } } return ( {lines} ) } export function ImageCompareView({ originalUrl, deskewedUrl, showGrid, showGridLeft, showBinarized, binarizedUrl, leftLabel, rightLabel, }: ImageCompareViewProps) { const [leftError, setLeftError] = useState(false) const [rightError, setRightError] = useState(false) const rightUrl = showBinarized && binarizedUrl ? binarizedUrl : deskewedUrl return (
{/* Left: Original */}

{leftLabel || 'Original (unbearbeitet)'}

{originalUrl && !leftError ? ( <> Original Scan setLeftError(true)} /> {showGridLeft && } ) : (
{leftError ? 'Fehler beim Laden' : 'Noch kein Bild'}
)}
{/* Right: Deskewed with Grid */}

{rightLabel || `${showBinarized ? 'Binarisiert' : 'Begradigt'}${showGrid ? ' + Raster (mm)' : ''}`}

{rightUrl && !rightError ? ( <> {rightLabel setRightError(true)} /> {showGrid && } ) : (
{rightError ? 'Fehler beim Laden' : `${rightLabel || 'Verarbeitung'} laeuft...`}
)}
) }