{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-build-duration",
  "title": "Build duration",
  "author": "andongmin94",
  "description": "Paired cold and cached builds with series controls, time savings, and a budget.",
  "dependencies": [
    "recharts@^3.10.1"
  ],
  "registryDependencies": [
    "https://neobrutal-ui.andongmin.com/r/chart.json",
    "https://neobrutal-ui.andongmin.com/r/card.json"
  ],
  "files": [
    {
      "path": "src/components/ui/chart-build-duration.tsx",
      "content": "\"use client\";\n\nimport { useState } from \"react\";\nimport { CartesianGrid, Line, LineChart, ReferenceLine, XAxis, YAxis } from \"recharts\";\n\nimport { Card, CardContent, CardDescription, CardHeader, CardTitle } from \"@/components/ui/card\";\nimport {\n  ChartContainer,\n  ChartSelect,\n  ChartTooltip,\n  ChartTooltipContent,\n  type ChartConfig,\n} from \"@/components/ui/chart\";\n\nconst builds = [\n  { build: \"B1\", cold: 210, warm: 108 },\n  { build: \"B2\", cold: 195, warm: 102 },\n  { build: \"B3\", cold: 238, warm: 114 },\n  { build: \"B4\", cold: 226, warm: 109 },\n  { build: \"B5\", cold: 204, warm: 96 },\n  { build: \"B6\", cold: 188, warm: 93 },\n];\nconst budget = 220;\nconst config = {\n  cold: { label: \"Cold build\", color: \"var(--foreground)\" },\n  warm: {\n    label: \"Cached build\",\n    color: \"color-mix(in srgb, var(--chart-2) 50%, var(--foreground))\",\n  },\n} satisfies ChartConfig;\n\nexport default function ChartBuildDuration() {\n  const [range, setRange] = useState(\"6\");\n  const [series, setSeries] = useState(\"both\");\n  const data = builds.slice(-Number(range));\n  const coldMean = data.reduce((total, row) => total + row.cold, 0) / data.length;\n  const warmMean = data.reduce((total, row) => total + row.warm, 0) / data.length;\n  const breaches = data.filter((row) => row.cold > budget).length;\n\n  return (\n    <Card className=\"min-w-0\" data-chart-recipe=\"builds\">\n      <CardHeader>\n        <p className=\"font-mono text-xs uppercase tracking-widest\">\n          Builds / Make the comparison explicit\n        </p>\n        <CardTitle>\n          <h3>Build duration</h3>\n        </CardTitle>\n        <CardDescription>\n          Paired cold and cached runs in seconds. Illustrative measurements of the same builds.\n        </CardDescription>\n      </CardHeader>\n      <CardContent className=\"grid min-w-0 gap-6\">\n        <div className=\"flex flex-wrap gap-4\">\n          <ChartSelect\n            label=\"Build period\"\n            value={range}\n            onValueChange={setRange}\n            options={[\n              { value: \"6\", label: \"All 6 builds\" },\n              { value: \"3\", label: \"Latest 3 builds\" },\n            ]}\n          />\n          <ChartSelect\n            label=\"Visible build series\"\n            value={series}\n            onValueChange={setSeries}\n            options={[\n              { value: \"both\", label: \"Both series\" },\n              { value: \"cold\", label: \"Cold only\" },\n              { value: \"warm\", label: \"Cached only\" },\n            ]}\n          />\n        </div>\n        <dl className=\"grid gap-4 border-y-2 border-border py-4 sm:grid-cols-3\" aria-live=\"polite\">\n          {[\n            [\"Mean cold run\", `${coldMean.toFixed(1)} s`],\n            [\"Mean cached run\", `${warmMean.toFixed(1)} s`],\n            [\"Mean time saved\", `${(coldMean - warmMean).toFixed(1)} s`],\n          ].map(([label, value]) => (\n            <div key={label}>\n              <dt className=\"text-xs\">{label}</dt>\n              <dd className=\"mt-1 text-2xl font-heading tabular-nums\">{value}</dd>\n            </div>\n          ))}\n        </dl>\n        <figure aria-label=\"Cold and cached build duration in seconds\" className=\"min-w-0\">\n          <ChartContainer config={config} className=\"h-72 w-full min-w-0 aspect-auto\">\n            <LineChart\n              accessibilityLayer\n              data={data}\n              margin={{ top: 12, right: 12, left: 0, bottom: 0 }}\n            >\n              <CartesianGrid vertical={false} />\n              <XAxis dataKey=\"build\" tickLine={false} axisLine={false} tickMargin={10} />\n              <YAxis\n                width={48}\n                domain={[0, 300]}\n                tickLine={false}\n                axisLine={false}\n                tickFormatter={(value) => `${value}s`}\n              />\n              <ReferenceLine y={budget} stroke=\"var(--foreground)\" strokeDasharray=\"2 5\" />\n              <ChartTooltip\n                content={\n                  <ChartTooltipContent\n                    formatter={(value, name) =>\n                      `${name === \"cold\" ? \"Cold\" : \"Cached\"}: ${value} s`\n                    }\n                  />\n                }\n              />\n              {series !== \"warm\" && (\n                <Line\n                  dataKey=\"cold\"\n                  type=\"linear\"\n                  stroke=\"var(--color-cold)\"\n                  strokeWidth={3}\n                  dot={{ r: 4, fill: \"var(--color-cold)\" }}\n                  isAnimationActive={false}\n                />\n              )}\n              {series !== \"cold\" && (\n                <Line\n                  dataKey=\"warm\"\n                  type=\"linear\"\n                  stroke=\"var(--color-warm)\"\n                  strokeWidth={2}\n                  strokeDasharray=\"8 4\"\n                  dot={{ r: 4, fill: \"var(--secondary-background)\", strokeWidth: 2 }}\n                  isAnimationActive={false}\n                />\n              )}\n            </LineChart>\n          </ChartContainer>\n          <figcaption className=\"mt-3 text-xs leading-5\">\n            Solid / filled dots: cold. Dashed / open dots: cached. Dotted horizontal line: 220 s\n            cold-run budget.\n          </figcaption>\n        </figure>\n        <output className=\"border-l-4 border-main pl-3 text-sm leading-6\">\n          {breaches} of {data.length} cold runs exceeded budget. Summaries and the table compare\n          both runs even when a plotted series is hidden.\n        </output>\n        <details className=\"min-w-0 border-t-2 border-border pt-4\">\n          <summary className=\"cursor-pointer text-sm font-heading\">View build data</summary>\n          <table className=\"mt-3 w-full text-left text-xs tabular-nums\">\n            <caption className=\"pb-3 text-left\">\n              Paired run durations. Time saved is cold minus cached, in seconds.\n            </caption>\n            <thead>\n              <tr>\n                {[\"Build\", \"Cold (s)\", \"Cached (s)\", \"Saved (s)\"].map((label) => (\n                  <th key={label} scope=\"col\" className=\"border-b-2 border-border py-2 pr-2\">\n                    {label}\n                  </th>\n                ))}\n              </tr>\n            </thead>\n            <tbody>\n              {data.map((row) => (\n                <tr key={row.build}>\n                  <th scope=\"row\" className=\"py-3 pr-2\">\n                    {row.build}\n                  </th>\n                  <td>{row.cold}</td>\n                  <td>{row.warm}</td>\n                  <td>{row.cold - row.warm}</td>\n                </tr>\n              ))}\n            </tbody>\n          </table>\n        </details>\n      </CardContent>\n    </Card>\n  );\n}\n",
      "type": "registry:ui"
    }
  ],
  "categories": [
    "data-display",
    "data-visualization",
    "recipe"
  ],
  "type": "registry:component"
}