"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.js");
const index_vue_vue_type_script_setup_true_lang = require("../../../../../components/Pages/ChartGlobImage/index.vue.js");
const chartEditStore = require("../../../../../store/modules/chartEditStore/chartEditStore.js");
const chartEditStore_d = require("../../../../../store/modules/chartEditStore/chartEditStore.d.js");
const chartLayoutStore_d = require("../../../../../store/modules/chartLayoutStore/chartLayoutStore.d.js");
const chartLayoutStore = require("../../../../../store/modules/chartLayoutStore/chartLayoutStore.js");
const packagesStore = require("../../../../../store/modules/packagesStore/packagesStore.js");
const utils = require("../../../../../utils/utils.js");
require("../../../../../../node_modules/.pnpm/crypto-js@4.1.1/node_modules/crypto-js/index.js");
require("../../../../../enums/pageEnum.js");
require("../../../../../router/index.js");
require("../../../../../store/modules/designStore/designStore.js");
const plugin = require("../../../../../utils/plugin.js");
const components = require("../../../../../utils/components.js");
const editPageEnum = require("../../../../../enums/editPageEnum.js");
const index = require("../../../../../packages/index.js");
const index_d = require("../../../../../packages/index.d.js");
const index_d$1 = require("../../../../../packages/components/Photos/index.d.js");
const iconify = require("../../../../../../node_modules/.pnpm/@iconify_vue@4.1.1_vue@3.3.4/node_modules/@iconify/vue/dist/iconify.js");
require("../../../../../../node_modules/.pnpm/vue3-lazyload@0.2.5-beta_a6dezdz3je235ci4e3tu4rayna/node_modules/vue3-lazyload/dist/vue3-lazyload.esm.js");
require("../../../../../components/GoSkeleton/index.vue.js");
require("../../../../../components/GoLoading/index.js");
const icon = require("../../../../../plugins/icon.js");
const omit = require("../../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/omit.js");
const runtimeCore_esmBundler = require("../../../../../../node_modules/.pnpm/@vue_runtime-core@3.3.4/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js");
const reactivity_esmBundler = require("../../../../../../node_modules/.pnpm/@vue_reactivity@3.3.4/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js");
const shared_esmBundler = require("../../../../../../node_modules/.pnpm/@vue_shared@3.3.4/node_modules/@vue/shared/dist/shared.esm-bundler.js");
const _withScopeId = (n) => (runtimeCore_esmBundler.pushScopeId("data-v-1d77a379"), n = n(), runtimeCore_esmBundler.popScopeId(), n);
const _hoisted_1 = { class: "go-content-charts-item-animation-patch" };
const _hoisted_2 = ["onDragstart", "onDragend", "onDblclick", "onClick"];
const _hoisted_3 = {
  class: "list-center go-flex-center go-transition",
  draggable: "true"
};
const _hoisted_4 = {
  class: "list-bottom",
  style: { "text-align": "center" }
};
const _hoisted_5 = {
  key: 0,
  class: "list-model"
};
const _hoisted_6 = ["onClick"];
const _hoisted_7 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ runtimeCore_esmBundler.createElementVNode("span", null, "删除", -1));
const _sfc_main = /* @__PURE__ */ runtimeCore_esmBundler.defineComponent({
  __name: "index",
  props: {
    menuOptions: {
      type: Array,
      default: () => []
    }
  },
  emits: ["deletePhoto"],
  setup(__props, { emit }) {
    const chartEditStore$1 = chartEditStore.useChartEditStore();
    const { TrashIcon } = icon.icon.ionicons5;
    const chartLayoutStore$1 = chartLayoutStore.useChartLayoutStore();
    const contentChartsItemBoxRef = reactivity_esmBundler.ref();
    const isShowTools = (item) => {
      return !item.disabled && item.package === index_d.PackagesCategoryEnum.PHOTOS && item.category === index_d$1.ChatCategoryEnum.PRIVATE;
    };
    const chartMode = runtimeCore_esmBundler.computed(() => {
      return chartLayoutStore$1.getChartType;
    });
    const dragStartHandle = (e, item) => {
      if (item.disabled)
        return;
      components.componentInstall(item.chartKey, index.fetchChartComponent(item));
      components.componentInstall(item.conKey, index.fetchConfigComponent(item));
      e.dataTransfer.setData(editPageEnum.DragKeyEnum.DRAG_KEY, utils.JSONStringify(omit.default(item, ["image"])));
      chartEditStore$1.setEditCanvas(chartEditStore_d.EditCanvasTypeEnum.IS_CREATE, true);
    };
    const dragendHandle = () => {
      chartEditStore$1.setEditCanvas(chartEditStore_d.EditCanvasTypeEnum.IS_CREATE, false);
    };
    const dblclickHandle = async (item) => {
      if (item.disabled)
        return;
      try {
        plugin.loadingStart();
        components.componentInstall(item.chartKey, index.fetchChartComponent(item));
        components.componentInstall(item.conKey, index.fetchConfigComponent(item));
        let newComponent = await index.createComponent(item);
        if (item.redirectComponent) {
          item.dataset && (newComponent.option.dataset = item.dataset);
          newComponent.chartConfig.title = item.title;
          newComponent.chartConfig.chartFrame = item.chartFrame;
        }
        chartEditStore$1.addComponentList(newComponent, false, true);
        chartEditStore$1.setTargetSelectChart(newComponent.id);
        plugin.loadingFinish();
      } catch (error) {
        plugin.loadingError();
        window["$message"].warning(`图表正在研发中, 敬请期待...`);
      }
    };
    const clickHandle = (item) => {
      var _a;
      (_a = item == null ? void 0 : item.configEvents) == null ? void 0 : _a.addHandle(item);
    };
    const deleteHandle = (item, index2) => {
      plugin.goDialog({
        message: "是否删除此图片？",
        transformOrigin: "center",
        onPositiveCallback: () => {
          const packagesStore$1 = packagesStore.usePackagesStore();
          emit("deletePhoto", item, index2);
          packagesStore$1.deletePhotos(item, index2);
        }
      });
    };
    runtimeCore_esmBundler.watch(
      () => chartMode.value,
      (newValue) => {
        if (newValue === chartLayoutStore_d.ChartModeEnum.DOUBLE) {
          runtimeCore_esmBundler.nextTick(() => {
            contentChartsItemBoxRef.value.classList.add("miniAnimation");
          });
        }
      }
    );
    return (_ctx, _cache) => {
      const _component_n_ellipsis = runtimeCore_esmBundler.resolveComponent("n-ellipsis");
      const _component_n_text = runtimeCore_esmBundler.resolveComponent("n-text");
      const _component_n_icon = runtimeCore_esmBundler.resolveComponent("n-icon");
      const _component_n_button = runtimeCore_esmBundler.resolveComponent("n-button");
      return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", _hoisted_1, [
        runtimeCore_esmBundler.createElementVNode("div", {
          ref_key: "contentChartsItemBoxRef",
          ref: contentChartsItemBoxRef,
          class: shared_esmBundler.normalizeClass(["go-content-charts-item-box", [chartMode.value === reactivity_esmBundler.unref(chartLayoutStore_d.ChartModeEnum).DOUBLE ? "double" : "single"]])
        }, [
          (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(__props.menuOptions, (item, index2) => {
            return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", {
              class: "item-box",
              key: item.title,
              draggable: "",
              onDragstart: ($event) => !item.disabled && dragStartHandle($event, item),
              onDragend: ($event) => !item.disabled && dragendHandle,
              onDblclick: ($event) => dblclickHandle(item),
              onClick: ($event) => clickHandle(item)
            }, [
              runtimeCore_esmBundler.createElementVNode("div", _hoisted_3, [
                item.icon ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(reactivity_esmBundler.unref(iconify.Icon), {
                  key: 0,
                  class: "list-img",
                  icon: item.icon,
                  color: "#999",
                  width: "48"
                }, null, 8, ["icon"])) : (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(reactivity_esmBundler.unref(index_vue_vue_type_script_setup_true_lang.default), {
                  key: 1,
                  class: "list-img",
                  chartConfig: item
                }, null, 8, ["chartConfig"]))
              ]),
              runtimeCore_esmBundler.createElementVNode("div", _hoisted_4, [
                runtimeCore_esmBundler.createVNode(_component_n_text, {
                  class: "list-bottom-text",
                  depth: "3"
                }, {
                  default: runtimeCore_esmBundler.withCtx(() => [
                    runtimeCore_esmBundler.createVNode(_component_n_ellipsis, { style: { "max-width": "90%" } }, {
                      default: runtimeCore_esmBundler.withCtx(() => [
                        runtimeCore_esmBundler.createTextVNode(shared_esmBundler.toDisplayString(item.title), 1)
                      ]),
                      _: 2
                    }, 1024)
                  ]),
                  _: 2
                }, 1024)
              ]),
              item.disabled ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", _hoisted_5)) : runtimeCore_esmBundler.createCommentVNode("", true),
              isShowTools(item) ? (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createElementBlock("div", {
                key: 1,
                class: "list-tools go-transition",
                onClick: ($event) => deleteHandle(item, index2)
              }, [
                runtimeCore_esmBundler.createVNode(_component_n_button, {
                  text: "",
                  type: "default",
                  color: "#ffffff"
                }, {
                  icon: runtimeCore_esmBundler.withCtx(() => [
                    runtimeCore_esmBundler.createVNode(_component_n_icon, null, {
                      default: runtimeCore_esmBundler.withCtx(() => [
                        runtimeCore_esmBundler.createVNode(reactivity_esmBundler.unref(TrashIcon))
                      ]),
                      _: 1
                    })
                  ]),
                  default: runtimeCore_esmBundler.withCtx(() => [
                    _hoisted_7
                  ]),
                  _: 1
                })
              ], 8, _hoisted_6)) : runtimeCore_esmBundler.createCommentVNode("", true)
            ], 40, _hoisted_2);
          }), 128))
        ], 2)
      ]);
    };
  }
});
exports.default = _sfc_main;
