import { selector } from "../../../../../dataSelector/index.js";
import { isEmpty, isNullish } from "remeda";
const boxPlotStyle_boxPlotStyle = (spec, context)=>{
    const { advancedVSeed, vseed } = context;
    const { markStyle, config } = advancedVSeed;
    const { boxPlotStyle } = markStyle;
    const { chartType } = vseed;
    const theme = config?.[chartType]?.boxPlotStyle;
    const result = {
        ...spec,
        boxPlot: {
            style: {
                shaftShape: 'filled-line',
                visible: true,
                shaftWidth: '50%',
                stroke: theme?.whiskerBorderColor,
                boxStroke: theme?.boxBorderColor,
                boxCornerRadius: theme?.boxCornerRadius,
                medianStroke: theme?.medianBorderColor ?? theme?.boxBorderColor
            }
        }
    };
    if (isNullish(boxPlotStyle) || isEmpty(boxPlotStyle)) return result;
    const boxPlotStyles = Array.isArray(boxPlotStyle) ? boxPlotStyle : [
        boxPlotStyle
    ];
    const customMap = boxPlotStyles.reduce((result, style, index)=>{
        const { boxColor, boxColorOpacity, boxBorderColor, boxBorderWidth = 1, boxVisible = true, boxBorderOpacity, medianBorderColor, whiskerBorderColor, boxCornerRadius } = style;
        return {
            ...result,
            [`custom${index + 1}`]: {
                level: index + 1,
                filter: (datum)=>{
                    if (selector(datum, style.selector)) return true;
                    return false;
                },
                style: {
                    visible: boxVisible,
                    fill: boxColor,
                    fillOpacity: boxColorOpacity,
                    lineWidth: boxBorderWidth,
                    stroke: whiskerBorderColor,
                    boxStroke: boxBorderColor,
                    boxCornerRadius: boxCornerRadius,
                    strokeOpacity: boxBorderOpacity,
                    medianStroke: medianBorderColor ?? boxBorderColor
                }
            }
        };
    }, {});
    result.boxPlot.state = {
        ...result.boxPlot.state,
        ...customMap
    };
    return result;
};
export { boxPlotStyle_boxPlotStyle as boxPlotStyle };

//# sourceMappingURL=boxPlotStyle.js.map