{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chart-service-latency",
  "title": "Service latency",
  "description": "p50 and p95 service latency against an explicit p95 budget.",
  "registryDependencies": [
    "@neumorphism-ui/chart"
  ],
  "files": [
    {
      "path": "src/components/blocks/service-latency-chart.tsx",
      "content": "\"use client\";\n\nimport { CartesianGrid, Line, LineChart, ReferenceLine, XAxis, YAxis } from \"recharts\";\n\nimport { ChartContainer, ChartTooltip, ChartLegend } from \"@/components/ui/chart\";\n\nconst copy = {\n  \"en\": {\n    \"title\": \"Service latency\",\n    \"description\": \"Daily p50 and p95 response time against a p95 budget.\",\n    \"worst\": \"Worst p95\",\n    \"overBudget\": \"periods over budget\",\n    \"empty\": \"No latency samples.\",\n    \"table\": \"View latency data\",\n    \"caption\": \"Service latency data\",\n    \"period\": \"Period\",\n    \"budget\": \"Budget\",\n    \"over\": \"Over\",\n    \"within\": \"Within\",\n    \"days\": [\n      \"Mon\",\n      \"Tue\",\n      \"Wed\",\n      \"Thu\",\n      \"Fri\",\n      \"Sat\",\n      \"Sun\"\n    ]\n  },\n  \"ko\": {\n    \"title\": \"서비스 지연 시간\",\n    \"description\": \"일별 p50·p95 응답 시간과 p95 목표값을 비교합니다.\",\n    \"worst\": \"최대 p95\",\n    \"overBudget\": \"기간에서 목표 초과\",\n    \"empty\": \"지연 시간 데이터가 없습니다.\",\n    \"table\": \"지연 시간 데이터 보기\",\n    \"caption\": \"서비스 지연 시간 데이터\",\n    \"period\": \"기간\",\n    \"budget\": \"목표\",\n    \"over\": \"초과\",\n    \"within\": \"이내\",\n    \"days\": [\n      \"월\",\n      \"화\",\n      \"수\",\n      \"목\",\n      \"금\",\n      \"토\",\n      \"일\"\n    ]\n  },\n  \"ja\": {\n    \"title\": \"サービスの応答時間\",\n    \"description\": \"日別のp50・p95応答時間をp95の目標値と比較します。\",\n    \"worst\": \"最大p95\",\n    \"overBudget\": \"期間で目標超過\",\n    \"empty\": \"応答時間データはありません。\",\n    \"table\": \"応答時間データを表示\",\n    \"caption\": \"サービス応答時間データ\",\n    \"period\": \"期間\",\n    \"budget\": \"目標\",\n    \"over\": \"超過\",\n    \"within\": \"以内\",\n    \"days\": [\n      \"月\",\n      \"火\",\n      \"水\",\n      \"木\",\n      \"金\",\n      \"土\",\n      \"日\"\n    ]\n  },\n  \"zh\": {\n    \"title\": \"服务延迟\",\n    \"description\": \"比较每日p50、p95响应时间与p95目标值。\",\n    \"worst\": \"最高p95\",\n    \"overBudget\": \"个时段超出目标\",\n    \"empty\": \"暂无延迟数据。\",\n    \"table\": \"查看延迟数据\",\n    \"caption\": \"服务延迟数据\",\n    \"period\": \"时段\",\n    \"budget\": \"目标\",\n    \"over\": \"超出\",\n    \"within\": \"范围内\",\n    \"days\": [\n      \"周一\",\n      \"周二\",\n      \"周三\",\n      \"周四\",\n      \"周五\",\n      \"周六\",\n      \"周日\"\n    ]\n  }\n} as const;\n\nexport type ServiceLatencyPoint = {\n  label: string;\n  p50Ms: number;\n  p95Ms: number;\n};\n\nexport function ServiceLatencyChart({\n  data,\n  budgetMs = 300,\n  locale = \"en\",\n}: {\n  data: readonly ServiceLatencyPoint[];\n  budgetMs?: number;\n  locale?: keyof typeof copy;\n}) {\n  const t = copy[locale];\n  const number = new Intl.NumberFormat(locale);\n  const worst = data.length ? Math.max(...data.map((row) => row.p95Ms)) : 0;\n  const breaches = data.filter((row) => row.p95Ms > budgetMs);\n\n  return (\n    <ChartContainer\n      data-chart=\"service-latency\"\n      title={t.title}\n      description={t.description}\n      summary={data.length ? `${t.worst} ${number.format(worst)} ms · ${breaches.length}/${data.length} ${t.overBudget}` : t.empty}\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.period}</th><th>p50 (ms)</th><th>p95 (ms)</th><th>{t.budget}</th></tr></thead>\n          <tbody>{data.map((row) => <tr key={row.label}><th scope=\"row\">{row.label}</th><td>{row.p50Ms}</td><td>{row.p95Ms}</td><td>{row.p95Ms > budgetMs ? t.over : t.within}</td></tr>)}</tbody>\n        </table>\n      }\n    >\n      <LineChart data={data} accessibilityLayer margin={{ top: 12, right: 12, bottom: 4, left: 0 }}>\n        <CartesianGrid vertical={false} stroke=\"var(--border)\" strokeDasharray=\"3 4\" />\n        <XAxis dataKey=\"label\" tick={{ fill: \"var(--muted-foreground)\" }} tickLine={false} axisLine={false} />\n        <YAxis domain={[0, \"auto\"]} width={52} tickFormatter={(value: number) => `${value}ms`} tick={{ fill: \"var(--muted-foreground)\" }} tickLine={false} axisLine={false} />\n        <ChartLegend reference={{ value: `${t.budget} ${number.format(budgetMs)} ms`, color: \"var(--destructive)\", dashArray: \"4 4\" }} />\n        <ReferenceLine ifOverflow=\"extendDomain\" y={budgetMs} stroke=\"var(--destructive)\" strokeDasharray=\"4 4\" />\n        <ChartTooltip formatter={(value) => `${Number(value)} ms`} />\n        <Line dataKey=\"p50Ms\" name=\"p50\" legendType=\"plainline\" stroke=\"var(--muted-foreground)\" strokeWidth={2} strokeDasharray=\"7 4\" dot={false} isAnimationActive={false} />\n        <Line dataKey=\"p95Ms\" name=\"p95\" legendType=\"plainline\" stroke=\"var(--primary)\" strokeWidth={2.5} dot={{ r: 3 }} isAnimationActive={false} />\n      </LineChart>\n    </ChartContainer>\n  );\n}\n\nconst exampleLatency: ServiceLatencyPoint[] = [\n  { label: \"Mon\", p50Ms: 80, p95Ms: 210 },\n  { label: \"Tue\", p50Ms: 76, p95Ms: 195 },\n  { label: \"Wed\", p50Ms: 95, p95Ms: 340 },\n  { label: \"Thu\", p50Ms: 130, p95Ms: 470 },\n  { label: \"Fri\", p50Ms: 100, p95Ms: 330 },\n  { label: \"Sat\", p50Ms: 82, p95Ms: 240 },\n  { label: \"Sun\", p50Ms: 79, p95Ms: 215 },\n];\n\nexport function ServiceLatencyExample({ locale = \"en\" }: { locale?: keyof typeof copy }) {\n  const data = exampleLatency.map((point, index) => ({ ...point, label: copy[locale].days[index] }));\n  return <ServiceLatencyChart data={data} locale={locale} />;\n}\n",
      "type": "registry:component",
      "target": "@components/blocks/service-latency-chart.tsx"
    }
  ],
  "categories": [
    "chart"
  ],
  "type": "registry:block"
}