/**
 * Copyright IBM Corp. 2020, 2026
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

import { __toESM } from "../../_virtual/_rolldown/runtime.js";
import { require_classnames } from "../../node_modules/classnames/index.js";
import { pkg } from "../../settings.js";
import uuidv4 from "../../global/js/utils/uuidv4.js";
import React, { useRef } from "react";
import PropTypes from "prop-types";
import { OverflowMenu, OverflowMenuItem } from "@carbon/react";

//#region src/components/ActionBar/ActionBarOverflowItems.tsx
var import_classnames = /* @__PURE__ */ __toESM(require_classnames());
const blockClass = `${pkg.prefix}--action-bar-overflow-items`;
const componentName = "ActionBar";
const ActionBarOverflowItems = ({ className, menuOptionsClass, overflowItems, overflowAriaLabel, overflowMenuRef }) => {
	const internalId = useRef(uuidv4());
	return /* @__PURE__ */ React.createElement("div", { ref: overflowMenuRef }, /* @__PURE__ */ React.createElement(OverflowMenu, {
		"aria-label": overflowAriaLabel,
		className: (0, import_classnames.default)(blockClass, className),
		direction: "bottom",
		flipped: true,
		iconDescription: overflowAriaLabel,
		menuOptionsClass: (0, import_classnames.default)(`${blockClass}__options`, menuOptionsClass)
	}, React.Children.map(overflowItems, (item, index) => {
		const ItemIcon = item?.props.renderIcon;
		return /* @__PURE__ */ React.createElement(OverflowMenuItem, {
			className: `${blockClass}__item`,
			onClick: item?.props.onClick,
			itemText: /* @__PURE__ */ React.createElement("div", {
				className: `${blockClass}__item-content`,
				"aria-describedby": `${internalId.current}-${index}--item-label`
			}, /* @__PURE__ */ React.createElement("span", {
				className: `${blockClass}__item-label`,
				id: `${internalId.current}-${index}--item-label`
			}, item?.props.label), typeof item?.props.renderIcon === "function" ? /* @__PURE__ */ React.createElement(ItemIcon, null) : item?.props.renderIcon)
		});
	})));
};
ActionBarOverflowItems.displayName = componentName;
ActionBarOverflowItems.propTypes = {
	className: PropTypes.string,
	menuOptionsClass: PropTypes.string,
	overflowAriaLabel: PropTypes.string,
	overflowItems: PropTypes.arrayOf(PropTypes.element),
	overflowMenuRef: PropTypes.oneOfType([
		PropTypes.shape({ current: PropTypes.elementType }),
		PropTypes.object,
		PropTypes.func
	]),
	tabIndex: PropTypes.number
};

//#endregion
export { ActionBarOverflowItems };