import { defineComponent as i, watch as n, openBlock as f, createElementBlock as b, createElementVNode as v, unref as O } from "vue";
import { cloneDeep as r, isEqual as _ } from "lodash";
import { useChart as w } from "../../core/useChart.mjs";
import { parseOtherData as E } from "../../utils/parseOtherData.mjs";
const g = { class: "zerov-widget" }, D = ["id"], k = i({ name: "zv-chart-other-gauge-stage" }), V = /* @__PURE__ */ i({
  ...k,
  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: a,
      chart: m,
      renderChart: c,
      renderData: o
    } = w({
      basicOption: r(e.basicOption),
      useEvents: r(e.useEvents),
      customRenderData: (t) => {
        t = r(t), window.SHJDatasourceV2({
          tId: e.uuid,
          sources: e.sources,
          callback: ({ data: s }) => {
            try {
              window.SHJParseEvent(e.useEvents, "dataListener", s), a(E(s, e.basicOption));
            } catch {
              window.SHJParseEvent(e.useEvents, "dataListener", null), a(t);
            }
          }
        });
      },
      emit: h
    });
    return n(() => e.sources, () => {
      e.sources && e.sources.length > 0 && o(e.basicOption);
    }, {
      deep: !0
    }), n(() => r(e.basicOption), (t, s) => {
      _(t, s) || c(t);
    }, {
      deep: !0
    }), d({
      getEchartsInstance: () => m.value,
      refresh: () => {
        e.sources && e.sources.length > 0 && c(e.basicOption), o(e.basicOption);
      },
      refreshView: () => {
        e.sources && e.sources.length > 0 && c(e.basicOption);
      },
      refreshData: () => {
        o(e.basicOption);
      }
    }), (t, s) => (f(), b("div", g, [
      v("div", {
        id: O(l),
        class: "widget"
      }, null, 8, D)
    ]));
  }
});
export {
  V as default
};
