'use client' import Image from 'next/image' import { useState } from 'react' import { cn } from '@/lib/utils' interface OptimizedImageProps { src: string alt: string width: number height: number className?: string priority?: boolean fill?: boolean sizes?: string quality?: number placeholder?: 'blur' | 'empty' blurDataURL?: string } // Generate a simple blur placeholder const shimmer = (w: number, h: number) => ` ` const toBase64 = (str: string) => typeof window === 'undefined' ? Buffer.from(str).toString('base64') : window.btoa(str) export default function OptimizedImage({ src, alt, width, height, className, priority = false, fill = false, sizes, quality = 75, placeholder = 'blur', blurDataURL, ...props }: OptimizedImageProps) { const [imageError, setImageError] = useState(false) const [imageLoaded, setImageLoaded] = useState(false) // Default fallback image for products const fallbackSrc = '/logo.png' // Generate blur placeholder if not provided const defaultBlurDataURL = `data:image/svg+xml;base64,${toBase64(shimmer(width, height))}` const handleError = () => { setImageError(true) } const handleLoad = () => { setImageLoaded(true) } return (