'use client';
import classNames from '../external/classnames/index.js';
import React__default from 'react';
import styles from './chart-components.module.css.js';

/* Default palette is Blue */
var DEFAULT_COLORS = ["3b82f6", "bfdbfe", "2563eb", "93c5fd", "1d4ed8", "60a5fa"];
function createColorMap(_a) {
    var categories = _a.categories, colors = _a.colors;
    var colorMap = new Map();
    for (var i = 0; i < categories.length; i++) {
        colorMap.set(categories[i], colors[i % colors.length]);
    }
    return colorMap;
}
function ChartLegend(_a) {
    var _b;
    var colorMap = _a.colorMap, dark = _a.dark, payload = _a.payload;
    return (React__default.createElement("div", { className: classNames(styles.legend, (_b = {}, _b[styles.dark] = dark, _b)) }, payload.map(function (_a, index) {
        var value = _a.value;
        return (React__default.createElement("div", { className: styles.row, key: index },
            React__default.createElement("span", { className: styles.dot, style: { backgroundColor: colorMap.get(String(value)) } }),
            React__default.createElement("span", { className: styles.name }, value)));
    })));
}
function ChartTooltip(_a) {
    var _b;
    var active = _a.active, colorMap = _a.colorMap, dark = _a.dark, payload = _a.payload, label = _a.label;
    if (active && payload && payload.length) {
        return (React__default.createElement("div", { className: classNames(styles.tooltip, (_b = {}, _b[styles.dark] = dark, _b)) },
            label ? React__default.createElement("div", null, label) : null,
            payload.map(function (_a, index) {
                var name = _a.name, value = _a.value;
                return (React__default.createElement("div", { className: styles.row, key: index },
                    React__default.createElement("span", { className: styles.dot, style: { backgroundColor: colorMap.get(String(name)) } }),
                    React__default.createElement("span", { className: styles.name }, name !== null && name !== void 0 ? name : ""),
                    React__default.createElement("span", { className: styles.value }, value)));
            })));
    }
    return null;
}

export { ChartLegend, ChartTooltip, DEFAULT_COLORS, createColorMap };
//# sourceMappingURL=chart-components.js.map
