;(function () {
/* AllocationDonut — SVG donut chart driven by the shared portfolio data.
   Slices are passed in by the parent (PerformanceScreen reads from
   `data/portfolio.js` `getSlices()`) so labels, colors, and percentages
   stay aligned with the Home Summary widget. */

const GAP = 0.6; // degrees between slices
const CX = 50;
const CY = 50;
const R_OUTER = 44;
const R_INNER = 28;

const AllocationDonut = ({ slices = [] }) => {
  let cursor = 0;
  const paths = slices.map((s) => {
    const sweep = s.pct * 360;
    const start = cursor + GAP / 2;
    const end = cursor + sweep - GAP / 2;
    cursor += sweep;
    return (
      <path
        key={s.id ?? s.label}
        d={donutPath(CX, CY, R_OUTER, R_INNER, start, end)}
        fill={s.color}
      />
    );
  });

  return (
    <svg width={120} height={120} viewBox="0 0 100 100">
      {paths}
    </svg>
  );
};

Object.assign(window, { AllocationDonut });
})();
