"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const IProjectItemData_1 = require("../app/IProjectItemData");
const AnimationBehaviorDefinition_1 = require("./AnimationBehaviorDefinition");
const AnimationControllerBehaviorDefinition_1 = require("./AnimationControllerBehaviorDefinition");
const AnimationControllerResourceDefinition_1 = require("./AnimationControllerResourceDefinition");
const AnimationResourceDefinition_1 = require("./AnimationResourceDefinition");
const BehaviorManifestDefinition_1 = require("./BehaviorManifestDefinition");
const BlockTypeBehaviorDefinition_1 = require("./BlockTypeBehaviorDefinition");
const EntityTypeDefinition_1 = require("./EntityTypeDefinition");
const FlipbookTextureCatalogDefinition_1 = require("./FlipbookTextureCatalogDefinition");
const ItemTypeBehaviorDefinition_1 = require("./ItemTypeBehaviorDefinition");
const ResourceManifestDefinition_1 = require("./ResourceManifestDefinition");
class MinecraftDefinitions {
    static async get(projectItem) {
        if (!projectItem.file || !projectItem.file.content || typeof projectItem.file.content !== "string") {
            return undefined;
        }
        switch (projectItem.itemType) {
            case IProjectItemData_1.ProjectItemType.entityTypeBehavior:
                return await EntityTypeDefinition_1.default.ensureOnFile(projectItem.file);
            case IProjectItemData_1.ProjectItemType.itemTypeBehaviorJson:
                return await ItemTypeBehaviorDefinition_1.default.ensureOnFile(projectItem.file);
            case IProjectItemData_1.ProjectItemType.blockTypeBehavior:
                return await BlockTypeBehaviorDefinition_1.default.ensureOnFile(projectItem.file);
            case IProjectItemData_1.ProjectItemType.flipbookTexturesJson:
                return await FlipbookTextureCatalogDefinition_1.default.ensureOnFile(projectItem.file);
            case IProjectItemData_1.ProjectItemType.behaviorPackManifestJson:
                return await BehaviorManifestDefinition_1.default.ensureOnFile(projectItem.file);
            case IProjectItemData_1.ProjectItemType.resourcePackManifestJson:
                return await ResourceManifestDefinition_1.default.ensureOnFile(projectItem.file);
            case IProjectItemData_1.ProjectItemType.animationControllerBehaviorJson:
                return await AnimationControllerBehaviorDefinition_1.default.ensureOnFile(projectItem.file);
            case IProjectItemData_1.ProjectItemType.animationControllerResourceJson:
                return await AnimationControllerResourceDefinition_1.default.ensureOnFile(projectItem.file);
            case IProjectItemData_1.ProjectItemType.animationBehaviorJson:
                return await AnimationBehaviorDefinition_1.default.ensureOnFile(projectItem.file);
            case IProjectItemData_1.ProjectItemType.animationResourceJson:
                return await AnimationResourceDefinition_1.default.ensureOnFile(projectItem.file);
        }
        return undefined;
    }
    static async formatVersionIsCurrent(projectItem) {
        const def = await MinecraftDefinitions.get(projectItem);
        if (def && def.getFormatVersionIsCurrent) {
            return await def.getFormatVersionIsCurrent();
        }
        return true;
    }
    static async getFormatVersion(projectItem) {
        const def = await MinecraftDefinitions.get(projectItem);
        if (def && def.getFormatVersion) {
            const fv = await def.getFormatVersion();
            if (!(fv instanceof Array)) {
                return undefined;
            }
            return fv;
        }
        return undefined;
    }
}
exports.default = MinecraftDefinitions;

//# sourceMappingURL=../maps/minecraft/MinecraftDefinitions.js.map
