var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
        r = Reflect.decorate(decorators, target, key, desc);
    else
        for (var i = decorators.length - 1; i >= 0; i--)
            if (d = decorators[i])
                r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
            t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import { h, Host } from "@stencil/core";
import { BarChart } from "../../../helpers/chart/bar-chart";
import { InjectVegaGlobalSlimmer, InjectVegaSlimmer } from "../../../../../../vega-slimmer/vega-slimmer-core";
import { VegaComponentUsageRuntimeMetricsSlimmer } from "../../../helpers/slimmers/component-usage-runtime-metrics";
/**
 * @vegaVersion 1.33.0
 */
export class VegaBarChart {
    constructor() {
        this.globalSlimmers = {};
        this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
        /**
         * Specifies the rendering options for the bar chart.
         *
         * @vegaVersion 1.33.0
         */
        this.options = {};
    }
    watchOptions(options) {
        this.initChart(options);
    }
    componentWillLoad() {
        this.initChart(this.options);
    }
    render() {
        return h(Host, { key: '4cc728ae4f8b87c54e24a8b080c91fbac8fd6269' });
    }
    /**
     * This function draws a bar chart using the provided options and data source.
     *
     * @param {LineChartOptionsType} options - The options parameter is an object that contains various options for configuring and rendering a line chart.
     */
    initChart(options) {
        const { mode = 'svg', dataSource = [] } = options, restOptions = __rest(options, ["mode", "dataSource"]);
        const mergedOptions = Object.assign(Object.assign({}, restOptions), { mode, container: this.host, dataSource: dataSource });
        if (this.chart) {
            this.chart.updateOptions(mergedOptions);
        }
        else {
            this.chart = new BarChart(mergedOptions);
            this.chart.render();
        }
    }
    static get is() { return "vega-bar-chart"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["vega-bar-chart.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["vega-bar-chart.css"]
        };
    }
    static get properties() {
        return {
            "options": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "VegaBarChartOptionsType",
                    "resolved": "\"container\" | { dataSource: ChartDataSourceItem[]; direction?: directionType; }",
                    "references": {
                        "VegaBarChartOptionsType": {
                            "location": "import",
                            "path": "./types",
                            "id": "src/components/vega-chart/vega-bar-chart/types.d.ts::VegaBarChartOptionsType",
                            "referenceLocation": "VegaBarChartOptionsType"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [{
                            "name": "vegaVersion",
                            "text": "1.33.0"
                        }],
                    "text": "Specifies the rendering options for the bar chart."
                },
                "getter": false,
                "setter": false,
                "defaultValue": "{}"
            }
        };
    }
    static get elementRef() { return "host"; }
    static get watchers() {
        return [{
                "propName": "options",
                "methodName": "watchOptions"
            }];
    }
}
__decorate([
    InjectVegaGlobalSlimmer()
], VegaBarChart.prototype, "globalSlimmers", void 0);
__decorate([
    InjectVegaSlimmer()
], VegaBarChart.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
