import { useMemo } from 'react';
import { hierarchy, pack } from 'd3-hierarchy';
export var useBubbles = function (_a) {
    var data = _a.data, width = _a.width, height = _a.height;
    return useMemo(function () {
        if (width === 0 || height === 0) {
            return [];
        }
        var bubblesLayout = pack().size([width, height]).padding(2);
        var bubblesData = hierarchy({ children: data })
            .sum(function (d) { return d.value; })
            .sort(function (a, b) { return b.value - a.value; });
        return bubblesLayout(bubblesData).leaves();
    }, [data, height, width]);
};
