const GLOBAL_KEY = "__SENTRY_INSTRUMENTED_MAP__"; function getInstrumentedMap() { const globalObj = globalThis; if (!globalObj[GLOBAL_KEY]) { globalObj[GLOBAL_KEY] = /* @__PURE__ */ new WeakMap(); } return globalObj[GLOBAL_KEY]; } function isWeakMapKey(value) { return typeof value === "object" && value !== null || typeof value === "function"; } function markAsInstrumented(original, instrumented) { try { if (isWeakMapKey(original)) { getInstrumentedMap().set(original, instrumented ?? original); } if (isWeakMapKey(instrumented) && instrumented !== original) { getInstrumentedMap().set(instrumented, instrumented); } } catch { } } function getInstrumented(obj) { try { if (isWeakMapKey(obj)) { return getInstrumentedMap().get(obj); } return void 0; } catch { return void 0; } } function ensureInstrumented(original, instrumentFn, noMark) { const existing = getInstrumented(original); if (existing) { return existing; } const instrumented = instrumentFn(original); if (!noMark) { markAsInstrumented(original, instrumented); } return instrumented; } export { ensureInstrumented, getInstrumented, markAsInstrumented }; //# sourceMappingURL=instrument.js.map