"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.n = resolveProxyFetchFromEnv;exports.t = makeProxyFetch;var _loggerU3s76KST = require("./logger-U3s76KST.js"); var _undici = require("undici"); //#region src/infra/net/proxy-fetch.ts /** * Create a fetch function that routes requests through the given HTTP proxy. * Uses undici's ProxyAgent under the hood. */ function makeProxyFetch(proxyUrl) { const agent = new _undici.ProxyAgent(proxyUrl); return (input, init) => (0, _undici.fetch)(input, { ...init, dispatcher: agent }); } /** * Resolve a proxy-aware fetch from standard environment variables * (HTTPS_PROXY, HTTP_PROXY, https_proxy, http_proxy). * Respects NO_PROXY / no_proxy exclusions via undici's EnvHttpProxyAgent. * Returns undefined when no proxy is configured. * Gracefully returns undefined if the proxy URL is malformed. */ function resolveProxyFetchFromEnv() { if (!(process.env.HTTPS_PROXY || process.env.HTTP_PROXY || process.env.https_proxy || process.env.http_proxy)?.trim()) return; try { const agent = new _undici.EnvHttpProxyAgent(); return (input, init) => (0, _undici.fetch)(input, { ...init, dispatcher: agent }); } catch (err) { (0, _loggerU3s76KST.i)(`Proxy env var set but agent creation failed — falling back to direct fetch: ${err instanceof Error ? err.message : String(err)}`); return; } } //#endregion /* v9-7c7ccba6496f0946 */