"use strict";

exports.__esModule = true;
exports.default = void 0;
var _tslib = require("tslib");
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _view = _interopRequireDefault(require("../view"));
var _button = _interopRequireDefault(require("../button"));
var _utils = require("../utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var BottomButton = function (props) {
  var _classNames, _classNames2;
  var _props$prefix = props.prefix,
    prefix = _props$prefix === void 0 ? 'mt-' : _props$prefix,
    _props$actions = props.actions,
    actions = _props$actions === void 0 ? ['cancel', 'ok'] : _props$actions,
    _props$size = props.size,
    size = _props$size === void 0 ? 'large' : _props$size,
    okText = props.okText,
    cancelText = props.cancelText,
    className = props.className,
    okProps = props.okProps,
    cancelProps = props.cancelProps,
    _props$enableSafeArea = props.enableSafeArea,
    enableSafeArea = _props$enableSafeArea === void 0 ? false : _props$enableSafeArea,
    _props$showDividingLi = props.showDividingLine,
    showDividingLine = _props$showDividingLi === void 0 ? true : _props$showDividingLi,
    children = props.children,
    onOk = props.onOk,
    onCancel = props.onCancel,
    others = (0, _tslib.__rest)(props, ["prefix", "actions", "size", "okText", "cancelText", "className", "okProps", "cancelProps", "enableSafeArea", "showDividingLine", "children", "onOk", "onCancel"]);
  var clsPrefix = prefix + "bottom-btn";
  var clses = {
    bottomBtn: (0, _classnames.default)(clsPrefix, className, (_classNames = {}, _classNames[clsPrefix + "--dividing"] = showDividingLine, _classNames[clsPrefix + "--safe"] = enableSafeArea, _classNames)),
    extra: clsPrefix + "-extra",
    container: (0, _classnames.default)(clsPrefix + "-container", (_classNames2 = {}, _classNames2[clsPrefix + "-container--col-2"] = (0, _utils.isValidArray)(actions) && actions.length === 2, _classNames2))
  };
  var _a = okProps || {},
    okBtnText = _a.text,
    otherOkBtnProps = (0, _tslib.__rest)(_a, ["text"]);
  var _b = cancelProps || {},
    cancelBtnText = _b.text,
    otherCancelBtnProps = (0, _tslib.__rest)(_b, ["text"]);
  return /*#__PURE__*/(0, _react.createElement)(_view.default, _extends({}, others, {
    className: clses.bottomBtn
  }), children ? /*#__PURE__*/(0, _react.createElement)(_view.default, {
    className: clses.extra
  }, children) : null, /*#__PURE__*/(0, _react.createElement)(_view.default, {
    className: clses.container
  }, actions.map(function (act) {
    var isCancel = act === 'cancel';
    var text = isCancel ? cancelText || cancelBtnText || '取消' : okText || okBtnText || '确定';
    var btnProps = Object.assign({
      onClick: isCancel ? onCancel : onOk,
      size: size
    }, isCancel ? otherCancelBtnProps : otherOkBtnProps);
    return /*#__PURE__*/(0, _react.createElement)(_button.default, _extends({
      key: "bottom-btn-" + act,
      type: isCancel ? 'normal' : 'primary',
      model: isCancel ? 'outline' : 'solid'
    }, btnProps), text);
  })));
};
BottomButton.displayName = 'BottomButton';
var _default = BottomButton;
exports.default = _default;