function normalizeRequestArgs(httpModule, requestArgs) {
    var _a, _b, _c, _d, _e, _f, _g, _h;
    var callback, requestOptions;
    // pop off the callback, if there is one
    if (typeof requestArgs[requestArgs.length - 1] === 'function') {
        callback = requestArgs.pop();
    }
    // create a RequestOptions object of whatever's at index 0
    if (typeof requestArgs[0] === 'string') {
        requestOptions = urlToOptions(new Url$2.URL(requestArgs[0]));
    }
    else if (requestArgs[0] instanceof Url$2.URL) {
        requestOptions = urlToOptions(requestArgs[0]);
    }
    else {
        requestOptions = requestArgs[0];
    }
    // if the options were given separately from the URL, fold them in
    if (requestArgs.length === 2) {
        requestOptions = __assign$5(__assign$5({}, requestOptions), requestArgs[1]);
    }
    // Figure out the protocol if it's currently missing
    if (requestOptions.protocol === undefined) {
        // Worst case we end up populating protocol with undefined, which it already is
        /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any */
        // NOTE: Prior to Node 9, `https` used internals of `http` module, thus we don't patch it.
        // Because of that, we cannot rely on `httpModule` to provide us with valid protocol,
        // as it will always return `http`, even when using `https` module.
        //
        // See test/integrations/http.test.ts for more details on Node <=v8 protocol issue.
        if (NODE_VERSION$1.major && NODE_VERSION$1.major > 8) {
            requestOptions.protocol =
                ((_b = (_a = httpModule) === null || _a === void 0 ? void 0 : _a.globalAgent) === null || _b === void 0 ? void 0 : _b.protocol) || ((_c = requestOptions.agent) === null || _c === void 0 ? void 0 : _c.protocol) || ((_d = requestOptions._defaultAgent) === null || _d === void 0 ? void 0 : _d.protocol);
        }
        else {
            requestOptions.protocol =
                ((_e = requestOptions.agent) === null || _e === void 0 ? void 0 : _e.protocol) || ((_f = requestOptions._defaultAgent) === null || _f === void 0 ? void 0 : _f.protocol) || ((_h = (_g = httpModule) === null || _g === void 0 ? void 0 : _g.globalAgent) === null || _h === void 0 ? void 0 : _h.protocol);
        }
        /* eslint-enable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any */
    }
    // return args in standardized form
    if (callback) {
        return [requestOptions, callback];
    }
    else {
        return [requestOptions];
    }
}
Normalize inputs to `http(s).request()` and `http(s).get()`.

Legal inputs to `http(s).request()` and `http(s).get()` can take one of ten forms:
    [ RequestOptions | string | URL ],
    [ RequestOptions | string | URL, RequestCallback ],
    [ string | URL, RequestOptions ], and
    [ string | URL, RequestOptions, RequestCallback ].

This standardizes to one of two forms: [ RequestOptions ] and [ RequestOptions, RequestCallback ]. A similar thing is
done as the first step of `http(s).request()` and `http(s).get()`; this just does it early so that we can interact
with the args in a standard way.

@param requestArgs The inputs to `http(s).request()` or `http(s).get()`, as an array.

@returns Equivalent args of the form [ RequestOptions ] or [ RequestOptions, RequestCallback ].