/*---------------------------------------------------------------------------------------------
 * 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 { isToolbarActionItem, isToolbarCustomItem, isToolbarGroupItem, } from "../../toolbar/ToolbarItem";
import { ToolGroup } from "./ToolGroup";
/** @internal */
export function Toolbar({ items, expandsTo = "bottom", panelAlignment = "start", }) {
    const [popoverOpen, setPopoverOpen] = React.useState(false);
    return (React.createElement(ToolbarContext.Provider, { value: {
            expandsTo,
            panelAlignment,
            popoverOpen,
            setPopoverOpen,
        } },
        React.createElement(ToolGroup, null, items.map((item) => {
            if (isToolbarActionItem(item)) {
                return React.createElement(ToolGroup.ActionItem, { key: item.id, item: item });
            }
            if (isToolbarGroupItem(item)) {
                return React.createElement(ToolGroup.GroupItem, { key: item.id, item: item });
            }
            if (isToolbarCustomItem(item)) {
                return React.createElement(ToolGroup.CustomItem, { key: item.id, item: item });
            }
            return null;
        }))));
}
/** @internal */
export const ToolbarContext = React.createContext(undefined);
ToolbarContext.displayName = "uifw:ToolbarContext";
//# sourceMappingURL=Toolbar.js.map