{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "carousel-with-dots",
  "type": "registry:ui",
  "title": "Carousel with Dots",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "Horizontally snapping card carousel with swipe gesture physics, a pill-shaped morphing dot indicator, keyboard arrow support, and circular navigation buttons.",
  "dependencies": [
    "framer-motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/carousel-with-dots.tsx",
      "content": "\"use client\";\n\nimport React, { useState, useEffect, useCallback } from \"react\";\nimport { motion, useReducedMotion, type PanInfo } from \"framer-motion\";\nimport { ChevronLeft, ChevronRight, Sparkles, Cpu, Shield, Zap } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface CarouselSlide {\n  id: string;\n  eyebrow: string;\n  title: string;\n  description: string;\n  stat: string;\n}\n\nexport interface CarouselWithDotsProps {\n  /** Array of slide items */\n  slides?: CarouselSlide[];\n  /** Initial active slide index. Default: 0 */\n  defaultIndex?: number;\n  /** Enable automatic slide rotation. Default: false */\n  autoPlay?: boolean;\n  /** Auto-play interval in milliseconds. Default: 4500 */\n  interval?: number;\n  /** Callback fired when the active slide changes */\n  onSlideChange?: (index: number) => void;\n  className?: string;\n}\n\nconst DEFAULT_SLIDES: CarouselSlide[] = [\n  {\n    id: \"display\",\n    eyebrow: \"ProMotion 120Hz\",\n    title: \"Adaptive refresh rates that match your gesture velocity.\",\n    description:\n      \"Every swipe and drag calculates release velocity to settle naturally without abrupt stops.\",\n    stat: \"120 FPS\",\n  },\n  {\n    id: \"acoustics\",\n    eyebrow: \"Spatial Audio Engine\",\n    title: \"Studio-grade acoustic isolation in a minimal enclosure.\",\n    description:\n      \"Precision-milled internals reduce harmonic distortion across the entire frequency spectrum.\",\n    stat: \"48 kHz\",\n  },\n  {\n    id: \"battery\",\n    eyebrow: \"All-Day Efficiency\",\n    title: \"Up to 22 hours of continuous workflow on a single charge.\",\n    description:\n      \"Fast-charge architecture restores 50% capacity in just 25 minutes over USB-C.\",\n    stat: \"22 HRS\",\n  },\n  {\n    id: \"security\",\n    eyebrow: \"Hardware Enclave\",\n    title: \"End-to-end encryption verified at silicon startup.\",\n    description:\n      \"Dedicated cryptographic keys remain isolated from the main application processor.\",\n    stat: \"256-BIT\",\n  },\n];\n\nexport function CarouselWithDots({\n  slides = DEFAULT_SLIDES,\n  defaultIndex = 0,\n  autoPlay = false,\n  interval = 4500,\n  onSlideChange,\n  className,\n}: CarouselWithDotsProps) {\n  const shouldReduceMotion = useReducedMotion() ?? false;\n  const [currentIndex, setCurrentIndex] = useState(defaultIndex);\n\n  const total = slides.length;\n\n  const goTo = useCallback(\n    (index: number) => {\n      const next = (index + total) % total;\n      setCurrentIndex(next);\n      onSlideChange?.(next);\n    },\n    [total, onSlideChange]\n  );\n\n  useEffect(() => {\n    if (!autoPlay || total <= 1) return;\n    const timer = setInterval(() => {\n      goTo(currentIndex + 1);\n    }, interval);\n    return () => clearInterval(timer);\n  }, [autoPlay, interval, currentIndex, total, goTo]);\n\n  const handleDragEnd = (\n    _: MouseEvent | TouchEvent | PointerEvent,\n    info: PanInfo\n  ) => {\n    const swipeThreshold = 40;\n    if (info.offset.x < -swipeThreshold || info.velocity.x < -300) {\n      goTo(currentIndex + 1);\n    } else if (info.offset.x > swipeThreshold || info.velocity.x > 300) {\n      goTo(currentIndex - 1);\n    }\n  };\n\n  const icons = [\n    <Sparkles key=\"0\" className=\"h-4 w-4\" />,\n    <Zap key=\"1\" className=\"h-4 w-4\" />,\n    <Cpu key=\"2\" className=\"h-4 w-4\" />,\n    <Shield key=\"3\" className=\"h-4 w-4\" />,\n  ];\n\n  return (\n    <div\n      role=\"region\"\n      aria-roledescription=\"carousel\"\n      aria-label=\"Feature highlights carousel\"\n      onKeyDown={(e) => {\n        if (e.key === \"ArrowLeft\") {\n          e.preventDefault();\n          goTo(currentIndex - 1);\n        } else if (e.key === \"ArrowRight\") {\n          e.preventDefault();\n          goTo(currentIndex + 1);\n        }\n      }}\n      tabIndex={0}\n      className={cn(\n        \"w-full max-w-lg select-none focus-visible:outline-none\",\n        className\n      )}\n    >\n      {/* Viewport Track */}\n      <div className=\"overflow-hidden rounded-[28px] border border-neutral-200 bg-white shadow-sm dark:border-neutral-800 dark:bg-[#0A0A0A]\">\n        <motion.div\n          drag=\"x\"\n          dragConstraints={{ left: 0, right: 0 }}\n          dragElastic={0.2}\n          onDragEnd={handleDragEnd}\n          animate={{ x: `-${currentIndex * 100}%` }}\n          transition={\n            shouldReduceMotion\n              ? { duration: 0 }\n              : { type: \"spring\", stiffness: 320, damping: 32 }\n          }\n          className=\"flex cursor-grab active:cursor-grabbing\"\n        >\n          {slides.map((slide, idx) => (\n            <div\n              key={slide.id}\n              role=\"group\"\n              aria-roledescription=\"slide\"\n              aria-label={`${idx + 1} of ${total}`}\n              className=\"w-full shrink-0 p-6 sm:p-8\"\n            >\n              <div className=\"flex items-center justify-between\">\n                <span className=\"inline-flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-3 py-1 font-mono text-[11px] font-medium text-neutral-700 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-300\">\n                  {icons[idx % icons.length]}\n                  {slide.eyebrow}\n                </span>\n                <span className=\"font-mono text-xs font-bold tracking-tight text-neutral-400 dark:text-neutral-500\">\n                  {slide.stat}\n                </span>\n              </div>\n\n              <h3 className=\"mt-5 text-xl font-bold tracking-tight text-neutral-950 dark:text-white sm:text-2xl\">\n                {slide.title}\n              </h3>\n\n              <p className=\"mt-2.5 text-xs leading-relaxed text-neutral-600 dark:text-neutral-400 sm:text-sm\">\n                {slide.description}\n              </p>\n            </div>\n          ))}\n        </motion.div>\n      </div>\n\n      {/* Bottom Controls: Pill-Shaped Page Indicator + Circular Arrow Controls */}\n      <div className=\"mt-4 flex items-center justify-between px-1\">\n        {/* Pill-Shaped Page Indicator */}\n        <div\n          role=\"tablist\"\n          aria-label=\"Slide indicators\"\n          className=\"inline-flex items-center gap-2 rounded-full border border-neutral-200 bg-neutral-100/90 px-3.5 py-2 backdrop-blur-md dark:border-neutral-800 dark:bg-neutral-900/90\"\n        >\n          {slides.map((slide, idx) => {\n            const isActive = idx === currentIndex;\n            return (\n              <button\n                key={slide.id}\n                type=\"button\"\n                role=\"tab\"\n                aria-selected={isActive}\n                aria-label={`Go to slide ${idx + 1}: ${slide.eyebrow}`}\n                onClick={() => goTo(idx)}\n                className=\"relative flex h-2 items-center justify-center focus-visible:outline-none\"\n              >\n                <motion.span\n                  animate={{\n                    width: isActive ? 22 : 6,\n                    opacity: isActive ? 1 : 0.4,\n                  }}\n                  transition={{ type: \"spring\", stiffness: 400, damping: 28 }}\n                  className=\"h-1.5 rounded-full bg-neutral-900 dark:bg-white\"\n                />\n              </button>\n            );\n          })}\n        </div>\n\n        {/* Arrow Controls */}\n        <div className=\"flex items-center gap-2\">\n          <button\n            type=\"button\"\n            aria-label=\"Previous slide\"\n            onClick={() => goTo(currentIndex - 1)}\n            className=\"flex h-9 w-9 items-center justify-center rounded-full border border-neutral-200 bg-white text-neutral-700 shadow-2xs transition-all hover:border-neutral-900 hover:text-neutral-950 active:scale-95 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-300 dark:hover:border-white dark:hover:text-white\"\n          >\n            <ChevronLeft className=\"h-4 w-4\" />\n          </button>\n\n          <button\n            type=\"button\"\n            aria-label=\"Next slide\"\n            onClick={() => goTo(currentIndex + 1)}\n            className=\"flex h-9 w-9 items-center justify-center rounded-full border border-neutral-200 bg-white text-neutral-700 shadow-2xs transition-all hover:border-neutral-900 hover:text-neutral-950 active:scale-95 dark:border-neutral-800 dark:bg-neutral-900 dark:text-neutral-300 dark:hover:border-white dark:hover:text-white\"\n          >\n            <ChevronRight className=\"h-4 w-4\" />\n          </button>\n        </div>\n      </div>\n    </div>\n  );\n}\n\nexport default CarouselWithDots;\n",
      "type": "registry:ui",
      "target": "components/ui/carousel-with-dots.tsx"
    },
    {
      "path": "lib/utils.ts",
      "content": "import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport async function copyToClipboard(text: string): Promise<boolean> {\n  if (typeof window === \"undefined\") return false;\n\n  try {\n    if (navigator.clipboard && window.isSecureContext) {\n      await navigator.clipboard.writeText(text);\n      return true;\n    }\n\n    const textArea = document.createElement(\"textarea\");\n    textArea.value = text;\n    textArea.style.position = \"fixed\";\n    textArea.style.left = \"-999999px\";\n    textArea.style.top = \"-999999px\";\n    document.body.appendChild(textArea);\n    textArea.focus();\n    textArea.select();\n    const succeeded = document.execCommand(\"copy\");\n    textArea.remove();\n    return succeeded;\n  } catch {\n    return false;\n  }\n}\n",
      "type": "registry:lib",
      "target": "lib/utils.ts"
    }
  ]
}
