{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "like-star-favorite",
  "type": "registry:component",
  "title": "Like Star Favorite",
  "description": "A star toggle that spins, sprays a burst of tiny stars and shows an Added to favorites chip that fades on its own.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "social",
    "favorite",
    "star",
    "toggle",
    "toast",
    "particles",
    "bookmark"
  ],
  "docs": "https://hyperblur.dev/effects/like-star-favorite",
  "files": [
    {
      "path": "registry/hyperblur/like-star-favorite.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/like-star-favorite.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface LikeStarFavoriteProps\n  extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"defaultValue\"> {\n  active?: boolean;\n  defaultActive?: boolean;\n  onActiveChange?: (active: boolean) => void;\n  color?: string;\n  size?: number;\n  label?: string;\n  toast?: string;\n  showToast?: boolean;\n  toastSide?: \"right\" | \"left\" | \"top\";\n}\n\nconst css = `\n.hb-qb4 {\n  position: relative;\n  display: inline-flex;\n  vertical-align: middle;\n  box-sizing: border-box;\n  font-family: inherit;\n}\n.hb-qb4 *, .hb-qb4 *::before, .hb-qb4 *::after { box-sizing: border-box; }\n.hb-qb4-btn {\n  position: relative;\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  width: calc(var(--hb-qb4-s) * 1.7);\n  height: calc(var(--hb-qb4-s) * 1.7);\n  margin: 0;\n  padding: 0;\n  border: 1px solid #262626;\n  border-radius: 50%;\n  background: #171717;\n  color: #8f8f8f;\n  cursor: pointer;\n  user-select: none;\n  touch-action: manipulation;\n  -webkit-tap-highlight-color: transparent;\n  transition: border-color 0.25s ease, background-color 0.25s ease, color 0.25s ease, box-shadow 0.3s ease, transform 0.12s ease;\n}\n.hb-qb4-btn:hover { border-color: #3a3a3a; color: #ededed; }\n.hb-qb4-btn:active { transform: scale(0.92); }\n.hb-qb4-btn:focus-visible { outline: 2px solid var(--hb-qb4-c); outline-offset: 3px; }\n.hb-qb4-btn[aria-pressed=\"true\"] {\n  border-color: color-mix(in srgb, var(--hb-qb4-c) 50%, #262626);\n  background: color-mix(in srgb, var(--hb-qb4-c) 10%, #171717);\n  color: var(--hb-qb4-c);\n  box-shadow: 0 0 0 4px color-mix(in srgb, var(--hb-qb4-c) 12%, transparent);\n}\n.hb-qb4-star {\n  display: block;\n  width: var(--hb-qb4-s);\n  height: var(--hb-qb4-s);\n}\n.hb-qb4-star svg {\n  display: block;\n  width: 100%;\n  height: 100%;\n  overflow: visible;\n  fill: transparent;\n  stroke: currentColor;\n  stroke-width: 1.7;\n  stroke-linejoin: round;\n  transition: fill 0.25s ease;\n}\n.hb-qb4-btn[aria-pressed=\"true\"] .hb-qb4-star svg { fill: var(--hb-qb4-c); }\n.hb-qb4-star[data-fx=\"on\"] { animation: hb-qb4-spin 0.75s cubic-bezier(0.25, 1.1, 0.4, 1); }\n.hb-qb4-star[data-fx=\"off\"] { animation: hb-qb4-off 0.3s ease-out; }\n@keyframes hb-qb4-spin {\n  0% { transform: rotate(0deg) scale(0.6); }\n  45% { transform: rotate(210deg) scale(1.4); }\n  100% { transform: rotate(360deg) scale(1); }\n}\n@keyframes hb-qb4-off {\n  0% { transform: rotate(0deg) scale(1.18); }\n  100% { transform: rotate(-72deg) scale(1); }\n}\n.hb-qb4-spray {\n  position: absolute;\n  inset: 0;\n  pointer-events: none;\n}\n.hb-qb4-bit {\n  position: absolute;\n  left: 50%;\n  top: 50%;\n  width: var(--hb-qb4-w);\n  height: var(--hb-qb4-w);\n  margin: calc(var(--hb-qb4-w) / -2) 0 0 calc(var(--hb-qb4-w) / -2);\n  opacity: 0;\n  animation: hb-qb4-fly 0.8s cubic-bezier(0.1, 0.7, 0.3, 1) var(--hb-qb4-d) forwards;\n}\n.hb-qb4-bit svg { display: block; width: 100%; height: 100%; fill: var(--hb-qb4-k); }\n@keyframes hb-qb4-fly {\n  0% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(0.3); }\n  60% { opacity: 1; }\n  100% { opacity: 0; transform: translate(var(--hb-qb4-x), var(--hb-qb4-y)) rotate(var(--hb-qb4-r)) scale(1); }\n}\n.hb-qb4-toast {\n  position: absolute;\n  top: 50%;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  padding: 7px 11px 7px 8px;\n  border: 1px solid #262626;\n  border-radius: 999px;\n  background: #171717;\n  color: #ededed;\n  font-size: 12px;\n  font-weight: 500;\n  line-height: 1;\n  white-space: nowrap;\n  pointer-events: none;\n  opacity: 0;\n  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);\n  animation: hb-qb4-toast-r 2.2s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;\n}\n.hb-qb4-toast[data-side=\"right\"] { left: calc(100% + 12px); }\n.hb-qb4-toast[data-side=\"left\"] { right: calc(100% + 12px); animation-name: hb-qb4-toast-l; }\n.hb-qb4-toast[data-side=\"top\"] { top: auto; bottom: calc(100% + 12px); left: 50%; animation-name: hb-qb4-toast-t; }\n.hb-qb4-toast svg {\n  width: 14px;\n  height: 14px;\n  flex: none;\n  padding: 2px;\n  border-radius: 50%;\n  background: var(--hb-qb4-c);\n  fill: none;\n  stroke: #0a0a0a;\n  stroke-width: 3;\n  stroke-linecap: round;\n  stroke-linejoin: round;\n}\n@keyframes hb-qb4-toast-r {\n  0% { opacity: 0; transform: translate(-10px, -50%) scale(0.92); }\n  10% { opacity: 1; transform: translate(0, -50%) scale(1); }\n  86% { opacity: 1; transform: translate(0, -50%) scale(1); }\n  100% { opacity: 0; transform: translate(6px, -50%) scale(0.96); }\n}\n@keyframes hb-qb4-toast-l {\n  0% { opacity: 0; transform: translate(10px, -50%) scale(0.92); }\n  10% { opacity: 1; transform: translate(0, -50%) scale(1); }\n  86% { opacity: 1; transform: translate(0, -50%) scale(1); }\n  100% { opacity: 0; transform: translate(-6px, -50%) scale(0.96); }\n}\n@keyframes hb-qb4-toast-t {\n  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.92); }\n  10% { opacity: 1; transform: translate(-50%, 0) scale(1); }\n  86% { opacity: 1; transform: translate(-50%, 0) scale(1); }\n  100% { opacity: 0; transform: translate(-50%, -6px) scale(0.96); }\n}\n.hb-qb4-sr {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  margin: -1px;\n  overflow: hidden;\n  clip-path: inset(50%);\n  white-space: nowrap;\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-qb4-btn, .hb-qb4-star svg { transition: none; }\n  .hb-qb4-star[data-fx] { animation: none; }\n  .hb-qb4-spray { display: none; }\n  .hb-qb4-toast { animation: none; opacity: 1; }\n  .hb-qb4-toast[data-side=\"right\"], .hb-qb4-toast[data-side=\"left\"] { transform: translateY(-50%); }\n  .hb-qb4-toast[data-side=\"top\"] { transform: translateX(-50%); }\n}\n`;\n\nfunction hash(n: number) {\n  let x = Math.imul(n + 1, 2654435761) ^ 0x9e3779b9;\n  x = Math.imul(x ^ (x >>> 15), 2246822519);\n  x = Math.imul(x ^ (x >>> 13), 3266489917);\n  return ((x ^ (x >>> 16)) >>> 0) / 4294967296;\n}\n\nfunction starPath(cx: number, cy: number, outer: number, inner: number) {\n  let d = \"\";\n  for (let i = 0; i < 10; i++) {\n    const r = i % 2 === 0 ? outer : inner;\n    const a = -Math.PI / 2 + (i * Math.PI) / 5;\n    d += `${i === 0 ? \"M\" : \"L\"}${(cx + Math.cos(a) * r).toFixed(2)} ${(cy + Math.sin(a) * r).toFixed(2)}`;\n  }\n  return `${d}Z`;\n}\n\nconst bigStar = starPath(12, 12.9, 9.6, 4.3);\nconst bitStar = starPath(12, 12.9, 11, 5);\n\nconst BITS = Array.from({ length: 9 }, (_, i) => {\n  const angle = (i / 9) * Math.PI * 2 + (hash(i) - 0.5) * 0.6;\n  const reach = 1.05 + hash(i + 11) * 0.55;\n  return {\n    x: Math.cos(angle) * reach,\n    y: Math.sin(angle) * reach,\n    w: 0.26 + hash(i + 23) * 0.2,\n    r: Math.round((hash(i + 37) - 0.5) * 420),\n    d: Math.round(hash(i + 53) * 90),\n    soft: i % 3 === 1,\n  };\n});\n\nexport function LikeStarFavorite({\n  active,\n  defaultActive = false,\n  onActiveChange,\n  color = \"#ffc83d\",\n  size = 24,\n  label = \"Favorite\",\n  toast = \"Added to favorites\",\n  showToast = true,\n  toastSide = \"right\",\n  className = \"\",\n  style,\n  ...rest\n}: LikeStarFavoriteProps) {\n  const controlled = active !== undefined;\n  const [inner, setInner] = React.useState(defaultActive);\n  const current = controlled ? active : inner;\n  const [seen, setSeen] = React.useState({ active: current, pulse: 0 });\n  const [shown, setShown] = React.useState(false);\n  const timer = React.useRef<number | undefined>(undefined);\n\n  if (seen.active !== current) {\n    setSeen({ active: current, pulse: seen.pulse + 1 });\n  }\n\n  React.useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  function toggle() {\n    const next = !current;\n    if (!controlled) setInner(next);\n    onActiveChange?.(next);\n    window.clearTimeout(timer.current);\n    if (next && showToast) {\n      setShown(true);\n      timer.current = window.setTimeout(() => setShown(false), 2200);\n    } else {\n      setShown(false);\n    }\n  }\n\n  const vars = {\n    \"--hb-qb4-s\": `${size}px`,\n    \"--hb-qb4-c\": color,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <span className={`hb-qb4 ${className}`} style={vars} {...rest}>\n      <style href=\"hb-like-star-favorite\" precedence=\"default\">{css}</style>\n      <button type=\"button\" className=\"hb-qb4-btn\" aria-pressed={current} aria-label={label} onClick={toggle}>\n        <span\n          key={`s${seen.pulse}`}\n          className=\"hb-qb4-star\"\n          data-fx={seen.pulse === 0 ? undefined : current ? \"on\" : \"off\"}\n          aria-hidden=\"true\"\n        >\n          <svg viewBox=\"0 0 24 24\">\n            <path d={bigStar} />\n          </svg>\n        </span>\n        {seen.pulse > 0 && current && (\n          <span key={`p${seen.pulse}`} className=\"hb-qb4-spray\" aria-hidden=\"true\">\n            {BITS.map((b, i) => (\n              <i\n                key={i}\n                className=\"hb-qb4-bit\"\n                style={\n                  {\n                    \"--hb-qb4-x\": `${(b.x * size).toFixed(2)}px`,\n                    \"--hb-qb4-y\": `${(b.y * size).toFixed(2)}px`,\n                    \"--hb-qb4-w\": `${(b.w * size).toFixed(2)}px`,\n                    \"--hb-qb4-r\": `${b.r}deg`,\n                    \"--hb-qb4-d\": `${b.d}ms`,\n                    \"--hb-qb4-k\": b.soft ? \"color-mix(in srgb, var(--hb-qb4-c) 45%, #ffffff)\" : \"var(--hb-qb4-c)\",\n                  } as React.CSSProperties\n                }\n              >\n                <svg viewBox=\"0 0 24 24\">\n                  <path d={bitStar} />\n                </svg>\n              </i>\n            ))}\n          </span>\n        )}\n      </button>\n      {shown && (\n        <span key={`t${seen.pulse}`} className=\"hb-qb4-toast\" data-side={toastSide} aria-hidden=\"true\">\n          <svg viewBox=\"0 0 16 16\">\n            <path d=\"M3.5 8.5l3 3 6-6.5\" />\n          </svg>\n          {toast}\n        </span>\n      )}\n      <span className=\"hb-qb4-sr\" role=\"status\" aria-live=\"polite\">\n        {seen.pulse === 0 ? \"\" : current ? toast : \"Removed from favorites\"}\n      </span>\n    </span>\n  );\n}\n"
    }
  ]
}