import { processEntityFeatures } from "../../permissions/_internal/processEntityFeatures";
import { InitiativeDefaultFeatures } from "./InitiativeBusinessRules";
import { computeLinks } from "./computeLinks";
import { computeItemProps } from "../../core/_internal/computeItemProps";
import { upgradeCatalogSchema } from "../../search/upgradeCatalogSchema";
import { getItemThumbnailUrl } from "../../resources/get-item-thumbnail-url";
/**
 * Given a model and an Initiative, set various computed properties that can't be directly mapped
 * @private
 * @param model
 * @param initiative
 * @param requestOptions
 * @returns
 */
export function computeProps(model, initiative, requestOptions) {
    var _a, _b;
    let token;
    if (requestOptions.authentication) {
        const session = requestOptions.authentication;
        token = session.token;
    }
    // compute base properties on initiative
    initiative = computeItemProps(model.item, initiative);
    // thumbnail url
    initiative.thumbnailUrl = getItemThumbnailUrl(model.item, requestOptions, token);
    initiative.view = Object.assign(Object.assign({}, model.data.view), { featuredImageUrl: (_a = model.data.view) === null || _a === void 0 ? void 0 : _a.featuredImageUrl });
    // Ensure we have a catalog and that its at the current schema
    initiative.catalog = upgradeCatalogSchema(initiative.catalog || {});
    /**
     * Features that can be disabled by the entity owner
     */
    initiative.features = processEntityFeatures(((_b = model.data.settings) === null || _b === void 0 ? void 0 : _b.features) || {}, InitiativeDefaultFeatures);
    initiative.links = computeLinks(model.item, requestOptions);
    // cast b/c this takes a partial but returns a full object
    return initiative;
}
//# sourceMappingURL=computeProps.js.map