'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "OverflowMenu", {
    enumerable: true,
    get: function() {
        return OverflowMenu;
    }
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _reactmenu = require("@fluentui/react-menu");
const _reactbutton = require("@fluentui/react-button");
const _reactoverflow = require("@fluentui/react-overflow");
const OverflowMenu = ({ itemIds, title, items })=>{
    const { ref, overflowCount, isOverflowing } = (0, _reactoverflow.useOverflowMenu)();
    let displayLabel = title;
    displayLabel = title === '' ? `+${overflowCount} items` : `+${overflowCount} ${title}`;
    if (!isOverflowing) {
        return null;
    }
    const remainingItemsCount = itemIds.length - overflowCount;
    const menuList = [];
    for(let i = remainingItemsCount; i < itemIds.length; i++){
        const buttonElement = items[i];
        menuList.push(/*#__PURE__*/ _react.createElement(_reactmenu.MenuItem, {
            tabIndex: -1,
            key: i,
            onClick: (e)=>{
                const button = buttonElement.props;
                if (button.onClick) {
                    button.onClick(e);
                }
            }
        }, buttonElement));
    }
    return /*#__PURE__*/ _react.createElement(_reactmenu.Menu, null, /*#__PURE__*/ _react.createElement(_reactmenu.MenuTrigger, {
        disableButtonEnhancement: true
    }, /*#__PURE__*/ _react.createElement(_reactbutton.MenuButton, {
        ref: ref
    }, displayLabel)), /*#__PURE__*/ _react.createElement(_reactmenu.MenuPopover, null, /*#__PURE__*/ _react.createElement(_reactmenu.MenuList, null, menuList)));
};
