"use client"; import { useTranslation } from "react-i18next"; import { GeneratedOutputFileActions, supportsGeneratedOutputActions, } from "@/components/chat/GeneratedOutputFileActions"; import { ChatFileLink } from "@/components/common/ChatFileLink"; import type { MessageAttachment } from "@/features/chat/ChatStateAdapter"; import { docIconFor } from "@/lib/doc-attachments"; import { imageSrcForAttachment } from "./attachment-media"; /** Format a byte count for a file card subtitle (e.g. "14 KB"). */ function formatFileSize(bytes?: number): string { if (!bytes || bytes <= 0) return ""; const units = ["B", "KB", "MB", "GB"]; let value = bytes; let unit = 0; while (value >= 1024 && unit < units.length - 1) { value /= 1024; unit += 1; } return `${unit === 0 ? value : value.toFixed(1)} ${units[unit]}`; } /** "DeepTutor_Introduction.pdf" → "DeepTutor Introduction" — the card title * reads like a document name; the extension already shows in the subtitle. */ function humanizeFilename(filename: string): string { const stem = filename.replace(/\.[A-Za-z0-9]{1,8}$/, ""); return ( stem .replace(/[_-]+/g, " ") .replace(/\s{2,}/g, " ") .trim() || filename ); } export default function GeneratedFileCardList({ files, onOpen, }: { files: MessageAttachment[]; onOpen?: (attachment: MessageAttachment) => void; }) { const { t } = useTranslation(); return (