'use strict';

var index = require('./index-Bq84pjsN.js');

const resetCss = () => `@layer reset, base, variants, states, sizes;  @layer reset {   :host {     display: contents;     -moz-text-size-adjust: none;     -webkit-text-size-adjust: none;     text-size-adjust: none;     font-family: var(--dds-font-family-sans);     font-feature-settings: var(--dds-font-features-sans);     text-rendering: optimizeLegibility;     -webkit-font-smoothing: antialiased;      *,     *::after,     *::before,     *::backdrop,     *::file-selector-button {       box-sizing: border-box;       margin: 0;       padding: 0;       min-inline-size: 0;       min-block-size: 0;     }      * {       scrollbar-width: thin;       scrollbar-color: color-mix(gray 50%, transparent);     }      *:focus-visible {       z-index: 1;     }      > * {       interpolate-size: allow-keywords;       -webkit-tap-highlight-color: transparent;     }   } } `;

const chartCss = () => ``;

const Chart = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
    }
    get el() { return index.getElement(this); }
    type = "bar";
    option;
    chartInstance = null;
    async componentDidLoad() {
        await this.initChart();
    }
    async onTypeChange() {
        this.chartInstance?.dispose();
        await this.initChart();
    }
    async initChart() {
        const container = this.el.shadowRoot?.querySelector('.chart');
        if (!container)
            return;
        // Core is always needed - but loaded once
        const echarts = await Promise.resolve().then(function () { return require('./core-v2xqBLM4.js'); });
        const { CanvasRenderer } = await Promise.resolve().then(function () { return require('./renderers-Bd0qdJZf.js'); });
        const { GridComponent, TooltipComponent, LegendComponent } = await Promise.resolve().then(function () { return require('./components-DCgxReQm.js'); });
        // Only load the chart module you actually need
        const chartModule = await this.loadChartModule();
        echarts.use([CanvasRenderer, GridComponent, TooltipComponent,
            LegendComponent, chartModule]);
        this.chartInstance = echarts.init(container);
        this.chartInstance.setOption(this.option);
    }
    async loadChartModule() {
        switch (this.type) {
            case 'bar':
                return (await Promise.resolve().then(function () { return require('./charts-D_kDgs0Z.js'); })).BarChart;
            case 'line':
                return (await Promise.resolve().then(function () { return require('./charts-D_kDgs0Z.js'); })).LineChart;
            case 'pie':
                return (await Promise.resolve().then(function () { return require('./charts-D_kDgs0Z.js'); })).PieChart;
            default:
                throw new Error(`Unknown chart type: ${this.type}`);
        }
    }
    disconnectedCallback() {
        this.chartInstance?.dispose();
    }
    render() {
        return index.jsx("div", { class: "chart", style: { width: '100%', height: '100%' } }, '8463ec1ac51060691875a0372a9562984cc2c5c7');
    }
    static get watchers() { return {
        "type": [{
                "onTypeChange": 0
            }]
    }; }
};
Chart.style = resetCss() + chartCss();

exports.dds_chart = Chart;
