{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hud-bar-chart",
  "type": "registry:ui",
  "title": "HUD Bar Chart",
  "description": "Dependency-free categorical bar chart: vertical or horizontal, grouped series with 2px surface gaps and per-bar hover readout.",
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "registry/hud/hud-bar-chart.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cn } from \"@/lib/utils\"\n\n// Categorical comparison, built from plain elements rather than SVG so axis type\n// stays real text at the kit's 10px minimum. Distinct in role from telemetry-bar\n// (one labelled progress bar) and segment-bar (a tick scale).\n//\n// Series share the validated monochrome order used by hud-line-chart: lightness\n// steps, not hues. --chart-5 (red) stays reserved for status. Bars carry a 2px\n// surface gap so adjacent steps never bleed together, and data-ends are square —\n// the kit is radius 0 by design.\nconst SERIES_COLORS = [\n  \"var(--chart-1)\", // #FF7A29 accent\n  \"var(--chart-3)\", // #C8CCCE\n  \"var(--chart-2)\", // #8A9094\n  \"var(--chart-4)\", // #5A6065\n]\n\ntype BarGroup = {\n  label: string\n  values: number[]\n}\n\nfunction HudBarChart({\n  className,\n  data,\n  series,\n  max: maxProp,\n  unit = \"\",\n  height = 200,\n  horizontal = false,\n  legend = true,\n  ...props\n}: Omit<React.ComponentProps<\"div\">, \"children\"> & {\n  data: BarGroup[]\n  /** Series names. Required when groups hold more than one value. */\n  series?: string[]\n  max?: number\n  unit?: string\n  /** Plot height in px. Ignored when horizontal. */\n  height?: number\n  horizontal?: boolean\n  legend?: boolean\n}) {\n  const [hover, setHover] = React.useState<string | null>(null)\n  const max = maxProp ?? (Math.max(...data.flatMap((d) => d.values), 0) || 1)\n  const names = series ?? []\n\n  const swatch = (i: number) => SERIES_COLORS[i % SERIES_COLORS.length]\n\n  const readout = (g: BarGroup, si: number) => (\n    <div className=\"pointer-events-none absolute bottom-full left-1/2 z-10 mb-1.5 -translate-x-1/2 border border-border bg-popover px-2 py-1 whitespace-nowrap\">\n      <span className=\"font-mono text-[10px] uppercase tracking-[0.12em] text-[#7A8085]\">\n        {names[si] ? `${names[si]} // ` : \"\"}\n        {g.label}\n      </span>\n      <span className=\"ml-2 font-mono text-[10px] text-[#D4D8DA]\">\n        {g.values[si]}\n        {unit}\n      </span>\n    </div>\n  )\n\n  return (\n    <div className={cn(\"w-full\", className)} {...props}>\n      {legend && names.length > 1 && (\n        <div className=\"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1\">\n          {names.map((n, i) => (\n            <span key={n} className=\"flex items-center gap-1.5\">\n              <span className=\"size-2\" style={{ background: swatch(i) }} />\n              <span className=\"font-mono text-[10px] uppercase tracking-[0.14em] text-[#7A8085]\">\n                {n}\n              </span>\n            </span>\n          ))}\n        </div>\n      )}\n\n      {horizontal ? (\n        <div className=\"flex flex-col gap-2\">\n          {data.map((g) => (\n            <div key={g.label} className=\"flex items-center gap-3\">\n              <span className=\"w-20 shrink-0 truncate text-right font-mono text-[10px] uppercase tracking-[0.12em] text-[#5A6065]\">\n                {g.label}\n              </span>\n              <div className=\"flex flex-1 flex-col gap-0.5\">\n                {g.values.map((v, si) => (\n                  <div\n                    key={si}\n                    className=\"relative h-2.5 bg-[#14171A]\"\n                    onMouseEnter={() => setHover(`${g.label}-${si}`)}\n                    onMouseLeave={() => setHover(null)}\n                  >\n                    <div\n                      className=\"h-full\"\n                      style={{\n                        width: `${Math.max(0, Math.min(1, v / max)) * 100}%`,\n                        background: swatch(si),\n                      }}\n                    />\n                    {hover === `${g.label}-${si}` && readout(g, si)}\n                  </div>\n                ))}\n              </div>\n              {/* Trailing readout only makes sense for a single series; grouped\n                  rows would silently show just the first value. */}\n              {g.values.length === 1 && (\n                <span className=\"w-12 shrink-0 font-mono text-[10px] text-[#D4D8DA]\">\n                  {g.values[0]}\n                  {unit}\n                </span>\n              )}\n            </div>\n          ))}\n        </div>\n      ) : (\n        <div>\n          <div className=\"flex items-end gap-2\" style={{ height }}>\n            {data.map((g) => (\n              <div key={g.label} className=\"flex h-full flex-1 items-end gap-0.5\">\n                {g.values.map((v, si) => (\n                  <div\n                    key={si}\n                    className=\"relative flex h-full flex-1 items-end\"\n                    onMouseEnter={() => setHover(`${g.label}-${si}`)}\n                    onMouseLeave={() => setHover(null)}\n                  >\n                    <div\n                      className=\"w-full\"\n                      style={{\n                        height: `${Math.max(0, Math.min(1, v / max)) * 100}%`,\n                        background: swatch(si),\n                      }}\n                    />\n                    {hover === `${g.label}-${si}` && readout(g, si)}\n                  </div>\n                ))}\n              </div>\n            ))}\n          </div>\n          <div className=\"mt-1.5 flex gap-2 border-t border-[#1D2023] pt-1.5\">\n            {data.map((g) => (\n              <span\n                key={g.label}\n                className=\"flex-1 truncate text-center font-mono text-[10px] uppercase tracking-[0.12em] text-[#5A6065]\"\n              >\n                {g.label}\n              </span>\n            ))}\n          </div>\n        </div>\n      )}\n    </div>\n  )\n}\n\nexport { HudBarChart, type BarGroup }\n",
      "type": "registry:ui"
    }
  ]
}