import React, { useState, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { Eye, Zap, Brain, Settings, ExternalLink, FileText } from 'lucide-react'; import DocumentViewer from './DocumentViewer'; const PreviewPanel = ({ file, processingMode, onModeChange, onProcess, isProcessing, apiKey }) => { const [previewUrl, setPreviewUrl] = useState(null); const [fileInfo, setFileInfo] = useState(null); const [showDocumentViewer, setShowDocumentViewer] = useState(false); // OCR borders for future use // const [showOcrBorders, setShowOcrBorders] = useState(false); useEffect(() => { if (file) { const url = URL.createObjectURL(file); setPreviewUrl(url); setFileInfo({ name: file.name, size: (file.size / 1024 / 1024).toFixed(2), type: file.type, lastModified: new Date(file.lastModified).toLocaleString() }); return () => URL.revokeObjectURL(url); } }, [file]); const processingModes = [ { id: 'standard', name: 'Standard Mode', model: 'Gemini 2.5 Flash', icon: , description: 'Fast processing', features: ['Same features as Pro', 'Faster speed', 'Slightly less accuracy'], gradient: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)' }, { id: 'structured', name: 'Structured Mode', model: 'Gemini 2.5 Pro', icon: , description: 'Maximum accuracy', features: ['Best accuracy', 'Advanced formatting', 'Slower processing'], gradient: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)' } ]; return ( <> {showDocumentViewer && ( setShowDocumentViewer(false)} /> )}
{/* File Preview */}

File Preview

{previewUrl && ( {file.type === 'application/pdf' ? (

PDF Document

Ready for processing setShowDocumentViewer(true)} whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }} > Open Viewer
) : file.type === 'text/html' || file.name.toLowerCase().endsWith('.html') ? (

HTML Document

Ready for processing setShowDocumentViewer(true)} whileHover={{ scale: 1.05 }} whileTap={{ scale: 0.95 }} > Open Viewer
) : ( Preview )}
)} {fileInfo && (
Name: {fileInfo.name}
Size: {fileInfo.size} MB
Type: {fileInfo.type}
Modified: {fileInfo.lastModified}
)}
{/* Processing Options */}

Processing Options

{processingModes.map((mode, index) => ( onModeChange(mode.id)} whileHover={{ scale: 1.02, y: -2 }} whileTap={{ scale: 0.98 }} initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} transition={{ delay: index * 0.1 }} >
{mode.icon}

{mode.name}

{mode.model}

{mode.description}

{mode.features.map((feature, idx) => ( {feature} ))}
{processingMode === mode.id && ( )} ))}
{isProcessing ? ( Processing... ) : ( 🚀 Extract Text )} {!apiKey && ( Please enter your Google API Key to continue )}
); }; export default PreviewPanel;