"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRunQueryEchartsConfig = void 0;
const bar_1 = require("./viz/bar");
const funnel_1 = require("./viz/funnel");
const horizontalBar_1 = require("./viz/horizontalBar");
const line_1 = require("./viz/line");
const pie_1 = require("./viz/pie");
const scatter_1 = require("./viz/scatter");
/**
 * Generates echarts options from ToolRunQueryArgs
 * Helpful for generating charts for AI agents on Slack
 * @param queryTool - ToolRunQueryArgsTransformed
 * @param queryResults - QueryResults
 * @param getPivotedResults - Function to pivot data (backend dependency)
 * @returns EChartsOption | null
 */
const getRunQueryEchartsConfig = async (queryTool, queryResults, getPivotedResults) => {
    const chartType = queryTool.chartConfig?.defaultVizType ?? 'table';
    // Don't render table as image
    if (chartType === 'table') {
        return Promise.resolve(null);
    }
    const { rows, fields: fieldsMap } = queryResults;
    // Empty data - don't render
    if (rows.length === 0) {
        return Promise.resolve(null);
    }
    switch (chartType) {
        case 'bar':
            return (0, bar_1.getBarChartEchartsConfig)(queryTool, rows, fieldsMap, getPivotedResults);
        case 'horizontal':
            return (0, horizontalBar_1.getHorizontalBarChartEchartsConfig)(queryTool, rows, fieldsMap, getPivotedResults);
        case 'line':
            return (0, line_1.getLineChartEchartsConfig)(queryTool, rows, fieldsMap, getPivotedResults);
        case 'scatter':
            return (0, scatter_1.getScatterChartEchartsConfig)(queryTool, rows, fieldsMap, getPivotedResults);
        case 'pie':
            return (0, pie_1.getPieChartEchartsConfig)(queryTool, rows);
        case 'funnel':
            return (0, funnel_1.getFunnelChartEchartsConfig)(queryTool, rows, fieldsMap);
        default:
            return Promise.resolve(null);
    }
};
exports.getRunQueryEchartsConfig = getRunQueryEchartsConfig;
//# sourceMappingURL=getRunQueryEchartsConfig.js.map