"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.tryEnsureFiles = exports.getMarketContent = exports.getWorldTemplates = exports.getNeighborFiles = exports.findEnsuredFilesOfType = exports.findEnsuredFiles = exports.getEnsuredFileOfType = exports.getEnsuredFile = exports.FormMappings = exports.ProjectItemSortOrder = void 0;
const Utilities_1 = require("../core/Utilities");
const Pack_1 = require("../minecraft/Pack");
const TextureDefinition_1 = require("../minecraft/TextureDefinition");
const StorageUtilities_1 = require("../storage/StorageUtilities");
const IProjectItemData_1 = require("./IProjectItemData");
const ProjectUtilities_1 = require("./ProjectUtilities");
// an attempt to group related things together via sort order. Used in the UI item list
// general order is design stuff, then script & logic, then behavior stuff, then resource stuff, then skin stuff, then world stuff, then misc stuff (e.g., dev things)
exports.ProjectItemSortOrder = [
    // VVV--- design stuff area
    IProjectItemData_1.ProjectItemType.designTexture,
    IProjectItemData_1.ProjectItemType.designPackManifestJson,
    IProjectItemData_1.ProjectItemType.designPackFolder,
    // VVV--- script & logic area
    IProjectItemData_1.ProjectItemType.ts,
    IProjectItemData_1.ProjectItemType.js,
    IProjectItemData_1.ProjectItemType.MCFunction,
    IProjectItemData_1.ProjectItemType.actionSet,
    IProjectItemData_1.ProjectItemType.entityTypeBaseJs,
    IProjectItemData_1.ProjectItemType.entityTypeBaseTs,
    IProjectItemData_1.ProjectItemType.blockTypeBaseJs,
    IProjectItemData_1.ProjectItemType.blockTypeBaseTs,
    IProjectItemData_1.ProjectItemType.catalogIndexJs,
    IProjectItemData_1.ProjectItemType.animationBehaviorJson,
    IProjectItemData_1.ProjectItemType.animationControllerBehaviorJson,
    IProjectItemData_1.ProjectItemType.testJs,
    // VVV--- behavior stuff area
    IProjectItemData_1.ProjectItemType.entityTypeBehavior,
    IProjectItemData_1.ProjectItemType.spawnRuleBehavior,
    IProjectItemData_1.ProjectItemType.spawnGroupJson,
    IProjectItemData_1.ProjectItemType.functionEventJson,
    IProjectItemData_1.ProjectItemType.itemTypeBehavior,
    IProjectItemData_1.ProjectItemType.craftingItemCatalog,
    IProjectItemData_1.ProjectItemType.recipeBehavior,
    IProjectItemData_1.ProjectItemType.blockTypeBehavior,
    IProjectItemData_1.ProjectItemType.blockMaterialsBehaviorJson,
    IProjectItemData_1.ProjectItemType.tradingBehaviorJson,
    IProjectItemData_1.ProjectItemType.volumeBehaviorJson,
    IProjectItemData_1.ProjectItemType.lootTableBehavior,
    IProjectItemData_1.ProjectItemType.dialogueBehaviorJson,
    //      VV-- Worldgen subarea
    IProjectItemData_1.ProjectItemType.featureRuleBehavior,
    IProjectItemData_1.ProjectItemType.featureBehavior,
    IProjectItemData_1.ProjectItemType.jigsawStructureSet,
    IProjectItemData_1.ProjectItemType.jigsawStructure,
    IProjectItemData_1.ProjectItemType.jigsawTemplatePool,
    IProjectItemData_1.ProjectItemType.jigsawProcessorList,
    IProjectItemData_1.ProjectItemType.biomeBehavior,
    IProjectItemData_1.ProjectItemType.dimensionJson,
    //      VV-- Misc uncommon subarea
    IProjectItemData_1.ProjectItemType.tickJson,
    IProjectItemData_1.ProjectItemType.cameraBehaviorJson,
    IProjectItemData_1.ProjectItemType.aimAssistPresetJson,
    IProjectItemData_1.ProjectItemType.aimAssistCategoryJson,
    IProjectItemData_1.ProjectItemType.behaviorTreeJson,
    IProjectItemData_1.ProjectItemType.behaviorPackFolder,
    IProjectItemData_1.ProjectItemType.behaviorPackManifestJson,
    // VVV--- resource stuff area
    IProjectItemData_1.ProjectItemType.entityTypeResource,
    IProjectItemData_1.ProjectItemType.attachableResourceJson,
    IProjectItemData_1.ProjectItemType.itemTypeLegacyResource,
    IProjectItemData_1.ProjectItemType.blocksCatalogResourceJson,
    IProjectItemData_1.ProjectItemType.blockTypeResourceJsonDoNotUse,
    IProjectItemData_1.ProjectItemType.blockCulling,
    IProjectItemData_1.ProjectItemType.terrainTextureCatalogResourceJson,
    IProjectItemData_1.ProjectItemType.particleJson,
    IProjectItemData_1.ProjectItemType.modelGeometryJson,
    IProjectItemData_1.ProjectItemType.itemTextureJson,
    IProjectItemData_1.ProjectItemType.texture,
    IProjectItemData_1.ProjectItemType.textureSetJson,
    IProjectItemData_1.ProjectItemType.animationResourceJson,
    IProjectItemData_1.ProjectItemType.animationControllerResourceJson,
    IProjectItemData_1.ProjectItemType.renderControllerJson,
    IProjectItemData_1.ProjectItemType.flipbookTexturesJson,
    //      VV-- Vibrant visuals subarea
    IProjectItemData_1.ProjectItemType.lightingJson,
    IProjectItemData_1.ProjectItemType.colorGradingJson,
    IProjectItemData_1.ProjectItemType.atmosphericsJson,
    IProjectItemData_1.ProjectItemType.pbrJson,
    IProjectItemData_1.ProjectItemType.pointLightsJson,
    IProjectItemData_1.ProjectItemType.waterJson,
    IProjectItemData_1.ProjectItemType.shadowsJson,
    //      VV-- JSON UI subarea
    IProjectItemData_1.ProjectItemType.uiJson,
    IProjectItemData_1.ProjectItemType.ninesliceJson,
    IProjectItemData_1.ProjectItemType.uiTexture,
    //      VV-- Misc uncommon visual stuff subarea
    IProjectItemData_1.ProjectItemType.cameraResourceJson,
    IProjectItemData_1.ProjectItemType.fogResourceJson,
    IProjectItemData_1.ProjectItemType.biomeResource,
    IProjectItemData_1.ProjectItemType.biomesClientCatalogResource,
    IProjectItemData_1.ProjectItemType.globalVariablesJson,
    IProjectItemData_1.ProjectItemType.sdlLayout,
    IProjectItemData_1.ProjectItemType.lodJson,
    IProjectItemData_1.ProjectItemType.rendererJson,
    IProjectItemData_1.ProjectItemType.loadingMessagesJson,
    IProjectItemData_1.ProjectItemType.fontMetadataJson,
    IProjectItemData_1.ProjectItemType.emoticonsJson,
    IProjectItemData_1.ProjectItemType.splashesJson,
    //      VV-- Sound/audio subarea
    IProjectItemData_1.ProjectItemType.soundCatalog,
    IProjectItemData_1.ProjectItemType.soundDefinitionCatalog,
    IProjectItemData_1.ProjectItemType.musicDefinitionJson,
    IProjectItemData_1.ProjectItemType.audio,
    //      VV-- (legacy) Materials subarea
    IProjectItemData_1.ProjectItemType.materialsResourceJson,
    IProjectItemData_1.ProjectItemType.material,
    IProjectItemData_1.ProjectItemType.materialSetJson,
    IProjectItemData_1.ProjectItemType.materialVertex,
    IProjectItemData_1.ProjectItemType.materialFragment,
    IProjectItemData_1.ProjectItemType.materialGeometry,
    IProjectItemData_1.ProjectItemType.languagesCatalogJson,
    IProjectItemData_1.ProjectItemType.lang,
    IProjectItemData_1.ProjectItemType.resourcePackManifestJson,
    IProjectItemData_1.ProjectItemType.textureListJson,
    IProjectItemData_1.ProjectItemType.fileListArrayJson,
    IProjectItemData_1.ProjectItemType.resourcePackFolder,
    // VVV--- world stuff area
    IProjectItemData_1.ProjectItemType.worldFolder,
    IProjectItemData_1.ProjectItemType.worldTemplateManifestJson,
    IProjectItemData_1.ProjectItemType.levelDat,
    IProjectItemData_1.ProjectItemType.behaviorPackListJson,
    IProjectItemData_1.ProjectItemType.resourcePackListJson,
    IProjectItemData_1.ProjectItemType.behaviorPackHistoryListJson,
    IProjectItemData_1.ProjectItemType.resourcePackHistoryListJson,
    IProjectItemData_1.ProjectItemType.levelDbLdb,
    IProjectItemData_1.ProjectItemType.levelDbLog,
    IProjectItemData_1.ProjectItemType.levelDbCurrent,
    IProjectItemData_1.ProjectItemType.levelDbManifest,
    IProjectItemData_1.ProjectItemType.worldTest,
    IProjectItemData_1.ProjectItemType.MCWorld,
    IProjectItemData_1.ProjectItemType.MCProject,
    IProjectItemData_1.ProjectItemType.MCTemplate,
    // VVV--- skin stuff area
    IProjectItemData_1.ProjectItemType.skinCatalogJson,
    IProjectItemData_1.ProjectItemType.skinPackGeometryJson,
    IProjectItemData_1.ProjectItemType.skinPackTextureBackCompatJson,
    IProjectItemData_1.ProjectItemType.skinPackManifestJson,
    IProjectItemData_1.ProjectItemType.skinPackFolder,
    // VVV--- persona area
    IProjectItemData_1.ProjectItemType.personaJson,
    IProjectItemData_1.ProjectItemType.personaManifestJson,
    IProjectItemData_1.ProjectItemType.personaPackFolder,
    // VVV--- dev stuff area
    IProjectItemData_1.ProjectItemType.tsconfigJson,
    IProjectItemData_1.ProjectItemType.packageJson,
    IProjectItemData_1.ProjectItemType.packageLockJson,
    IProjectItemData_1.ProjectItemType.vsCodeLaunchJson,
    IProjectItemData_1.ProjectItemType.vsCodeTasksJson,
    IProjectItemData_1.ProjectItemType.vsCodeSettingsJson,
    IProjectItemData_1.ProjectItemType.vsCodeExtensionsJson,
    IProjectItemData_1.ProjectItemType.justConfigTs,
    IProjectItemData_1.ProjectItemType.esLintConfigMjs,
    IProjectItemData_1.ProjectItemType.env,
    IProjectItemData_1.ProjectItemType.prettierRcJson,
    IProjectItemData_1.ProjectItemType.buildProcessedJs,
    // VVV--- marketing area
    IProjectItemData_1.ProjectItemType.marketingAssetImage,
    IProjectItemData_1.ProjectItemType.storeAssetImage,
    // VVV--- metaproject
    IProjectItemData_1.ProjectItemType.dataForm,
    IProjectItemData_1.ProjectItemType.docInfoJson,
    IProjectItemData_1.ProjectItemType.scriptTypesJson,
    IProjectItemData_1.ProjectItemType.commandSetDefinitionJson,
    IProjectItemData_1.ProjectItemType.jsconfigJson,
    IProjectItemData_1.ProjectItemType.docfxJson,
    IProjectItemData_1.ProjectItemType.jsdocJson,
    IProjectItemData_1.ProjectItemType.documentedTypeFolder,
    IProjectItemData_1.ProjectItemType.documentedCommandFolder,
    IProjectItemData_1.ProjectItemType.contentIndexJson,
    IProjectItemData_1.ProjectItemType.contentReportJson,
    IProjectItemData_1.ProjectItemType.mcToolsProjectPreferences,
    IProjectItemData_1.ProjectItemType.projectSummaryMetadata,
    IProjectItemData_1.ProjectItemType.engineOrderingJson,
    IProjectItemData_1.ProjectItemType.vanillaDataJson,
    IProjectItemData_1.ProjectItemType.tagsMetadata,
    // VVV--- uncategorized artifacts
    IProjectItemData_1.ProjectItemType.image,
    IProjectItemData_1.ProjectItemType.uniformsJson,
    IProjectItemData_1.ProjectItemType.unknownJson,
    // VVV--- packaging artifacts
    IProjectItemData_1.ProjectItemType.packIconImage,
    IProjectItemData_1.ProjectItemType.educationJson,
    IProjectItemData_1.ProjectItemType.contentsJson,
    IProjectItemData_1.ProjectItemType.MCAddon,
    IProjectItemData_1.ProjectItemType.MCPack,
    IProjectItemData_1.ProjectItemType.zip,
    IProjectItemData_1.ProjectItemType.unknown,
];
exports.FormMappings = {
/*  ["" + ProjectItemType.atmosphericsJson]: {
  formCategory: "client_deferred_rendering",
  formName: "atmosphericscattering_atmosphericscatteringconfigsettings",
  select: "minecraft:atmosphere_settings",
},
["" + ProjectItemType.colorGradingJson]: {
  formCategory: "client_deferred_rendering",
  formName: "colorgraderconfig_colorgradingparameterssrc",
  select: "minecraft:color_grading_settings",
},
["" + ProjectItemType.lightingJson]: {
  formCategory: "client_deferred_rendering",
  formName: "lightinggroup_lightingimpl_1_21_70",
  select: "minecraft:lighting_settings",
},
["" + ProjectItemType.pbrJson]: {
  formCategory: "client_deferred_rendering",
  formName: "pbrfallbackconfig_pbrfallbackconfigsettings",
  select: "minecraft:pbr_fallback_settings",
},
["" + ProjectItemType.waterJson]: {
  formCategory: "client_deferred_rendering",
  formName: "waterconfig_waterconfigsettingsv1",
  select: "minecraft:water_settings",
},
["" + ProjectItemType.shadowsJson]: {
  formCategory: "client_deferred_rendering",
  formName: "shadowstylizationconfig_shadowstylizationconfigsettings",
  select: "minecraft:shadow_settings",
},
["" + ProjectItemType.pointLightsJson]: {
  formCategory: "client_deferred_rendering",
  formName: "pointlightconfig_pointlightconfigsettings",
  select: "minecraft:point_light_settings",
},*/
};
class ProjectItemUtilities {
    static inferTypeFromContent(content, fileName) {
        const type = StorageUtilities_1.default.getTypeFromName(fileName);
        if (typeof content === "string") {
            switch (type) {
                case "json":
                    return ProjectItemUtilities.inferTypeFromJsonContent(content, fileName);
            }
        }
        else {
            switch (type) {
                case "png":
                    return { itemType: IProjectItemData_1.ProjectItemType.texture, packType: Pack_1.PackType.resource, path: "/textures/ " };
            }
        }
        return { itemType: IProjectItemData_1.ProjectItemType.unknown, packType: Pack_1.PackType.behavior, path: "/" };
    }
    static getFormPathForType(itemType) {
        switch (itemType) {
            case IProjectItemData_1.ProjectItemType.entityTypeBehavior:
                return "entity/actor_document";
            case IProjectItemData_1.ProjectItemType.biomeBehavior:
                return "biome/biome_json_file";
            case IProjectItemData_1.ProjectItemType.blockCulling:
                return "block_culling/blockculling";
            case IProjectItemData_1.ProjectItemType.biomesClientCatalogResource:
                return "client_biome/client_biome_json_file";
            case IProjectItemData_1.ProjectItemType.atmosphericsJson:
                return "client_deferred_rendering/atmosphericscattering_atmosphericscatteringconfigsettings";
            case IProjectItemData_1.ProjectItemType.colorGradingJson:
                return "client_deferred_rendering/colorgraderconfig_colorgradingparameterssrc";
            case IProjectItemData_1.ProjectItemType.lightingJson:
                return "client_deferred_rendering/lightinggroup_lightingimpl_1_21_70";
            case IProjectItemData_1.ProjectItemType.pbrJson:
                return "client_deferred_rendering/pbrfallbackconfig_pbrfallbackconfigsettings";
            case IProjectItemData_1.ProjectItemType.pointLightsJson:
                return "client_deferred_rendering/pointlightconfig_pointlightconfigsettings";
            case IProjectItemData_1.ProjectItemType.shadowsJson:
                return "client_deferred_rendering/shadowstylizationconfig_shadowstylizationconfigsettings";
            case IProjectItemData_1.ProjectItemType.waterJson:
                return "client_deferred_rendering/waterconfig_waterconfigsettingsv1";
            case IProjectItemData_1.ProjectItemType.itemTypeLegacyResource:
                return "client_item/resource";
            case IProjectItemData_1.ProjectItemType.featureRuleBehavior:
                return "feature/feature_rule_definition";
            case IProjectItemData_1.ProjectItemType.featureBehavior:
                return "features/features";
            case IProjectItemData_1.ProjectItemType.fogResourceJson:
                return "fogs/fogs";
            case IProjectItemData_1.ProjectItemType.jigsawStructure:
                return "jigsaw/minecraft_jigsaw_structure_metadata";
            case IProjectItemData_1.ProjectItemType.spawnRuleBehavior:
                return "spawn/spawn_rules";
            case IProjectItemData_1.ProjectItemType.modelGeometryJson:
                return "visual/geometry.v1.21.0";
            default:
                return undefined;
        }
    }
    static getSchemaPathForType(itemType) {
        switch (itemType) {
            case IProjectItemData_1.ProjectItemType.behaviorPackManifestJson:
                return "general/manifest.json";
            case IProjectItemData_1.ProjectItemType.behaviorPackListJson:
                return "general/world_x_packs.json";
            case IProjectItemData_1.ProjectItemType.resourcePackListJson:
                return "general/world_x_packs.json";
            case IProjectItemData_1.ProjectItemType.animationControllerBehaviorJson:
                return "behavior/animation_controllers/animation_controller.json";
            case IProjectItemData_1.ProjectItemType.animationBehaviorJson:
                return "behavior/animations/animations.json";
            case IProjectItemData_1.ProjectItemType.blockTypeBehavior:
                return "behavior/blocks/blocks.json";
            case IProjectItemData_1.ProjectItemType.itemTypeBehavior:
                return "behavior/items/items.json";
            case IProjectItemData_1.ProjectItemType.lootTableBehavior:
                return "behavior/loot_tables/loot_tables.json";
            case IProjectItemData_1.ProjectItemType.dialogueBehaviorJson:
                return "behavior/dialogue/dialogue.json";
            case IProjectItemData_1.ProjectItemType.entityTypeBehavior:
                return "behavior/entities/entities.json";
            case IProjectItemData_1.ProjectItemType.atmosphericsJson:
                return "resource/atmospherics/atmospherics.json";
            case IProjectItemData_1.ProjectItemType.blocksCatalogResourceJson:
                return "resource/blocks.json";
            case IProjectItemData_1.ProjectItemType.soundCatalog:
                return "resource/sounds.json";
            case IProjectItemData_1.ProjectItemType.animationResourceJson:
                return "resource/animations/actor_animation.json";
            case IProjectItemData_1.ProjectItemType.animationControllerResourceJson:
                return "resource/animation_controllers/animation_controller.json";
            case IProjectItemData_1.ProjectItemType.entityTypeResource:
                return "resource/entity/entity.json";
            case IProjectItemData_1.ProjectItemType.fogResourceJson:
                return "resource/fog/fog.json";
            case IProjectItemData_1.ProjectItemType.modelGeometryJson:
                return "resource/models/entity/model_entity.json";
            case IProjectItemData_1.ProjectItemType.biomesClientCatalogResource:
                return "resource/biomes_client.json";
            case IProjectItemData_1.ProjectItemType.particleJson:
                return "resource/particles/particles.json";
            case IProjectItemData_1.ProjectItemType.renderControllerJson:
                return "resource/render_controllers/render_controllers.json";
            case IProjectItemData_1.ProjectItemType.blockCulling:
                return "resource/block_culling/block_culling.json";
            case IProjectItemData_1.ProjectItemType.craftingItemCatalog:
                return "behavior/item_catalog/crafting_item_catalog.json";
            //     case ProjectItemType.uiTextureJson:
            //        return "resource/textures/ui_texture_definition.json";
            case IProjectItemData_1.ProjectItemType.languagesCatalogJson:
                return "language/languages.json";
            case IProjectItemData_1.ProjectItemType.featureBehavior:
                return "behavior/features/features.json";
            case IProjectItemData_1.ProjectItemType.featureRuleBehavior:
                return "behavior/feature_rules/feature_rules.json";
            case IProjectItemData_1.ProjectItemType.functionEventJson:
                return "behavior/functions/tick.json";
            case IProjectItemData_1.ProjectItemType.recipeBehavior:
                return "behavior/recipes/recipes.json";
            case IProjectItemData_1.ProjectItemType.spawnRuleBehavior:
                return "behavior/spawn_rules/spawn_rules.json";
            case IProjectItemData_1.ProjectItemType.tradingBehaviorJson:
                return "behavior/trading/trading.json";
            case IProjectItemData_1.ProjectItemType.attachableResourceJson:
                return "resource/attachables/attachables.json";
            case IProjectItemData_1.ProjectItemType.itemTypeLegacyResource:
                return "resource/items/items.json";
            case IProjectItemData_1.ProjectItemType.materialsResourceJson:
                return "resource/materials/materials.json";
            case IProjectItemData_1.ProjectItemType.musicDefinitionJson:
                return "resource/sounds/music_definitions.json";
            case IProjectItemData_1.ProjectItemType.soundDefinitionCatalog:
                return "resource/sounds/sound_definitions.json";
            case IProjectItemData_1.ProjectItemType.blockTypeResourceJsonDoNotUse:
                return "resource/blocks.json";
            case IProjectItemData_1.ProjectItemType.uiJson:
                return "resource/ui/ui.json";
            case IProjectItemData_1.ProjectItemType.tickJson:
                return "behavior/functions/tick.json";
            case IProjectItemData_1.ProjectItemType.flipbookTexturesJson:
                return "resource/textures/flipbook_textures.json";
            case IProjectItemData_1.ProjectItemType.itemTextureJson:
                return "resource/textures/item_texture.json";
            case IProjectItemData_1.ProjectItemType.terrainTextureCatalogResourceJson:
                return "resource/textures/terrain_texture.json";
            case IProjectItemData_1.ProjectItemType.globalVariablesJson:
                return "resource/ui/_global_variables.json";
            default:
                return undefined;
        }
    }
    static inferTypeFromJsonContent(jsonContent, fileName) {
        const fileBaseName = StorageUtilities_1.default.getBaseFromName(fileName);
        if (fileBaseName) {
            if (fileBaseName.endsWith(".mci")) {
                return { itemType: IProjectItemData_1.ProjectItemType.contentIndexJson };
            }
            else if (fileBaseName.endsWith(".mcr")) {
                return { itemType: IProjectItemData_1.ProjectItemType.contentReportJson };
            }
        }
        const firstHundred = jsonContent.substring(0, 100);
        if (firstHundred.indexOf('"minecraft:recipe_shaped"') >= 0 ||
            firstHundred.indexOf('"minecraft:recipe_shapeless"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.recipeBehavior };
        }
        else if (firstHundred.indexOf('"minecraft:entity"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.entityTypeBehavior };
        }
        else if (firstHundred.indexOf('"minecraft:item"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.itemTypeBehavior };
        }
        else if (firstHundred.indexOf('"pools"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.itemTypeBehavior };
        }
        else if (firstHundred.indexOf('"minecraft:spawn_rules"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.spawnRuleBehavior };
        }
        else if (firstHundred.indexOf('"tiers"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.tradingBehaviorJson };
        }
        else if (firstHundred.indexOf('"animation_controllers"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.animationControllerResourceJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"animations"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.animationResourceJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"animations"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.animationResourceJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"minecraft:attachable"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.attachableResourceJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"minecraft:client_entity"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.entityTypeResource, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"minecraft:fog_settings"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.fogResourceJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"minecraft:geometry"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.modelGeometryJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"particle_effect"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.particleJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"render_controllers"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.renderControllerJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"block_culling"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.blockCulling, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"item_catalog"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.craftingItemCatalog, packType: Pack_1.PackType.behavior };
        }
        else if (firstHundred.indexOf('"namespace"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.uiJson, packType: Pack_1.PackType.resource };
        }
        else if (firstHundred.indexOf('"sound_definitions"') >= 0) {
            return { itemType: IProjectItemData_1.ProjectItemType.soundDefinitionCatalog, packType: Pack_1.PackType.resource };
        }
        else if (fileBaseName === "manifest") {
            const jsonO = Utilities_1.default.getJsonObject(jsonContent);
            if (jsonO !== undefined && jsonO["modules"]) {
                for (const mod of jsonO["modules"]) {
                    if (mod && mod["type"]) {
                        switch (mod["type"]) {
                            case "script":
                            case "data":
                                return { itemType: IProjectItemData_1.ProjectItemType.behaviorPackManifestJson };
                            case "resources":
                                return { itemType: IProjectItemData_1.ProjectItemType.resourcePackManifestJson };
                        }
                    }
                }
            }
        }
        return { itemType: IProjectItemData_1.ProjectItemType.unknown };
    }
    static getSortOrder(itemType) {
        for (let i = 0; i < exports.ProjectItemSortOrder.length; i++) {
            if (exports.ProjectItemSortOrder[i] === itemType) {
                return i;
            }
        }
        return exports.ProjectItemSortOrder.length + itemType;
    }
    static getItemByTypeAndName(project, name, projectItemType) {
        const itemsCopy = project.getItemsByType(projectItemType);
        for (const item of itemsCopy) {
            if (item.itemType === projectItemType && (item.name === name || item.name.startsWith(name.toLowerCase() + "."))) {
                return item;
            }
        }
        return undefined;
    }
    static getAccessoryFolderPathFromFilePath(projectItem) {
        let relativePath = projectItem.projectPath;
        if (!relativePath) {
            return projectItem.name + " " + ProjectItemUtilities.getDescriptionForType(projectItem.itemType);
        }
        relativePath = relativePath.replace(/\./gi, "_");
        return relativePath;
    }
    static getCategory(itemType) {
        switch (itemType) {
            case IProjectItemData_1.ProjectItemType.MCFunction:
            case IProjectItemData_1.ProjectItemType.testJs:
            case IProjectItemData_1.ProjectItemType.actionSet:
            case IProjectItemData_1.ProjectItemType.animationBehaviorJson:
            case IProjectItemData_1.ProjectItemType.animationControllerBehaviorJson:
            case IProjectItemData_1.ProjectItemType.tickJson:
            case IProjectItemData_1.ProjectItemType.js:
            case IProjectItemData_1.ProjectItemType.ts:
            case IProjectItemData_1.ProjectItemType.buildProcessedJs:
            case IProjectItemData_1.ProjectItemType.catalogIndexJs:
                return IProjectItemData_1.ProjectItemCategory.logic;
            case IProjectItemData_1.ProjectItemType.image:
            case IProjectItemData_1.ProjectItemType.texture:
            case IProjectItemData_1.ProjectItemType.storeAssetImage:
            case IProjectItemData_1.ProjectItemType.marketingAssetImage:
            case IProjectItemData_1.ProjectItemType.designTexture:
            case IProjectItemData_1.ProjectItemType.uiTexture:
            case IProjectItemData_1.ProjectItemType.packIconImage:
            case IProjectItemData_1.ProjectItemType.soundDefinitionCatalog:
            case IProjectItemData_1.ProjectItemType.soundCatalog:
            case IProjectItemData_1.ProjectItemType.resourcePackManifestJson:
            case IProjectItemData_1.ProjectItemType.resourcePackListJson:
            case IProjectItemData_1.ProjectItemType.renderControllerJson:
            case IProjectItemData_1.ProjectItemType.lightingJson:
            case IProjectItemData_1.ProjectItemType.textureSetJson:
            case IProjectItemData_1.ProjectItemType.modelGeometryJson:
            case IProjectItemData_1.ProjectItemType.material:
            case IProjectItemData_1.ProjectItemType.materialSetJson:
            case IProjectItemData_1.ProjectItemType.animationControllerResourceJson:
            case IProjectItemData_1.ProjectItemType.animationResourceJson:
            case IProjectItemData_1.ProjectItemType.itemTextureJson:
            case IProjectItemData_1.ProjectItemType.flipbookTexturesJson:
            case IProjectItemData_1.ProjectItemType.terrainTextureCatalogResourceJson:
            case IProjectItemData_1.ProjectItemType.globalVariablesJson:
            case IProjectItemData_1.ProjectItemType.uiJson:
            case IProjectItemData_1.ProjectItemType.lang:
            case IProjectItemData_1.ProjectItemType.languagesCatalogJson:
            case IProjectItemData_1.ProjectItemType.ninesliceJson:
            case IProjectItemData_1.ProjectItemType.attachableResourceJson:
            case IProjectItemData_1.ProjectItemType.audio:
            case IProjectItemData_1.ProjectItemType.designPackManifestJson:
            case IProjectItemData_1.ProjectItemType.designPackFolder:
                return IProjectItemData_1.ProjectItemCategory.assets;
            case IProjectItemData_1.ProjectItemType.entityTypeBehavior:
            case IProjectItemData_1.ProjectItemType.entityTypeResource:
            case IProjectItemData_1.ProjectItemType.entityTypeBaseJs:
            case IProjectItemData_1.ProjectItemType.entityTypeBaseTs:
            case IProjectItemData_1.ProjectItemType.blockTypeBehavior:
            case IProjectItemData_1.ProjectItemType.blocksCatalogResourceJson:
            case IProjectItemData_1.ProjectItemType.blockTypeResourceJsonDoNotUse:
            case IProjectItemData_1.ProjectItemType.itemTypeBehavior:
            case IProjectItemData_1.ProjectItemType.fogResourceJson:
            case IProjectItemData_1.ProjectItemType.tradingBehaviorJson:
            case IProjectItemData_1.ProjectItemType.particleJson:
            case IProjectItemData_1.ProjectItemType.structure:
            case IProjectItemData_1.ProjectItemType.recipeBehavior:
            case IProjectItemData_1.ProjectItemType.biomeBehavior:
            case IProjectItemData_1.ProjectItemType.biomeResource:
            case IProjectItemData_1.ProjectItemType.biomesClientCatalogResource:
            case IProjectItemData_1.ProjectItemType.lootTableBehavior:
            case IProjectItemData_1.ProjectItemType.spawnRuleBehavior:
            case IProjectItemData_1.ProjectItemType.dialogueBehaviorJson:
            case IProjectItemData_1.ProjectItemType.MCWorld:
            case IProjectItemData_1.ProjectItemType.worldTemplateManifestJson:
            case IProjectItemData_1.ProjectItemType.itemTypeLegacyResource:
            case IProjectItemData_1.ProjectItemType.featureBehavior:
            case IProjectItemData_1.ProjectItemType.featureRuleBehavior:
                return IProjectItemData_1.ProjectItemCategory.types;
            case IProjectItemData_1.ProjectItemType.esLintConfigMjs:
            case IProjectItemData_1.ProjectItemType.env:
            case IProjectItemData_1.ProjectItemType.justConfigTs:
            case IProjectItemData_1.ProjectItemType.packageLockJson:
            case IProjectItemData_1.ProjectItemType.jsconfigJson:
            case IProjectItemData_1.ProjectItemType.prettierRcJson:
            case IProjectItemData_1.ProjectItemType.tsconfigJson:
            case IProjectItemData_1.ProjectItemType.docfxJson:
            case IProjectItemData_1.ProjectItemType.jsdocJson:
            case IProjectItemData_1.ProjectItemType.vsCodeExtensionsJson:
            case IProjectItemData_1.ProjectItemType.vsCodeLaunchJson:
            case IProjectItemData_1.ProjectItemType.vsCodeSettingsJson:
            case IProjectItemData_1.ProjectItemType.vsCodeTasksJson:
                return IProjectItemData_1.ProjectItemCategory.build;
            case IProjectItemData_1.ProjectItemType.mcToolsProjectPreferences:
                return IProjectItemData_1.ProjectItemCategory.mctools;
            case IProjectItemData_1.ProjectItemType.zip:
            case IProjectItemData_1.ProjectItemType.MCAddon:
            case IProjectItemData_1.ProjectItemType.MCPack:
            case IProjectItemData_1.ProjectItemType.MCTemplate:
            case IProjectItemData_1.ProjectItemType.MCProject:
            case IProjectItemData_1.ProjectItemType.personaPackFolder:
            case IProjectItemData_1.ProjectItemType.behaviorPackFolder:
            case IProjectItemData_1.ProjectItemType.resourcePackFolder:
            case IProjectItemData_1.ProjectItemType.skinPackFolder:
                return IProjectItemData_1.ProjectItemCategory.package;
        }
        return IProjectItemData_1.ProjectItemCategory.unknown;
    }
    static isTextureType(itemType) {
        if (itemType === IProjectItemData_1.ProjectItemType.texture ||
            itemType === IProjectItemData_1.ProjectItemType.designTexture ||
            itemType === IProjectItemData_1.ProjectItemType.uiTexture) {
            return true;
        }
        return false;
    }
    static isImageType(itemType) {
        if (ProjectItemUtilities.isTextureType(itemType) ||
            itemType === IProjectItemData_1.ProjectItemType.image ||
            itemType === IProjectItemData_1.ProjectItemType.storeAssetImage ||
            itemType === IProjectItemData_1.ProjectItemType.marketingAssetImage ||
            itemType === IProjectItemData_1.ProjectItemType.packIconImage) {
            return true;
        }
        return false;
    }
    static isAudioType(itemType) {
        if (itemType === IProjectItemData_1.ProjectItemType.audio) {
            return true;
        }
        return false;
    }
    static isPackageType(itemType) {
        if (itemType === IProjectItemData_1.ProjectItemType.zip ||
            itemType === IProjectItemData_1.ProjectItemType.MCAddon ||
            itemType === IProjectItemData_1.ProjectItemType.MCPack ||
            itemType === IProjectItemData_1.ProjectItemType.MCProject ||
            itemType === IProjectItemData_1.ProjectItemType.MCWorld ||
            itemType === IProjectItemData_1.ProjectItemType.MCTemplate) {
            return true;
        }
        return false;
    }
    static isBinaryType(itemType) {
        if (this.isImageType(itemType) || this.isPackageType(itemType) || this.isAudioType(itemType)) {
            return true;
        }
        return false;
    }
    static isVibrantVisualsTypeRelated(itemType) {
        if (itemType === IProjectItemData_1.ProjectItemType.atmosphericsJson ||
            itemType === IProjectItemData_1.ProjectItemType.colorGradingJson ||
            itemType === IProjectItemData_1.ProjectItemType.lightingJson ||
            itemType === IProjectItemData_1.ProjectItemType.shadowsJson ||
            itemType === IProjectItemData_1.ProjectItemType.pbrJson ||
            itemType === IProjectItemData_1.ProjectItemType.pointLightsJson ||
            itemType === IProjectItemData_1.ProjectItemType.waterJson ||
            itemType ===
                IProjectItemData_1.ProjectItemType.textureSetJson /* not 100% sure there might not be some legit usages of this outside of VV */) {
            return true;
        }
        return false;
    }
    static isVibrantVisualsRelated(item) {
        if (this.isVibrantVisualsTypeRelated(item.itemType)) {
            return true;
        }
        if (item.itemType === IProjectItemData_1.ProjectItemType.texture) {
            const fileName = item.name.toLowerCase();
            for (const ext of TextureDefinition_1.VibrantVisualsFileExtensionVariants) {
                if (fileName.endsWith(ext)) {
                    return true;
                }
            }
        }
        return false;
    }
    static getMimeTypes(item) {
        switch (item.itemType) {
            case IProjectItemData_1.ProjectItemType.js:
            case IProjectItemData_1.ProjectItemType.testJs:
            case IProjectItemData_1.ProjectItemType.entityTypeBaseJs:
            case IProjectItemData_1.ProjectItemType.buildProcessedJs:
            case IProjectItemData_1.ProjectItemType.catalogIndexJs:
            case IProjectItemData_1.ProjectItemType.entityTypeBaseTs:
            case IProjectItemData_1.ProjectItemType.esLintConfigMjs:
            case IProjectItemData_1.ProjectItemType.blockTypeBaseJs:
                return ["application/javascript"];
            case IProjectItemData_1.ProjectItemType.justConfigTs:
            case IProjectItemData_1.ProjectItemType.ts:
            case IProjectItemData_1.ProjectItemType.blockTypeBaseTs:
                return ["application/typescript"];
            case IProjectItemData_1.ProjectItemType.personaJson:
            case IProjectItemData_1.ProjectItemType.tsconfigJson:
            case IProjectItemData_1.ProjectItemType.prettierRcJson:
            case IProjectItemData_1.ProjectItemType.jsconfigJson:
            case IProjectItemData_1.ProjectItemType.docfxJson:
            case IProjectItemData_1.ProjectItemType.jsdocJson:
            case IProjectItemData_1.ProjectItemType.packageJson:
            case IProjectItemData_1.ProjectItemType.packageLockJson:
            case IProjectItemData_1.ProjectItemType.docInfoJson:
            case IProjectItemData_1.ProjectItemType.scriptTypesJson:
            case IProjectItemData_1.ProjectItemType.vanillaDataJson:
            case IProjectItemData_1.ProjectItemType.engineOrderingJson:
            case IProjectItemData_1.ProjectItemType.commandSetDefinitionJson:
            case IProjectItemData_1.ProjectItemType.skinPackManifestJson:
            case IProjectItemData_1.ProjectItemType.blockCulling:
            case IProjectItemData_1.ProjectItemType.craftingItemCatalog:
            case IProjectItemData_1.ProjectItemType.personaManifestJson:
            case IProjectItemData_1.ProjectItemType.vsCodeLaunchJson:
            case IProjectItemData_1.ProjectItemType.vsCodeTasksJson:
            case IProjectItemData_1.ProjectItemType.vsCodeSettingsJson:
            case IProjectItemData_1.ProjectItemType.vsCodeExtensionsJson:
            case IProjectItemData_1.ProjectItemType.designPackManifestJson:
            case IProjectItemData_1.ProjectItemType.sdlLayout:
            case IProjectItemData_1.ProjectItemType.splashesJson:
            case IProjectItemData_1.ProjectItemType.loadingMessagesJson:
            case IProjectItemData_1.ProjectItemType.fontMetadataJson:
            case IProjectItemData_1.ProjectItemType.emoticonsJson:
            case IProjectItemData_1.ProjectItemType.unknownJson:
            case IProjectItemData_1.ProjectItemType.behaviorPackManifestJson:
            case IProjectItemData_1.ProjectItemType.resourcePackManifestJson:
            case IProjectItemData_1.ProjectItemType.entityTypeBehavior:
            case IProjectItemData_1.ProjectItemType.tickJson:
            case IProjectItemData_1.ProjectItemType.aimAssistPresetJson:
            case IProjectItemData_1.ProjectItemType.waterJson:
            case IProjectItemData_1.ProjectItemType.shadowsJson:
            case IProjectItemData_1.ProjectItemType.pbrJson:
            case IProjectItemData_1.ProjectItemType.atmosphericsJson:
            case IProjectItemData_1.ProjectItemType.pointLightsJson:
            case IProjectItemData_1.ProjectItemType.colorGradingJson:
            case IProjectItemData_1.ProjectItemType.cameraBehaviorJson:
            case IProjectItemData_1.ProjectItemType.actionSet:
            case IProjectItemData_1.ProjectItemType.worldTest:
            case IProjectItemData_1.ProjectItemType.behaviorPackListJson:
            case IProjectItemData_1.ProjectItemType.resourcePackListJson:
            case IProjectItemData_1.ProjectItemType.animationBehaviorJson:
            case IProjectItemData_1.ProjectItemType.animationControllerBehaviorJson:
            case IProjectItemData_1.ProjectItemType.blockTypeBehavior:
            case IProjectItemData_1.ProjectItemType.blockMaterialsBehaviorJson:
            case IProjectItemData_1.ProjectItemType.itemTypeBehavior:
            case IProjectItemData_1.ProjectItemType.lootTableBehavior:
            case IProjectItemData_1.ProjectItemType.biomesClientCatalogResource:
            case IProjectItemData_1.ProjectItemType.fileListArrayJson:
            case IProjectItemData_1.ProjectItemType.blocksCatalogResourceJson:
            case IProjectItemData_1.ProjectItemType.soundCatalog:
            case IProjectItemData_1.ProjectItemType.animationResourceJson:
            case IProjectItemData_1.ProjectItemType.animationControllerResourceJson:
            case IProjectItemData_1.ProjectItemType.entityTypeResource:
            case IProjectItemData_1.ProjectItemType.fogResourceJson:
            case IProjectItemData_1.ProjectItemType.modelGeometryJson:
            case IProjectItemData_1.ProjectItemType.particleJson:
            case IProjectItemData_1.ProjectItemType.renderControllerJson:
            case IProjectItemData_1.ProjectItemType.ninesliceJson:
            case IProjectItemData_1.ProjectItemType.uiJson:
            case IProjectItemData_1.ProjectItemType.languagesCatalogJson:
            case IProjectItemData_1.ProjectItemType.biomeBehavior:
            case IProjectItemData_1.ProjectItemType.biomeResource:
            case IProjectItemData_1.ProjectItemType.dialogueBehaviorJson:
            case IProjectItemData_1.ProjectItemType.featureRuleBehavior:
            case IProjectItemData_1.ProjectItemType.featureBehavior:
            case IProjectItemData_1.ProjectItemType.functionEventJson:
            case IProjectItemData_1.ProjectItemType.recipeBehavior:
            case IProjectItemData_1.ProjectItemType.spawnRuleBehavior:
            case IProjectItemData_1.ProjectItemType.tradingBehaviorJson:
            case IProjectItemData_1.ProjectItemType.volumeBehaviorJson:
            case IProjectItemData_1.ProjectItemType.attachableResourceJson:
            case IProjectItemData_1.ProjectItemType.itemTypeLegacyResource:
            case IProjectItemData_1.ProjectItemType.materialsResourceJson:
            case IProjectItemData_1.ProjectItemType.musicDefinitionJson:
            case IProjectItemData_1.ProjectItemType.soundDefinitionCatalog:
            case IProjectItemData_1.ProjectItemType.contentIndexJson:
            case IProjectItemData_1.ProjectItemType.contentReportJson:
            case IProjectItemData_1.ProjectItemType.worldTemplateManifestJson:
            case IProjectItemData_1.ProjectItemType.textureSetJson:
            case IProjectItemData_1.ProjectItemType.textureListJson:
            case IProjectItemData_1.ProjectItemType.lightingJson:
            case IProjectItemData_1.ProjectItemType.flipbookTexturesJson:
            case IProjectItemData_1.ProjectItemType.itemTextureJson:
            case IProjectItemData_1.ProjectItemType.terrainTextureCatalogResourceJson:
            case IProjectItemData_1.ProjectItemType.globalVariablesJson:
            case IProjectItemData_1.ProjectItemType.dataForm:
            case IProjectItemData_1.ProjectItemType.mcToolsProjectPreferences:
            case IProjectItemData_1.ProjectItemType.dimensionJson:
            case IProjectItemData_1.ProjectItemType.behaviorPackHistoryListJson:
            case IProjectItemData_1.ProjectItemType.resourcePackHistoryListJson:
            case IProjectItemData_1.ProjectItemType.contentsJson:
            case IProjectItemData_1.ProjectItemType.jigsawProcessorList:
            case IProjectItemData_1.ProjectItemType.jigsawStructure:
            case IProjectItemData_1.ProjectItemType.jigsawTemplatePool:
            case IProjectItemData_1.ProjectItemType.jigsawStructureSet:
            case IProjectItemData_1.ProjectItemType.educationJson:
                return ["application/json"];
            case IProjectItemData_1.ProjectItemType.MCWorld:
            case IProjectItemData_1.ProjectItemType.MCTemplate:
            case IProjectItemData_1.ProjectItemType.MCProject:
            case IProjectItemData_1.ProjectItemType.MCAddon:
            case IProjectItemData_1.ProjectItemType.MCPack:
            case IProjectItemData_1.ProjectItemType.zip:
                return ["application/zip"];
            case IProjectItemData_1.ProjectItemType.structure:
                return ["application/octet-stream"];
            case IProjectItemData_1.ProjectItemType.MCFunction:
            case IProjectItemData_1.ProjectItemType.material:
            case IProjectItemData_1.ProjectItemType.materialGeometry:
            case IProjectItemData_1.ProjectItemType.materialFragment:
            case IProjectItemData_1.ProjectItemType.materialSetJson:
            case IProjectItemData_1.ProjectItemType.materialVertex:
            case IProjectItemData_1.ProjectItemType.env:
            case IProjectItemData_1.ProjectItemType.lang:
                return ["text/plain"];
            case IProjectItemData_1.ProjectItemType.audio:
                return ["audio/wav", "audio/mp3", "audio/ogg"];
            case IProjectItemData_1.ProjectItemType.image:
            case IProjectItemData_1.ProjectItemType.texture:
            case IProjectItemData_1.ProjectItemType.uiTexture:
            case IProjectItemData_1.ProjectItemType.designTexture:
            case IProjectItemData_1.ProjectItemType.packIconImage:
            case IProjectItemData_1.ProjectItemType.marketingAssetImage:
            case IProjectItemData_1.ProjectItemType.storeAssetImage:
                return ["image/png", "image/tiff"];
            default:
                return ["application/octet-stream"];
        }
    }
    static getDescriptionForType(type) {
        switch (type) {
            case IProjectItemData_1.ProjectItemType.skinCatalogJson:
                return "Skins Catalog";
            case IProjectItemData_1.ProjectItemType.personaJson:
                return "Persona";
            case IProjectItemData_1.ProjectItemType.sdlLayout:
                return "SDL Layout";
            case IProjectItemData_1.ProjectItemType.rendererJson:
                return "Renderer";
            case IProjectItemData_1.ProjectItemType.splashesJson:
                return "Splashes";
            case IProjectItemData_1.ProjectItemType.loadingMessagesJson:
                return "Loading Messages";
            case IProjectItemData_1.ProjectItemType.fontMetadataJson:
                return "Font Metadata";
            case IProjectItemData_1.ProjectItemType.emoticonsJson:
                return "Emoticons";
            case IProjectItemData_1.ProjectItemType.js:
                return "JavaScript";
            case IProjectItemData_1.ProjectItemType.buildProcessedJs:
                return "Built JavaScript";
            case IProjectItemData_1.ProjectItemType.ts:
                return "TypeScript";
            case IProjectItemData_1.ProjectItemType.unknownJson:
                return "General json file";
            case IProjectItemData_1.ProjectItemType.designPackManifestJson:
                return "Design pack manifest";
            case IProjectItemData_1.ProjectItemType.behaviorPackManifestJson:
                return "Behavior pack manifest";
            case IProjectItemData_1.ProjectItemType.resourcePackManifestJson:
                return "Resource pack manifest";
            case IProjectItemData_1.ProjectItemType.testJs:
                return "Test JavaScript file";
            case IProjectItemData_1.ProjectItemType.entityTypeBaseJs:
                return "Entity type JavaScript";
            case IProjectItemData_1.ProjectItemType.entityTypeBaseTs:
                return "Entity type TypeScript";
            case IProjectItemData_1.ProjectItemType.entityTypeBehavior:
                return "Entity type";
            case IProjectItemData_1.ProjectItemType.MCTemplate:
                return "Minecraft template";
            case IProjectItemData_1.ProjectItemType.MCWorld:
                return "Minecraft world";
            case IProjectItemData_1.ProjectItemType.MCProject:
                return "Minecraft project";
            case IProjectItemData_1.ProjectItemType.MCAddon:
                return "Minecraft addon";
            case IProjectItemData_1.ProjectItemType.MCPack:
                return "Minecraft pack";
            case IProjectItemData_1.ProjectItemType.zip:
                return "Minecraft zip";
            case IProjectItemData_1.ProjectItemType.worldFolder:
                return "Minecraft world";
            case IProjectItemData_1.ProjectItemType.structure:
                return "Structure";
            case IProjectItemData_1.ProjectItemType.MCFunction:
                return "Function";
            case IProjectItemData_1.ProjectItemType.tickJson:
                return "Tick";
            case IProjectItemData_1.ProjectItemType.material:
                return "Material";
            case IProjectItemData_1.ProjectItemType.materialSetJson:
                return "Material Set";
            case IProjectItemData_1.ProjectItemType.materialGeometry:
                return "Geometry";
            case IProjectItemData_1.ProjectItemType.materialFragment:
                return "Fragment";
            case IProjectItemData_1.ProjectItemType.materialVertex:
                return "Vertex";
            case IProjectItemData_1.ProjectItemType.shadowsJson:
                return "Shadow";
            case IProjectItemData_1.ProjectItemType.waterJson:
                return "Water";
            case IProjectItemData_1.ProjectItemType.jigsawProcessorList:
                return "Jigsaw Processor List";
            case IProjectItemData_1.ProjectItemType.jigsawStructure:
                return "Jigsaw Structure";
            case IProjectItemData_1.ProjectItemType.jigsawTemplatePool:
                return "Jigsaw Template Pool";
            case IProjectItemData_1.ProjectItemType.contentsJson:
                return "Contents Catalog";
            case IProjectItemData_1.ProjectItemType.jigsawStructureSet:
                return "Jigsaw Structure Set";
            case IProjectItemData_1.ProjectItemType.pbrJson:
                return "PBR";
            case IProjectItemData_1.ProjectItemType.atmosphericsJson:
                return "Atmospherics";
            case IProjectItemData_1.ProjectItemType.pointLightsJson:
                return "Point Light";
            case IProjectItemData_1.ProjectItemType.colorGradingJson:
                return "Color Grading";
            case IProjectItemData_1.ProjectItemType.cameraBehaviorJson:
                return "Camera";
            case IProjectItemData_1.ProjectItemType.aimAssistPresetJson:
                return "Aim Assist Preset";
            case IProjectItemData_1.ProjectItemType.aimAssistCategoryJson:
                return "Aim Assist Category";
            case IProjectItemData_1.ProjectItemType.behaviorTreeJson:
                return "Behavior Tree";
            case IProjectItemData_1.ProjectItemType.spawnGroupJson:
                return "Spawn Group";
            case IProjectItemData_1.ProjectItemType.catalogIndexJs:
                return "Catalog index";
            case IProjectItemData_1.ProjectItemType.personaPackFolder:
                return "Persona pack";
            case IProjectItemData_1.ProjectItemType.designPackFolder:
                return "Design pack";
            case IProjectItemData_1.ProjectItemType.behaviorPackFolder:
                return "Behavior pack";
            case IProjectItemData_1.ProjectItemType.resourcePackFolder:
                return "Resource pack";
            case IProjectItemData_1.ProjectItemType.skinPackFolder:
                return "Skin pack";
            case IProjectItemData_1.ProjectItemType.actionSet:
                return "Action Set";
            case IProjectItemData_1.ProjectItemType.worldTest:
                return "World test";
            case IProjectItemData_1.ProjectItemType.behaviorPackListJson:
                return "World behavior pack list";
            case IProjectItemData_1.ProjectItemType.resourcePackListJson:
                return "World resource pack list";
            case IProjectItemData_1.ProjectItemType.animationBehaviorJson:
                return "Behavior pack animation";
            case IProjectItemData_1.ProjectItemType.animationControllerBehaviorJson:
                return "Behavior pack animation controller";
            case IProjectItemData_1.ProjectItemType.blockTypeBehavior:
                return "Block type";
            case IProjectItemData_1.ProjectItemType.itemTypeBehavior:
                return "Item type";
            case IProjectItemData_1.ProjectItemType.lootTableBehavior:
                return "Loot table";
            case IProjectItemData_1.ProjectItemType.biomesClientCatalogResource:
                return "Biome resources";
            case IProjectItemData_1.ProjectItemType.fileListArrayJson:
                return "File list";
            case IProjectItemData_1.ProjectItemType.craftingItemCatalog:
                return "Crafting Item catalog";
            case IProjectItemData_1.ProjectItemType.blocksCatalogResourceJson:
                return "Block resource catalog";
            case IProjectItemData_1.ProjectItemType.soundCatalog:
                return "Sound catalog";
            case IProjectItemData_1.ProjectItemType.animationResourceJson:
                return "Animation";
            case IProjectItemData_1.ProjectItemType.animationControllerResourceJson:
                return "Animation controller";
            case IProjectItemData_1.ProjectItemType.entityTypeResource:
                return "Entity type visuals/audio";
            case IProjectItemData_1.ProjectItemType.fogResourceJson:
                return "Fog";
            case IProjectItemData_1.ProjectItemType.modelGeometryJson:
                return "Model";
            case IProjectItemData_1.ProjectItemType.particleJson:
                return "Particle";
            case IProjectItemData_1.ProjectItemType.renderControllerJson:
                return "Render controller";
            case IProjectItemData_1.ProjectItemType.blockCulling:
                return "Block culling";
            case IProjectItemData_1.ProjectItemType.uiJson:
                return "User interface";
            case IProjectItemData_1.ProjectItemType.languagesCatalogJson:
                return "Language catalog";
            case IProjectItemData_1.ProjectItemType.biomeBehavior:
                return "Biome";
            case IProjectItemData_1.ProjectItemType.biomeResource:
                return "Biome Resources";
            case IProjectItemData_1.ProjectItemType.dialogueBehaviorJson:
                return "Entity dialogue";
            case IProjectItemData_1.ProjectItemType.featureRuleBehavior:
                return "World feature rule";
            case IProjectItemData_1.ProjectItemType.featureBehavior:
                return "Feature";
            case IProjectItemData_1.ProjectItemType.functionEventJson:
                return "Function event";
            case IProjectItemData_1.ProjectItemType.recipeBehavior:
                return "Recipe";
            case IProjectItemData_1.ProjectItemType.spawnRuleBehavior:
                return "Spawn rule";
            case IProjectItemData_1.ProjectItemType.tradingBehaviorJson:
                return "Trading";
            case IProjectItemData_1.ProjectItemType.volumeBehaviorJson:
                return "Volume";
            case IProjectItemData_1.ProjectItemType.attachableResourceJson:
                return "Attachable";
            case IProjectItemData_1.ProjectItemType.itemTypeLegacyResource:
                return "Item type resources";
            case IProjectItemData_1.ProjectItemType.materialsResourceJson:
                return "Materials";
            case IProjectItemData_1.ProjectItemType.musicDefinitionJson:
                return "Music catalog";
            case IProjectItemData_1.ProjectItemType.soundDefinitionCatalog:
                return "Sound catalog";
            case IProjectItemData_1.ProjectItemType.audio:
                return "Audio";
            case IProjectItemData_1.ProjectItemType.contentIndexJson:
                return "Content Description";
            case IProjectItemData_1.ProjectItemType.contentReportJson:
                return "Content Report";
            case IProjectItemData_1.ProjectItemType.tsconfigJson:
                return "TypeScript config";
            case IProjectItemData_1.ProjectItemType.prettierRcJson:
                return "Prettier JavaScript/JSON style config";
            case IProjectItemData_1.ProjectItemType.jsconfigJson:
                return "JavaScript config";
            case IProjectItemData_1.ProjectItemType.docfxJson:
                return "DocFX definition";
            case IProjectItemData_1.ProjectItemType.jsdocJson:
                return "JSDoc definition";
            case IProjectItemData_1.ProjectItemType.packageJson:
                return "NPM package definition";
            case IProjectItemData_1.ProjectItemType.packageLockJson:
                return "NPM package lock definition";
            case IProjectItemData_1.ProjectItemType.env:
                return "Environment File";
            case IProjectItemData_1.ProjectItemType.esLintConfigMjs:
                return "ESLint config";
            case IProjectItemData_1.ProjectItemType.justConfigTs:
                return "Just config";
            case IProjectItemData_1.ProjectItemType.docInfoJson:
                return "Doc info json";
            case IProjectItemData_1.ProjectItemType.ninesliceJson:
                return "Nine-slice scaling config";
            case IProjectItemData_1.ProjectItemType.scriptTypesJson:
                return "Script types definition";
            case IProjectItemData_1.ProjectItemType.vanillaDataJson:
                return "Vanilla data definition";
            case IProjectItemData_1.ProjectItemType.engineOrderingJson:
                return "Engine ordering definition";
            case IProjectItemData_1.ProjectItemType.commandSetDefinitionJson:
                return "Command definition";
            case IProjectItemData_1.ProjectItemType.skinPackManifestJson:
                return "Skin pack manifest";
            case IProjectItemData_1.ProjectItemType.personaManifestJson:
                return "Persona manifest";
            case IProjectItemData_1.ProjectItemType.blockTypeBaseJs:
                return "Block type base JavaScript";
            case IProjectItemData_1.ProjectItemType.blockTypeBaseTs:
                return "Block type base TypeScript";
            case IProjectItemData_1.ProjectItemType.image:
                return "Image";
            case IProjectItemData_1.ProjectItemType.texture:
                return "Texture";
            case IProjectItemData_1.ProjectItemType.uiTexture:
                return "UI texture";
            case IProjectItemData_1.ProjectItemType.designTexture:
                return "Design texture";
            case IProjectItemData_1.ProjectItemType.packIconImage:
                return "Icon";
            case IProjectItemData_1.ProjectItemType.marketingAssetImage:
                return "Marketing image";
            case IProjectItemData_1.ProjectItemType.storeAssetImage:
                return "Store image";
            case IProjectItemData_1.ProjectItemType.vsCodeLaunchJson:
                return "VS Code launch file";
            case IProjectItemData_1.ProjectItemType.vsCodeTasksJson:
                return "VS Code tasks";
            case IProjectItemData_1.ProjectItemType.vsCodeSettingsJson:
                return "VS Code settings";
            case IProjectItemData_1.ProjectItemType.vsCodeExtensionsJson:
                return "VS Code extensions";
            case IProjectItemData_1.ProjectItemType.lang:
                return "Language translations";
            case IProjectItemData_1.ProjectItemType.worldTemplateManifestJson:
                return "World template manifest";
            case IProjectItemData_1.ProjectItemType.textureSetJson:
                return "Texture set";
            case IProjectItemData_1.ProjectItemType.textureListJson:
                return "Texture list";
            case IProjectItemData_1.ProjectItemType.lightingJson:
                return "Lighting";
            case IProjectItemData_1.ProjectItemType.flipbookTexturesJson:
                return "Flipbook texture set";
            case IProjectItemData_1.ProjectItemType.itemTextureJson:
                return "Item texture";
            case IProjectItemData_1.ProjectItemType.terrainTextureCatalogResourceJson:
                return "Terrain texture";
            case IProjectItemData_1.ProjectItemType.globalVariablesJson:
                return "UI global variables";
            case IProjectItemData_1.ProjectItemType.dataForm:
                return "Form";
            case IProjectItemData_1.ProjectItemType.dimensionJson:
                return "Dimension";
            case IProjectItemData_1.ProjectItemType.mcToolsProjectPreferences:
                return "MCTools preferences";
            case IProjectItemData_1.ProjectItemType.behaviorPackHistoryListJson:
                return "Behavior pack history";
            case IProjectItemData_1.ProjectItemType.resourcePackHistoryListJson:
                return "Resource pack history";
            case IProjectItemData_1.ProjectItemType.educationJson:
                return "Education manifest";
            default:
                return "Unknown";
        }
    }
    static wouldBeCircular(candidate, considering, visitedPaths, dontGoUpward, dontGoDownward) {
        if (!visitedPaths) {
            visitedPaths = new Set();
        }
        if (!candidate.projectPath) {
            return false;
        }
        if (!considering) {
            considering = candidate;
        }
        if (considering.projectPath) {
            if (visitedPaths.has(considering.projectPath)) {
                return true;
            }
            visitedPaths.add(considering.projectPath);
        }
        else {
            return false;
        }
        if (considering.parentItems && !dontGoUpward) {
            for (const parentItem of considering.parentItems) {
                if (parentItem.parentItem) {
                    if (this.wouldBeCircular(candidate, parentItem.parentItem, visitedPaths, false, true)) {
                        return true;
                    }
                }
            }
        }
        if (considering.childItems && !dontGoDownward) {
            for (const childItem of considering.childItems) {
                if (childItem.childItem) {
                    if (this.wouldBeCircular(candidate, childItem.childItem, visitedPaths, true, false)) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
    static isBlock(type) {
        return (type === IProjectItemData_1.ProjectItemType.blockCulling ||
            type === IProjectItemData_1.ProjectItemType.terrainTextureCatalogResourceJson ||
            type === IProjectItemData_1.ProjectItemType.blockTypeBehavior ||
            type === IProjectItemData_1.ProjectItemType.blocksCatalogResourceJson ||
            type === IProjectItemData_1.ProjectItemType.blockMaterialsBehaviorJson);
    }
    static isBlockRelated(projectItem, dontGoUpward, dontGoDownward) {
        if (projectItem.parentItems && !dontGoUpward) {
            for (const parentItem of projectItem.parentItems) {
                if (parentItem.parentItem) {
                    if (this.isBlock(parentItem.parentItem.itemType)) {
                        return true;
                    }
                    if (this.isBlockRelated(parentItem.parentItem, false, true)) {
                        return true;
                    }
                }
            }
        }
        if (projectItem.childItems && !dontGoDownward) {
            for (const parentItem of projectItem.childItems) {
                if (parentItem.childItem) {
                    if (this.isBlock(parentItem.childItem.itemType)) {
                        return true;
                    }
                    if (this.isBlockRelated(parentItem.childItem, true, false)) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
    static isUI(type) {
        return type === IProjectItemData_1.ProjectItemType.uiJson || type === IProjectItemData_1.ProjectItemType.uiTexture;
    }
    static isUIRelated(projectItem, goUpwardOnly, goDownwardOnly) {
        if (projectItem.parentItems && (goUpwardOnly || goUpwardOnly === undefined)) {
            for (const parentItem of projectItem.parentItems) {
                if (parentItem.parentItem) {
                    if (this.isUI(parentItem.parentItem.itemType)) {
                        return true;
                    }
                    if (this.isUIRelated(parentItem.parentItem, true, false)) {
                        return true;
                    }
                }
            }
        }
        if (projectItem.childItems && (goDownwardOnly || goDownwardOnly === undefined)) {
            for (const childItem of projectItem.childItems) {
                if (childItem.childItem) {
                    if (this.isUI(childItem.childItem.itemType)) {
                        return true;
                    }
                    if (this.isUIRelated(childItem.childItem, false, true)) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
    static isBehaviorRelated(itemType) {
        if (itemType === IProjectItemData_1.ProjectItemType.spawnRuleBehavior ||
            itemType === IProjectItemData_1.ProjectItemType.lootTableBehavior ||
            itemType === IProjectItemData_1.ProjectItemType.recipeBehavior ||
            itemType === IProjectItemData_1.ProjectItemType.biomeBehavior ||
            itemType === IProjectItemData_1.ProjectItemType.featureBehavior ||
            itemType === IProjectItemData_1.ProjectItemType.featureRuleBehavior ||
            itemType === IProjectItemData_1.ProjectItemType.jigsawProcessorList ||
            itemType === IProjectItemData_1.ProjectItemType.jigsawStructure ||
            itemType === IProjectItemData_1.ProjectItemType.jigsawStructureSet ||
            itemType === IProjectItemData_1.ProjectItemType.jigsawTemplatePool) {
            return true;
        }
        return false;
    }
    static getRootAncestorItems(item, ancestorList) {
        if (ancestorList === undefined) {
            ancestorList = [];
        }
        if (item.parentItems) {
            for (const parentItem of item.parentItems) {
                if (parentItem.parentItem) {
                    this.getRootAncestorItems(parentItem.parentItem, ancestorList);
                }
            }
        }
        else {
            ancestorList.push(item);
        }
        return ancestorList;
    }
    static getRelationshipDescription(itemRel) {
        if (!itemRel.parentItem || !itemRel.childItem) {
            return undefined;
        }
        if (itemRel.parentItem.itemType === IProjectItemData_1.ProjectItemType.entityTypeBehavior &&
            itemRel.childItem.itemType === IProjectItemData_1.ProjectItemType.entityTypeResource) {
            return StorageUtilities_1.default.getBaseFromName(itemRel.parentItem.name) + " visuals/audio";
        }
        return undefined;
    }
    static isDesignRelated(itemType) {
        if (itemType === IProjectItemData_1.ProjectItemType.designTexture ||
            itemType === IProjectItemData_1.ProjectItemType.designPackFolder ||
            itemType === IProjectItemData_1.ProjectItemType.actionSet ||
            itemType === IProjectItemData_1.ProjectItemType.designPackManifestJson) {
            return true;
        }
        return false;
    }
    static isResourceRelated(itemType) {
        if (ProjectItemUtilities.isVibrantVisualsTypeRelated(itemType)) {
            return true;
        }
        if (itemType === IProjectItemData_1.ProjectItemType.attachableResourceJson ||
            itemType === IProjectItemData_1.ProjectItemType.animationControllerResourceJson ||
            itemType === IProjectItemData_1.ProjectItemType.animationResourceJson ||
            itemType === IProjectItemData_1.ProjectItemType.entityTypeResource ||
            itemType === IProjectItemData_1.ProjectItemType.renderControllerJson ||
            itemType === IProjectItemData_1.ProjectItemType.modelGeometryJson ||
            itemType === IProjectItemData_1.ProjectItemType.biomeResource ||
            itemType === IProjectItemData_1.ProjectItemType.biomesClientCatalogResource ||
            itemType === IProjectItemData_1.ProjectItemType.texture ||
            itemType === IProjectItemData_1.ProjectItemType.uiJson ||
            itemType === IProjectItemData_1.ProjectItemType.uiTexture ||
            itemType === IProjectItemData_1.ProjectItemType.audio ||
            itemType === IProjectItemData_1.ProjectItemType.itemTypeLegacyResource ||
            itemType === IProjectItemData_1.ProjectItemType.blocksCatalogResourceJson) {
            return true;
        }
        return false;
    }
    static isItem(type) {
        return (type === IProjectItemData_1.ProjectItemType.itemTextureJson ||
            type === IProjectItemData_1.ProjectItemType.itemTypeBehavior ||
            type === IProjectItemData_1.ProjectItemType.attachableResourceJson ||
            type === IProjectItemData_1.ProjectItemType.itemTypeLegacyResource);
    }
    static isItemRelated(projectItem, dontGoUpward, dontGoDownward) {
        if (projectItem.parentItems && !dontGoUpward) {
            for (const parentItem of projectItem.parentItems) {
                if (parentItem.parentItem) {
                    if (this.isItem(parentItem.parentItem.itemType)) {
                        return true;
                    }
                    if (this.isItemRelated(parentItem.parentItem, false, true)) {
                        return true;
                    }
                }
            }
        }
        if (projectItem.childItems && !dontGoDownward) {
            for (const parentItem of projectItem.childItems) {
                if (parentItem.childItem) {
                    if (this.isItem(parentItem.childItem.itemType)) {
                        return true;
                    }
                    if (this.isItemRelated(parentItem.childItem, true, false)) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
    static isEntity(type) {
        return (type === IProjectItemData_1.ProjectItemType.entityTypeBehavior ||
            type === IProjectItemData_1.ProjectItemType.entityTypeResource ||
            type === IProjectItemData_1.ProjectItemType.renderControllerJson);
    }
    static isEntityRelated(projectItem, dontGoUpward, dontGoDownward) {
        if (projectItem.parentItems && !dontGoUpward) {
            for (const parentItem of projectItem.parentItems) {
                if (parentItem.parentItem) {
                    if (this.isEntity(parentItem.parentItem.itemType)) {
                        return true;
                    }
                    if (this.isEntityRelated(parentItem.parentItem, false, true)) {
                        return true;
                    }
                }
            }
        }
        if (projectItem.childItems && !dontGoDownward) {
            for (const parentItem of projectItem.childItems) {
                if (parentItem.childItem) {
                    if (this.isEntity(parentItem.childItem.itemType)) {
                        return true;
                    }
                    if (this.isEntityRelated(parentItem.childItem, true, false)) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
    static isParticle(type) {
        return type === IProjectItemData_1.ProjectItemType.particleJson;
    }
    static isParticleRelated(projectItem, dontGoUpward, dontGoDownward) {
        if (projectItem.parentItems && !dontGoUpward) {
            for (const parentItem of projectItem.parentItems) {
                if (parentItem.parentItem) {
                    if (this.isParticle(parentItem.parentItem.itemType)) {
                        return true;
                    }
                    if (this.isParticleRelated(parentItem.parentItem, false, true)) {
                        return true;
                    }
                }
            }
        }
        if (projectItem.childItems && !dontGoDownward) {
            for (const parentItem of projectItem.childItems) {
                if (parentItem.childItem) {
                    if (this.isParticle(parentItem.childItem.itemType)) {
                        return true;
                    }
                    if (this.isParticleRelated(parentItem.childItem, true, false)) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
    static getNewItemName(type) {
        return ProjectItemUtilities.getDescriptionForType(type).toLowerCase();
    }
    static getColorForType(type) {
        const cat = ProjectItemUtilities.getCategory(type);
        switch (cat) {
            case IProjectItemData_1.ProjectItemCategory.logic:
                return {
                    red: (type % 4) * 24 + 160,
                    green: (Math.floor(type / 4) % 4) * 12 + 104,
                    blue: (Math.floor(type / 16) % 4) * 12 + 104,
                };
            case IProjectItemData_1.ProjectItemCategory.assets:
                return {
                    red: (Math.floor(type / 4) % 4) * 12 + 104,
                    green: (type % 4) * 24 + 160,
                    blue: (Math.floor(type / 16) % 4) * 12 + 104,
                };
            case IProjectItemData_1.ProjectItemCategory.types:
                return {
                    red: (Math.floor(type / 16) % 4) * 12 + 104,
                    green: (Math.floor(type / 4) % 4) * 12 + 104,
                    blue: (type % 4) * 24 + 160,
                };
            default:
                return {
                    red: (Math.floor(type / 4) % 4) * 24 + 128,
                    green: (Math.floor(type / 4) % 4) * 24 + 128,
                    blue: (Math.floor(type / 4) % 4) * 24 + 128,
                };
        }
    }
    static getPluralDescriptionForType(type) {
        // override non-"plus s" plural-ifications here
        switch (type) {
            case IProjectItemData_1.ProjectItemType.audio:
                return "Audio";
            case IProjectItemData_1.ProjectItemType.ts:
                return "TypeScript files";
            case IProjectItemData_1.ProjectItemType.js:
                return "JavaScript files";
            case IProjectItemData_1.ProjectItemType.itemTypeLegacyResource:
                return "Item type visuals and audio";
            case IProjectItemData_1.ProjectItemType.entityTypeResource:
                return "Entity type visuals/audio";
            case IProjectItemData_1.ProjectItemType.catalogIndexJs:
                return "Catalog indexes";
            case IProjectItemData_1.ProjectItemType.behaviorPackHistoryListJson:
                return "Behavior pack histories";
            case IProjectItemData_1.ProjectItemType.resourcePackHistoryListJson:
                return "Resource pack histories";
            case IProjectItemData_1.ProjectItemType.globalVariablesJson:
            case IProjectItemData_1.ProjectItemType.materialGeometry:
            case IProjectItemData_1.ProjectItemType.atmosphericsJson:
            case IProjectItemData_1.ProjectItemType.biomesClientCatalogResource:
            case IProjectItemData_1.ProjectItemType.vsCodeTasksJson:
            case IProjectItemData_1.ProjectItemType.vsCodeSettingsJson:
            case IProjectItemData_1.ProjectItemType.vsCodeExtensionsJson:
            case IProjectItemData_1.ProjectItemType.mcToolsProjectPreferences:
            case IProjectItemData_1.ProjectItemType.materialsResourceJson:
            case IProjectItemData_1.ProjectItemType.lang:
                return this.getDescriptionForType(type);
            default:
                const str = this.getDescriptionForType(type);
                if (!str.endsWith("s")) {
                    return str + "s";
                }
                return str;
        }
    }
    static async getDefaultFolderForType(project, itemType) {
        const paths = ProjectItemUtilities.getFolderRootsForType(itemType);
        if (paths === undefined || paths.length === 0) {
            return undefined;
        }
        await project.ensureLoadedProjectFolder();
        if (!project.projectFolder) {
            return undefined;
        }
        switch (itemType) {
            case IProjectItemData_1.ProjectItemType.js:
            case IProjectItemData_1.ProjectItemType.ts:
                const scriptsFolder = await project.getMainScriptsFolder();
                return scriptsFolder;
            case IProjectItemData_1.ProjectItemType.entityTypeBehavior:
            case IProjectItemData_1.ProjectItemType.MCFunction:
                const defaultBpFolder = await project.getDefaultBehaviorPackFolder();
                if (!defaultBpFolder) {
                    return undefined;
                }
                return defaultBpFolder.ensureFolderFromRelativePath(paths[0]);
            case IProjectItemData_1.ProjectItemType.entityTypeResource:
            case IProjectItemData_1.ProjectItemType.modelGeometryJson:
                const defaultRpFolder = await project.getDefaultResourcePackFolder();
                if (!defaultRpFolder) {
                    return undefined;
                }
                return defaultRpFolder.ensureFolderFromRelativePath(paths[0]);
            case IProjectItemData_1.ProjectItemType.spawnRuleBehavior:
            case IProjectItemData_1.ProjectItemType.lootTableBehavior:
            case IProjectItemData_1.ProjectItemType.recipeBehavior:
            case IProjectItemData_1.ProjectItemType.featureBehavior:
            case IProjectItemData_1.ProjectItemType.featureRuleBehavior:
            case IProjectItemData_1.ProjectItemType.jigsawProcessorList:
            case IProjectItemData_1.ProjectItemType.jigsawStructure:
            case IProjectItemData_1.ProjectItemType.jigsawTemplatePool:
            case IProjectItemData_1.ProjectItemType.jigsawStructureSet:
                return await ProjectUtilities_1.default.getDefaultBehaviorPackFolder(project, paths);
            case IProjectItemData_1.ProjectItemType.designTexture:
                const defaultDpFolder = await project.getDefaultDesignPackFolder();
                if (!defaultDpFolder) {
                    return undefined;
                }
                return defaultDpFolder.ensureFolderFromRelativePath(StorageUtilities_1.default.ensureStartsWithDelimiter(paths[0]));
            case IProjectItemData_1.ProjectItemType.uiTexture:
                const defaultRpFolderA = await project.getDefaultResourcePackFolder();
                if (!defaultRpFolderA) {
                    return undefined;
                }
                return defaultRpFolderA.ensureFolderFromRelativePath(paths.join("/"));
        }
        return undefined;
    }
    static getNewItemTechnicalName(type) {
        const roots = this.getFolderRootsForType(type);
        if (roots.length > 0) {
            let str = roots[roots.length - 1];
            if (str === "entities") {
                str = "entity";
            }
            else if (str.endsWith("s")) {
                str = str.substring(0, str.length - 1);
            }
            return str;
        }
        return "item";
    }
    static getFolderRootsForType(itemType) {
        switch (itemType) {
            case IProjectItemData_1.ProjectItemType.MCFunction:
                return ["functions"];
            case IProjectItemData_1.ProjectItemType.featureRuleBehavior:
                return ["feature_rules"];
            case IProjectItemData_1.ProjectItemType.actionSet:
                return ["action_sets"];
            case IProjectItemData_1.ProjectItemType.designTexture:
                return ["design_textures"];
            case IProjectItemData_1.ProjectItemType.featureBehavior:
                return ["features"];
            case IProjectItemData_1.ProjectItemType.js:
            case IProjectItemData_1.ProjectItemType.ts:
                return ["scripts"];
            case IProjectItemData_1.ProjectItemType.image:
                return ["subpacks"];
            case IProjectItemData_1.ProjectItemType.craftingItemCatalog:
                return ["item_catalog"];
            case IProjectItemData_1.ProjectItemType.lightingJson:
                return ["lighting"];
            case IProjectItemData_1.ProjectItemType.tickJson:
                return ["functions"];
            case IProjectItemData_1.ProjectItemType.uiTexture:
                return ["textures", "ui"];
            case IProjectItemData_1.ProjectItemType.jigsawProcessorList:
                return ["worldgen", "processors"];
            case IProjectItemData_1.ProjectItemType.jigsawStructure:
                return ["worldgen", "jigsaw_structures"];
            case IProjectItemData_1.ProjectItemType.jigsawTemplatePool:
                return ["worldgen", "template_pools"];
            case IProjectItemData_1.ProjectItemType.jigsawStructureSet:
                return ["worldgen", "structure_sets"];
            case IProjectItemData_1.ProjectItemType.biomeResource:
            case IProjectItemData_1.ProjectItemType.biomeBehavior:
                return ["biomes"];
            case IProjectItemData_1.ProjectItemType.texture:
            case IProjectItemData_1.ProjectItemType.terrainTextureCatalogResourceJson:
            case IProjectItemData_1.ProjectItemType.itemTextureJson:
            case IProjectItemData_1.ProjectItemType.flipbookTexturesJson:
                return ["textures"];
            case IProjectItemData_1.ProjectItemType.packIconImage:
                return [
                    "resource_packs",
                    "rps",
                    "development_resource_packs",
                    "behavior_packs",
                    "bps",
                    "development_behavior_packs",
                ];
            case IProjectItemData_1.ProjectItemType.modelGeometryJson:
                return ["models"];
            case IProjectItemData_1.ProjectItemType.soundCatalog:
                return ["resource_packs", "rps", "development_resource_packs"];
            case IProjectItemData_1.ProjectItemType.soundDefinitionCatalog:
                return ["sounds"];
            case IProjectItemData_1.ProjectItemType.entityTypeResource:
                return ["entity"];
            case IProjectItemData_1.ProjectItemType.animationControllerResourceJson:
            case IProjectItemData_1.ProjectItemType.animationControllerBehaviorJson:
                return ["animation_controllers"];
            case IProjectItemData_1.ProjectItemType.animationResourceJson:
            case IProjectItemData_1.ProjectItemType.animationBehaviorJson:
                return ["animations"];
            case IProjectItemData_1.ProjectItemType.renderControllerJson:
                return ["render_controllers"];
            case IProjectItemData_1.ProjectItemType.attachableResourceJson:
                return ["attachables"];
            case IProjectItemData_1.ProjectItemType.entityTypeBehavior:
                return ["entities"];
            case IProjectItemData_1.ProjectItemType.itemTypeBehavior:
            case IProjectItemData_1.ProjectItemType.itemTypeLegacyResource:
                return ["items"];
            case IProjectItemData_1.ProjectItemType.blockTypeBehavior:
                return ["blocks"];
            case IProjectItemData_1.ProjectItemType.documentedTypeFolder:
                return ["script_modules"];
            case IProjectItemData_1.ProjectItemType.commandSetDefinitionJson:
                return ["command_modules"];
            case IProjectItemData_1.ProjectItemType.lootTableBehavior:
                return ["loot_tables"];
            case IProjectItemData_1.ProjectItemType.recipeBehavior:
                return ["recipes"];
            case IProjectItemData_1.ProjectItemType.spawnRuleBehavior:
                return ["spawn_rules"];
            case IProjectItemData_1.ProjectItemType.particleJson:
                return ["particles"];
            case IProjectItemData_1.ProjectItemType.structure:
                return ["structures"];
            case IProjectItemData_1.ProjectItemType.worldFolder:
            case IProjectItemData_1.ProjectItemType.MCWorld:
                return ["worlds"];
            case IProjectItemData_1.ProjectItemType.colorGradingJson:
                return ["color_grading"];
            case IProjectItemData_1.ProjectItemType.atmosphericsJson:
                return ["atmospherics"];
            case IProjectItemData_1.ProjectItemType.pbrJson:
                return ["pbr"];
            case IProjectItemData_1.ProjectItemType.pointLightsJson:
                return ["point_lights"];
            case IProjectItemData_1.ProjectItemType.shadowsJson:
                return ["shadows"];
            case IProjectItemData_1.ProjectItemType.waterJson:
                return ["water"];
            case IProjectItemData_1.ProjectItemType.aimAssistPresetJson:
                return ["cameras"];
            case IProjectItemData_1.ProjectItemType.dimensionJson:
                return ["dimensions"];
            case IProjectItemData_1.ProjectItemType.fogResourceJson:
                return ["fogs"];
            case IProjectItemData_1.ProjectItemType.dataForm:
                return ["forms"];
            case IProjectItemData_1.ProjectItemType.scriptTypesJson:
                return ["checkpoint_input", "script_modules"];
            case IProjectItemData_1.ProjectItemType.engineOrderingJson:
                return ["checkpoint_input", "engine_modules"];
            case IProjectItemData_1.ProjectItemType.vanillaDataJson:
                return ["checkpoint_input", "vanilladata_modules"];
            case IProjectItemData_1.ProjectItemType.marketingAssetImage:
                return ["marketing art"];
            case IProjectItemData_1.ProjectItemType.storeAssetImage:
                return ["store art"];
            case IProjectItemData_1.ProjectItemType.audio:
                return ["sounds"];
            case IProjectItemData_1.ProjectItemType.materialSetJson:
            case IProjectItemData_1.ProjectItemType.materialsResourceJson:
            case IProjectItemData_1.ProjectItemType.material:
                return ["materials"];
        }
        return [];
    }
}
exports.default = ProjectItemUtilities;
function getEnsuredFile(items, predicate) {
    const foundItem = items.find(predicate);
    return foundItem ? foundItem.loadFileContent() : Promise.resolve(undefined);
}
exports.getEnsuredFile = getEnsuredFile;
const getEnsuredFileOfType = (items, type) => getEnsuredFile(items, (item) => item.itemType === type);
exports.getEnsuredFileOfType = getEnsuredFileOfType;
function findEnsuredFiles(items, predicate) {
    const filteredItems = items.filter(predicate);
    return Promise.all(filteredItems.map((item) => item.loadFileContent()));
}
exports.findEnsuredFiles = findEnsuredFiles;
const findEnsuredFilesOfType = (items, type) => findEnsuredFiles(items, (item) => item.itemType === type);
exports.findEnsuredFilesOfType = findEnsuredFilesOfType;
function getNeighborFiles(items, subject) {
    const projectPath = subject.projectPath?.toLowerCase();
    if (!projectPath) {
        throw new Error(`No Project path found for project item: ${subject.name}`);
    }
    const folderProjectPath = projectPath.substring(0, projectPath.length - subject.name.length);
    const neighbors = folderProjectPath && items.filter((item) => item.projectPath?.toLocaleLowerCase().startsWith(folderProjectPath));
    return neighbors || [];
}
exports.getNeighborFiles = getNeighborFiles;
function getWorldTemplates(items) {
    return items
        .filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.worldTemplateManifestJson)
        .map((worldManifest) => ({ name: worldManifest.name, items: getNeighborFiles(items, worldManifest) }));
}
exports.getWorldTemplates = getWorldTemplates;
function getMarketContent(items) {
    const marketContentTypes = new Set([IProjectItemData_1.ProjectItemType.storeAssetImage, IProjectItemData_1.ProjectItemType.marketingAssetImage]);
    return items.filter((item) => marketContentTypes.has(item.itemType));
}
exports.getMarketContent = getMarketContent;
async function tryEnsureFiles(items, predicate = () => true) {
    const filteredItems = items.filter(predicate);
    const fileReads = await Promise.all(filteredItems.map(async (item) => [item, await item.loadFileContent()]));
    const success = [];
    const failed = [];
    for (const [item, file] of fileReads) {
        if (!file) {
            failed.push(item);
        }
        else {
            success.push(item);
        }
    }
    return [success, failed];
}
exports.tryEnsureFiles = tryEnsureFiles;

//# sourceMappingURL=../maps/app/ProjectItemUtilities.js.map
