import { Progress } from "@/components/ui/progress"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; import { resetDurationLabels } from "@/lib/constants/governance"; import { cn } from "@/lib/utils"; import { formatCompactNumber } from "@/lib/utils/governance"; interface RateLimitShape { token_max_limit?: number | null; token_reset_duration?: string | null; token_current_usage?: number | null; request_max_limit?: number | null; request_reset_duration?: string | null; request_current_usage?: number | null; } interface RateLimitDisplayProps { rateLimits: RateLimitShape | null | undefined; /** Compact mode for narrow cells — still renders bars, just tighter */ compact?: boolean; /** Render limit + reset period only (no usage bar). Use for template entities like access profiles. */ limitOnly?: boolean; } const formatResetDuration = (duration?: string | null) => { if (!duration) return ""; return resetDurationLabels[duration] || duration; }; function LimitText({ label, max, resetDuration }: { label: string; max: number; resetDuration?: string | null }) { return (
{current.toLocaleString()} / {max.toLocaleString()} {label}
{resetDuration ? (Resets {formatResetDuration(resetDuration)}
) : null}