// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.

const resetColor = "\x1b[0m";
const brightColor = "\x1b[1m";
const highlightColor = "\x1b[31m";

try {
    const invisibleCharactersLength = resetColor.length + brightColor.length + highlightColor.length;

    const firstLine = `Active development of this SDK has been moved to ${highlightColor}@azure/cognitiveservices-customvision-training${resetColor}${brightColor} package.`;
    const secondLine = "This package is in maintenance mode and will be deprecated in July 2019.";
    const thirdLine = "Visit https://aka.ms/azure-sdk-for-js-migration for more information.";

    const framePadding = 4;
    const adjustedFirstLineLength = firstLine.length - invisibleCharactersLength;
    const width = Math.max(adjustedFirstLineLength, secondLine.length, thirdLine.length) + framePadding;
    const getPaddingLength = (strLength) => width - strLength - framePadding;

    const firstLinePaddingLength = getPaddingLength(adjustedFirstLineLength);
    const secondLinePaddingLength = getPaddingLength(secondLine.length);
    const thirdLinePaddingLength = getPaddingLength(thirdLine.length);
    const line = "#".repeat(width);

    const formatTextLine = (text, padding) => `#${" ".repeat(Math.floor(padding / 2))} ${text} ${" ".repeat(Math.ceil(padding / 2))}#`;

    console.log(brightColor);
    console.log("\n" + line);
    console.log(formatTextLine(firstLine, firstLinePaddingLength));
    console.log(formatTextLine(secondLine, secondLinePaddingLength));
    console.log(formatTextLine(thirdLine, thirdLinePaddingLength));
    console.log(line + "\n");
    console.log(resetColor);
} catch (err) {
    // ignore
}
