"use strict";
/*---------------------------------------------------------------------------------------------
 * 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
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.useUiItemsProviderToolbarItems = void 0;
const React = require("react");
const useActiveStageProvidedToolbarItems_1 = require("./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.
 */
const useUiItemsProviderToolbarItems = (
// eslint-disable-next-line deprecation/deprecation
manager, toolbarUsage, toolbarOrientation) => {
    const providedItems = (0, useActiveStageProvidedToolbarItems_1.useActiveStageProvidedToolbarItems)(toolbarUsage, toolbarOrientation);
    const [items, setItems] = React.useState(providedItems);
    React.useEffect(() => {
        manager?.loadItems(providedItems);
        setItems(manager?.items ?? providedItems);
        return manager?.onItemsChanged.addListener((args) => {
            setItems(args.items);
        });
    }, [manager, providedItems]);
    return items;
};
exports.useUiItemsProviderToolbarItems = useUiItemsProviderToolbarItems;
//# sourceMappingURL=useUiItemsProviderToolbarItems.js.map