/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Toolbar
 */
import * as React from "react";
import { ToolGroupOverflowContext } from "./OverflowButton.js";
import { Item } from "./Item.js";
import { GroupMenuItem } from "./GroupItem.js";
import { ToolbarContext } from "./Toolbar.js";
import { useSafeContext } from "../../hooks/useSafeContext.js";
/** @internal */
export const ActionItem = React.forwardRef(function ActionItem({ item }, ref) {
    const { onItemExecuted } = useSafeContext(ToolbarContext);
    const overflowContext = React.useContext(ToolGroupOverflowContext);
    if (overflowContext) {
        return React.createElement(GroupMenuItem, { item: item, onClose: overflowContext.onClose });
    }
    return (React.createElement(Item, { ref: ref, item: item, onClick: () => {
            item.execute();
            onItemExecuted?.(item);
        } }));
});
//# sourceMappingURL=ActionItem.js.map