"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _one = require("remax/one");

var _indexModule = _interopRequireDefault(require("./index.module.less"));

var _classnames = _interopRequireDefault(require("classnames"));

var _shadow = _interopRequireDefault(require("../shadow"));

var _needWrap = _interopRequireDefault(require("../need-wrap"));

var _space = _interopRequireDefault(require("../space"));

var _icon = _interopRequireDefault(require("../icon"));

var _excluded = ["children", "className", "size", "shadow", "type", "icon", "bold", "round", "block", "ghost", "loading", "disable"];

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

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; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var _default = function _default(_ref) {
  var _classNames;

  var children = _ref.children,
      className = _ref.className,
      _ref$size = _ref.size,
      size = _ref$size === void 0 ? 'normal' : _ref$size,
      _ref$shadow = _ref.shadow,
      shadow = _ref$shadow === void 0 ? false : _ref$shadow,
      _ref$type = _ref.type,
      type = _ref$type === void 0 ? 'default' : _ref$type,
      icon = _ref.icon,
      bold = _ref.bold,
      _ref$round = _ref.round,
      round = _ref$round === void 0 ? false : _ref$round,
      _ref$block = _ref.block,
      block = _ref$block === void 0 ? true : _ref$block,
      _ref$ghost = _ref.ghost,
      ghost = _ref$ghost === void 0 ? false : _ref$ghost,
      _ref$loading = _ref.loading,
      loading = _ref$loading === void 0 ? false : _ref$loading,
      disable = _ref.disable,
      props = _objectWithoutProperties(_ref, _excluded);

  return /*#__PURE__*/_react.default.createElement(_needWrap.default, {
    wrap: _shadow.default,
    need: shadow
  }, /*#__PURE__*/_react.default.createElement(_one.Button, _objectSpread({
    "aria-label": typeof children === 'string' ? children : undefined,
    "aria-disabled": disable,
    className: (0, _classnames.default)(_indexModule.default.button, className, _indexModule.default[size], _indexModule.default[type], (_classNames = {}, _defineProperty(_classNames, _indexModule.default.ghost, ghost), _defineProperty(_classNames, _indexModule.default.disable, disable), _defineProperty(_classNames, _indexModule.default.block, block), _defineProperty(_classNames, _indexModule.default.loading, loading), _defineProperty(_classNames, _indexModule.default.round, round), _defineProperty(_classNames, _indexModule.default.bold, bold), _defineProperty(_classNames, _indexModule.default.noBorder, type === 'default' && shadow), _classNames))
  }, props), /*#__PURE__*/_react.default.createElement(_space.default, {
    size: '.5em',
    alignItems: 'center'
  }, loading ? /*#__PURE__*/_react.default.createElement(_icon.default, {
    name: 'loading',
    color: type === 'default' ? '#999' : '#fff'
  }) : icon, children)));
};

exports.default = _default;