"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _flex = _interopRequireDefault(require("../../templates/flex"));
var _icon = require("../../icon");
var _typography = require("../../typography");
var _excluded = ["open", "icon", "label", "caret", "ref"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
var MenuContainer = (0, _styledComponents["default"])(_flex["default"]).withConfig({
  displayName: "menuButton__MenuContainer",
  componentId: "sc-aj99z3-0"
})(["cursor:pointer;"]);
var MenuButton = function MenuButton(_ref) {
  var open = _ref.open,
    icon = _ref.icon,
    label = _ref.label,
    caret = _ref.caret,
    ref = _ref.ref,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  return /*#__PURE__*/_react["default"].createElement(MenuContainer, _extends({
    gap: 2,
    padding: [2, 4],
    justifyContent: "between",
    alignItems: "center",
    role: "button",
    tabindex: "0",
    "aria-haspopup": "listbox",
    "aria-expanded": open,
    ref: ref
  }, rest), /*#__PURE__*/_react["default"].createElement(_flex["default"], {
    alignItems: "center",
    gap: 2
  }, icon, typeof label === "string" ? /*#__PURE__*/_react["default"].createElement(_typography.Text, null, label) : label), caret === true ? /*#__PURE__*/_react["default"].createElement(_icon.Icon, {
    name: "chevron_down",
    color: "text",
    width: "12px",
    height: "12px",
    rotate: open ? 2 : null
  }) : caret);
};
var _default = exports["default"] = MenuButton;