"use client";
import { Tooltip, TooltipContent, TooltipTrigger } from "@kandev/ui/tooltip";
import type { ProviderUsage } from "@/lib/types/agent-profile";
type Props = {
usage: ProviderUsage;
};
export function getBarColor(pct: number): string {
if (pct >= 90) return "bg-red-500";
if (pct >= 80) return "bg-amber-500";
return "bg-emerald-500";
}
export function getTextColor(pct: number): string {
if (pct >= 90) return "text-red-600 dark:text-red-400";
if (pct >= 80) return "text-amber-600 dark:text-amber-400";
return "text-emerald-600 dark:text-emerald-400";
}
function formatResetTime(resetAt: string): string {
const now = Date.now();
const reset = new Date(resetAt).getTime();
const diffMs = reset - now;
if (diffMs <= 0) return "resetting soon";
const diffH = Math.floor(diffMs / (1000 * 60 * 60));
const diffM = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60));
if (diffH > 0) return `Resets in ${diffH}h ${diffM}m`;
return `Resets in ${diffM}m`;
}
function WindowBar({ label, pct, resetAt }: { label: string; pct: number; resetAt: string }) {
const clampedPct = Math.min(100, Math.max(0, pct));
const barColor = getBarColor(clampedPct);
const textColor = getTextColor(clampedPct);
return (
{formatResetTime(resetAt)}
No utilization data available.
; } return (