"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSupportedMetricType = exports.getMetricRepresentation = exports.supportedMetricTypes = exports.PreAggregateMetricRepresentationKind = void 0;
const tslib_1 = require("tslib");
const field_1 = require("../../types/field");
const assertUnreachable_1 = tslib_1.__importDefault(require("../../utils/assertUnreachable"));
var PreAggregateMetricRepresentationKind;
(function (PreAggregateMetricRepresentationKind) {
    PreAggregateMetricRepresentationKind["DIRECT"] = "direct";
    PreAggregateMetricRepresentationKind["DECOMPOSED"] = "decomposed";
    PreAggregateMetricRepresentationKind["UNSUPPORTED"] = "unsupported";
})(PreAggregateMetricRepresentationKind || (exports.PreAggregateMetricRepresentationKind = PreAggregateMetricRepresentationKind = {}));
exports.supportedMetricTypes = [
    field_1.MetricType.SUM,
    field_1.MetricType.COUNT,
    field_1.MetricType.MIN,
    field_1.MetricType.MAX,
    field_1.MetricType.AVERAGE,
];
const getMetricRepresentation = (metricType) => {
    switch (metricType) {
        case field_1.MetricType.SUM:
        case field_1.MetricType.COUNT:
            return {
                kind: PreAggregateMetricRepresentationKind.DIRECT,
                metricType: field_1.MetricType.SUM,
            };
        case field_1.MetricType.MIN:
            return {
                kind: PreAggregateMetricRepresentationKind.DIRECT,
                metricType: field_1.MetricType.MIN,
            };
        case field_1.MetricType.MAX:
            return {
                kind: PreAggregateMetricRepresentationKind.DIRECT,
                metricType: field_1.MetricType.MAX,
            };
        case field_1.MetricType.AVERAGE:
            return {
                kind: PreAggregateMetricRepresentationKind.DECOMPOSED,
                metricType: field_1.MetricType.AVERAGE,
                components: ['sum', 'count'],
            };
        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 {
                kind: PreAggregateMetricRepresentationKind.UNSUPPORTED,
            };
        default:
            return (0, assertUnreachable_1.default)(metricType, `Unknown metric type`);
    }
};
exports.getMetricRepresentation = getMetricRepresentation;
const isSupportedMetricType = (metricType) => (0, exports.getMetricRepresentation)(metricType).kind !==
    PreAggregateMetricRepresentationKind.UNSUPPORTED;
exports.isSupportedMetricType = isSupportedMetricType;
//# sourceMappingURL=metricRepresentation.js.map