import { defineComponent as n, watch as i, createElementBlock as f, openBlock as b, createElementVNode as v, unref as _ } from "vue";
import { cloneDeep as r, isEqual as E } from "lodash";
import { SHJDatasourceV2 as O } from "../../commons/core/datasource/index.mjs";
import { useChart as w } from "../../commons/core/useChart.mjs";
import { parseDataset as k } from "../../commons/utils/parseDataset.mjs";
import { cloneSeries as D } from "../../commons/utils/cloneSeries.mjs";
const g = { class: "zerov-widget" }, x = ["id"], S = n({ name: "zv-chart-bar-horizontal-stack" }), L = /* @__PURE__ */ n({
  ...S,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {},
    uuid: {}
  },
  emits: [
    "chart-click",
    "chart-dblclick",
    "chart-mousedown",
    "chart-mouseover",
    "chart-mouseout",
    "chart-contextmenu"
  ],
  setup(u, { expose: d, emit: m }) {
    const e = u, l = m, {
      id: p,
      setOption: o,
      chart: h,
      renderChart: c,
      renderData: a
    } = w({
      basicOption: r(e.basicOption),
      useEvents: r(e.useEvents),
      customRenderData: (s) => {
        s = r(s), O.parse({
          tId: e.uuid,
          sources: e.sources,
          callback: ({ data: t }) => {
            try {
              window.SHJParseEvent(e.useEvents, "dataListener", t), s.dataset = k(r(t)), s.series = D(t, s.series), o(s);
            } catch {
              window.SHJParseEvent(e.useEvents, "dataListener", null), o(s);
            }
          }
        });
      },
      emit: l
    });
    return i(() => e.sources, () => {
      a(e.basicOption);
    }, {
      deep: !0
    }), i(() => r(e.basicOption), (s, t) => {
      E(s, t) || c(s);
    }, {
      deep: !0
    }), d({
      getEchartsInstance: () => h.value,
      refresh: () => {
        e.sources && e.sources.length > 0 && c(e.basicOption), a(e.basicOption);
      },
      refreshView: () => {
        e.sources && e.sources.length > 0 && c(e.basicOption);
      },
      refreshData: () => {
        a(e.basicOption);
      }
    }), (s, t) => (b(), f("div", g, [
      v("div", {
        id: _(p),
        class: "widget"
      }, null, 8, x)
    ]));
  }
});
export {
  L as default
};
