// ExploitChainFigure — 6.5 + 7.5 = 9.3.
//
// The concrete form of the "both pillars, one graph" argument, and the only
// place on the site where that argument stops being architectural. Two findings
// every scanner tells you to fix next quarter, plus one nobody files at all,
// chained into an account takeover.
//
// Arithmetic that shouldn't work is what makes it stick, so the numbers are set
// large and the sum is stated plainly. Data lives in data/asymmetry.js because
// the same chain appears in the deck and the report.

function ExploitChainFigure({ heading, note } = {}) {
  const { React } = window;
  const chain = window.ExploitChain;
  if (!chain) return null;

  return (
    <figure className="ah-chain">
      {heading && <figcaption className="ah-chain-head ah-eyebrow">{heading}</figcaption>}

      <div className="ah-chain-row">
        {chain.links.map((l, i) => (
          <React.Fragment key={l.label}>
            {i > 0 && <span className="ah-chain-op" aria-hidden="true">+</span>}
            <div className="ah-chain-link">
              <span className="ah-chain-v">{l.v}</span>
              <span className="ah-chain-l">{l.label}</span>
              <span className="ah-chain-n">{l.note}</span>
            </div>
          </React.Fragment>
        ))}
        <span className="ah-chain-op" aria-hidden="true">=</span>
        <div className="ah-chain-link ah-chain-link--crit">
          <span className="ah-chain-v">{chain.result.v}</span>
          <span className="ah-chain-l">{chain.result.label}</span>
          <span className="ah-chain-n">{chain.result.note}</span>
        </div>
      </div>

      <p className="ah-chain-note ah-small">
        {note || (
          <>
            Two mediums your scanner tells you to fix next quarter, plus one it never
            files at all. The chain only exists in the graph — so if your tools don&rsquo;t
            share one, it doesn&rsquo;t exist for you. It still exists for the attacker.
          </>
        )}
      </p>
    </figure>
  );
}

window.ExploitChainFigure = ExploitChainFigure;
