"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PageResourceMenusConverter = void 0;
const ta_json_1 = require("ta-json");
const menu_item_1 = require("../models/pages/menu-item");
class PageResourceMenusConverter {
    /**
     * Serializes a string map of arrays of {@link MenuItem}s.
     *
     * @param value - The map of strings to arrays of {@link MenuItem}s
     * @returns A JSON value object.
     */
    serialize(value) {
        const result = {};
        Object.keys(value).forEach(menuName => {
            const menu = value[menuName];
            result[menuName] = menu.map(menuItem => {
                return ta_json_1.TaJson.serialize(menuItem);
            });
        });
        return result;
    }
    /**
     * Deserializes a JSON object into a string map of arrays of {@link MenuItem}s.
     *
     * @param value - A JSON object
     * @returns A mapping of strings to arrays of {@link MenuItem}s.
     */
    deserialize(value) {
        if (!value) {
            return {};
        }
        const result = {};
        Object.keys(value).forEach(menuName => {
            const menu = value[menuName];
            if (Array.isArray(menu)) {
                result[menuName] = menu.map(menuItem => {
                    return ta_json_1.TaJson.deserialize(menuItem, menu_item_1.MenuItem);
                });
            }
        });
        return result;
    }
}
exports.PageResourceMenusConverter = PageResourceMenusConverter;
//# sourceMappingURL=page-resource-menus-converter.js.map