{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "progress-bar",
  "title": "Progress Bar",
  "description": "A progress bar component.",
  "registryDependencies": [
    "https://www.dashboardblocks.com/r/radix/block-state.json",
    "https://www.dashboardblocks.com/r/radix/use-in-view.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/progress-bar.tsx",
      "content": "'use client'\n\nimport { useBlockState } from '@/registry/components/dashboardblocks/block-state'\nimport { useInView } from '@/registry/hooks/use-in-view'\nimport { useEffect, useState } from 'react'\n\nimport { cn } from '@/lib/utils'\n\nexport interface ProgressBarProps {\n  className?: string\n  fillClassName?: string\n  percentage: number\n}\n\nexport const ProgressBar = ({\n  className,\n  percentage,\n  fillClassName,\n}: ProgressBarProps) => {\n  const [width, setWidth] = useState(0)\n  const { isInView, ref } = useInView()\n  const state = useBlockState()\n  const loading = state === 'loading'\n\n  const safePercentage = Number.isFinite(percentage) ? percentage : 0\n  const normalized = Math.min(100, Math.max(0, safePercentage))\n\n  useEffect(() => {\n    if (isInView) {\n      const timer = requestAnimationFrame(() => {\n        setWidth(normalized)\n      })\n      return () => cancelAnimationFrame(timer)\n    }\n  }, [isInView, normalized])\n\n  return (\n    <div\n      ref={ref as React.RefObject<HTMLDivElement>}\n      className={cn(\n        'h-2 w-full rounded-full bg-muted',\n        className,\n        loading && 'bg-muted animate-pulse motion-reduce:animate-none',\n      )}\n    >\n      <div\n        className={cn(\n          'h-full rounded-full bg-primary transition-[width] duration-1000 ease-[cubic-bezier(0.33,1,0.68,1)]',\n          fillClassName,\n        )}\n        style={{ width: `${state ? 0 : width}%` }}\n      />\n    </div>\n  )\n}\n\nexport interface SegmentedProgressBarProps {\n  className?: string\n  segments: Array<{\n    color?: string\n    label?: string\n    value: number\n  }>\n  total: number\n}\n\nexport const SegmentedProgressBar = ({\n  className,\n  segments,\n  total,\n}: SegmentedProgressBarProps) => {\n  const [animatedMultiplier, setAnimatedMultiplier] = useState(0)\n  const { isInView, ref } = useInView()\n  const state = useBlockState()\n  const loading = state === 'loading'\n  const safeTotal = total > 0 ? total : 1\n\n  useEffect(() => {\n    if (isInView) {\n      const timer = requestAnimationFrame(() => {\n        setAnimatedMultiplier(1)\n      })\n      return () => cancelAnimationFrame(timer)\n    }\n  }, [isInView])\n\n  return (\n    <div\n      ref={ref as React.RefObject<HTMLDivElement>}\n      className={cn(\n        'flex h-2 w-full overflow-hidden rounded-full bg-muted',\n        className,\n        loading && 'bg-muted animate-pulse motion-reduce:animate-none',\n      )}\n    >\n      {!state &&\n        segments.map((segment, index) => {\n          const percentage = (segment.value / safeTotal) * 100\n          const animatedWidth = Math.max(0, percentage) * animatedMultiplier\n          return (\n            <div\n              key={segment.label || index}\n              className='h-full transition-[width] duration-1000 ease-[cubic-bezier(0.33,1,0.68,1)] first:rounded-l-full last:rounded-r-full'\n              style={{\n                width: `${animatedWidth}%`,\n                backgroundColor: segment.color || 'var(--color-primary)',\n              }}\n            />\n          )\n        })}\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/progress-bar.tsx"
    }
  ],
  "type": "registry:component"
}
