import { isVNode } from 'vue';
import { isObject } from '@vue/shared';
import '../../../../utils/index.mjs';
import { ElMessageBox } from 'element-plus';
import { isString, isUndefined } from '../../../../utils/src/is.mjs';

function MessageBox(options, appContext = null) {
  if (isString(options) || isVNode(options)) {
    options = {
      message: options
    };
  }
  return ElMessageBox(options, appContext);
}
const MESSAGE_BOX_VARIANTS = ["alert", "confirm", "prompt"];
const MESSAGE_BOX_DEFAULT_OPTS = {
  alert: { closeOnPressEscape: false, closeOnClickModal: false },
  confirm: { showCancelButton: true },
  prompt: { showCancelButton: true, showInput: true }
};
MESSAGE_BOX_VARIANTS.forEach((boxType) => {
  MessageBox[boxType] = messageBoxFactory(boxType);
});
function messageBoxFactory(boxType) {
  return (message, title, options, appContext) => {
    let titleOrOpts = "";
    if (isObject(title)) {
      options = title;
      titleOrOpts = "";
    } else if (isUndefined(title)) {
      titleOrOpts = "";
    } else {
      titleOrOpts = title;
    }
    return MessageBox(
      Object.assign(
        {
          title: titleOrOpts,
          message,
          type: "",
          ...MESSAGE_BOX_DEFAULT_OPTS[boxType]
        },
        options,
        {
          boxType
        }
      ),
      appContext
    );
  };
}
MessageBox.close = ElMessageBox.close;
MessageBox._context = ElMessageBox._context;

export { MessageBox as default };
//# sourceMappingURL=method.mjs.map
