"use strict";

exports.__esModule = true;
exports.default = exports.Wrapper = void 0;
var _react = _interopRequireDefault(require("react"));
var _styles = require("@material-ui/core/styles");
var _Menu = _interopRequireDefault(require("./Menu"));
var _useToggle3 = _interopRequireDefault(require("../../hooks/useToggle"));
var _withClickOutside = _interopRequireDefault(require("../../hocs/withClickOutside"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var useStyles = (0, _styles.makeStyles)(function () {
  return {
    wrapper: {
      position: "relative"
    }
  };
});
var Wrapper = exports.Wrapper = (0, _withClickOutside.default)(_react.default.forwardRef(__signature__(__signature__(function (_ref, ref) {
  var children = _ref.children,
    className = _ref.className;
  var classes = useStyles();
  return /*#__PURE__*/_react.default.createElement("div", {
    ref: ref,
    className: "".concat(classes.wrapper, " ").concat(className ? className : "")
  }, children);
}, "useStyles{classes}", function () {
  return [useStyles];
}), "useStyles{classes}", function () {
  return [useStyles];
})));
var DropMenu = function DropMenu(_ref2) {
  var id = _ref2.id,
    initOpen = _ref2.initOpen,
    menuItems = _ref2.menuItems,
    alignRight = _ref2.alignRight,
    _ref2$className = _ref2.className,
    className = _ref2$className === void 0 ? "" : _ref2$className,
    children = _ref2.children;
  var _useToggle = (0, _useToggle3.default)(initOpen),
    _useToggle2 = _slicedToArray(_useToggle, 3),
    open = _useToggle2[0],
    toggle = _useToggle2[1],
    reset = _useToggle2[2];
  return /*#__PURE__*/_react.default.createElement(Wrapper, {
    className: className,
    onClickOutside: reset
  }, /*#__PURE__*/_react.default.createElement("div", {
    id: id + "Anchor",
    onClick: toggle
  }, _react.default.Children.map(children, function (child) {
    return typeof child === "object" ? _react.default.cloneElement(child, {
      open: open
    }) : child;
  })), /*#__PURE__*/_react.default.createElement(_Menu.default, {
    id: id + "Dropdown",
    open: open,
    menuItems: menuItems,
    reset: reset,
    alignRight: alignRight
  }));
};
__signature__(DropMenu, "useToggle{[open, toggle, reset]}", function () {
  return [_useToggle3.default];
});
__signature__(DropMenu, "useToggle{[open, toggle, reset]}", function () {
  return [_useToggle3.default];
});
var _default = DropMenu;
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/DropMenu/index.js");
  reactHotLoader.register(Wrapper, "Wrapper", "/home/vsts/work/1/s/src/components/DropMenu/index.js");
  reactHotLoader.register(DropMenu, "DropMenu", "/home/vsts/work/1/s/src/components/DropMenu/index.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/DropMenu/index.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/DropMenu/index.js");
  reactHotLoader.register(Wrapper, "Wrapper", "/home/vsts/work/1/s/src/components/DropMenu/index.js");
  reactHotLoader.register(DropMenu, "DropMenu", "/home/vsts/work/1/s/src/components/DropMenu/index.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/DropMenu/index.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();