{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"price-scoreboard","title":"Price scoreboard","description":"The four numbers atop a pricing page: overall position vs market with its index and trend, then lines priced above, in line and below, each optionally a filter.","registryDependencies":["https://ui.twelfth.ai/r/price-trend.json","https://ui.twelfth.ai/r/retail-format.json"],"files":[{"path":"src/registry/catman/ui/price-scoreboard.tsx","content":"\"use client\"\n\nimport type { ReactNode } from \"react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { formatMarketPosition, formatUnits } from \"@/registry/catman/lib/retail-format\"\nimport { PriceTrend, type PriceTrendPoint } from \"@/registry/catman/ui/price-trend\"\n\n/**\n * The four numbers at the top of a pricing page: where the range sits against\n * the market overall, then how many lines are priced above it, in line with\n * it, and below it. The three counts are filters when `onSelect` is given.\n *\n * Part of the twelfth catman registry (`@twelfth/price-scoreboard`).\n */\nexport type PriceVerdict = \"above\" | \"in_line\" | \"below\"\n\nexport type PriceScoreboardCounts = Record<PriceVerdict, number>\n\nconst TILE = \"flex flex-col justify-start rounded-xl border bg-card px-4 py-3 text-left\"\nconst LINE = \"flex flex-wrap items-baseline gap-x-2 gap-y-0.5\"\n/** A selected filter is spotlit (ink border and a hard 2px offset) so it\n * cannot be mistaken for a hovered one. Nothing moves between states. */\nconst SPOTLIT = \"border-foreground shadow-[0_2px_0_var(--color-foreground)]\"\nconst RECEDED = \"hover:border-foreground/35\"\n\nconst LABELS: Record<PriceVerdict, string> = {\n  above: \"Priced above market\",\n  in_line: \"In line with market\",\n  below: \"Priced below market\",\n}\n\nexport function PriceScoreboard({\n  positionPct,\n  trend = [],\n  counts,\n  unitShares,\n  selected = null,\n  onSelect,\n  info,\n  className,\n}: {\n  /** The range's overall position vs the market, in percent; null when unknown. */\n  positionPct: number | null\n  /** Weekly position history for the sparkline. */\n  trend?: PriceTrendPoint[]\n  counts: PriceScoreboardCounts\n  /** Each verdict's share of recent units, in percent, shown under its count. */\n  unitShares?: Partial<Record<PriceVerdict, number | null>>\n  /** The verdict currently filtering the list, if any. */\n  selected?: PriceVerdict | null\n  /** Makes the three counts filters. Clicking the selected one again should clear it. */\n  onSelect?: (verdict: PriceVerdict) => void\n  /** Sits beside the position, e.g. an (i) explaining the market bands. */\n  info?: ReactNode\n  className?: string\n}) {\n  return (\n    <div className={cn(\"@container w-full\", className)}>\n      <div className=\"grid grid-cols-2 gap-3 @xl:grid-cols-[1.6fr_1fr_1fr_1fr]\">\n        <div role=\"group\" aria-label=\"Position vs market\" className={TILE}>\n          <div className={LINE}>\n            <span className=\"inline-flex items-center gap-1.5\">\n              <span className=\"text-lg font-medium tabular-nums\">{formatMarketPosition(positionPct)}</span>\n              {info}\n            </span>\n            <span className=\"flex items-center gap-2 text-xs text-muted-foreground\">\n              {positionPct !== null ? <span className=\"font-mono\">index {Math.round(100 + positionPct)}</span> : null}\n              {trend.length ? <PriceTrend points={trend} label=\"Position vs market\" width={48} height={16} /> : null}\n            </span>\n          </div>\n        </div>\n        {(Object.keys(LABELS) as PriceVerdict[]).map((verdict) => {\n          const share = unitShares?.[verdict]\n          const body = (\n            <span className={LINE}>\n              <span className=\"text-sm\">{LABELS[verdict]}</span>\n              <span className=\"font-mono text-lg font-medium tabular-nums\">{formatUnits(counts[verdict])}</span>\n              {share != null ? <span className=\"text-xs text-muted-foreground\">{share}% of units</span> : null}\n            </span>\n          )\n          if (!onSelect) return <div key={verdict} className={TILE}>{body}</div>\n          const pressed = selected === verdict\n          return (\n            <button\n              key={verdict}\n              type=\"button\"\n              aria-pressed={pressed}\n              onClick={() => onSelect(verdict)}\n              className={cn(TILE, \"outline-none transition-[border-color,box-shadow] duration-150 focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none\", pressed ? SPOTLIT : RECEDED)}\n            >\n              {body}\n            </button>\n          )\n        })}\n      </div>\n    </div>\n  )\n}\n","type":"registry:ui"}],"type":"registry:ui"}