function _array_like_to_array(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
    return arr2;
}
function _array_with_holes(arr) {
    if (Array.isArray(arr)) return arr;
}
function _array_without_holes(arr) {
    if (Array.isArray(arr)) return _array_like_to_array(arr);
}
function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _iterable_to_array(iter) {
    if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _iterable_to_array_limit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally{
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally{
            if (_d) throw _e;
        }
    }
    return _arr;
}
function _non_iterable_rest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _non_iterable_spread() {
    throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
function ownKeys(object, enumerableOnly) {
    var keys = Object.keys(object);
    if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);
        if (enumerableOnly) {
            symbols = symbols.filter(function(sym) {
                return Object.getOwnPropertyDescriptor(object, sym).enumerable;
            });
        }
        keys.push.apply(keys, symbols);
    }
    return keys;
}
function _object_spread_props(target, source) {
    source = source != null ? source : {};
    if (Object.getOwnPropertyDescriptors) {
        Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
    } else {
        ownKeys(Object(source)).forEach(function(key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
        });
    }
    return target;
}
function _object_without_properties(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys, key, i;
    if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
        sourceKeys = Reflect.ownKeys(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
        return target;
    }
    target = _object_without_properties_loose(source, excluded);
    if (Object.getOwnPropertySymbols) {
        sourceKeys = Object.getOwnPropertySymbols(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
    }
    return target;
}
function _object_without_properties_loose(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
    for(i = 0; i < sourceKeys.length; i++){
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) continue;
        if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
        target[key] = source[key];
    }
    return target;
}
function _sliced_to_array(arr, i) {
    return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _to_consumable_array(arr) {
    return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
}
function _unsupported_iterable_to_array(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _array_like_to_array(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(n);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
import { ConfigProvider } from "antd";
import { BarElement, CategoryScale, Chart as ChartJS, Legend, LinearScale, Tooltip } from "chart.js";
import classNames from "clsx";
import React, { useContext, useEffect, useMemo, useRef, useState } from "react";
import { Bar } from "react-chartjs-2";
import ChartStatistic from "../ChartStatistic";
import { ChartContainer, ChartFilter, ChartToolBar, downloadChart } from "../components";
import { defaultColorList } from "../const";
import { useDetectTheme } from "../hooks";
import { hexToRgba, resolveCssVariable } from "../utils";
import { useStyle } from "./style";
var histogramChartComponentsRegistered = false;
/**
 * 计算 Sturges 规则的分箱数量
 * k = ceil(log2(n) + 1)
 */ function calculateBinCount(n) {
    if (n <= 0) return 1;
    return Math.ceil(Math.log2(n) + 1);
}
/**
 * 计算分箱边界
 */ function calculateBinEdges(values, binCount) {
    var _Math, _Math1;
    if (values.length === 0) {
        return {
            edges: [],
            min: 0,
            max: 0
        };
    }
    var min = (_Math = Math).min.apply(_Math, _to_consumable_array(values));
    var max = (_Math1 = Math).max.apply(_Math1, _to_consumable_array(values));
    // 如果所有值相同，创建一个默认范围
    if (min === max) {
        var edge = min;
        return {
            edges: [
                edge - 0.5,
                edge + 0.5
            ],
            min: edge - 0.5,
            max: edge + 0.5
        };
    }
    var range = max - min;
    var binWidth = range / binCount;
    var edges = [];
    for(var i = 0; i <= binCount; i++){
        edges.push(min + i * binWidth);
    }
    return {
        edges: edges,
        min: min,
        max: max
    };
}
/**
 * 格式化分箱标签，对超出范围的数字使用普通计数格式而非科学记数法
 */ function formatBinLabel(start, end) {
    var formatNum = function formatNum(n) {
        if (Math.abs(n) < 0.01 && n !== 0) {
            return n.toFixed(4);
        }
        if (Number.isInteger(n)) {
            return n.toLocaleString('en-US', {
                useGrouping: false
            });
        }
        return parseFloat(n.toFixed(2)).toString();
    };
    return "".concat(formatNum(start), " - ").concat(formatNum(end));
}
var HistogramChart = function HistogramChart(_0) {
    var title = _0.title, data = _0.data, _0_width = _0.width, width = _0_width === void 0 ? 600 : _0_width, _0_height = _0.height, height = _0_height === void 0 ? 400 : _0_height, className = _0.className, classNamesProp = _0.classNames, style = _0.style, styles = _0.styles, dataTime = _0.dataTime, theme = _0.theme, color = _0.color, _0_showLegend = _0.showLegend, showLegend = _0_showLegend === void 0 ? true : _0_showLegend, _0_legendPosition = _0.legendPosition, legendPosition = _0_legendPosition === void 0 ? 'bottom' : _0_legendPosition, _0_showGrid = _0.showGrid, showGrid = _0_showGrid === void 0 ? true : _0_showGrid, xAxisLabel = _0.xAxisLabel, yAxisLabel = _0.yAxisLabel, _0_stacked = _0.stacked, stacked = _0_stacked === void 0 ? true : _0_stacked, customBinCount = _0.binCount, _0_showFrequency = _0.showFrequency, showFrequency = _0_showFrequency === void 0 ? false : _0_showFrequency, toolbarExtra = _0.toolbarExtra, _0_renderFilterInToolbar = _0.renderFilterInToolbar, renderFilterInToolbar = _0_renderFilterInToolbar === void 0 ? false : _0_renderFilterInToolbar, statisticConfig = _0.statistic, _0_loading = _0.loading, loading = _0_loading === void 0 ? false : _0_loading, props = _object_without_properties(_0, [
        "title",
        "data",
        "width",
        "height",
        "className",
        "classNames",
        "style",
        "styles",
        "dataTime",
        "theme",
        "color",
        "showLegend",
        "legendPosition",
        "showGrid",
        "xAxisLabel",
        "yAxisLabel",
        "stacked",
        "binCount",
        "showFrequency",
        "toolbarExtra",
        "renderFilterInToolbar",
        "statistic",
        "loading"
    ]);
    // 注册 Chart.js 组件
    useMemo(function() {
        if (histogramChartComponentsRegistered) {
            return undefined;
        }
        if (typeof window === 'undefined') {
            return undefined;
        }
        ChartJS.register(CategoryScale, LinearScale, BarElement, Tooltip, Legend);
        histogramChartComponentsRegistered = true;
        return undefined;
    }, []);
    var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
    var prefixCls = getPrefixCls('histogram-chart');
    var _useStyle = useStyle(prefixCls), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
    // 处理 ChartStatistic 组件配置
    var statistics = useMemo(function() {
        if (!statisticConfig) return null;
        if (Array.isArray(statisticConfig) && statisticConfig.length === 0) return null;
        return Array.isArray(statisticConfig) ? statisticConfig : [
            statisticConfig
        ];
    }, [
        statisticConfig
    ]);
    // 响应式尺寸计算
    var _useState = _sliced_to_array(useState(typeof window !== 'undefined' ? window.innerWidth : 768), 2), windowWidth = _useState[0], setWindowWidth = _useState[1];
    var isMobile = windowWidth <= 768;
    var responsiveWidth = isMobile ? '100%' : width;
    var responsiveHeight = isMobile ? Math.min(windowWidth * 0.8, 400) : height;
    // 监听窗口大小变化
    useEffect(function() {
        var handleResize = function handleResize() {
            setWindowWidth(window.innerWidth);
        };
        if (typeof window !== 'undefined') {
            window.addEventListener('resize', handleResize);
            return function() {
                return window.removeEventListener('resize', handleResize);
            };
        }
    }, []);
    var chartRef = useRef(null);
    // 数据安全检查
    var safeData = Array.isArray(data) ? data : [];
    // 从数据中提取分类
    var categories = useMemo(function() {
        var uniqueCategories = _to_consumable_array(new Set(safeData.map(function(item) {
            return item === null || item === void 0 ? void 0 : item.category;
        }))).filter(Boolean);
        return uniqueCategories;
    }, [
        safeData
    ]);
    // 从数据中提取 filterLabel
    var validFilterLabels = useMemo(function() {
        return safeData.map(function(item) {
            return item === null || item === void 0 ? void 0 : item.filterLabel;
        }).filter(function(filterLabel) {
            return filterLabel !== undefined;
        });
    }, [
        safeData
    ]);
    var filterLabels = useMemo(function() {
        return validFilterLabels.length > 0 ? _to_consumable_array(new Set(validFilterLabels)) : undefined;
    }, [
        validFilterLabels
    ]);
    // 状态管理
    var _useState1 = _sliced_to_array(useState(categories.find(Boolean) || ''), 2), selectedFilter = _useState1[0], setSelectedFilter = _useState1[1];
    var _useState2 = _sliced_to_array(useState(filterLabels && filterLabels.length > 0 ? filterLabels[0] : undefined), 2), selectedFilterLabel = _useState2[0], setSelectedFilterLabel = _useState2[1];
    // 当数据变化导致当前选中分类失效时，自动回退
    useEffect(function() {
        if (selectedFilter && !categories.includes(selectedFilter)) {
            setSelectedFilter(categories.find(Boolean) || '');
        }
    }, [
        categories,
        selectedFilter
    ]);
    // 筛选数据
    var filteredData = useMemo(function() {
        var base = selectedFilter ? safeData.filter(function(item) {
            return item.category === selectedFilter;
        }) : safeData;
        var withFilterLabel = !filterLabels || !selectedFilterLabel ? base : base.filter(function(item) {
            return item.filterLabel === selectedFilterLabel;
        });
        return withFilterLabel.filter(function(item) {
            return item && typeof item.value === 'number' && Number.isFinite(item.value);
        });
    }, [
        safeData,
        selectedFilter,
        filterLabels,
        selectedFilterLabel
    ]);
    // 从数据中提取唯一的类型
    var types = useMemo(function() {
        var allTypes = filteredData.map(function(item) {
            return item.type;
        }).filter(Boolean);
        return allTypes.length > 0 ? _to_consumable_array(new Set(allTypes)) : [
            '默认'
        ];
    }, [
        filteredData
    ]);
    // 判断是否为预分箱数据（所有项都有 left 和 right 字段）
    var isPreBinned = useMemo(function() {
        return filteredData.length > 0 && filteredData.every(function(item) {
            return typeof item.left === 'number' && typeof item.right === 'number';
        });
    }, [
        filteredData
    ]);
    // 计算分箱
    var binning = useMemo(function() {
        if (filteredData.length === 0) {
            return {
                edges: [],
                labels: [],
                binCount: 0
            };
        }
        if (isPreBinned) {
            // 预分箱模式：按 left 排序，直接生成区间标签
            var sorted = _to_consumable_array(filteredData).sort(function(a, b) {
                return a.left - b.left;
            });
            var uniqueEdgePairs = sorted.reduce(function(acc, item) {
                var l = item.left;
                var r = item.right;
                if (!acc.some(function(p) {
                    return p.left === l && p.right === r;
                })) {
                    acc.push({
                        left: l,
                        right: r
                    });
                }
                return acc;
            }, []);
            var edges = _to_consumable_array(uniqueEdgePairs.map(function(p) {
                return p.left;
            })).concat([
                uniqueEdgePairs[uniqueEdgePairs.length - 1].right
            ]);
            var labels = uniqueEdgePairs.map(function(p) {
                return formatBinLabel(p.left, p.right);
            });
            return {
                edges: edges,
                labels: labels,
                binCount: labels.length
            };
        }
        var allValues = filteredData.map(function(item) {
            return item.value;
        });
        var autoBinCount = customBinCount || calculateBinCount(allValues.length);
        var edges1 = calculateBinEdges(allValues, autoBinCount).edges;
        // 生成分箱标签
        var labels1 = [];
        for(var i = 0; i < edges1.length - 1; i++){
            labels1.push(formatBinLabel(edges1[i], edges1[i + 1]));
        }
        return {
            edges: edges1,
            labels: labels1,
            binCount: autoBinCount
        };
    }, [
        filteredData,
        customBinCount,
        isPreBinned
    ]);
    // 计算每个分箱的频率/计数
    var histogramData = useMemo(function() {
        var edges = binning.edges, labels = binning.labels;
        if (edges.length === 0 || types.length === 0) {
            return {};
        }
        var result = {};
        if (isPreBinned) {
            // 预分箱模式：直接将 value 映射到对应区间
            types.forEach(function(type) {
                if (!type) return;
                var typeData = filteredData.filter(function(item) {
                    return (item.type || '默认') === type;
                });
                var counts = new Array(labels.length).fill(0);
                typeData.forEach(function(item) {
                    var l = item.left;
                    var r = item.right;
                    var idx = labels.indexOf(formatBinLabel(l, r));
                    if (idx !== -1) {
                        counts[idx] += showFrequency ? item.value : item.value;
                    }
                });
                result[type] = counts;
            });
            return result;
        }
        types.forEach(function(type) {
            if (!type) return; // Skip undefined types
            var typeData = filteredData.filter(function(item) {
                return (item.type || '默认') === type;
            });
            var counts = new Array(labels.length).fill(0);
            typeData.forEach(function(item) {
                var value = item.value;
                // 找到所属分箱
                for(var i = 0; i < edges.length - 1; i++){
                    if (value >= edges[i] && (value < edges[i + 1] || i === edges.length - 2)) {
                        counts[i]++;
                        break;
                    }
                }
            });
            // 如果需要显示频率而非计数
            if (showFrequency && typeData.length > 0) {
                var total = typeData.length;
                result[type] = counts.map(function(c) {
                    return c / total;
                });
            } else {
                result[type] = counts;
            }
        });
        return result;
    }, [
        filteredData,
        types,
        binning,
        showFrequency,
        isPreBinned
    ]);
    // 构建 Chart.js 数据结构
    var processedData = useMemo(function() {
        var labels = binning.labels;
        if (labels.length === 0) {
            return {
                labels: [],
                datasets: []
            };
        }
        var datasets = types.map(function(type, index) {
            if (!type) return null;
            var provided = color;
            var pickByIndex = function pickByIndex(i) {
                return Array.isArray(provided) ? provided[i] || provided[0] || defaultColorList[i % defaultColorList.length] : provided || defaultColorList[i % defaultColorList.length];
            };
            var baseColor = pickByIndex(index);
            var resolvedBaseColor = resolveCssVariable(baseColor);
            return {
                label: type,
                data: histogramData[type] || [],
                backgroundColor: hexToRgba(resolvedBaseColor, 0.6),
                borderColor: resolvedBaseColor,
                borderWidth: 1,
                categoryPercentage: 1.0,
                barPercentage: 1.0,
                stack: stacked ? 'stack' : undefined,
                borderRadius: 4,
                borderSkipped: false
            };
        });
        return {
            labels: labels,
            datasets: datasets.filter(function(d) {
                return d !== null;
            })
        };
    }, [
        histogramData,
        types,
        binning,
        color,
        stacked
    ]);
    var detectedTheme = useDetectTheme();
    var resolvedTheme = theme !== null && theme !== void 0 ? theme : detectedTheme;
    var isLight = resolvedTheme === 'light';
    var axisTextColor = isLight ? 'rgba(0, 25, 61, 0.3255)' : 'rgba(255, 255, 255, 0.8)';
    var gridColor = isLight ? 'rgba(0,0,0,0.08)' : 'rgba(255,255,255,0.2)';
    // 图表配置选项
    var options = {
        responsive: true,
        maintainAspectRatio: false,
        plugins: {
            legend: {
                display: showLegend && types.length > 1,
                position: legendPosition,
                labels: {
                    color: axisTextColor,
                    font: {
                        size: isMobile ? 10 : 12,
                        weight: 'normal'
                    },
                    padding: isMobile ? 10 : 12,
                    usePointStyle: true,
                    pointStyle: 'rectRounded'
                }
            },
            tooltip: {
                backgroundColor: isLight ? 'rgba(255,255,255,0.95)' : 'rgba(0,0,0,0.85)',
                titleColor: isLight ? '#333' : '#fff',
                bodyColor: isLight ? '#333' : '#fff',
                borderColor: isLight ? 'rgba(0,0,0,0.12)' : 'rgba(255,255,255,0.2)',
                borderWidth: 1,
                cornerRadius: isMobile ? 6 : 8,
                displayColors: true,
                callbacks: {
                    label: function label(context) {
                        var value = context.parsed.y;
                        return "".concat(context.dataset.label, ": ").concat((value !== null && value !== void 0 ? value : 0).toFixed(showFrequency ? 4 : 0));
                    }
                }
            }
        },
        scales: {
            x: {
                stacked: stacked,
                title: {
                    display: !!xAxisLabel,
                    text: xAxisLabel || '值范围',
                    color: axisTextColor,
                    font: {
                        size: isMobile ? 10 : 12,
                        weight: 'normal'
                    }
                },
                grid: {
                    display: showGrid,
                    color: gridColor,
                    lineWidth: 1
                },
                ticks: {
                    color: axisTextColor,
                    font: {
                        size: isMobile ? 8 : 10
                    },
                    maxRotation: 45,
                    minRotation: 0
                }
            },
            y: {
                stacked: stacked,
                beginAtZero: true,
                title: {
                    display: !!yAxisLabel,
                    text: yAxisLabel || (showFrequency ? '频率' : '计数'),
                    color: axisTextColor,
                    font: {
                        size: isMobile ? 10 : 12,
                        weight: 'normal'
                    }
                },
                grid: {
                    display: showGrid,
                    color: gridColor,
                    lineWidth: 1
                },
                ticks: {
                    color: axisTextColor,
                    font: {
                        size: isMobile ? 10 : 12
                    }
                }
            }
        },
        animation: {
            duration: isMobile ? 200 : 400
        }
    };
    var handleDownload = function handleDownload() {
        downloadChart(chartRef.current, 'histogram-chart');
    };
    // 筛选器选项
    var filterOptions = useMemo(function() {
        return categories.map(function(category) {
            return {
                label: category || '默认',
                value: category || '默认'
            };
        });
    }, [
        categories
    ]);
    var filteredDataByFilterLabel = useMemo(function() {
        return filterLabels === null || filterLabels === void 0 ? void 0 : filterLabels.map(function(item) {
            return {
                key: item,
                label: item
            };
        });
    }, [
        filterLabels
    ]);
    // 空数据处理
    if (safeData.length === 0 || filteredData.length === 0) {
        return wrapSSR(/*#__PURE__*/ React.createElement(ChartContainer, {
            baseClassName: classNames("".concat(prefixCls, "-container"), hashId),
            theme: resolvedTheme,
            className: classNames(classNamesProp === null || classNamesProp === void 0 ? void 0 : classNamesProp.root, className),
            isMobile: isMobile,
            variant: props.variant,
            style: _object_spread({
                width: responsiveWidth,
                height: responsiveHeight
            }, style, styles === null || styles === void 0 ? void 0 : styles.root)
        }, /*#__PURE__*/ React.createElement(ChartToolBar, {
            title: title || '直方图',
            onDownload: function onDownload() {},
            extra: toolbarExtra,
            dataTime: dataTime,
            loading: loading
        }), /*#__PURE__*/ React.createElement("div", {
            className: classNames("".concat(prefixCls, "-empty-wrapper"), hashId),
            style: {
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                height: responsiveHeight,
                color: '#999',
                fontSize: '14px'
            }
        }, "暂无有效数据")));
    }
    return wrapSSR(/*#__PURE__*/ React.createElement(ChartContainer, {
        baseClassName: classNames("".concat(prefixCls, "-container"), hashId),
        theme: resolvedTheme,
        className: classNames(classNamesProp === null || classNamesProp === void 0 ? void 0 : classNamesProp.root, className),
        isMobile: isMobile,
        variant: props.variant,
        style: _object_spread({
            width: responsiveWidth,
            height: responsiveHeight
        }, style, styles === null || styles === void 0 ? void 0 : styles.root)
    }, /*#__PURE__*/ React.createElement(ChartToolBar, {
        title: title || '直方图',
        theme: resolvedTheme,
        onDownload: handleDownload,
        extra: toolbarExtra,
        dataTime: dataTime,
        loading: loading,
        filter: renderFilterInToolbar && filterOptions.length > 1 ? /*#__PURE__*/ React.createElement(ChartFilter, _object_spread_props(_object_spread({
            filterOptions: filterOptions,
            selectedFilter: selectedFilter,
            onFilterChange: setSelectedFilter
        }, filterLabels && {
            customOptions: filteredDataByFilterLabel,
            selectedCustomSelection: selectedFilterLabel,
            onSelectionChange: setSelectedFilterLabel
        }), {
            theme: resolvedTheme,
            variant: "compact"
        })) : undefined
    }), statistics && /*#__PURE__*/ React.createElement("div", {
        className: classNames(classNamesProp === null || classNamesProp === void 0 ? void 0 : classNamesProp.statisticContainer, "".concat(prefixCls, "-statistic-container")),
        style: styles === null || styles === void 0 ? void 0 : styles.statisticContainer
    }, statistics.map(function(config, index) {
        return /*#__PURE__*/ React.createElement(ChartStatistic, _object_spread_props(_object_spread({
            key: index
        }, config), {
            theme: resolvedTheme
        }));
    })), !renderFilterInToolbar && filterOptions.length > 1 && /*#__PURE__*/ React.createElement(ChartFilter, _object_spread_props(_object_spread({
        filterOptions: filterOptions,
        selectedFilter: selectedFilter,
        onFilterChange: setSelectedFilter
    }, filterLabels && {
        customOptions: filteredDataByFilterLabel,
        selectedCustomSelection: selectedFilterLabel,
        onSelectionChange: setSelectedFilterLabel
    }), {
        theme: resolvedTheme
    })), /*#__PURE__*/ React.createElement("div", {
        className: classNames(classNamesProp === null || classNamesProp === void 0 ? void 0 : classNamesProp.wrapper, "".concat(prefixCls, "-wrapper")),
        style: _object_spread({
            height: responsiveHeight
        }, styles === null || styles === void 0 ? void 0 : styles.wrapper)
    }, /*#__PURE__*/ React.createElement(Bar, {
        ref: chartRef,
        data: processedData,
        options: options
    }))));
};
export default HistogramChart;
