import { __require as W } from "./index-utils10.js";
import { __require as v } from "./index-AxiosError.js";
import { __require as C } from "./index-FormData.js";
var p, q;
function J() {
  if (q) return p;
  q = 1;
  var i = W(), O = v(), x = C();
  function b(e) {
    return i.isPlainObject(e) || i.isArray(e);
  }
  function F(e) {
    return i.endsWith(e, "[]") ? e.slice(0, -2) : e;
  }
  function B(e, n, o) {
    return e ? e.concat(n).map(function(s, c) {
      return s = F(s), !o && c ? "[" + s + "]" : s;
    }).join(o ? "." : "") : n;
  }
  function E(e) {
    return i.isArray(e) && !e.some(b);
  }
  var S = i.toFlatObject(i, {}, null, function(n) {
    return /^is[A-Z]/.test(n);
  });
  function h(e) {
    return e && i.isFunction(e.append) && e[Symbol.toStringTag] === "FormData" && e[Symbol.iterator];
  }
  function U(e, n, o) {
    if (!i.isObject(e))
      throw new TypeError("target must be an object");
    n = n || new (x || FormData)(), o = i.toFlatObject(o, {
      metaTokens: !0,
      dots: !1,
      indexes: !1
    }, !1, function(t, u) {
      return !i.isUndefined(u[t]);
    });
    var w = o.metaTokens, s = o.visitor || _, c = o.dots, A = o.indexes, V = o.Blob || typeof Blob < "u" && Blob, T = V && h(n);
    if (!i.isFunction(s))
      throw new TypeError("visitor must be a function");
    function l(r) {
      if (r === null) return "";
      if (i.isDate(r))
        return r.toISOString();
      if (!T && i.isBlob(r))
        throw new O("Blob is not supported. Use a Buffer instead.");
      return i.isArrayBuffer(r) || i.isTypedArray(r) ? T && typeof Blob == "function" ? new Blob([r]) : Buffer.from(r) : r;
    }
    function _(r, t, u) {
      var f = r;
      if (r && !u && typeof r == "object") {
        if (i.endsWith(t, "{}"))
          t = w ? t : t.slice(0, -2), r = JSON.stringify(r);
        else if (i.isArray(r) && E(r) || i.isFileList(r) || i.endsWith(t, "[]") && (f = i.toArray(r)))
          return t = F(t), f.forEach(function(d, D) {
            !i.isUndefined(d) && n.append(
              // eslint-disable-next-line no-nested-ternary
              A === !0 ? B([t], D, c) : A === null ? t : t + "[]",
              l(d)
            );
          }), !1;
      }
      return b(r) ? !0 : (n.append(B(u, t, c), l(r)), !1);
    }
    var m = [], g = Object.assign(S, {
      defaultVisitor: _,
      convertValue: l,
      isVisitable: b
    });
    function j(r, t) {
      if (!i.isUndefined(r)) {
        if (m.indexOf(r) !== -1)
          throw Error("Circular reference detected in " + t.join("."));
        m.push(r), i.forEach(r, function(f, a) {
          var d = !i.isUndefined(f) && s.call(
            n,
            f,
            i.isString(a) ? a.trim() : a,
            t,
            g
          );
          d === !0 && j(f, t ? t.concat(a) : [a]);
        }), m.pop();
      }
    }
    if (!i.isObject(e))
      throw new TypeError("data must be an object");
    return j(e), n;
  }
  return p = U, p;
}
export {
  J as __require
};
