"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.computeProps = computeProps;
const processEntityFeatures_1 = require("../../permissions/_internal/processEntityFeatures");
const TemplateBusinessRules_1 = require("./TemplateBusinessRules");
const computeLinks_1 = require("./computeLinks");
const get_prop_1 = require("../../objects/get-prop");
const utils_1 = require("../utils");
const computeItemProps_1 = require("../../core/_internal/computeItemProps");
/**
 * @private
 * Given a model and a template, set various computed
 * properties on the template that can't be directly
 * mapped from the model
 * @param model
 * @param template
 * @param requestOptions
 */
function computeProps(model, template, requestOptions) {
    // 1. compute base properties on template
    template = (0, computeItemProps_1.computeItemProps)(model.item, template);
    // 2. compute relevant template links
    template.links = (0, computeLinks_1.computeLinks)(model.item, requestOptions);
    // 3. append the template's thumbnail url at the top-level
    template.thumbnailUrl = template.links.thumbnail;
    // 6. process features that can be disabled by the entity owner
    template.features = (0, processEntityFeatures_1.processEntityFeatures)((0, get_prop_1.getProp)(model, "data.settings.features") || {}, TemplateBusinessRules_1.TemplateDefaultFeatures);
    // 7. compute additional template-specific properties
    template.isDeployed = ((0, get_prop_1.getProp)(model, "item.typeKeywords") || []).includes("Deployed");
    template.deployedType = (0, utils_1.getDeployedTemplateType)(model.item);
    // 8. cast b/c this takes a partial but returns a full template
    return template;
}
//# sourceMappingURL=computeProps.js.map