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KAAK,iBAAiB,GACzC,QAAQ,UACH,KAAK,IAAM,KAAK,QAAQ,EAAK,IAC7B,KAAM,IAEP,GADA,KAAK,iBAAiB,EAAM,GAER,mBADT,EACN,WACD,IACI,OAAO,EAAO,WAAW,EAAK,EAClC,CACA,MAAO,GACH,OAAO,EAAG,EACd,CAEJ,KAAK,UAAU,cAAgB,EAE/B,MAAM,aAAa,EAAK,EAAS,IACjC,IACA,KAAK,iBAAiB,EAAM,GAC5B,EAAG,IAEX,CACA,gBAAA,GACI,MAAM,EAAS,KAAK,UAAU,cAE9B,GADA,KAAK,UAAU,mBAAgB,GAC1B,EACD,MAAM,IAAI,MAAM,sDAEpB,OAAO,CACX,CACA,eAAI,GACA,OAAQ,KAAK,UAAU,cACA,WAAlB,KAAK,SAAwB,IAAM,GAC5C,CACA,eAAI,CAAY,GACR,KAAK,YACL,KAAK,UAAU,YAAc,EAErC,CACA,YAAI,GACA,OAAQ,KAAK,UAAU,WAClB,KAAK,mBAAqB,SAAW,QAC9C,CACA,YAAI,CAAS,GACL,KAAK,YACL,KAAK,UAAU,SAAW,EAElC","file":"/npm/agent-base@9.0.0/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.48.0.\n * Original file: /npm/agent-base@9.0.0/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import * as net from 'net';\nimport * as http from 'http';\nimport { Agent as HttpsAgent } from 'https';\nexport * from './helpers.js';\nconst INTERNAL = Symbol('AgentBaseInternalState');\nexport class Agent extends http.Agent {\n    constructor(opts) {\n        super(opts);\n        this[INTERNAL] = {};\n    }\n    /**\n     * Determine whether this is an `http` or `https` request.\n     */\n    isSecureEndpoint(options) {\n        if (options) {\n            // First check the `secureEndpoint` property explicitly, since this\n            // means that a parent `Agent` is \"passing through\" to this instance.\n            // eslint-disable-next-line @typescript-eslint/no-explicit-any\n            if (typeof options.secureEndpoint === 'boolean') {\n                return options.secureEndpoint;\n            }\n            // If no explicit `secure` endpoint, check if `protocol` property is\n            // set. This will usually be the case since using a full string URL\n            // or `URL` instance should be the most common usage.\n            if (typeof options.protocol === 'string') {\n                return options.protocol === 'https:';\n            }\n        }\n        // Finally, if no `protocol` property was set, then fall back to\n        // checking the stack trace of the current call stack, and try to\n        // detect the \"https\" module.\n        const { stack } = new Error();\n        if (typeof stack !== 'string')\n            return false;\n        return stack\n            .split('\\n')\n            .some((l) => l.indexOf('(https.js:') !== -1 ||\n            l.indexOf('node:https:') !== -1);\n    }\n    // In order to support async signatures in `connect()` and Node's native\n    // connection pooling in `http.Agent`, the array of sockets for each origin\n    // has to be updated synchronously. This is so the length of the array is\n    // accurate when `addRequest()` is next called. We achieve this by creating a\n    // fake socket and adding it to `sockets[origin]` and incrementing\n    // `totalSocketCount`.\n    incrementSockets(name) {\n        // If `maxSockets` and `maxTotalSockets` are both Infinity then there is no\n        // need to create a fake socket because Node.js native connection pooling\n        // will never be invoked.\n        if (this.maxSockets === Infinity && this.maxTotalSockets === Infinity) {\n            return null;\n        }\n        // All instances of `sockets` are expected TypeScript errors. The\n        // alternative is to add it as a private property of this class but that\n        // will break TypeScript subclassing.\n        if (!this.sockets[name]) {\n            // @ts-expect-error `sockets` is readonly in `@types/node`\n            this.sockets[name] = [];\n        }\n        const fakeSocket = new net.Socket({ writable: false });\n        this.sockets[name].push(fakeSocket);\n        // @ts-expect-error `totalSocketCount` isn't defined in `@types/node`\n        this.totalSocketCount++;\n        return fakeSocket;\n    }\n    decrementSockets(name, socket) {\n        if (!this.sockets[name] || socket === null) {\n            return;\n        }\n        const sockets = this.sockets[name];\n        const index = sockets.indexOf(socket);\n        if (index !== -1) {\n            sockets.splice(index, 1);\n            // @ts-expect-error  `totalSocketCount` isn't defined in `@types/node`\n            this.totalSocketCount--;\n            if (sockets.length === 0) {\n                // @ts-expect-error `sockets` is readonly in `@types/node`\n                delete this.sockets[name];\n            }\n        }\n    }\n    // In order to properly update the socket pool, we need to call `getName()` on\n    // the core `https.Agent` if it is a secureEndpoint.\n    getName(options) {\n        const secureEndpoint = this.isSecureEndpoint(options);\n        if (secureEndpoint) {\n            return HttpsAgent.prototype.getName.call(this, options);\n        }\n        return super.getName(options);\n    }\n    createSocket(req, options, cb) {\n        const connectOpts = {\n            ...options,\n            secureEndpoint: this.isSecureEndpoint(options),\n        };\n        const name = this.getName(connectOpts);\n        const fakeSocket = this.incrementSockets(name);\n        Promise.resolve()\n            .then(() => this.connect(req, connectOpts))\n            .then((socket) => {\n            this.decrementSockets(name, fakeSocket);\n            if (typeof socket\n                .addRequest === 'function') {\n                try {\n                    return socket.addRequest(req, connectOpts);\n                }\n                catch (err) {\n                    return cb(err);\n                }\n            }\n            this[INTERNAL].currentSocket = socket;\n            // @ts-expect-error `createSocket()` isn't defined in `@types/node`\n            super.createSocket(req, options, cb);\n        }, (err) => {\n            this.decrementSockets(name, fakeSocket);\n            cb(err);\n        });\n    }\n    createConnection() {\n        const socket = this[INTERNAL].currentSocket;\n        this[INTERNAL].currentSocket = undefined;\n        if (!socket) {\n            throw new Error('No socket was returned in the `connect()` function');\n        }\n        return socket;\n    }\n    get defaultPort() {\n        return (this[INTERNAL].defaultPort ??\n            (this.protocol === 'https:' ? 443 : 80));\n    }\n    set defaultPort(v) {\n        if (this[INTERNAL]) {\n            this[INTERNAL].defaultPort = v;\n        }\n    }\n    get protocol() {\n        return (this[INTERNAL].protocol ??\n            (this.isSecureEndpoint() ? 'https:' : 'http:'));\n    }\n    set protocol(v) {\n        if (this[INTERNAL]) {\n            this[INTERNAL].protocol = v;\n        }\n    }\n}\n"]}