/* eslint-disable @next/next/no-img-element -- External card image URLs; next/image migration is out of scope. */ import { useCallback, useEffect, useRef } from 'react'; import { useFocusTrap } from '../../lib/use-focus-trap'; export default function ScannerDisambiguation({ disambiguation, submittingReview, onPick, onNotInCatalog, onCancel, }) { const sheetRef = useFocusTrap(Boolean(disambiguation)); const backdropRef = useRef(null); const scrollContainerRef = useRef(null); useEffect(() => { if (!disambiguation) return undefined; const backdrop = backdropRef.current; const sheet = sheetRef.current; if (!backdrop || !sheet) return undefined; requestAnimationFrame(() => { backdrop.dataset.visible = 'true'; sheet.dataset.visible = 'true'; }); const handler = (e) => { if (e.key === 'Escape') onCancel(); }; document.addEventListener('keydown', handler); return () => document.removeEventListener('keydown', handler); }, [disambiguation, onCancel, sheetRef]); const handleBackdropClick = useCallback( (e) => { if (e.target === e.currentTarget) onCancel(); }, [onCancel] ); if (!disambiguation) return null; return (
{/* Bottom sheet */}
{/* Drag handle */}

Which card is this?

{disambiguation.message || 'Multiple matches found. Select the correct printing.'}

{disambiguation.visionHint && ( Vision detected: {disambiguation.visionHint} )}
{/* Horizontal candidate scroll */}
{disambiguation.candidates.map((candidate) => ( ))}
{/* Action buttons */}
); }