{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "carousel13",
  "title": "Carousel",
  "description": "Carousel built with shadcn/ui.",
  "dependencies": [
    "embla-carousel-autoplay@8"
  ],
  "registryDependencies": [
    "carousel"
  ],
  "files": [
    {
      "path": "contents/components/carousel/13/index.tsx",
      "content": "\"use client\";\n\nimport { useState, useEffect, useRef } from \"react\";\nimport Image from \"next/image\";\nimport Autoplay from \"embla-carousel-autoplay\";\nimport {\n  Carousel,\n  CarouselContent,\n  CarouselItem,\n  CarouselNext,\n  CarouselPrevious,\n  type CarouselApi\n} from \"@/components/ui/carousel\";\n\nconst images = [\n  \"https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800&h=600&fit=crop\",\n  \"https://images.unsplash.com/photo-1469474968028-56623f02e42e?w=800&h=600&fit=crop\",\n  \"https://images.unsplash.com/photo-1441974231531-c6227db76b6e?w=800&h=600&fit=crop\",\n  \"https://images.unsplash.com/photo-1470071459604-3b5ec3a7fe05?w=800&h=600&fit=crop\"\n];\n\nexport default function CarouselComponent() {\n  const [api, setApi] = useState<CarouselApi>();\n  const [progress, setProgress] = useState(0);\n  const autoplay = useRef(Autoplay({ delay: 4000, stopOnInteraction: false }));\n  const progressRef = useRef<HTMLDivElement>(null);\n\n  useEffect(() => {\n    if (!api) {\n      return;\n    }\n\n    const autoplayPlugin = api.plugins()?.autoplay;\n    if (!autoplayPlugin) {\n      return;\n    }\n\n    let interval: NodeJS.Timeout;\n\n    const updateProgress = () => {\n      const timeUntilNext = autoplayPlugin.timeUntilNext();\n      if (timeUntilNext !== null) {\n        const total = 4000;\n        const remaining = timeUntilNext;\n        const percentage = ((total - remaining) / total) * 100;\n        setProgress(percentage);\n      }\n    };\n\n    const startProgress = () => {\n      clearInterval(interval);\n      setProgress(0);\n      interval = setInterval(updateProgress, 50);\n    };\n\n    const handleSelect = () => {\n      autoplayPlugin.reset();\n      startProgress();\n    };\n\n    startProgress();\n\n    api.on(\"select\", handleSelect);\n\n    return () => {\n      clearInterval(interval);\n      api.off(\"select\", handleSelect);\n    };\n  }, [api]);\n\n  return (\n    <div className=\"w-full max-w-xs\">\n      <Carousel\n        setApi={setApi}\n        className=\"w-full\"\n        plugins={[autoplay.current]}\n        opts={{\n          loop: true\n        }}>\n        <CarouselContent>\n          {images.map((src, index) => (\n            <CarouselItem key={index}>\n              <figure>\n                <Image\n                  src={src}\n                  alt={`Image ${index + 1}`}\n                  width={800}\n                  height={600}\n                  className=\"aspect-4/3 rounded-lg object-cover\"\n                />\n              </figure>\n            </CarouselItem>\n          ))}\n        </CarouselContent>\n        <CarouselPrevious />\n        <CarouselNext />\n      </Carousel>\n      <div className=\"bg-muted mt-4 h-1 w-full overflow-hidden rounded-full\">\n        <div\n          ref={progressRef}\n          className=\"bg-primary h-full transition-all duration-75\"\n          style={{ width: `${progress}%` }}\n        />\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/carousel13.tsx"
    }
  ],
  "type": "registry:component"
}