import { isNumber } from "remeda";
import { intl } from "../../../../../i18n/index.js";
import { createFormatterByMeasure, findAllMeasures } from "../../../../utils/index.js";
const pivotIndicators = (spec, context)=>{
    const { advancedVSeed, vseed } = context;
    const { measureTree } = advancedVSeed;
    const measures = findAllMeasures(measureTree);
    const indicatorsAsCol = vseed.indicatorsAsCol ?? false;
    return {
        ...spec,
        indicatorTitle: intl.i18n`指标名称`,
        indicatorsAsCol,
        hideIndicatorName: measures.length <= 1,
        indicators: measures.map((measure)=>{
            const formatter = createFormatterByMeasure(measure);
            return {
                cellType: 'text',
                indicatorKey: measure.id,
                title: measure.alias || measure.id,
                width: 'auto',
                format: (value, col, row, table)=>{
                    if (!isNumber(col) || !isNumber(row) || !table) return value;
                    const datum = table.getCellOriginRecord(col, row);
                    if (!datum?.[0]) return value;
                    return formatter(value);
                }
            };
        })
    };
};
export { pivotIndicators };

//# sourceMappingURL=pivotIndicators.js.map