import i from "./index.es227.js";
import S from "./index.es311.js";
const h = Symbol("internals");
function y(o) {
  return o && String(o).trim().toLowerCase();
}
function m(o) {
  return o === !1 || o == null ? o : i.isArray(o) ? o.map(m) : String(o);
}
function A(o) {
  const t = /* @__PURE__ */ Object.create(null), e = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
  let s;
  for (; s = e.exec(o); )
    t[s[1]] = s[2];
  return t;
}
const k = (o) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(o.trim());
function g(o, t, e, s, n) {
  if (i.isFunction(s))
    return s.call(this, t, e);
  if (n && (t = e), !!i.isString(t)) {
    if (i.isString(s))
      return t.indexOf(s) !== -1;
    if (i.isRegExp(s))
      return s.test(t);
  }
}
function E(o) {
  return o.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (t, e, s) => e.toUpperCase() + s);
}
function j(o, t) {
  const e = i.toCamelCase(" " + t);
  ["get", "set", "has"].forEach((s) => {
    Object.defineProperty(o, s + e, {
      value: function(n, r, f) {
        return this[s].call(this, t, n, r, f);
      },
      configurable: !0
    });
  });
}
class b {
  constructor(t) {
    t && this.set(t);
  }
  set(t, e, s) {
    const n = this;
    function r(c, l, a) {
      const u = y(l);
      if (!u)
        throw new Error("header name must be a non-empty string");
      const p = i.findKey(n, u);
      (!p || n[p] === void 0 || a === !0 || a === void 0 && n[p] !== !1) && (n[p || l] = m(c));
    }
    const f = (c, l) => i.forEach(c, (a, u) => r(a, u, l));
    if (i.isPlainObject(t) || t instanceof this.constructor)
      f(t, e);
    else if (i.isString(t) && (t = t.trim()) && !k(t))
      f(S(t), e);
    else if (i.isObject(t) && i.isIterable(t)) {
      let c = {}, l, a;
      for (const u of t) {
        if (!i.isArray(u))
          throw TypeError("Object iterator must return a key-value pair");
        c[a = u[0]] = (l = c[a]) ? i.isArray(l) ? [...l, u[1]] : [l, u[1]] : u[1];
      }
      f(c, e);
    } else
      t != null && r(e, t, s);
    return this;
  }
  get(t, e) {
    if (t = y(t), t) {
      const s = i.findKey(this, t);
      if (s) {
        const n = this[s];
        if (!e)
          return n;
        if (e === !0)
          return A(n);
        if (i.isFunction(e))
          return e.call(this, n, s);
        if (i.isRegExp(e))
          return e.exec(n);
        throw new TypeError("parser must be boolean|regexp|function");
      }
    }
  }
  has(t, e) {
    if (t = y(t), t) {
      const s = i.findKey(this, t);
      return !!(s && this[s] !== void 0 && (!e || g(this, this[s], s, e)));
    }
    return !1;
  }
  delete(t, e) {
    const s = this;
    let n = !1;
    function r(f) {
      if (f = y(f), f) {
        const c = i.findKey(s, f);
        c && (!e || g(s, s[c], c, e)) && (delete s[c], n = !0);
      }
    }
    return i.isArray(t) ? t.forEach(r) : r(t), n;
  }
  clear(t) {
    const e = Object.keys(this);
    let s = e.length, n = !1;
    for (; s--; ) {
      const r = e[s];
      (!t || g(this, this[r], r, t, !0)) && (delete this[r], n = !0);
    }
    return n;
  }
  normalize(t) {
    const e = this, s = {};
    return i.forEach(this, (n, r) => {
      const f = i.findKey(s, r);
      if (f) {
        e[f] = m(n), delete e[r];
        return;
      }
      const c = t ? E(r) : String(r).trim();
      c !== r && delete e[r], e[c] = m(n), s[c] = !0;
    }), this;
  }
  concat(...t) {
    return this.constructor.concat(this, ...t);
  }
  toJSON(t) {
    const e = /* @__PURE__ */ Object.create(null);
    return i.forEach(this, (s, n) => {
      s != null && s !== !1 && (e[n] = t && i.isArray(s) ? s.join(", ") : s);
    }), e;
  }
  [Symbol.iterator]() {
    return Object.entries(this.toJSON())[Symbol.iterator]();
  }
  toString() {
    return Object.entries(this.toJSON()).map(([t, e]) => t + ": " + e).join(`
`);
  }
  getSetCookie() {
    return this.get("set-cookie") || [];
  }
  get [Symbol.toStringTag]() {
    return "AxiosHeaders";
  }
  static from(t) {
    return t instanceof this ? t : new this(t);
  }
  static concat(t, ...e) {
    const s = new this(t);
    return e.forEach((n) => s.set(n)), s;
  }
  static accessor(t) {
    const s = (this[h] = this[h] = {
      accessors: {}
    }).accessors, n = this.prototype;
    function r(f) {
      const c = y(f);
      s[c] || (j(n, f), s[c] = !0);
    }
    return i.isArray(t) ? t.forEach(r) : r(t), this;
  }
}
b.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
i.reduceDescriptors(b.prototype, ({ value: o }, t) => {
  let e = t[0].toUpperCase() + t.slice(1);
  return {
    get: () => o,
    set(s) {
      this[e] = s;
    }
  };
});
i.freezeMethods(b);
export {
  b as default
};
//# sourceMappingURL=index.es241.js.map
