"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const Project_1 = require("../app/Project");
const CartoApp_1 = require("../app/CartoApp");
const NodeStorage_1 = require("../local/NodeStorage");
const Database_1 = require("../minecraft/Database");
const LocalEnvironment_1 = require("../local/LocalEnvironment");
const ProjectInfoSet_1 = require("../info/ProjectInfoSet");
const IProjectInfoData_1 = require("../info/IProjectInfoData");
const StorageUtilities_1 = require("../storage/StorageUtilities");
const ProjectExporter_1 = require("../app/ProjectExporter");
const WorldLevelDat_1 = require("../minecraft/WorldLevelDat");
const fs = require("fs");
const ProjectItem_1 = require("../app/ProjectItem");
const IProjectItemData_1 = require("../app/IProjectItemData");
const ProjectUtilities_1 = require("../app/ProjectUtilities");
const ProjectItemUtilities_1 = require("../app/ProjectItemUtilities");
const TestUtilities_1 = require("./TestUtilities");
CartoApp_1.default.hostType = CartoApp_1.HostType.testLocal;
let carto = undefined;
let localEnv = undefined;
let scenariosFolder = undefined;
let resultsFolder = undefined;
localEnv = new LocalEnvironment_1.default(false);
(async () => {
    CartoApp_1.default.localFolderExists = _localFolderExists;
    CartoApp_1.default.ensureLocalFolder = _ensureLocalFolder;
    const scenariosStorage = new NodeStorage_1.default(NodeStorage_1.default.ensureEndsWithDelimiter(__dirname) + "/../../test/", "scenarios");
    scenariosFolder = scenariosStorage.rootFolder;
    await scenariosFolder.ensureExists();
    const resultsStorage = new NodeStorage_1.default(NodeStorage_1.default.ensureEndsWithDelimiter(__dirname) + "/../../test/", "results");
    resultsFolder = resultsStorage.rootFolder;
    await resultsFolder.ensureExists();
    CartoApp_1.default.prefsStorage = new NodeStorage_1.default(localEnv.utilities.testWorkingPath + "prefs" + NodeStorage_1.default.platformFolderDelimiter, "");
    CartoApp_1.default.projectsStorage = new NodeStorage_1.default(localEnv.utilities.testWorkingPath + "projects" + NodeStorage_1.default.platformFolderDelimiter, "");
    CartoApp_1.default.packStorage = new NodeStorage_1.default(localEnv.utilities.testWorkingPath + "packs" + NodeStorage_1.default.platformFolderDelimiter, "");
    CartoApp_1.default.worldStorage = new NodeStorage_1.default(localEnv.utilities.testWorkingPath + "worlds" + NodeStorage_1.default.platformFolderDelimiter, "");
    CartoApp_1.default.deploymentStorage = new NodeStorage_1.default(localEnv.utilities.testWorkingPath + "deployment" + NodeStorage_1.default.platformFolderDelimiter, "");
    CartoApp_1.default.workingStorage = new NodeStorage_1.default(localEnv.utilities.testWorkingPath + "working" + NodeStorage_1.default.platformFolderDelimiter, "");
    const coreStorage = new NodeStorage_1.default(__dirname + "/../../public/data/content/", "");
    Database_1.default.contentFolder = coreStorage.rootFolder;
    await CartoApp_1.default.init();
    carto = CartoApp_1.default.carto;
    if (!carto) {
        return;
    }
    await carto.load();
    Database_1.default.local = localEnv.utilities;
    carto.local = localEnv.utilities;
    carto.onStatusAdded.subscribe(handleStatusAdded);
})();
function handleStatusAdded(carto, status) {
    console.log(status.message);
}
function _ensureLocalFolder(path) {
    const ls = new NodeStorage_1.default(path, "");
    return ls.rootFolder;
}
async function _localFolderExists(path) {
    const ls = new NodeStorage_1.default(path, "");
    return await ls.rootFolder.exists();
}
async function _loadProject(name) {
    if (!carto || !scenariosFolder || !resultsFolder) {
        chai_1.assert.fail("Not properly initialized");
    }
    const project = new Project_1.default(carto, name, null);
    project.autoDeploymentMode = Project_1.ProjectAutoDeploymentMode.noAutoDeployment;
    project.localFolderPath = __dirname + "/../../../samplecontent/" + name + "/";
    await project.inferProjectItemsFromFiles();
    return project;
}
function removeResultFolder(scenarioName) {
    if (resultsFolder) {
        const path = StorageUtilities_1.default.ensureEndsWithDelimiter(resultsFolder.fullPath) +
            StorageUtilities_1.default.ensureEndsWithDelimiter(scenarioName);
        // guard against being called at a "more root" file path
        if (fs.existsSync(path) && !StorageUtilities_1.default.isPathRiskyForDelete(path)) {
            try {
                fs.rmSync(path, {
                    recursive: true,
                });
            }
            catch (e) {
                console.log("Error occurred during rmSync on '" + path + "'");
                throw e;
            }
        }
    }
}
describe("simple", async () => {
    it("has expected structure", async () => {
        const project = await _loadProject("simple");
        (0, chai_1.expect)(project.items.length).to.equal(6);
    });
    it("report file matches", async () => {
        const project = await _loadProject("simple");
        const pis = new ProjectInfoSet_1.default(project, IProjectInfoData_1.ProjectInfoSuite.default);
        await pis.generateForProject();
        const dataObject = pis.getDataObject();
        await (0, TestUtilities_1.ensureReportJsonMatchesScenario)(scenariosFolder, resultsFolder, dataObject, "simple");
    });
});
describe("deployJs", async () => {
    before((done) => {
        removeResultFolder("deployJs");
        done();
    });
    it("has expected structure", async () => {
        const project = await _loadProject("deployJs");
        (0, chai_1.expect)(project.items.length).to.equal(4);
    });
    it("deploy outputs match", async () => {
        const project = await _loadProject("deployJs");
        if (!carto || !resultsFolder) {
            return;
        }
        const worldSettings = {
            generator: WorldLevelDat_1.Generator.infinite,
            gameType: WorldLevelDat_1.GameType.survival,
            randomSeed: "3000",
            lastPlayed: BigInt(new Date(2023, 0, 1).getTime()),
        };
        const resultsOutFolder = resultsFolder.ensureFolder("deployJs");
        await resultsOutFolder.ensureExists();
        await ProjectExporter_1.default.deployProjectAndGeneratedWorldTo(carto, project, worldSettings, resultsOutFolder);
        await (0, TestUtilities_1.folderMatches)(scenariosFolder, resultsFolder, "deployJs", ["level.dat", "level.dat_old"]);
    });
});
describe("Project utility methods", () => {
    it("resetProjectItems removes unknown and json items", async () => {
        const project = await _loadProject("simple");
        // Simulate unknown and json items using real ProjectItem instances with all required properties
        project.items.push(new ProjectItem_1.default(project, {
            itemType: IProjectItemData_1.ProjectItemType.unknown,
            projectPath: "/fake1",
            variants: {},
            tags: [],
            name: "fake1",
            storageType: IProjectItemData_1.ProjectItemStorageType.singleFile,
        }));
        project.items.push(new ProjectItem_1.default(project, {
            itemType: IProjectItemData_1.ProjectItemType.unknownJson,
            projectPath: "/fake2",
            variants: {},
            tags: [],
            name: "fake2",
            storageType: IProjectItemData_1.ProjectItemStorageType.singleFile,
        }));
        const before = project.items.length;
        project.resetProjectItems();
        const after = project.items.length;
        (0, chai_1.expect)(after).to.be.lessThan(before);
    });
    it("ensureStoragePathIsCollapsed/NotCollapsed works as expected", async () => {
        const project = await _loadProject("simple");
        const path = "/test/path";
        project.ensureStoragePathIsCollapsed(path);
        (0, chai_1.expect)(project.collapsedStoragePaths).to.include(path);
        project.ensureStoragePathIsNotCollapsed(path);
        (0, chai_1.expect)(project.collapsedStoragePaths).to.not.include(path);
    });
    it("getFirstItemByType returns correct item", async () => {
        const project = await _loadProject("simple");
        const item = project.getFirstItemByType(project.items[0].itemType);
        (0, chai_1.expect)(item).to.exist;
        if (item) {
            (0, chai_1.expect)(item.itemType).to.equal(project.items[0].itemType);
        }
    });
});
describe("spawnRulesDependency", async () => {
    let project;
    beforeEach(async () => {
        project = await _loadProject("spawnRulesDependency");
    });
    it("has expected structure", async () => {
        chai_1.assert.isDefined(project);
        chai_1.assert.isTrue(project.projectFolder !== null);
        chai_1.assert.isTrue(project.projectFolder !== undefined);
    });
    it("spawn rules track entity type behavior dependencies", async () => {
        chai_1.assert.isDefined(project);
        // Load the project items
        await project.inferProjectItemsFromFiles();
        // Find the spawn rule item
        const spawnRuleItem = project.items.find((item) => item.itemType === IProjectItemData_1.ProjectItemType.spawnRuleBehavior && item.name === "example_entity.json");
        chai_1.assert.isDefined(spawnRuleItem, "Spawn rule item should exist");
        // Find the entity type behavior item
        const entityItem = project.items.find((item) => item.itemType === IProjectItemData_1.ProjectItemType.entityTypeBehavior && item.name === "example_entity.json");
        chai_1.assert.isDefined(entityItem, "Entity type behavior item should exist");
        // Process relations to set up dependencies
        await project.processRelations();
        // Check that the spawn rule has the entity type behavior as a child
        chai_1.assert.isDefined(spawnRuleItem?.parentItems, "Spawn rule should have parent items");
        if (spawnRuleItem && spawnRuleItem.parentItems) {
            chai_1.assert.isTrue(spawnRuleItem?.parentItems.length > 0, "Spawn rule should have at least one parent item");
            const hasEntityParent = spawnRuleItem?.parentItems.some((childRel) => childRel.parentItem === entityItem);
            chai_1.assert.isTrue(hasEntityParent, "Spawn rule should have entity type behavior as parent");
        }
    });
});
describe("Advanced Content Type Tests", async () => {
    it("validates ProjectItemUtilities functionality", async () => {
        const project = await _loadProject("comprehensive");
        // Test item type detection
        const entityItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.entityTypeBehavior);
        (0, chai_1.expect)(entityItems.length).to.be.greaterThan(0);
        if (entityItems.length > 0) {
            const entityItem = entityItems[0];
            // Test category assignment
            const category = ProjectItemUtilities_1.default.getCategory(entityItem.itemType);
            (0, chai_1.expect)(category).to.be.a("number");
            // Test display name
            const displayName = ProjectItemUtilities_1.default.getDescriptionForType(entityItem.itemType);
            (0, chai_1.expect)(displayName).to.be.a("string");
            (0, chai_1.expect)(displayName.length).to.be.greaterThan(0);
            // Test sort order
            const sortOrder = ProjectItemUtilities_1.default.getSortOrder(entityItem.itemType);
            (0, chai_1.expect)(sortOrder).to.be.a("number");
            (0, chai_1.expect)(sortOrder).to.be.greaterThanOrEqual(0);
        }
    });
    it("validates different file extensions are handled", async () => {
        const project = await _loadProject("comprehensive");
        // Test different file types
        const jsonItems = project.items.filter((item) => item.projectPath?.endsWith(".json"));
        const jsItems = project.items.filter((item) => item.projectPath?.endsWith(".js"));
        const langItems = project.items.filter((item) => item.projectPath?.endsWith(".lang"));
        const mcfunctionItems = project.items.filter((item) => item.projectPath?.endsWith(".mcfunction"));
        (0, chai_1.expect)(jsonItems.length).to.be.greaterThan(0);
        (0, chai_1.expect)(jsItems.length).to.be.greaterThan(0);
        (0, chai_1.expect)(langItems.length).to.be.greaterThan(0);
        (0, chai_1.expect)(mcfunctionItems.length).to.be.greaterThan(0);
    });
    it("validates project structure detection", async () => {
        const project = await _loadProject("comprehensive");
        // Test structure detection
        const hasBehaviorPack = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.behaviorPackManifestJson);
        const hasResourcePack = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.resourcePackManifestJson);
        const hasScripts = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.js);
        const hasEntities = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.entityTypeBehavior);
        const hasBlocks = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.blockTypeBehavior);
        const hasItems = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.itemTypeBehavior);
        (0, chai_1.expect)(hasBehaviorPack).to.be.true;
        (0, chai_1.expect)(hasResourcePack).to.be.true;
        (0, chai_1.expect)(hasScripts).to.be.true;
        (0, chai_1.expect)(hasEntities).to.be.true;
        (0, chai_1.expect)(hasBlocks).to.be.true;
        (0, chai_1.expect)(hasItems).to.be.true;
    });
    it("validates folder structure inference", async () => {
        const project = await _loadProject("comprehensive");
        // Test that items are properly categorized by their folder structure
        const entityItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.entityTypeBehavior);
        const blockItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.blockTypeBehavior);
        const itemItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.itemTypeBehavior);
        const recipeItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.recipeBehavior);
        const functionItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.MCFunction);
        if (entityItems.length > 0) {
            (0, chai_1.expect)(entityItems[0].projectPath).to.contain("entities");
        }
        if (blockItems.length > 0) {
            (0, chai_1.expect)(blockItems[0].projectPath).to.contain("blocks");
        }
        if (itemItems.length > 0) {
            (0, chai_1.expect)(itemItems[0].projectPath).to.contain("items");
        }
        if (recipeItems.length > 0) {
            (0, chai_1.expect)(recipeItems[0].projectPath).to.contain("recipes");
        }
        if (functionItems.length > 0) {
            (0, chai_1.expect)(functionItems[0].projectPath).to.contain("functions");
        }
    });
    it("validates content type diversity", async () => {
        const project = await _loadProject("comprehensive");
        // Get unique item types
        const uniqueTypes = [...new Set(project.items.map((item) => item.itemType))];
        // Should have diverse content types
        (0, chai_1.expect)(uniqueTypes.length).to.be.greaterThan(15);
        // Should include various categories
        const categories = uniqueTypes.map((type) => ProjectItemUtilities_1.default.getCategory(type));
        const uniqueCategories = [...new Set(categories)];
        (0, chai_1.expect)(uniqueCategories.length).to.be.greaterThan(3);
    });
    it("validates project utilities functionality", async () => {
        const project = await _loadProject("comprehensive");
        // Test project analysis
        const hasScripts = (await project.getScriptState()).hasScript;
        const hasEntities = ProjectUtilities_1.default.hasEntities(project);
        const hasBlocks = ProjectUtilities_1.default.hasBlocks(project);
        const hasItems = ProjectUtilities_1.default.hasItems(project);
        (0, chai_1.expect)(hasScripts).to.be.true;
        (0, chai_1.expect)(hasEntities).to.be.true;
        (0, chai_1.expect)(hasBlocks).to.be.true;
        (0, chai_1.expect)(hasItems).to.be.true;
    });
    it("validates complex project structure", async () => {
        const project = await _loadProject("comprehensive");
        // Test nested folder structures
        const nestedItems = project.items.filter((item) => item.projectPath && item.projectPath.split("/").length > 3);
        (0, chai_1.expect)(nestedItems.length).to.be.greaterThan(0);
    });
    it("validates different manifest types", async () => {
        const project = await _loadProject("comprehensive");
        const behaviorManifests = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.behaviorPackManifestJson);
        const resourceManifests = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.resourcePackManifestJson);
        (0, chai_1.expect)(behaviorManifests.length).to.equal(1);
        (0, chai_1.expect)(resourceManifests.length).to.equal(1);
        if (behaviorManifests.length > 0) {
            (0, chai_1.expect)(behaviorManifests[0].projectPath).to.contain("behavior_packs");
        }
        if (resourceManifests.length > 0) {
            (0, chai_1.expect)(resourceManifests[0].projectPath).to.contain("resource_packs");
        }
    });
    it("validates animation and animation controller content", async () => {
        const project = await _loadProject("comprehensive");
        const animations = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.animationBehaviorJson);
        const animationControllers = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.animationControllerBehaviorJson);
        (0, chai_1.expect)(animations.length).to.be.greaterThan(0);
        (0, chai_1.expect)(animationControllers.length).to.be.greaterThan(0);
        if (animations.length > 0) {
            (0, chai_1.expect)(animations[0].projectPath).to.contain("animations");
        }
        if (animationControllers.length > 0) {
            (0, chai_1.expect)(animationControllers[0].projectPath).to.contain("animation_controllers");
        }
    });
    it("validates resource pack specific content", async () => {
        const project = await _loadProject("comprehensive");
        const geometries = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.modelGeometryJson);
        const renderControllers = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.renderControllerJson);
        const particles = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.particleJson);
        const clientEntities = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.entityTypeResource);
        (0, chai_1.expect)(geometries.length).to.be.greaterThan(0);
        (0, chai_1.expect)(renderControllers.length).to.be.greaterThan(0);
        (0, chai_1.expect)(particles.length).to.be.greaterThan(0);
        (0, chai_1.expect)(clientEntities.length).to.be.greaterThan(0);
        if (geometries.length > 0) {
            (0, chai_1.expect)(geometries[0].projectPath).to.contain("models");
        }
        if (renderControllers.length > 0) {
            (0, chai_1.expect)(renderControllers[0].projectPath).to.contain("render_controllers");
        }
        if (particles.length > 0) {
            (0, chai_1.expect)(particles[0].projectPath).to.contain("particles");
        }
        if (clientEntities.length > 0) {
            (0, chai_1.expect)(clientEntities[0].projectPath).to.contain("entity");
        }
    });
    it("validates language and localization content", async () => {
        const project = await _loadProject("comprehensive");
        const langFiles = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.lang);
        const languagesCatalog = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.languagesCatalogResourceJson);
        (0, chai_1.expect)(langFiles.length).to.be.greaterThan(0);
        (0, chai_1.expect)(languagesCatalog.length).to.be.greaterThan(0);
        if (langFiles.length > 0) {
            (0, chai_1.expect)(langFiles[0].projectPath).to.contain("texts");
        }
        if (languagesCatalog.length > 0) {
            (0, chai_1.expect)(languagesCatalog[0].projectPath).to.contain("texts");
        }
    });
});
describe("Specialized Content Types", async () => {
    it("validates dialogue content", async () => {
        const project = await _loadProject("comprehensive");
        const dialogueItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.dialogueBehaviorJson);
        (0, chai_1.expect)(dialogueItems.length).to.be.greaterThan(0);
        const dialogueItem = dialogueItems[0];
        (0, chai_1.expect)(dialogueItem.name).to.equal("sample_dialogue.json");
        (0, chai_1.expect)(dialogueItem.projectPath).to.contain("dialogue");
    });
    it("validates trading content", async () => {
        const project = await _loadProject("comprehensive");
        const tradingItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.tradingBehaviorJson);
        (0, chai_1.expect)(tradingItems.length).to.be.greaterThan(0);
        const tradingItem = tradingItems[0];
        (0, chai_1.expect)(tradingItem.name).to.equal("sample_trading.json");
        (0, chai_1.expect)(tradingItem.projectPath).to.contain("trading");
    });
    it("validates attachable content", async () => {
        const project = await _loadProject("comprehensive");
        const attachableItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.attachableResourceJson);
        (0, chai_1.expect)(attachableItems.length).to.be.greaterThan(0);
        const attachableItem = attachableItems[0];
        (0, chai_1.expect)(attachableItem.name).to.equal("sample_attachable.json");
        (0, chai_1.expect)(attachableItem.projectPath).to.contain("attachables");
    });
    it("validates resource pack animations", async () => {
        const project = await _loadProject("comprehensive");
        const resourceAnimations = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.animationResourceJson);
        (0, chai_1.expect)(resourceAnimations.length).to.be.greaterThan(0);
        const resourceAnimation = resourceAnimations[0];
        (0, chai_1.expect)(resourceAnimation.name).to.equal("sample_entity_resource.json");
        (0, chai_1.expect)(resourceAnimation.projectPath).to.contain("resource_packs");
    });
    it("validates resource pack animation controllers", async () => {
        const project = await _loadProject("comprehensive");
        const resourceAnimationControllers = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.animationControllerResourceJson);
        (0, chai_1.expect)(resourceAnimationControllers.length).to.be.greaterThan(0);
        const resourceAnimationController = resourceAnimationControllers[0];
        (0, chai_1.expect)(resourceAnimationController.name).to.equal("sample_entity_resource.json");
        (0, chai_1.expect)(resourceAnimationController.projectPath).to.contain("resource_packs");
    });
    it("validates multiple recipe types", async () => {
        const project = await _loadProject("comprehensive");
        const recipeItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.recipeBehavior);
        (0, chai_1.expect)(recipeItems.length).to.be.greaterThan(1);
        const recipeNames = recipeItems.map((item) => item.name);
        (0, chai_1.expect)(recipeNames).to.include("sample_recipe.json");
        (0, chai_1.expect)(recipeNames).to.include("shapeless_recipe.json");
    });
    it("validates multiple loot table types", async () => {
        const project = await _loadProject("comprehensive");
        const lootTableItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.lootTableBehavior);
        (0, chai_1.expect)(lootTableItems.length).to.be.greaterThan(1);
        const lootTableNames = lootTableItems.map((item) => item.name);
        (0, chai_1.expect)(lootTableNames).to.include("sample_loot_table.json");
        (0, chai_1.expect)(lootTableNames).to.include("treasure_loot.json");
    });
    it("validates multiple function types", async () => {
        const project = await _loadProject("comprehensive");
        const functionItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.MCFunction);
        (0, chai_1.expect)(functionItems.length).to.be.greaterThan(1);
        const functionNames = functionItems.map((item) => item.name);
        (0, chai_1.expect)(functionNames).to.include("sample_function.mcfunction");
        (0, chai_1.expect)(functionNames).to.include("complex_function.mcfunction");
    });
    it("validates multiple item types", async () => {
        const project = await _loadProject("comprehensive");
        const itemItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.itemTypeBehavior);
        (0, chai_1.expect)(itemItems.length).to.be.greaterThan(1);
        const itemNames = itemItems.map((item) => item.name);
        (0, chai_1.expect)(itemNames).to.include("sample_item.json");
        (0, chai_1.expect)(itemNames).to.include("simple_tool.json");
    });
    it("validates behavior pack only project", async () => {
        const project = await _loadProject("behavior_pack_only");
        const behaviorManifests = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.behaviorPackManifestJson);
        const resourceManifests = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.resourcePackManifestJson);
        const entityItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.entityTypeBehavior);
        (0, chai_1.expect)(behaviorManifests.length).to.equal(1);
        (0, chai_1.expect)(resourceManifests.length).to.equal(0);
        (0, chai_1.expect)(entityItems.length).to.be.greaterThan(0);
    });
    it("validates resource pack only project", async () => {
        const project = await _loadProject("resource_pack_only");
        const behaviorManifests = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.behaviorPackManifestJson);
        const resourceManifests = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.resourcePackManifestJson);
        (0, chai_1.expect)(behaviorManifests.length).to.equal(0);
        (0, chai_1.expect)(resourceManifests.length).to.equal(1);
    });
    it("validates file path patterns", async () => {
        const project = await _loadProject("comprehensive");
        // Check that items have expected path patterns
        const entityItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.entityTypeBehavior);
        const blockItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.blockTypeBehavior);
        const resourceEntityItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.entityTypeResource);
        if (entityItems.length > 0) {
            (0, chai_1.expect)(entityItems[0].projectPath).to.match(/behavior_packs.*entities/);
        }
        if (blockItems.length > 0) {
            (0, chai_1.expect)(blockItems[0].projectPath).to.match(/behavior_packs.*blocks/);
        }
        if (resourceEntityItems.length > 0) {
            (0, chai_1.expect)(resourceEntityItems[0].projectPath).to.match(/resource_packs.*entity/);
        }
    });
    it("validates content type classification", async () => {
        const project = await _loadProject("comprehensive");
        // Test that different content types are properly classified
        const contentTypes = [
            IProjectItemData_1.ProjectItemType.entityTypeBehavior,
            IProjectItemData_1.ProjectItemType.entityTypeResource,
            IProjectItemData_1.ProjectItemType.blockTypeBehavior,
            IProjectItemData_1.ProjectItemType.itemTypeBehavior,
            IProjectItemData_1.ProjectItemType.recipeBehavior,
            IProjectItemData_1.ProjectItemType.lootTableBehavior,
            IProjectItemData_1.ProjectItemType.MCFunction,
            IProjectItemData_1.ProjectItemType.animationBehaviorJson,
            IProjectItemData_1.ProjectItemType.animationResourceJson,
            IProjectItemData_1.ProjectItemType.dialogueBehaviorJson,
            IProjectItemData_1.ProjectItemType.tradingBehaviorJson,
            IProjectItemData_1.ProjectItemType.attachableResourceJson,
            IProjectItemData_1.ProjectItemType.spawnRuleBehavior,
            IProjectItemData_1.ProjectItemType.modelGeometryJson,
            IProjectItemData_1.ProjectItemType.renderControllerJson,
            IProjectItemData_1.ProjectItemType.particleJson,
            IProjectItemData_1.ProjectItemType.js,
            IProjectItemData_1.ProjectItemType.lang,
        ];
        for (const contentType of contentTypes) {
            const items = project.items.filter((item) => item.itemType === contentType);
            if (items.length > 0) {
                const displayName = ProjectItemUtilities_1.default.getDescriptionForType(contentType);
                (0, chai_1.expect)(displayName).to.be.a("string");
                (0, chai_1.expect)(displayName.length).to.be.greaterThan(0);
            }
        }
    });
    it("validates project structure completeness", async () => {
        const project = await _loadProject("comprehensive");
        // Should have both behavior and resource packs
        const hasBehaviorPack = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.behaviorPackManifestJson);
        const hasResourcePack = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.resourcePackManifestJson);
        (0, chai_1.expect)(hasBehaviorPack).to.be.true;
        (0, chai_1.expect)(hasResourcePack).to.be.true;
        // Should have various content types
        const hasEntities = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.entityTypeBehavior);
        const hasBlocks = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.blockTypeBehavior);
        const hasItems = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.itemTypeBehavior);
        const hasRecipes = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.recipeBehavior);
        const hasFunctions = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.MCFunction);
        const hasAnimations = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.animationBehaviorJson);
        const hasLootTables = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.lootTableBehavior);
        const hasSpawnRules = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.spawnRuleBehavior);
        const hasScripts = project.items.some((item) => item.itemType === IProjectItemData_1.ProjectItemType.js);
        (0, chai_1.expect)(hasEntities).to.be.true;
        (0, chai_1.expect)(hasBlocks).to.be.true;
        (0, chai_1.expect)(hasItems).to.be.true;
        (0, chai_1.expect)(hasRecipes).to.be.true;
        (0, chai_1.expect)(hasFunctions).to.be.true;
        (0, chai_1.expect)(hasAnimations).to.be.true;
        (0, chai_1.expect)(hasLootTables).to.be.true;
        (0, chai_1.expect)(hasSpawnRules).to.be.true;
        (0, chai_1.expect)(hasScripts).to.be.true;
    });
    it("validates unique identifiers", async () => {
        const project = await _loadProject("comprehensive");
        // Test that items have unique names within their types
        const entityItems = project.items.filter((item) => item.itemType === IProjectItemData_1.ProjectItemType.entityTypeBehavior);
        const entityNames = entityItems.map((item) => item.name);
        const uniqueEntityNames = [...new Set(entityNames)];
        (0, chai_1.expect)(entityNames.length).to.equal(uniqueEntityNames.length);
    });
    it("validates content diversity metrics", async () => {
        const project = await _loadProject("comprehensive");
        // Calculate content diversity metrics
        const totalItems = project.items.length;
        const uniqueTypes = [...new Set(project.items.map((item) => item.itemType))];
        const uniqueCategories = [...new Set(project.items.map((item) => ProjectItemUtilities_1.default.getCategory(item.itemType)))];
        (0, chai_1.expect)(totalItems).to.be.greaterThan(20);
        (0, chai_1.expect)(uniqueTypes.length).to.be.greaterThan(18);
        (0, chai_1.expect)(uniqueCategories.length).to.be.greaterThan(3);
    });
});

//# sourceMappingURL=../maps/test/CartoTest.js.map
