/*(c) Copyright 2015 Pivotal Software, Inc. All Rights Reserved.*/
'use strict';

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

var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

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 _get2 = require('babel-runtime/helpers/get');

var _get3 = _interopRequireDefault(_get2);

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

var _inherits3 = _interopRequireDefault(_inherits2);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var types = _react2.default.PropTypes;

exports.default = function (ParentClass) {
  var _class, _temp;

  return _temp = _class = function (_ParentClass) {
    (0, _inherits3.default)(Transition, _ParentClass);

    function Transition() {
      (0, _classCallCheck3.default)(this, Transition);
      return (0, _possibleConstructorReturn3.default)(this, (Transition.__proto__ || (0, _getPrototypeOf2.default)(Transition)).apply(this, arguments));
    }

    (0, _createClass3.default)(Transition, [{
      key: 'componentWillUpdate',
      value: function componentWillUpdate(nextProps, nextState) {
        (0, _get3.default)(Transition.prototype.__proto__ || (0, _getPrototypeOf2.default)(Transition.prototype), 'componentWillUpdate', this) && (0, _get3.default)(Transition.prototype.__proto__ || (0, _getPrototypeOf2.default)(Transition.prototype), 'componentWillUpdate', this).call(this, nextProps, nextState);

        var open = nextState.open;
        var onEntered = nextProps.onEntered,
            onExited = nextProps.onExited;


        var transitionCallback = open ? onEntered : onExited;
        var transitioning = open !== this.state.open;
        if (transitioning && transitionCallback) transitionCallback();
      }
    }]);
    return Transition;
  }(ParentClass), _class.propTypes = {
    onEntered: types.func,
    onExited: types.func
  }, _temp;
};

module.exports = exports['default'];