import * as _vue from "vue";

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

import classNames from '../_util/classNames';
import Dialog from './Modal';
import ActionButton from './ActionButton';
import { getConfirmLocale } from './locale';

var ConfirmDialog = function ConfirmDialog(_, _ref) {
  var attrs = _ref.attrs;
  var icon = attrs.icon,
      onCancel = attrs.onCancel,
      onOk = attrs.onOk,
      close = attrs.close,
      zIndex = attrs.zIndex,
      afterClose = attrs.afterClose,
      visible = attrs.visible,
      keyboard = attrs.keyboard,
      centered = attrs.centered,
      getContainer = attrs.getContainer,
      maskStyle = attrs.maskStyle,
      okButtonProps = attrs.okButtonProps,
      cancelButtonProps = attrs.cancelButtonProps,
      _attrs$closable = attrs.closable,
      closable = _attrs$closable === void 0 ? false : _attrs$closable;
  var okType = attrs.okType || 'primary';
  var prefixCls = attrs.prefixCls || 'ant-modal';
  var contentPrefixCls = "".concat(prefixCls, "-confirm"); // 默认为 true，保持向下兼容

  var okCancel = 'okCancel' in attrs ? attrs.okCancel : true;
  var width = attrs.width || 416;
  var style = attrs.style || {};
  var mask = attrs.mask === undefined ? true : attrs.mask; // 默认为 false，保持旧版默认行为

  var maskClosable = attrs.maskClosable === undefined ? false : attrs.maskClosable;
  var runtimeLocale = getConfirmLocale();
  var okText = attrs.okText || (okCancel ? runtimeLocale.okText : runtimeLocale.justOkText);
  var cancelText = attrs.cancelText || runtimeLocale.cancelText;
  var autoFocusButton = attrs.autoFocusButton === null ? false : attrs.autoFocusButton || 'ok';
  var transitionName = attrs.transitionName || 'zoom';
  var maskTransitionName = attrs.maskTransitionName || 'fade';
  var classString = classNames(contentPrefixCls, "".concat(contentPrefixCls, "-").concat(attrs.type), "".concat(prefixCls, "-").concat(attrs.type), attrs.class);

  var cancelButton = okCancel && _vue.createVNode(ActionButton, {
    "actionFn": onCancel,
    "closeModal": close,
    "autofocus": autoFocusButton === 'cancel',
    "buttonProps": cancelButtonProps
  }, {
    default: function _default() {
      return [cancelText];
    }
  });

  return _vue.createVNode(Dialog, {
    "prefixCls": prefixCls,
    "class": classString,
    "wrapClassName": classNames(_defineProperty({}, "".concat(contentPrefixCls, "-centered"), !!centered)),
    "onCancel": function onCancel(e) {
      return close({
        triggerCancel: true
      }, e);
    },
    "visible": visible,
    "closable": closable,
    "title": "",
    "transitionName": transitionName,
    "footer": "",
    "maskTransitionName": maskTransitionName,
    "mask": mask,
    "maskClosable": maskClosable,
    "maskStyle": maskStyle,
    "style": style,
    "width": width,
    "zIndex": zIndex,
    "afterClose": afterClose,
    "keyboard": keyboard,
    "centered": centered,
    "getContainer": getContainer
  }, {
    default: function _default() {
      return [_vue.createVNode("div", {
        "class": "".concat(contentPrefixCls, "-body-wrapper")
      }, [_vue.createVNode("div", {
        "class": "".concat(contentPrefixCls, "-body")
      }, [typeof icon === 'function' ? icon() : icon, attrs.title === undefined ? null : _vue.createVNode("span", {
        "class": "".concat(contentPrefixCls, "-title")
      }, [attrs.title]), _vue.createVNode("div", {
        "class": "".concat(contentPrefixCls, "-content")
      }, [typeof attrs.content === 'function' ? attrs.content() : attrs.content])]), _vue.createVNode("div", {
        "class": "".concat(contentPrefixCls, "-btns")
      }, [cancelButton, _vue.createVNode(ActionButton, {
        "type": okType,
        "actionFn": onOk,
        "closeModal": close,
        "autofocus": autoFocusButton === 'ok',
        "buttonProps": okButtonProps
      }, {
        default: function _default() {
          return [okText];
        }
      })])])];
    }
  });
};

ConfirmDialog.inheritAttrs = false;
export default ConfirmDialog;