"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.useActiveStageId = void 0;
const react_1 = require("react");
const UiFramework_1 = require("../UiFramework");
/** React hook that maintains the active stage Id.
 * @public
 */
function useActiveStageId() {
    const [activeStageId, setActiveStageId] = (0, react_1.useState)(UiFramework_1.UiFramework.frontstages.activeFrontstageId);
    (0, react_1.useEffect)(() => {
        const handleFrontstageActivatedEvent = (args) => {
            setActiveStageId(args.activatedFrontstageDef.id);
        };
        UiFramework_1.UiFramework.frontstages.onFrontstageActivatedEvent.addListener(handleFrontstageActivatedEvent);
        return () => {
            UiFramework_1.UiFramework.frontstages.onFrontstageActivatedEvent.removeListener(handleFrontstageActivatedEvent);
        };
    }, []);
    return activeStageId;
}
exports.useActiveStageId = useActiveStageId;
//# sourceMappingURL=useActiveStageId.js.map