import { defineComponent as i, watch as n, 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 w } from "../../commons/core/datasource/index.mjs";
import { useChart as O } from "../../commons/core/useChart.mjs";
import { parseDataset as g } from "../../commons/utils/parseDataset.mjs";
const D = { class: "zerov-widget" }, k = ["id"], x = i({ name: "zv-chart-bar-waterfall" }), B = /* @__PURE__ */ i({
  ...x,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {},
    uuid: {}
  },
  emits: [
    "chart-click",
    "chart-dblclick",
    "chart-mousedown",
    "chart-mouseover",
    "chart-mouseout",
    "chart-contextmenu"
  ],
  setup(u, { expose: d, emit: l }) {
    const e = u, p = l, {
      id: m,
      setOption: o,
      chart: h,
      renderChart: c,
      renderData: a
    } = O({
      basicOption: r(e.basicOption),
      useEvents: r(e.useEvents),
      customRenderData: (t) => {
        t = r(t), w.parse({
          tId: e.uuid,
          sources: e.sources,
          callback: ({ data: s }) => {
            try {
              window.SHJParseEvent(e.useEvents, "dataListener", s), t.dataset = g(r(s)), o(t);
            } catch {
              window.SHJParseEvent(e.useEvents, "dataListener", null), o(t);
            }
          }
        });
      },
      emit: p
    });
    return n(() => e.sources, () => {
      e.sources && e.sources.length > 0 && a(e.basicOption);
    }, {
      deep: !0
    }), n(() => r(e.basicOption), (t, s) => {
      E(t, s) || c(t);
    }, {
      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);
      }
    }), (t, s) => (b(), f("div", D, [
      v("div", {
        id: _(m),
        class: "widget"
      }, null, 8, k)
    ]));
  }
});
export {
  B as default
};
