/*---------------------------------------------------------------------------------------------
 * 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 { useActiveStageProvidedToolbarItems } from "./useActiveStageProvidedToolbarItems";
/** Hook that retrieves active frontstage toolbar items from UiItemsProviders and manage them through [[ToolbarItemsManager]].
 * @public
 * @deprecated in 4.4.0. This uses ToolbarItemsManager which is internal, directly use [[ToolbarComposer]] instead.
 */
export const useUiItemsProviderToolbarItems = (
// eslint-disable-next-line deprecation/deprecation
manager, toolbarUsage, toolbarOrientation) => {
    const providedItems = useActiveStageProvidedToolbarItems(toolbarUsage, toolbarOrientation);
    const [items, setItems] = React.useState(providedItems);
    React.useEffect(() => {
        var _a;
        manager === null || manager === void 0 ? void 0 : manager.loadItems(providedItems);
        setItems((_a = manager === null || manager === void 0 ? void 0 : manager.items) !== null && _a !== void 0 ? _a : providedItems);
        return manager === null || manager === void 0 ? void 0 : manager.onItemsChanged.addListener((args) => {
            setItems(args.items);
        });
    }, [manager, providedItems]);
    return items;
};
//# sourceMappingURL=useUiItemsProviderToolbarItems.js.map