const browser = require('@sentry/browser');
const utils = require('@sentry/utils');

const STACKTRACE_FRAME_LIMIT = 50;
const [, chrome] = browser.chromeStackLineParser;
const [, node] = utils.nodeStackLineParser();
/**
 * A stack parser than combines Chrome and node.js parsers to give the best results even when nodeIntegration = true
 */
const electronRendererStackParser = (stack, skipFirst = 0) => {
    const frames = [];
    for (const line of stack.split('\n').slice(skipFirst)) {
        const chromeFrame = chrome(line);
        const nodeFrame = node(line);
        // We favour the chrome parser unless in_app == false
        if (chromeFrame && (nodeFrame === null || nodeFrame === void 0 ? void 0 : nodeFrame.in_app) !== false) {
            frames.push(chromeFrame);
        }
        else if (nodeFrame) {
            frames.push(utils.dropUndefinedKeys(nodeFrame));
        }
        if (frames.length >= STACKTRACE_FRAME_LIMIT) {
            break;
        }
    }
    return utils.stripSentryFramesAndReverse(frames);
};

exports.electronRendererStackParser = electronRendererStackParser;
//# sourceMappingURL=stack-parse.js.map
