import { FileText, FileImage, FileType2, Link2, FileSpreadsheet } from "lucide-react";
import type { InferredEvidenceKind } from "@/lib/evidenceFileKind";

const ICON_CLASS: Record<InferredEvidenceKind, string> = {
  pdf: "text-red-600",
  image: "text-emerald-600",
  docx: "text-blue-600",
  xlsx: "text-green-700",
  link: "text-sky-600",
  other: "text-muted-foreground",
};

interface EvidenceFileTypeIconProps {
  kind: InferredEvidenceKind;
  className?: string;
  title?: string;
}

/**
 * Small icon for PDF / image / Word / Excel / link / other, for tables and links.
 */
export function EvidenceFileTypeIcon({ kind, className = "h-4 w-4", title }: EvidenceFileTypeIconProps) {
  const color = ICON_CLASS[kind] ?? ICON_CLASS.other;
  const c = `${className} ${color} shrink-0`.trim();
  const icon =
    kind === "image" ? (
      <FileImage className={c} />
    ) : kind === "link" ? (
      <Link2 className={c} />
    ) : kind === "xlsx" ? (
      <FileSpreadsheet className={c} />
    ) : kind === "docx" ? (
      <FileType2 className={c} />
    ) : kind === "pdf" ? (
      <FileText className={c} />
    ) : (
      <FileType2 className={c} />
    );
  if (title) {
    return <span title={title}>{icon}</span>;
  }
  return icon;
}
