"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useBubbles = void 0;
var react_1 = require("react");
var d3_hierarchy_1 = require("d3-hierarchy");
var useBubbles = function (_a) {
    var data = _a.data, width = _a.width, height = _a.height;
    return (0, react_1.useMemo)(function () {
        if (width === 0 || height === 0) {
            return [];
        }
        var bubblesLayout = (0, d3_hierarchy_1.pack)().size([width, height]).padding(2);
        var bubblesData = (0, d3_hierarchy_1.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]);
};
exports.useBubbles = useBubbles;
