{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "reveal1",
  "title": "Before/After Image Slider",
  "description": "Interactive image comparison component with a draggable divider supporting horizontal and vertical orientations. Perfect for showcasing transformations, photo editing results, or design improvements.",
  "dependencies": [
    "clsx",
    "tailwind-merge",
    "lucide-react"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/reveal1/reveal1.tsx",
      "content": "\"use client\";\n\nimport { GripHorizontal, GripVertical } from \"lucide-react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\ninterface Reveal1Props {\n  heading?: string;\n  description?: string;\n  beforeImage: {\n    src: string;\n    alt: string;\n  };\n  afterImage: {\n    src: string;\n    alt: string;\n  };\n  beforeLabel?: string;\n  afterLabel?: string;\n  orientation?: \"horizontal\" | \"vertical\";\n  initialPosition?: number;\n  showLabels?: boolean;\n  dividerWidth?: number;\n  className?: string;\n}\n\nexport const reveal1Demo: Reveal1Props = {\n  heading: \"See the Transformation\",\n  description:\n    \"Drag the slider to compare the before and after results. Experience the difference our solution makes.\",\n  beforeImage: {\n    src: \"https://images.unsplash.com/photo-1558370781-d6196949e317?q=80&w=2958&auto=format&fit=crop&sat=-100\",\n    alt: \"Before\",\n  },\n  afterImage: {\n    src: \"https://images.unsplash.com/photo-1558370781-d6196949e317?q=80&w=2958&auto=format&fit=crop\",\n    alt: \"After\",\n  },\n  beforeLabel: \"Before\",\n  afterLabel: \"After\",\n  showLabels: true,\n};\n\nexport function Reveal1({\n  heading,\n  description,\n  beforeImage,\n  afterImage,\n  beforeLabel = \"Before\",\n  afterLabel = \"After\",\n  orientation = \"horizontal\",\n  initialPosition = 50,\n  showLabels = true,\n  dividerWidth = 4,\n  className,\n}: Reveal1Props) {\n  const [position, setPosition] = useState(initialPosition);\n  const [isDragging, setIsDragging] = useState(false);\n  const containerRef = useRef<HTMLDivElement>(null);\n\n  const isHorizontal = orientation === \"horizontal\";\n\n  const handleMove = useCallback(\n    (clientX: number, clientY: number) => {\n      if (!containerRef.current) return;\n\n      const rect = containerRef.current.getBoundingClientRect();\n\n      if (isHorizontal) {\n        const x = clientX - rect.left;\n        const percentage = Math.max(0, Math.min(100, (x / rect.width) * 100));\n        setPosition(percentage);\n      } else {\n        const y = clientY - rect.top;\n        const percentage = Math.max(0, Math.min(100, (y / rect.height) * 100));\n        setPosition(percentage);\n      }\n    },\n    [isHorizontal]\n  );\n\n  const handleMouseDown = useCallback(\n    (e: React.MouseEvent) => {\n      e.preventDefault();\n      setIsDragging(true);\n      handleMove(e.clientX, e.clientY);\n    },\n    [handleMove]\n  );\n\n  const handleTouchStart = useCallback(\n    (e: React.TouchEvent) => {\n      setIsDragging(true);\n      const touch = e.touches[0];\n      if (touch) {\n        handleMove(touch.clientX, touch.clientY);\n      }\n    },\n    [handleMove]\n  );\n\n  useEffect(() => {\n    const handleMouseMove = (e: MouseEvent) => {\n      if (isDragging) {\n        handleMove(e.clientX, e.clientY);\n      }\n    };\n\n    const handleTouchMove = (e: TouchEvent) => {\n      if (isDragging) {\n        const touch = e.touches[0];\n        if (touch) {\n          handleMove(touch.clientX, touch.clientY);\n        }\n      }\n    };\n\n    const handleEnd = () => {\n      setIsDragging(false);\n    };\n\n    if (isDragging) {\n      document.addEventListener(\"mousemove\", handleMouseMove);\n      document.addEventListener(\"touchmove\", handleTouchMove);\n      document.addEventListener(\"mouseup\", handleEnd);\n      document.addEventListener(\"touchend\", handleEnd);\n    }\n\n    return () => {\n      document.removeEventListener(\"mousemove\", handleMouseMove);\n      document.removeEventListener(\"touchmove\", handleTouchMove);\n      document.removeEventListener(\"mouseup\", handleEnd);\n      document.removeEventListener(\"touchend\", handleEnd);\n    };\n  }, [isDragging, handleMove]);\n\n  return (\n    <section className={cn(\"py-16 md:py-24 w-full\", className)}>\n      <div className=\"mx-auto max-w-5xl px-4 md:px-6\">\n        <div className=\"flex flex-col items-center gap-8\">\n          {/* Header */}\n          {(heading || description) && (\n            <div className=\"flex flex-col items-center text-center gap-4\">\n              {heading && (\n                <h2 className=\"text-2xl sm:text-3xl font-semibold text-balance md:text-5xl\">\n                  {heading}\n                </h2>\n              )}\n              {description && (\n                <p className=\"max-w-2xl text-base sm:text-lg text-muted-foreground text-balance\">\n                  {description}\n                </p>\n              )}\n            </div>\n          )}\n\n          {/* Comparison Container */}\n          <div\n            ref={containerRef}\n            role=\"slider\"\n            aria-label=\"Before/After comparison slider\"\n            aria-valuemin={0}\n            aria-valuemax={100}\n            aria-valuenow={position}\n            tabIndex={0}\n            className={cn(\n              \"relative w-full rounded-lg overflow-hidden shadow-2xl border select-none\",\n              \"aspect-video\",\n              isHorizontal ? \"cursor-ew-resize\" : \"cursor-ns-resize\"\n            )}\n            onMouseDown={handleMouseDown}\n            onTouchStart={handleTouchStart}\n          >\n            {/* After Image (Bottom layer - full) */}\n            <div className=\"absolute inset-0\">\n              <img\n                className=\"absolute inset-0 size-full object-cover\"\n                src={afterImage.src}\n                alt={afterImage.alt}\n              />\n            </div>\n\n            {/* Before Image (Top layer - clipped) */}\n            <div\n              className=\"absolute inset-0\"\n              style={{\n                clipPath: isHorizontal\n                  ? `inset(0 ${100 - position}% 0 0)`\n                  : `inset(0 0 ${100 - position}% 0)`,\n              }}\n            >\n              <img\n                className=\"absolute inset-0 size-full object-cover\"\n                src={beforeImage.src}\n                alt={beforeImage.alt}\n              />\n            </div>\n\n            {/* Divider Line */}\n            <div\n              className={cn(\n                \"absolute bg-white shadow-lg z-10\",\n                isHorizontal ? \"top-0 bottom-0 -translate-x-1/2\" : \"left-0 right-0 -translate-y-1/2\"\n              )}\n              style={{\n                [isHorizontal ? \"left\" : \"top\"]: `${position}%`,\n                [isHorizontal ? \"width\" : \"height\"]: `${dividerWidth}px`,\n              }}\n            >\n              {/* Handle */}\n              <div\n                className={cn(\n                  \"absolute bg-primary text-background rounded-full shadow-xl\",\n                  \"flex items-center justify-center\",\n                  \"w-10 h-10 border-3 border-white\",\n                  \"left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2\",\n                  \"transition-transform\",\n                  isDragging && \"scale-110\"\n                )}\n              >\n                {isHorizontal ? (\n                  <GripVertical className=\"size-5 text-background\" />\n                ) : (\n                  <GripHorizontal className=\"size-5 text-background\" />\n                )}\n              </div>\n            </div>\n\n            {/* Labels */}\n            {showLabels && (\n              <>\n                <div\n                  className={cn(\n                    \"absolute z-20 px-3 py-1.5 rounded-full\",\n                    \"bg-black/70 text-white text-sm font-medium backdrop-blur-sm\",\n                    \"top-4 left-4\"\n                  )}\n                >\n                  {beforeLabel}\n                </div>\n                <div\n                  className={cn(\n                    \"absolute z-20 px-3 py-1.5 rounded-full\",\n                    \"bg-black/70 text-white text-sm font-medium backdrop-blur-sm\",\n                    isHorizontal ? \"top-4 right-4\" : \"bottom-4 left-4\"\n                  )}\n                >\n                  {afterLabel}\n                </div>\n              </>\n            )}\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/beste/block/reveal1.tsx"
    }
  ],
  "type": "registry:block"
}