"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Menu = Menu;
var _reactNative = require("react-native");
var _MenuButton = _interopRequireDefault(require("../../../../../elements/MenuButton"));
var _MenuAction = _interopRequireDefault(require("../../../../../elements/MenuAction"));
var _CopyLinkAction = require("../../../../../elements/CopyLinkAction");
var _ShareAction = require("../../../../../elements/ShareAction");
var _enums = require("../../../../../enums");
var _useMenu = require("./hooks/useMenu");
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 Menu({
  userId,
  displayName
}) {
  const {
    actions,
    shareLink,
    menuButtonId,
    openBottomSheet,
    bottomSheetHeight
  } = (0, _useMenu.useMenu)({
    userId,
    displayName
  });
  const items = [...actions.map(({
    visible,
    ...action
  }) => ({
    visible,
    action: /*#__PURE__*/React.createElement(_MenuAction.default, _extends({
      gap: "small"
    }, action, {
      key: action.label
    }))
  })), {
    visible: !!shareLink,
    action: /*#__PURE__*/React.createElement(_CopyLinkAction.CopyLinkAction, {
      key: "copy",
      link: shareLink ?? '',
      pageId: _enums.PageID.user_profile_page
    })
  }, {
    visible: !!shareLink,
    action: /*#__PURE__*/React.createElement(_ShareAction.ShareAction, {
      key: "share",
      link: shareLink ?? '',
      pageId: _enums.PageID.user_profile_page
    })
  }].filter(({
    visible
  }) => visible);
  return /*#__PURE__*/React.createElement(_MenuButton.default, {
    testID: menuButtonId,
    accessibilityLabel: "User profile menu",
    onPress: () => {
      openBottomSheet({
        height: bottomSheetHeight[items.length],
        content: /*#__PURE__*/React.createElement(_reactNative.View, null, items.map(({
          action
        }) => action))
      });
    }
  });
}
//# sourceMappingURL=Menu.js.map