import type { DiffReport } from "@codarch/metrics/browser"; import { formatCompact } from "@codarch/render/browser"; import { CollapsibleSection, GroupHead } from "../CollapsibleSection"; import { balanceSummary, debtBalance } from "../balance"; import { BalanceRow } from "./BalanceRow"; import { deltaTone } from "./deltaTone"; /** * La deuda y el crecimiento, en una sola sección: lo que pesa y dónde crece el * peso no se leen por separado, y su título no desaparece aunque el cambio esté * limpio (ADR 0078). */ export function DebtSection({ report, onSelectPath }: { report: DiffReport; onSelectPath: (path: string) => void; }) { const balance = debtBalance(report); const debtDelta = balance.debt ? balance.debt.head - balance.debt.base : 0; const moves = balance.increased.length + balance.decreased.length; return (

La deuda de migración del cambio y lo que más creció: dos lecturas del mismo peso.

{balance.debt ? (
deuda {formatCompact(balance.debt.base)} →{" "} {formatCompact(balance.debt.head)}{" "} ({debtDelta > 0 ? `+${debtDelta}` : debtDelta}) cruces FFI {balance.debt.crossings} nativos {balance.debt.native}
) : (

Este reporte no trae la lente de migración: no hay deuda que balancear.

)} {balance.debt ? (
0 ? String(moves) : undefined} /> {moves > 0 ? (
{[...balance.increased, ...balance.decreased].map((file) => ( onSelectPath(file.path)} /> ))}
) : (

La deuda de migración no se ha movido en este cambio.

)} {balance.rest > 0 ? (

+{balance.rest} más

) : null}
) : null}
0 ? `${report.hotspotMetric ?? "métrica"} · ${balance.hotspots.length}` : (report.hotspotMetric ?? "métrica") } /> {balance.hotspots.length > 0 ? (
{balance.hotspots.map((hotspot) => ( onSelectPath(hotspot.path)} /> ))}
) : (

Ningún fichero ha crecido en este cambio.

)}
); }