'use client';
'use strict';

var _tslib = require('../_virtual/_tslib.js');
var index = require('../external/classnames/index.js');
var React = require('react');
var reactVirtualizedAutoSizer_esm = require('../external/react-virtualized-auto-sizer/dist/react-virtualized-auto-sizer.esm.js');
var chartComponents = require('./chart-components.js');
var pieChart_module = require('./pie-chart.module.css.js');
var Cell = require('../external/recharts/es6/component/Cell.js');
var PieChart$1 = require('../external/recharts/es6/chart/PieChart.js');
var Tooltip = require('../external/recharts/es6/component/Tooltip.js');
var Legend = require('../external/recharts/es6/component/Legend.js');
var Pie = require('../external/recharts/es6/polar/Pie.js');

var PieChart = React.forwardRef(function PieChartRoot(_a, ref) {
    var className = _a.className, category = _a.category, _b = _a.colors, colors = _b === void 0 ? chartComponents.DEFAULT_COLORS : _b, dark = _a.dark, data = _a.data, index$1 = _a.index, otherProps = _tslib.__rest(_a, ["className", "category", "colors", "dark", "data", "index"]);
    var colorMap = chartComponents.createColorMap({ categories: data.map(function (obj) { return obj[index$1]; }), colors: colors });
    var cells = data.map(function (_, index) {
        var color = colors[index % colors.length];
        return React.createElement(Cell.Cell, { key: index, fill: color });
    });
    return (React.createElement("div", _tslib.__assign({ className: index(className, pieChart_module.root), ref: ref }, otherProps, { style: _tslib.__assign(_tslib.__assign({}, otherProps.style), { minHeight: 200, minWidth: 300 }) }),
        React.createElement(reactVirtualizedAutoSizer_esm, null, function (_a) {
            var _b;
            var height = _a.height, width = _a.width;
            return (React.createElement(PieChart$1.PieChart, { className: index((_b = {}, _b[pieChart_module.dark] = dark, _b)), data: data, height: height, width: width },
                React.createElement(Tooltip.Tooltip, { content: function (_a) {
                        var active = _a.active, payload = _a.payload, label = _a.label;
                        return (React.createElement(chartComponents.ChartTooltip, { active: active, colorMap: colorMap, dark: dark, label: label, payload: payload }));
                    }, isAnimationActive: false }),
                React.createElement(Legend.Legend, { content: function (_a) {
                        var payload = _a.payload;
                        return React.createElement(chartComponents.ChartLegend, { colorMap: colorMap, dark: dark, payload: payload });
                    }, verticalAlign: "bottom" }),
                React.createElement(Pie.Pie, { className: pieChart_module.pie, data: data, cx: "50%", cy: "50%", startAngle: 90, endAngle: -270, innerRadius: "75%", isAnimationActive: false, outerRadius: "100%", dataKey: category, nameKey: index$1 }, cells)));
        })));
});

exports.PieChart = PieChart;
//# sourceMappingURL=pie-chart.js.map
