'use client'; import { useEffect } from 'react'; import { ChevronLeft, ChevronRight, Download, X } from 'lucide-react'; import { Button } from '@/components/ui/button'; import type { ChatMessage } from '@/lib/api'; import { cn } from '@/lib/utils'; interface ChatImageLightboxProps { open: boolean; images: ChatMessage[]; index: number; mediaUrls: Record; onClose: () => void; onIndexChange: (index: number) => void; onDownload?: (message: ChatMessage) => void; } export function ChatImageLightbox({ open, images, index, mediaUrls, onClose, onIndexChange, onDownload }: ChatImageLightboxProps) { const current = images[index]; useEffect(() => { if (!open) return; function handleKeyDown(event: KeyboardEvent) { if (event.key === 'Escape') onClose(); if (event.key === 'ArrowLeft') onIndexChange(Math.max(0, index - 1)); if (event.key === 'ArrowRight') onIndexChange(Math.min(images.length - 1, index + 1)); } window.addEventListener('keydown', handleKeyDown); return () => window.removeEventListener('keydown', handleKeyDown); }, [open, index, images.length, onClose, onIndexChange]); if (!open || !current?.storageKey) return null; const media = mediaUrls[current.storageKey]; return (

{current.senderName}

{index + 1} из {images.length}

{onDownload ? ( ) : null}
{media?.blobUrl ? ( // eslint-disable-next-line @next/next/no-img-element ) : (
Загрузка изображения...
)}
{current.content ? (
{current.content}
) : null} {images.length > 1 ? (
{images.map((image, imageIndex) => { const thumb = image.storageKey ? mediaUrls[image.storageKey] : undefined; return ( ); })}
) : null}
); }