import React, { useState, useRef } from 'react'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { Upload, File, ImageIcon, Video, Music, FileText, Download, Play, Pause, Trash2, X } from 'lucide-react'; interface MediaFile { id: string; name: string; type: string; size: number; url: string; uploadedAt: Date; uploadedBy: string; } interface MediaPanelProps { isVisible: boolean; className?: string; } export const MediaPanel: React.FC = ({ isVisible, className = '' }) => { const [mediaFiles, setMediaFiles] = useState([ // Mock data for demonstration { id: '1', name: 'demo-video.mp4', type: 'video/mp4', size: 12456789, url: 'https://www.w3schools.com/html/mov_bbb.mp4', uploadedAt: new Date(Date.now() - 300000), uploadedBy: 'Alice' }, { id: '2', name: 'background-music.mp3', type: 'audio/mpeg', size: 3456789, url: 'https://www.soundjay.com/misc/sounds/bell-ringing-05.wav', uploadedAt: new Date(Date.now() - 600000), uploadedBy: 'Bob' }, { id: '3', name: 'screenshot.png', type: 'image/png', size: 234567, url: 'https://picsum.photos/800/600', uploadedAt: new Date(Date.now() - 900000), uploadedBy: 'You' } ]); const [playingAudio, setPlayingAudio] = useState(null); const [playingVideo, setPlayingVideo] = useState(null); const audioRefs = useRef<{ [key: string]: HTMLAudioElement }>({}); const videoRefs = useRef<{ [key: string]: HTMLVideoElement }>({}); const formatFileSize = (bytes: number) => { if (bytes === 0) return '0 Bytes'; const k = 1024; const sizes = ['Bytes', 'KB', 'MB', 'GB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; }; const formatTimeAgo = (date: Date) => { const timeDiff = Date.now() - date.getTime(); if (timeDiff < 60000) { return 'Just now'; } else if (timeDiff < 3600000) { const minutes = Math.floor(timeDiff / 60000); return `${minutes}m ago`; } else { const hours = Math.floor(timeDiff / 3600000); return `${hours}h ago`; } }; const getFileIcon = (type: string) => { if (type.startsWith('image/')) return ; if (type.startsWith('video/')) return