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