{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "instant-camera",
  "title": "Instant Camera",
  "author": "VenusUI",
  "description": "An instant camera that fires its flash and ejects a print that slowly develops.",
  "dependencies": [
    "lucide-react"
  ],
  "files": [
    {
      "path": "registry/default/ui/instant-camera.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { RotateCcw } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport interface InstantPhoto {\n  src: string\n  alt: string\n  caption?: string\n}\n\ninterface InstantCameraProps extends React.ComponentProps<\"div\"> {\n  /** Photos the camera \"takes\", in order. They repeat if the film outlasts them. */\n  photos: InstantPhoto[]\n  /** Exposures in a pack of film. */\n  film?: number\n  /** Photos already taken when it first appears. */\n  defaultTaken?: number\n  onCapture?: (photo: InstantPhoto, remaining: number) => void\n}\n\nconst TILTS = [-3, 2, -1.5, 3.5]\n\n/**\n * An instant camera. Press the red button: the flash fires, a print slides\n * out of the slot and slowly develops. When the film runs out, reload it.\n */\nfunction InstantCamera({ photos, film = 8, defaultTaken = 0, onCapture, className, ...props }: InstantCameraProps) {\n  const [taken, setTaken] = React.useState(defaultTaken)\n  const [shots, setShots] = React.useState(defaultTaken)\n  const [flash, setFlash] = React.useState(false)\n  const timer = React.useRef<ReturnType<typeof setTimeout>>(undefined)\n  const remaining = film - shots\n  const latest = taken > 0 ? photos[(taken - 1) % photos.length] : null\n  const previous = taken > 1 ? photos[(taken - 2) % photos.length] : null\n\n  React.useEffect(() => () => clearTimeout(timer.current), [])\n\n  const shoot = () => {\n    if (remaining <= 0) return\n    const photo = photos[taken % photos.length]\n    setTaken(taken + 1)\n    setShots(shots + 1)\n    setFlash(true)\n    onCapture?.(photo, remaining - 1)\n    clearTimeout(timer.current)\n    timer.current = setTimeout(() => setFlash(false), 140)\n  }\n\n  return (\n    <div data-slot=\"instant-camera\" className={cn(\"flex w-72 max-w-full flex-col items-center\", className)} {...props}>\n      <div className=\"relative w-full pb-[17rem]\">\n        {/* Prints slide out of the slot at the bottom of the body. */}\n        <div className=\"absolute -inset-x-4 top-[12.75rem] bottom-0 flex justify-center overflow-hidden\">\n          {previous ? <Print key={`p${taken}`} photo={previous} tilt={TILTS[taken % TILTS.length]} settled /> : null}\n          {latest ? <Print key={taken} photo={latest} tilt={TILTS[(taken + 1) % TILTS.length]} /> : null}\n        </div>\n\n        <div className=\"relative z-10 h-52 overflow-hidden rounded-[1.75rem] bg-linear-to-b from-stone-100 to-stone-300 shadow-[0_18px_28px_-16px_rgb(0_0_0/0.65),inset_0_2px_0_white] ring-1 ring-black/10\">\n          <div aria-hidden=\"true\" className=\"absolute inset-x-0 top-[62%] flex h-3 flex-col\">\n            <span className=\"flex-1 bg-amber-500\" />\n            <span className=\"flex-1 bg-teal-700\" />\n          </div>\n          <span aria-hidden=\"true\" className={cn(\"absolute top-4 left-5 h-9 w-16 rounded-md border border-stone-400 transition-colors duration-100\", flash ? \"bg-white shadow-[0_0_34px_14px_white]\" : \"bg-[repeating-linear-gradient(90deg,#e7e5e4_0_3px,#fafaf9_3px_6px)]\")} />\n          <span aria-hidden=\"true\" className=\"absolute top-4 right-5 size-9 rounded-md bg-[radial-gradient(circle_at_35%_30%,#475569,#020617_70%)] ring-2 ring-stone-400\" />\n          <span aria-hidden=\"true\" className=\"absolute top-7 left-1/2 grid size-32 -translate-x-1/2 place-items-center rounded-full bg-linear-145 from-stone-700 to-black shadow-[0_5px_10px_rgb(0_0_0/0.4)] ring-4 ring-stone-200\">\n            <span className=\"grid size-20 place-items-center rounded-full bg-neutral-950 ring-1 ring-stone-600\">\n              <span className=\"relative size-12 rounded-full bg-[radial-gradient(circle_at_38%_32%,#7c6fd6,#123a4c_46%,#020617_74%)]\">\n                <span className=\"absolute top-2 left-3 h-1.5 w-3 -rotate-30 rounded-full bg-white/50\" />\n              </span>\n            </span>\n          </span>\n          <p aria-live=\"polite\" className=\"absolute right-4 bottom-3 rounded-sm bg-stone-800 px-1.5 py-0.5 font-mono text-[10px] text-amber-300 tabular-nums\">\n            <span className=\"sr-only\">Film left: </span>\n            {remaining}\n          </p>\n          <button\n            type=\"button\"\n            onClick={shoot}\n            disabled={remaining <= 0}\n            aria-label=\"Take a photo\"\n            className=\"absolute bottom-3 left-4 size-11 rounded-full bg-linear-to-b from-red-500 to-red-700 shadow-[0_3px_0_#7f1d1d,0_5px_6px_rgb(0_0_0/0.3)] outline-none transition-[transform,box-shadow] duration-75 active:translate-y-[3px] active:shadow-[0_0_0_#7f1d1d] focus-visible:ring-3 focus-visible:ring-blue-600/60 disabled:from-stone-400 disabled:to-stone-500 disabled:shadow-[0_3px_0_#57534e] motion-reduce:transition-none\"\n          />\n          <span aria-hidden=\"true\" className=\"absolute inset-x-8 bottom-0 h-1.5 rounded-t-sm bg-stone-800\" />\n        </div>\n      </div>\n\n      {remaining <= 0 ? (\n        <button\n          type=\"button\"\n          onClick={() => setShots(0)}\n          className=\"inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-sm font-medium outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50\"\n        >\n          <RotateCcw aria-hidden=\"true\" className=\"size-3.5\" />\n          Load new film\n        </button>\n      ) : null}\n    </div>\n  )\n}\n\nfunction Print({ photo, tilt, settled = false }: { photo: InstantPhoto; tilt: number; settled?: boolean }) {\n  return (\n    <figure\n      style={{ \"--tilt\": `${tilt}deg`, rotate: `${settled ? tilt * 2 : tilt}deg` } as React.CSSProperties}\n      className={cn(\"absolute top-3 w-52 bg-[#fdfcf8] p-2.5 pb-3 text-neutral-700 shadow-[0_6px_12px_-6px_rgb(0_0_0/0.45)] ring-1 ring-black/5\", settled ? \"opacity-90\" : \"animate-instant-camera-eject motion-reduce:animate-none\")}\n    >\n      <img src={photo.src} alt={photo.alt} draggable={false} className={cn(\"aspect-square w-full bg-neutral-800 object-cover\", !settled && \"animate-instant-camera-develop motion-reduce:animate-none\")} />\n      <figcaption className=\"mt-2 min-h-4 truncate text-center font-serif text-xs italic\">{photo.caption}</figcaption>\n    </figure>\n  )\n}\n\nexport { InstantCamera }\n",
      "type": "registry:ui"
    }
  ],
  "cssVars": {
    "theme": {
      "animate-instant-camera-eject": "instant-camera-eject 1.1s cubic-bezier(0.2, 0.75, 0.3, 1) both",
      "animate-instant-camera-develop": "instant-camera-develop 5s ease-out both"
    }
  },
  "css": {
    "@keyframes instant-camera-eject": {
      "from": {
        "translate": "0 -100%",
        "rotate": "0deg"
      },
      "to": {
        "translate": "0 0",
        "rotate": "var(--tilt)"
      }
    },
    "@keyframes instant-camera-develop": {
      "from": {
        "filter": "brightness(1.9) saturate(0) contrast(0.55) blur(3px)"
      },
      "to": {
        "filter": "none"
      }
    }
  },
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "interactive",
    "animations"
  ],
  "type": "registry:ui"
}