// (C) 2022 GoodData Corporation
import { BucketNames } from "@gooddata/sdk-ui";
import { getBucketItems } from "../../../utils/bucketHelper.js";
function areAllMeasuresOnSingleAxis(buckets, secondaryAxis) {
    const measures = getBucketItems(buckets, BucketNames.MEASURES);
    const measureCount = measures.length;
    const numberOfMeasureOnSecondaryAxis = secondaryAxis.measures?.length ?? 0;
    return numberOfMeasureOnSecondaryAxis === 0 || measureCount === numberOfMeasureOnSecondaryAxis;
}
export function canSortStackTotalValue(buckets, properties) {
    const supportedControls = properties?.controls;
    const stackMeasures = supportedControls?.["stackMeasures"] ?? false;
    const secondaryAxis = supportedControls?.["secondary_xaxis"] ?? { measures: [] };
    const allMeasuresOnSingleAxis = areAllMeasuresOnSingleAxis(buckets, secondaryAxis);
    return stackMeasures && allMeasuresOnSingleAxis;
}
//# sourceMappingURL=sortHelpers.js.map