'use strict';

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

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _defineProperty2 = require('babel-runtime/helpers/defineProperty');

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _classnames3 = require('classnames');

var _classnames4 = _interopRequireDefault(_classnames3);

var _react = require('react');

var React = _interopRequireWildcard(_react);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }

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

var __rest = undefined && undefined.__rest || function (s, e) {
    var t = {};
    for (var p in s) {
        if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
    }if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
        if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
    }return t;
};

var Badge = function (_React$Component) {
    (0, _inherits3['default'])(Badge, _React$Component);

    function Badge() {
        (0, _classCallCheck3['default'])(this, Badge);
        return (0, _possibleConstructorReturn3['default'])(this, (Badge.__proto__ || Object.getPrototypeOf(Badge)).apply(this, arguments));
    }

    (0, _createClass3['default'])(Badge, [{
        key: 'render',
        value: function render() {
            var _classnames, _classnames2;

            // tslint:disable:prefer-const
            var _a = this.props,
                className = _a.className,
                prefixCls = _a.prefixCls,
                children = _a.children,
                text = _a.text,
                size = _a.size,
                overflowCount = _a.overflowCount,
                dot = _a.dot,
                corner = _a.corner,
                hot = _a.hot,
                restProps = __rest(_a, ["className", "prefixCls", "children", "text", "size", "overflowCount", "dot", "corner", "hot"]);
            overflowCount = overflowCount;
            text = typeof text === 'number' && text > overflowCount ? overflowCount + '+' : text;
            // dot mode don't need text
            if (dot) {
                text = '';
            }
            var scrollNumberCls = (0, _classnames4['default'])((_classnames = {}, (0, _defineProperty3['default'])(_classnames, prefixCls + '-dot', dot), (0, _defineProperty3['default'])(_classnames, prefixCls + '-dot-large', dot && size === 'large'), (0, _defineProperty3['default'])(_classnames, prefixCls + '-text', !dot && !corner), (0, _defineProperty3['default'])(_classnames, prefixCls + '-corner', corner), (0, _defineProperty3['default'])(_classnames, prefixCls + '-corner-large', corner && size === 'large'), _classnames));
            var badgeCls = (0, _classnames4['default'])(prefixCls, className, (_classnames2 = {}, (0, _defineProperty3['default'])(_classnames2, prefixCls + '-not-a-wrapper', !children), (0, _defineProperty3['default'])(_classnames2, prefixCls + '-corner-wrapper', corner), (0, _defineProperty3['default'])(_classnames2, prefixCls + '-hot', !!hot), (0, _defineProperty3['default'])(_classnames2, prefixCls + '-corner-wrapper-large', corner && size === 'large'), _classnames2));
            return React.createElement(
                'span',
                { className: badgeCls },
                children,
                (text || dot) &&
                // tslint:disable-next-line:jsx-no-multiline-js
                React.createElement(
                    'sup',
                    (0, _extends3['default'])({ className: scrollNumberCls }, restProps),
                    text
                )
            );
        }
    }]);
    return Badge;
}(React.Component);

exports['default'] = Badge;

Badge.defaultProps = {
    prefixCls: 'am-badge',
    size: 'small',
    overflowCount: 99,
    dot: false,
    corner: false
};
module.exports = exports['default'];