import _extends from 'babel-runtime/helpers/extends';
import _defineProperty from 'babel-runtime/helpers/defineProperty';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
var __rest = this && this.__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;
};
import React from 'react';
import classNames from 'classnames';

var CheckableTag = function (_React$Component) {
    _inherits(CheckableTag, _React$Component);

    function CheckableTag() {
        _classCallCheck(this, CheckableTag);

        var _this = _possibleConstructorReturn(this, (CheckableTag.__proto__ || Object.getPrototypeOf(CheckableTag)).apply(this, arguments));

        _this.handleClick = function () {
            var _this$props = _this.props,
                checked = _this$props.checked,
                onChange = _this$props.onChange;

            if (onChange) {
                onChange(!checked);
            }
        };
        return _this;
    }

    _createClass(CheckableTag, [{
        key: 'render',
        value: function render() {
            var _classNames;

            var _a = this.props,
                _a$prefixCls = _a.prefixCls,
                prefixCls = _a$prefixCls === undefined ? 'ant-tag' : _a$prefixCls,
                className = _a.className,
                checked = _a.checked,
                restProps = __rest(_a, ["prefixCls", "className", "checked"]);
            var cls = classNames(prefixCls, (_classNames = {}, _defineProperty(_classNames, prefixCls + '-checkable', true), _defineProperty(_classNames, prefixCls + '-checkable-checked', checked), _classNames), className);
            delete restProps.onChange; // TypeScript cannot check delete now.
            return React.createElement('div', _extends({}, restProps, { className: cls, onClick: this.handleClick }));
        }
    }]);

    return CheckableTag;
}(React.Component);

export default CheckableTag;