/* Ledger — the on-dark evidence list.
   Source: index.html lines 132–137 (.ledger / .lrow / .lk / .lv / .lv.volt).

   A 24ch label against a serif tabular figure. Exactly ONE row may carry
   volt: the number that is the story. Passing volt on two rows means neither
   reads as the finding, so this component warns rather than rendering it. */
function Ledger({ rows = [] }) {
  const voltCount = rows.filter((row) => row.volt).length;
  if (voltCount > 1 && typeof console !== 'undefined') {
    console.warn(
      `[public-record] Ledger received ${voltCount} volt rows. A data block gets one ` +
      'volt figure — the number that is the story. Two means neither reads as the finding.'
    );
  }

  return (
    <div className="ledger">
      {rows.map((row) => (
        <div className="lrow" key={row.label}>
          <span className="lk">{row.label}</span>
          <span className={row.volt && voltCount === 1 ? 'lv volt' : 'lv'}>{row.value}</span>
        </div>
      ))}
    </div>
  );
}

window.Ledger = Ledger;
