"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DEFAULT_PAGE_NAME = exports.defaultPageLayouts = void 0;
exports.getDefaultPageLayout = getDefaultPageLayout;
const lodash_1 = require("lodash");
const index_js_1 = require("../pages/index.js");
exports.defaultPageLayouts = {
    '5': (_featureFlags) => {
        const v5 = {
            ...(0, lodash_1.cloneDeep)(index_js_1.pageV6),
            version: 5
        };
        return v5;
    },
    '6': (_featureFlags) => (0, lodash_1.cloneDeep)(index_js_1.pageV6),
    '7': (_featureFlags) => (0, lodash_1.cloneDeep)(index_js_1.pageV7),
    '8': (_featureFlags) => {
        let page = (0, lodash_1.cloneDeep)(index_js_1.pageV8);
        try {
            const firstSection = page.children?.[0];
            const firstColumn = firstSection.children?.[0];
            // Set page minWidth to 300
            page.minWidth = { value: 300, mode: 'px' };
            // Set the first section to fitContent
            firstSection.height.mode = 'fitContent';
            firstSection.height.value = 8;
            delete firstSection.minHeight;
            // Set the first column to scrollContents
            firstColumn.shouldScrollContents = true;
            // Sets the first section stackOnMobile to 480px, Breakpoint.mobile
            firstSection.stackColumnsAt = { value: 480, mode: 'px' };
            // Update the layoutVersion to 2, this will skip migrations
            page.layoutVersion = 2;
        }
        catch (e) {
            console.error('FAILED TO UPDATE PAGE LAYOUT TO V8');
            console.error(e);
            // We don't need to throw an error here, but we should fix it because the defaults will be wrong
            // Instead we just return the default page
            page = (0, lodash_1.cloneDeep)(index_js_1.pageV8);
        }
        return page;
    }
};
// This logic is only used when creating pages. It should only contain
// the current and next version, delete any unused versions
function getDefaultPageLayout(version, featureFlags) {
    if (exports.defaultPageLayouts[String(version)]) {
        return exports.defaultPageLayouts[String(version)](featureFlags);
    }
    else {
        throw Error(`Missing layout for version ${version}`);
    }
}
exports.DEFAULT_PAGE_NAME = 'Page1';
//# sourceMappingURL=page.js.map