// Metro module 1078 (f1079). import { isPrimitive, defineIntegration, addGlobalErrorInstrumentationHandler, getClient, isString, stripDataUrlContent, getLocationHref, UNKNOWN_FUNCTION, captureEvent, debug, addGlobalUnhandledRejectionInstrumentationHandler } from "./Module817"; import { shouldIgnoreOnError } from "./ignoreNextOnError"; import { eventFromUnknownInput } from "./exceptionFromError_1031"; import { DEBUG_BUILD } from "./Module1072"; function $mk67647() { return () => []; } const _getUnhandledRejectionError = function _getUnhandledRejectionError(a0) { let reason, reason2; if (isPrimitive(a0)) { return a0; } L8: { L10: { L6: { try { if ("reason" in a0) { reason2 = a0.reason; break L8; } if (!("detail" in a0)) { break L10; } if ("reason" in a0.detail) { reason = a0.detail.reason; break L6; } break L10; } catch ($e) { break L10; } } return reason; } return a0; } return reason2; }; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const r17 = defineIntegration(function(r3 = {}) { let c12709_0 = { onerror: true, onunhandledrejection: true, ...r3 }; return { name: "GlobalHandlers", setupOnce: () => { Error.stackTraceLimit = 50; }, setup: (a0) => { if (c12709_0.onerror) { let c24038_0 = a0; addGlobalErrorInstrumentationHandler((a0) => { const client = getClient(); const r24 = (client == null ? void 0 : client.getOptions()) || { stackParser: $mk67647(), attachStacktrace: false }; const { stackParser: stackParser2, attachStacktrace } = r24; if (getClient() === c24038_0 && !shouldIgnoreOnError()) { const { msg, url, line, column, error } = a0; const r44 = eventFromUnknownInput(stackParser2, error || msg, void 0, attachStacktrace, false); const exception = r44.exception || {}; r44.exception = exception; const values = exception.values || []; exception.values = values; const r47 = values[0] || {}; values[0] = r47; const stacktrace = r47.stacktrace || {}; r47.stacktrace = stacktrace; const frames = stacktrace.frames || []; stacktrace.frames = frames; let filename = isString(url) ? url.length !== 0 ? url.startsWith("data:") ? `<${stripDataUrlContent(url, false)}>` : url : void 0 : void 0; if (filename == null) { filename = getLocationHref(); } if (frames.length === 0) { frames.push({ colno: column, filename, function: UNKNOWN_FUNCTION, in_app: true, lineno: line }); } r44.level = "error"; captureEvent(r44, { originalException: error, mechanism: { handled: false, type: "auto.browser.global_handlers.onerror" } }); } }); if (DEBUG_BUILD) { debug.log(`Global Handler attached: onerror`); } } if (c12709_0.onunhandledrejection) { let c24039_0 = a0; addGlobalUnhandledRejectionInstrumentationHandler((a0) => { const client = getClient(); const r20 = (client == null ? void 0 : client.getOptions()) || { stackParser: $mk67647(), attachStacktrace: false }; const { stackParser: stackParser2, attachStacktrace } = r20; if (getClient() === c24039_0 && !shouldIgnoreOnError()) { const originalException = _getUnhandledRejectionError(a0); const r44 = isPrimitive(originalException) ? { exception: { values: [{ type: "UnhandledRejection", value: `Non-Error promise rejection captured with value: ${String(originalException)}` }] } } : eventFromUnknownInput(stackParser2, originalException, void 0, attachStacktrace, true); r44.level = "error"; captureEvent(r44, { originalException, mechanism: { handled: false, type: "auto.browser.global_handlers.onunhandledrejection" } }); } }); if (DEBUG_BUILD) { debug.log(`Global Handler attached: onunhandledrejection`); } } } }; }); export function _eventFromRejectionWithPrimitive(a0) { return { exception: { values: [{ type: "UnhandledRejection", value: `Non-Error promise rejection captured with value: ${String(a0)}` }] } }; } export { _getUnhandledRejectionError }; export { r17 as globalHandlersIntegration };