import { useEffect, useRef, useState, type CSSProperties } from 'react'; import { Heart, MessageCircle, Bookmark, Share2, Plus, Play, Pause, Volume2, VolumeX, Music2, Maximize, Check, MapPin } from 'lucide-react'; import { compact, type VideoItem } from '../lib/videos'; export type Reaction = { liked?: boolean; saved?: boolean; followed?: boolean }; type Props = { item: VideoItem; position: number; active: boolean; muted: boolean; playing: boolean; reaction: Reaction; commentCount: number; setPlaying: (value: boolean) => void; toggleMuted: () => void; onReact: (field: keyof Reaction, force?: boolean) => void; onComment: () => void; onShare: () => void; onTag: (tag: string) => void; }; export function VideoCard({ item, position, active, muted, playing, reaction, commentCount, setPlaying, toggleMuted, onReact, onComment, onShare, onTag }: Props) { const video = useRef(null); const card = useRef(null); const clickTimer = useRef | null>(null); const [progress, setProgress] = useState(0); const [duration, setDuration] = useState(8); const [failed, setFailed] = useState(false); const [hearts, setHearts] = useState<{ id: number; x: number; y: number }[]>([]); useEffect(() => { const element = video.current; if (!element) return; let cancelled = false; if (active && playing) element.play().catch(() => { if (!cancelled) setPlaying(false); }); else element.pause(); if (!active) { element.currentTime = 0; setProgress(0); } return () => { cancelled = true; }; }, [active, playing, setPlaying]); useEffect(() => () => { if (clickTimer.current) clearTimeout(clickTimer.current); }, []); const time = (seconds: number) => `00:${Math.floor(seconds).toString().padStart(2, '0')}`; return
; }