{
  "$schema": "https://www.cooki-ui.design/schema/registry-item.json",
  "name": "3d-bend-carousel",
  "type": "registry:ui",
  "title": "3D Bend Carousel",
  "description": "Curved cylindrical card carousel with 3D perspective depth, momentum drag physics, auto-snap, and orientation control.",
  "category": "media",
  "dependencies": [
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "tags": [
    "3d",
    "carousel",
    "media",
    "gallery",
    "bend",
    "cylindrical",
    "drag",
    "momentum"
  ],
  "files": [
    {
      "path": "registry/media/3d-bend-carousel/3d-bend-carousel.tsx",
      "type": "registry:ui",
      "target": "components/ui/3d-bend-carousel.tsx",
      "content": "\"use client\";\n\nimport React, {\n  useRef,\n  useState,\n  useEffect,\n  useCallback,\n  useMemo,\n  forwardRef,\n  useImperativeHandle,\n} from \"react\";\nimport {\n  ChevronUp,\n  ChevronDown,\n  ChevronLeft,\n  ChevronRight,\n  Play,\n  Pause,\n  ExternalLink,\n} from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface BendCarouselItem {\n  id?: string | number;\n  image: string;\n  title?: string;\n  subtitle?: string;\n  badge?: string;\n  tag?: string;\n  description?: string;\n  link?: string;\n  onClick?: () => void;\n}\n\nexport interface ThreeDBendCarouselProps {\n  /** Array of items (objects or image URL strings) */\n  items?: (string | BendCarouselItem)[];\n  /** Compatibility alias for image URLs */\n  images?: string[];\n  /** Card width in pixels */\n  itemWidth?: number;\n  /** Aspect ratio (width / height) */\n  aspectRatio?: number;\n  /** Gap between items in pixels (can be negative for stacked/shingle effect) */\n  gap?: number;\n  /** 3D Perspective value in pixels */\n  perspective?: number;\n  /** Maximum bend rotation angle in degrees */\n  bendAngle?: number;\n  /** 3D depth displacement along Z-axis in pixels */\n  depth?: number;\n  /** Curvature direction: 'concave' (curves away into screen) or 'convex' (curves forward) */\n  curveDirection?: \"concave\" | \"convex\";\n  /** Bend orientation: 'vertical' or 'horizontal' */\n  orientation?: \"vertical\" | \"horizontal\";\n  /** Height of the carousel viewport */\n  height?: number | string;\n  /** Width of the carousel container */\n  width?: number | string;\n  /** Damping factor for smooth momentum lerp (0.04 to 0.2, lower is floatier, higher is snappier) */\n  damping?: number;\n  /** Friction applied to drag velocity on release */\n  momentumFactor?: number;\n  /** Auto-snap to nearest card when user stops dragging or scrolling */\n  snap?: boolean;\n  /** Seamless infinite looping */\n  loop?: boolean;\n  /** Whether items away from center fade to monochrome grayscale */\n  grayscaleInactive?: boolean;\n  /** Scale factor for the active center card */\n  activeScale?: number;\n  /** Minimum opacity for cards farthest from center */\n  minOpacity?: number;\n  /** Enable mouse & touch drag navigation */\n  enableDrag?: boolean;\n  /** Enable mouse wheel navigation */\n  enableWheel?: boolean;\n  /** Enable keyboard arrow navigation */\n  enableKeyboard?: boolean;\n  /** Auto play slides */\n  autoPlay?: boolean;\n  /** Auto play interval in milliseconds */\n  autoPlayInterval?: number;\n  /** Pause auto play when mouse hovers over carousel */\n  pauseOnHover?: boolean;\n  /** Show floating navigation controls (prev/next/autoplay) */\n  showControls?: boolean;\n  /** Show pagination indicators */\n  showIndicators?: boolean;\n  /** Show simulated dynamic 3D glass sheen reflection */\n  showGlare?: boolean;\n  /** Custom container className */\n  className?: string;\n  /** Custom card className */\n  cardClassName?: string;\n  /** Callback fired when the active center item changes */\n  onActiveChange?: (index: number) => void;\n  /** Callback fired when an item card is clicked */\n  onItemClick?: (item: BendCarouselItem, index: number) => void;\n  /** Custom render function for card inner content */\n  renderItem?: (\n    item: BendCarouselItem,\n    index: number,\n    isCenter: boolean\n  ) => React.ReactNode;\n}\n\nexport interface ThreeDBendCarouselRef {\n  next: () => void;\n  prev: () => void;\n  goTo: (index: number) => void;\n  togglePlay: () => void;\n  getActiveIndex: () => number;\n}\n\nconst DEFAULT_ITEMS: BendCarouselItem[] = [\n  {\n    id: 1,\n    image: \"https://images.unsplash.com/photo-1579783900882-c0d3dad7b119?q=80&w=1200&auto=format&fit=crop\",\n    title: \"Cosmic Solitude\",\n    subtitle: \"Abstract Surrealism\",\n    tag: \"Exhibition\",\n    badge: \"01\",\n    description: \"Deep celestial hues bending across spatial dimensions.\",\n  },\n  {\n    id: 2,\n    image: \"https://images.unsplash.com/photo-1507679799987-c73779587ccf?q=80&w=1200&auto=format&fit=crop\",\n    title: \"Monochrome Architecture\",\n    subtitle: \"Brutalist Forms\",\n    tag: \"Design\",\n    badge: \"02\",\n    description: \"Sleek geometric curves and high-contrast light gradients.\",\n  },\n  {\n    id: 3,\n    image: \"https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?q=80&w=1200&auto=format&fit=crop\",\n    title: \"Fluid Dynamics\",\n    subtitle: \"Generative Art\",\n    tag: \"3D Motion\",\n    badge: \"03\",\n    description: \"Iridescent liquid waveforms suspended in kinetic stasis.\",\n  },\n  {\n    id: 4,\n    image: \"https://images.unsplash.com/photo-1541701494587-cb58502866ab?q=80&w=1200&auto=format&fit=crop\",\n    title: \"Neon Horizon\",\n    subtitle: \"Cybernetic Chroma\",\n    tag: \"Visuals\",\n    badge: \"04\",\n    description: \"Luminescent ultraviolet streams cascading through mist.\",\n  },\n  {\n    id: 5,\n    image: \"https://images.unsplash.com/photo-1518770660439-4636190af475?q=80&w=1200&auto=format&fit=crop\",\n    title: \"Quantum Circuitry\",\n    subtitle: \"Silicon Symphony\",\n    tag: \"Hardware\",\n    badge: \"05\",\n    description: \"Microscopic pathways powering modern artificial intelligence.\",\n  },\n  {\n    id: 6,\n    image: \"https://images.unsplash.com/photo-1550684848-fac1c5b4e853?q=80&w=1200&auto=format&fit=crop\",\n    title: \"Prismatic Dispersion\",\n    subtitle: \"Refractive Glass\",\n    tag: \"Optical\",\n    badge: \"06\",\n    description: \"Polished crystal facets bending incoming white light beams.\",\n  },\n];\n\nexport const ThreeDBendCarousel = forwardRef<\n  ThreeDBendCarouselRef,\n  ThreeDBendCarouselProps\n>(\n  (\n    {\n      items: rawItems,\n      images,\n      itemWidth = 320,\n      aspectRatio = 0.8,\n      gap = -40,\n      perspective = 1000,\n      bendAngle = 45,\n      depth = 400,\n      curveDirection = \"concave\",\n      orientation = \"vertical\",\n      height = 620,\n      width = \"100%\",\n      damping = 0.085,\n      momentumFactor = 120,\n      snap = true,\n      loop = true,\n      grayscaleInactive = true,\n      activeScale = 1.04,\n      minOpacity = 0.22,\n      enableDrag = true,\n      enableWheel = true,\n      enableKeyboard = true,\n      autoPlay = false,\n      autoPlayInterval = 4000,\n      pauseOnHover = true,\n      showControls = true,\n      showIndicators = true,\n      showGlare = true,\n      className,\n      cardClassName,\n      onActiveChange,\n      onItemClick,\n      renderItem,\n    },\n    ref\n  ) => {\n    // Normalize items: support raw image strings or BendCarouselItem objects\n    const formattedItems: BendCarouselItem[] = useMemo(() => {\n      if (rawItems && rawItems.length > 0) {\n        return rawItems.map((item, idx) => {\n          if (typeof item === \"string\") {\n            return {\n              id: idx,\n              image: item,\n              title: `Item ${idx + 1}`,\n              badge: `${idx + 1 < 10 ? \"0\" : \"\"}${idx + 1}`,\n            };\n          }\n          return item;\n        });\n      }\n      if (images && images.length > 0) {\n        return images.map((src, idx) => ({\n          id: idx,\n          image: src,\n          title: `Slide ${idx + 1}`,\n          badge: `${idx + 1 < 10 ? \"0\" : \"\"}${idx + 1}`,\n        }));\n      }\n      return DEFAULT_ITEMS;\n    }, [rawItems, images]);\n\n    const count = formattedItems.length;\n    const itemHeight = itemWidth / aspectRatio;\n    const isVertical = orientation === \"vertical\";\n    const itemDimension = isVertical ? itemHeight : itemWidth;\n    const step = itemDimension + gap;\n\n    const containerRef = useRef<HTMLDivElement>(null);\n    const cardRefs = useRef<(HTMLDivElement | null)[]>([]);\n    const glareRefs = useRef<(HTMLDivElement | null)[]>([]);\n\n    // Continuous physics state stored in refs to prevent React re-renders on every frame (ensures silky 60-120fps)\n    const currentOffsetRef = useRef<number>(0);\n    const targetOffsetRef = useRef<number>(0);\n    const isDraggingRef = useRef<boolean>(false);\n    const isHoveringRef = useRef<boolean>(false);\n    const dragStartCoordRef = useRef<number>(0);\n    const dragStartOffsetRef = useRef<number>(0);\n    const lastCoordRef = useRef<number>(0);\n    const lastTimeRef = useRef<number>(0);\n    const velocityRef = useRef<number>(0);\n    const rafIdRef = useRef<number | null>(null);\n    const wheelDebounceTimerRef = useRef<NodeJS.Timeout | null>(null);\n\n    const [activeIndex, setActiveIndex] = useState<number>(0);\n    const [isPlaying, setIsPlaying] = useState<boolean>(autoPlay);\n    const activeIndexRef = useRef<number>(0);\n\n    // Keep activeIndexRef synced\n    useEffect(() => {\n      activeIndexRef.current = activeIndex;\n    }, [activeIndex]);\n\n    // Apply 3D matrix / translate3d transforms directly to DOM elements\n    const updateTransforms = useCallback(() => {\n      if (!containerRef.current || count === 0) return;\n\n      const containerDim = isVertical\n        ? containerRef.current.clientHeight || 600\n        : containerRef.current.clientWidth || 900;\n\n      const centerOffset = containerDim / 2;\n      const currentOffset = currentOffsetRef.current;\n      const totalSpan = count * step;\n\n      let nearestIndex = 0;\n      let minDistance = Infinity;\n\n      for (let i = 0; i < count; i++) {\n        const el = cardRefs.current[i];\n        if (!el) continue;\n\n        let deltaPixels = i * step - currentOffset;\n\n        if (loop && totalSpan > 0) {\n          // Circular wrapping calculation\n          deltaPixels =\n            ((deltaPixels % totalSpan) + totalSpan * 1.5) % totalSpan -\n            totalSpan / 2;\n        }\n\n        const distFromCenter = Math.abs(deltaPixels);\n        if (distFromCenter < minDistance) {\n          minDistance = distFromCenter;\n          nearestIndex = i;\n        }\n\n        // Normalized progress relative to viewport center (-1.5 to 1.5)\n        const viewThreshold = Math.max(1, centerOffset * 0.85);\n        const normalized = Math.max(\n          -1.6,\n          Math.min(1.6, deltaPixels / viewThreshold)\n        );\n        const absNorm = Math.abs(normalized);\n\n        // 3D Curves Calculation\n        const curveSign = curveDirection === \"concave\" ? 1 : -1;\n        const rotateAngle = -normalized * bendAngle * curveSign;\n        const translateZ = -absNorm * depth;\n\n        // Smooth Opacity & Scale\n        const opacity = Math.max(\n          minOpacity,\n          1 - Math.pow(absNorm * 0.75, 1.25)\n        );\n        const scale = Math.max(\n          0.85,\n          activeScale - absNorm * (activeScale - 0.92)\n        );\n\n        // Dynamic z-index so centered cards sit above bending ones\n        const zIndex = Math.round(100 - absNorm * 50);\n\n        // Dynamic Transform Origin for natural hinge bending\n        let transformOrigin = \"center center\";\n        if (isVertical) {\n          if (normalized > 0.04) transformOrigin = \"top center\";\n          else if (normalized < -0.04) transformOrigin = \"bottom center\";\n        } else {\n          if (normalized > 0.04) transformOrigin = \"left center\";\n          else if (normalized < -0.04) transformOrigin = \"right center\";\n        }\n\n        // Apply 3D Transform\n        if (isVertical) {\n          el.style.transform = `translate3d(-50%, calc(-50% + ${deltaPixels}px), ${translateZ}px) rotateX(${rotateAngle}deg) scale(${scale})`;\n        } else {\n          el.style.transform = `translate3d(calc(-50% + ${deltaPixels}px), -50%, ${translateZ}px) rotateY(${rotateAngle}deg) scale(${scale})`;\n        }\n\n        el.style.transformOrigin = transformOrigin;\n        el.style.opacity = `${opacity}`;\n        el.style.zIndex = `${zIndex}`;\n\n        // Grayscale & Brightness Depth Filter\n        if (grayscaleInactive) {\n          const grayPercent = Math.min(100, Math.pow(absNorm, 1.4) * 100);\n          const brightness = Math.max(0.6, 1 - absNorm * 0.35);\n          el.style.filter = `grayscale(${grayPercent.toFixed(1)}%) brightness(${brightness.toFixed(2)})`;\n        }\n\n        // 3D Glass Sheen Glare Effect\n        const glareEl = glareRefs.current[i];\n        if (glareEl && showGlare) {\n          const glareOpacity = Math.max(0, 0.45 - absNorm * 0.45);\n          const glareAngle = isVertical\n            ? 180 + rotateAngle * 2\n            : 90 + rotateAngle * 2;\n          glareEl.style.opacity = `${glareOpacity.toFixed(3)}`;\n          glareEl.style.background = `linear-gradient(${glareAngle}deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0.05) 45%, transparent 70%)`;\n        }\n      }\n\n      // Update active index state when the closest item changes\n      if (nearestIndex !== activeIndexRef.current) {\n        activeIndexRef.current = nearestIndex;\n        setActiveIndex(nearestIndex);\n        onActiveChange?.(nearestIndex);\n      }\n    }, [\n      count,\n      isVertical,\n      step,\n      loop,\n      curveDirection,\n      bendAngle,\n      depth,\n      minOpacity,\n      activeScale,\n      grayscaleInactive,\n      showGlare,\n      onActiveChange,\n    ]);\n\n    // High performance RAF render loop with lerp damping\n    const tick = useCallback(() => {\n      const diff = targetOffsetRef.current - currentOffsetRef.current;\n\n      if (Math.abs(diff) > 0.05 || isDraggingRef.current) {\n        currentOffsetRef.current += diff * damping;\n        updateTransforms();\n        rafIdRef.current = requestAnimationFrame(tick);\n      } else {\n        currentOffsetRef.current = targetOffsetRef.current;\n        updateTransforms();\n        rafIdRef.current = null;\n      }\n    }, [damping, updateTransforms]);\n\n    const wakeRaf = useCallback(() => {\n      if (!rafIdRef.current) {\n        rafIdRef.current = requestAnimationFrame(tick);\n      }\n    }, [tick]);\n\n    // Smooth navigation helpers\n    const snapToNearest = useCallback(() => {\n      if (!snap || count === 0) return;\n      const rawTarget = targetOffsetRef.current;\n      const targetCard = Math.round(rawTarget / step);\n      let newTarget = targetCard * step;\n\n      if (!loop) {\n        newTarget = Math.max(0, Math.min((count - 1) * step, newTarget));\n      }\n\n      targetOffsetRef.current = newTarget;\n      wakeRaf();\n    }, [snap, count, step, loop, wakeRaf]);\n\n    const goTo = useCallback(\n      (index: number) => {\n        if (count === 0) return;\n        const normalizedTarget = Math.max(0, Math.min(count - 1, index));\n\n        if (loop) {\n          // Find closest direction to target index\n          const currentVirtual = Math.round(currentOffsetRef.current / step);\n          const currentMod =\n            ((currentVirtual % count) + count) % count;\n          let diff = normalizedTarget - currentMod;\n\n          if (diff > count / 2) diff -= count;\n          if (diff < -count / 2) diff += count;\n\n          targetOffsetRef.current = (currentVirtual + diff) * step;\n        } else {\n          targetOffsetRef.current = normalizedTarget * step;\n        }\n        wakeRaf();\n      },\n      [count, loop, step, wakeRaf]\n    );\n\n    const next = useCallback(() => {\n      if (loop) {\n        targetOffsetRef.current += step;\n      } else {\n        const nextIdx = Math.min(count - 1, activeIndexRef.current + 1);\n        targetOffsetRef.current = nextIdx * step;\n      }\n      wakeRaf();\n    }, [loop, step, count, wakeRaf]);\n\n    const prev = useCallback(() => {\n      if (loop) {\n        targetOffsetRef.current -= step;\n      } else {\n        const prevIdx = Math.max(0, activeIndexRef.current - 1);\n        targetOffsetRef.current = prevIdx * step;\n      }\n      wakeRaf();\n    }, [loop, step, wakeRaf]);\n\n    // Expose imperative handle methods\n    useImperativeHandle(\n      ref,\n      () => ({\n        next,\n        prev,\n        goTo,\n        togglePlay: () => setIsPlaying((p) => !p),\n        getActiveIndex: () => activeIndexRef.current,\n      }),\n      [next, prev, goTo]\n    );\n\n    // Mouse & Touch Drag Interaction\n    const handleDragStart = (e: React.MouseEvent | React.TouchEvent) => {\n      if (!enableDrag) return;\n\n      isDraggingRef.current = true;\n      const clientCoord = \"touches\" in e\n        ? isVertical\n          ? e.touches[0].clientY\n          : e.touches[0].clientX\n        : isVertical\n        ? e.clientY\n        : e.clientX;\n\n      dragStartCoordRef.current = clientCoord;\n      dragStartOffsetRef.current = targetOffsetRef.current;\n      lastCoordRef.current = clientCoord;\n      lastTimeRef.current = performance.now();\n      velocityRef.current = 0;\n\n      wakeRaf();\n    };\n\n    useEffect(() => {\n      const handleDragMove = (e: MouseEvent | TouchEvent) => {\n        if (!isDraggingRef.current) return;\n\n        const clientCoord = \"touches\" in e\n          ? isVertical\n            ? e.touches[0].clientY\n            : e.touches[0].clientX\n          : isVertical\n          ? e.clientY\n          : e.clientX;\n\n        const delta = dragStartCoordRef.current - clientCoord;\n        let newTarget = dragStartOffsetRef.current + delta;\n\n        // Bounded dragging with rubber-band resistance if loop is false\n        if (!loop) {\n          const maxOffset = (count - 1) * step;\n          if (newTarget < 0) {\n            newTarget = newTarget * 0.35;\n          } else if (newTarget > maxOffset) {\n            newTarget = maxOffset + (newTarget - maxOffset) * 0.35;\n          }\n        }\n\n        targetOffsetRef.current = newTarget;\n\n        // Calculate drag velocity for smooth momentum release\n        const now = performance.now();\n        const dt = now - lastTimeRef.current;\n        if (dt > 8) {\n          const dCoord = lastCoordRef.current - clientCoord;\n          velocityRef.current = dCoord / dt;\n          lastCoordRef.current = clientCoord;\n          lastTimeRef.current = now;\n        }\n\n        wakeRaf();\n      };\n\n      const handleDragEnd = () => {\n        if (!isDraggingRef.current) return;\n        isDraggingRef.current = false;\n\n        // Apply momentum inertia flick\n        const momentum = velocityRef.current * momentumFactor;\n        targetOffsetRef.current += momentum;\n\n        snapToNearest();\n        wakeRaf();\n      };\n\n      window.addEventListener(\"mousemove\", handleDragMove, { passive: true });\n      window.addEventListener(\"mouseup\", handleDragEnd);\n      window.addEventListener(\"touchmove\", handleDragMove, { passive: true });\n      window.addEventListener(\"touchend\", handleDragEnd);\n\n      return () => {\n        window.removeEventListener(\"mousemove\", handleDragMove);\n        window.removeEventListener(\"mouseup\", handleDragEnd);\n        window.removeEventListener(\"touchmove\", handleDragMove);\n        window.removeEventListener(\"touchend\", handleDragEnd);\n      };\n    }, [\n      isVertical,\n      loop,\n      count,\n      step,\n      momentumFactor,\n      snapToNearest,\n      wakeRaf,\n    ]);\n\n    // Wheel Interaction\n    const handleWheel = useCallback(\n      (e: WheelEvent) => {\n        if (!enableWheel) return;\n        e.preventDefault();\n\n        const delta = Math.abs(e.deltaY) > Math.abs(e.deltaX) ? e.deltaY : e.deltaX;\n        const normalizedDelta = Math.sign(delta) * Math.min(Math.abs(delta), 120);\n\n        let newTarget = targetOffsetRef.current + normalizedDelta * 1.1;\n\n        if (!loop) {\n          const maxOffset = (count - 1) * step;\n          newTarget = Math.max(0, Math.min(maxOffset, newTarget));\n        }\n\n        targetOffsetRef.current = newTarget;\n        wakeRaf();\n\n        if (snap) {\n          if (wheelDebounceTimerRef.current) {\n            clearTimeout(wheelDebounceTimerRef.current);\n          }\n          wheelDebounceTimerRef.current = setTimeout(() => {\n            snapToNearest();\n          }, 180);\n        }\n      },\n      [enableWheel, loop, count, step, wakeRaf, snap, snapToNearest]\n    );\n\n    // Keyboard Arrow Controls\n    useEffect(() => {\n      if (!enableKeyboard) return;\n\n      const handleKeyDown = (e: KeyboardEvent) => {\n        if (!containerRef.current) return;\n        // Only react if active element is container or within container\n        const isFocused =\n          document.activeElement === containerRef.current ||\n          containerRef.current.contains(document.activeElement);\n\n        if (!isFocused && !isHoveringRef.current) return;\n\n        if (isVertical) {\n          if (e.key === \"ArrowUp\") {\n            e.preventDefault();\n            prev();\n          } else if (e.key === \"ArrowDown\") {\n            e.preventDefault();\n            next();\n          }\n        } else {\n          if (e.key === \"ArrowLeft\") {\n            e.preventDefault();\n            prev();\n          } else if (e.key === \"ArrowRight\") {\n            e.preventDefault();\n            next();\n          }\n        }\n      };\n\n      window.addEventListener(\"keydown\", handleKeyDown);\n      return () => window.removeEventListener(\"keydown\", handleKeyDown);\n    }, [enableKeyboard, isVertical, next, prev]);\n\n    // Attach wheel listener non-passively so we can prevent page scroll jitter\n    useEffect(() => {\n      const container = containerRef.current;\n      if (!container || !enableWheel) return;\n\n      container.addEventListener(\"wheel\", handleWheel, { passive: false });\n      return () => container.removeEventListener(\"wheel\", handleWheel);\n    }, [handleWheel, enableWheel]);\n\n    // Autoplay Timer\n    useEffect(() => {\n      if (!isPlaying) return;\n\n      const interval = setInterval(() => {\n        if (pauseOnHover && isHoveringRef.current) return;\n        if (isDraggingRef.current) return;\n        next();\n      }, autoPlayInterval);\n\n      return () => clearInterval(interval);\n    }, [isPlaying, pauseOnHover, autoPlayInterval, next]);\n\n    // Initial setup & resize observer\n    useEffect(() => {\n      updateTransforms();\n\n      const container = containerRef.current;\n      if (!container) return;\n\n      const observer = new ResizeObserver(() => {\n        updateTransforms();\n      });\n      observer.observe(container);\n\n      return () => {\n        observer.disconnect();\n        if (rafIdRef.current) cancelAnimationFrame(rafIdRef.current);\n      };\n    }, [updateTransforms]);\n\n    return (\n      <div\n        ref={containerRef}\n        tabIndex={0}\n        onMouseEnter={() => {\n          isHoveringRef.current = true;\n        }}\n        onMouseLeave={() => {\n          isHoveringRef.current = false;\n        }}\n        onMouseDown={handleDragStart}\n        onTouchStart={handleDragStart}\n        className={cn(\n          \"relative overflow-hidden select-none outline-none group\",\n          \"flex items-center justify-center\",\n          \"cursor-grab active:cursor-grabbing\",\n          className\n        )}\n        style={{\n          width,\n          height,\n          perspective: `${perspective}px`,\n          perspectiveOrigin: \"50% 50%\",\n        }}\n        aria-label=\"3D Bend Carousel\"\n        role=\"region\"\n      >\n        {/* 3D Curved Stage */}\n        <div\n          className=\"relative w-full h-full flex items-center justify-center pointer-events-none\"\n          style={{\n            transformStyle: \"preserve-3d\",\n          }}\n        >\n          {formattedItems.map((item, index) => {\n            const isCenter = activeIndex === index;\n\n            return (\n              <div\n                key={item.id ?? index}\n                ref={(el) => {\n                  cardRefs.current[index] = el;\n                }}\n                onClick={(e) => {\n                  e.stopPropagation();\n                  if (isCenter) {\n                    item.onClick?.();\n                    onItemClick?.(item, index);\n                  } else {\n                    goTo(index);\n                  }\n                }}\n                className={cn(\n                  \"absolute top-1/2 left-1/2 rounded-2xl overflow-hidden\",\n                  \"shadow-2xl shadow-black/25 dark:shadow-black/75\",\n                  \"border border-zinc-200/80 dark:border-zinc-800/80\",\n                  \"bg-zinc-100 dark:bg-zinc-900\",\n                  \"pointer-events-auto cursor-pointer\",\n                  \"transition-shadow duration-300\",\n                  isCenter && \"ring-1 ring-white/20 shadow-black/40 dark:shadow-black/90\",\n                  cardClassName\n                )}\n                style={{\n                  width: `${itemWidth}px`,\n                  height: `${itemHeight}px`,\n                  willChange: \"transform, opacity, filter\",\n                  backfaceVisibility: \"hidden\",\n                }}\n              >\n                {renderItem ? (\n                  renderItem(item, index, isCenter)\n                ) : (\n                  <div className=\"relative w-full h-full flex flex-col justify-end overflow-hidden group/card\">\n                    {/* Background Image */}\n                    <img\n                      src={item.image}\n                      alt={item.title || `Slide ${index + 1}`}\n                      className=\"absolute inset-0 w-full h-full object-cover pointer-events-none select-none\"\n                      loading=\"lazy\"\n                    />\n\n                    {/* Ambient vignette shadow gradient */}\n                    <div className=\"absolute inset-0 bg-gradient-to-t from-black/85 via-black/35 to-black/10 pointer-events-none\" />\n\n                    {/* Top Badge & Tag info */}\n                    <div className=\"absolute top-4 left-4 right-4 flex items-center justify-between z-10 pointer-events-none\">\n                      {item.badge && (\n                        <span className=\"px-2.5 py-1 text-xs font-semibold tracking-wider uppercase rounded-full backdrop-blur-md bg-white/20 dark:bg-black/40 text-white border border-white/25 shadow-sm\">\n                          {item.badge}\n                        </span>\n                      )}\n                      {item.tag && (\n                        <span className=\"px-2 py-0.5 text-[11px] font-medium tracking-wide rounded-md backdrop-blur-md bg-black/30 text-zinc-200 border border-white/10\">\n                          {item.tag}\n                        </span>\n                      )}\n                    </div>\n\n                    {/* Card Content Footer */}\n                    <div className=\"relative z-10 p-5 text-white\">\n                      {item.subtitle && (\n                        <p className=\"text-xs font-medium tracking-wider uppercase text-zinc-300/90 mb-1\">\n                          {item.subtitle}\n                        </p>\n                      )}\n                      {item.title && (\n                        <h3 className=\"text-lg font-bold tracking-tight text-white leading-snug line-clamp-1\">\n                          {item.title}\n                        </h3>\n                      )}\n                      {item.description && (\n                        <p className=\"text-xs text-zinc-300 mt-1 line-clamp-2 leading-relaxed opacity-90\">\n                          {item.description}\n                        </p>\n                      )}\n\n                      {/* External Link or Action Pill */}\n                      {item.link && (\n                        <div className=\"mt-3 flex items-center gap-1 text-xs font-medium text-white/90 group-hover/card:text-white transition-colors\">\n                          <span>Explore</span>\n                          <ExternalLink className=\"w-3.5 h-3.5 ml-0.5 transition-transform group-hover/card:translate-x-0.5\" />\n                        </div>\n                      )}\n                    </div>\n\n                    {/* 3D Glass Specular Sheen Layer */}\n                    {showGlare && (\n                      <div\n                        ref={(el) => {\n                          glareRefs.current[index] = el;\n                        }}\n                        className=\"absolute inset-0 pointer-events-none transition-opacity duration-150\"\n                        style={{\n                          mixBlendMode: \"overlay\",\n                        }}\n                      />\n                    )}\n                  </div>\n                )}\n              </div>\n            );\n          })}\n        </div>\n\n        {/* Floating Navigation Controls */}\n        {showControls && (\n          <div\n            className={cn(\n              \"absolute z-30 flex items-center gap-2\",\n              isVertical\n                ? \"right-4 top-1/2 -translate-y-1/2 flex-col\"\n                : \"bottom-6 left-1/2 -translate-x-1/2 flex-row\"\n            )}\n            onClick={(e) => e.stopPropagation()}\n          >\n            {/* Prev Button */}\n            <button\n              type=\"button\"\n              onClick={prev}\n              aria-label=\"Previous slide\"\n              className={cn(\n                \"p-2.5 rounded-full backdrop-blur-md transition-all duration-200\",\n                \"bg-white/80 dark:bg-zinc-900/80\",\n                \"border border-zinc-200/80 dark:border-zinc-800/80\",\n                \"text-zinc-800 dark:text-zinc-200\",\n                \"shadow-lg hover:scale-105 active:scale-95\",\n                \"hover:bg-white dark:hover:bg-zinc-800 hover:text-black dark:hover:text-white\"\n              )}\n            >\n              {isVertical ? (\n                <ChevronUp className=\"w-4 h-4\" />\n              ) : (\n                <ChevronLeft className=\"w-4 h-4\" />\n              )}\n            </button>\n\n            {/* Autoplay Play/Pause Toggle */}\n            {autoPlay && (\n              <button\n                type=\"button\"\n                onClick={() => setIsPlaying((p) => !p)}\n                aria-label={isPlaying ? \"Pause autoplay\" : \"Start autoplay\"}\n                className={cn(\n                  \"p-2.5 rounded-full backdrop-blur-md transition-all duration-200\",\n                  \"bg-white/80 dark:bg-zinc-900/80\",\n                  \"border border-zinc-200/80 dark:border-zinc-800/80\",\n                  \"text-zinc-800 dark:text-zinc-200\",\n                  \"shadow-lg hover:scale-105 active:scale-95\",\n                  isPlaying && \"text-emerald-500 dark:text-emerald-400\"\n                )}\n              >\n                {isPlaying ? (\n                  <Pause className=\"w-3.5 h-3.5\" />\n                ) : (\n                  <Play className=\"w-3.5 h-3.5 ml-0.5\" />\n                )}\n              </button>\n            )}\n\n            {/* Next Button */}\n            <button\n              type=\"button\"\n              onClick={next}\n              aria-label=\"Next slide\"\n              className={cn(\n                \"p-2.5 rounded-full backdrop-blur-md transition-all duration-200\",\n                \"bg-white/80 dark:bg-zinc-900/80\",\n                \"border border-zinc-200/80 dark:border-zinc-800/80\",\n                \"text-zinc-800 dark:text-zinc-200\",\n                \"shadow-lg hover:scale-105 active:scale-95\",\n                \"hover:bg-white dark:hover:bg-zinc-800 hover:text-black dark:hover:text-white\"\n              )}\n            >\n              {isVertical ? (\n                <ChevronDown className=\"w-4 h-4\" />\n              ) : (\n                <ChevronRight className=\"w-4 h-4\" />\n              )}\n            </button>\n          </div>\n        )}\n\n        {/* Minimalist Indicators (Dots & Counter) */}\n        {showIndicators && count > 1 && (\n          <div\n            className={cn(\n              \"absolute z-30 pointer-events-auto\",\n              isVertical\n                ? \"left-6 top-1/2 -translate-y-1/2 flex flex-col items-center gap-2\"\n                : \"bottom-6 left-6 flex items-center gap-2\"\n            )}\n            onClick={(e) => e.stopPropagation()}\n          >\n            <div className=\"flex items-center gap-1.5 px-3 py-1.5 rounded-full backdrop-blur-md bg-black/40 border border-white/10 text-white shadow-md\">\n              <span className=\"text-xs font-mono font-medium\">\n                {(activeIndex + 1).toString().padStart(2, \"0\")}\n              </span>\n              <span className=\"text-[10px] text-zinc-400\">/</span>\n              <span className=\"text-[10px] font-mono text-zinc-400\">\n                {count.toString().padStart(2, \"0\")}\n              </span>\n            </div>\n\n            {/* Pagination Dots */}\n            <div\n              className={cn(\n                \"flex items-center gap-1.5 p-1 rounded-full backdrop-blur-md bg-black/30 border border-white/10\",\n                isVertical && \"flex-col\"\n              )}\n            >\n              {formattedItems.map((_, i) => (\n                <button\n                  key={i}\n                  type=\"button\"\n                  onClick={() => goTo(i)}\n                  aria-label={`Go to slide ${i + 1}`}\n                  className={cn(\n                    \"rounded-full transition-all duration-300\",\n                    activeIndex === i\n                      ? \"bg-white w-2 h-4\"\n                      : \"bg-white/40 hover:bg-white/70 w-2 h-2\"\n                  )}\n                />\n              ))}\n            </div>\n          </div>\n        )}\n      </div>\n    );\n  }\n);\n\nThreeDBendCarousel.displayName = \"ThreeDBendCarousel\";\n\nexport default ThreeDBendCarousel;\n"
    }
  ]
}