define(["require", "exports", "react"], function (require, exports, React) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.renderScatterPolarCategoryLabels = void 0;
    /**
     * Helper to render categorical labels for scatterpolar charts with improved overlap logic across all series
     * Now places labels at equal angles for all unique texts, regardless of data positions.
     */
    function renderScatterPolarCategoryLabels(_a) {
        var allSeriesData = _a.allSeriesData, xAxisScale = _a.xAxisScale, yAxisScale = _a.yAxisScale, className = _a.className, maybeLineOptions = _a.maybeLineOptions, _b = _a.minPixelGap, minPixelGap = _b === void 0 ? 40 : _b;
        // 1. Aggregate all data points from all series
        var allLabels = [];
        allSeriesData.forEach(function (series) {
            series.data.forEach(function (pt) {
                if (pt.text) {
                    allLabels.push({ x: pt.x, y: pt.y, text: pt.text });
                }
            });
        });
        // 2. Deduplicate by text (angle label)
        var uniqueTexts = Array.from(new Set(allLabels.map(function (l) { return l.text; })));
        // 3. Place labels at equal angles
        var renderedLabels = [];
        var placedPositions = [];
        var labelRadius = 0.7; // You can adjust this value for more/less offset
        var numLabels = uniqueTexts.length;
        uniqueTexts.forEach(function (text, i) {
            var angle = ((2 * Math.PI) / numLabels) * i;
            var originXOffset = (maybeLineOptions === null || maybeLineOptions === void 0 ? void 0 : maybeLineOptions.originXOffset) || 0;
            var x = xAxisScale(labelRadius * Math.cos(angle) - originXOffset / 2);
            var y = yAxisScale(labelRadius * Math.sin(angle));
            // Check distance from all previously placed labels
            var isFarEnough = placedPositions.every(function (pos) { return Math.sqrt(Math.pow((x - pos.x), 2) + Math.pow((y - pos.y), 2)) >= minPixelGap; });
            if (renderedLabels.length === 0 || isFarEnough) {
                renderedLabels.push(React.createElement("text", { key: "scatterpolar-label-".concat(text), x: x, y: y, className: className, textAnchor: "middle", alignmentBaseline: "middle", opacity: 1 }, text));
                placedPositions.push({ x: x, y: y });
            }
        });
        return renderedLabels;
    }
    exports.renderScatterPolarCategoryLabels = renderScatterPolarCategoryLabels;
});
//# sourceMappingURL=scatterpolar-utils.js.map