import { selector, selectorWithDynamicFilter } from "../../../../../dataSelector/index.js";
import { isEmpty, isNullish } from "remeda";
const pointStyle_pointStyle = (spec, context)=>{
    const { advancedVSeed } = context;
    const { markStyle } = advancedVSeed;
    const { pointStyle } = markStyle;
    const result = {
        ...spec,
        point: {
            style: {}
        }
    };
    if (isNullish(pointStyle) || isEmpty(pointStyle)) return result;
    const pointStyles = Array.isArray(pointStyle) ? pointStyle : [
        pointStyle
    ];
    const customMap = pointStyles.reduce((result, style, index)=>{
        const { pointBorderColor, pointBorderStyle, pointBorderWidth = 1, pointColor, pointColorOpacity, pointSize, pointVisible = true } = style;
        const lineDash = 'dashed' === pointBorderStyle ? [
            5,
            2
        ] : 'dotted' === pointBorderStyle ? [
            2,
            5
        ] : [
            0,
            0
        ];
        return {
            ...result,
            [`custom${index + 1}`]: {
                level: index + 1,
                filter: (datum)=>{
                    const shouldApply = style.dynamicFilter ? selectorWithDynamicFilter(datum, style.dynamicFilter, style.selector) : selector(datum, style.selector);
                    if (shouldApply) return true;
                    return false;
                },
                style: {
                    visible: pointVisible,
                    size: pointSize,
                    fill: pointColor,
                    fillOpacity: pointColorOpacity,
                    innerBorder: {
                        stroke: pointBorderColor,
                        lineWidth: pointBorderWidth,
                        distance: (pointBorderWidth || 0) / 2,
                        lineDash: lineDash
                    }
                }
            }
        };
    }, {});
    return {
        ...result,
        point: {
            ...result.point,
            state: {
                ...customMap
            }
        }
    };
};
export { pointStyle_pointStyle as pointStyle };

//# sourceMappingURL=pointStyle.js.map