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 _inherits from "@babel/runtime/helpers/inherits";
import _createSuper from "@babel/runtime/helpers/createSuper";
import React, { Component } from 'react';
import classNames from 'classnames';
import omit from 'lodash/omit';
import RcSwitch from '../rc-components/switch';
import { Size } from '../_util/enum';
import ConfigContext from '../config-provider/ConfigContext';

var Switch = /*#__PURE__*/function (_Component) {
  _inherits(Switch, _Component);

  var _super = _createSuper(Switch);

  function Switch() {
    var _this;

    _classCallCheck(this, Switch);

    _this = _super.apply(this, arguments);

    _this.saveSwitch = function (node) {
      _this.rcSwitch = node;
    };

    return _this;
  }

  _createClass(Switch, [{
    key: "focus",
    value: function focus() {
      if (this.rcSwitch) {
        this.rcSwitch.focus();
      }
    }
  }, {
    key: "blur",
    value: function blur() {
      if (this.rcSwitch) {
        this.rcSwitch.blur();
      }
    }
  }, {
    key: "render",
    value: function render() {
      var _classNames;

      var _this$props = this.props,
          customizePrefixCls = _this$props.prefixCls,
          size = _this$props.size,
          loading = _this$props.loading,
          _this$props$className = _this$props.className,
          className = _this$props$className === void 0 ? '' : _this$props$className;
      var getPrefixCls = this.context.getPrefixCls;
      var prefixCls = getPrefixCls('switch', customizePrefixCls);
      var classes = classNames(className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-small"), size === Size.small), _defineProperty(_classNames, "".concat(prefixCls, "-loading"), loading), _classNames));
      return /*#__PURE__*/React.createElement(RcSwitch, _extends({}, omit(this.props, ['loading']), {
        prefixCls: prefixCls,
        className: classes,
        ref: this.saveSwitch
      }));
    }
  }], [{
    key: "contextType",
    get: function get() {
      return ConfigContext;
    }
  }]);

  return Switch;
}(Component);

export { Switch as default };
Switch.displayName = 'Switch';
//# sourceMappingURL=index.js.map
