{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "vintage-led",
  "title": "Vintage LED",
  "author": "Visant Labs <visantsupply@gmail.com>",
  "description": "LED de painel com halo. Quatro cores, estado on/off.",
  "registryDependencies": [
    "@visant/vintage-theme",
    "utils"
  ],
  "files": [
    {
      "path": "registry/vintage/ui/vintage-led.tsx",
      "content": "\"use client\";\n\nimport { useEffect } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\ninterface VintageLedProps {\n  color?: \"green\" | \"red\" | \"yellow\" | \"orange\" | string;\n  active?: boolean;\n  label?: string;\n  size?: \"sm\" | \"md\" | \"lg\";\n  pulse?: boolean;\n  /**\n   * Quanto o LED está aceso, de 0 a 1. É o que separa \"ligado\" de \"no talo\":\n   * um indicador de nível precisa clarear com o sinal, não só acender.\n   */\n  intensity?: number;\n  className?: string;\n}\n\nconst presetColors: Record<string, { on: string; off: string }> = {\n  green: { on: \"var(--vintage-meter-green)\", off: \"color-mix(in srgb, var(--vintage-meter-green) 22%, var(--vintage-surface-1))\" },\n  red: { on: \"var(--vintage-meter-red)\", off: \"color-mix(in srgb, var(--vintage-meter-red) 22%, var(--vintage-surface-1))\" },\n  yellow: { on: \"var(--vintage-meter-yellow)\", off: \"color-mix(in srgb, var(--vintage-meter-yellow) 22%, var(--vintage-surface-1))\" },\n  orange: { on: \"var(--vintage-accent)\", off: \"color-mix(in srgb, var(--vintage-accent) 22%, var(--vintage-surface-1))\" },\n};\n\nconst sizeMap = {\n  sm: { w: 8, h: 8 },\n  md: { w: 12, h: 12 },\n  lg: { w: 16, h: 16 },\n};\n\n/**\n * O piscar mora aqui, e não emprestado do `vintage-tv-frame`.\n *\n * A animação usada antes (`vtv-rec-blink`) só existe quando o frame de TV está\n * na página: quem instalasse o LED sozinho — o caso normal — ganhava um `pulse`\n * que não pulsava. Mesma técnica do vizinho, keyframes próprios, e com o\n * respeito a `prefers-reduced-motion` escrito junto em vez de esquecido.\n */\nconst STYLE_ID = \"vintage-led-keyframes\";\n\nfunction injectKeyframes() {\n  if (typeof document === \"undefined\") return;\n  if (document.getElementById(STYLE_ID)) return;\n  const style = document.createElement(\"style\");\n  style.id = STYLE_ID;\n  style.textContent = `\n@keyframes vled-pulse {\n  0%, 100% { opacity: 1; }\n  50%      { opacity: 0.35; }\n}\n.vled-pulse { animation: vled-pulse 1s ease-in-out infinite; }\n@media (prefers-reduced-motion: reduce) {\n  .vled-pulse { animation: none; }\n}\n`;\n  document.head.appendChild(style);\n}\n\nexport function VintageLed({\n  color = \"green\",\n  active = false,\n  label,\n  size = \"md\",\n  pulse = false,\n  intensity = 1,\n  className,\n}: VintageLedProps) {\n  useEffect(injectKeyframes, []);\n\n  const preset = presetColors[color];\n  const onColor = preset ? preset.on : color;\n  const offColor = preset ? preset.off : `color-mix(in srgb, ${color} 20%, var(--vintage-surface-1))`;\n  const s = sizeMap[size];\n  const i = Math.max(0, Math.min(1, intensity));\n  const brilho = active\n    ? `color-mix(in srgb, ${onColor} ${Math.round(35 + i * 65)}%, ${offColor})`\n    : offColor;\n\n  // Aro cromado em volta da lente: é ele que diz \"peça montada no painel\" e\n  // não \"bolinha de cor\". Um terço do diâmetro da lente, de cada lado.\n  const aro = Math.max(2, Math.round(s.w * 0.28));\n\n  return (\n    <div\n      className={cn(\"inline-flex flex-col items-center gap-1.5\", className)}\n    >\n      <div\n        className=\"rounded-full\"\n        style={{\n          padding: aro,\n          background:\n            \"linear-gradient(180deg, var(--vintage-metal-mid), var(--vintage-metal-dark))\",\n          boxShadow: \"0 1px 1px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.35)\",\n        }}\n      >\n        <div\n          className={cn(\"relative rounded-full\", active && pulse && \"vled-pulse\")}\n          style={{\n            width: s.w,\n            height: s.h,\n            // Lente: o reflexo da lâmpada da sala fica em cima, sempre, aceso\n            // ou não. O que muda com o estado é a cor por trás do vidro.\n            background: `radial-gradient(circle at 50% 30%, rgba(255,255,255,${active ? 0.55 : 0.18}) 0%, transparent 38%), ${brilho}`,\n            boxShadow: active\n              ? `inset 0 -1px 2px rgba(0,0,0,0.35), 0 0 ${s.w * i}px ${onColor}, 0 0 ${s.w * 2 * i}px color-mix(in srgb, ${onColor} 55%, transparent)`\n              : \"inset 0 1px 2px rgba(0,0,0,0.7)\",\n            transition:\n              \"background var(--dur-fast,160ms) var(--ease-out,ease), box-shadow var(--dur-fast,160ms) var(--ease-out,ease)\",\n          }}\n        />\n      </div>\n      {label && (\n        <span\n          className=\"font-vintage-mono font-semibold tracking-[0.16em] uppercase\"\n          style={{\n            fontSize: Math.max(9, s.w * 0.65),\n            color: active ? \"var(--vintage-label)\" : \"var(--vintage-text-muted)\",\n            textShadow: \"var(--vintage-engrave)\",\n            transition: \"color var(--dur-fast,160ms) var(--ease-out,ease)\",\n          }}\n        >\n          {label}\n        </span>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "uso": {
      "quando": "Indicar estado on/off num painel do kit vintage, como clip, gravando ou ligado",
      "evite": "Status de sistema em produto comum: store-status ou um ponto do tema, não o LED com halo"
    }
  },
  "categories": [
    "feedback",
    "audio",
    "estado"
  ],
  "type": "registry:ui"
}