import type { MarketConcentration } from "@dci/core";
import { ApiNote, CoverageBar, HonestEmpty, ShareList } from "@/components/intelligence/shared";
import { fmtInt, fmtPct } from "@/lib/format";
import { routes } from "@/lib/routes";
function hhiLabel(hhi: number): string {
if (hhi >= 2500) return "highly concentrated";
if (hhi >= 1500) return "moderately concentrated";
return "unconcentrated";
}
function Figures({ hhi, top3, top5 }: { hhi: number; top3: number; top5: number }) {
return (
- HHI
- {fmtInt(hhi)}
- {hhiLabel(hhi)} · 0–10 000
- Top-3 share
- {fmtPct(top3)}
- Top-5 share
- {fmtPct(top5)}
);
}
/**
* MARKET CONCENTRATION — computed on facility counts and, separately, on known MW (only when published
* figures exist). The MW view always shows its coverage and says "incomplete MW data" when partial.
*/
export function MarketConcentrationPanel({ c, facilityCount }: { c: MarketConcentration; facilityCount: number }) {
const f = c.facilities;
const mw = c.knownMw;
return (
On facility counts
{fmtInt(c.operatorCount)} operators · {fmtInt(facilityCount)} counted facilities (campus rows with buildings excluded)
({ key: o.id, label: o.name, href: routes.operator(o.slug), count: o.count, share: o.share }))} unit="facilities" />
On known MW
{mw ? (
<>
Published operational MW only
{mw.coverage < 1 && (
Incomplete MW data — {fmtPct(mw.coverage)} of facilities publish a figure; shares below describe the published subset, not the market.
)}
({ key: o.id, label: o.name, href: routes.operator(o.slug), count: Math.round(o.mw), share: o.share }))} unit="MW" />
>
) : (
)}
);
}