"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 core_frontend_1 = require("@itwin/core-frontend");
const shim_1 = require("use-sync-external-store/shim");
const subscribe = (onStoreChange) => {
    return core_frontend_1.IModelApp.viewManager.onSelectedViewportChanged.addListener(onStoreChange);
};
const getSnapshot = () => {
    return core_frontend_1.IModelApp.viewManager.selectedView;
};
/** React hook that maintains the active viewport.
 * @public
 */
function useActiveViewport() {
    const activeViewport = (0, shim_1.useSyncExternalStore)(subscribe, getSnapshot);
    return activeViewport;
}
exports.useActiveViewport = useActiveViewport;
//# sourceMappingURL=useActiveViewport.js.map