"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._migrateEventListCardConfigs = _migrateEventListCardConfigs;
const set_prop_1 = require("../../objects/set-prop");
const util_1 = require("../../util");
/**
 * Reconfigure event list card properties
 * @private
 * @param {object} model Site Model
 * @returns {object}
 */
function _migrateEventListCardConfigs(model) {
    var _a;
    // do nothing if migration already applied
    if (((_a = model.item.properties) === null || _a === void 0 ? void 0 : _a.schemaVersion) >= 1.6)
        return model;
    // apply migration
    const clone = (0, util_1.cloneObject)(model);
    clone.data.values.layout.sections.map((section) => (Object.assign(Object.assign({}, section), { rows: (section.rows || []).map((row) => (Object.assign(Object.assign({}, row), { cards: (row.cards || []).map((card) => {
                if (card.component.name === "event-list-card") {
                    card.component.settings.displayMode = card.component.settings
                        .calendarEnabled
                        ? "calendar"
                        : "list";
                    delete card.component.settings.calendarEnabled;
                }
                return card;
            }) }))) })));
    // increment schemaVersion
    (0, set_prop_1.setProp)("item.properties.schemaVersion", 1.6, clone);
    return clone;
}
//# sourceMappingURL=_migrate-event-list-card-configs.js.map