{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "analytics-02",
  "type": "registry:block",
  "description": "A traffic sources breakdown with switchable ranges and bar meters.",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/designali/blocks/analytics/analytics-02.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\n\nimport { cn } from \"@workspace/ui/lib/utils\"\n\nimport { CounterNumber } from \"@/registry/designali/ui/counter-number\"\n\nconst ranges = {\n  \"7d\": [320, 410, 380, 460, 520, 490, 610],\n  \"30d\": [280, 340, 390, 360, 420, 470, 450, 510, 560, 530, 590, 640, 620, 680],\n  \"90d\": [210, 260, 300, 340, 330, 380, 420, 460, 440, 500, 540, 580],\n} as const\n\ntype Range = keyof typeof ranges\n\nconst sources = [\n  { name: \"Google search\", share: 42, color: \"var(--chart-1)\" },\n  { name: \"Direct\", share: 24, color: \"var(--chart-2)\" },\n  { name: \"21st.dev\", share: 18, color: \"var(--chart-3)\" },\n  { name: \"Instagram & X\", share: 11, color: \"var(--chart-4)\" },\n  { name: \"Newsletter\", share: 5, color: \"var(--chart-5)\" },\n]\n\nexport default function Analytics02() {\n  const [range, setRange] = useState<Range>(\"30d\")\n  const data = ranges[range]\n  const max = Math.max(...data)\n  const total = data.reduce((sum, v) => sum + v, 0)\n\n  return (\n    <section className=\"w-full bg-muted/40 px-6 py-16 text-foreground md:py-24\">\n      <div className=\"mx-auto grid max-w-6xl gap-px border border-border bg-border lg:grid-cols-3\">\n        <div className=\"bg-background p-6 md:p-8 lg:col-span-2\">\n          <div className=\"flex flex-wrap items-start justify-between gap-4\">\n            <div>\n              <p className=\"text-xs text-muted-foreground\">Unique visitors on designali.com</p>\n              <CounterNumber\n                value={total}\n                className=\"mt-1 block text-4xl font-semibold tracking-tight\"\n              />\n            </div>\n            <div className=\"flex border border-border\">\n              {(Object.keys(ranges) as Range[]).map((key) => (\n                <button\n                  key={key}\n                  type=\"button\"\n                  onClick={() => setRange(key)}\n                  className={cn(\n                    \"px-3 py-1.5 text-xs transition-colors not-last:border-r not-last:border-border\",\n                    range === key\n                      ? \"bg-foreground text-background\"\n                      : \"text-muted-foreground hover:bg-muted\"\n                  )}\n                >\n                  {key}\n                </button>\n              ))}\n            </div>\n          </div>\n\n          <div className=\"mt-10 flex h-64 items-end gap-1.5 md:gap-2\">\n            {data.map((value, i) => (\n              <div key={i} className=\"group relative flex h-full flex-1 items-end\">\n                <div\n                  className=\"w-full bg-primary/80 transition-colors group-hover:bg-primary\"\n                  style={{ height: `${(value / max) * 100}%` }}\n                />\n                <span className=\"pointer-events-none absolute -top-6 left-1/2 -translate-x-1/2 border border-border bg-background px-1.5 py-0.5 text-[10px] opacity-0 transition-opacity group-hover:opacity-100\">\n                  {value}\n                </span>\n              </div>\n            ))}\n          </div>\n          <div className=\"mt-2 border-t border-border pt-2 text-[10px] text-muted-foreground\">\n            Hover a bar to see daily totals\n          </div>\n        </div>\n\n        <div className=\"bg-background p-6 md:p-8\">\n          <p className=\"text-sm font-medium\">Where visitors come from</p>\n          <div className=\"mt-6 flex h-3 w-full\">\n            {sources.map((source) => (\n              <div\n                key={source.name}\n                style={{ width: `${source.share}%`, background: source.color }}\n              />\n            ))}\n          </div>\n          <ul className=\"mt-8 divide-y divide-border\">\n            {sources.map((source) => (\n              <li key={source.name} className=\"flex items-center justify-between py-3 text-sm\">\n                <span className=\"flex items-center gap-2\">\n                  <span className=\"size-2.5\" style={{ background: source.color }} />\n                  {source.name}\n                </span>\n                <span className=\"font-sans text-muted-foreground\">{source.share}%</span>\n              </li>\n            ))}\n          </ul>\n        </div>\n      </div>\n    </section>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "meta": {
    "iframeHeight": "700px"
  },
  "categories": [
    "analytics"
  ]
}