"use client"; import { cn } from "@/shared/utils/cn"; import { formatResetTime } from "./utils"; // Calculate color based on remaining percentage const getColorClasses = (remainingPercentage) => { if (remainingPercentage > 70) { return { text: "text-green-500", bg: "bg-green-500", bgLight: "bg-green-500/10", emoji: "🟢" }; } if (remainingPercentage >= 30) { return { text: "text-yellow-500", bg: "bg-yellow-500", bgLight: "bg-yellow-500/10", emoji: "🟡" }; } // 0-29% including 0% (out of quota) - show red return { text: "text-red-500", bg: "bg-red-500", bgLight: "bg-red-500/10", emoji: "🔴" }; }; // Format reset time display const formatResetTimeDisplay = (resetTime) => { if (!resetTime) return null; try { const resetDate = new Date(resetTime); const now = new Date(); const isToday = resetDate.toDateString() === now.toDateString(); const isTomorrow = resetDate.toDateString() === new Date(now.getTime() + 86400000).toDateString(); const timeStr = resetDate.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit", hour12: true, }); if (isToday) return `Today, ${timeStr}`; if (isTomorrow) return `Tomorrow, ${timeStr}`; return resetDate.toLocaleString(undefined, { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", hour12: true, }); } catch { return null; } }; export default function QuotaProgressBar({ percentage = 0, label = "", used = 0, total = 0, unlimited = false, resetTime = null }) { const colors = getColorClasses(percentage); const countdown = formatResetTime(resetTime); const resetDisplay = formatResetTimeDisplay(resetTime); // percentage is already remaining percentage (from ProviderLimitCard) const remaining = percentage; return (