const i = function(n, t = location.hash) {
  const e = new RegExp("[#?&]" + n + "=([^&]*)"), r = t.match(e);
  return !r || r.length != 2 ? "" : (r[1] = decodeURIComponent(r[1]), r[1] = r[1].replace(/\+/g, " "), r[1]);
}, f = function(n, t, e = !0) {
  let r = p(n, t);
  s(!!e, r);
}, l = function(n, t, e = !0) {
  f(n, null, e);
}, p = function(n, t, e = location.hash) {
  const r = new RegExp("&?" + n + "=[^&]*", "g");
  return e = e.replace(r, ""), t !== null && (t = (t + "").replace(" ", "%20"), e = e.replace(r, "&" + n + "=" + t), e.indexOf("&" + n + "=") == -1 && (e += "&" + n + "=" + t)), e = e.replace(/&+/g, "&"), e = e.replace(/^(#)?&|&$/g, "$1"), e = "#" + e, e = e.replace(/^#+/, "#"), e === "#" && (e = ""), e;
}, u = function(n, t) {
  n instanceof Map && (n = Object.fromEntries(n)), t === void 0 && (t = !0);
  let e = location.hash;
  for (const r in n) {
    const c = new RegExp("&?" + r + "=[^&]*", "g");
    e = e.replace(c, ""), n[r] !== null && (n[r] = (n[r] + "").replace(" ", "%20"), e += "&" + r + "=" + n[r]);
  }
  e = e.replace(/&+/g, "&"), e = e.replace(/^(#)?&|&$/g, "$1"), e = "#" + e, e = e.replace(/^#+/, "#"), e === "#" && (e = ""), s(!!t, e);
}, s = (n = !1, t) => {
  if (t === location.hash) return;
  const e = location.href, r = location.href.replace(/#.*/, "") + t;
  n ? history.replaceState(history.state, "", r) : history.pushState(history.state, "", r);
  const c = new HashChangeEvent("hashchange", {
    oldURL: e,
    newURL: r
  });
  window.dispatchEvent(c);
};
export {
  l as delHash,
  p as genHash,
  i as getHash,
  s as historySetState,
  f as setHash,
  u as setHashs
};
//# sourceMappingURL=route.js.map
