import * as u from "react";
/**
 * react-router v7.7.0
 *
 * Copyright (c) Remix Software Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE.md file in the root directory of this source tree.
 *
 * @license MIT
 */
var re = "popstate";
function be(e = {}) {
  function t(a, r) {
    let { pathname: o, search: s, hash: c } = a.location;
    return G(
      "",
      { pathname: o, search: s, hash: c },
      // state defaults to `null` because `window.history.state` does
      r.state && r.state.usr || null,
      r.state && r.state.key || "default"
    );
  }
  function n(a, r) {
    return typeof r == "string" ? r : M(r);
  }
  return Se(
    t,
    n,
    null,
    e
  );
}
function C(e, t) {
  if (e === !1 || e === null || typeof e > "u")
    throw new Error(t);
}
function P(e, t) {
  if (!e) {
    typeof console < "u" && console.warn(t);
    try {
      throw new Error(t);
    } catch {
    }
  }
}
function Pe() {
  return Math.random().toString(36).substring(2, 10);
}
function ae(e, t) {
  return {
    usr: e.state,
    key: e.key,
    idx: t
  };
}
function G(e, t, n = null, a) {
  return {
    pathname: typeof e == "string" ? e : e.pathname,
    search: "",
    hash: "",
    ...typeof t == "string" ? B(t) : t,
    state: n,
    // TODO: This could be cleaned up.  push/replace should probably just take
    // full Locations now and avoid the need to run through this flow at all
    // But that's a pretty big refactor to the current test suite so going to
    // keep as is for the time being and just let any incoming keys take precedence
    key: t && t.key || a || Pe()
  };
}
function M({
  pathname: e = "/",
  search: t = "",
  hash: n = ""
}) {
  return t && t !== "?" && (e += t.charAt(0) === "?" ? t : "?" + t), n && n !== "#" && (e += n.charAt(0) === "#" ? n : "#" + n), e;
}
function B(e) {
  let t = {};
  if (e) {
    let n = e.indexOf("#");
    n >= 0 && (t.hash = e.substring(n), e = e.substring(0, n));
    let a = e.indexOf("?");
    a >= 0 && (t.search = e.substring(a), e = e.substring(0, a)), e && (t.pathname = e);
  }
  return t;
}
function Se(e, t, n, a = {}) {
  let { window: r = document.defaultView, v5Compat: o = !1 } = a, s = r.history, c = "POP", i = null, l = f();
  l == null && (l = 0, s.replaceState({ ...s.state, idx: l }, ""));
  function f() {
    return (s.state || { idx: null }).idx;
  }
  function h() {
    c = "POP";
    let y = f(), d = y == null ? null : y - l;
    l = y, i && i({ action: c, location: p.location, delta: d });
  }
  function m(y, d) {
    c = "PUSH";
    let x = G(p.location, y, d);
    l = f() + 1;
    let w = ae(x, l), R = p.createHref(x);
    try {
      s.pushState(w, "", R);
    } catch (E) {
      if (E instanceof DOMException && E.name === "DataCloneError")
        throw E;
      r.location.assign(R);
    }
    o && i && i({ action: c, location: p.location, delta: 1 });
  }
  function v(y, d) {
    c = "REPLACE";
    let x = G(p.location, y, d);
    l = f();
    let w = ae(x, l), R = p.createHref(x);
    s.replaceState(w, "", R), o && i && i({ action: c, location: p.location, delta: 0 });
  }
  function g(y) {
    return Le(y);
  }
  let p = {
    get action() {
      return c;
    },
    get location() {
      return e(r, s);
    },
    listen(y) {
      if (i)
        throw new Error("A history only accepts one active listener");
      return r.addEventListener(re, h), i = y, () => {
        r.removeEventListener(re, h), i = null;
      };
    },
    createHref(y) {
      return t(r, y);
    },
    createURL: g,
    encodeLocation(y) {
      let d = g(y);
      return {
        pathname: d.pathname,
        search: d.search,
        hash: d.hash
      };
    },
    push: m,
    replace: v,
    go(y) {
      return s.go(y);
    }
  };
  return p;
}
function Le(e, t = !1) {
  let n = "http://localhost";
  typeof window < "u" && (n = window.location.origin !== "null" ? window.location.origin : window.location.href), C(n, "No window.location.(origin|href) available to create URL");
  let a = typeof e == "string" ? e : M(e);
  return a = a.replace(/ $/, "%20"), !t && a.startsWith("//") && (a = n + a), new URL(a, n);
}
function ue(e, t, n = "/") {
  return ke(e, t, n, !1);
}
function ke(e, t, n, a) {
  let r = typeof t == "string" ? B(t) : t, o = k(r.pathname || "/", n);
  if (o == null)
    return null;
  let s = se(e);
  $e(s);
  let c = null;
  for (let i = 0; c == null && i < s.length; ++i) {
    let l = We(o);
    c = Oe(
      s[i],
      l,
      a
    );
  }
  return c;
}
function se(e, t = [], n = [], a = "") {
  let r = (o, s, c) => {
    let i = {
      relativePath: c === void 0 ? o.path || "" : c,
      caseSensitive: o.caseSensitive === !0,
      childrenIndex: s,
      route: o
    };
    i.relativePath.startsWith("/") && (C(
      i.relativePath.startsWith(a),
      `Absolute route path "${i.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`
    ), i.relativePath = i.relativePath.slice(a.length));
    let l = L([a, i.relativePath]), f = n.concat(i);
    o.children && o.children.length > 0 && (C(
      // Our types know better, but runtime JS may not!
      // @ts-expect-error
      o.index !== !0,
      `Index routes must not have child routes. Please remove all child routes from route path "${l}".`
    ), se(o.children, t, f, l)), !(o.path == null && !o.index) && t.push({
      path: l,
      score: Be(l, o.index),
      routesMeta: f
    });
  };
  return e.forEach((o, s) => {
    if (o.path === "" || !o.path?.includes("?"))
      r(o, s);
    else
      for (let c of ce(o.path))
        r(o, s, c);
  }), t;
}
function ce(e) {
  let t = e.split("/");
  if (t.length === 0) return [];
  let [n, ...a] = t, r = n.endsWith("?"), o = n.replace(/\?$/, "");
  if (a.length === 0)
    return r ? [o, ""] : [o];
  let s = ce(a.join("/")), c = [];
  return c.push(
    ...s.map(
      (i) => i === "" ? o : [o, i].join("/")
    )
  ), r && c.push(...s), c.map(
    (i) => e.startsWith("/") && i === "" ? "/" : i
  );
}
function $e(e) {
  e.sort(
    (t, n) => t.score !== n.score ? n.score - t.score : Ae(
      t.routesMeta.map((a) => a.childrenIndex),
      n.routesMeta.map((a) => a.childrenIndex)
    )
  );
}
var Fe = /^:[\w-]+$/, Ie = 3, Ne = 2, Te = 1, De = 10, Me = -2, oe = (e) => e === "*";
function Be(e, t) {
  let n = e.split("/"), a = n.length;
  return n.some(oe) && (a += Me), t && (a += Ne), n.filter((r) => !oe(r)).reduce(
    (r, o) => r + (Fe.test(o) ? Ie : o === "" ? Te : De),
    a
  );
}
function Ae(e, t) {
  return e.length === t.length && e.slice(0, -1).every((a, r) => a === t[r]) ? (
    // If two routes are siblings, we should try to match the earlier sibling
    // first. This allows people to have fine-grained control over the matching
    // behavior by simply putting routes with identical paths in the order they
    // want them tried.
    e[e.length - 1] - t[t.length - 1]
  ) : (
    // Otherwise, it doesn't really make sense to rank non-siblings by index,
    // so they sort equally.
    0
  );
}
function Oe(e, t, n = !1) {
  let { routesMeta: a } = e, r = {}, o = "/", s = [];
  for (let c = 0; c < a.length; ++c) {
    let i = a[c], l = c === a.length - 1, f = o === "/" ? t : t.slice(o.length) || "/", h = K(
      { path: i.relativePath, caseSensitive: i.caseSensitive, end: l },
      f
    ), m = i.route;
    if (!h && l && n && !a[a.length - 1].route.index && (h = K(
      {
        path: i.relativePath,
        caseSensitive: i.caseSensitive,
        end: !1
      },
      f
    )), !h)
      return null;
    Object.assign(r, h.params), s.push({
      // TODO: Can this as be avoided?
      params: r,
      pathname: L([o, h.pathname]),
      pathnameBase: ze(
        L([o, h.pathnameBase])
      ),
      route: m
    }), h.pathnameBase !== "/" && (o = L([o, h.pathnameBase]));
  }
  return s;
}
function K(e, t) {
  typeof e == "string" && (e = { path: e, caseSensitive: !1, end: !0 });
  let [n, a] = Ue(
    e.path,
    e.caseSensitive,
    e.end
  ), r = t.match(n);
  if (!r) return null;
  let o = r[0], s = o.replace(/(.)\/+$/, "$1"), c = r.slice(1);
  return {
    params: a.reduce(
      (l, { paramName: f, isOptional: h }, m) => {
        if (f === "*") {
          let g = c[m] || "";
          s = o.slice(0, o.length - g.length).replace(/(.)\/+$/, "$1");
        }
        const v = c[m];
        return h && !v ? l[f] = void 0 : l[f] = (v || "").replace(/%2F/g, "/"), l;
      },
      {}
    ),
    pathname: o,
    pathnameBase: s,
    pattern: e
  };
}
function Ue(e, t = !1, n = !0) {
  P(
    e === "*" || !e.endsWith("*") || e.endsWith("/*"),
    `Route path "${e}" will be treated as if it were "${e.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/, "/*")}".`
  );
  let a = [], r = "^" + e.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(
    /\/:([\w-]+)(\?)?/g,
    (s, c, i) => (a.push({ paramName: c, isOptional: i != null }), i ? "/?([^\\/]+)?" : "/([^\\/]+)")
  );
  return e.endsWith("*") ? (a.push({ paramName: "*" }), r += e === "*" || e === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$") : n ? r += "\\/*$" : e !== "" && e !== "/" && (r += "(?:(?=\\/|$))"), [new RegExp(r, t ? void 0 : "i"), a];
}
function We(e) {
  try {
    return e.split("/").map((t) => decodeURIComponent(t).replace(/\//g, "%2F")).join("/");
  } catch (t) {
    return P(
      !1,
      `The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`
    ), e;
  }
}
function k(e, t) {
  if (t === "/") return e;
  if (!e.toLowerCase().startsWith(t.toLowerCase()))
    return null;
  let n = t.endsWith("/") ? t.length - 1 : t.length, a = e.charAt(n);
  return a && a !== "/" ? null : e.slice(n) || "/";
}
function He(e, t = "/") {
  let {
    pathname: n,
    search: a = "",
    hash: r = ""
  } = typeof e == "string" ? B(e) : e;
  return {
    pathname: n ? n.startsWith("/") ? n : _e(n, t) : t,
    search: Ke(a),
    hash: je(r)
  };
}
function _e(e, t) {
  let n = t.replace(/\/+$/, "").split("/");
  return e.split("/").forEach((r) => {
    r === ".." ? n.length > 1 && n.pop() : r !== "." && n.push(r);
  }), n.length > 1 ? n.join("/") : "/";
}
function Y(e, t, n, a) {
  return `Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(
    a
  )}].  Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`;
}
function Ve(e) {
  return e.filter(
    (t, n) => n === 0 || t.route.path && t.route.path.length > 0
  );
}
function fe(e) {
  let t = Ve(e);
  return t.map(
    (n, a) => a === t.length - 1 ? n.pathname : n.pathnameBase
  );
}
function de(e, t, n, a = !1) {
  let r;
  typeof e == "string" ? r = B(e) : (r = { ...e }, C(
    !r.pathname || !r.pathname.includes("?"),
    Y("?", "pathname", "search", r)
  ), C(
    !r.pathname || !r.pathname.includes("#"),
    Y("#", "pathname", "hash", r)
  ), C(
    !r.search || !r.search.includes("#"),
    Y("#", "search", "hash", r)
  ));
  let o = e === "" || r.pathname === "", s = o ? "/" : r.pathname, c;
  if (s == null)
    c = n;
  else {
    let h = t.length - 1;
    if (!a && s.startsWith("..")) {
      let m = s.split("/");
      for (; m[0] === ".."; )
        m.shift(), h -= 1;
      r.pathname = m.join("/");
    }
    c = h >= 0 ? t[h] : "/";
  }
  let i = He(r, c), l = s && s !== "/" && s.endsWith("/"), f = (o || s === ".") && n.endsWith("/");
  return !i.pathname.endsWith("/") && (l || f) && (i.pathname += "/"), i;
}
var L = (e) => e.join("/").replace(/\/\/+/g, "/"), ze = (e) => e.replace(/\/+$/, "").replace(/^\/*/, "/"), Ke = (e) => !e || e === "?" ? "" : e.startsWith("?") ? e : "?" + e, je = (e) => !e || e === "#" ? "" : e.startsWith("#") ? e : "#" + e;
function Je(e) {
  return e != null && typeof e.status == "number" && typeof e.statusText == "string" && typeof e.internal == "boolean" && "data" in e;
}
var he = [
  "POST",
  "PUT",
  "PATCH",
  "DELETE"
];
new Set(
  he
);
var Ye = [
  "GET",
  ...he
];
new Set(Ye);
var N = u.createContext(null);
N.displayName = "DataRouter";
var j = u.createContext(null);
j.displayName = "DataRouterState";
u.createContext(!1);
var me = u.createContext({
  isTransitioning: !1
});
me.displayName = "ViewTransition";
var qe = u.createContext(
  /* @__PURE__ */ new Map()
);
qe.displayName = "Fetchers";
var Ge = u.createContext(null);
Ge.displayName = "Await";
var S = u.createContext(
  null
);
S.displayName = "Navigation";
var A = u.createContext(
  null
);
A.displayName = "Location";
var $ = u.createContext({
  outlet: null,
  matches: [],
  isDataRoute: !1
});
$.displayName = "Route";
var X = u.createContext(null);
X.displayName = "RouteError";
function Xe(e, { relative: t } = {}) {
  C(
    O(),
    // TODO: This error is probably because they somehow have 2 versions of the
    // router loaded. We can help them understand how to avoid that.
    "useHref() may be used only in the context of a <Router> component."
  );
  let { basename: n, navigator: a } = u.useContext(S), { hash: r, pathname: o, search: s } = U(e, { relative: t }), c = o;
  return n !== "/" && (c = o === "/" ? n : L([n, o])), a.createHref({ pathname: c, search: s, hash: r });
}
function O() {
  return u.useContext(A) != null;
}
function F() {
  return C(
    O(),
    // TODO: This error is probably because they somehow have 2 versions of the
    // router loaded. We can help them understand how to avoid that.
    "useLocation() may be used only in the context of a <Router> component."
  ), u.useContext(A).location;
}
function Kt() {
  return u.useContext(A).navigationType;
}
var pe = "You should call navigate() in a React.useEffect(), not when your component is first rendered.";
function ge(e) {
  u.useContext(S).static || u.useLayoutEffect(e);
}
function Qe() {
  let { isDataRoute: e } = u.useContext($);
  return e ? ft() : Ze();
}
function Ze() {
  C(
    O(),
    // TODO: This error is probably because they somehow have 2 versions of the
    // router loaded. We can help them understand how to avoid that.
    "useNavigate() may be used only in the context of a <Router> component."
  );
  let e = u.useContext(N), { basename: t, navigator: n } = u.useContext(S), { matches: a } = u.useContext($), { pathname: r } = F(), o = JSON.stringify(fe(a)), s = u.useRef(!1);
  return ge(() => {
    s.current = !0;
  }), u.useCallback(
    (i, l = {}) => {
      if (P(s.current, pe), !s.current) return;
      if (typeof i == "number") {
        n.go(i);
        return;
      }
      let f = de(
        i,
        JSON.parse(o),
        r,
        l.relative === "path"
      );
      e == null && t !== "/" && (f.pathname = f.pathname === "/" ? t : L([t, f.pathname])), (l.replace ? n.replace : n.push)(
        f,
        l.state,
        l
      );
    },
    [
      t,
      n,
      o,
      r,
      e
    ]
  );
}
u.createContext(null);
function U(e, { relative: t } = {}) {
  let { matches: n } = u.useContext($), { pathname: a } = F(), r = JSON.stringify(fe(n));
  return u.useMemo(
    () => de(
      e,
      JSON.parse(r),
      a,
      t === "path"
    ),
    [e, r, a, t]
  );
}
function et(e, t, n, a) {
  C(
    O(),
    // TODO: This error is probably because they somehow have 2 versions of the
    // router loaded. We can help them understand how to avoid that.
    "useRoutes() may be used only in the context of a <Router> component."
  );
  let { navigator: r } = u.useContext(S), { matches: o } = u.useContext($), s = o[o.length - 1], c = s ? s.params : {}, i = s ? s.pathname : "/", l = s ? s.pathnameBase : "/", f = s && s.route;
  {
    let d = f && f.path || "";
    ye(
      i,
      !f || d.endsWith("*") || d.endsWith("*?"),
      `You rendered descendant <Routes> (or called \`useRoutes()\`) at "${i}" (under <Route path="${d}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.

Please change the parent <Route path="${d}"> to <Route path="${d === "/" ? "*" : `${d}/*`}">.`
    );
  }
  let h = F(), m;
  m = h;
  let v = m.pathname || "/", g = v;
  if (l !== "/") {
    let d = l.replace(/^\//, "").split("/");
    g = "/" + v.replace(/^\//, "").split("/").slice(d.length).join("/");
  }
  let p = ue(e, { pathname: g });
  return P(
    f || p != null,
    `No routes matched location "${m.pathname}${m.search}${m.hash}" `
  ), P(
    p == null || p[p.length - 1].route.element !== void 0 || p[p.length - 1].route.Component !== void 0 || p[p.length - 1].route.lazy !== void 0,
    `Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`
  ), ot(
    p && p.map(
      (d) => Object.assign({}, d, {
        params: Object.assign({}, c, d.params),
        pathname: L([
          l,
          // Re-encode pathnames that were decoded inside matchRoutes
          r.encodeLocation ? r.encodeLocation(d.pathname).pathname : d.pathname
        ]),
        pathnameBase: d.pathnameBase === "/" ? l : L([
          l,
          // Re-encode pathnames that were decoded inside matchRoutes
          r.encodeLocation ? r.encodeLocation(d.pathnameBase).pathname : d.pathnameBase
        ])
      })
    ),
    o,
    n,
    a
  );
}
function tt() {
  let e = ct(), t = Je(e) ? `${e.status} ${e.statusText}` : e instanceof Error ? e.message : JSON.stringify(e), n = e instanceof Error ? e.stack : null, a = "rgba(200,200,200, 0.5)", r = { padding: "0.5rem", backgroundColor: a }, o = { padding: "2px 4px", backgroundColor: a }, s = null;
  return console.error(
    "Error handled by React Router default ErrorBoundary:",
    e
  ), s = /* @__PURE__ */ u.createElement(u.Fragment, null, /* @__PURE__ */ u.createElement("p", null, "💿 Hey developer 👋"), /* @__PURE__ */ u.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ u.createElement("code", { style: o }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ u.createElement("code", { style: o }, "errorElement"), " prop on your route.")), /* @__PURE__ */ u.createElement(u.Fragment, null, /* @__PURE__ */ u.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ u.createElement("h3", { style: { fontStyle: "italic" } }, t), n ? /* @__PURE__ */ u.createElement("pre", { style: r }, n) : null, s);
}
var nt = /* @__PURE__ */ u.createElement(tt, null), rt = class extends u.Component {
  constructor(e) {
    super(e), this.state = {
      location: e.location,
      revalidation: e.revalidation,
      error: e.error
    };
  }
  static getDerivedStateFromError(e) {
    return { error: e };
  }
  static getDerivedStateFromProps(e, t) {
    return t.location !== e.location || t.revalidation !== "idle" && e.revalidation === "idle" ? {
      error: e.error,
      location: e.location,
      revalidation: e.revalidation
    } : {
      error: e.error !== void 0 ? e.error : t.error,
      location: t.location,
      revalidation: e.revalidation || t.revalidation
    };
  }
  componentDidCatch(e, t) {
    console.error(
      "React Router caught the following error during render",
      e,
      t
    );
  }
  render() {
    return this.state.error !== void 0 ? /* @__PURE__ */ u.createElement($.Provider, { value: this.props.routeContext }, /* @__PURE__ */ u.createElement(
      X.Provider,
      {
        value: this.state.error,
        children: this.props.component
      }
    )) : this.props.children;
  }
};
function at({ routeContext: e, match: t, children: n }) {
  let a = u.useContext(N);
  return a && a.static && a.staticContext && (t.route.errorElement || t.route.ErrorBoundary) && (a.staticContext._deepestRenderedBoundaryId = t.route.id), /* @__PURE__ */ u.createElement($.Provider, { value: e }, n);
}
function ot(e, t = [], n = null, a = null) {
  if (e == null) {
    if (!n)
      return null;
    if (n.errors)
      e = n.matches;
    else if (t.length === 0 && !n.initialized && n.matches.length > 0)
      e = n.matches;
    else
      return null;
  }
  let r = e, o = n?.errors;
  if (o != null) {
    let i = r.findIndex(
      (l) => l.route.id && o?.[l.route.id] !== void 0
    );
    C(
      i >= 0,
      `Could not find a matching route for errors on route IDs: ${Object.keys(
        o
      ).join(",")}`
    ), r = r.slice(
      0,
      Math.min(r.length, i + 1)
    );
  }
  let s = !1, c = -1;
  if (n)
    for (let i = 0; i < r.length; i++) {
      let l = r[i];
      if ((l.route.HydrateFallback || l.route.hydrateFallbackElement) && (c = i), l.route.id) {
        let { loaderData: f, errors: h } = n, m = l.route.loader && !f.hasOwnProperty(l.route.id) && (!h || h[l.route.id] === void 0);
        if (l.route.lazy || m) {
          s = !0, c >= 0 ? r = r.slice(0, c + 1) : r = [r[0]];
          break;
        }
      }
    }
  return r.reduceRight((i, l, f) => {
    let h, m = !1, v = null, g = null;
    n && (h = o && l.route.id ? o[l.route.id] : void 0, v = l.route.errorElement || nt, s && (c < 0 && f === 0 ? (ye(
      "route-fallback",
      !1,
      "No `HydrateFallback` element provided to render during initial hydration"
    ), m = !0, g = null) : c === f && (m = !0, g = l.route.hydrateFallbackElement || null)));
    let p = t.concat(r.slice(0, f + 1)), y = () => {
      let d;
      return h ? d = v : m ? d = g : l.route.Component ? d = /* @__PURE__ */ u.createElement(l.route.Component, null) : l.route.element ? d = l.route.element : d = i, /* @__PURE__ */ u.createElement(
        at,
        {
          match: l,
          routeContext: {
            outlet: i,
            matches: p,
            isDataRoute: n != null
          },
          children: d
        }
      );
    };
    return n && (l.route.ErrorBoundary || l.route.errorElement || f === 0) ? /* @__PURE__ */ u.createElement(
      rt,
      {
        location: n.location,
        revalidation: n.revalidation,
        component: v,
        error: h,
        children: y(),
        routeContext: { outlet: null, matches: p, isDataRoute: !0 }
      }
    ) : y();
  }, null);
}
function Q(e) {
  return `${e} must be used within a data router.  See https://reactrouter.com/en/main/routers/picking-a-router.`;
}
function lt(e) {
  let t = u.useContext(N);
  return C(t, Q(e)), t;
}
function it(e) {
  let t = u.useContext(j);
  return C(t, Q(e)), t;
}
function ut(e) {
  let t = u.useContext($);
  return C(t, Q(e)), t;
}
function Z(e) {
  let t = ut(e), n = t.matches[t.matches.length - 1];
  return C(
    n.route.id,
    `${e} can only be used on routes that contain a unique "id"`
  ), n.route.id;
}
function st() {
  return Z(
    "useRouteId"
    /* UseRouteId */
  );
}
function ct() {
  let e = u.useContext(X), t = it(
    "useRouteError"
    /* UseRouteError */
  ), n = Z(
    "useRouteError"
    /* UseRouteError */
  );
  return e !== void 0 ? e : t.errors?.[n];
}
function ft() {
  let { router: e } = lt(
    "useNavigate"
    /* UseNavigateStable */
  ), t = Z(
    "useNavigate"
    /* UseNavigateStable */
  ), n = u.useRef(!1);
  return ge(() => {
    n.current = !0;
  }), u.useCallback(
    async (r, o = {}) => {
      P(n.current, pe), n.current && (typeof r == "number" ? e.navigate(r) : await e.navigate(r, { fromRouteId: t, ...o }));
    },
    [e, t]
  );
}
var le = {};
function ye(e, t, n) {
  !t && !le[e] && (le[e] = !0, P(!1, n));
}
u.memo(dt);
function dt({
  routes: e,
  future: t,
  state: n
}) {
  return et(e, void 0, n, t);
}
function ht({
  basename: e = "/",
  children: t = null,
  location: n,
  navigationType: a = "POP",
  navigator: r,
  static: o = !1
}) {
  C(
    !O(),
    "You cannot render a <Router> inside another <Router>. You should never have more than one in your app."
  );
  let s = e.replace(/^\/*/, "/"), c = u.useMemo(
    () => ({
      basename: s,
      navigator: r,
      static: o,
      future: {}
    }),
    [s, r, o]
  );
  typeof n == "string" && (n = B(n));
  let {
    pathname: i = "/",
    search: l = "",
    hash: f = "",
    state: h = null,
    key: m = "default"
  } = n, v = u.useMemo(() => {
    let g = k(i, s);
    return g == null ? null : {
      location: {
        pathname: g,
        search: l,
        hash: f,
        state: h,
        key: m
      },
      navigationType: a
    };
  }, [s, i, l, f, h, m, a]);
  return P(
    v != null,
    `<Router basename="${s}"> is not able to match the URL "${i}${l}${f}" because it does not start with the basename, so the <Router> won't render anything.`
  ), v == null ? null : /* @__PURE__ */ u.createElement(S.Provider, { value: c }, /* @__PURE__ */ u.createElement(A.Provider, { children: t, value: v }));
}
var V = "get", z = "application/x-www-form-urlencoded";
function J(e) {
  return e != null && typeof e.tagName == "string";
}
function mt(e) {
  return J(e) && e.tagName.toLowerCase() === "button";
}
function pt(e) {
  return J(e) && e.tagName.toLowerCase() === "form";
}
function gt(e) {
  return J(e) && e.tagName.toLowerCase() === "input";
}
function yt(e) {
  return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
}
function vt(e, t) {
  return e.button === 0 && // Ignore everything but left clicks
  (!t || t === "_self") && // Let browser handle "target=_blank" etc.
  !yt(e);
}
var _ = null;
function wt() {
  if (_ === null)
    try {
      new FormData(
        document.createElement("form"),
        // @ts-expect-error if FormData supports the submitter parameter, this will throw
        0
      ), _ = !1;
    } catch {
      _ = !0;
    }
  return _;
}
var xt = /* @__PURE__ */ new Set([
  "application/x-www-form-urlencoded",
  "multipart/form-data",
  "text/plain"
]);
function q(e) {
  return e != null && !xt.has(e) ? (P(
    !1,
    `"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${z}"`
  ), null) : e;
}
function Ct(e, t) {
  let n, a, r, o, s;
  if (pt(e)) {
    let c = e.getAttribute("action");
    a = c ? k(c, t) : null, n = e.getAttribute("method") || V, r = q(e.getAttribute("enctype")) || z, o = new FormData(e);
  } else if (mt(e) || gt(e) && (e.type === "submit" || e.type === "image")) {
    let c = e.form;
    if (c == null)
      throw new Error(
        'Cannot submit a <button> or <input type="submit"> without a <form>'
      );
    let i = e.getAttribute("formaction") || c.getAttribute("action");
    if (a = i ? k(i, t) : null, n = e.getAttribute("formmethod") || c.getAttribute("method") || V, r = q(e.getAttribute("formenctype")) || q(c.getAttribute("enctype")) || z, o = new FormData(c, e), !wt()) {
      let { name: l, type: f, value: h } = e;
      if (f === "image") {
        let m = l ? `${l}.` : "";
        o.append(`${m}x`, "0"), o.append(`${m}y`, "0");
      } else l && o.append(l, h);
    }
  } else {
    if (J(e))
      throw new Error(
        'Cannot submit element that is not <form>, <button>, or <input type="submit|image">'
      );
    n = V, a = null, r = z, s = e;
  }
  return o && r === "text/plain" && (s = o, o = void 0), { action: a, method: n.toLowerCase(), encType: r, formData: o, body: s };
}
Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
function ee(e, t) {
  if (e === !1 || e === null || typeof e > "u")
    throw new Error(t);
}
function Rt(e, t, n) {
  let a = typeof e == "string" ? new URL(
    e,
    // This can be called during the SSR flow via PrefetchPageLinksImpl so
    // don't assume window is available
    typeof window > "u" ? "server://singlefetch/" : window.location.origin
  ) : e;
  return a.pathname === "/" ? a.pathname = `_root.${n}` : t && k(a.pathname, t) === "/" ? a.pathname = `${t.replace(/\/$/, "")}/_root.${n}` : a.pathname = `${a.pathname.replace(/\/$/, "")}.${n}`, a;
}
async function Et(e, t) {
  if (e.id in t)
    return t[e.id];
  try {
    let n = await import(
      /* @vite-ignore */
      /* webpackIgnore: true */
      e.module
    );
    return t[e.id] = n, n;
  } catch (n) {
    return console.error(
      `Error loading route module \`${e.module}\`, reloading page...`
    ), console.error(n), window.__reactRouterContext && window.__reactRouterContext.isSpaMode, window.location.reload(), new Promise(() => {
    });
  }
}
function bt(e) {
  return e == null ? !1 : e.href == null ? e.rel === "preload" && typeof e.imageSrcSet == "string" && typeof e.imageSizes == "string" : typeof e.rel == "string" && typeof e.href == "string";
}
async function Pt(e, t, n) {
  let a = await Promise.all(
    e.map(async (r) => {
      let o = t.routes[r.route.id];
      if (o) {
        let s = await Et(o, n);
        return s.links ? s.links() : [];
      }
      return [];
    })
  );
  return $t(
    a.flat(1).filter(bt).filter((r) => r.rel === "stylesheet" || r.rel === "preload").map(
      (r) => r.rel === "stylesheet" ? { ...r, rel: "prefetch", as: "style" } : { ...r, rel: "prefetch" }
    )
  );
}
function ie(e, t, n, a, r, o) {
  let s = (i, l) => n[l] ? i.route.id !== n[l].route.id : !0, c = (i, l) => (
    // param change, /users/123 -> /users/456
    n[l].pathname !== i.pathname || // splat param changed, which is not present in match.path
    // e.g. /files/images/avatar.jpg -> files/finances.xls
    n[l].route.path?.endsWith("*") && n[l].params["*"] !== i.params["*"]
  );
  return o === "assets" ? t.filter(
    (i, l) => s(i, l) || c(i, l)
  ) : o === "data" ? t.filter((i, l) => {
    let f = a.routes[i.route.id];
    if (!f || !f.hasLoader)
      return !1;
    if (s(i, l) || c(i, l))
      return !0;
    if (i.route.shouldRevalidate) {
      let h = i.route.shouldRevalidate({
        currentUrl: new URL(
          r.pathname + r.search + r.hash,
          window.origin
        ),
        currentParams: n[0]?.params || {},
        nextUrl: new URL(e, window.origin),
        nextParams: i.params,
        defaultShouldRevalidate: !0
      });
      if (typeof h == "boolean")
        return h;
    }
    return !0;
  }) : [];
}
function St(e, t, { includeHydrateFallback: n } = {}) {
  return Lt(
    e.map((a) => {
      let r = t.routes[a.route.id];
      if (!r) return [];
      let o = [r.module];
      return r.clientActionModule && (o = o.concat(r.clientActionModule)), r.clientLoaderModule && (o = o.concat(r.clientLoaderModule)), n && r.hydrateFallbackModule && (o = o.concat(r.hydrateFallbackModule)), r.imports && (o = o.concat(r.imports)), o;
    }).flat(1)
  );
}
function Lt(e) {
  return [...new Set(e)];
}
function kt(e) {
  let t = {}, n = Object.keys(e).sort();
  for (let a of n)
    t[a] = e[a];
  return t;
}
function $t(e, t) {
  let n = /* @__PURE__ */ new Set();
  return new Set(t), e.reduce((a, r) => {
    let o = JSON.stringify(kt(r));
    return n.has(o) || (n.add(o), a.push({ key: o, link: r })), a;
  }, []);
}
function ve() {
  let e = u.useContext(N);
  return ee(
    e,
    "You must render this element inside a <DataRouterContext.Provider> element"
  ), e;
}
function Ft() {
  let e = u.useContext(j);
  return ee(
    e,
    "You must render this element inside a <DataRouterStateContext.Provider> element"
  ), e;
}
var te = u.createContext(void 0);
te.displayName = "FrameworkContext";
function we() {
  let e = u.useContext(te);
  return ee(
    e,
    "You must render this element inside a <HydratedRouter> element"
  ), e;
}
function It(e, t) {
  let n = u.useContext(te), [a, r] = u.useState(!1), [o, s] = u.useState(!1), { onFocus: c, onBlur: i, onMouseEnter: l, onMouseLeave: f, onTouchStart: h } = t, m = u.useRef(null);
  u.useEffect(() => {
    if (e === "render" && s(!0), e === "viewport") {
      let p = (d) => {
        d.forEach((x) => {
          s(x.isIntersecting);
        });
      }, y = new IntersectionObserver(p, { threshold: 0.5 });
      return m.current && y.observe(m.current), () => {
        y.disconnect();
      };
    }
  }, [e]), u.useEffect(() => {
    if (a) {
      let p = setTimeout(() => {
        s(!0);
      }, 100);
      return () => {
        clearTimeout(p);
      };
    }
  }, [a]);
  let v = () => {
    r(!0);
  }, g = () => {
    r(!1), s(!1);
  };
  return n ? e !== "intent" ? [o, m, {}] : [
    o,
    m,
    {
      onFocus: D(c, v),
      onBlur: D(i, g),
      onMouseEnter: D(l, v),
      onMouseLeave: D(f, g),
      onTouchStart: D(h, v)
    }
  ] : [!1, m, {}];
}
function D(e, t) {
  return (n) => {
    e && e(n), n.defaultPrevented || t(n);
  };
}
function Nt({
  page: e,
  ...t
}) {
  let { router: n } = ve(), a = u.useMemo(
    () => ue(n.routes, e, n.basename),
    [n.routes, e, n.basename]
  );
  return a ? /* @__PURE__ */ u.createElement(Dt, { page: e, matches: a, ...t }) : null;
}
function Tt(e) {
  let { manifest: t, routeModules: n } = we(), [a, r] = u.useState([]);
  return u.useEffect(() => {
    let o = !1;
    return Pt(e, t, n).then(
      (s) => {
        o || r(s);
      }
    ), () => {
      o = !0;
    };
  }, [e, t, n]), a;
}
function Dt({
  page: e,
  matches: t,
  ...n
}) {
  let a = F(), { manifest: r, routeModules: o } = we(), { basename: s } = ve(), { loaderData: c, matches: i } = Ft(), l = u.useMemo(
    () => ie(
      e,
      t,
      i,
      r,
      a,
      "data"
    ),
    [e, t, i, r, a]
  ), f = u.useMemo(
    () => ie(
      e,
      t,
      i,
      r,
      a,
      "assets"
    ),
    [e, t, i, r, a]
  ), h = u.useMemo(() => {
    if (e === a.pathname + a.search + a.hash)
      return [];
    let g = /* @__PURE__ */ new Set(), p = !1;
    if (t.forEach((d) => {
      let x = r.routes[d.route.id];
      !x || !x.hasLoader || (!l.some((w) => w.route.id === d.route.id) && d.route.id in c && o[d.route.id]?.shouldRevalidate || x.hasClientLoader ? p = !0 : g.add(d.route.id));
    }), g.size === 0)
      return [];
    let y = Rt(e, s, "data");
    return p && g.size > 0 && y.searchParams.set(
      "_routes",
      t.filter((d) => g.has(d.route.id)).map((d) => d.route.id).join(",")
    ), [y.pathname + y.search];
  }, [
    s,
    c,
    a,
    r,
    l,
    t,
    e,
    o
  ]), m = u.useMemo(
    () => St(f, r),
    [f, r]
  ), v = Tt(f);
  return /* @__PURE__ */ u.createElement(u.Fragment, null, h.map((g) => /* @__PURE__ */ u.createElement("link", { key: g, rel: "prefetch", as: "fetch", href: g, ...n })), m.map((g) => /* @__PURE__ */ u.createElement("link", { key: g, rel: "modulepreload", href: g, ...n })), v.map(({ key: g, link: p }) => (
    // these don't spread `linkProps` because they are full link descriptors
    // already with their own props
    /* @__PURE__ */ u.createElement("link", { key: g, ...p })
  )));
}
function Mt(...e) {
  return (t) => {
    e.forEach((n) => {
      typeof n == "function" ? n(t) : n != null && (n.current = t);
    });
  };
}
var xe = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u";
try {
  xe && (window.__reactRouterVersion = // @ts-expect-error
  "7.7.0");
} catch {
}
function jt({
  basename: e,
  children: t,
  window: n
}) {
  let a = u.useRef();
  a.current == null && (a.current = be({ window: n, v5Compat: !0 }));
  let r = a.current, [o, s] = u.useState({
    action: r.action,
    location: r.location
  }), c = u.useCallback(
    (i) => {
      u.startTransition(() => s(i));
    },
    [s]
  );
  return u.useLayoutEffect(() => r.listen(c), [r, c]), /* @__PURE__ */ u.createElement(
    ht,
    {
      basename: e,
      children: t,
      location: o.location,
      navigationType: o.action,
      navigator: r
    }
  );
}
var Ce = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i, Re = u.forwardRef(
  function({
    onClick: t,
    discover: n = "render",
    prefetch: a = "none",
    relative: r,
    reloadDocument: o,
    replace: s,
    state: c,
    target: i,
    to: l,
    preventScrollReset: f,
    viewTransition: h,
    ...m
  }, v) {
    let { basename: g } = u.useContext(S), p = typeof l == "string" && Ce.test(l), y, d = !1;
    if (typeof l == "string" && p && (y = l, xe))
      try {
        let b = new URL(window.location.href), I = l.startsWith("//") ? new URL(b.protocol + l) : new URL(l), ne = k(I.pathname, g);
        I.origin === b.origin && ne != null ? l = ne + I.search + I.hash : d = !0;
      } catch {
        P(
          !1,
          `<Link to="${l}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
        );
      }
    let x = Xe(l, { relative: r }), [w, R, E] = It(
      a,
      m
    ), W = Ut(l, {
      replace: s,
      state: c,
      target: i,
      preventScrollReset: f,
      relative: r,
      viewTransition: h
    });
    function T(b) {
      t && t(b), b.defaultPrevented || W(b);
    }
    let H = (
      // eslint-disable-next-line jsx-a11y/anchor-has-content
      /* @__PURE__ */ u.createElement(
        "a",
        {
          ...m,
          ...E,
          href: y || x,
          onClick: d || o ? t : T,
          ref: Mt(v, R),
          target: i,
          "data-discover": !p && n === "render" ? "true" : void 0
        }
      )
    );
    return w && !p ? /* @__PURE__ */ u.createElement(u.Fragment, null, H, /* @__PURE__ */ u.createElement(Nt, { page: x })) : H;
  }
);
Re.displayName = "Link";
var Bt = u.forwardRef(
  function({
    "aria-current": t = "page",
    caseSensitive: n = !1,
    className: a = "",
    end: r = !1,
    style: o,
    to: s,
    viewTransition: c,
    children: i,
    ...l
  }, f) {
    let h = U(s, { relative: l.relative }), m = F(), v = u.useContext(j), { navigator: g, basename: p } = u.useContext(S), y = v != null && // Conditional usage is OK here because the usage of a data router is static
    // eslint-disable-next-line react-hooks/rules-of-hooks
    zt(h) && c === !0, d = g.encodeLocation ? g.encodeLocation(h).pathname : h.pathname, x = m.pathname, w = v && v.navigation && v.navigation.location ? v.navigation.location.pathname : null;
    n || (x = x.toLowerCase(), w = w ? w.toLowerCase() : null, d = d.toLowerCase()), w && p && (w = k(w, p) || w);
    const R = d !== "/" && d.endsWith("/") ? d.length - 1 : d.length;
    let E = x === d || !r && x.startsWith(d) && x.charAt(R) === "/", W = w != null && (w === d || !r && w.startsWith(d) && w.charAt(d.length) === "/"), T = {
      isActive: E,
      isPending: W,
      isTransitioning: y
    }, H = E ? t : void 0, b;
    typeof a == "function" ? b = a(T) : b = [
      a,
      E ? "active" : null,
      W ? "pending" : null,
      y ? "transitioning" : null
    ].filter(Boolean).join(" ");
    let I = typeof o == "function" ? o(T) : o;
    return /* @__PURE__ */ u.createElement(
      Re,
      {
        ...l,
        "aria-current": H,
        className: b,
        ref: f,
        style: I,
        to: s,
        viewTransition: c
      },
      typeof i == "function" ? i(T) : i
    );
  }
);
Bt.displayName = "NavLink";
var At = u.forwardRef(
  ({
    discover: e = "render",
    fetcherKey: t,
    navigate: n,
    reloadDocument: a,
    replace: r,
    state: o,
    method: s = V,
    action: c,
    onSubmit: i,
    relative: l,
    preventScrollReset: f,
    viewTransition: h,
    ...m
  }, v) => {
    let g = _t(), p = Vt(c, { relative: l }), y = s.toLowerCase() === "get" ? "get" : "post", d = typeof c == "string" && Ce.test(c), x = (w) => {
      if (i && i(w), w.defaultPrevented) return;
      w.preventDefault();
      let R = w.nativeEvent.submitter, E = R?.getAttribute("formmethod") || s;
      g(R || w.currentTarget, {
        fetcherKey: t,
        method: E,
        navigate: n,
        replace: r,
        state: o,
        relative: l,
        preventScrollReset: f,
        viewTransition: h
      });
    };
    return /* @__PURE__ */ u.createElement(
      "form",
      {
        ref: v,
        method: y,
        action: p,
        onSubmit: a ? i : x,
        ...m,
        "data-discover": !d && e === "render" ? "true" : void 0
      }
    );
  }
);
At.displayName = "Form";
function Ot(e) {
  return `${e} must be used within a data router.  See https://reactrouter.com/en/main/routers/picking-a-router.`;
}
function Ee(e) {
  let t = u.useContext(N);
  return C(t, Ot(e)), t;
}
function Ut(e, {
  target: t,
  replace: n,
  state: a,
  preventScrollReset: r,
  relative: o,
  viewTransition: s
} = {}) {
  let c = Qe(), i = F(), l = U(e, { relative: o });
  return u.useCallback(
    (f) => {
      if (vt(f, t)) {
        f.preventDefault();
        let h = n !== void 0 ? n : M(i) === M(l);
        c(e, {
          replace: h,
          state: a,
          preventScrollReset: r,
          relative: o,
          viewTransition: s
        });
      }
    },
    [
      i,
      c,
      l,
      n,
      a,
      t,
      e,
      r,
      o,
      s
    ]
  );
}
var Wt = 0, Ht = () => `__${String(++Wt)}__`;
function _t() {
  let { router: e } = Ee(
    "useSubmit"
    /* UseSubmit */
  ), { basename: t } = u.useContext(S), n = st();
  return u.useCallback(
    async (a, r = {}) => {
      let { action: o, method: s, encType: c, formData: i, body: l } = Ct(
        a,
        t
      );
      if (r.navigate === !1) {
        let f = r.fetcherKey || Ht();
        await e.fetch(f, n, r.action || o, {
          preventScrollReset: r.preventScrollReset,
          formData: i,
          body: l,
          formMethod: r.method || s,
          formEncType: r.encType || c,
          flushSync: r.flushSync
        });
      } else
        await e.navigate(r.action || o, {
          preventScrollReset: r.preventScrollReset,
          formData: i,
          body: l,
          formMethod: r.method || s,
          formEncType: r.encType || c,
          replace: r.replace,
          state: r.state,
          fromRouteId: n,
          flushSync: r.flushSync,
          viewTransition: r.viewTransition
        });
    },
    [e, t, n]
  );
}
function Vt(e, { relative: t } = {}) {
  let { basename: n } = u.useContext(S), a = u.useContext($);
  C(a, "useFormAction must be used inside a RouteContext");
  let [r] = a.matches.slice(-1), o = { ...U(e || ".", { relative: t }) }, s = F();
  if (e == null) {
    o.search = s.search;
    let c = new URLSearchParams(o.search), i = c.getAll("index");
    if (i.some((f) => f === "")) {
      c.delete("index"), i.filter((h) => h).forEach((h) => c.append("index", h));
      let f = c.toString();
      o.search = f ? `?${f}` : "";
    }
  }
  return (!e || e === ".") && r.route.index && (o.search = o.search ? o.search.replace(/^\?/, "?index&") : "?index"), n !== "/" && (o.pathname = o.pathname === "/" ? n : L([n, o.pathname])), M(o);
}
function zt(e, t = {}) {
  let n = u.useContext(me);
  C(
    n != null,
    "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`.  Did you accidentally import `RouterProvider` from `react-router`?"
  );
  let { basename: a } = Ee(
    "useViewTransitionState"
    /* useViewTransitionState */
  ), r = U(e, { relative: t.relative });
  if (!n.isTransitioning)
    return !1;
  let o = k(n.currentLocation.pathname, a) || n.currentLocation.pathname, s = k(n.nextLocation.pathname, a) || n.nextLocation.pathname;
  return K(r.pathname, s) != null || K(r.pathname, o) != null;
}
export {
  jt as BrowserRouter,
  N as DataRouterContext,
  j as DataRouterStateContext,
  qe as FetchersContext,
  At as Form,
  te as FrameworkContext,
  Re as Link,
  A as LocationContext,
  Bt as NavLink,
  S as NavigationContext,
  Nt as PrefetchPageLinks,
  $ as RouteContext,
  ht as Router,
  me as ViewTransitionContext,
  be as createBrowserHistory,
  M as createPath,
  C as invariant,
  Je as isRouteErrorResponse,
  K as matchPath,
  ue as matchRoutes,
  B as parsePath,
  He as resolvePath,
  Rt as singleFetchUrl,
  k as stripBasename,
  Vt as useFormAction,
  Xe as useHref,
  O as useInRouterContext,
  Ut as useLinkClickHandler,
  F as useLocation,
  Qe as useNavigate,
  Kt as useNavigationType,
  U as useResolvedPath,
  ct as useRouteError,
  _t as useSubmit,
  zt as useViewTransitionState
};
//# sourceMappingURL=chunk-EF7DTUVF.js.map
