"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isVizTableConfig = exports.isVizPieChartConfig = exports.isVizCartesianChartConfig = exports.isVizLineChartConfig = exports.isVizBarChartConfig = exports.isPivotChartLayout = exports.StackType = exports.AxisSide = exports.VizIndexType = exports.VIZ_DEFAULT_AGGREGATION = exports.vizAggregationOptions = exports.SortByDirection = exports.VizAggregationOptions = void 0;
exports.getColumnAxisType = getColumnAxisType;
exports.getTableCalculationAxisType = getTableCalculationAxisType;
const field_1 = require("../../types/field");
const savedCharts_1 = require("../../types/savedCharts");
var VizAggregationOptions;
(function (VizAggregationOptions) {
    VizAggregationOptions["SUM"] = "sum";
    VizAggregationOptions["COUNT"] = "count";
    VizAggregationOptions["AVERAGE"] = "avg";
    VizAggregationOptions["MIN"] = "min";
    VizAggregationOptions["MAX"] = "max";
    VizAggregationOptions["ANY"] = "any";
})(VizAggregationOptions || (exports.VizAggregationOptions = VizAggregationOptions = {}));
var SortByDirection;
(function (SortByDirection) {
    SortByDirection["ASC"] = "ASC";
    SortByDirection["DESC"] = "DESC";
})(SortByDirection || (exports.SortByDirection = SortByDirection = {}));
exports.vizAggregationOptions = [
    VizAggregationOptions.SUM,
    VizAggregationOptions.COUNT,
    VizAggregationOptions.AVERAGE,
    VizAggregationOptions.MIN,
    VizAggregationOptions.MAX,
    VizAggregationOptions.ANY,
];
exports.VIZ_DEFAULT_AGGREGATION = VizAggregationOptions.COUNT;
var VizIndexType;
(function (VizIndexType) {
    VizIndexType["TIME"] = "time";
    VizIndexType["CATEGORY"] = "category";
})(VizIndexType || (exports.VizIndexType = VizIndexType = {}));
var AxisSide;
(function (AxisSide) {
    AxisSide[AxisSide["LEFT"] = 0] = "LEFT";
    AxisSide[AxisSide["RIGHT"] = 1] = "RIGHT";
})(AxisSide || (exports.AxisSide = AxisSide = {}));
var StackType;
(function (StackType) {
    StackType["NONE"] = "none";
    StackType["NORMAL"] = "stack";
    StackType["PERCENT"] = "stack100";
})(StackType || (exports.StackType = StackType = {}));
function getColumnAxisType(dimensionType) {
    switch (dimensionType) {
        case field_1.DimensionType.DATE:
        case field_1.DimensionType.TIMESTAMP:
            return VizIndexType.TIME;
        case field_1.DimensionType.BOOLEAN:
        case field_1.DimensionType.NUMBER:
        case field_1.DimensionType.STRING:
        default:
            return VizIndexType.CATEGORY;
    }
}
function getTableCalculationAxisType(tableCalculationType) {
    switch (tableCalculationType) {
        case field_1.TableCalculationType.DATE:
        case field_1.TableCalculationType.TIMESTAMP:
            return VizIndexType.TIME;
        default:
            return VizIndexType.CATEGORY;
    }
}
const isPivotChartLayout = (obj) => {
    if (typeof obj !== 'object' || obj === null) {
        return false;
    }
    // PivotChartLayout.y is always an array of { reference, aggregation }.
    // A VizColumnsConfig could have a column named "y" but its value would be
    // a VizColumnConfig object (with label, frozen, visible), never an array.
    if ('y' in obj && Array.isArray(obj.y)) {
        return true;
    }
    return false;
};
exports.isPivotChartLayout = isPivotChartLayout;
const isVizBarChartConfig = (value) => !!value && value.type === savedCharts_1.ChartKind.VERTICAL_BAR;
exports.isVizBarChartConfig = isVizBarChartConfig;
const isVizLineChartConfig = (value) => !!value && value.type === savedCharts_1.ChartKind.LINE;
exports.isVizLineChartConfig = isVizLineChartConfig;
const isVizCartesianChartConfig = (value) => !!value &&
    (value.type === savedCharts_1.ChartKind.LINE || value.type === savedCharts_1.ChartKind.VERTICAL_BAR);
exports.isVizCartesianChartConfig = isVizCartesianChartConfig;
const isVizPieChartConfig = (value) => !!value && value.type === savedCharts_1.ChartKind.PIE;
exports.isVizPieChartConfig = isVizPieChartConfig;
const isVizTableConfig = (value) => !!value && value.type === savedCharts_1.ChartKind.TABLE;
exports.isVizTableConfig = isVizTableConfig;
//# sourceMappingURL=index.js.map