import { debug, varlockSettings, scanForLeaks } from './chunk-PRASPAE4.js';
import { __name } from './chunk-IBAHCH6O.js';

// src/runtime/patch-response.ts
function patchGlobalResponse() {
  debug("\u26A1\uFE0F PATCHING global Response");
  if (globalThis.Response._patchedByVarlock) {
    debug("> already patched");
    return;
  }
  if (varlockSettings.preventLeaks === false) {
    debug("> disabled by settings");
    return;
  }
  const _UnpatchedResponse = globalThis.Response;
  globalThis.Response = class VarlockPatchedResponse extends _UnpatchedResponse {
    static {
      __name(this, "VarlockPatchedResponse");
    }
    static _patchedByVarlock = true;
    // Make native fetch() responses (which are instances of the original Response)
    // pass instanceof checks against the patched globalThis.Response.
    static [Symbol.hasInstance](instance) {
      return instance instanceof _UnpatchedResponse;
    }
    constructor(body, init) {
      debug("\u26A1\uFE0F patched Response constructor");
      super(scanForLeaks(body, { method: "patched Response constructor" }), init);
    }
    static json(data, init) {
      debug("\u26A1\uFE0F patched Response.json");
      scanForLeaks(JSON.stringify(data), { method: "patched Response.json" });
      const r = _UnpatchedResponse.json(data, init);
      Object.setPrototypeOf(r, Response.prototype);
      return r;
    }
  };
}
__name(patchGlobalResponse, "patchGlobalResponse");

export { patchGlobalResponse };
//# sourceMappingURL=chunk-CWWKO23R.js.map
//# sourceMappingURL=chunk-CWWKO23R.js.map