import i from "../utils.mjs";
import h from "./AxiosHeaders.mjs";
const c = (s) => s instanceof h ? s.toJSON() : s;
function C(s, d) {
  d = d || {};
  const f = {};
  function o(t, e, r) {
    return i.isPlainObject(t) && i.isPlainObject(e) ? i.merge.call({ caseless: r }, t, e) : i.isPlainObject(e) ? i.merge({}, e) : i.isArray(e) ? e.slice() : e;
  }
  function u(t, e, r) {
    if (i.isUndefined(e)) {
      if (!i.isUndefined(t))
        return o(void 0, t, r);
    } else
      return o(t, e, r);
  }
  function a(t, e) {
    if (!i.isUndefined(e))
      return o(void 0, e);
  }
  function n(t, e) {
    if (i.isUndefined(e)) {
      if (!i.isUndefined(t))
        return o(void 0, t);
    } else
      return o(void 0, e);
  }
  function l(t, e, r) {
    if (r in d)
      return o(t, e);
    if (r in s)
      return o(void 0, t);
  }
  const g = {
    url: a,
    method: a,
    data: a,
    baseURL: n,
    transformRequest: n,
    transformResponse: n,
    paramsSerializer: n,
    timeout: n,
    timeoutMessage: n,
    withCredentials: n,
    withXSRFToken: n,
    adapter: n,
    responseType: n,
    xsrfCookieName: n,
    xsrfHeaderName: n,
    onUploadProgress: n,
    onDownloadProgress: n,
    decompress: n,
    maxContentLength: n,
    maxBodyLength: n,
    beforeRedirect: n,
    transport: n,
    httpAgent: n,
    httpsAgent: n,
    cancelToken: n,
    socketPath: n,
    responseEncoding: n,
    validateStatus: l,
    headers: (t, e) => u(c(t), c(e), !0)
  };
  return i.forEach(Object.keys(Object.assign({}, s, d)), function(e) {
    const r = g[e] || u, m = r(s[e], d[e], e);
    i.isUndefined(m) && r !== l || (f[e] = m);
  }), f;
}
export {
  C as default
};
