"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 Base
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLayout = exports.useLayoutStore = exports.createLayoutStore = exports.LayoutStoreContext = void 0;
const React = require("react");
const zustand_1 = require("zustand");
const traditional_1 = require("zustand/traditional");
const shallow_1 = require("zustand/shallow");
const core_bentley_1 = require("@itwin/core-bentley");
const NineZoneState_1 = require("../state/NineZoneState");
/** @internal */
exports.LayoutStoreContext = React.createContext(undefined);
exports.LayoutStoreContext.displayName = "appui:LayoutStoreContext";
/** @internal */
function createLayoutStore(args) {
    return (0, zustand_1.createStore)(() => (0, NineZoneState_1.createNineZoneState)(args));
}
exports.createLayoutStore = createLayoutStore;
/** @internal */
function useLayoutStore() {
    const store = React.useContext(exports.LayoutStoreContext);
    (0, core_bentley_1.assert)(!!store, "LayoutStoreContext is not defined");
    return store;
}
exports.useLayoutStore = useLayoutStore;
/** @internal */
function useLayout(selector, multipleSlices = false) {
    const store = useLayoutStore();
    return (0, traditional_1.useStoreWithEqualityFn)(store, selector, multipleSlices ? shallow_1.shallow : undefined);
}
exports.useLayout = useLayout;
//# sourceMappingURL=LayoutStore.js.map