,
};
return iconMap[ext] || ;
}
// Get file type and icon
function getFileType(filename: string): {
type: string;
icon: React.ReactNode;
color: string;
} {
const ext = filename.split(".").pop()?.toLowerCase() || "";
const imageExts = ["png", "jpg", "jpeg", "gif", "bmp", "svg", "webp"];
const videoExts = ["mp4", "avi", "mkv", "mov", "wmv", "flv", "webm"];
const audioExts = ["mp3", "wav", "flac", "ogg", "aac", "m4a"];
const textExts = ["txt", "readme"];
const codeExts = [
"js",
"ts",
"jsx",
"tsx",
"py",
"java",
"cpp",
"c",
"cs",
"php",
"rb",
"go",
"rs",
"html",
"css",
"scss",
"less",
"json",
"xml",
"yaml",
"yml",
"toml",
"ini",
"conf",
"sh",
"bash",
"zsh",
"sql",
"vue",
"svelte",
"md",
];
if (imageExts.includes(ext)) {
return {
type: "image",
icon: Loading file...
This file is {formatFileSize(file.size)} in size, which may cause performance issues when opened as text.
{isTooLarge ? (File is too large (> 10MB) and cannot be opened as text for security reasons.
Do you want to continue opening this file as text? This may slow down your browser.
)}This file type is not supported for preview. You can download it to view in an external application.
{onDownload && ( )}