import { jsx, jsxs } from "react/jsx-runtime";
import { StyledBox, StyledSection, StyledRow } from "./StyledBox.js";
function formatTokenCount(count) {
  if (count >= 1e6) {
    return `${(count / 1e6).toFixed(1)}M`;
  }
  if (count >= 1e3) {
    return `${(count / 1e3).toFixed(1)}K`;
  }
  return count.toString();
}
function formatCost(cost) {
  if (cost < 0.01) {
    return `$${cost.toFixed(4)}`;
  }
  if (cost < 1) {
    return `$${cost.toFixed(3)}`;
  }
  return `$${cost.toFixed(2)}`;
}
function StatsBox({ data }) {
  return /* @__PURE__ */ jsxs(StyledBox, { title: "System Statistics", children: [
    /* @__PURE__ */ jsxs(StyledSection, { title: "Sessions", children: [
      /* @__PURE__ */ jsx(StyledRow, { label: "Total Sessions", value: data.sessions.total.toString() }),
      /* @__PURE__ */ jsx(StyledRow, { label: "In Memory", value: data.sessions.inMemory.toString() }),
      /* @__PURE__ */ jsx(StyledRow, { label: "Max Allowed", value: data.sessions.maxAllowed.toString() })
    ] }),
    /* @__PURE__ */ jsxs(StyledSection, { title: "MCP Servers", children: [
      /* @__PURE__ */ jsx(
        StyledRow,
        {
          label: "Connected",
          value: data.mcp.connected.toString(),
          valueColor: "green"
        }
      ),
      data.mcp.failed > 0 && /* @__PURE__ */ jsx(StyledRow, { label: "Failed", value: data.mcp.failed.toString(), valueColor: "red" }),
      /* @__PURE__ */ jsx(StyledRow, { label: "Available Tools", value: data.mcp.toolCount.toString() })
    ] }),
    data.tokenUsage && /* @__PURE__ */ jsxs(StyledSection, { title: "Token Usage (This Session)", children: [
      /* @__PURE__ */ jsx(
        StyledRow,
        {
          label: "Input",
          value: formatTokenCount(data.tokenUsage.inputTokens)
        }
      ),
      /* @__PURE__ */ jsx(
        StyledRow,
        {
          label: "Output",
          value: formatTokenCount(data.tokenUsage.outputTokens)
        }
      ),
      data.tokenUsage.reasoningTokens > 0 && /* @__PURE__ */ jsx(
        StyledRow,
        {
          label: "Reasoning",
          value: formatTokenCount(data.tokenUsage.reasoningTokens)
        }
      ),
      data.tokenUsage.cacheReadTokens > 0 && /* @__PURE__ */ jsx(
        StyledRow,
        {
          label: "Cache Read",
          value: formatTokenCount(data.tokenUsage.cacheReadTokens),
          valueColor: "cyan"
        }
      ),
      data.tokenUsage.cacheWriteTokens > 0 && /* @__PURE__ */ jsx(
        StyledRow,
        {
          label: "Cache Write",
          value: formatTokenCount(data.tokenUsage.cacheWriteTokens),
          valueColor: "orange"
        }
      ),
      /* @__PURE__ */ jsx(
        StyledRow,
        {
          label: "Total",
          value: formatTokenCount(data.tokenUsage.totalTokens),
          valueColor: "blue"
        }
      ),
      data.estimatedCost !== void 0 && /* @__PURE__ */ jsx(
        StyledRow,
        {
          label: "Est. Cost",
          value: formatCost(data.estimatedCost),
          valueColor: "green"
        }
      )
    ] })
  ] });
}
export {
  StatsBox
};
