{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "image-viewer",
  "title": "Image Viewer",
  "author": "AlgorizeTech",
  "description": "Ask the user to pick one of 4 image viewer variants: https://avaraui.com/view/image-viewer. This item holds 4 of them as looks of one component (inner-zoom, side-zoom, slider, thumbnails). Skip the question if the user already named one. A collection of 4 responsive E-commerce Image Viewer components featuring inner lens magnifying zoom, HD side portal projection, carousel sliders, and interactive thumbnail strips.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "src/components/custom/blocks/ImageViewerBlock.tsx",
      "content": "\"use client\";\n\nimport React, { useState, useEffect, useCallback, useRef } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport {\n  Heart,\n  ChevronLeft,\n  ChevronRight,\n  X,\n  ZoomIn,\n  Maximize2,\n} from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport type ImageViewerVariant =\n  | \"inner-zoom\"\n  | \"side-zoom\"\n  | \"slider\"\n  | \"thumbnails\";\n\nexport type ThumbnailPosition = \"left\" | \"right\" | \"bottom\";\n\nexport interface ImageViewerColor {\n  name: string;\n  class: string;\n  bgClass?: string;\n  image?: string;\n}\n\nexport interface ImageViewerProps extends React.HTMLAttributes<HTMLDivElement> {\n  /** Display architecture variant */\n  variant?: ImageViewerVariant;\n  /** Position of thumbnails when variant=\"thumbnails\" ('left' | 'right' | 'bottom'). Default: 'left' */\n  thumbnailPosition?: ThumbnailPosition;\n  /** List of product/gallery image URLs */\n  images?: string[];\n  /** Optional colorways with matching images; colorway `i`'s `bgClass` tints the frame and thumbnail behind image `i` */\n  colors?: ImageViewerColor[];\n  /** Index of initial active image (0-indexed). Defaults to 3 for 'side-zoom', 1 for 'slider', 2 for 'thumbnails', 0 for others */\n  defaultImage?: number;\n  /** Badge text shown in the top corner (e.g. \"20% OFF\") */\n  badge?: string;\n  /** Whether to show the floating wishlist heart button */\n  showWishlist?: boolean;\n  /** Whether clicking the image opens fullscreen lightbox modal */\n  enableLightbox?: boolean;\n  /**\n   * Magnification of the side-zoom loupe over the image as shown in the frame.\n   * 3–10 is the usual e-commerce range; serve images large enough to stay\n   * sharp at it. Default: 3\n   */\n  zoomLevel?: number;\n  /** Custom callback when active image changes */\n  onImageChange?: (index: number) => void;\n  className?: string;\n}\n\nconst DEFAULT_IMAGES = [\n  \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516400/red-shows-1790516403807.jpg\",\n  \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516403/purple-shows-1790516403806.jpg\",\n  \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516399/blue-shows-1790516403806.jpg\",\n  \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto/v1790516397/baby-pink-shows-1790516403806.jpg\",\n];\n\nconst ITEM_BG_CLASSES = [\n  \"bg-primary/10 border-primary/20\",\n  \"bg-primary/10 border-primary/20\",\n  \"bg-primary/10 border-primary/20\",\n  \"bg-primary/10 border-primary/20\",\n];\n\nconst LOUPE_MAX = 360;\nconst SCREEN_MARGIN = 12;\n/** The frame shows its image at scale-140, so the loupe starts from that. */\nconst FRAME_SCALE = 1.4;\n\n/** Loupe edge in px: as large as LOUPE_MAX allows without crowding the screen. */\nfunction loupeSize() {\n  return Math.min(\n    LOUPE_MAX,\n    window.innerWidth - SCREEN_MARGIN * 2,\n    window.innerHeight * 0.5,\n  );\n}\n\n/**\n * Places the side-zoom loupe just above the pointer, clear of the reticle.\n * It flips below when there is no room above and is clamped to the viewport\n * on every edge, so it never leaves the screen at any size.\n */\nfunction placeLoupe(cx: number, cy: number, size: number, reticle: number) {\n  const vw = window.innerWidth;\n  const vh = window.innerHeight;\n  const gap = reticle / 2 + 12;\n  const clamp = (v: number, max: number) =>\n    Math.min(Math.max(v, SCREEN_MARGIN), max - SCREEN_MARGIN - size);\n\n  let top = cy - gap - size;\n  if (top < SCREEN_MARGIN) top = cy + gap;\n  return {\n    width: size,\n    height: size,\n    left: clamp(cx - size / 2, vw),\n    top: clamp(top, vh),\n  };\n}\n\n/**\n * Offset of the zoomed image inside the loupe so the point under the pointer\n * sits at its centre. `pct` is the pointer's position across the frame and\n * `full` the zoomed image's edge; clamped so the loupe never shows past the\n * image's edge.\n */\nfunction loupeOffset(pct: number, full: number, size: number) {\n  const along = 0.5 + (pct / 100 - 0.5) / FRAME_SCALE;\n  return Math.min(0, Math.max(size - full, size / 2 - along * full));\n}\n\nconst DEFAULT_COLORS: ImageViewerColor[] = [\n  { name: \"Crimson Red\", class: \"bg-[#BC2433]\", bgClass: ITEM_BG_CLASSES[0], image: DEFAULT_IMAGES[0] },\n  { name: \"Vibrant Purple\", class: \"bg-[#4A2C81]\", bgClass: ITEM_BG_CLASSES[1], image: DEFAULT_IMAGES[1] },\n  { name: \"Cobalt Blue\", class: \"bg-[#0A53B8]\", bgClass: ITEM_BG_CLASSES[2], image: DEFAULT_IMAGES[2] },\n  { name: \"Baby Pink\", class: \"bg-[#E4ADB2]\", bgClass: ITEM_BG_CLASSES[3], image: DEFAULT_IMAGES[3] },\n];\n\nexport function ImageViewer({\n  variant = \"inner-zoom\",\n  thumbnailPosition = \"left\",\n  images = DEFAULT_IMAGES,\n  colors = DEFAULT_COLORS,\n  defaultImage,\n  badge = \"20% OFF\",\n  showWishlist = true,\n  enableLightbox = true,\n  zoomLevel = 3,\n  onImageChange,\n  className,\n  ...props\n}: ImageViewerProps) {\n  const getVariantDefaultImage = (v: ImageViewerVariant) => {\n    if (v === \"side-zoom\") return 3;\n    if (v === \"slider\") return 1;\n    if (v === \"thumbnails\") return 2;\n    return 0;\n  };\n  const initialIndex =\n    defaultImage !== undefined ? defaultImage : getVariantDefaultImage(variant);\n  const [selectedImage, setSelectedImage] = useState(initialIndex);\n  const [liked, setLiked] = useState(false);\n  const [isModalOpen, setIsModalOpen] = useState(false);\n  // x/y: percent within the frame; cx/cy: pointer in viewport px and fw: frame\n  // width in px (side loupe).\n  const [zoomPos, setZoomPos] = useState<{\n    x: number;\n    y: number;\n    cx: number;\n    cy: number;\n    fw: number;\n    visible: boolean;\n  }>({ x: 0, y: 0, cx: 0, cy: 0, fw: 0, visible: false });\n\n  const activeImage = images[selectedImage % images.length] || images[0];\n  // The tint behind image `idx`: its colourway's `bgClass` when one is given.\n  const tintFor = (idx: number) =>\n    colors[idx]?.bgClass ?? ITEM_BG_CLASSES[idx % ITEM_BG_CLASSES.length];\n\n  const handleSelectImage = useCallback(\n    (index: number) => {\n      setSelectedImage(index);\n      onImageChange?.(index);\n    },\n    [onImageChange]\n  );\n\n  const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {\n    const { left, top, width, height } = e.currentTarget.getBoundingClientRect();\n    const x = Math.max(0, Math.min(100, ((e.clientX - left) / width) * 100));\n    const y = Math.max(0, Math.min(100, ((e.clientY - top) / height) * 100));\n    setZoomPos({ x, y, cx: e.clientX, cy: e.clientY, fw: width, visible: true });\n  };\n\n  const handleMouseLeave = () => {\n    setZoomPos((prev) => ({ ...prev, visible: false }));\n  };\n\n  // Set while a finger is down on the frame (read by the scroll hide below).\n  const touchingRef = useRef(false);\n\n  const handleTouchMove = (e: React.TouchEvent<HTMLDivElement>) => {\n    if (!e.touches[0]) return;\n    const { left, top, width, height } = e.currentTarget.getBoundingClientRect();\n    const touch = e.touches[0];\n    touchingRef.current = true;\n    const x = Math.max(0, Math.min(100, ((touch.clientX - left) / width) * 100));\n    const y = Math.max(0, Math.min(100, ((touch.clientY - top) / height) * 100));\n    setZoomPos({ x, y, cx: touch.clientX, cy: touch.clientY, fw: width, visible: true });\n  };\n\n  // The loupe is fixed to the viewport, so a wheel scroll would strand it away\n  // from a still mouse; hide it until the next move instead. Touch is exempt:\n  // a drag scrolls the page too, but every touchmove re-places the loupe.\n  useEffect(() => {\n    if (variant !== \"side-zoom\" || !zoomPos.visible) return;\n    const hide = () => {\n      if (!touchingRef.current) setZoomPos((prev) => ({ ...prev, visible: false }));\n    };\n    window.addEventListener(\"scroll\", hide, { capture: true, passive: true });\n    window.addEventListener(\"resize\", hide);\n    return () => {\n      window.removeEventListener(\"scroll\", hide, { capture: true });\n      window.removeEventListener(\"resize\", hide);\n    };\n  }, [variant, zoomPos.visible]);\n\n  const handleTouchEnd = () => {\n    touchingRef.current = false;\n    setZoomPos((prev) => ({ ...prev, visible: false }));\n  };\n\n  const nextImage = useCallback(() => {\n    setSelectedImage((prev) => (prev === images.length - 1 ? 0 : prev + 1));\n  }, [images.length]);\n\n  const prevImage = useCallback(() => {\n    setSelectedImage((prev) => (prev === 0 ? images.length - 1 : prev - 1));\n  }, [images.length]);\n\n  // Keyboard controls for modal\n  useEffect(() => {\n    if (!isModalOpen) return;\n    const onKeyDown = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") setIsModalOpen(false);\n      if (e.key === \"ArrowRight\") nextImage();\n      if (e.key === \"ArrowLeft\") prevImage();\n    };\n    window.addEventListener(\"keydown\", onKeyDown);\n    return () => window.removeEventListener(\"keydown\", onKeyDown);\n  }, [isModalOpen, nextImage, prevImage]);\n\n  const isVerticalThumbnails = thumbnailPosition === \"left\" || thumbnailPosition === \"right\";\n  const containerRef = useRef<HTMLDivElement>(null);\n  const [thumbSize, setThumbSize] = useState<number | null>(null);\n\n  useEffect(() => {\n    if (!isVerticalThumbnails || !containerRef.current) return;\n    const el = containerRef.current;\n    const updateSize = () => {\n      const w = el.clientWidth;\n      if (w > 0 && images.length > 0) {\n        const colGap = window.innerWidth >= 640 ? 16 : 12;\n        const itemGap = window.innerWidth >= 640 ? 10 : 8;\n        const totalItemGaps = (images.length - 1) * itemGap;\n        const size = Math.max(30, Math.floor((w - colGap - totalItemGaps) / (images.length + 1)));\n        setThumbSize(size);\n      }\n    };\n    updateSize();\n    const observer = new ResizeObserver(updateSize);\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, [isVerticalThumbnails, images.length]);\n\n  const renderThumbnailList = () => {\n    const fallbackWidth = `calc((100% - 16px - ${Math.max(0, images.length - 1)} * 10px) / ${images.length + 1})`;\n\n    return (\n      <div\n        style={\n          isVerticalThumbnails\n            ? { width: thumbSize ? `${thumbSize}px` : fallbackWidth }\n            : undefined\n        }\n        className={cn(\n          isVerticalThumbnails\n            ? \"flex flex-col gap-2 sm:gap-2.5 shrink-0 overflow-hidden\"\n            : \"grid grid-cols-4 gap-2.5 sm:gap-3 w-full\"\n        )}\n      >\n        {images.map((img, idx) => (\n          <button\n            key={idx}\n            type=\"button\"\n            onClick={() => handleSelectImage(idx)}\n            style={\n              isVerticalThumbnails && thumbSize\n                ? { width: `${thumbSize}px`, height: `${thumbSize}px` }\n                : undefined\n            }\n            className={cn(\n              \"aspect-square w-full rounded-xl sm:rounded-2xl overflow-hidden border-2 transition-all p-0 flex items-center justify-center cursor-pointer shadow-sm shrink-0\",\n              tintFor(idx),\n              selectedImage === idx\n                ? \"border-primary ring-2 ring-primary/30 scale-105\"\n                : \"border-border opacity-70 hover:opacity-100 hover:border-primary/50\"\n            )}\n            aria-label={`Thumbnail image ${idx + 1}`}\n          >\n            <img src={img} alt=\"Thumbnail Preview\" className=\"w-full h-full object-cover scale-110 p-0\" />\n          </button>\n        ))}\n      </div>\n    );\n  };\n\n  // Side-zoom loupe geometry. `full` is the zoomed image's edge: the frame's\n  // on-screen image (frame width × scale-140) times zoomLevel. The reticle\n  // marks the frame area that fills the loupe at that magnification.\n  const loupe =\n    variant === \"side-zoom\" && zoomPos.visible\n      ? (() => {\n          const size = loupeSize();\n          return {\n            size,\n            full: zoomPos.fw * FRAME_SCALE * zoomLevel,\n            reticle: size / zoomLevel,\n          };\n        })()\n      : null;\n\n  return (\n    <div\n      ref={containerRef}\n      className={cn(\n        \"relative w-full max-w-2xl select-none mx-auto\",\n        className\n      )}\n      {...props}\n    >\n      {/* ------------------------------------------------------------- */}\n      {/* 1. INNER ZOOM VIEWER                                          */}\n      {/* ------------------------------------------------------------- */}\n      {variant === \"inner-zoom\" && (\n        <div className=\"space-y-4\">\n          <div\n            onMouseMove={handleMouseMove}\n            onMouseLeave={handleMouseLeave}\n            onTouchMove={handleTouchMove}\n            onTouchEnd={handleTouchEnd}\n            className={cn(\n              \"aspect-square w-full rounded-3xl sm:rounded-[2.5rem] overflow-hidden border border-border relative flex items-center justify-center p-0 transition-colors group cursor-crosshair\",\n              tintFor(selectedImage)\n            )}\n          >\n            <img\n              src={activeImage}\n              alt=\"Product View\"\n              className={cn(\n                \"w-full h-full object-cover scale-140 p-0 transition-all duration-300\",\n                zoomPos.visible && \"opacity-0\"\n              )}\n            />\n\n            {/* Inner Magnifier Zoom Canvas */}\n            {zoomPos.visible && (\n              <div\n                className=\"absolute inset-0 w-full h-full pointer-events-none transition-all duration-150 rounded-3xl sm:rounded-[2.5rem]\"\n                style={{\n                  backgroundImage: `url(${activeImage})`,\n                  backgroundPosition: `${zoomPos.x}% ${zoomPos.y}%`,\n                  backgroundSize: \"260%\",\n                  backgroundRepeat: \"no-repeat\",\n                }}\n              />\n            )}\n\n            {/* Top Badge */}\n            {badge && (\n              <span className=\"absolute top-4 left-4 sm:top-5 sm:left-5 px-3.5 py-1 rounded-full bg-primary text-primary-foreground text-xs font-extrabold uppercase tracking-wider z-20 pointer-events-auto shadow-md\">\n                {badge}\n              </span>\n            )}\n\n            {/* Wishlist Button */}\n            {showWishlist && (\n              <button\n                type=\"button\"\n                onClick={(e) => {\n                  e.stopPropagation();\n                  setLiked(!liked);\n                }}\n                className=\"absolute top-4 right-4 sm:top-5 sm:right-5 p-3 rounded-full bg-background/90 backdrop-blur-md border border-border text-foreground hover:text-rose-500 transition-all z-20 cursor-pointer shadow-sm hover:scale-110 active:scale-95\"\n                aria-label=\"Save to Wishlist\"\n              >\n                <Heart className={cn(\"size-4 sm:size-5 transition-colors\", liked && \"fill-rose-500 text-rose-500\")} />\n              </button>\n            )}\n          </div>\n        </div>\n      )}\n\n      {/* ------------------------------------------------------------- */}\n      {/* 2. SIDE LENS ZOOM VIEWER                                      */}\n      {/* ------------------------------------------------------------- */}\n      {variant === \"side-zoom\" && (\n        <div className=\"space-y-4\">\n          <div className=\"relative w-full\">\n            <div\n              onMouseMove={handleMouseMove}\n              onMouseLeave={handleMouseLeave}\n              onTouchMove={handleTouchMove}\n              onTouchEnd={handleTouchEnd}\n              className={cn(\n                \"aspect-square w-full rounded-3xl sm:rounded-[2.5rem] overflow-hidden border border-border relative flex items-center justify-center p-0 transition-colors group cursor-crosshair\",\n                tintFor(selectedImage)\n              )}\n            >\n              <img\n                src={activeImage}\n                alt=\"Product View\"\n                className=\"w-full h-full object-cover scale-140 p-0 transition-all duration-300\"\n              />\n\n              {/* Reticle Lens Box — sized to exactly the area the loupe shows */}\n              {loupe && (\n                <div\n                  className=\"absolute rounded-lg border-2 border-primary/70 bg-primary/10 pointer-events-none -translate-x-1/2 -translate-y-1/2 block shadow-lg\"\n                  style={{\n                    left: `${zoomPos.x}%`,\n                    top: `${zoomPos.y}%`,\n                    width: loupe.reticle,\n                    height: loupe.reticle,\n                  }}\n                />\n              )}\n\n              {/* Badge */}\n              {badge && (\n                <span className=\"absolute top-4 left-4 sm:top-5 sm:left-5 px-3.5 py-1 rounded-full bg-primary text-primary-foreground text-xs font-extrabold uppercase tracking-wider z-20 pointer-events-auto shadow-md\">\n                  {badge}\n                </span>\n              )}\n\n              {/* Wishlist */}\n              {showWishlist && (\n                <button\n                  type=\"button\"\n                  onClick={(e) => {\n                    e.stopPropagation();\n                    setLiked(!liked);\n                  }}\n                  className=\"absolute top-4 right-4 sm:top-5 sm:right-5 p-3 rounded-full bg-background/90 backdrop-blur-md border border-border text-foreground hover:text-rose-500 transition-all z-20 cursor-pointer shadow-sm hover:scale-110 active:scale-95\"\n                  aria-label=\"Save to Wishlist\"\n                >\n                  <Heart className={cn(\"size-4 sm:size-5 transition-colors\", liked && \"fill-rose-500 text-rose-500\")} />\n                </button>\n              )}\n            </div>\n\n            {/* Floating Loupe — rendered into <body> with fixed positioning so\n                no clipping ancestor can crop it; placeLoupe keeps it above the\n                pointer and inside the viewport. */}\n            {loupe &&\n              createPortal(\n                <div\n                  className={cn(\n                    \"fixed rounded-2xl sm:rounded-[2rem] overflow-hidden border-2 border-border z-[100] pointer-events-none shadow-2xl animate-in fade-in zoom-in-95 duration-150 motion-reduce:animate-none\",\n                    tintFor(selectedImage)\n                  )}\n                  style={placeLoupe(zoomPos.cx, zoomPos.cy, loupe.size, loupe.reticle)}\n                >\n                  {/* A square object-cover <img> crops exactly like the frame,\n                      whatever the image's own aspect ratio. */}\n                  <img\n                    src={activeImage}\n                    alt=\"\"\n                    className=\"absolute max-w-none object-cover\"\n                    style={{\n                      width: loupe.full,\n                      height: loupe.full,\n                      left: loupeOffset(zoomPos.x, loupe.full, loupe.size),\n                      top: loupeOffset(zoomPos.y, loupe.full, loupe.size),\n                    }}\n                  />\n                  <div className=\"absolute bottom-3 left-3 px-2.5 py-1 rounded-full bg-background/90 backdrop-blur-md border border-border text-[10px] sm:text-xs font-bold text-foreground flex items-center gap-1.5 shadow-sm\">\n                    <Maximize2 className=\"size-3 sm:size-3.5 text-primary\" /> {zoomLevel}x Zoom\n                  </div>\n                </div>,\n                document.body\n              )}\n          </div>\n        </div>\n      )}\n\n      {/* ------------------------------------------------------------- */}\n      {/* 3. SLIDER / CAROUSEL VIEWER                                   */}\n      {/* ------------------------------------------------------------- */}\n      {variant === \"slider\" && (\n        <div className=\"space-y-4\">\n          <div\n            onClick={() => enableLightbox && setIsModalOpen(true)}\n            className={cn(\n              \"aspect-square w-full rounded-3xl sm:rounded-[2.5rem] overflow-hidden border border-border relative flex items-center justify-center p-0 transition-colors group\",\n              enableLightbox ? \"cursor-pointer\" : \"cursor-default\",\n              tintFor(selectedImage)\n            )}\n          >\n            <img\n              src={activeImage}\n              alt=\"Slider Product View\"\n              className=\"peer w-full h-full object-cover scale-140 p-0 transition-all duration-300 group-hover:scale-105\"\n            />\n\n            {/* Click to Expand Overlay */}\n            {enableLightbox && (\n              <div className=\"absolute inset-0 bg-black/20 opacity-0 peer-hover:opacity-100 transition-opacity flex items-center justify-center pointer-events-none z-10\">\n                <span className=\"px-4 py-2 rounded-full bg-black/70 text-white backdrop-blur-md text-xs font-semibold flex items-center gap-2 shadow-lg\">\n                  <ZoomIn className=\"size-4\" /> Click to Expand\n                </span>\n              </div>\n            )}\n\n            {/* Badge */}\n            {badge && (\n              <span className=\"absolute top-4 left-4 sm:top-5 sm:left-5 px-3.5 py-1 rounded-full bg-primary text-primary-foreground text-xs font-extrabold uppercase tracking-wider z-20 pointer-events-auto shadow-md\">\n                {badge}\n              </span>\n            )}\n\n            {/* Wishlist Button */}\n            {showWishlist && (\n              <button\n                type=\"button\"\n                onClick={(e) => {\n                  e.stopPropagation();\n                  setLiked(!liked);\n                }}\n                className=\"absolute top-4 right-4 sm:top-5 sm:right-5 p-3 rounded-full bg-background/90 backdrop-blur-md border border-border text-foreground hover:text-rose-500 transition-all z-20 cursor-pointer shadow-sm hover:scale-110 active:scale-95\"\n                aria-label=\"Save to Wishlist\"\n              >\n                <Heart className={cn(\"size-4 sm:size-5 transition-colors\", liked && \"fill-rose-500 text-rose-500\")} />\n              </button>\n            )}\n\n            {/* Left Slider Arrow Button */}\n            <button\n              type=\"button\"\n              onClick={(e) => {\n                e.stopPropagation();\n                prevImage();\n              }}\n              className=\"absolute left-4 top-1/2 -translate-y-1/2 p-3 rounded-full bg-background/90 border border-border text-foreground hover:scale-110 transition-all backdrop-blur-md z-20 cursor-pointer shadow-md active:scale-95\"\n              aria-label=\"Previous Image\"\n            >\n              <ChevronLeft className=\"size-5\" />\n            </button>\n\n            {/* Right Slider Arrow Button */}\n            <button\n              type=\"button\"\n              onClick={(e) => {\n                e.stopPropagation();\n                nextImage();\n              }}\n              className=\"absolute right-4 top-1/2 -translate-y-1/2 p-3 rounded-full bg-background/90 border border-border text-foreground hover:scale-110 transition-all backdrop-blur-md z-20 cursor-pointer shadow-md active:scale-95\"\n              aria-label=\"Next Image\"\n            >\n              <ChevronRight className=\"size-5\" />\n            </button>\n\n            {/* Slide Indicator Dots */}\n            <div\n              className=\"absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-2 z-20 p-1.5 rounded-full bg-background/70 backdrop-blur-md border border-border/50\"\n              onClick={(e) => e.stopPropagation()}\n            >\n              {images.map((_, idx) => (\n                <button\n                  key={idx}\n                  type=\"button\"\n                  onClick={() => handleSelectImage(idx)}\n                  className={cn(\n                    \"h-2 rounded-full transition-all cursor-pointer\",\n                    selectedImage === idx ? \"w-6 bg-primary\" : \"w-2 bg-muted hover:bg-muted-foreground/50\"\n                  )}\n                  aria-label={`Go to slide ${idx + 1}`}\n                />\n              ))}\n            </div>\n          </div>\n        </div>\n      )}\n\n      {/* ------------------------------------------------------------- */}\n      {/* 4. THUMBNAIL STRIP GALLERY VIEWER                            */}\n      {/* ------------------------------------------------------------- */}\n      {variant === \"thumbnails\" && (\n        <div\n          className={cn(\n            thumbnailPosition === \"left\" && \"flex flex-row gap-3 sm:gap-4 items-start\",\n            thumbnailPosition === \"right\" && \"flex flex-row gap-3 sm:gap-4 items-start\",\n            thumbnailPosition === \"bottom\" && \"flex flex-col gap-3 sm:gap-4\"\n          )}\n        >\n          {thumbnailPosition === \"left\" && renderThumbnailList()}\n\n          <div\n            onClick={() => enableLightbox && setIsModalOpen(true)}\n            className={cn(\n              \"aspect-square rounded-2xl sm:rounded-3xl overflow-hidden border border-border relative flex items-center justify-center p-0 transition-colors group\",\n              thumbnailPosition === \"bottom\" ? \"w-full\" : \"flex-1 min-w-0\",\n              enableLightbox ? \"cursor-pointer\" : \"cursor-default\",\n              tintFor(selectedImage)\n            )}\n          >\n            <img\n              src={activeImage}\n              alt=\"Thumbnail Product View\"\n              className=\"peer w-full h-full object-cover scale-140 p-0 transition-all duration-300 group-hover:scale-105\"\n            />\n\n            {/* Click to Expand Overlay */}\n            {enableLightbox && (\n              <div className=\"absolute inset-0 bg-black/20 opacity-0 peer-hover:opacity-100 transition-opacity flex items-center justify-center pointer-events-none z-10\">\n                <span className=\"px-4 py-2 rounded-full bg-black/70 text-white backdrop-blur-md text-xs font-semibold flex items-center gap-2 shadow-lg\">\n                  <ZoomIn className=\"size-4\" /> Click to Expand\n                </span>\n              </div>\n            )}\n\n            {/* Badge */}\n            {badge && (\n              <span className=\"absolute top-4 left-4 px-3.5 py-1 rounded-full bg-primary text-primary-foreground text-xs font-extrabold uppercase tracking-wider z-20 pointer-events-auto shadow-md\">\n                {badge}\n              </span>\n            )}\n\n            {/* Wishlist Button */}\n            {showWishlist && (\n              <button\n                type=\"button\"\n                onClick={(e) => {\n                  e.stopPropagation();\n                  setLiked(!liked);\n                }}\n                className=\"absolute top-4 right-4 p-2.5 sm:p-3 rounded-full bg-background/90 backdrop-blur-md border border-border text-foreground hover:text-rose-500 transition-all z-20 cursor-pointer shadow-sm hover:scale-110 active:scale-95\"\n                aria-label=\"Save to Wishlist\"\n              >\n                <Heart className={cn(\"size-4 sm:size-5 transition-colors\", liked && \"fill-rose-500 text-rose-500\")} />\n              </button>\n            )}\n          </div>\n\n          {thumbnailPosition === \"right\" && renderThumbnailList()}\n          {thumbnailPosition === \"bottom\" && renderThumbnailList()}\n        </div>\n      )}\n\n      {/* ------------------------------------------------------------- */}\n      {/* FULLSCREEN LIGHTBOX MODAL DIALOG                              */}\n      {/* ------------------------------------------------------------- */}\n      {isModalOpen && (\n        <div\n          role=\"dialog\"\n          aria-modal=\"true\"\n          onClick={() => setIsModalOpen(false)}\n          className=\"fixed inset-0 z-50 bg-background/60 backdrop-blur-md flex items-center justify-center p-4 sm:p-8 animate-in fade-in duration-200\"\n        >\n          {/* Close Button */}\n          <button\n            type=\"button\"\n            onClick={() => setIsModalOpen(false)}\n            className=\"absolute top-4 right-4 sm:top-6 sm:right-6 p-3 rounded-full bg-card/80 hover:bg-card border border-border text-foreground transition-all backdrop-blur-md z-50 cursor-pointer hover:scale-110 active:scale-95\"\n            aria-label=\"Close Lightbox\"\n          >\n            <X className=\"size-6\" />\n          </button>\n\n          {/* Modal Container */}\n          <div\n            className=\"relative flex flex-col items-center justify-center p-0\"\n            onClick={(e) => e.stopPropagation()}\n          >\n            {/* Relative Image Wrapper */}\n            <div className=\"relative flex items-center justify-center\">\n              <div\n                className={cn(\n                  \"p-0 rounded-3xl border border-border max-w-[80vw] sm:max-w-2xl max-h-[65vh] aspect-square sm:aspect-[4/3] flex items-center justify-center transition-colors overflow-hidden\",\n                  tintFor(selectedImage)\n                )}\n              >\n                <img\n                  src={activeImage}\n                  alt=\"Full Screen Expanded View\"\n                  className=\"w-full h-full object-cover scale-140 transition-all duration-300\"\n                />\n              </div>\n\n              {/* Lightbox Slider Arrows */}\n              <button\n                type=\"button\"\n                onClick={prevImage}\n                className=\"absolute right-[calc(100%+10px)] sm:right-[calc(100%+25px)] top-1/2 -translate-y-1/2 p-2 sm:p-3 rounded-full bg-card/90 hover:bg-card border border-border text-foreground backdrop-blur-md transition-all z-50 cursor-pointer hover:scale-110 shrink-0\"\n                aria-label=\"Previous Image\"\n              >\n                <ChevronLeft className=\"size-5 sm:size-6\" />\n              </button>\n\n              <button\n                type=\"button\"\n                onClick={nextImage}\n                className=\"absolute left-[calc(100%+10px)] sm:left-[calc(100%+25px)] top-1/2 -translate-y-1/2 p-2 sm:p-3 rounded-full bg-card/90 hover:bg-card border border-border text-foreground backdrop-blur-md transition-all z-50 cursor-pointer hover:scale-110 shrink-0\"\n                aria-label=\"Next Image\"\n              >\n                <ChevronRight className=\"size-5 sm:size-6\" />\n              </button>\n\n              {/* Thumbnails inside Lightbox */}\n              <div className=\"absolute top-[calc(100%+15px)] sm:top-[calc(100%+30px)] left-1/2 -translate-x-1/2 flex gap-2 sm:gap-3 p-1.5 sm:p-2 rounded-2xl bg-card/90 backdrop-blur-md border border-border z-50\">\n                {images.map((img, idx) => (\n                  <button\n                    key={idx}\n                    type=\"button\"\n                    onClick={() => handleSelectImage(idx)}\n                    className={cn(\n                      \"size-9 sm:size-12 rounded-lg sm:rounded-xl overflow-hidden border-2 transition-all cursor-pointer p-0 flex items-center justify-center\",\n                      tintFor(idx),\n                      selectedImage === idx\n                        ? \"border-primary ring-2 ring-primary/40 scale-105\"\n                        : \"border-border opacity-70 hover:opacity-100\"\n                    )}\n                    aria-label={`View image ${idx + 1}`}\n                  >\n                    <img src={img} alt=\"Thumbnail Preview\" className=\"w-full h-full object-cover scale-120 p-0\" />\n                  </button>\n                ))}\n              </div>\n            </div>\n          </div>\n        </div>\n      )}\n    </div>\n  );\n}\n\nexport default ImageViewer;\n",
      "type": "registry:component",
      "target": "components/custom/blocks/ImageViewerBlock.tsx"
    }
  ],
  "docs": "Named export: ImageViewer. Accepts `variant` (4 variants: inner-zoom, side-zoom, slider, thumbnails), `thumbnailPosition` (left, right, bottom), `images`, `colors`, `badge`, `showWishlist`, `enableLightbox`, `className`. Includes built-in fullscreen lightbox modal with keyboard and arrow controls.",
  "categories": [
    "media",
    "commerce",
    "data-display"
  ],
  "type": "registry:component"
}
