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