import { createNumFormatter, isAreaPercent, isBarPercent, isColumnPercent, isPivotChart } from "../../../../utils/index.js";
import { createLinearFormat, createLinearPercentFormat } from "./format/linearFormat.js";
import { defaultTitleText } from "./title/defaultTitleText.js";
import { linearAxisStyle } from "./linearAxisStyle.js";
const yLinear = (spec, context)=>{
    const result = {
        ...spec
    };
    const { advancedVSeed, vseed } = context;
    const { chartType } = vseed;
    const { measures = [], dimensions = [], encoding } = advancedVSeed;
    const config = advancedVSeed.config?.[chartType]?.yAxis ?? {};
    if (!result.axes) result.axes = [];
    const isPivot = isPivotChart(vseed);
    const { autoFormat, numFormat = {} } = config;
    const formatter = createNumFormatter(numFormat);
    const percentFormatter = createNumFormatter({
        type: 'percent'
    });
    const formatMethod = (value)=>{
        if (isBarPercent(vseed) || isColumnPercent(vseed) || isAreaPercent(vseed)) return createLinearPercentFormat(value, autoFormat, numFormat, formatter, percentFormatter);
        return createLinearFormat(value, autoFormat, numFormat, formatter);
    };
    const titleText = config.title?.titleText || defaultTitleText(measures, dimensions, encoding.y);
    const linearAxis = linearAxisStyle({
        ...config,
        orient: 'left',
        formatMethod,
        titleText,
        isPivot
    });
    result.axes = [
        ...result.axes,
        linearAxis
    ];
    return result;
};
export { yLinear };

//# sourceMappingURL=yLinear.js.map