{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "aura-mic",
  "type": "registry:ui",
  "title": "Aura Mic",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "A black and white microphone toggle that surrounds itself with a unique animated aura while listening. Six styles are included: halftone, moire, thread, ink, eclipse and ridgeline. Built with React, Tailwind CSS and Framer Motion.",
  "dependencies": [
    "framer-motion",
    "lucide-react"
  ],
  "files": [
    {
      "path": "components/ui/aura-mic.tsx",
      "content": "\"use client\";\n\nimport { useId, useState } from \"react\";\nimport { motion, AnimatePresence, useReducedMotion } from \"framer-motion\";\nimport { Mic, MicOff } from \"lucide-react\";\n\n/**\n * AuraMic — strictly black & white.\n * Everything is drawn with `currentColor`, so it flips automatically:\n * black on light backgrounds, white on dark (via Tailwind `dark:`).\n *\n * halftone  – a printed dot grid that swells outward in waves\n * moire     – two ring sets drifting against each other, interference fringes appear\n * thread    – a single looping Lissajous line that keeps re-knotting itself\n * ink       – liquid droplets that bleed out of the button and merge back (gooey)\n * eclipse   – thick/thin crescents orbiting the button like a solar corona\n * ridgeline – stacked signal lines that spike like a pulsar plot\n */\nexport type AuraAnimation =\n  | \"halftone\"\n  | \"moire\"\n  | \"thread\"\n  | \"ink\"\n  | \"eclipse\"\n  | \"ridgeline\";\n\ninterface AuraMicProps {\n  animation?: AuraAnimation;\n  size?: number;\n  onListeningChange?: (listening: boolean) => void;\n}\n\n/* ---------- helpers ---------- */\n\nconst STAGE = 220;\nconst r1 = (n: number) => Math.round(n * 10) / 10;\n\n/** Keyframe arrays for a point travelling around an ellipse. */\nfunction orbit(rx: number, ry: number, phase = 0, dir = 1, steps = 24) {\n  const xs: number[] = [];\n  const ys: number[] = [];\n  for (let i = 0; i <= steps; i++) {\n    const a = phase + dir * (i / steps) * Math.PI * 2;\n    xs.push(r1(Math.cos(a) * rx));\n    ys.push(r1(Math.sin(a) * ry));\n  }\n  return { xs, ys };\n}\n\n/** Deterministic pseudo-random in [0, 1). */\nconst hash = (s: number) => {\n  const v = Math.sin(s * 127.1) * 43758.5453;\n  return v - Math.floor(v);\n};\n\nconst loop = (duration: number, extra = {}) => ({\n  duration,\n  repeat: Infinity,\n  ease: \"linear\" as const,\n  ...extra,\n});\n\n/* ---------- 1. HALFTONE ---------- */\n\nconst HALFTONE = (() => {\n  const dots: { x: number; y: number; d: number }[] = [];\n  const step = 15;\n  const n = 7;\n  for (let gx = -n; gx <= n; gx++) {\n    for (let gy = -n; gy <= n; gy++) {\n      const x = gx * step;\n      const y = gy * step;\n      const d = Math.hypot(x, y);\n      if (d <= 100) dots.push({ x, y, d });\n    }\n  }\n  return dots;\n})();\n\nfunction Halftone({ size }: { size: number }) {\n  const inner = size / 2 + 8;\n  return (\n    <g fill=\"currentColor\" stroke=\"none\">\n      {HALFTONE.filter((p) => p.d > inner).map(({ x, y, d }, i) => {\n        const peak = Math.max(1.5, 7 - (d / 100) * 5.5);\n        return (\n          <motion.circle\n            key={i}\n            cx={x}\n            cy={y}\n            initial={{ r: 0.5 }}\n            animate={{ r: [0.5, peak, 0.5] }}\n            transition={{\n              duration: 1.8,\n              repeat: Infinity,\n              ease: \"easeInOut\",\n              delay: (d / 100) * 0.9,\n            }}\n          />\n        );\n      })}\n    </g>\n  );\n}\n\n/* ---------- 2. MOIRÉ ---------- */\n\nfunction Moire({ size }: { size: number }) {\n  const radii: number[] = [];\n  for (let r = size / 2 + 6; r <= 100; r += 5.5) radii.push(r);\n  const { xs, ys } = orbit(8, 8, 0, 1, 16);\n\n  return (\n    <g fill=\"none\" strokeWidth={1}>\n      <g opacity={0.9}>\n        {radii.map((r) => (\n          <circle key={r} r={r} />\n        ))}\n      </g>\n      <motion.g\n        animate={{ x: xs, y: ys }}\n        transition={loop(4)}\n        opacity={0.9}\n      >\n        {radii.map((r) => (\n          <circle key={r} r={r} />\n        ))}\n      </motion.g>\n    </g>\n  );\n}\n\n/* ---------- 3. THREAD (Lissajous) ---------- */\n\nfunction lissajous(a: number, b: number, phase: number, amp: number, n = 160) {\n  let d = \"\";\n  for (let i = 0; i <= n; i++) {\n    const t = (i / n) * Math.PI * 2;\n    const x = r1(Math.sin(a * t + phase) * amp);\n    const y = r1(Math.sin(b * t) * amp);\n    d += `${i === 0 ? \"M\" : \" L\"}${x} ${y}`;\n  }\n  return d;\n}\n\nconst THREAD_A = [0, 0.7, 1.5, 2.3].map((p) => lissajous(3, 2, p, 84));\nconst THREAD_B = [1.2, 2.0, 2.9, 3.6].map((p) => lissajous(5, 4, p, 70));\n\nfunction Thread() {\n  const t = {\n    duration: 3.4,\n    repeat: Infinity,\n    repeatType: \"mirror\" as const,\n    ease: \"easeInOut\" as const,\n  };\n  return (\n    <g fill=\"none\" strokeLinejoin=\"round\" strokeLinecap=\"round\">\n      <motion.path\n        d={THREAD_A[0]}\n        strokeWidth={1.6}\n        animate={{ d: THREAD_A }}\n        transition={t}\n      />\n      <motion.path\n        d={THREAD_B[0]}\n        strokeWidth={0.8}\n        opacity={0.45}\n        animate={{ d: THREAD_B }}\n        transition={{ ...t, duration: 4.6 }}\n      />\n    </g>\n  );\n}\n\n/* ---------- 4. INK (gooey droplets) ---------- */\n\nfunction Ink({ size, uid }: { size: number; uid: string }) {\n  const base = size / 2;\n  const blobs = [\n    { rx: base + 10, ry: base + 18, r: 13, dur: 5.5, phase: 0, dir: 1 },\n    { rx: base + 22, ry: base + 12, r: 9, dur: 4.2, phase: 1.3, dir: -1 },\n    { rx: base + 16, ry: base + 26, r: 11, dur: 6.8, phase: 2.6, dir: 1 },\n    { rx: base + 28, ry: base + 20, r: 7, dur: 3.6, phase: 3.9, dir: -1 },\n    { rx: base + 12, ry: base + 14, r: 10, dur: 4.8, phase: 5.1, dir: 1 },\n  ];\n\n  return (\n    <>\n      <defs>\n        <filter\n          id={`goo-${uid}`}\n          filterUnits=\"userSpaceOnUse\"\n          x={-110}\n          y={-110}\n          width={220}\n          height={220}\n        >\n          <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"6\" result=\"blur\" />\n          <feColorMatrix\n            in=\"blur\"\n            mode=\"matrix\"\n            values=\"1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 20 -9\"\n          />\n        </filter>\n      </defs>\n      <g filter={`url(#goo-${uid})`} fill=\"currentColor\" stroke=\"none\">\n        {/* core hides under the button so blobs appear to pull away from it */}\n        <circle r={base - 2} />\n        {blobs.map((b, i) => {\n          const { xs, ys } = orbit(b.rx, b.ry, b.phase, b.dir);\n          return (\n            <motion.circle\n              key={i}\n              r={b.r}\n              animate={{\n                cx: xs,\n                cy: ys,\n                r: [b.r, b.r * 0.55, b.r * 1.1, b.r],\n              }}\n              transition={{\n                cx: loop(b.dur),\n                cy: loop(b.dur),\n                r: { duration: b.dur / 2, repeat: Infinity, ease: \"easeInOut\" },\n              }}\n            />\n          );\n        })}\n      </g>\n    </>\n  );\n}\n\n/* ---------- 5. ECLIPSE ---------- */\n\nfunction Eclipse({ size, uid }: { size: number; uid: string }) {\n  const base = size / 2;\n  const crescents = [\n    { R: base + 14, off: 11, dur: 4.5, dir: 1, o: 1 },\n    { R: base + 32, off: 15, dur: 7.5, dir: -1, o: 0.55 },\n  ];\n\n  return (\n    <g fill=\"currentColor\" stroke=\"none\">\n      {crescents.map((c, i) => {\n        const id = `ecl-${uid}-${i}`;\n        const { xs, ys } = orbit(c.off, c.off, i * 2, c.dir);\n        return (\n          <g key={id}>\n            <defs>\n              <mask\n                id={id}\n                maskUnits=\"userSpaceOnUse\"\n                x={-110}\n                y={-110}\n                width={220}\n                height={220}\n              >\n                <circle r={c.R} fill=\"white\" />\n                <motion.circle\n                  r={c.R}\n                  fill=\"black\"\n                  animate={{ cx: xs, cy: ys }}\n                  transition={loop(c.dur)}\n                />\n              </mask>\n            </defs>\n            <circle r={c.R} mask={`url(#${id})`} opacity={c.o} />\n          </g>\n        );\n      })}\n    </g>\n  );\n}\n\n/* ---------- 6. RIDGELINE ---------- */\n\nconst RIDGE_LINES = 13;\nconst RIDGE_FRAMES = 3;\n\nconst RIDGES = Array.from({ length: RIDGE_LINES }, (_, i) => {\n  const baseY = -84 + i * 14;\n  return Array.from({ length: RIDGE_FRAMES }, (_, f) => {\n    let d = \"\";\n    for (let j = 0; j <= 40; j++) {\n      const x = -100 + j * 5;\n      const env = Math.exp(-Math.pow(x / 42, 2));\n      const noise = hash(i * 53 + j * 17 + f * 101);\n      const y = r1(baseY - env * 18 * noise);\n      d += `${j === 0 ? \"M\" : \" L\"}${x} ${y}`;\n    }\n    return d;\n  });\n});\n\nfunction Ridgeline() {\n  return (\n    <g fill=\"none\" strokeWidth={1.3} strokeLinejoin=\"round\">\n      <clipPath id=\"ridge-clip\">\n        <circle r={100} />\n      </clipPath>\n      <g clipPath=\"url(#ridge-clip)\">\n        {RIDGES.map((frames, i) => (\n          <motion.path\n            key={i}\n            d={frames[0]}\n            animate={{ d: frames }}\n            transition={{\n              duration: 1.1 + (i % 4) * 0.25,\n              repeat: Infinity,\n              repeatType: \"mirror\",\n              ease: \"easeInOut\",\n            }}\n          />\n        ))}\n      </g>\n    </g>\n  );\n}\n\n/* ---------- component ---------- */\n\nexport function AuraMic({\n  animation = \"halftone\",\n  size = 48,\n  onListeningChange,\n}: AuraMicProps) {\n  const [listening, setListening] = useState(false);\n  const reduceMotion = useReducedMotion();\n  const uid = useId().replace(/:/g, \"\");\n\n  const toggle = () => {\n    const next = !listening;\n    setListening(next);\n    onListeningChange?.(next);\n  };\n\n  return (\n    <div\n      className=\"relative flex items-center justify-center text-black dark:text-white\"\n      style={{ width: STAGE, height: STAGE }}\n    >\n      <AnimatePresence>\n        {listening && !reduceMotion && (\n          <motion.svg\n            key={animation}\n            className=\"pointer-events-none absolute inset-0\"\n            width={STAGE}\n            height={STAGE}\n            viewBox=\"-110 -110 220 220\"\n            fill=\"none\"\n            stroke=\"currentColor\"\n            aria-hidden=\"true\"\n            initial={{ opacity: 0 }}\n            animate={{ opacity: 1 }}\n            exit={{ opacity: 0 }}\n            transition={{ duration: 0.35 }}\n          >\n            {animation === \"halftone\" && <Halftone size={size} />}\n            {animation === \"moire\" && <Moire size={size} />}\n            {animation === \"thread\" && <Thread />}\n            {animation === \"ink\" && <Ink size={size} uid={uid} />}\n            {animation === \"eclipse\" && <Eclipse size={size} uid={uid} />}\n            {animation === \"ridgeline\" && <Ridgeline />}\n          </motion.svg>\n        )}\n      </AnimatePresence>\n\n      {/* MIC BUTTON: outlined when idle, solid (inverted) when listening */}\n      <motion.button\n        onClick={toggle}\n        whileTap={{ scale: 0.9 }}\n        className={[\n          \"relative z-10 flex items-center justify-center rounded-full border-2\",\n          \"border-black dark:border-white\",\n          \"focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4\",\n          \"focus-visible:outline-black dark:focus-visible:outline-white\",\n          \"transition-colors duration-200\",\n          listening\n            ? \"bg-black text-white dark:bg-white dark:text-black\"\n            : \"bg-transparent text-black dark:text-white\",\n        ].join(\" \")}\n        style={{ width: size, height: size }}\n        aria-label={listening ? \"Stop listening\" : \"Start listening\"}\n        aria-pressed={listening}\n      >\n        <AnimatePresence mode=\"wait\" initial={false}>\n          <motion.span\n            key={String(listening)}\n            className=\"flex\"\n            initial={{ scale: 0, rotate: -45 }}\n            animate={{ scale: 1, rotate: 0 }}\n            exit={{ scale: 0, rotate: 45 }}\n            transition={{ duration: 0.15 }}\n          >\n            {listening ? <Mic size={size * 0.38} /> : <MicOff size={size * 0.38} />}\n          </motion.span>\n        </AnimatePresence>\n      </motion.button>\n    </div>\n  );\n}",
      "type": "registry:ui",
      "target": "components/ui/aura-mic.tsx"
    }
  ]
}
