1"use strict";
2var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3    if (k2 === undefined) k2 = k;
4    var desc = Object.getOwnPropertyDescriptor(m, k);
5    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6      desc = { enumerable: true, get: function() { return m[k]; } };
7    }
8    Object.defineProperty(o, k2, desc);
9}) : (function(o, m, k, k2) {
10    if (k2 === undefined) k2 = k;
11    o[k2] = m[k];
12}));
13var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14    Object.defineProperty(o, "default", { enumerable: true, value: v });
15}) : function(o, v) {
16    o["default"] = v;
17});
18var __importStar = (this && this.__importStar) || function (mod) {
19    if (mod && mod.__esModule) return mod;
20    var result = {};
21    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22    __setModuleDefault(result, mod);
23    return result;
24};
25var __importDefault = (this && this.__importDefault) || function (mod) {
26    return (mod && mod.__esModule) ? mod : { "default": mod };
27};
28Object.defineProperty(exports, "__esModule", { value: true });
29exports.LogBoxInspectorCodeFrame = void 0;
30/**
31 * Copyright (c) 650 Industries.
32 * Copyright (c) Meta Platforms, Inc. and affiliates.
33 *
34 * This source code is licensed under the MIT license found in the
35 * LICENSE file in the root directory of this source tree.
36 */
37const react_1 = __importDefault(require("react"));
38const react_native_1 = require("react-native");
39const LogBoxInspectorSection_1 = require("./LogBoxInspectorSection");
40const AnsiHighlight_1 = require("../UI/AnsiHighlight");
41const LogBoxButton_1 = require("../UI/LogBoxButton");
42const LogBoxStyle = __importStar(require("../UI/LogBoxStyle"));
43const constants_1 = require("../UI/constants");
44const formatProjectFilePath_1 = require("../formatProjectFilePath");
45const openFileInEditor_1 = __importDefault(require("../modules/openFileInEditor"));
46function LogBoxInspectorCodeFrame({ codeFrame }) {
47    if (codeFrame == null) {
48        return null;
49    }
50    function getFileName() {
51        return (0, formatProjectFilePath_1.formatProjectFilePath)(process.env.EXPO_PROJECT_ROOT, codeFrame?.fileName);
52    }
53    function getLocation() {
54        const location = codeFrame?.location;
55        if (location != null) {
56            return ` (${location.row}:${location.column + 1 /* Code frame columns are zero indexed */})`;
57        }
58        return null;
59    }
60    return (react_1.default.createElement(LogBoxInspectorSection_1.LogBoxInspectorSection, { heading: "Source" },
61        react_1.default.createElement(react_native_1.View, { style: styles.box },
62            react_1.default.createElement(react_native_1.View, { style: styles.frame },
63                react_1.default.createElement(react_native_1.ScrollView, { horizontal: true },
64                    react_1.default.createElement(AnsiHighlight_1.Ansi, { style: styles.content, text: codeFrame.content }))),
65            react_1.default.createElement(LogBoxButton_1.LogBoxButton, { backgroundColor: {
66                    default: 'transparent',
67                    pressed: LogBoxStyle.getBackgroundDarkColor(1),
68                }, style: styles.button, onPress: () => {
69                    (0, openFileInEditor_1.default)(codeFrame.fileName, codeFrame.location?.row ?? 0);
70                } },
71                react_1.default.createElement(react_native_1.Text, { style: styles.fileText },
72                    getFileName(),
73                    getLocation())))));
74}
75exports.LogBoxInspectorCodeFrame = LogBoxInspectorCodeFrame;
76const styles = react_native_1.StyleSheet.create({
77    box: {
78        backgroundColor: LogBoxStyle.getBackgroundColor(),
79        borderWidth: 1,
80        borderColor: '#323232',
81        marginLeft: 10,
82        marginRight: 10,
83        marginTop: 5,
84        borderRadius: 3,
85    },
86    frame: {
87        padding: 10,
88        borderBottomColor: LogBoxStyle.getTextColor(0.1),
89        borderBottomWidth: 1,
90    },
91    button: {
92        paddingTop: 10,
93        paddingBottom: 10,
94    },
95    content: {
96        color: LogBoxStyle.getTextColor(1),
97        fontSize: 12,
98        includeFontPadding: false,
99        lineHeight: 20,
100        fontFamily: constants_1.CODE_FONT,
101    },
102    fileText: {
103        userSelect: 'none',
104        color: LogBoxStyle.getTextColor(0.5),
105        textAlign: 'center',
106        flex: 1,
107        fontSize: 16,
108        includeFontPadding: false,
109        fontFamily: constants_1.CODE_FONT,
110    },
111});
112//# sourceMappingURL=LogBoxInspectorCodeFrame.js.map