import React from 'react'; import { DownloadIcon } from '../ui/icons'; import { formatFileSize } from '../utils/format'; const PreviewWorkspace = ({ document, previewEntry, resolveApiPath, onClose, onRegenerateThumbnails, }) => { if (!document) { return null; } const title = document.title || document.original_name || 'Document'; const mime = previewEntry?.contentType || document.content_type || 'application/pdf'; const downloadHref = document.current_version?.download_path ? resolveApiPath(document.current_version.download_path) : null; const sizeBytes = Number(document.current_version?.size_bytes) || 0; const sizeLabel = sizeBytes > 0 ? formatFileSize(sizeBytes) : null; const metadata = document.metadata && Object.keys(document.metadata).length > 0 ? document.metadata : null; return (

{title}

{document.content_type || mime} {sizeLabel ? ` · ${sizeLabel}` : ''}
{ if (!downloadHref) { event.preventDefault(); } }} > Download
{!previewEntry?.url ? (
Loading preview…
) : (