/**
* Task stats line: after each Task finishes, shows "this turn's usage" at the
* **bottom-left** of the AI reply — input, output, output TPS, elapsed time, and cost (converted
* in real time from the current Model's pricing, hidden if no pricing is configured); all five
* share the same basis (this turn's usage), each expressed uniformly as icon + value (no text
* labels); the reply timestamp and a copy button sit at the end (copies this turn's assistant
* text, falling back to the stats themselves when there's no text). Below sm the row is slimmed
* to fit the width: the TPS chip is dropped and cost/elapsed lose excess decimals (compact
* formatter variants); desktop shows all five, formatted as always.
* At ≥sm the whole line is invisible but takes up space by default, surfacing only on hovering
* the reply or the line itself — matching the same convention, font size, and color as the user
* message footer: the AI's footer sits bottom-left, the user's sits bottom-right, symmetric on
* both sides. Below sm the line is always visible: phones have no hover (Tailwind v4 even gates
* hover: variants behind `@media (hover: hover)`), so a hover-revealed footer would simply
* never appear there.
* Arrow direction reads as "where the tokens go": **up arrow = input** (sent up to the model),
* **down arrow = output** (returned by the model).
* This line only answers "how much did this turn cost", **it doesn't break down the cache
* composition** — how much of the input hit cache is a debugging-level detail that belongs to the
* Trace page's turn card (which shows cache hits and hit rate); the current **context usage** is
* likewise not repeated here — it's expressed by the ring below the input box (see ContextGauge
* in chat-input).
* This line sits right below this turn's AI reply and simultaneously **serves as that reply's
* footer**: it provides the reply timestamp and copy button at the end, so the assistant message
* itself doesn't render a separate one (otherwise two copy buttons would pop up in the same spot).
*/
import { useState } from "react";
import { formatTaskStats } from "../../lib/omni/task-stats";
import type { TaskStats } from "../../lib/omni/task-stats";
import {
formatMessageTime,
formatMoney,
formatTps,
humanizeDuration,
humanizeTokens,
} from "../../lib/format";
import { STAT_ICONS } from "../../lib/stat-icons";
import { S } from "../../lib/strings";
import { GlyphIcon } from "../../components/ui/glyph-icon";
import { useTheme } from "../../state/theme";
import { useLocale } from "../../state/locale";
/**
* Icon + value; hover explains what this item is (the icon alone doesn't convey the exact
* meaning). `display` swaps the default `flex` for a responsive variant (the TPS chip is
* `hidden sm:flex`); `compactValue`, when it differs, replaces the value below sm — fewer
* decimals so the one-line stats row fits a phone without needing its scroll fallback.
*/
function StatChip({
icon,
value,
compactValue,
label,
display = "flex",
}: {
icon: string;
value: string;
compactValue?: string;
label: string;
display?: string;
}) {
return (