{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-install-diagnostics",
  "title": "Install diagnostics",
  "description": "Sequential installation stage durations with unit switching.",
  "registryDependencies": [
    "@neumorphism-ui/chart",
    "@neumorphism-ui/select"
  ],
  "files": [
    {
      "path": "src/components/blocks/install-diagnostics-chart.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { Bar, BarChart, CartesianGrid, XAxis, YAxis } from \"recharts\";\n\nimport { ChartContainer, ChartTooltip } from \"@/components/ui/chart\";\nimport { Select, SelectItem } from \"@/components/ui/select\";\n\nconst copy = {\n  \"en\": {\n    \"title\": \"Installation diagnostics\",\n    \"description\": \"Sequential stage durations for one installation trace.\",\n    \"total\": \"Total\",\n    \"longest\": \"Longest stage\",\n    \"empty\": \"No installation trace.\",\n    \"unit\": \"Unit\",\n    \"ms\": \"Milliseconds\",\n    \"seconds\": \"Seconds\",\n    \"table\": \"View installation data\",\n    \"caption\": \"Installation diagnostic data\",\n    \"stage\": \"Stage\",\n    \"duration\": \"Duration\",\n    \"share\": \"Share\",\n    \"stages\": [\n      \"Resolve\",\n      \"Download\",\n      \"Transform\",\n      \"Write\"\n    ]\n  },\n  \"ko\": {\n    \"title\": \"설치 단계 진단\",\n    \"description\": \"한 번의 설치에서 순서대로 실행된 각 단계의 소요 시간입니다.\",\n    \"total\": \"전체 시간\",\n    \"longest\": \"가장 오래 걸린 단계\",\n    \"empty\": \"설치 기록이 없습니다.\",\n    \"unit\": \"단위\",\n    \"ms\": \"밀리초\",\n    \"seconds\": \"초\",\n    \"table\": \"설치 데이터 보기\",\n    \"caption\": \"설치 단계 진단 데이터\",\n    \"stage\": \"단계\",\n    \"duration\": \"소요 시간\",\n    \"share\": \"비율\",\n    \"stages\": [\n      \"의존성 확인\",\n      \"다운로드\",\n      \"변환\",\n      \"파일 쓰기\"\n    ]\n  },\n  \"ja\": {\n    \"title\": \"インストール診断\",\n    \"description\": \"1回のインストールで順番に実行された各工程の所要時間です。\",\n    \"total\": \"合計時間\",\n    \"longest\": \"最長の工程\",\n    \"empty\": \"インストール記録はありません。\",\n    \"unit\": \"単位\",\n    \"ms\": \"ミリ秒\",\n    \"seconds\": \"秒\",\n    \"table\": \"インストールデータを表示\",\n    \"caption\": \"インストール診断データ\",\n    \"stage\": \"工程\",\n    \"duration\": \"所要時間\",\n    \"share\": \"割合\",\n    \"stages\": [\n      \"依存関係\",\n      \"ダウンロード\",\n      \"変換\",\n      \"書き込み\"\n    ]\n  },\n  \"zh\": {\n    \"title\": \"安装诊断\",\n    \"description\": \"一次安装中按顺序执行的各阶段耗时。\",\n    \"total\": \"总耗时\",\n    \"longest\": \"最耗时阶段\",\n    \"empty\": \"暂无安装记录。\",\n    \"unit\": \"单位\",\n    \"ms\": \"毫秒\",\n    \"seconds\": \"秒\",\n    \"table\": \"查看安装数据\",\n    \"caption\": \"安装诊断数据\",\n    \"stage\": \"阶段\",\n    \"duration\": \"耗时\",\n    \"share\": \"占比\",\n    \"stages\": [\n      \"解析依赖\",\n      \"下载\",\n      \"转换\",\n      \"写入\"\n    ]\n  }\n} as const;\n\nexport type InstallDiagnosticPoint = {\n  stage: string;\n  durationMs: number;\n};\n\nexport function InstallDiagnosticsChart({\n  data,\n  locale = \"en\",\n}: {\n  data: readonly InstallDiagnosticPoint[];\n  locale?: keyof typeof copy;\n}) {\n  const t = copy[locale];\n  const [unit, setUnit] = React.useState<\"ms\" | \"s\">(\"ms\");\n  const total = data.reduce((sum, row) => sum + row.durationMs, 0);\n  const largest = data.length ? data.reduce((best, row) => row.durationMs > best.durationMs ? row : best) : null;\n  const format = (value: number) => unit === \"ms\" ? `${value} ms` : `${(value / 1000).toFixed(2)} s`;\n\n  return (\n    <ChartContainer\n      data-chart=\"install-diagnostics\"\n      title={t.title}\n      description={t.description}\n      summary={largest ? `${t.total} ${format(total)} · ${t.longest} ${largest.stage} (${format(largest.durationMs)})` : t.empty}\n      actions={\n        <label className=\"grid gap-1.5 text-xs\">\n          {t.unit}\n          <Select value={unit} onChange={(event) => setUnit(event.target.value as typeof unit)}>\n            <SelectItem value=\"ms\">{t.ms}</SelectItem>\n            <SelectItem value=\"s\">{t.seconds}</SelectItem>\n          </Select>\n        </label>\n      }\n      tableLabel={t.table}\n      emptyLabel={t.empty}\n      empty={!data.length}\n      table={\n        <table>\n          <caption className=\"sr-only\">{t.caption}</caption>\n          <thead><tr><th>{t.stage}</th><th>{t.duration}</th><th>{t.share}</th></tr></thead>\n          <tbody>{data.map((row) => <tr key={row.stage}><th scope=\"row\">{row.stage}</th><td>{format(row.durationMs)}</td><td>{total ? ((row.durationMs / total) * 100).toFixed(1) + \"%\" : \"—\"}</td></tr>)}</tbody>\n        </table>\n      }\n    >\n      <BarChart data={data} layout=\"vertical\" accessibilityLayer margin={{ top: 12, right: 12, bottom: 4, left: 0 }}>\n        <CartesianGrid horizontal={false} stroke=\"var(--border)\" strokeDasharray=\"3 4\" />\n        <XAxis type=\"number\" tickFormatter={(value: number) => format(value)} tick={{ fill: \"var(--muted-foreground)\" }} tickLine={false} axisLine={false} />\n        <YAxis type=\"category\" dataKey=\"stage\" width={locale === \"en\" ? 72 : 88} tick={{ fill: \"var(--muted-foreground)\" }} tickLine={false} axisLine={false} />\n        <ChartTooltip formatter={(value) => format(Number(value))} />\n        <Bar dataKey=\"durationMs\" name={t.duration} fill=\"var(--primary)\" radius={[0, 4, 4, 0]} maxBarSize={42} isAnimationActive={false} />\n      </BarChart>\n    </ChartContainer>\n  );\n}\n\nconst exampleTrace: InstallDiagnosticPoint[] = [\n  { stage: \"Resolve\", durationMs: 120 },\n  { stage: \"Download\", durationMs: 840 },\n  { stage: \"Transform\", durationMs: 210 },\n  { stage: \"Write\", durationMs: 90 },\n];\n\nexport function InstallDiagnosticsExample({ locale = \"en\" }: { locale?: keyof typeof copy }) {\n  const data = exampleTrace.map((point, index) => ({ ...point, stage: copy[locale].stages[index] }));\n  return <InstallDiagnosticsChart data={data} locale={locale} />;\n}\n",
      "type": "registry:component",
      "target": "@components/blocks/install-diagnostics-chart.tsx"
    }
  ],
  "categories": [
    "chart"
  ],
  "type": "registry:block"
}