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CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAA,4BAAe,EAAC,CAAC,CAAC,CAAC,CAAA;IACjG,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS,EAAE,CAAC;QAC9B,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO;QACL,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,iCAAc,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,mCAAe,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClE,CAAA;AACH,CAAC","sourcesContent":["import { HttpExecutor } from \"builder-util-runtime\"\nimport { ClientRequest, request as httpRequest } from \"http\"\nimport { HttpProxyAgent } from \"http-proxy-agent\"\nimport * as https from \"https\"\nimport { HttpsProxyAgent } from \"https-proxy-agent\"\nimport { isEmptyOrSpaces } from \"./stringUtil\"\n\nexport class NodeHttpExecutor extends HttpExecutor<ClientRequest> {\n  // noinspection JSMethodCanBeStatic\n  // noinspection JSUnusedGlobalSymbols\n  createRequest(options: any, callback: (response: any) => void): ClientRequest {\n    if (process.env[\"https_proxy\"] !== undefined && options.protocol === \"https:\") {\n      options.agent = new HttpsProxyAgent(process.env[\"https_proxy\"])\n    } else if (process.env[\"http_proxy\"] !== undefined && options.protocol === \"http:\") {\n      options.agent = new HttpProxyAgent(process.env[\"http_proxy\"])\n    }\n    return (options.protocol === \"http:\" ? httpRequest : https.request)(options, callback)\n  }\n}\n\nexport const httpExecutor = new NodeHttpExecutor()\n\nexport function buildGotProxyAgent(): { http?: HttpProxyAgent<string>; https?: HttpsProxyAgent<string> } | undefined {\n  // Use Array.find so a whitespace-only uppercase var doesn't block the lowercase fallback.\n  const httpsProxy = [process.env.HTTPS_PROXY, process.env.https_proxy].find(v => !isEmptyOrSpaces(v))\n  const httpProxy = [process.env.HTTP_PROXY, process.env.http_proxy].find(v => !isEmptyOrSpaces(v))\n  if (!httpsProxy && !httpProxy) {\n    return undefined\n  }\n  return {\n    ...(httpProxy ? { http: new HttpProxyAgent(httpProxy) } : {}),\n    ...(httpsProxy ? { https: new HttpsProxyAgent(httpsProxy) } : {}),\n  }\n}\n"]}