const l = (r, s) => {
  let e = window.location.search || "";
  if (r && r !== location.href) {
    const t = r.indexOf("?");
    t !== -1 ? e = r.slice(t) : e = "";
  }
  const n = new URLSearchParams(e);
  if (s)
    return n.get(s);
  {
    let t = {};
    for (let [o, a] of n.entries())
      t[o] = a;
    return t;
  }
}, f = (r, s = {}) => {
  let e = "", n = "";
  const t = Object.keys(s);
  return t && t.length && t.forEach((o, a) => {
    a === t.length - 1 ? n += `${o}=${s[o]}` : n += `${o}=${s[o]}&`;
  }), n ? e = location.origin + r + `?${n}` : e = location.origin + r, e;
}, h = (r, s) => {
  const e = s || location.href, n = l(e), t = Object.keys(n) || [];
  if (!t || !t.length) return e.includes("?") ? e.split("?")[0] : e.split("&")[0];
  let o = t.filter((i) => !r.includes(i));
  if (!o || !o.length) return e.includes("?") ? e.split("?")[0] : e.split("&")[0];
  let a = "";
  return o.forEach((i, c) => {
    c === t.length - 1 ? a += `${i}=${n[i]}` : a += `${i}=${n[i]}&`;
  }), e.includes("?") ? e.split("?")[0] + `?${a}` : e.split("&")[0] + `?${a}`;
}, u = (r) => {
  const s = new URLSearchParams(r.split("?")[1]), e = {};
  for (const [n, t] of s)
    e.hasOwnProperty(n) ? Array.isArray(e[n]) ? e[n].push(t) : e[n] = [e[n], t] : e[n] = t;
  return e;
}, g = (r) => {
  let s = "";
  const e = Object.keys(r);
  return e && e.length && e.forEach((n, t) => {
    t === e.length - 1 ? s += `${n}=${r[n]}` : s += `${n}=${r[n]}&`;
  }), s;
}, p = (r, s) => {
  const e = new URL(r, location.origin);
  let { origin: n, pathname: t } = e;
  t === "/" && (t = ""), s.map((a) => t += `/${a}`);
  const o = new URL(`${n}${t}`);
  return e.searchParams.forEach((a, i) => {
    o.searchParams.append(i, a);
  }), o.toString();
};
function m(r, s) {
  const e = new URL(r, window.location.origin);
  return Object.entries(s).forEach(([n, t]) => {
    e.searchParams.set(n, t);
  }), e.toString();
}
function $(r) {
  const s = /^(https?:\/\/[^/]+)/, e = r.match(s);
  return e && e.length > 1 ? e[1] : null;
}
export {
  p as addPathParamsToUrl,
  m as appendQueryParams,
  h as funcUrlDel,
  f as getFullPath,
  $ as getOriginFromUrl,
  l as getUrlParams,
  g as objectToUrlparams,
  u as urlParamsToObject
};
