import { clone } from "remeda";
import { isCommonMeasureEncoding } from "./utils.js";
const buildMeasuresForScatter = (advancedVSeed)=>{
    const { measures = [] } = advancedVSeed;
    const encodedMeasures = [];
    for(let index = 0; index < measures.length; index++){
        const item = measures[index];
        const encoding = item.encoding;
        const isYAxis = 'yAxis' === encoding;
        const isXAxis = 'xAxis' === encoding;
        const isOtherEncoding = item.encoding && isCommonMeasureEncoding(encoding);
        if (isYAxis) encodedMeasures.push(item);
        else if (isXAxis) encodedMeasures.push(item);
        else if (!isOtherEncoding && 'size' !== encoding) {
            const xCount = encodedMeasures.filter((m)=>'xAxis' === m.encoding).length;
            item.encoding = 0 === xCount ? 'xAxis' : 'yAxis';
            encodedMeasures.push(item);
        }
    }
    const xCount = encodedMeasures.filter((m)=>'xAxis' === m.encoding).length;
    const yCount = encodedMeasures.filter((m)=>'yAxis' === m.encoding).length;
    if (0 === yCount && xCount > 0) {
        const cloneMeasure = clone(encodedMeasures[0]);
        cloneMeasure.encoding = 'yAxis';
        encodedMeasures.push(cloneMeasure);
    }
    advancedVSeed.reshapeMeasures = encodedMeasures.length > 0 ? [
        encodedMeasures
    ] : [];
    return advancedVSeed;
};
export { buildMeasuresForScatter };

//# sourceMappingURL=buildMeasuresForScatter.js.map