import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2023-2026 GoodData Corporation
import { cloneDeep, set } from "lodash-es";
import { useIntl } from "react-intl";
import { getComparisonRgbColor } from "@gooddata/sdk-ui-charts";
import { DisabledBubbleMessage } from "../../../../DisabledBubbleMessage.js";
import { ColorDropdown } from "../../../colors/colorDropdown/ColorDropdown.js";
import { ColoredItemContent } from "../../../colors/coloredItemsList/ColoredItemContent.js";
export function ColorItem({ disabled, align, showDisabledMessage, color, colorType, colorPalette, labelDescriptor, valuePath, properties, pushData, }) {
    const { formatMessage } = useIntl();
    const label = formatMessage(labelDescriptor);
    const rgbColor = getComparisonRgbColor(color, colorType, colorPalette);
    const chartFill = properties?.controls?.["chartFill"];
    const handleColorSelected = (color) => {
        const clonedProperties = cloneDeep(properties);
        set(clonedProperties.controls, valuePath, color);
        pushData({ properties: clonedProperties });
    };
    return (_jsx(DisabledBubbleMessage, { showDisabledMessage: !!showDisabledMessage, children: _jsx(ColorDropdown, { colorPalette: colorPalette, onColorSelected: handleColorSelected, selectedColorItem: color, disabled: disabled, children: _jsx(ColoredItemContent, { text: label, align: align, color: rgbColor, chartFill: chartFill }) }) }));
}
//# sourceMappingURL=ColorItem.js.map