"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSectionHeightMap = exports.useSectionHeightData = void 0;
const react_1 = require("react");
const CntrlContext_1 = require("../provider/CntrlContext");
const Section_1 = require("./Section");
const useSectionHeightData = (sectionId) => {
    const sectionHeightContext = (0, react_1.useContext)(CntrlContext_1.CntrlContext);
    const layouts = sectionHeightContext.layouts;
    const sectionHeightData = sectionHeightContext.getSectionHeightData(sectionId);
    return sectionHeightData ? getSectionHeightMap(sectionHeightData) : getDefaultHeightData(layouts);
};
exports.useSectionHeightData = useSectionHeightData;
function getSectionHeightMap(sectionHeight) {
    return Object.fromEntries(Object.entries(sectionHeight).map(([sectionId, heightData]) => [sectionId, (0, Section_1.getSectionHeight)(heightData)]));
}
exports.getSectionHeightMap = getSectionHeightMap;
function getDefaultHeightData(layouts) {
    return layouts.reduce((acc, layout) => (Object.assign(Object.assign({}, acc), { [layout.id]: '0' })), {});
}
