{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "reveal-copy-base",
  "type": "registry:component",
  "title": "Reveal Copy (base)",
  "description": "Theme-ready base variant of An animated reveal copy component that smoothly uncovers content with interactive motion..",
  "dependencies": [
    "motion",
    "react-icons"
  ],
  "files": [
    {
      "path": "components/watermelon/reveal-copy.tsx",
      "type": "registry:component",
      "content": "import { useState, useEffect, useCallback } from 'react';\nimport { motion, AnimatePresence } from 'motion/react';\nimport { FaCopy } from 'react-icons/fa';\nimport { BsEyeFill } from 'react-icons/bs';\nimport { FaCheck } from 'react-icons/fa6';\n\ntype RevealAndCopyProps = {\n  cardNumber: string;\n  hiddenIndexes?: number[];\n  revealDuration?: number;\n  copiedDuration?: number;\n};\n\nexport const RevealAndCopy = ({\n  cardNumber,\n  hiddenIndexes = [1, 2],\n  revealDuration = 3000,\n  copiedDuration = 1200,\n}: RevealAndCopyProps) => {\n  const [revealed, setRevealed] = useState(false);\n  const [copied, setCopied] = useState(false);\n  const [timerActive, setTimerActive] = useState(false);\n\n  const parts = cardNumber.split(' ');\n\n  const resetAll = useCallback(() => {\n    setRevealed(false);\n    setCopied(false);\n    setTimerActive(false);\n  }, []);\n\n  useEffect(() => {\n    if (!revealed) return;\n    // eslint-disable-next-line react-hooks/set-state-in-effect\n    setTimerActive(true);\n\n    const timer = setTimeout(() => {\n      if (!copied) resetAll();\n    }, revealDuration);\n\n    return () => clearTimeout(timer);\n  }, [revealed, copied, revealDuration, resetAll]);\n\n  useEffect(() => {\n    if (!copied) return;\n\n    const timer = setTimeout(() => {\n      resetAll();\n    }, copiedDuration);\n\n    return () => clearTimeout(timer);\n  }, [copied, copiedDuration, resetAll]);\n\n  const handleCopy = async () => {\n    if (copied) return;\n\n    await navigator.clipboard.writeText(cardNumber);\n\n    setCopied(true);\n    setTimerActive(false);\n  };\n\n  return (\n    <div className=\"theme-injected  flex flex-col items-center justify-center gap-8 transition-colors duration-500\">\n      <div className=\"border-border bg-background flex h-[70px] w-full max-w-[420px] items-center rounded-lg border-2 px-3 shadow-sm transition-colors duration-500\">\n        <div className=\"relative flex flex-1 items-center justify-between overflow-hidden text-[16px] tracking-[0.08em] sm:text-[22px] sm:tracking-[0.18em]\">\n          <AnimatePresence>\n            {revealed && (\n              <motion.div\n                key=\"shine\"\n                initial={{ left: '-60%' }}\n                animate={{ left: '160%' }}\n                transition={{\n                  delay: 0.35,\n                  duration: 1,\n                  ease: 'linear',\n                }}\n                className=\"pointer-events-none absolute inset-y-0 z-30 w-[60%] mix-blend-overlay\"\n                style={{\n                  transform: 'skewX(-20deg)',\n                  background: `\n                    linear-gradient(\n                      90deg,\n                      transparent 0%,\n                      oklch(var(--background) / 0.15) 20%,\n                      oklch(var(--background) / 0.9) 50%,\n                      oklch(var(--background) / 0.15) 80%,\n                      transparent 100%\n                    )\n                  `,\n                  filter: 'blur(6px)',\n                }}\n              />\n            )}\n          </AnimatePresence>\n\n          {parts.map((part, idx) => {\n            const isMasked = !revealed && hiddenIndexes.includes(idx);\n            const display = isMasked ? 'xxxx' : part;\n\n            return (\n              <div\n                key={idx}\n                className=\"relative flex flex-1 min-w-0 justify-center overflow-hidden font-bold\"\n              >\n                <div className=\"relative flex items-center\">\n                  <AnimatePresence mode=\"popLayout\" initial={false}>\n                    {display.split('').map((char, i) => (\n                      <motion.span\n                        key={`${display}-${i}`}\n                        initial={{\n                          opacity: 0,\n                          y: 12,\n                          scale: 0.5,\n                          filter: 'blur(4px)',\n                        }}\n                        animate={{\n                          opacity: 1,\n                          y: 0,\n                          scale: 1,\n                          filter: 'blur(0px)',\n                          transition: {\n                            type: 'spring',\n                            stiffness: 200,\n                            damping: 14,\n                            delay: i * 0.06,\n                          },\n                        }}\n                        exit={{\n                          opacity: 0,\n                          y: -12,\n                          scale: 0.5,\n                          filter: 'blur(4px)',\n                          transition: {\n                            delay: i * 0.06,\n                            duration: 0.18,\n                          },\n                        }}\n                        className=\"text-foreground tabular-nums\"\n                      >\n                        {char}\n                      </motion.span>\n                    ))}\n                  </AnimatePresence>\n                </div>\n              </div>\n            );\n          })}\n        </div>\n\n        <div className=\"relative ml-2 shrink-0 sm:ml-4 h-12 w-12\">\n          <AnimatePresence mode=\"popLayout\" initial={false}>\n            {!revealed && (\n              <motion.button\n                key=\"eye\"\n                onClick={() => setRevealed(true)}\n                initial={{ scale: 0.85, opacity: 0 }}\n                animate={{ scale: 1, opacity: 1 }}\n                exit={{ scale: 0.85, opacity: 0 }}\n                className=\"bg-muted text-foreground flex h-full w-full items-center justify-center rounded-lg\"\n              >\n                <BsEyeFill size={22} />\n              </motion.button>\n            )}\n\n            {revealed && (\n              <motion.button\n                key=\"copy\"\n                onClick={handleCopy}\n                initial={{ scale: 0.85, opacity: 0 }}\n                animate={{ scale: 1, opacity: 1 }}\n                exit={{ scale: 0.85, opacity: 0 }}\n                className={`relative flex h-full w-full items-center justify-center rounded-lg transition-colors duration-300 ${\n                  copied\n                    ? 'bg-primary text-primary-foreground'\n                    : 'bg-secondary text-secondary-foreground'\n                }`}\n              >\n                {timerActive && !copied && (\n                  <svg\n                    className=\"pointer-events-none absolute inset-0 h-full w-full\"\n                    viewBox=\"0 0 48 48\"\n                  >\n                    <motion.rect\n                      x=\"1.5\"\n                      y=\"1.5\"\n                      width=\"45\"\n                      height=\"45\"\n                      rx=\"var(--radius)\"\n                      ry=\"var(--radius)\"\n                      fill=\"transparent\"\n                      className=\"stroke-secondary-foreground\"\n                      strokeWidth=\"3\"\n                      strokeDasharray=\"180\"\n                      initial={{ strokeDashoffset: 180 }}\n                      animate={{ strokeDashoffset: 0 }}\n                      transition={{\n                        duration: revealDuration / 1000,\n                        ease: 'linear',\n                      }}\n                    />\n                  </svg>\n                )}\n\n                {copied ? <FaCheck size={22} /> : <FaCopy size={22} />}\n              </motion.button>\n            )}\n          </AnimatePresence>\n        </div>\n      </div>\n    </div>\n  );\n};\n"
    }
  ]
}
