import { defineComponent as u, watch as i, openBlock as v, createElementBlock as b, 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-scatter" }), 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: l, emit: p }) {
    const e = d, h = p, {
      id: m,
      setOption: o,
      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 n = t.series.find((_) => _._sourceId === s.id);
              n && (n.data = s.data[0].data), o(t);
            } catch {
              window.SHJParseEvent(e.useEvents, "dataListener", null), o(t);
            }
          }
        });
      },
      emit: h
    });
    return i(() => e.sources, () => {
      c(e.basicOption);
    }, {
      deep: !0
    }), i(() => r(e.basicOption), (t, s) => {
      O(t, s) || a(t);
    }, {
      deep: !0
    }), l({
      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) => (v(), b("div", k, [
      w("div", {
        id: E(m),
        class: "widget"
      }, null, 8, D)
    ]));
  }
});
export {
  I as default
};
