"use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;exports.__esModule = true;exports.withSize = withSize;var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _react = _interopRequireDefault(require("react"));



var _SizeControlContext = require("./SizeControlContext");
var _constants = require("./constants");







function withSize(constructor) {
  var SizeDecorator = /*#__PURE__*/function (_constructor) {function SizeDecorator() {var _this;for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];}_this = _constructor.call.apply(_constructor, [this].concat(args)) || this;_this.
      size = _constants.defaultSizeValue;return _this;}(0, _inheritsLoose2.default)(SizeDecorator, _constructor);var _proto = SizeDecorator.prototype;_proto.

    render = function render() {var _this2 = this;
      return /*#__PURE__*/(
        _react.default.createElement(_SizeControlContext.SizeControlContext.Consumer, null,
        function (context) {var _this2$props$size;
          _this2.size = (_this2$props$size = _this2.props.size) != null ? _this2$props$size : context.size;
          var originalRender = _constructor.prototype.render;
          if (typeof originalRender === 'function') {
            return originalRender.call(_this2);
          }

          return null;
        }
        ));

    };return SizeDecorator;}(constructor);


  var nameDescriptor = Object.getOwnPropertyDescriptor(SizeDecorator, 'name');
  if (!nameDescriptor || nameDescriptor.configurable) {
    Object.defineProperty(SizeDecorator, 'name', { value: constructor.name });
  }

  return SizeDecorator;
}