"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.WorldItemInfoGeneratorTest = void 0;
const ProjectInfoItem_1 = require("./ProjectInfoItem");
const IProjectItemData_1 = require("../app/IProjectItemData");
const MCWorld_1 = require("../minecraft/MCWorld");
const Log_1 = require("../core/Log");
const IInfoItemData_1 = require("./IInfoItemData");
const ProjectInfoUtilities_1 = require("./ProjectInfoUtilities");
const MinecraftUtilities_1 = require("../minecraft/MinecraftUtilities");
var WorldItemInfoGeneratorTest;
(function (WorldItemInfoGeneratorTest) {
    WorldItemInfoGeneratorTest[WorldItemInfoGeneratorTest["betaApisExperiment"] = 101] = "betaApisExperiment";
    WorldItemInfoGeneratorTest[WorldItemInfoGeneratorTest["dataDrivenItemsExperiment"] = 102] = "dataDrivenItemsExperiment";
    WorldItemInfoGeneratorTest[WorldItemInfoGeneratorTest["deferredTechnicalPreviewExperiment"] = 103] = "deferredTechnicalPreviewExperiment";
    WorldItemInfoGeneratorTest[WorldItemInfoGeneratorTest["baseGameVersion"] = 107] = "baseGameVersion";
    WorldItemInfoGeneratorTest[WorldItemInfoGeneratorTest["worldName"] = 108] = "worldName";
    WorldItemInfoGeneratorTest[WorldItemInfoGeneratorTest["worldDescription"] = 109] = "worldDescription";
})(WorldItemInfoGeneratorTest = exports.WorldItemInfoGeneratorTest || (exports.WorldItemInfoGeneratorTest = {}));
class WorldItemInfoGenerator {
    id = "WORLD";
    title = "World Validation";
    getTopicData(topicId) {
        return {
            title: topicId.toString(),
        };
    }
    summarize(info, infoSet) {
        info.baseGameVersion = infoSet.getFirstStringValue(this.id, WorldItemInfoGeneratorTest.baseGameVersion);
        info.minBaseGameVersionString = infoSet.getMinNumberArrayValueAsVersionString(this.id, WorldItemInfoGeneratorTest.baseGameVersion);
        info.minBaseGameVersion = MinecraftUtilities_1.default.getVersionNumber(info.minBaseGameVersionString);
    }
    async generate(projectItem) {
        const items = [];
        if (projectItem.itemType === IProjectItemData_1.ProjectItemType.MCWorld ||
            projectItem.itemType === IProjectItemData_1.ProjectItemType.MCTemplate ||
            projectItem.itemType === IProjectItemData_1.ProjectItemType.worldFolder) {
            let mcworld = await MCWorld_1.default.ensureOnItem(projectItem);
            if (!mcworld) {
                Log_1.default.debugAlert("Could not find respective world.");
                return items;
            }
            await mcworld.load(false);
            items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.info, this.id, WorldItemInfoGeneratorTest.betaApisExperiment, ProjectInfoUtilities_1.default.getTitleFromEnum(WorldItemInfoGeneratorTest, WorldItemInfoGeneratorTest.betaApisExperiment), projectItem, mcworld.betaApisExperiment, mcworld.name));
            items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.info, this.id, WorldItemInfoGeneratorTest.dataDrivenItemsExperiment, ProjectInfoUtilities_1.default.getTitleFromEnum(WorldItemInfoGeneratorTest, WorldItemInfoGeneratorTest.dataDrivenItemsExperiment), projectItem, mcworld.dataDrivenItemsExperiment, mcworld.name));
            items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.info, this.id, WorldItemInfoGeneratorTest.deferredTechnicalPreviewExperiment, ProjectInfoUtilities_1.default.getTitleFromEnum(WorldItemInfoGeneratorTest, WorldItemInfoGeneratorTest.deferredTechnicalPreviewExperiment), projectItem, mcworld.deferredTechnicalPreviewExperiment, mcworld.name));
            if (mcworld.manifest && mcworld.manifest.header && mcworld.manifest.header.base_game_version) {
                let val = mcworld.manifest.header.base_game_version;
                if (val.join) {
                    val = val.join(".");
                }
                val = val.toString();
                items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.info, this.id, WorldItemInfoGeneratorTest.baseGameVersion, "Base game version", projectItem, val, mcworld.name));
                items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.info, "WORLD", WorldItemInfoGeneratorTest.worldName, ProjectInfoUtilities_1.default.getTitleFromEnum(WorldItemInfoGeneratorTest, WorldItemInfoGeneratorTest.worldName), projectItem, mcworld.manifest.header.name, mcworld.name));
                items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.info, "WORLD", WorldItemInfoGeneratorTest.worldDescription, ProjectInfoUtilities_1.default.getTitleFromEnum(WorldItemInfoGeneratorTest, WorldItemInfoGeneratorTest.worldDescription), projectItem, mcworld.manifest.header.description, mcworld.name));
            }
        }
        return items;
    }
}
exports.default = WorldItemInfoGenerator;

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