{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "lens-distortion-card",
  "title": "Lens Distortion Card",
  "description": "An image card with a magnifying lens that follows the cursor.",
  "dependencies": [
    "@paper-design/shaders-react"
  ],
  "files": [
    {
      "path": "registry/shaders/lens-distortion-card/lens-distortion-card.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { LensDistortion } from \"@paper-design/shaders-react\"\n\nimport { cn } from \"@/lib/utils\"\n\n// The photo is zoomed in slightly so the radial smear near the card's edges\n// still samples the image instead of running off it.\nconst ZOOM = 1.12\n\ntype LensDistortionCardProps = React.ComponentProps<\"div\"> & {\n  /** Any image URL. Remote images must be served with CORS headers. */\n  image?: string\n  alt?: string\n  eyebrow?: string\n  title?: string\n  /** How far the image smears away from the cursor, 0 to 1. */\n  strength?: number\n  /** Strength of the rainbow fringing in the smear, 0 to 1. */\n  dispersion?: number\n}\n\nfunction LensDistortionCard({\n  image = \"https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?w=1200&q=80&fm=jpg\",\n  alt = \"A desert road leading through red rocks towards a mountain\",\n  eyebrow = \"Field notes / 04\",\n  title = \"Valley of Fire\",\n  strength = 0.35,\n  dispersion = 0.5,\n  className,\n  onPointerMove,\n  onPointerLeave,\n  ...props\n}: LensDistortionCardProps) {\n  const [active, setActive] = React.useState(false)\n  // Cursor position relative to the card, from 0 to 1 on each axis. It keeps\n  // its last value after the cursor leaves so the effect fades out in place.\n  const [lens, setLens] = React.useState({ x: 0.5, y: 0.5 })\n\n  return (\n    <div\n      data-slot=\"lens-distortion-card\"\n      className={cn(\n        \"relative isolate aspect-4/5 w-full max-w-sm cursor-none overflow-hidden bg-neutral-900 text-white\",\n        className\n      )}\n      onPointerMove={(event) => {\n        const rect = event.currentTarget.getBoundingClientRect()\n        setActive(true)\n        setLens({\n          x: (event.clientX - rect.left) / rect.width,\n          y: (event.clientY - rect.top) / rect.height,\n        })\n        onPointerMove?.(event)\n      }}\n      onPointerLeave={(event) => {\n        setActive(false)\n        onPointerLeave?.(event)\n      }}\n      {...props}\n    >\n      {/* eslint-disable-next-line @next/next/no-img-element */}\n      <img\n        src={image}\n        alt={alt}\n        crossOrigin=\"anonymous\"\n        className=\"absolute inset-0 -z-10 size-full object-cover\"\n        style={{ scale: ZOOM }}\n      />\n      {/*\n        The shader always draws its lens at the center of its canvas. The canvas\n        is twice the card's size and follows the cursor, while imageX / imageY\n        pan the picture back so it stays aligned with the photo underneath.\n      */}\n      <div\n        aria-hidden\n        className={cn(\n          \"pointer-events-none absolute top-0 left-0 -z-10 h-[200%] w-[200%] transition-opacity duration-300\",\n          active ? \"opacity-100\" : \"opacity-0\"\n        )}\n        style={{ translate: `${(lens.x - 1) * 50}% ${(lens.y - 1) * 50}%` }}\n      >\n        <LensDistortion\n          className=\"size-full\"\n          image={image}\n          fit=\"cover\"\n          // Half the canvas, so the photo matches the card's size, then zoomed.\n          scale={0.5 * ZOOM}\n          imageX={(0.5 - lens.x) / ZOOM}\n          imageY={(0.5 - lens.y) / ZOOM}\n          lensBulge={0}\n          lensCircle={0}\n          count={24}\n          spread={strength}\n          perspective={1}\n          bias={0}\n          angle={0}\n          dispersion={dispersion}\n          dispersionShift={-1}\n          dispersionColor={0.6}\n          focusCenter={0.9}\n          focusEdges={1}\n          swirl={0}\n          noise={0}\n        />\n      </div>\n      <div className=\"pointer-events-none flex size-full flex-col justify-end gap-1 bg-linear-to-t from-black/70 via-black/0 to-black/0 p-6\">\n        <span className=\"font-mono text-[11px] tracking-widest text-white/70 uppercase\">\n          {eyebrow}\n        </span>\n        <h3 className=\"font-heading text-2xl leading-tight\">{title}</h3>\n      </div>\n    </div>\n  )\n}\n\nexport { LensDistortionCard }\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "components",
    "cards"
  ],
  "type": "registry:component"
}