"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isCompatible = exports.getAdditivityType = exports.PreAggregateAdditivityType = void 0;
const tslib_1 = require("tslib");
const field_1 = require("../../types/field");
const assertUnreachable_1 = tslib_1.__importDefault(require("../../utils/assertUnreachable"));
var PreAggregateAdditivityType;
(function (PreAggregateAdditivityType) {
    PreAggregateAdditivityType["ADDITIVE"] = "additive";
    PreAggregateAdditivityType["DECOMPOSABLE"] = "decomposable";
    PreAggregateAdditivityType["NON_ADDITIVE"] = "non_additive";
})(PreAggregateAdditivityType || (exports.PreAggregateAdditivityType = PreAggregateAdditivityType = {}));
const getAdditivityType = (metricType) => {
    switch (metricType) {
        case field_1.MetricType.SUM:
        case field_1.MetricType.COUNT:
        case field_1.MetricType.MIN:
        case field_1.MetricType.MAX:
            return PreAggregateAdditivityType.ADDITIVE;
        case field_1.MetricType.AVERAGE:
            return PreAggregateAdditivityType.DECOMPOSABLE;
        case field_1.MetricType.COUNT_DISTINCT:
        case field_1.MetricType.SUM_DISTINCT:
        case field_1.MetricType.AVERAGE_DISTINCT:
        case field_1.MetricType.MEDIAN:
        case field_1.MetricType.PERCENTILE:
        case field_1.MetricType.NUMBER:
        case field_1.MetricType.STRING:
        case field_1.MetricType.DATE:
        case field_1.MetricType.TIMESTAMP:
        case field_1.MetricType.BOOLEAN:
        case field_1.MetricType.PERCENT_OF_PREVIOUS:
        case field_1.MetricType.PERCENT_OF_TOTAL:
        case field_1.MetricType.RUNNING_TOTAL:
            return PreAggregateAdditivityType.NON_ADDITIVE;
        default:
            return (0, assertUnreachable_1.default)(metricType, `Unknown metric type`);
    }
};
exports.getAdditivityType = getAdditivityType;
const isCompatible = (metricType) => {
    const additivityType = (0, exports.getAdditivityType)(metricType);
    switch (additivityType) {
        case PreAggregateAdditivityType.ADDITIVE:
        case PreAggregateAdditivityType.DECOMPOSABLE:
            return true;
        case PreAggregateAdditivityType.NON_ADDITIVE:
            return false;
        default:
            return (0, assertUnreachable_1.default)(additivityType, `Unknown additivity type`);
    }
};
exports.isCompatible = isCompatible;
//# sourceMappingURL=additivity.js.map