"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Submenu = void 0;
var _react = _interopRequireWildcard(require("react"));
var _utils = require("../../utils");
var _IconButton = require("../IconButton");
var _Icons = require("../Icons");
var _Menu = require("../Menu");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var Submenu = exports.Submenu = function Submenu(_ref) {
  var onBack = _ref.onBack,
    onHeightChange = _ref.onHeightChange,
    style = _ref.style,
    children = _ref.children,
    title = _ref.title,
    indexPage = _ref.indexPage;
  var ref = (0, _react.useRef)(null);
  var dimensions = (0, _utils.useResizeObserver)(ref);
  var height = dimensions === null || dimensions === void 0 ? void 0 : dimensions.height;
  (0, _react.useEffect)(function () {
    if (height && height > 0 && !indexPage) {
      onHeightChange === null || onHeightChange === void 0 || onHeightChange(height);
    }
  }, [height, onHeightChange, indexPage]);
  return /*#__PURE__*/_react.default.createElement("div", {
    style: style,
    ref: ref
  }, /*#__PURE__*/_react.default.createElement(_Menu.MenuHeader, {
    title: title,
    leftElement: /*#__PURE__*/_react.default.createElement(_IconButton.IconButton, {
      onClick: onBack,
      variant: "text gray",
      size: "small"
    }, /*#__PURE__*/_react.default.createElement(_Icons.ArrowLeftIcon, null))
  }), children);
};
//# sourceMappingURL=Submenu.js.map