import { defineComponent as i, watch as n, createElementBlock as f, openBlock as v, createElementVNode as _, unref as b } 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";
const g = { class: "zerov-widget" }, k = ["id"], D = i({ name: "zv-chart-other-tree" }), V = /* @__PURE__ */ i({
  ...D,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {},
    uuid: {}
  },
  emits: [
    "chart-click",
    "chart-dblclick",
    "chart-mousedown",
    "chart-mouseover",
    "chart-mouseout",
    "chart-contextmenu"
  ],
  setup(u, { expose: d, emit: p }) {
    const e = u, h = p, {
      id: l,
      setOption: o,
      chart: m,
      renderChart: c,
      renderData: a
    } = w({
      basicOption: r(e.basicOption),
      useEvents: r(e.useEvents),
      customRenderData: (t) => {
        t = r(t), O.parse({
          tId: e.uuid,
          sources: e.sources,
          callback: ({ data: s }) => {
            try {
              window.SHJParseEvent(e.useEvents, "dataListener", s), t.series[0].data = r(s[0].data), o(t);
            } catch {
              window.SHJParseEvent(e.useEvents, "dataListener", null), o(t);
            }
          }
        });
      },
      emit: h
    });
    return n(() => e.sources, () => {
      a(e.basicOption);
    }, {
      deep: !0
    }), n(() => r(e.basicOption), (t, s) => {
      E(t, s) || c(t);
    }, {
      deep: !0
    }), d({
      getEchartsInstance: () => m.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) => (v(), f("div", g, [
      _("div", {
        id: b(l),
        class: "widget"
      }, null, 8, k)
    ]));
  }
});
export {
  V as default
};
