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