"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 Hooks
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.useAvailableUiItemsProviders = void 0;
const react_1 = require("react");
const appui_abstract_1 = require("@itwin/appui-abstract");
/** React hook that maintains the number of available UiItemsProviders. This allows components to use it to refresh when a
 * UiItemsProviders is added or removed allowing the ui component to be re-rendered.
 * @internal
 */
function useAvailableUiItemsProviders() {
    const [uiItemsProviderIds, setUiItemsProviderIds] = (0, react_1.useState)(appui_abstract_1.UiItemsManager.registeredProviderIds); // eslint-disable-line deprecation/deprecation
    (0, react_1.useEffect)(() => {
        const handleUiProviderRegisteredEvent = () => {
            setUiItemsProviderIds(appui_abstract_1.UiItemsManager.registeredProviderIds); // eslint-disable-line deprecation/deprecation
        };
        appui_abstract_1.UiItemsManager.onUiProviderRegisteredEvent.addListener(handleUiProviderRegisteredEvent); // eslint-disable-line deprecation/deprecation
        return () => {
            appui_abstract_1.UiItemsManager.onUiProviderRegisteredEvent.removeListener(handleUiProviderRegisteredEvent); // eslint-disable-line deprecation/deprecation
        };
    }, []);
    return uiItemsProviderIds;
}
exports.useAvailableUiItemsProviders = useAvailableUiItemsProviders;
//# sourceMappingURL=useAvailableUiItemsProviders.js.map