import { defineComponent, computed, reactive, ref, watch, resolveComponent, openBlock, createElementBlock, createElementVNode, createVNode, withCtx, unref, toRefs, useCssVars, createBlock, normalizeClass, isRef, createCommentVNode } from "vue";
import { C as ContentBox } from "./index-42e17fe3.js";
import { J as defineStore, K as packagesList, n as StorageEnum, k as getLocalStorage, L as setLocalStorage, N as loadAsyncComponent, O as useSettingStore, _ as _export_sfc, y as useDesignStore, Q as PackagesCategoryEnum, r as renderIcon, R as PackagesCategoryName, i as icon } from "./index-67bc0910.js";
import { u as useChartLayoutStore, C as ChartLayoutStoreEnum } from "./chartLayoutStore-de4e7ebb.js";
const usePackagesStore = defineStore({
  id: "usePackagesStore",
  state: () => ({
    packagesList: Object.freeze(packagesList),
    newPhoto: void 0
  }),
  getters: {
    getPackagesList() {
      return this.packagesList;
    }
  },
  actions: {
    addPhotos(newPhoto, index2) {
      this.newPhoto = newPhoto;
    },
    deletePhotos(photoInfo, index2) {
      const StoreKey = StorageEnum.GO_USER_MEDIA_PHOTOS;
      const userPhotosList = getLocalStorage(StoreKey);
      userPhotosList.splice(index2 - 1, 1);
      setLocalStorage(StoreKey, userPhotosList);
    }
  }
});
const _hoisted_1$1 = { class: "go-chart-common" };
const _hoisted_2$1 = { class: "chart-content-list" };
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    selectOptions: {
      type: Object,
      default: () => {
      }
    }
  },
  setup(__props) {
    const props = __props;
    const ChartsItemBox = loadAsyncComponent(() => import("./index-cbaa6258.js"));
    const packagesStore = usePackagesStore();
    const settingStore = useSettingStore();
    computed(() => {
      if (packages.categorysNum > 2)
        return true;
      return !settingStore.getHidePackageOneCategory;
    });
    let packages = reactive({
      // 侧边栏
      menuOptions: [],
      // 当前选择
      selectOptions: {},
      // 分类归档
      categorys: {
        all: []
      },
      categoryNames: {
        all: "所有"
      },
      // 分类归档数量
      categorysNum: 0,
      // 存储不同类别组件进来的选中值
      saveSelectOptions: {}
    });
    const selectValue = ref("all");
    const setSelectOptions = (categorys) => {
      for (const val in categorys) {
        packages.selectOptions = categorys[val];
        break;
      }
    };
    watch(
      // @ts-ignore
      () => props.selectOptions,
      (newData) => {
        packages.categorysNum = 0;
        if (!newData)
          return;
        newData.list.forEach((e) => {
          const value = packages.categorys[e.category];
          packages.categorys[e.category] = value && value.length ? [...value, e] : [e];
          packages.categoryNames[e.category] = e.categoryName;
          packages.categorys["all"].push(e);
        });
        for (const val in packages.categorys) {
          packages.categorysNum += 1;
          packages.menuOptions.push({
            key: val,
            label: packages.categoryNames[val]
          });
        }
        setSelectOptions(packages.categorys);
        selectValue.value = packages.menuOptions[0]["key"];
      },
      {
        immediate: true
      }
    );
    watch(
      () => packagesStore.newPhoto,
      (newPhoto) => {
        if (!newPhoto)
          return;
        const newPhotoCategory = newPhoto.category;
        packages.categorys[newPhotoCategory].splice(1, 0, newPhoto);
        packages.categorys["all"].splice(1, 0, newPhoto);
      }
    );
    const deleteHandle = (item, index2) => {
      packages.categorys[item.category].splice(index2, 1);
      packages.categorys["all"].splice(index2, 1);
    };
    return (_ctx, _cache) => {
      const _component_n_scrollbar = resolveComponent("n-scrollbar");
      return openBlock(), createElementBlock("div", _hoisted_1$1, [
        createElementVNode("div", _hoisted_2$1, [
          createVNode(_component_n_scrollbar, { trigger: "none" }, {
            default: withCtx(() => [
              createVNode(unref(ChartsItemBox), {
                menuOptions: unref(packages).selectOptions,
                onDeletePhoto: deleteHandle
              }, null, 8, ["menuOptions"])
            ]),
            _: 1
          })
        ])
      ]);
    };
  }
});
const index_vue_vue_type_style_index_0_scoped_37918cf8_lang = "";
const ChartsOptionContent = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-37918cf8"]]);
const designStore = useDesignStore();
const themeColor = ref(designStore.getAppTheme);
const { setItem } = useChartLayoutStore();
const { getCharts } = toRefs(useChartLayoutStore());
const { AirPlaneOutlineIcon, ImageIcon, BarChartIcon } = icon.ionicons5;
const { TableSplitIcon, RoadmapIcon, SpellCheckIcon, GraphicalDataFlowIcon } = icon.carbon;
const packagesListObj = {
  [PackagesCategoryEnum.CHARTS]: {
    icon: renderIcon(RoadmapIcon),
    label: PackagesCategoryName.CHARTS
  },
  [PackagesCategoryEnum.INFORMATIONS]: {
    icon: renderIcon(SpellCheckIcon),
    label: PackagesCategoryName.INFORMATIONS
  },
  [PackagesCategoryEnum.TABLES]: {
    icon: renderIcon(TableSplitIcon),
    label: PackagesCategoryName.TABLES
  },
  [PackagesCategoryEnum.DECORATES]: {
    icon: renderIcon(GraphicalDataFlowIcon),
    label: PackagesCategoryName.DECORATES
  },
  [PackagesCategoryEnum.PHOTOS]: {
    icon: renderIcon(ImageIcon),
    label: PackagesCategoryName.PHOTOS
  },
  [PackagesCategoryEnum.ICONS]: {
    icon: renderIcon(AirPlaneOutlineIcon),
    label: PackagesCategoryName.ICONS
  }
};
const useAsideHook = () => {
  const packagesStore = usePackagesStore();
  const menuOptions = [];
  const handlePackagesList = () => {
    for (const val in packagesStore.getPackagesList) {
      menuOptions.push({
        key: val,
        // @ts-ignore
        icon: packagesListObj[val].icon,
        // @ts-ignore
        label: packagesListObj[val].label,
        // @ts-ignore
        list: packagesStore.getPackagesList[val]
      });
    }
  };
  handlePackagesList();
  let beforeSelect = menuOptions[0]["key"];
  const selectValue = ref(menuOptions[0]["key"]);
  const selectOptions = ref(menuOptions[0]);
  const clickItemHandle = (key, item) => {
    selectOptions.value = item;
    if (beforeSelect === key) {
      setItem(ChartLayoutStoreEnum.CHARTS, !getCharts.value, false);
    } else {
      setItem(ChartLayoutStoreEnum.CHARTS, true, false);
    }
    beforeSelect = key;
  };
  return {
    getCharts,
    BarChartIcon,
    themeColor,
    selectOptions,
    selectValue,
    clickItemHandle,
    menuOptions
  };
};
const _hoisted_1 = { class: "menu-width-box" };
const _hoisted_2 = { class: "menu-component-box" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  setup(__props) {
    useCssVars((_ctx) => ({
      "54e51da8": unref(themeColor2)
    }));
    const { getCharts: getCharts2, BarChartIcon: BarChartIcon2, themeColor: themeColor2, selectOptions, selectValue, clickItemHandle, menuOptions } = useAsideHook();
    return (_ctx, _cache) => {
      const _component_n_icon = resolveComponent("n-icon");
      const _component_n_menu = resolveComponent("n-menu");
      const _component_go_skeleton = resolveComponent("go-skeleton");
      return openBlock(), createBlock(unref(ContentBox), {
        class: normalizeClass(["go-content-charts", { scoped: !unref(getCharts2) }]),
        title: "组件",
        depth: 1,
        backIcon: false
      }, {
        icon: withCtx(() => [
          createVNode(_component_n_icon, {
            size: "14",
            depth: 2
          }, {
            default: withCtx(() => [
              createVNode(unref(BarChartIcon2))
            ]),
            _: 1
          })
        ]),
        default: withCtx(() => [
          createElementVNode("aside", null, [
            createElementVNode("div", _hoisted_1, [
              createVNode(_component_n_menu, {
                class: "menu-width",
                value: unref(selectValue),
                "onUpdate:value": [
                  _cache[0] || (_cache[0] = ($event) => isRef(selectValue) ? selectValue.value = $event : null),
                  unref(clickItemHandle)
                ],
                options: unref(menuOptions),
                "icon-size": 16,
                indent: 18
              }, null, 8, ["value", "options", "onUpdate:value"]),
              createElementVNode("div", _hoisted_2, [
                createVNode(_component_go_skeleton, {
                  load: !unref(selectOptions),
                  round: "",
                  text: "",
                  repeat: 2,
                  style: { "width": "90%" }
                }, null, 8, ["load"]),
                unref(selectOptions) ? (openBlock(), createBlock(unref(ChartsOptionContent), {
                  selectOptions: unref(selectOptions),
                  key: unref(selectValue)
                }, null, 8, ["selectOptions"])) : createCommentVNode("", true)
              ])
            ])
          ])
        ]),
        _: 1
      }, 8, ["class"]);
    };
  }
});
const index_vue_vue_type_style_index_0_scoped_0281ee89_lang = "";
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-0281ee89"]]);
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: index
}, Symbol.toStringTag, { value: "Module" }));
export {
  index$1 as i,
  usePackagesStore as u
};
