import React from 'react'; import { Heart, Maximize, Share2, Grid } from 'lucide-react'; import { Button } from "@/components/ui/button"; import { isVideoType, detectMediaType, normalizeMediaType } from "@/lib/mediaRegistry"; import { getVideoUrlWithResolution } from "../utils"; import ResponsiveImage from "@/components/ResponsiveImage"; import { Loader2 } from 'lucide-react'; const VidstackPlayer = React.lazy(() => import('@/player/components/VidstackPlayerImpl').then(m => ({ default: m.VidstackPlayerImpl }))); import { PostRendererProps } from '../types'; export const EmbedRenderer: React.FC = (props) => { const { post, mediaItems, mediaItem, likesCount, isLiked, onExpand } = props; const [currentMediaId, setCurrentMediaId] = React.useState(mediaItem?.id || (mediaItems[0]?.id)); const currentItem = mediaItems.find(i => i.id === currentMediaId) || mediaItems[0]; if (!currentItem) return
No content
; const effectiveType = currentItem.type || detectMediaType(currentItem.image_url); const isVideo = isVideoType(normalizeMediaType(effectiveType)); const videoUrl = (isVideo && currentItem.image_url) ? getVideoUrlWithResolution(currentItem.image_url) : undefined; return (
{/* Main Media Area */}
{isVideo ? ( currentItem.type === 'tiktok' ? (
) : (
}>
) ) : ( onExpand(currentItem)} // Triggers open in new tab /> )} {/* Embed Overlay Brand/Link - visible on hover over media */}
{/* Filmstrip (only if multiple items) */} {mediaItems.length > 1 && (
{ if (el) { el.addEventListener('wheel', (e) => { if (e.deltaY !== 0) { e.preventDefault(); el.scrollLeft += e.deltaY; } }, { passive: false }); } }} className="h-20 bg-muted/30 border-t flex items-center p-2 gap-2 overflow-x-auto scrollbar-hide shrink-0" > {mediaItems.map((item) => (
setCurrentMediaId(item.id)} >
))}
)} {/* Footer / Meta */}

{post?.title || "Untitled"}

{currentItem.title && currentItem.title !== post?.title && (
{currentItem.title}
)} {(currentItem.description || post?.description) && (

{currentItem.description || post?.description}

)}
0 ? "currentColor" : "none"} /> {likesCount}
); };