import { defineComponent as M, ref as _, reactive as O, watch as r, nextTick as s, onBeforeUnmount as b, createElementBlock as k, openBlock as v } from "vue";
import * as i from "echarts/core";
import { MapChart as g, ScatterChart as z } from "echarts/charts";
import { TooltipComponent as D, VisualMapComponent as P, MarkPointComponent as R, ToolboxComponent as w } from "echarts/components";
import { CanvasRenderer as x } from "echarts/renderers";
import { __ChinaGeoJson as L } from "./model/ChinaGeoJson.js";
import { defaultOption as S } from "./model/options.js";
import { nanhaizhudaoWithLableOffset as u, OriginSpecialAreaMarkPoint as l } from "./model/index.js";
const V = {
  name: "CiEchartChinaMap"
}, J = /* @__PURE__ */ M({
  ...V,
  props: {
    fragmentOption: { default: () => ({}) },
    ChinaMapData: { default: () => [] },
    props: { default: () => ({ name: "name", value: "value" }) },
    showSpecialMarkPoint: { type: Boolean, default: !0 },
    nanhaizhudaoLabelOffset: { default: () => [0, 0] }
  },
  setup(h, { expose: m }) {
    i.use([
      g,
      D,
      P,
      R,
      w,
      z,
      x
    ]), i.registerMap("china", L);
    const p = _(null);
    let n = null, o = O(S);
    const a = h, c = () => (l.forEach((e) => {
      const t = a.ChinaMapData.find(
        (C) => C[a.props.name] === e.name
      );
      t ? e.value = t[a.props.value] : e.value = void 0;
    }), l), d = () => {
      const e = a.ChinaMapData.find((t) => t[a.props.name] === "南海诸岛");
      e ? e.label = { ...e.label, offset: a.nanhaizhudaoLabelOffset } : a.ChinaMapData.push(u[0]);
    };
    r(
      () => a.fragmentOption,
      (e, t) => {
        Object.assign(o, a.fragmentOption), s(() => {
          f();
        });
      },
      { deep: !0, immediate: !0 }
    ), r(
      () => a.ChinaMapData,
      (e, t) => {
        d(), o.series[0].data = a.ChinaMapData, a.showSpecialMarkPoint ? o.series[0].markPoint.data = c() : o.series[0].markPoint.data = [], s(() => {
          f();
        });
      }
    ), r(
      () => a.nanhaizhudaoLabelOffset,
      () => {
        u[0].label.offset = a.nanhaizhudaoLabelOffset;
      },
      { immediate: !0 }
    );
    function f() {
      n ? n.clear() : n = i.init(p.value), n.setOption(o);
    }
    return b(() => {
      n && n.dispose();
    }), m({ OriginSpecialAreaMarkPoint: l }), (e, t) => (v(), k("div", {
      id: "CiEchartChinaMap",
      ref_key: "chartRef",
      ref: p
    }, null, 512));
  }
});
export {
  J as default
};
