import { createFormatterByDimension } from "../../../../utils/index.js";
const labelTreeMapGroup = (spec, context)=>{
    const result = {
        ...spec
    };
    const { advancedVSeed } = context;
    const { chartType, dimensions = [], encoding } = advancedVSeed;
    const baseConfig = advancedVSeed.config[chartType];
    const { label } = baseConfig;
    if (!label.enable) return result;
    result.nonLeaf = {
        visible: true
    };
    const dimIds = encoding.hierarchy || [];
    const dimFormatters = dimIds.map((id)=>{
        const dim = dimensions.find((item)=>item.id === id);
        return createFormatterByDimension(dim, advancedVSeed.locale);
    });
    const formatHierarchyName = (name, depth)=>{
        if (!dimFormatters?.[depth]) return name;
        return dimFormatters[depth](name);
    };
    result.nonLeafLabel = {
        visible: true,
        position: 'top',
        padding: 30,
        style: {
            x: (data)=>(data.labelRect?.x0 || 0) + 4,
            textAlign: 'left',
            text: (data)=>formatHierarchyName(String(data.name ?? ''), data.depth),
            fontSize: label?.labelFontSize ?? 12,
            fill: '#000'
        }
    };
    return result;
};
export { labelTreeMapGroup };

//# sourceMappingURL=labelTreeMapGroup.js.map