"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

var React = _interopRequireWildcard(require("react"));

var PropTypes = _interopRequireWildcard(require("prop-types"));

var _reactIntersectionObserver = _interopRequireDefault(require("@researchgate/react-intersection-observer"));

var S = _interopRequireWildcard(require("./styles"));

var MenuContainer = function MenuContainer(_ref) {
  var adjustHeight = _ref.adjustHeight,
      children = _ref.children;

  var _React$useState = React.useState(true),
      _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
      isIntersecting = _React$useState2[0],
      setIsIntersecting = _React$useState2[1];

  var onIntersectionChange = React.useCallback(function (arg) {
    setIsIntersecting(arg.isIntersecting);
  }, []);
  return React.createElement(React.Fragment, null, React.createElement(_reactIntersectionObserver.default, {
    onChange: onIntersectionChange
  }, React.createElement(S.MenuIntersectionGuard, null)), React.createElement(S.MenuIntersectionContainer, {
    isIntersecting: isIntersecting,
    adjustHeight: adjustHeight
  }, children));
};

MenuContainer.propTypes = {
  adjustHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
  children: PropTypes.node
};
var _default = MenuContainer;
exports.default = _default;