"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSlackAiEchartsConfig = void 0;
const types_1 = require("../../types");
const getVerticalBarChartEchartsConfig_1 = require("./generateBarVizConfigTool/getVerticalBarChartEchartsConfig");
const getTimeSeriesChartEchartsConfig_1 = require("./generateTimeSeriesVizConfigTool/getTimeSeriesChartEchartsConfig");
const getRunQueryEchartsConfig_1 = require("./runQueryTool/getRunQueryEchartsConfig");
/**
 * Main function to generate echarts config for Slack AI agents
 * Decides which specific echarts config function to use based on the tool type
 *
 * @param toolArgs - Discriminated union of tool arguments with type
 * @param queryResults - Query results from running the query
 * @param getPivotedResults - Function to pivot data (backend dependency)
 * @returns EChartsOption | null
 */
const getSlackAiEchartsConfig = async ({ toolArgs, queryResults, getPivotedResults, }) => {
    // Empty data - don't render
    if (queryResults.rows.length === 0) {
        return null;
    }
    switch (toolArgs.type) {
        case types_1.AiResultType.QUERY_RESULT:
            return (0, getRunQueryEchartsConfig_1.getRunQueryEchartsConfig)(toolArgs.tool, queryResults, getPivotedResults);
        case types_1.AiResultType.TIME_SERIES_RESULT:
            return (0, getTimeSeriesChartEchartsConfig_1.getTimeSeriesChartEchartsConfig)(toolArgs.tool, queryResults.rows, queryResults.fields, toolArgs.tool.vizConfig.sorts, getPivotedResults);
        case types_1.AiResultType.VERTICAL_BAR_RESULT:
            return (0, getVerticalBarChartEchartsConfig_1.getVerticalBarChartEchartsConfig)(toolArgs.tool, queryResults.rows, queryResults.fields, toolArgs.tool.vizConfig.sorts, getPivotedResults);
        case types_1.AiResultType.TABLE_RESULT:
            // Tables don't render as echarts images
            return null;
        default:
            return null;
    }
};
exports.getSlackAiEchartsConfig = getSlackAiEchartsConfig;
//# sourceMappingURL=getSlackAiEchartsConfig.js.map