text: Object.defineProperty(exports, "__esModule", {
    value: true
  });
  
  var _omit2 = require("lodash/omit");
  
  var _omit3 = _interopRequireDefault(_omit2);
  
  var _defaults2 = require("lodash/defaults");
  
  var _defaults3 = _interopRequireDefault(_defaults2);
  
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  
  var _react = require("react");
  
  var _react2 = _interopRequireDefault(_react);
  
  var _propTypes = require("prop-types");
  
  var _propTypes2 = _interopRequireDefault(_propTypes);
  
  var _log = require("../victory-util/log");
  
  var _log2 = _interopRequireDefault(_log);
  
  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 VictoryPortal = function (_React$Component) {
    _inherits(VictoryPortal, _React$Component);
  
    function VictoryPortal() {
      _classCallCheck(this, VictoryPortal);
  
      return _possibleConstructorReturn(this, (VictoryPortal.__proto__ || Object.getPrototypeOf(VictoryPortal)).apply(this, arguments));
    }
  
    _createClass(VictoryPortal, [{
      key: "componentDidMount",
      value: function componentDidMount() {
        if (!this.checkedContext) {
          if (typeof this.context.portalUpdate !== "function") {
            var msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
            _log2.default.warn(msg);
            this.renderInPlace = true;
          }
          this.checkedContext = true;
        }
        this.forceUpdate();
      }
    }, {
      key: "componentDidUpdate",
      value: function componentDidUpdate() {
        if (!this.renderInPlace) {
          this.portalKey = this.portalKey || this.context.portalRegister();
          this.context.portalUpdate(this.portalKey, this.element);
        }
      }
    }, {
      key: "componentWillUnmount",
      value: function componentWillUnmount() {
        if (this.context && this.context.portalDeregister) {
          this.context.portalDeregister(this.portalKey);
        }
      }
  
      // Overridden in victory-core-native
  
    }, {
      key: "renderPortal",
      value: function renderPortal(child) {
        if (this.renderInPlace) {
          return child;
        }
        this.element = child;
        return null;
      }
    }, {
      key: "render",
      value: function render() {
        var children = Array.isArray(this.props.children) ? this.props.children[0] : this.props.children;
        var groupComponent = this.props.groupComponent;
  
        var childProps = children && children.props || {};
        var standardProps = childProps.groupComponent ? { groupComponent: groupComponent, standalone: false } : {};
        var newProps = (0, _defaults3.default)(standardProps, childProps, (0, _omit3.default)(this.props, ["children", "groupComponent"]));
        var child = children && _react2.default.cloneElement(children, newProps);
        return this.renderPortal(child);
      }
    }]);
  
    return VictoryPortal;
  }(_react2.default.Component);
  
  VictoryPortal.displayName = "VictoryPortal";
  VictoryPortal.role = "portal";
  VictoryPortal.propTypes = {
    children: _propTypes2.default.node,
    groupComponent: _propTypes2.default.element
  };
  VictoryPortal.defaultProps = {
    groupComponent: _react2.default.createElement("g", null)
  };
  VictoryPortal.contextTypes = {
    portalDeregister: _propTypes2.default.func,
    portalRegister: _propTypes2.default.func,
    portalUpdate: _propTypes2.default.func
  };
  exports.default = VictoryPortal;