import __variableDynamicImportRuntimeHelper from "../../../../../../_virtual/dynamic-import-helper.mjs";
import "../../../../../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.mjs";
import { includes } from "./config.mjs";
import B from "../../../../../../node_modules/.pnpm/vue-echarts@6.6.1_echarts@5.4.3_vue@3.3.4/node_modules/vue-echarts/dist/index.esm.min.mjs";
import { useCanvasInitOptions } from "../../../../../hooks/useCanvasInitOptions.hook.mjs";
import "../../../../../store/modules/designStore/designStore.mjs";
import "../../../../../settings/designSetting.mjs";
import "../../../../../../node_modules/.pnpm/screenfull@6.0.2/node_modules/screenfull/index.mjs";
import "../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_root.mjs";
import "../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseGetTag.mjs";
import "../../../../../../node_modules/.pnpm/html2canvas@1.4.1/node_modules/html2canvas/dist/html2canvas.esm.mjs";
import "../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseClone.mjs";
import "../../../../../../node_modules/.pnpm/crypto-js@4.1.1/node_modules/crypto-js/index.mjs";
import { isPreview } from "../../../../../utils/router.mjs";
import "../../../../../../node_modules/.pnpm/vue3-lazyload@0.2.5-beta_a6dezdz3je235ci4e3tu4rayna/node_modules/vue3-lazyload/dist/vue3-lazyload.esm.mjs";
import "../../../../../components/GoSkeleton/index.vue.mjs";
import "../../../../../components/GoLoading/index.mjs";
import { useChartDataFetch } from "../../../../../hooks/useChartDataFetch.hook.mjs";
import "../../../../../api/axios.mjs";
import "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/index.mjs";
import "../../../../../store/modules/langStore/langStore.mjs";
import { mergeTheme, setOption } from "../../../../public/chart.mjs";
import { useChartEditStore } from "../../../../../store/modules/chartEditStore/chartEditStore.mjs";
import mapJsonWithoutHainanIsLands from "./mapWithoutHainanIsLands.json.mjs";
import { install } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/chart/map/install.mjs";
import { install as install$5 } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/geo/install.mjs";
import { install as install$6 } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/chart/effectScatter/install.mjs";
import { install as install$7 } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/visualMap/install.mjs";
import { registerMap } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/core/echarts.mjs";
import { defineComponent, watch, openBlock, createBlock, nextTick } from "../../../../../../node_modules/.pnpm/@vue_runtime-core@3.3.4/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.mjs";
import { use } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/extension.mjs";
import { install as install$1 } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/dataset/install.mjs";
import { install as install$2 } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/renderer/installCanvasRenderer.mjs";
import { install as install$3 } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/grid/install.mjs";
import { install as install$4 } from "../../../../../../node_modules/.pnpm/echarts@5.4.3/node_modules/echarts/lib/component/tooltip/install.mjs";
import { reactive, ref, unref } from "../../../../../../node_modules/.pnpm/@vue_reactivity@3.3.4/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.mjs";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    themeSetting: {
      type: Object,
      required: true
    },
    themeColor: {
      type: Object,
      required: true
    },
    chartConfig: {
      type: Object,
      required: true
    }
  },
  setup(__props) {
    const props = __props;
    const initOptions = useCanvasInitOptions(props.chartConfig.option, props.themeSetting);
    use([
      install,
      install$1,
      install$2,
      install$3,
      install$4,
      install$5,
      install$6,
      install$7
    ]);
    const option = reactive({
      value: mergeTheme(props.chartConfig.option, props.themeSetting, includes)
    });
    const vChartRef = ref();
    const getGeojson = (regionId) => {
      return new Promise((resolve) => {
        __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./mapGeojson/110000.json": () => import("./mapGeojson/110000.json.mjs"), "./mapGeojson/120000.json": () => import("./mapGeojson/120000.json.mjs"), "./mapGeojson/130000.json": () => import("./mapGeojson/130000.json.mjs"), "./mapGeojson/140000.json": () => import("./mapGeojson/140000.json.mjs"), "./mapGeojson/150000.json": () => import("./mapGeojson/150000.json.mjs"), "./mapGeojson/210000.json": () => import("./mapGeojson/210000.json.mjs"), "./mapGeojson/220000.json": () => import("./mapGeojson/220000.json.mjs"), "./mapGeojson/230000.json": () => import("./mapGeojson/230000.json.mjs"), "./mapGeojson/310000.json": () => import("./mapGeojson/310000.json.mjs"), "./mapGeojson/320000.json": () => import("./mapGeojson/320000.json.mjs"), "./mapGeojson/330000.json": () => import("./mapGeojson/330000.json.mjs"), "./mapGeojson/340000.json": () => import("./mapGeojson/340000.json.mjs"), "./mapGeojson/350000.json": () => import("./mapGeojson/350000.json.mjs"), "./mapGeojson/360000.json": () => import("./mapGeojson/360000.json.mjs"), "./mapGeojson/370000.json": () => import("./mapGeojson/370000.json.mjs"), "./mapGeojson/410000.json": () => import("./mapGeojson/410000.json.mjs"), "./mapGeojson/420000.json": () => import("./mapGeojson/420000.json.mjs"), "./mapGeojson/430000.json": () => import("./mapGeojson/430000.json.mjs"), "./mapGeojson/440000.json": () => import("./mapGeojson/440000.json.mjs"), "./mapGeojson/450000.json": () => import("./mapGeojson/450000.json.mjs"), "./mapGeojson/460000.json": () => import("./mapGeojson/460000.json.mjs"), "./mapGeojson/500000.json": () => import("./mapGeojson/500000.json.mjs"), "./mapGeojson/510000.json": () => import("./mapGeojson/510000.json.mjs"), "./mapGeojson/520000.json": () => import("./mapGeojson/520000.json.mjs"), "./mapGeojson/530000.json": () => import("./mapGeojson/530000.json.mjs"), "./mapGeojson/540000.json": () => import("./mapGeojson/540000.json.mjs"), "./mapGeojson/610000.json": () => import("./mapGeojson/610000.json.mjs"), "./mapGeojson/620000.json": () => import("./mapGeojson/620000.json.mjs"), "./mapGeojson/630000.json": () => import("./mapGeojson/630000.json.mjs"), "./mapGeojson/640000.json": () => import("./mapGeojson/640000.json.mjs"), "./mapGeojson/650000.json": () => import("./mapGeojson/650000.json.mjs"), "./mapGeojson/710000.json": () => import("./mapGeojson/710000.json.mjs"), "./mapGeojson/810000.json": () => import("./mapGeojson/810000.json.mjs"), "./mapGeojson/820000.json": () => import("./mapGeojson/820000.json.mjs"), "./mapGeojson/china.json": () => import("./mapGeojson/china.json.mjs"), "./mapGeojson/empty.json": () => import("./mapGeojson/empty.json.mjs") }), `./mapGeojson/${regionId}.json`).then((data) => {
          registerMap(regionId, { geoJSON: data.default, specialAreas: {} });
          resolve(true);
        });
      });
    };
    registerMap(`${props.chartConfig.option.mapRegion.adcode}`, { geoJSON: {}, specialAreas: {} });
    const registerMapInitAsync = async () => {
      await nextTick();
      const adCode = `${props.chartConfig.option.mapRegion.adcode}`;
      if (adCode !== "china") {
        await getGeojson(adCode);
      } else {
        await hainanLandsHandle(props.chartConfig.option.mapRegion.showHainanIsLands);
      }
      vEchartsSetOption();
    };
    registerMapInitAsync();
    const vEchartsSetOption = () => {
      option.value = props.chartConfig.option;
      setOption(vChartRef.value, props.chartConfig.option);
    };
    const dataSetHandle = async (dataset) => {
      props.chartConfig.option.series.forEach((item) => {
        if (item.type === "effectScatter" && dataset.point)
          item.data = dataset.point;
        else if (item.type === "map" && dataset.map)
          item.data = dataset.map;
      });
      if (dataset.pieces)
        props.chartConfig.option.visualMap.pieces = dataset.pieces;
      isPreview() && vEchartsSetOption();
    };
    const hainanLandsHandle = async (newData) => {
      if (newData) {
        await getGeojson("china");
      } else {
        registerMap("china", { geoJSON: mapJsonWithoutHainanIsLands, specialAreas: {} });
      }
    };
    watch(
      () => props.chartConfig.option.dataset,
      (newData) => {
        dataSetHandle(newData);
      },
      {
        immediate: true,
        deep: false
      }
    );
    watch(
      () => props.chartConfig.option.mapRegion.showHainanIsLands,
      async (newData) => {
        try {
          await hainanLandsHandle(newData);
          vEchartsSetOption();
        } catch (error) {
          console.log(error);
        }
      },
      {
        deep: false
      }
    );
    watch(
      () => `${props.chartConfig.option.mapRegion.adcode}`,
      async (newData) => {
        try {
          await getGeojson(newData);
          props.chartConfig.option.geo.map = newData;
          props.chartConfig.option.series.forEach((item) => {
            if (item.type === "map")
              item.map = newData;
          });
          vEchartsSetOption();
        } catch (error) {
          console.log(error);
        }
      },
      {
        deep: false
      }
    );
    useChartDataFetch(props.chartConfig, useChartEditStore, (newData) => {
      dataSetHandle(newData);
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(B), {
        ref_key: "vChartRef",
        ref: vChartRef,
        "init-options": unref(initOptions),
        theme: __props.themeColor,
        option: option.value,
        "manual-update": unref(isPreview)(),
        autoresize: ""
      }, null, 8, ["init-options", "theme", "option", "manual-update"]);
    };
  }
});
export {
  _sfc_main as default
};
