import "../../node_modules/.pnpm/vue3-lazyload@0.2.5-beta_a6dezdz3je235ci4e3tu4rayna/node_modules/vue3-lazyload/dist/vue3-lazyload.esm.mjs";
import { renderIcon } from "./utils.mjs";
import "../../node_modules/.pnpm/crypto-js@4.1.1/node_modules/crypto-js/index.mjs";
import "../enums/pageEnum.mjs";
import "../router/index.mjs";
import "../store/modules/designStore/designStore.mjs";
import { DialogEnum } from "../enums/pluginEnum.mjs";
import { dialogIconSize, maskClosable } from "../settings/designSetting.mjs";
import "../../node_modules/.pnpm/vue@3.3.4/node_modules/vue/dist/vue.runtime.esm-bundler.mjs";
import "../components/GoLoading/index.mjs";
import "../components/GoSkeleton/index.vue.mjs";
import { icon } from "../plugins/icon.mjs";
const { InformationCircleIcon } = icon.ionicons5;
const loadingStart = () => {
  window["$loading"].start();
};
const loadingFinish = () => {
  setTimeout(() => {
    window["$loading"].finish();
  });
};
const loadingError = () => {
  setTimeout(() => {
    window["$loading"].error();
  });
};
const goDialog = (params) => {
  const {
    type,
    title,
    message,
    positiveText,
    negativeText,
    closeNegativeText,
    isMaskClosable,
    onPositiveCallback,
    onNegativeCallback,
    promise,
    promiseResCallback,
    promiseRejCallback
  } = params;
  const typeObj = {
    // 自定义
    [DialogEnum.DELETE]: {
      fn: window["$dialog"].warning,
      message: message || "是否删除此数据?"
    },
    // 原有
    [DialogEnum.WARNING]: {
      fn: window["$dialog"].warning,
      message: message || "是否执行此操作?"
    },
    [DialogEnum.ERROR]: {
      fn: window["$dialog"].error,
      message: message || "是否执行此操作?"
    },
    [DialogEnum.SUCCESS]: {
      fn: window["$dialog"].success,
      message: message || "是否执行此操作?"
    }
  };
  const dialog = typeObj[type || DialogEnum.WARNING]["fn"]({
    // 导入其余 NaiveUI 支持参数
    ...params,
    title: title || "提示",
    icon: renderIcon(InformationCircleIcon, { size: dialogIconSize }),
    content: typeObj[type || DialogEnum.WARNING]["message"],
    positiveText: positiveText || "确定",
    negativeText: closeNegativeText ? void 0 : negativeText || "取消",
    // 是否通过遮罩关闭
    maskClosable: isMaskClosable || maskClosable,
    onPositiveClick: async () => {
      if (promise && onPositiveCallback) {
        dialog.loading = true;
        try {
          const res = await onPositiveCallback();
          promiseResCallback && promiseResCallback(res);
        } catch (err) {
          promiseRejCallback && promiseRejCallback(err);
        }
        dialog.loading = false;
        return;
      }
      onPositiveCallback && onPositiveCallback(dialog);
    },
    onNegativeClick: async () => {
      onNegativeCallback && onNegativeCallback(dialog);
    }
  });
};
export {
  goDialog,
  loadingError,
  loadingFinish,
  loadingStart
};
