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