"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.useActiveViewport = void 0;
const react_1 = require("react");
const core_frontend_1 = require("@itwin/core-frontend");
/** React hook that maintains the active viewport.
 * @public
 */
function useActiveViewport() {
    const [activeViewport, setActiveViewport] = (0, react_1.useState)(core_frontend_1.IModelApp.viewManager.selectedView);
    (0, react_1.useEffect)(() => {
        return core_frontend_1.IModelApp.viewManager.onSelectedViewportChanged.addListener((args) => {
            setActiveViewport(args.current);
        });
    }, []);
    return activeViewport;
}
exports.useActiveViewport = useActiveViewport;
//# sourceMappingURL=useActiveViewport.js.map