"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._ensureCatalog = _ensureCatalog;
const get_prop_1 = require("../../objects/get-prop");
const util_1 = require("../../util");
/**
 * Move the data.values.groups array into the
 * data.catalog object
 * @param {Object} model Site Model
 * @private
 */
function _ensureCatalog(model) {
    // early exit
    if ((0, get_prop_1.getProp)(model, "item.properties.schemaVersion") >= 1.2)
        return model;
    const clone = (0, util_1.cloneObject)(model);
    const catalog = (0, get_prop_1.getProp)(clone, "data.catalog") || {};
    if ((0, get_prop_1.getProp)(clone, "data.values.groups")) {
        catalog.groups = (0, util_1.cloneObject)(clone.data.values.groups);
        delete clone.data.values.groups;
    }
    clone.data.catalog = catalog;
    // bump the schemaVersion
    clone.item.properties.schemaVersion = 1.2;
    return clone;
}
//# sourceMappingURL=_ensure-catalog.js.map