'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var shared = require('@vue/shared');
var is = require('../../../../utils/src/is.js');
var elementPlus = require('element-plus');
var index = require('../../../../hooks/base/useGlobalConfig/index.js');

const messageTypes = ["success", "info", "warning", "error"];
const normalizeMessageOptions = (params) => {
  const normalized = !params || is.isString(params) || vue.isVNode(params) || shared.isFunction(params) ? { message: params } : params;
  return normalized;
};
const message = (options = {}, context) => {
  const normalized = normalizeMessageOptions(options);
  const messageGlobalConfig = index.useGlobalConfig("message") ?? {};
  return elementPlus.ElMessage(
    {
      grouping: true,
      plain: messageGlobalConfig.value?.plain,
      //   duration: 5 * 1000,
      ...normalized
    },
    context
  );
};
message.closeAll = elementPlus.ElMessage.closeAll;
message.closeAllByPlacement = elementPlus.ElMessage.closeAllByPlacement;
message._context = elementPlus.ElMessage._context;
messageTypes.forEach((type) => {
  message[type] = (options = {}, appContext) => {
    const normalized = normalizeMessageOptions(options);
    return message({ ...normalized, type }, appContext);
  };
});

exports.default = message;
exports.messageTypes = messageTypes;
exports.normalizeMessageOptions = normalizeMessageOptions;
//# sourceMappingURL=method.js.map
