import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";

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(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

import React from 'react';
import { Raiser as Component } from './component';
export var Raiser =
/*#__PURE__*/
function (_React$Component) {
  _inherits(Raiser, _React$Component);

  function Raiser(props) {
    var _this;

    _classCallCheck(this, Raiser);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(Raiser).call(this, props));

    _this.handleDecrease = function () {
      if (_this.state.count === 0) return;
      var count = _this.state.count - 1;

      _this.setState({
        count: count
      });

      _this.props.onCount(count);
    };

    _this.handleRaise = function () {
      var count = _this.state.count + 1;

      _this.setState({
        count: count
      });

      _this.props.onCount(count);
    };

    _this.state = {
      count: 0
    };
    return _this;
  }

  _createClass(Raiser, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      this.props.onCount(this.state.count);
    }
  }, {
    key: "reset",
    value: function reset() {
      this.setState({
        count: 0
      });
    }
  }, {
    key: "render",
    value: function render() {
      return React.createElement(Component, _objectSpread({}, this.props, {
        count: this.state.count,
        onDecrease: this.handleDecrease,
        onRaise: this.handleRaise
      }));
    }
  }]);

  return Raiser;
}(React.Component);