"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValidGeneratorTest = void 0;
const ProjectInfoItem_1 = require("./ProjectInfoItem");
const IInfoItemData_1 = require("./IInfoItemData");
const StorageUtilities_1 = require("../storage/StorageUtilities");
var ValidGeneratorTest;
(function (ValidGeneratorTest) {
    ValidGeneratorTest[ValidGeneratorTest["nonCompliantJson"] = 102] = "nonCompliantJson";
    ValidGeneratorTest[ValidGeneratorTest["emptyJson"] = 103] = "emptyJson";
    ValidGeneratorTest[ValidGeneratorTest["jsonNotString"] = 104] = "jsonNotString";
})(ValidGeneratorTest = exports.ValidGeneratorTest || (exports.ValidGeneratorTest = {}));
class ValidFileGenerator {
    id = "VALFILE";
    title = "Valid files";
    getTopicData(topicId) {
        return {
            title: topicId.toString(),
        };
    }
    summarize(info, infoSet) { }
    async generate(project, file, contentIndex) {
        const items = [];
        if (StorageUtilities_1.default.getMimeType(file) === "application/json") {
            if (!file.isString) {
                items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.error, this.id, ValidGeneratorTest.jsonNotString, `JSON file is not a string`, project.getItemByExtendedOrProjectPath(file.extendedPath), file.content ? file.content.length + " bytes" : "unloadable"));
            }
            else if (!file.content || file.content?.length < 2) {
                items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.error, this.id, ValidGeneratorTest.emptyJson, `JSON file is empty`, project.getItemByExtendedOrProjectPath(file.extendedPath), file.content ? file.content.length + " characters" : "unloadable"));
            }
            else {
                StorageUtilities_1.default.getJsonObject(file);
                if (file.isInErrorState) {
                    items.push(new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.error, this.id, ValidGeneratorTest.nonCompliantJson, `JSON file is not JSON compliant`, project.getItemByExtendedOrProjectPath(file.extendedPath), file.errorStateMessage ? file.errorStateMessage : "unparseable"));
                }
            }
        }
        return items;
    }
}
exports.default = ValidFileGenerator;

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