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BAAqB,CAAC,MAAM,EAC5B,qBAAqB,CAAC,SAAS,EAC/B,IAAI,CACL,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,OAAO,CAAC,IAAY;QAChC,OAAO,QAAQ,CAAC,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAC9D,CAAC;IAEO,MAAM,CAAC,mBAAmB,CAAC,IAAY,EAAE,QAAiC;QAChF,IAAI,MAAM,GAAW,EAAE,CAAC;QACxB,MAAM,cAAc,GAAW,QAAQ,CAAC,MAAM,CAAC;QAC/C,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC7C,MAAM,IAAI,uBAAU,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5F,CAAC;QAED,OAAO,MAAM,GAAG,uBAAU,CAAC,4BAA4B,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;IACnG,CAAC;IAEO,MAAM,CAAC,0BAA0B,CAAC,SAAiB,EAAE,OAAe,EAAE,IAAY;QACxF,OAAO,CACL,uBAAU,CAAC,4BAA4B,CAAC,SAAS,CAAC;YAClD,IAAI;YACJ,uBAAU,CAAC,4BAA4B,CAAC,OAAO,CAAC,CACjD,CAAC;IACJ,CAAC;CACF;AAtND,4BAsNC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { AnsiEscape } from './AnsiEscape';\n\nexport enum SgrParameterAttribute {\n BlackForeground = 30,\n RedForeground = 31,\n GreenForeground = 32,\n YellowForeground = 33,\n BlueForeground = 34,\n MagentaForeground = 35,\n CyanForeground = 36,\n WhiteForeground = 37,\n GrayForeground = 90,\n DefaultForeground = 39,\n\n BlackBackground = 40,\n RedBackground = 41,\n GreenBackground = 42,\n YellowBackground = 43,\n BlueBackground = 44,\n MagentaBackground = 45,\n CyanBackground = 46,\n WhiteBackground = 47,\n GrayBackground = 100,\n DefaultBackground = 49,\n\n Bold = 1,\n\n // On Linux, the \"BoldOff\" code instead causes the text to be double-underlined:\n // https://en.wikipedia.org/wiki/Talk:ANSI_escape_code#SGR_21%E2%80%94%60Bold_off%60_not_widely_supported\n // Use \"NormalColorOrIntensity\" instead\n // BoldOff = 21,\n\n Dim = 2,\n NormalColorOrIntensity = 22,\n Underline = 4,\n UnderlineOff = 24,\n Blink = 5,\n BlinkOff = 25,\n InvertColor = 7,\n InvertColorOff = 27,\n Hidden = 8,\n HiddenOff = 28\n}\n\nconst RAINBOW_SEQUENCE: SgrParameterAttribute[] = [\n SgrParameterAttribute.RedForeground,\n SgrParameterAttribute.YellowForeground,\n SgrParameterAttribute.GreenForeground,\n SgrParameterAttribute.CyanForeground,\n SgrParameterAttribute.BlueForeground,\n SgrParameterAttribute.MagentaForeground\n];\n\n/**\n * The static functions on this class are used to produce colored text\n * for use with a terminal that supports ANSI escape codes.\n *\n * Note that this API always generates color codes, regardless of whether\n * the process's stdout is a TTY. The reason is that, in a complex program, the\n * code that is generating strings often does not know were those strings will end\n * up. In some cases, the same log message may get printed both to a shell\n * that supports color AND to a log file that does not.\n *\n * @example\n * ```ts\n * console.log(Colorize.red('Red Text!'))\n * terminal.writeLine(Colorize.green('Green Text!'), ' ', Colorize.blue('Blue Text!'));\n *```\n *\n * @public\n */\nexport class Colorize {\n public static black(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.BlackForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static red(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.RedForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static green(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.GreenForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static yellow(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.YellowForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static blue(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.BlueForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static magenta(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.MagentaForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static cyan(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.CyanForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static white(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.WhiteForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static gray(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.GrayForeground,\n SgrParameterAttribute.DefaultForeground,\n text\n );\n }\n\n public static blackBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.BlackBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static redBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.RedBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static greenBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.GreenBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static yellowBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.YellowBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static blueBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.BlueBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static magentaBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.MagentaBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static cyanBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.CyanBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static whiteBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.WhiteBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static grayBackground(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.GrayBackground,\n SgrParameterAttribute.DefaultBackground,\n text\n );\n }\n\n public static bold(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.Bold,\n SgrParameterAttribute.NormalColorOrIntensity,\n text\n );\n }\n\n public static dim(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.Dim,\n SgrParameterAttribute.NormalColorOrIntensity,\n text\n );\n }\n\n public static underline(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.Underline,\n SgrParameterAttribute.UnderlineOff,\n text\n );\n }\n\n public static blink(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.Blink,\n SgrParameterAttribute.BlinkOff,\n text\n );\n }\n\n public static invertColor(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.InvertColor,\n SgrParameterAttribute.InvertColorOff,\n text\n );\n }\n\n public static hidden(text: string): string {\n return Colorize._wrapTextInAnsiEscapeCodes(\n SgrParameterAttribute.Hidden,\n SgrParameterAttribute.HiddenOff,\n text\n );\n }\n\n public static rainbow(text: string): string {\n return Colorize._applyColorSequence(text, RAINBOW_SEQUENCE);\n }\n\n private static _applyColorSequence(text: string, sequence: SgrParameterAttribute[]): string {\n let result: string = '';\n const sequenceLength: number = sequence.length;\n for (let i: number = 0; i < text.length; i++) {\n result += AnsiEscape.getEscapeSequenceForAnsiCode(sequence[i % sequenceLength]) + text[i];\n }\n\n return result + AnsiEscape.getEscapeSequenceForAnsiCode(SgrParameterAttribute.DefaultForeground);\n }\n\n private static _wrapTextInAnsiEscapeCodes(startCode: number, endCode: number, text: string): string {\n return (\n AnsiEscape.getEscapeSequenceForAnsiCode(startCode) +\n text +\n AnsiEscape.getEscapeSequenceForAnsiCode(endCode)\n );\n }\n}\n"]}