const l = async (a, t, r) => {
  const n = document.createElement("form");
  n.target = r, n.action = a, n.method = "post", f(n, t), document.body.appendChild(n), n.submit(), n.remove();
}, f = (a, t) => {
  const r = c(t);
  for (const [n, e] of r.entries()) {
    if (e instanceof File)
      throw new Error("Files can not be manual set in `HTMLFormElement`");
    const o = document.createElement("input");
    o.name = n, o.value = String(e), a.appendChild(o);
  }
}, c = (a, t = new FormData(), r) => {
  for (const [n, e] of Object.entries(a)) {
    if (e == null) continue;
    const o = r ? `${r}[${n}]` : n;
    switch (!0) {
      case e instanceof File:
        t.append(o, e, e.name);
        break;
      case e instanceof FileList:
        for (let i = 0; i < e.length; i++) {
          const s = e.item(i);
          s && t.append(o + "[]", s, s.name);
        }
        break;
      case e instanceof Blob:
        t.append(o, e);
        break;
      case Array.isArray(e):
        e.forEach((i, s) => {
          c({ [o + "[" + s + "]"]: i }, t);
        });
        break;
      case e instanceof Date:
        t.append(o, e.toISOString());
        break;
      case typeof e == "object":
        c(e, t, o);
        break;
      default:
        t.append(o, String(e));
    }
  }
  return t;
}, p = (a) => {
  const t = new URLSearchParams(), r = (n, e) => {
    if (e != null) {
      if (Array.isArray(e)) {
        for (const [o, i] of Object.entries(e))
          r(`${n}[${o}]`, i);
        return;
      }
      if (typeof e == "object") {
        for (const [o, i] of Object.entries(e))
          r(`${n}[${o}]`, i);
        return;
      }
      t.append(n, String(e));
    }
  };
  for (const [n, e] of Object.entries(a))
    r(n, e);
  return t.toString();
};
export {
  f as dataToForm,
  c as formDataSerializer,
  l as postInWindow,
  p as querySerializer
};
//# sourceMappingURL=lazy-40pjr8cZ.es.js.map
