"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 utils = require("../../../../utils/utils.js");
require("../../../../../node_modules/.pnpm/crypto-js@4.1.1/node_modules/crypto-js/index.js");
const router = require("../../../../utils/router.js");
const storage = require("../../../../utils/storage.js");
require("../../../../store/modules/designStore/designStore.js");
const plugin = require("../../../../utils/plugin.js");
require("../../../../components/GoLoading/index.js");
const pageEnum = require("../../../../enums/pageEnum.js");
const storageEnum = require("../../../../enums/storageEnum.js");
const vueRouter_esmBundler = require("../../../../../node_modules/.pnpm/vue-router@4.0.12_vue@3.3.4/node_modules/vue-router/dist/vue-router.esm-bundler.js");
const chartEditStore = require("../../../../store/modules/chartEditStore/chartEditStore.js");
const useSyncUpdate_hook = require("../../ContentEdit/components/EditTools/hooks/useSyncUpdate.hook.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");
const icon = require("../../../../plugins/icon.js");
const lodash = require("../../../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/lodash.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 shared_esmBundler = require("../../../../../node_modules/.pnpm/@vue_shared@3.3.4/node_modules/@vue/shared/dist/shared.esm-bundler.js");
const _sfc_main = /* @__PURE__ */ runtimeCore_esmBundler.defineComponent({
  __name: "index",
  setup(__props) {
    const { BrowsersOutlineIcon, SendIcon, AnalyticsIcon } = icon.icon.ionicons5;
    const chartEditStore$1 = chartEditStore.useChartEditStore();
    const routerParamsInfo = vueRouter_esmBundler.useRoute();
    const previewHandle = () => {
      const path = router.fetchPathByName(pageEnum.PreviewEnum.CHART_PREVIEW_NAME, "href");
      if (!path)
        return;
      const { id } = routerParamsInfo.params;
      const previewId = typeof id === "string" ? id : id[0];
      const storageInfo = chartEditStore$1.getStorageInfo;
      const sessionStorageInfo = storage.getLocalStorage(storageEnum.StorageEnum.GO_CHART_STORAGE_LIST) || [];
      if (sessionStorageInfo == null ? void 0 : sessionStorageInfo.length) {
        const repeateIndex = sessionStorageInfo.findIndex((e) => e.id === previewId);
        if (repeateIndex !== -1) {
          sessionStorageInfo.splice(repeateIndex, 1, { id: previewId, ...storageInfo });
          storage.setSessionStorage(storageEnum.StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo);
        } else {
          sessionStorageInfo.push({
            id: previewId,
            ...storageInfo
          });
          storage.setSessionStorage(storageEnum.StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo);
        }
      } else {
        storage.setSessionStorage(storageEnum.StorageEnum.GO_CHART_STORAGE_LIST, [{ id: previewId, ...storageInfo }]);
      }
      router.routerTurnByPath(path, [previewId], void 0, true);
    };
    const sendHandle = () => {
      plugin.goDialog({
        message: "保存当前设计，需要表单提交相关信息",
        positiveText: "了然",
        closeNegativeText: true,
        onPositiveCallback: () => {
        }
      });
    };
    const btnList = [
      {
        select: true,
        title: "同步内容",
        type: "primary",
        icon: utils.renderIcon(AnalyticsIcon),
        event: useSyncUpdate_hook.syncData
      },
      {
        select: true,
        title: "预览",
        icon: utils.renderIcon(BrowsersOutlineIcon),
        event: previewHandle
      },
      {
        select: true,
        title: "保存",
        icon: utils.renderIcon(SendIcon),
        event: sendHandle
      }
    ];
    const comBtnList = runtimeCore_esmBundler.computed(() => {
      if (chartEditStore$1.getEditCanvas.isCodeEdit) {
        return btnList;
      }
      const cloneList = lodash.lodashExports.cloneDeep(btnList);
      cloneList.shift();
      return cloneList;
    });
    return (_ctx, _cache) => {
      const _component_n_button = runtimeCore_esmBundler.resolveComponent("n-button");
      const _component_n_space = runtimeCore_esmBundler.resolveComponent("n-space");
      return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(_component_n_space, { class: "go-mt-0" }, {
        default: runtimeCore_esmBundler.withCtx(() => [
          (runtimeCore_esmBundler.openBlock(true), runtimeCore_esmBundler.createElementBlock(runtimeCore_esmBundler.Fragment, null, runtimeCore_esmBundler.renderList(comBtnList.value, (item, index) => {
            return runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(_component_n_button, {
              key: item.title,
              type: item.type,
              ghost: "",
              onClick: item.event
            }, {
              icon: runtimeCore_esmBundler.withCtx(() => [
                (runtimeCore_esmBundler.openBlock(), runtimeCore_esmBundler.createBlock(runtimeCore_esmBundler.resolveDynamicComponent(item.icon)))
              ]),
              default: runtimeCore_esmBundler.withCtx(() => [
                runtimeCore_esmBundler.createElementVNode("span", null, shared_esmBundler.toDisplayString(item.title), 1)
              ]),
              _: 2
            }, 1032, ["type", "onClick"]);
          }), 128))
        ]),
        _: 1
      });
    };
  }
});
exports.default = _sfc_main;
