text: "use strict";
  
  exports.__esModule = true;
  
  var _react = require("react");
  
  var _react2 = _interopRequireDefault(_react);
  
  var _propTypes = require("prop-types");
  
  var _propTypes2 = _interopRequireDefault(_propTypes);
  
  var _history = require("history");
  
  var _invariant = require("invariant");
  
  var _invariant2 = _interopRequireDefault(_invariant);
  
  var _RouterContext = require("./RouterContext");
  
  var _RouterContext2 = _interopRequireDefault(_RouterContext);
  
  var _generatePath = require("./generatePath");
  
  var _generatePath2 = _interopRequireDefault(_generatePath);
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  
  function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  
  var Navigate = function (_React$Component) {
    _inherits(Navigate, _React$Component);
  
    function Navigate(props) {
      _classCallCheck(this, Navigate);
  
      var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
  
      props.method(props.to);
      return _this;
    }
  
    Navigate.prototype.componentDidUpdate = function componentDidUpdate(prevProps) {
      if (!(0, _history.locationsAreEqual)(prevProps.to, this.props.to)) {
        this.props.method(this.props.to);
      }
    };
  
    Navigate.prototype.render = function render() {
      return null;
    };
  
    return Navigate;
  }(_react2.default.Component);
  
  if (process.env.NODE_ENV !== "production") {
    var locationType = _propTypes2.default.shape({
      pathname: _propTypes2.default.string.isRequired,
      search: _propTypes2.default.string.isRequired,
      hash: _propTypes2.default.string.isRequired
    });
  
    Navigate.propTypes = {
      method: _propTypes2.default.func.isRequired,
      to: locationType.isRequired
    };
  }
  
  /**
   * The public API for navigating programmatically with a component.
   */
  function Redirect(props) {
    return _react2.default.createElement(
      _RouterContext2.default.Consumer,
      null,
      function (context) {
        !context ? process.env.NODE_ENV !== "production" ? (0, _invariant2.default)(false, "You should not use <Redirect> outside a <Router>") : (0, _invariant2.default)(false) : void 0;
  
        var method = props.push ? context.history.push : context.history.replace;
        var to = (0, _history.createLocation)(props.computedMatch ? typeof props.to === "string" ? (0, _generatePath2.default)(props.to, props.computedMatch.params) : Object.assign({}, props.to, {
          pathname: (0, _generatePath2.default)(props.to.pathname, props.computedMatch.params)
        }) : props.to);
  
        return _react2.default.createElement(Navigate, { method: method, to: to });
      }
    );
  }
  
  Redirect.defaultProps = {
    push: false
  };
  
  if (process.env.NODE_ENV !== "production") {
    Redirect.propTypes = {
      push: _propTypes2.default.bool,
      from: _propTypes2.default.string,
      to: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]).isRequired
    };
  }
  
  exports.default = Redirect;