{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bar-chart",
  "type": "registry:component",
  "title": "Grouped bars",
  "description": "Organize related observations into periods and call out the group that needs attention.",
  "categories": [
    "charts"
  ],
  "dependencies": [
    "recharts-analytics@npm:recharts@3.10.1"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/registry/overtrue/bar-chart.tsx",
      "type": "registry:component",
      "target": "components/overtrue/bar-chart.tsx",
      "content": "/** Adapted from dashboardcn (MIT), copyright 2026 dashboardcn contributors.\n * Source: https://github.com/NoahGdev/dashboardcn/tree/b1ffacbca0f7a0be60135c8665b9e8c267205c48\n *\n * MIT License\n *\n * Copyright (c) 2026 dashboardcn contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n * ---\n *\n * Portions of this project are derived from shadcn/ui and shadcn/registry-template\n * (https://github.com/shadcn-ui/ui), Copyright (c) 2023 shadcn, licensed under the\n * MIT License. The notice above applies to those portions as well.\n */\n\"use client\";\n\nimport * as React from \"react\";\nimport {\n  Bar,\n  BarChart as RechartsBarChart,\n  CartesianGrid,\n  Rectangle,\n  ReferenceLine,\n  XAxis,\n  YAxis,\n  useActiveTooltipDataPoints,\n  type BarProps,\n  type BarShapeProps,\n} from \"recharts-analytics\";\n\nimport { cn } from \"@/lib/utils\";\nimport { ChartContainer, ChartTooltip } from \"./analytics-chart\";\n\nexport type BarRow = Record<string, unknown>;\n\nexport interface BarReferenceLine {\n  /** Horizontal line at this y value. */\n  y: number;\n  label?: string;\n  /** Any CSS color. Defaults to the muted foreground. */\n  color?: string;\n  /** Defaults to dashed. */\n  dashed?: boolean;\n}\n\nexport interface BarChartProps extends Omit<\n  React.ComponentProps<typeof ChartContainer>,\n  \"config\" | \"children\"\n> {\n  data: BarRow[];\n  /** Key of the x-axis value in each row. */\n  xKey: string;\n  /** Key of the bar value in each row. */\n  yKey: string;\n  /**\n   * Key of a coarser label, e.g. \"month\" for weekly rows. When set, the x-axis\n   * shows one tick per group centered under its bars instead of a tick per bar.\n   */\n  groupKey?: string;\n  /** \"gradient\" fades each bar toward the bottom; \"striped\" fills it with diagonal bands. */\n  variant?: \"gradient\" | \"striped\" | \"solid\";\n  /** Any CSS color for highlighted bars. Defaults to chart-1. */\n  color?: string;\n  /** Any CSS color for bars that are not highlighted. Defaults to the muted foreground. */\n  mutedColor?: string;\n  /** Return true for bars drawn in color. Every bar is highlighted when omitted. */\n  highlight?: (row: BarRow, index: number) => boolean;\n  grid?: \"dashed\" | \"solid\" | \"none\";\n  showYAxis?: boolean;\n  showTooltip?: boolean;\n  /** Draw a hollow ring on top of the hovered bar. */\n  showActiveMarker?: boolean;\n  barRadius?: number;\n  /** Animate bars after hydration and when data changes. Respects reduced motion. */\n  animate?: boolean;\n  animationDuration?: number;\n  /** Horizontal lines, e.g. a goal or an average. The y-axis extends to fit them. */\n  referenceLines?: BarReferenceLine[];\n  xFormatter?: (value: unknown) => string;\n  yFormatter?: (value: number) => string;\n  /** Secondary line of the tooltip. Defaults to the formatted x value. */\n  tooltipLabel?: (row: BarRow, index: number) => React.ReactNode;\n  onBarClick?: (row: BarRow, index: number) => void;\n}\n\n/** Keyboard focus on the plot gets the shared primary ring. */\nconst FOCUS =\n  \"[&_.recharts-surface:focus-visible]:rounded-lg [&_.recharts-surface:focus-visible]:shadow-[0_0_0_2px_color-mix(in_oklab,var(--color-primary)_30%,transparent)]\";\n\nconst reducedMotionQuery = \"(prefers-reduced-motion: reduce)\";\n\nfunction subscribeToReducedMotion(onChange: () => void) {\n  const query = window.matchMedia(reducedMotionQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n}\n\nfunction getReducedMotionSnapshot() {\n  return window.matchMedia(reducedMotionQuery).matches;\n}\n\nfunction getReducedMotionServerSnapshot() {\n  return true;\n}\n\nfunction defaultXFormatter(value: unknown) {\n  if (typeof value === \"string\" && /^\\d{4}-\\d{2}-\\d{2}/.test(value)) {\n    const [y, m, d] = value.split(\"-\").map(Number);\n    return new Date(y!, m! - 1, d).toLocaleDateString(\"en-US\", {\n      month: \"short\",\n      day: \"numeric\",\n    });\n  }\n  return String(value);\n}\n\n/** One tick per group, placed under the middle bar of the group. */\nfunction groupTicks(data: BarRow[], groupKey: string) {\n  const labels: string[] = Array.from({ length: data.length }, () => \"\");\n  let start = 0;\n  for (let i = 1; i <= data.length; i++) {\n    if (i === data.length || data[i]![groupKey] !== data[start]![groupKey]) {\n      labels[Math.floor((start + i - 1) / 2)] = String(\n        data[start]![groupKey] ?? \"\",\n      );\n      start = i;\n    }\n  }\n  return labels;\n}\n\n/* ------------------------------------------------------------ visual tokens */\n\nconst GRID = \"color-mix(in oklab, var(--color-foreground) 7%, transparent)\";\nconst TICK = { fontSize: 11, fill: \"var(--color-muted-foreground)\" };\n/** cubic-bezier(0.22, 1, 0.36, 1) is the ease-out-quint curve. */\nconst easeOut = (t: number) => 1 - Math.pow(1 - t, 5);\nconst clamp01 = (t: number) => Math.min(1, Math.max(0, t));\nconst mix = (from: number, to: number, t: number) => from + (to - from) * t;\n\ntype BarInterpolate = NonNullable<BarProps[\"animationInterpolateFn\"]>;\n\n/**\n * Bars rise from the baseline one after another on entrance and glide on\n * updates. Recharts runs the clock linearly; each bar applies its own delay and easing.\n */\nfunction barTween(count: number, duration: number) {\n  const step = count > 1 ? Math.min(28, 360 / (count - 1)) : 0;\n  const total = duration + step * Math.max(count - 1, 0);\n  const interpolate: BarInterpolate = (items, elapsed) => {\n    if (items == null) return [];\n    const entering = items.every((item) => item.status === \"added\");\n    return items.flatMap((item, index) => {\n      const t =\n        elapsed >= 1\n          ? 1\n          : easeOut(\n              clamp01(\n                (elapsed * total - (entering ? index * step : 0)) / duration,\n              ),\n            );\n      if (item.status === \"removed\") {\n        if (t >= 1) return [];\n        const prev = item.prev;\n        return [\n          {\n            ...prev,\n            height: mix(prev.height, 0, t),\n            y: mix(prev.y, prev.y + prev.height, t),\n          },\n        ];\n      }\n      if (item.status === \"matched\") {\n        const { prev, next } = item;\n        return [\n          {\n            ...next,\n            x: mix(prev.x, next.x, t),\n            y: mix(prev.y, next.y, t),\n            width: mix(prev.width, next.width, t),\n            height: mix(prev.height, next.height, t),\n          },\n        ];\n      }\n      const next = item.next;\n      return [\n        {\n          ...next,\n          height: mix(0, next.height, t),\n          y: mix(next.stackedBarStart, next.y, t),\n        },\n      ];\n    });\n  };\n  return { interpolate, total };\n}\n\n/** A bar that dims while another bar is hovered or focused, with an optional ring marker. */\nfunction BarShape({\n  fill,\n  on,\n  color,\n  mutedColor,\n  marker,\n  ...props\n}: BarShapeProps & {\n  fill: string;\n  on: boolean;\n  color: string;\n  mutedColor: string;\n  marker: boolean;\n}) {\n  const active = useActiveTooltipDataPoints();\n  const hovering = active != null && active.length > 0;\n  const isActive = hovering && active.includes(props.payload);\n  const { x, y, width, height } = props;\n  const accent = on ? color : mutedColor;\n  return (\n    <g\n      data-slot=\"bar-chart-bar\"\n      data-active={isActive || undefined}\n      className=\"transition-opacity duration-150 ease-out motion-reduce:transition-none\"\n      style={{ opacity: hovering && !isActive ? 0.4 : 1 }}\n    >\n      <Rectangle {...props} fill={fill} />\n      {marker && isActive && height > 0 ? (\n        <g data-slot=\"bar-chart-marker\" pointerEvents=\"none\">\n          <circle\n            cx={x + width / 2}\n            cy={y}\n            r={9}\n            fill={accent}\n            fillOpacity={0.18}\n          />\n          <circle\n            cx={x + width / 2}\n            cy={y}\n            r={4}\n            fill=\"var(--color-card)\"\n            stroke={accent}\n            strokeWidth={2}\n          />\n        </g>\n      ) : null}\n    </g>\n  );\n}\n\n/** A single-series bar chart with gradient or striped fills, highlighted bars, and a hover marker. */\nfunction BarChart({\n  data,\n  xKey,\n  yKey,\n  groupKey,\n  variant = \"gradient\",\n  color = \"var(--color-chart-1)\",\n  mutedColor = \"var(--color-muted-foreground)\",\n  highlight,\n  grid = \"dashed\",\n  showYAxis = false,\n  showTooltip = true,\n  showActiveMarker = true,\n  barRadius = 6,\n  animate = true,\n  animationDuration = 500,\n  referenceLines = [],\n  xFormatter = defaultXFormatter,\n  yFormatter,\n  tooltipLabel,\n  onBarClick,\n  className,\n  ...props\n}: BarChartProps) {\n  const id = React.useId().replace(/:/g, \"\");\n  const reducedMotion = React.useSyncExternalStore(\n    subscribeToReducedMotion,\n    getReducedMotionSnapshot,\n    getReducedMotionServerSnapshot,\n  );\n  const isHighlighted = React.useCallback(\n    (index: number) => (highlight ? highlight(data[index]!, index) : true),\n    [data, highlight],\n  );\n  const tickLabels = React.useMemo(\n    () => (groupKey ? groupTicks(data, groupKey) : null),\n    [data, groupKey],\n  );\n  const tween = React.useMemo(\n    () => barTween(data.length, animationDuration),\n    [data.length, animationDuration],\n  );\n  const fillFor = (index: number) =>\n    `url(#${id}-${isHighlighted(index) ? \"on\" : \"off\"})`;\n  const format = (value: number) =>\n    yFormatter ? yFormatter(value) : value.toLocaleString();\n\n  return (\n    <ChartContainer\n      data-slot=\"bar-chart\"\n      data-variant={variant}\n      config={{ [yKey]: { label: yKey, color } }}\n      className={cn(\"aspect-auto h-64 w-full tabular-nums\", FOCUS, className)}\n      {...props}\n    >\n      <RechartsBarChart\n        data={data}\n        margin={{ top: 14, right: 8, bottom: 0, left: showYAxis ? 0 : 8 }}\n        barCategoryGap=\"28%\"\n      >\n        <defs>\n          {variant === \"gradient\" ? (\n            <>\n              <linearGradient id={`${id}-on`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n                <stop offset=\"0%\" stopColor={color} stopOpacity={1} />\n                <stop offset=\"100%\" stopColor={color} stopOpacity={0.72} />\n              </linearGradient>\n              <linearGradient id={`${id}-off`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n                <stop offset=\"0%\" stopColor={mutedColor} stopOpacity={0.3} />\n                <stop offset=\"100%\" stopColor={mutedColor} stopOpacity={0.16} />\n              </linearGradient>\n            </>\n          ) : variant === \"striped\" ? (\n            <>\n              {([\"on\", \"off\"] as const).map((state) => {\n                const fill = state === \"on\" ? color : mutedColor;\n                const base = state === \"on\" ? 0.42 : 0.14;\n                const band = state === \"on\" ? 1 : 0.32;\n                return (\n                  <pattern\n                    key={state}\n                    id={`${id}-${state}`}\n                    patternUnits=\"userSpaceOnUse\"\n                    width={6}\n                    height={6}\n                    patternTransform=\"rotate(45)\"\n                  >\n                    <rect width={6} height={6} fill={fill} fillOpacity={base} />\n                    <rect width={2.5} height={6} fill={fill} fillOpacity={band} />\n                  </pattern>\n                );\n              })}\n            </>\n          ) : (\n            <>\n              <linearGradient id={`${id}-on`}>\n                <stop stopColor={color} />\n              </linearGradient>\n              <linearGradient id={`${id}-off`}>\n                <stop stopColor={mutedColor} stopOpacity={0.3} />\n              </linearGradient>\n            </>\n          )}\n        </defs>\n        {grid !== \"none\" ? (\n          <CartesianGrid\n            vertical={false}\n            stroke={GRID}\n            strokeDasharray={grid === \"dashed\" ? \"3 5\" : undefined}\n          />\n        ) : null}\n        <XAxis\n          dataKey={xKey}\n          tickLine={false}\n          axisLine={false}\n          tickMargin={10}\n          tick={TICK}\n          interval={tickLabels ? 0 : \"preserveStartEnd\"}\n          minTickGap={tickLabels ? 0 : 24}\n          tickFormatter={\n            tickLabels\n              ? (_, index) => tickLabels[index] ?? \"\"\n              : (v) => xFormatter(v)\n          }\n        />\n        <YAxis\n          hide={!showYAxis}\n          tickLine={false}\n          axisLine={false}\n          tickMargin={8}\n          tick={TICK}\n          width={44}\n          tickFormatter={yFormatter}\n        />\n        <ChartTooltip\n          cursor={false}\n          isAnimationActive={false}\n          content={({ active, payload }) => {\n            const entry = payload?.[0];\n            if (!showTooltip || !active || !entry) return null;\n            const row = entry.payload as BarRow;\n            const index = data.indexOf(row);\n            const value = Number(row[yKey]);\n            return (\n              <div\n                data-slot=\"bar-chart-tooltip\"\n                className=\"min-w-32 rounded-xl border border-border/70 bg-popover/90 px-3 py-2 text-xs text-popover-foreground shadow-xl backdrop-blur-md\"\n              >\n                <div className=\"flex items-center gap-2\">\n                  <span\n                    aria-hidden=\"true\"\n                    className=\"size-2 shrink-0 rounded-full\"\n                    style={{\n                      backgroundColor: isHighlighted(index) ? color : mutedColor,\n                    }}\n                  />\n                  <span className=\"text-sm font-semibold tracking-[-0.01em] tabular-nums\">\n                    {format(value)}\n                  </span>\n                </div>\n                <div className=\"mt-0.5 pl-4 text-muted-foreground\">\n                  {tooltipLabel\n                    ? tooltipLabel(row, index)\n                    : xFormatter(row[xKey])}\n                </div>\n              </div>\n            );\n          }}\n        />\n        <Bar\n          dataKey={yKey}\n          radius={barRadius}\n          isAnimationActive={animate && !reducedMotion}\n          animationDuration={tween.total}\n          animationEasing=\"linear\"\n          animationInterpolateFn={tween.interpolate}\n          shape={(shape: BarShapeProps) => (\n            <BarShape\n              {...shape}\n              fill={fillFor(shape.originalDataIndex ?? shape.index)}\n              on={isHighlighted(shape.originalDataIndex ?? shape.index)}\n              color={color}\n              mutedColor={mutedColor}\n              marker={showActiveMarker}\n            />\n          )}\n          onClick={\n            onBarClick\n              ? (_, index) => onBarClick(data[index]!, index)\n              : undefined\n          }\n          className={onBarClick ? \"cursor-pointer\" : undefined}\n        />\n        {referenceLines.map((line, index) => (\n          <ReferenceLine\n            key={index}\n            y={line.y}\n            ifOverflow=\"extendDomain\"\n            stroke={\n              line.color ??\n              \"color-mix(in oklab, var(--color-muted-foreground) 70%, transparent)\"\n            }\n            strokeDasharray={line.dashed === false ? undefined : \"3 4\"}\n            label={\n              line.label\n                ? {\n                    value: line.label,\n                    position: \"insideBottomRight\",\n                    fill: line.color ?? \"var(--color-muted-foreground)\",\n                    fontSize: 11,\n                    fontWeight: 500,\n                    stroke: \"var(--color-card)\",\n                    strokeWidth: 4,\n                    strokeLinejoin: \"round\",\n                    paintOrder: \"stroke\",\n                  }\n                : undefined\n            }\n          />\n        ))}\n      </RechartsBarChart>\n    </ChartContainer>\n  );\n}\n\nexport { BarChart };\n"
    },
    {
      "path": "src/registry/overtrue/analytics-chart.tsx",
      "type": "registry:component",
      "target": "components/overtrue/analytics-chart.tsx",
      "content": "/** Adapted from dashboardcn (MIT), copyright 2026 dashboardcn contributors.\n * Source: https://github.com/NoahGdev/dashboardcn/tree/b1ffacbca0f7a0be60135c8665b9e8c267205c48\n *\n * MIT License\n *\n * Copyright (c) 2026 dashboardcn contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n * ---\n *\n * Portions of this project are derived from shadcn/ui and shadcn/registry-template\n * (https://github.com/shadcn-ui/ui), Copyright (c) 2023 shadcn, licensed under the\n * MIT License. The notice above applies to those portions as well.\n */\n\"use client\";\n\nimport * as React from \"react\";\nimport * as RechartsPrimitive from \"recharts-analytics\";\nimport type { TooltipValueType } from \"recharts-analytics\";\n\nimport { cn } from \"@/lib/utils\";\n\n// Format: { THEME_NAME: CSS_SELECTOR }\nconst THEMES = { light: \"\", dark: \".dark\" } as const;\n\nconst INITIAL_DIMENSION = { width: 320, height: 200 } as const;\ntype TooltipNameType = number | string;\n\nexport type ChartConfig = Record<\n  string,\n  {\n    label?: React.ReactNode;\n    icon?: React.ComponentType;\n  } & (\n    | { color?: string; theme?: never }\n    | { color?: never; theme: Record<keyof typeof THEMES, string> }\n  )\n>;\n\ntype ChartContextProps = {\n  config: ChartConfig;\n};\n\nconst ChartContext = React.createContext<ChartContextProps | null>(null);\n\nfunction useChart() {\n  const context = React.useContext(ChartContext);\n\n  if (!context) {\n    throw new Error(\"useChart must be used within a <ChartContainer />\");\n  }\n\n  return context;\n}\n\nfunction ChartContainer({\n  id,\n  className,\n  children,\n  config,\n  initialDimension = INITIAL_DIMENSION,\n  ...props\n}: React.ComponentProps<\"div\"> & {\n  config: ChartConfig;\n  children: React.ComponentProps<\n    typeof RechartsPrimitive.ResponsiveContainer\n  >[\"children\"];\n  initialDimension?: {\n    width: number;\n    height: number;\n  };\n}) {\n  const uniqueId = React.useId();\n  const chartId = `chart-${id ?? uniqueId.replace(/:/g, \"\")}`;\n\n  return (\n    <ChartContext.Provider value={{ config }}>\n      <div\n        data-slot=\"chart\"\n        data-chart={chartId}\n        className={cn(\n          \"flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden\",\n          className,\n        )}\n        {...props}\n      >\n        <ChartStyle id={chartId} config={config} />\n        <RechartsPrimitive.ResponsiveContainer\n          initialDimension={initialDimension}\n        >\n          {children}\n        </RechartsPrimitive.ResponsiveContainer>\n      </div>\n    </ChartContext.Provider>\n  );\n}\n\nconst ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {\n  const colorConfig = Object.entries(config).filter(\n    ([, config]) => config.theme ?? config.color,\n  );\n\n  if (!colorConfig.length) {\n    return null;\n  }\n\n  return (\n    <style\n      dangerouslySetInnerHTML={{\n        __html: Object.entries(THEMES)\n          .map(\n            ([theme, prefix]) => `\n${prefix} [data-chart=${id}] {\n${colorConfig\n  .map(([key, itemConfig]) => {\n    const color =\n      itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ??\n      itemConfig.color;\n    return color ? `  --color-${key}: ${color};` : null;\n  })\n  .join(\"\\n\")}\n}\n`,\n          )\n          .join(\"\\n\"),\n      }}\n    />\n  );\n};\n\nconst ChartTooltip = RechartsPrimitive.Tooltip;\n\nfunction ChartTooltipContent({\n  active,\n  payload,\n  className,\n  indicator = \"dot\",\n  hideLabel = false,\n  hideIndicator = false,\n  label,\n  labelFormatter,\n  labelClassName,\n  formatter,\n  color,\n  nameKey,\n  labelKey,\n}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &\n  React.ComponentProps<\"div\"> & {\n    hideLabel?: boolean;\n    hideIndicator?: boolean;\n    indicator?: \"line\" | \"dot\" | \"dashed\";\n    nameKey?: string;\n    labelKey?: string;\n  } & Omit<\n    RechartsPrimitive.DefaultTooltipContentProps<\n      TooltipValueType,\n      TooltipNameType\n    >,\n    \"accessibilityLayer\"\n  >) {\n  const { config } = useChart();\n\n  const tooltipLabel = React.useMemo(() => {\n    if (hideLabel || !payload?.length) {\n      return null;\n    }\n\n    const [item] = payload;\n    const key = `${labelKey ?? item?.dataKey ?? item?.name ?? \"value\"}`;\n    const itemConfig = getPayloadConfigFromPayload(config, item, key);\n    const value =\n      !labelKey && typeof label === \"string\"\n        ? (config[label]?.label ?? label)\n        : itemConfig?.label;\n\n    if (labelFormatter) {\n      return (\n        <div className={cn(\"font-medium\", labelClassName)}>\n          {labelFormatter(value, payload)}\n        </div>\n      );\n    }\n\n    if (!value) {\n      return null;\n    }\n\n    return <div className={cn(\"font-medium\", labelClassName)}>{value}</div>;\n  }, [\n    label,\n    labelFormatter,\n    payload,\n    hideLabel,\n    labelClassName,\n    config,\n    labelKey,\n  ]);\n\n  if (!active || !payload?.length) {\n    return null;\n  }\n\n  const nestLabel = payload.length === 1 && indicator !== \"dot\";\n\n  return (\n    <div\n      className={cn(\n        \"grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl\",\n        className,\n      )}\n    >\n      {!nestLabel ? tooltipLabel : null}\n      <div className=\"grid gap-1.5\">\n        {payload\n          .filter((item) => item.type !== \"none\")\n          .map((item, index) => {\n            const key = `${nameKey ?? item.name ?? item.dataKey ?? \"value\"}`;\n            const itemConfig = getPayloadConfigFromPayload(config, item, key);\n            const indicatorColor = color ?? item.payload?.fill ?? item.color;\n\n            return (\n              <div\n                key={index}\n                className={cn(\n                  \"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground\",\n                  indicator === \"dot\" && \"items-center\",\n                )}\n              >\n                {formatter && item?.value !== undefined && item.name ? (\n                  formatter(item.value, item.name, item, index, item.payload)\n                ) : (\n                  <>\n                    {itemConfig?.icon ? (\n                      <itemConfig.icon />\n                    ) : (\n                      !hideIndicator && (\n                        <div\n                          className={cn(\n                            \"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)\",\n                            {\n                              \"h-2.5 w-2.5\": indicator === \"dot\",\n                              \"w-1\": indicator === \"line\",\n                              \"w-0 border-[1.5px] border-dashed bg-transparent\":\n                                indicator === \"dashed\",\n                              \"my-0.5\": nestLabel && indicator === \"dashed\",\n                            },\n                          )}\n                          style={\n                            {\n                              \"--color-bg\": indicatorColor,\n                              \"--color-border\": indicatorColor,\n                            } as React.CSSProperties\n                          }\n                        />\n                      )\n                    )}\n                    <div\n                      className={cn(\n                        \"flex flex-1 justify-between leading-none\",\n                        nestLabel ? \"items-end\" : \"items-center\",\n                      )}\n                    >\n                      <div className=\"grid gap-1.5\">\n                        {nestLabel ? tooltipLabel : null}\n                        <span className=\"text-muted-foreground\">\n                          {itemConfig?.label ?? item.name}\n                        </span>\n                      </div>\n                      {item.value != null && (\n                        <span className=\"font-mono font-medium text-foreground tabular-nums\">\n                          {typeof item.value === \"number\"\n                            ? item.value.toLocaleString()\n                            : String(item.value)}\n                        </span>\n                      )}\n                    </div>\n                  </>\n                )}\n              </div>\n            );\n          })}\n      </div>\n    </div>\n  );\n}\n\nconst ChartLegend = RechartsPrimitive.Legend;\n\nfunction ChartLegendContent({\n  className,\n  hideIcon = false,\n  payload,\n  verticalAlign = \"bottom\",\n  nameKey,\n}: React.ComponentProps<\"div\"> & {\n  hideIcon?: boolean;\n  nameKey?: string;\n} & RechartsPrimitive.DefaultLegendContentProps) {\n  const { config } = useChart();\n\n  if (!payload?.length) {\n    return null;\n  }\n\n  return (\n    <div\n      className={cn(\n        \"flex items-center justify-center gap-4\",\n        verticalAlign === \"top\" ? \"pb-3\" : \"pt-3\",\n        className,\n      )}\n    >\n      {payload\n        .filter((item) => item.type !== \"none\")\n        .map((item, index) => {\n          const key = `${nameKey ?? item.dataKey ?? \"value\"}`;\n          const itemConfig = getPayloadConfigFromPayload(config, item, key);\n\n          return (\n            <div\n              key={index}\n              className={cn(\n                \"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground\",\n              )}\n            >\n              {itemConfig?.icon && !hideIcon ? (\n                <itemConfig.icon />\n              ) : (\n                <div\n                  className=\"h-2 w-2 shrink-0 rounded-[2px]\"\n                  style={{\n                    backgroundColor: item.color,\n                  }}\n                />\n              )}\n              {itemConfig?.label}\n            </div>\n          );\n        })}\n    </div>\n  );\n}\n\n// Helper to extract item config from a payload.\nfunction getPayloadConfigFromPayload(\n  config: ChartConfig,\n  payload: unknown,\n  key: string,\n) {\n  if (typeof payload !== \"object\" || payload === null) {\n    return undefined;\n  }\n\n  const payloadPayload =\n    \"payload\" in payload &&\n    typeof payload.payload === \"object\" &&\n    payload.payload !== null\n      ? payload.payload\n      : undefined;\n\n  let configLabelKey: string = key;\n\n  if (\n    key in payload &&\n    typeof payload[key as keyof typeof payload] === \"string\"\n  ) {\n    configLabelKey = payload[key as keyof typeof payload] as string;\n  } else if (\n    payloadPayload &&\n    key in payloadPayload &&\n    typeof payloadPayload[key as keyof typeof payloadPayload] === \"string\"\n  ) {\n    configLabelKey = payloadPayload[\n      key as keyof typeof payloadPayload\n    ] as string;\n  }\n\n  return configLabelKey in config ? config[configLabelKey] : config[key];\n}\n\nexport {\n  ChartContainer,\n  ChartTooltip,\n  ChartTooltipContent,\n  ChartLegend,\n  ChartLegendContent,\n  ChartStyle,\n};\n"
    }
  ],
  "docs": "Documentation: https://ui.overtrue.xyz/components/bar-chart. Requires an initialized shadcn/ui project with Tailwind CSS v4."
}
