import { useState, useEffect } from 'react'; import { X, ArrowDownToLine, PanelLeftOpen, PanelLeftClose } from 'lucide-react'; import { Button, OGDialog, OGDialogContent, TooltipAnchor } from '~/components'; import { useLocalize } from '~/hooks'; export default function DialogImage({ isOpen, onOpenChange, src = '', downloadImage, args }) { const localize = useLocalize(); const [isPromptOpen, setIsPromptOpen] = useState(false); const [imageSize, setImageSize] = useState(null); const getImageSize = async (url: string) => { try { const response = await fetch(url, { method: 'HEAD' }); const contentLength = response.headers.get('Content-Length'); if (contentLength) { const bytes = parseInt(contentLength, 10); return formatFileSize(bytes); } const fullResponse = await fetch(url); const blob = await fullResponse.blob(); return formatFileSize(blob.size); } catch (error) { console.error('Error getting image size:', error); return null; } }; const formatFileSize = (bytes: number): string => { 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]; }; useEffect(() => { if (isOpen && src) { getImageSize(src).then(setImageSize); } }, [isOpen, src]); return (
onOpenChange(false)} variant="ghost" className="h-10 w-10 p-0 hover:bg-surface-hover" > } />
downloadImage()} variant="ghost" className="h-10 w-10 p-0"> } /> setIsPromptOpen(!isPromptOpen)} variant="ghost" className="h-10 w-10 p-0" > {isPromptOpen ? ( ) : ( )} } />
{/* Main content area with image */}
Image
{/* Side Panel */}

{localize('com_ui_image_details')}

{/* Prompt Section */}

{localize('com_ui_prompt')}

{args?.prompt || 'No prompt available'}

{/* Generation Settings */}

{localize('com_ui_generation_settings')}

{localize('com_ui_size')}: {args?.size || 'Unknown'}
{localize('com_ui_quality')}: {args?.quality || 'Standard'}
{localize('com_ui_file_size')}: {imageSize || 'Loading...'}
); }