;(function () {
/* AllocationPie — donut pie chart for the Summary widget.
   Renders a Path per slice using donutPath; 0.6° gap between slices. */

const AllocationPie = ({ slices, size = 132 }) => {
  const total = slices.reduce((s, x) => s + x.value, 0) || 1;
  let cursor = 0;
  return (
    <svg width={size} height={size} viewBox="0 0 100 100">
      {slices.map((slice) => {
        const start = cursor;
        const end = cursor + (slice.value / total) * 360;
        cursor = end;
        if (slice.value === 0) return null;
        return (
          <path
            key={slice.label}
            d={donutPath(50, 50, 44, 28, start + 0.6, end - 0.6)}
            fill={slice.color}
          />
        );
      })}
    </svg>
  );
};

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