"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
const Utilities_1 = require("../core/Utilities");
const IUpdateResult_1 = require("./IUpdateResult");
class ProjectUpdateResult {
    #data;
    get dataObject() {
        return this.#data;
    }
    get resultType() {
        return this.#data.resultType;
    }
    get message() {
        return this.#data.message;
    }
    get updaterId() {
        return this.#data.updaterId;
    }
    get updaterIndex() {
        return this.#data.updaterIndex;
    }
    get data() {
        return this.#data.data;
    }
    get content() {
        return this.#data.content;
    }
    get contentSummary() {
        let errorContent = this.#data.content;
        if (errorContent) {
            errorContent = errorContent.replace(/\n/gi, " ");
            errorContent = errorContent.replace(/\r/gi, " ");
            if (errorContent.length > 80) {
                errorContent = errorContent.substring(0, 77) + "...";
            }
        }
        return errorContent;
    }
    get typeSummary() {
        switch (this.#data.resultType) {
            case IUpdateResult_1.UpdateResultType.noChange:
                return "No changes";
            case IUpdateResult_1.UpdateResultType.updatedFile:
                return "Updated file";
            default:
                return "Unknown";
        }
    }
    get typeSummaryShort() {
        let short = this.typeSummary.toUpperCase();
        short = short.replace(/\s/g, "");
        return short;
    }
    toString() {
        let summaryString = this.typeSummaryShort + ": ";
        summaryString += "[" + this.updaterId + Utilities_1.default.frontPadToLength(this.updaterIndex, 3, "0") + "] ";
        summaryString += this.message;
        if (this.data) {
            summaryString += ": " + this.data;
        }
        const errorContent = this.contentSummary;
        if (errorContent) {
            summaryString += " [in " + errorContent + "]";
        }
        return summaryString;
    }
    constructor(resultType, updaterId, updaterIndex, message, projectItem, data, itemId, content) {
        this.#data = {
            resultType: resultType,
            updaterId: updaterId,
            updaterIndex: updaterIndex,
            message: message,
            itemStoragePath: projectItem ? projectItem.projectPath : undefined,
            data: data,
            itemId: itemId,
            content: content,
        };
    }
}
exports.default = ProjectUpdateResult;

//# sourceMappingURL=../maps/updates/ProjectUpdateResult.js.map
