"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const ProjectUtilities_1 = require("../app/ProjectUtilities");
const Utilities_1 = require("../core/Utilities");
const IProjectInfoData_1 = require("./IProjectInfoData");
const ProjectInfoSet_1 = require("./ProjectInfoSet");
class ProjectInfoUtilities {
    static _generalTopicsById = {
        0: "Test Failure",
        1: "Test Success",
        2: "Test Not Applicable",
    };
    static getTitleFromEnum(categoryEnum, topicId) {
        if (categoryEnum[topicId]) {
            return Utilities_1.default.humanifyJsName(categoryEnum[topicId]);
        }
        const generalTitle = this._generalTopicsById[topicId];
        if (!!generalTitle) {
            return generalTitle;
        }
        return "General Item " + topicId;
    }
    static getGeneralTopicTitle(topicId) {
        return this._generalTopicsById[topicId];
    }
    static async getDerivedStates(project, pisData) {
        const isAddon = await ProjectUtilities_1.default.getIsAddon(project);
        const derivedStates = [];
        if (isAddon) {
            const pisAddon = new ProjectInfoSet_1.default(project, IProjectInfoData_1.ProjectInfoSuite.cooperativeAddOn);
            await pisAddon.generateForProject();
            const projectSet = {
                projectContainerName: project.containerName,
                projectPath: project.projectFolder?.storageRelativePath,
                projectName: project.name,
                projectTitle: project.title,
                infoSetData: pisAddon.getDataObject(),
                suite: IProjectInfoData_1.ProjectInfoSuite.cooperativeAddOn,
            };
            derivedStates.push(projectSet);
        }
        const pisSharing = new ProjectInfoSet_1.default(project, IProjectInfoData_1.ProjectInfoSuite.sharing);
        await pisSharing.generateForProject();
        const sharing = {
            projectContainerName: project.containerName,
            projectPath: project.projectFolder?.storageRelativePath,
            projectName: project.name,
            projectTitle: project.title,
            infoSetData: pisSharing.getDataObject(),
            suite: IProjectInfoData_1.ProjectInfoSuite.cooperativeAddOn,
        };
        derivedStates.push(sharing);
        const shouldRunPlatformVersion = pisData.info["CWave"] !== undefined;
        if (shouldRunPlatformVersion) {
            const pisPlatforMVersion = new ProjectInfoSet_1.default(project, IProjectInfoData_1.ProjectInfoSuite.currentPlatformVersions);
            await pisPlatforMVersion.generateForProject();
            const projectSet = {
                projectContainerName: project.containerName,
                projectPath: project.projectFolder?.storageRelativePath,
                projectName: project.name,
                projectTitle: project.title,
                infoSetData: pisPlatforMVersion.getDataObject(),
                suite: IProjectInfoData_1.ProjectInfoSuite.currentPlatformVersions,
            };
            derivedStates.push(projectSet);
        }
        return derivedStates;
    }
}
exports.default = ProjectInfoUtilities;

//# sourceMappingURL=../maps/info/ProjectInfoUtilities.js.map
