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BAAI,IAAC,KAAK,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,GAAG,IACtC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CACxB,CACR,CAAC;IACJ,CAAC,CAAC,CACG,CACR,CAAC,CACG,CACR,CAAC;AACJ,CAAC;AAzDD,oBAyDC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE;QACJ,aAAa,EAAE,KAAK;KACrB;CACF,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport Anser from 'anser';\nimport React from 'react';\nimport { StyleProp, StyleSheet, Text, TextStyle, View } from 'react-native';\n\n// Afterglow theme from https://iterm2colorschemes.com/\nconst COLORS: Record<string, string> = {\n  'ansi-black': 'rgb(27, 27, 27)',\n  'ansi-red': 'rgb(187, 86, 83)',\n  'ansi-green': 'rgb(144, 157, 98)',\n  'ansi-yellow': 'rgb(234, 193, 121)',\n  'ansi-blue': 'rgb(125, 169, 199)',\n  'ansi-magenta': 'rgb(176, 101, 151)',\n  'ansi-cyan': 'rgb(140, 220, 216)',\n  // Instead of white, use the default color provided to the component\n  // 'ansi-white': 'rgb(216, 216, 216)',\n  'ansi-bright-black': 'rgb(98, 98, 98)',\n  'ansi-bright-red': 'rgb(187, 86, 83)',\n  'ansi-bright-green': 'rgb(144, 157, 98)',\n  'ansi-bright-yellow': 'rgb(234, 193, 121)',\n  'ansi-bright-blue': 'rgb(125, 169, 199)',\n  'ansi-bright-magenta': 'rgb(176, 101, 151)',\n  'ansi-bright-cyan': 'rgb(140, 220, 216)',\n  'ansi-bright-white': 'rgb(247, 247, 247)',\n};\n\nexport function Ansi({ text, style }: { text: string; style: StyleProp<TextStyle> }) {\n  let commonWhitespaceLength = Infinity;\n  const parsedLines = text.split(/\\n/).map((line) =>\n    Anser.ansiToJson(line, {\n      json: true,\n      remove_empty: true,\n      use_classes: true,\n    })\n  );\n\n  parsedLines.map((lines) => {\n    // The third item on each line includes the whitespace of the source code.\n    // We are looking for the least amount of common whitespace to trim all lines.\n    // Example: Array [\" \", \" 96 |\", \"     text\", ...]\n    const match = lines[2] && lines[2]?.content?.match(/^ +/);\n    const whitespaceLength = (match && match[0]?.length) || 0;\n    if (whitespaceLength < commonWhitespaceLength) {\n      commonWhitespaceLength = whitespaceLength;\n    }\n  });\n\n  const getText = (content: string, key: number) => {\n    if (key === 1) {\n      // Remove the vertical bar after line numbers\n      return content.replace(/\\| $/, ' ');\n    } else if (key === 2 && commonWhitespaceLength < Infinity) {\n      // Remove common whitespace at the beginning of the line\n      return content.substr(commonWhitespaceLength);\n    } else {\n      return content;\n    }\n  };\n\n  return (\n    <View>\n      {parsedLines.map((items, i) => (\n        <View style={styles.line} key={i}>\n          {items.map((bundle, key) => {\n            const textStyle =\n              bundle.fg && COLORS[bundle.fg]\n                ? {\n                    backgroundColor: bundle.bg && COLORS[bundle.bg],\n                    color: bundle.fg && COLORS[bundle.fg],\n                  }\n                : {\n                    backgroundColor: bundle.bg && COLORS[bundle.bg],\n                  };\n            return (\n              <Text style={[style, textStyle]} key={key}>\n                {getText(bundle.content, key)}\n              </Text>\n            );\n          })}\n        </View>\n      ))}\n    </View>\n  );\n}\n\nconst styles = StyleSheet.create({\n  line: {\n    flexDirection: 'row',\n  },\n});\n"]}