{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ds-card-stat-comparison",
  "title": "Card Stat Comparison",
  "description": "A side-by-side comparison card for current vs. previous period values with trend indicators.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "@lema-ds/card-stat-shared",
    "@lema-ds/card",
    "@lema-ds/skeleton",
    "@lema-ds/ui-i18n",
    "@lema-ds/ds-locale-provider"
  ],
  "files": [
    {
      "path": "components/ds/ds-card-stat-comparison.tsx",
      "content": "import * as React from \"react\"\nimport { ArrowLeftRightIcon } from \"lucide-react\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Card, CardAction, CardContent, CardHeader } from \"@/components/ui/card\"\nimport { Skeleton } from \"@/components/ui/skeleton\"\nimport { UI_I18N, type UILocale } from \"@/lib/ui-i18n\"\nimport { useOptionalUILocale } from \"@/components/ui/ds-locale-provider\"\n\nimport {\n  type CardStatTrend,\n  type CardStatSize,\n  type FormatOptions,\n  applyFormat,\n  TrendBadge,\n  formatValue,\n  cardStatLabelVariants,\n  cardStatValueVariants,\n  cardStatDescriptionVariants,\n  cardStatHeaderIconVariants,\n  cardStatContentGapVariants,\n} from \"@/lib/card-stats-shared\"\n\nexport interface CardStatComparisonProps extends FormatOptions {\n  label: string\n  current: number\n  previous: number\n  currentLabel?: string\n  previousLabel?: string\n  icon?: React.ElementType\n  size?: CardStatSize\n  className?: string\n  loading?: boolean\n  empty?: boolean\n}\n\nexport function CardStatComparison({\n  label,\n  current,\n  previous,\n  currentLabel,\n  previousLabel,\n  icon: Icon,\n  size = \"sm\",\n  className,\n  loading,\n  empty,\n  locale: fmtLocaleProp,\n  ...fmt\n}: CardStatComparisonProps) {\n  const fmtLocale = useOptionalUILocale(fmtLocaleProp)\n  const uiLocale = (fmtLocale ?? \"en-US\") as UILocale\n  currentLabel ??= UI_I18N[uiLocale].cardStats.thisPeriod\n  previousLabel ??= UI_I18N[uiLocale].cardStats.lastPeriod\n\n  if (loading) {\n    return (\n      <Card size=\"sm\" className={className} data-slot=\"card-stat-comparison\">\n        <CardHeader className=\"flex flex-row items-center justify-between\">\n          <Skeleton className=\"h-3 w-28 rounded-md\" />\n          <Skeleton\n            className={cn(cardStatHeaderIconVariants({ size }), \"rounded-md\")}\n          />\n        </CardHeader>\n        <CardContent\n          className={cn(\"flex flex-col\", cardStatContentGapVariants({ size }))}\n          data-slot=\"card-stat-comparison-skeleton\"\n        >\n          <div className=\"grid grid-cols-2\">\n            <div className=\"flex flex-col gap-1.5 pr-4\">\n              <Skeleton className=\"h-2.5 w-20 rounded-md\" />\n              <Skeleton className=\"h-7 w-24\" />\n            </div>\n            <div className=\"flex flex-col gap-1.5 border-l pl-4\">\n              <Skeleton className=\"h-2.5 w-20 rounded-md\" />\n              <Skeleton className=\"h-7 w-24\" />\n            </div>\n          </div>\n          <Skeleton className=\"h-9 rounded-xl\" />\n        </CardContent>\n      </Card>\n    )\n  }\n\n  if (empty) {\n    return (\n      <Card size=\"sm\" className={className} data-slot=\"card-stat-comparison\">\n        <CardHeader className=\"flex flex-row items-center justify-between\">\n          <span\n            className={cn(\n              \"truncate text-muted-foreground\",\n              cardStatLabelVariants({ size })\n            )}\n          >\n            {label}\n          </span>\n          {Icon && (\n            <CardAction className=\"text-muted-foreground\">\n              <Icon\n                className={cardStatHeaderIconVariants({ size })}\n                aria-hidden\n              />\n            </CardAction>\n          )}\n        </CardHeader>\n        <CardContent\n          className={cn(\"flex flex-col\", cardStatContentGapVariants({ size }))}\n          data-slot=\"card-stat-comparison-empty\"\n        >\n          <div className=\"grid grid-cols-2\">\n            <div className=\"flex flex-col gap-0.5 pr-4\">\n              <p\n                className={cn(\n                  \"text-muted-foreground\",\n                  cardStatLabelVariants({ size })\n                )}\n              >\n                {currentLabel}\n              </p>\n              <p\n                className={cn(\n                  cardStatValueVariants({ size }),\n                  \"text-muted-foreground/25\"\n                )}\n              >\n                —\n              </p>\n            </div>\n            <div className=\"flex flex-col gap-0.5 border-l pl-4\">\n              <p\n                className={cn(\n                  \"text-muted-foreground\",\n                  cardStatLabelVariants({ size })\n                )}\n              >\n                {previousLabel}\n              </p>\n              <p\n                className={cn(\n                  cardStatValueVariants({ size }),\n                  \"text-muted-foreground/20\"\n                )}\n              >\n                —\n              </p>\n            </div>\n          </div>\n          <div className=\"flex items-center justify-center gap-2 rounded-xl bg-muted/30 px-3 py-2\">\n            <ArrowLeftRightIcon\n              className=\"size-3 text-muted-foreground/40\"\n              aria-hidden\n            />\n            <span\n              className={cn(\n                \"text-muted-foreground/50\",\n                cardStatDescriptionVariants({ size })\n              )}\n            >\n              {UI_I18N[uiLocale].cardStats.noComparison}\n            </span>\n          </div>\n        </CardContent>\n      </Card>\n    )\n  }\n\n  const f = (v: number) => applyFormat(v, { ...fmt, locale: fmtLocale })\n  const delta =\n    previous !== 0 ? ((current - previous) / Math.abs(previous)) * 100 : 0\n  const trendDir: CardStatTrend =\n    delta > 0.05 ? \"up\" : delta < -0.05 ? \"down\" : \"neutral\"\n  const deltaLabel = `${delta > 0 ? \"+\" : \"\"}${formatValue(Math.abs(delta) / 100, \"percent\", { decimals: 1, locale: fmtLocale })}`\n\n  return (\n    <Card size=\"sm\" className={className} data-slot=\"card-stat-comparison\">\n      <CardHeader className=\"flex flex-row items-center justify-between\">\n        <span\n          className={cn(\n            \"truncate text-muted-foreground\",\n            cardStatLabelVariants({ size })\n          )}\n        >\n          {label}\n        </span>\n        {Icon && (\n          <CardAction className=\"text-muted-foreground\">\n            <Icon\n              className={cardStatHeaderIconVariants({ size })}\n              aria-hidden\n            />\n          </CardAction>\n        )}\n      </CardHeader>\n      <CardContent\n        className={cn(\"flex flex-col\", cardStatContentGapVariants({ size }))}\n        data-slot=\"card-stat-comparison\"\n      >\n        <div className=\"grid grid-cols-2\">\n          <div className=\"flex flex-col gap-0.5 pr-4\">\n            <p\n              className={cn(\n                \"text-muted-foreground\",\n                cardStatLabelVariants({ size })\n              )}\n            >\n              {currentLabel}\n            </p>\n            <p className={cardStatValueVariants({ size })}>{f(current)}</p>\n          </div>\n          <div className=\"flex flex-col gap-0.5 border-l pl-4\">\n            <p\n              className={cn(\n                \"text-muted-foreground\",\n                cardStatLabelVariants({ size })\n              )}\n            >\n              {previousLabel}\n            </p>\n            <p\n              className={cn(\n                cardStatValueVariants({ size }),\n                \"text-muted-foreground/60\"\n              )}\n            >\n              {f(previous)}\n            </p>\n          </div>\n        </div>\n        <div className=\"flex items-center gap-2 rounded-xl bg-muted/50 px-3 py-2\">\n          <TrendBadge trend={trendDir} value={deltaLabel} size={size} />\n          <span\n            className={cn(\n              \"text-muted-foreground\",\n              cardStatDescriptionVariants({ size })\n            )}\n          >\n            vs {previousLabel.toLowerCase()}\n          </span>\n        </div>\n      </CardContent>\n    </Card>\n  )\n}\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}
