import { defineComponent as d, watch as n, createElementBlock as b, openBlock as E, createElementVNode as O, unref as g } from "vue";
import { cloneDeep as r, isEqual as k } from "lodash";
import { SHJDatasourceV2 as w } from "../../commons/plugins/datasource/index.mjs";
import { useChart as D } from "../../commons/core/useChart.mjs";
import { SHJParseEvent as u } from "../../commons/plugins/event/index.mjs";
const x = { class: "zerov-widget" }, C = ["id"], I = d({ name: "zv-chart-map-bmap-rich" }), J = /* @__PURE__ */ d({
  ...I,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {},
    uuid: {}
  },
  emits: [
    "chart-click",
    "chart-dblclick",
    "chart-mousedown",
    "chart-mouseover",
    "chart-mouseout",
    "chart-contextmenu"
  ],
  setup(p, { expose: m, emit: h }) {
    const e = p, l = h, {
      id: f,
      setOption: i,
      chart: v,
      renderChart: a,
      renderData: c
    } = D({
      basicOption: r(e.basicOption),
      useEvents: r(e.useEvents),
      customRenderData: (t) => {
        t = r(t), w.parse({
          tId: e.uuid,
          sources: e.sources,
          callback: (s) => {
            try {
              u.parseEvents(e.useEvents, "dataListener", s.data);
              const o = t.series.find((_) => _._sourceId === s.id);
              o && (o.data = s.data[0].data), i(t);
            } catch {
              u.parseEvents(e.useEvents, "dataListener", null), i(t);
            }
          }
        });
      },
      emit: l
    });
    return n(() => e.sources, () => {
      c(e.basicOption);
    }, {
      deep: !0
    }), n(() => r(e.basicOption), (t, s) => {
      k(t, s) || a(t);
    }, {
      deep: !0
    }), m({
      getEchartsInstance: () => v.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) => (E(), b("div", x, [
      O("div", {
        id: g(f),
        class: "widget"
      }, null, 8, C)
    ]));
  }
});
export {
  J as default
};
