import { isArray } from "@visactor/vutils";
import { createFormatterByDimension } from "../../../../utils/index.js";
import { MeasureId } from "../../../../../dataReshape/index.js";
const radarAngleAxis = (spec, context)=>{
    const result = {
        ...spec
    };
    const { advancedVSeed } = context;
    const { dimensions = [], encoding, datasetReshapeInfo, pivotAllDatasetReshapeInfo } = advancedVSeed;
    if (!result.axes) result.axes = [];
    const onlyMeasureId = 0 === (encoding.angle || []).filter((v)=>v !== MeasureId).length;
    const dimensionMap = new Map(dimensions.map((item)=>[
            item.id,
            item
        ]));
    const dimIds = (encoding.angle || []).filter((v)=>v !== MeasureId);
    const dimFormatter = dimIds.length ? createFormatterByDimension(dimensionMap.get(dimIds[0]), advancedVSeed.locale) : null;
    const allDatasetReshapeInfo = pivotAllDatasetReshapeInfo || datasetReshapeInfo;
    const colorIdMap = allDatasetReshapeInfo.reduce((prev, cur)=>({
            ...prev,
            ...cur.unfoldInfo.colorIdMap
        }), {});
    result.axes.push({
        orient: 'angle',
        visible: true,
        zero: true,
        nice: true,
        label: {
            formatMethod: (text)=>{
                if (isArray(text)) return text;
                if (onlyMeasureId) return colorIdMap[String(text)]?.alias ?? text;
                const rawText = String(text ?? '');
                if (!dimFormatter) return rawText;
                return dimFormatter(rawText);
            }
        },
        grid: {
            visible: true
        },
        domainLine: {
            visible: true
        },
        tick: {
            visible: true
        }
    });
    return result;
};
export { radarAngleAxis };

//# sourceMappingURL=radarAngle.js.map