{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "progress-circle-bars",
  "title": "Progress Circle Bars",
  "description": "A circular progress indicator with ring, gauge, and dashes arc styles, scroll-triggered count-up animation, color thresholds, a comparison target marker, and a completion pulse.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/progress-circle-bars/progress-circle-bars.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, useInView, type Transition } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nconst SIZE_PRESETS: Record<string, { circleSize: number; strokeWidth: number }> = {\n  \"2xl\": { circleSize: 200, strokeWidth: 20 },\n  xl: { circleSize: 160, strokeWidth: 16 },\n  lg: { circleSize: 120, strokeWidth: 12 },\n  md: { circleSize: 90, strokeWidth: 10 },\n  sm: { circleSize: 64, strokeWidth: 8 },\n  xs: { circleSize: 44, strokeWidth: 6 },\n  \"2xs\": { circleSize: 32, strokeWidth: 4 },\n};\n\nexport type ProgressCircleSizePreset = keyof typeof SIZE_PRESETS | \"custom\";\nexport type ProgressCircleArcStyle = \"ring\" | \"gauge\" | \"dashes\";\nexport type ProgressCircleValueStyle = \"center\" | \"badge\" | \"none\";\n\nexport interface ProgressCircleBarsProps extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"children\" | \"content\"> {\n  sizePreset?: ProgressCircleSizePreset;\n  arcStyle?: ProgressCircleArcStyle;\n  circleSize?: number;\n  strokeWidth?: number;\n  dashCount?: number;\n  showCenterLabel?: boolean;\n\n  label?: string;\n  percentage?: number;\n  showLabel?: boolean;\n\n  valueStyle?: ProgressCircleValueStyle;\n  countUp?: boolean;\n  prefix?: string;\n  suffix?: string;\n  badgeBg?: string;\n  badgeTextColor?: string;\n\n  colorStart?: string;\n  colorEnd?: string;\n\n  thresholdsEnabled?: boolean;\n  thresholdLowMax?: number;\n  thresholdLowColor?: string;\n  thresholdMidMax?: number;\n  thresholdMidColor?: string;\n  thresholdHighColor?: string;\n\n  trackColor?: string;\n  trackBorderWidth?: number;\n  trackBorderColor?: string;\n\n  labelColor?: string;\n  labelSize?: number;\n  labelFontFamily?: string;\n  percentageColor?: string;\n  percentageSize?: number;\n  percentageFontFamily?: string;\n  spacing?: number;\n\n  scrollReveal?: boolean;\n  duration?: number;\n  delay?: number;\n  completionPulse?: boolean;\n\n  comparisonEnabled?: boolean;\n  comparisonValue?: number;\n  comparisonColor?: string;\n  comparisonStrokeScale?: number;\n}\n\nexport function ProgressCircleBars({\n  sizePreset = \"lg\",\n  arcStyle = \"dashes\",\n  circleSize = 120,\n  strokeWidth = 12,\n  dashCount = 60,\n  showCenterLabel = true,\n\n  label = \"Circle\",\n  percentage = 75,\n  showLabel = true,\n\n  valueStyle = \"center\",\n  countUp = true,\n  prefix = \"\",\n  suffix = \"%\",\n  badgeBg = \"#111111\",\n  badgeTextColor = \"#ffffff\",\n\n  colorStart = \"#F39C12\",\n  colorEnd = \"#F39C12\",\n\n  thresholdsEnabled = false,\n  thresholdLowMax = 40,\n  thresholdLowColor = \"#ef4444\",\n  thresholdMidMax = 70,\n  thresholdMidColor = \"#f59e0b\",\n  thresholdHighColor = \"#10b981\",\n\n  trackColor = \"#f0f0f8\",\n  trackBorderWidth = 0,\n  trackBorderColor = \"#e5e7eb\",\n\n  labelColor = \"#111111\",\n  labelSize = 11,\n  labelFontFamily = \"Inter, sans-serif\",\n  percentageColor = \"#111111\",\n  percentageSize = 24,\n  percentageFontFamily = \"Inter, sans-serif\",\n  spacing = 10,\n\n  scrollReveal = true,\n  duration = 1.4,\n  delay = 0.1,\n  completionPulse = true,\n\n  comparisonEnabled = false,\n  comparisonValue = 90,\n  comparisonColor = \"#d1d5db\",\n  comparisonStrokeScale = 0.45,\n\n  className,\n  ...props\n}: ProgressCircleBarsProps) {\n  const ref = React.useRef<HTMLDivElement>(null);\n  const isInView = useInView(ref, { once: true, amount: 0.3 });\n  const [animated, setAnimated] = React.useState(false);\n  const [displayValue, setDisplayValue] = React.useState(0);\n  const [animFillPct, setAnimFillPct] = React.useState(0);\n  const [pulseKey, setPulseKey] = React.useState(0);\n  const didInitialAnim = React.useRef(false);\n  const gradId = `cpb-arc-grad-${React.useId().replace(/[^a-zA-Z0-9]/g, \"\")}`;\n\n  const clampedPct = Math.min(100, Math.max(0, percentage));\n  const isComplete = clampedPct === 100;\n  const shouldAnimate = scrollReveal ? isInView : true;\n\n  React.useEffect(() => {\n    if (!shouldAnimate || animated) return;\n    const timer = setTimeout(() => setAnimated(true), delay * 1000);\n    return () => clearTimeout(timer);\n  }, [shouldAnimate, animated, delay]);\n\n  React.useEffect(() => {\n    if (!animated) return;\n    didInitialAnim.current = false;\n    const totalFrames = Math.round(duration * 60);\n    let frame = 0;\n    const id = setInterval(() => {\n      frame++;\n      const t = frame / totalFrames;\n      const eased = 1 - Math.pow(1 - t, 3);\n      const animPct = Math.round(eased * clampedPct);\n      setDisplayValue(countUp ? animPct : clampedPct);\n      setAnimFillPct(eased * clampedPct);\n      if (frame >= totalFrames) {\n        didInitialAnim.current = true;\n        clearInterval(id);\n      }\n    }, 1000 / 60);\n    return () => clearInterval(id);\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [animated]);\n\n  React.useEffect(() => {\n    if (!animated || !didInitialAnim.current) return;\n    setDisplayValue(clampedPct);\n    setAnimFillPct(clampedPct);\n  }, [clampedPct, animated]);\n\n  React.useEffect(() => {\n    if (animated && isComplete && completionPulse) {\n      const t = setTimeout(() => setPulseKey((k) => k + 1), duration * 1000 + 100);\n      return () => clearTimeout(t);\n    }\n  }, [animated, isComplete, completionPulse, duration]);\n\n  let activeFillStart = colorStart;\n  let activeFillEnd = colorEnd;\n  if (thresholdsEnabled) {\n    const color = clampedPct < thresholdLowMax ? thresholdLowColor : clampedPct < thresholdMidMax ? thresholdMidColor : thresholdHighColor;\n    activeFillStart = color;\n    activeFillEnd = color;\n  }\n\n  const ease = [0.25, 0.46, 0.45, 0.94] as const;\n  const transition: Transition = { duration, ease };\n\n  const isCustomSize = sizePreset === \"custom\";\n  const presetVals = !isCustomSize ? SIZE_PRESETS[sizePreset] : null;\n  const svgSize = presetVals ? presetVals.circleSize : circleSize;\n  const sw = presetVals ? presetVals.strokeWidth : strokeWidth;\n  const r = (svgSize - sw) / 2;\n  const cx = svgSize / 2;\n  const cy = svgSize / 2;\n  const circumference = 2 * Math.PI * r;\n  const isGauge = arcStyle === \"gauge\";\n  const isDashes = arcStyle === \"dashes\";\n\n  const ringOffset = animated ? circumference * (1 - clampedPct / 100) : circumference;\n  const gaugeFillLength = animated ? circumference * 0.75 * (clampedPct / 100) : 0;\n\n  const showCenterValue = valueStyle === \"center\";\n  const showBadge = valueStyle === \"badge\";\n\n  const gaugeProps = isGauge\n    ? {\n        strokeDasharray: `${circumference * 0.75} ${circumference * 0.25}`,\n        transform: `rotate(135, ${cx}, ${cy})`,\n      }\n    : {};\n\n  return (\n    <div\n      ref={ref}\n      role=\"img\"\n      aria-label={`${label}: ${Math.round(clampedPct)}%`}\n      className={cn(\"inline-flex flex-col items-center box-border\", className)}\n      style={{ gap: spacing }}\n      {...props}\n    >\n      <div className=\"relative\" style={{ width: svgSize, height: svgSize }}>\n        <svg width={svgSize} height={svgSize} aria-hidden=\"true\" style={{ overflow: \"visible\", display: \"block\" }}>\n          <defs>\n            <linearGradient id={gradId} gradientUnits=\"userSpaceOnUse\" x1=\"0\" y1={cy} x2={svgSize} y2={cy}>\n              <stop offset=\"0%\" stopColor={activeFillStart} />\n              <stop offset=\"100%\" stopColor={activeFillEnd} />\n            </linearGradient>\n          </defs>\n\n          {trackBorderWidth > 0 && !isDashes && (\n            <circle cx={cx} cy={cy} r={r} fill=\"none\" stroke={trackBorderColor} strokeWidth={sw + trackBorderWidth * 2} strokeLinecap=\"round\" {...gaugeProps} />\n          )}\n\n          {!isDashes && <circle cx={cx} cy={cy} r={r} fill=\"none\" stroke={trackColor} strokeWidth={sw} strokeLinecap=\"round\" {...gaugeProps} />}\n\n          {!isGauge && !isDashes && (\n            <motion.circle\n              cx={cx}\n              cy={cy}\n              r={r}\n              fill=\"none\"\n              stroke={activeFillStart !== activeFillEnd ? `url(#${gradId})` : activeFillStart}\n              strokeWidth={sw}\n              strokeLinecap=\"round\"\n              strokeDasharray={circumference}\n              transform={`rotate(-90, ${cx}, ${cy})`}\n              initial={{ strokeDashoffset: circumference }}\n              animate={{ strokeDashoffset: ringOffset }}\n              transition={transition}\n            />\n          )}\n\n          {isGauge && !isDashes && (\n            <motion.circle\n              cx={cx}\n              cy={cy}\n              r={r}\n              fill=\"none\"\n              stroke={activeFillStart !== activeFillEnd ? `url(#${gradId})` : activeFillStart}\n              strokeWidth={sw}\n              strokeLinecap=\"round\"\n              transform={`rotate(135, ${cx}, ${cy})`}\n              initial={{ strokeDasharray: `0 ${circumference}` }}\n              animate={{ strokeDasharray: `${gaugeFillLength} ${circumference}` }}\n              transition={transition}\n            />\n          )}\n\n          {comparisonEnabled && !isDashes && !isGauge && (\n            <motion.circle\n              cx={cx}\n              cy={cy}\n              r={r}\n              fill=\"none\"\n              stroke={comparisonColor}\n              strokeWidth={sw * comparisonStrokeScale}\n              strokeLinecap=\"round\"\n              strokeDasharray={circumference}\n              transform={`rotate(-90, ${cx}, ${cy})`}\n              initial={{ strokeDashoffset: circumference }}\n              animate={{ strokeDashoffset: animated ? circumference * (1 - comparisonValue / 100) : circumference }}\n              transition={{ duration: duration * 0.8, ease }}\n            />\n          )}\n\n          {comparisonEnabled && !isDashes && isGauge && (\n            <motion.circle\n              cx={cx}\n              cy={cy}\n              r={r}\n              fill=\"none\"\n              stroke={comparisonColor}\n              strokeWidth={sw * comparisonStrokeScale}\n              strokeLinecap=\"round\"\n              transform={`rotate(135, ${cx}, ${cy})`}\n              initial={{ strokeDasharray: `0 ${circumference}` }}\n              animate={{ strokeDasharray: `${animated ? circumference * 0.75 * (comparisonValue / 100) : 0} ${circumference}` }}\n              transition={{ duration: duration * 0.8, ease }}\n            />\n          )}\n\n          {isDashes &&\n            (() => {\n              const count = dashCount;\n              const stepAngle = 360 / count;\n              const filledCount = animated ? Math.round((animFillPct / 100) * count) : 0;\n              const compCount = comparisonEnabled ? Math.round((comparisonValue / 100) * count) : 0;\n              const dashWidth = Math.max(2, sw * 0.28);\n              const dashFilledH = sw;\n              const dashTrackH = sw * 0.4;\n              const dashCompH = sw * 0.75;\n              const outerY = cy - r - sw / 2;\n\n              return (\n                <>\n                  {comparisonEnabled &&\n                    Array.from({ length: count }, (_, i) => {\n                      if (i < filledCount || i >= compCount) return null;\n                      return (\n                        <rect\n                          key={`c${i}`}\n                          x={cx - dashWidth / 2}\n                          y={outerY}\n                          width={dashWidth}\n                          height={dashCompH}\n                          rx={dashWidth / 2}\n                          fill={comparisonColor}\n                          opacity={0.65}\n                          transform={`rotate(${stepAngle * i}, ${cx}, ${cy})`}\n                        />\n                      );\n                    })}\n                  {Array.from({ length: count }, (_, i) => {\n                    const isFilled = i < filledCount;\n                    const h = isFilled ? dashFilledH : dashTrackH;\n                    return (\n                      <rect\n                        key={i}\n                        x={cx - dashWidth / 2}\n                        y={outerY}\n                        width={dashWidth}\n                        height={h}\n                        rx={dashWidth / 2}\n                        fill={isFilled ? (activeFillStart !== activeFillEnd ? `url(#${gradId})` : activeFillStart) : trackColor}\n                        opacity={isFilled ? 1 : 0.55}\n                        transform={`rotate(${stepAngle * i}, ${cx}, ${cy})`}\n                      />\n                    );\n                  })}\n                </>\n              );\n            })()}\n        </svg>\n\n        {(showCenterValue || showCenterLabel) && (\n          <div aria-hidden=\"true\" className=\"absolute inset-0 flex flex-col items-center justify-center gap-0.5 pointer-events-none\">\n            {showCenterValue && (\n              <span\n                style={{\n                  color: percentageColor,\n                  fontSize: percentageSize,\n                  fontFamily: percentageFontFamily,\n                  fontWeight: 700,\n                  lineHeight: 1,\n                  letterSpacing: \"-0.04em\",\n                  fontVariantNumeric: \"tabular-nums\",\n                }}\n              >\n                {prefix}\n                {displayValue}\n                {suffix}\n              </span>\n            )}\n            {showCenterLabel && (\n              <span style={{ color: labelColor, fontSize: labelSize, fontFamily: labelFontFamily, fontWeight: 500, lineHeight: 1.2, opacity: 0.55 }}>{label}</span>\n            )}\n          </div>\n        )}\n\n        {completionPulse && isComplete && pulseKey > 0 && (\n          <motion.div\n            key={pulseKey}\n            className=\"absolute inset-0 rounded-full pointer-events-none\"\n            style={{ border: `${Math.max(2, sw * 0.4)}px solid ${activeFillEnd}` }}\n            initial={{ opacity: 0.75, scale: 1 }}\n            animate={{ opacity: 0, scale: 1.15 }}\n            transition={{ duration: 0.9, ease: \"easeOut\" }}\n          />\n        )}\n      </div>\n\n      {showBadge && (\n        <motion.div\n          aria-hidden=\"true\"\n          className=\"flex flex-col items-center pointer-events-none -mt-1\"\n          initial={{ opacity: 0 }}\n          animate={{ opacity: animated ? 1 : 0 }}\n          transition={transition}\n        >\n          <div style={{ width: 0, height: 0, borderLeft: \"5px solid transparent\", borderRight: \"5px solid transparent\", borderBottom: `6px solid ${badgeBg}` }} />\n          <div\n            style={{\n              backgroundColor: badgeBg,\n              color: badgeTextColor,\n              padding: \"3px 10px\",\n              borderRadius: 999,\n              fontSize: 12,\n              fontFamily: percentageFontFamily,\n              fontWeight: 700,\n              fontVariantNumeric: \"tabular-nums\",\n              letterSpacing: \"-0.02em\",\n              boxShadow: \"0 2px 10px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.1)\",\n              whiteSpace: \"nowrap\",\n              lineHeight: 1.6,\n            }}\n          >\n            {prefix}\n            {displayValue}\n            {suffix}\n          </div>\n        </motion.div>\n      )}\n\n      {showLabel && !showCenterLabel && (\n        <span style={{ color: labelColor, fontSize: labelSize, fontFamily: labelFontFamily, fontWeight: 500, lineHeight: 1.2, letterSpacing: \"-0.01em\" }}>{label}</span>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}