"use client"; import { useEffect, useRef } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import type { SessionDocument } from "@/lib/documentReader"; import { cn } from "@/lib/utils"; type DocumentReaderPanelProps = { title?: string; document: SessionDocument | null; activeBlockIndex?: number; error?: string | null; helperText?: string; readOnly?: boolean; onPickFile?: (file: File | null) => void; onClear?: () => void; }; export function DocumentReaderPanel({ title = "Reading Document", document, activeBlockIndex = -1, error, helperText, readOnly = false, onPickFile, onClear, }: DocumentReaderPanelProps) { const blockRefs = useRef<(HTMLParagraphElement | null)[]>([]); useEffect(() => { if (activeBlockIndex < 0) return; blockRefs.current[activeBlockIndex]?.scrollIntoView({ block: "nearest", behavior: "smooth", }); }, [activeBlockIndex]); return (
{title}
{document ? `${document.name} ยท ${document.blocks.length} blocks` : "Upload a PDF or TXT to read while recording."}
{helperText}
} {error &&{error}
}{ blockRefs.current[block.index] = node; }} className={cn( "rounded-2xl px-3 py-2 text-sm leading-7 text-ink/80 transition", isActive ? "bg-amber-100 text-ink shadow-sm" : "bg-transparent" )} > {block.text}
); })}