import {
  a as rt
} from "../_browser-chunks/chunk-NM3IIACQ.js";
import "../_browser-chunks/chunk-VRBWRKGV.js";
import {
  b as k,
  f as Pe
} from "../_browser-chunks/chunk-IU22WWJQ.js";
import {
  a as tt
} from "../_browser-chunks/chunk-VEVXVIEO.js";
import {
  a as xe
} from "../_browser-chunks/chunk-JCASV5LV.js";
import {
  a as o,
  e as Se
} from "../_browser-chunks/chunk-IO47FP3U.js";

// src/router/utils.ts
import { once as nt } from "storybook/internal/client-logger";
var q = Se(tt(), 1), V = Se(rt(), 1);
var at = /\/([^/]+)\/(?:(.*)_)?([^/]+)?/, Le = (0, q.default)(1e3)((e) => {
  let t = {
    viewMode: void 0,
    storyId: void 0,
    refId: void 0
  };
  if (e) {
    let [, r, a, n] = e.toLowerCase().match(at) || [];
    r && Object.assign(t, {
      viewMode: r,
      storyId: n,
      refId: a
    });
  }
  return t;
}), J = Symbol("Deeply equal"), oe = /* @__PURE__ */ o((e, t) => {
  if (typeof e != typeof t)
    return t;
  if (Pe(e, t))
    return J;
  if (Array.isArray(e) && Array.isArray(t)) {
    let r = t.reduce((a, n, l) => {
      let i = oe(e[l], n);
      return i !== J && (a[l] = i), a;
    }, new Array(t.length));
    return t.length >= e.length ? r : r.concat(new Array(e.length - t.length).fill(void 0));
  }
  return k(e) && k(t) ? Object.keys({ ...e, ...t }).reduce((r, a) => {
    let n = oe(e?.[a], t?.[a]);
    return n === J ? r : Object.assign(r, { [a]: n });
  }, {}) : t;
}, "deepDiff"), Ce = /^[a-zA-Z0-9 _-]*$/, ot = /^-?[0-9]+(\.[0-9]+)?$/, _e = /^#([a-f0-9]{3,4}|[a-f0-9]{6}|[a-f0-9]{8})$/i, Ae = /^(rgba?|hsla?)\(([0-9]{1,3}),\s?([0-9]{1,3})%?,\s?([0-9]{1,3})%?,?\s?([0-9](\.[0-9]{1,2})?)?\)$/i, ie = /* @__PURE__ */ o((e = "", t) => e === null || e === "" || !Ce.test(e) ? !1 : t == null || t instanceof Date || typeof t == "number" || typeof t == "boolean" ? !0 : typeof t == "string" ? Ce.test(t) || ot.test(t) || _e.test(t) || Ae.test(t) : Array.isArray(t) ? t.every((r) => ie(e, r)) : k(t) ? Object.entries(t).every(([r, a]) => ie(r, a)) : !1, "validateArgs"), le = /* @__PURE__ */ o((e) => e === void 0 ? "!undefined" : e === null ? "!null" : typeof e == "string" ? _e.test(e) ? `!hex(${e.slice(1)})` : Ae.test(e) ? `!${e.replace(/[\s%]/g, "")}` : e : typeof e == "boolean" ? `!${e}` : e instanceof Date ? `!date(${e.toISOString()})` : Array.isArray(e) ? e.map(le) : k(e) ? Object.entries(e).reduce(
  (t, [r, a]) => Object.assign(t, { [r]: le(a) }),
  {}
) : e, "encodeSpecialValues"), it = /* @__PURE__ */ o((e) => {
  switch (e) {
    case "%20":
      return "+";
    case "%5B":
      return "[";
    case "%5D":
      return "]";
    case "%2C":
      return ",";
    case "%3A":
      return ":";
  }
  return e;
}, "decodeKnownQueryChar"), lt = /%[0-9A-F]{2}/g, dr = /* @__PURE__ */ o((e, t) => {
  let r = oe(e, t);
  if (!r || r === J)
    return "";
  let a = Object.entries(r).reduce((n, [l, i]) => ie(l, i) ? Object.assign(n, { [l]: i }) : (nt.warn(xe`
      Omitted potentially unsafe URL args.

      More info: https://storybook.js.org/docs/writing-stories/args#setting-args-through-the-url
    `), n), {});
  return (0, V.stringify)(le(a), {
    delimiter: ";",
    // we don't actually create multiple query params
    nesting: !0,
    nestingSyntax: "js"
    // encode objects using dot notation: obj.key=val
  }).replace(lt, it).split(";").map((n) => n.replace("=", ":")).join(";");
}, "buildArgsParam"), st = (0, q.default)(1e3)((e) => e !== void 0 ? (0, V.parse)(e) : {}), Fe = /* @__PURE__ */ o((e) => st(e.search ? e.search.slice(1) : ""), "queryFromLocation"), fr = /* @__PURE__ */ o((e) => {
  let t = (0, V.stringify)(e);
  return t ? "?" + t : "";
}, "stringifyQuery"), Oe = (0, q.default)(1e3)((e, t, r = !0) => {
  if (r) {
    if (typeof t != "string")
      throw new Error("startsWith only works with string targets");
    return e && e.startsWith(t) ? { path: e } : null;
  }
  let a = typeof t == "string" && e === t, n = e && t && e.match(t);
  return a || n ? { path: e } : null;
});

// src/router/router.tsx
import Y, { useCallback as nr } from "react";
import { global as ar } from "@storybook/global";

// ../node_modules/react-router-dom/dist/index.js
import * as f from "react";

// ../node_modules/react-router/dist/index.js
import * as c from "react";

// ../node_modules/@remix-run/router/dist/router.js
function z() {
  return z = Object.assign ? Object.assign.bind() : function(e) {
    for (var t = 1; t < arguments.length; t++) {
      var r = arguments[t];
      for (var a in r)
        Object.prototype.hasOwnProperty.call(r, a) && (e[a] = r[a]);
    }
    return e;
  }, z.apply(this, arguments);
}
o(z, "_extends");
var S;
(function(e) {
  e.Pop = "POP", e.Push = "PUSH", e.Replace = "REPLACE";
})(S || (S = {}));
var Ue = "popstate";
function Ie(e) {
  e === void 0 && (e = {});
  function t(a, n) {
    let {
      pathname: l,
      search: i,
      hash: s
    } = a.location;
    return ue(
      "",
      {
        pathname: l,
        search: i,
        hash: s
      },
      // state defaults to `null` because `window.history.state` does
      n.state && n.state.usr || null,
      n.state && n.state.key || "default"
    );
  }
  o(t, "createBrowserLocation");
  function r(a, n) {
    return typeof n == "string" ? n : C(n);
  }
  return o(r, "createBrowserHref"), ct(t, r, null, e);
}
o(Ie, "createBrowserHistory");
function E(e, t) {
  if (e === !1 || e === null || typeof e > "u")
    throw new Error(t);
}
o(E, "invariant");
function F(e, t) {
  if (!e) {
    typeof console < "u" && console.warn(t);
    try {
      throw new Error(t);
    } catch {
    }
  }
}
o(F, "warning");
function ut() {
  return Math.random().toString(36).substr(2, 8);
}
o(ut, "createKey");
function Me(e, t) {
  return {
    usr: e.state,
    key: e.key,
    idx: t
  };
}
o(Me, "getHistoryState");
function ue(e, t, r, a) {
  return r === void 0 && (r = null), z({
    pathname: typeof e == "string" ? e : e.pathname,
    search: "",
    hash: ""
  }, typeof t == "string" ? O(t) : t, {
    state: r,
    // 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 || ut()
  });
}
o(ue, "createLocation");
function C(e) {
  let {
    pathname: t = "/",
    search: r = "",
    hash: a = ""
  } = e;
  return r && r !== "?" && (t += r.charAt(0) === "?" ? r : "?" + r), a && a !== "#" && (t += a.charAt(0) === "#" ? a : "#" + a), t;
}
o(C, "createPath");
function O(e) {
  let t = {};
  if (e) {
    let r = e.indexOf("#");
    r >= 0 && (t.hash = e.substr(r), e = e.substr(0, r));
    let a = e.indexOf("?");
    a >= 0 && (t.search = e.substr(a), e = e.substr(0, a)), e && (t.pathname = e);
  }
  return t;
}
o(O, "parsePath");
function ct(e, t, r, a) {
  a === void 0 && (a = {});
  let {
    window: n = document.defaultView,
    v5Compat: l = !1
  } = a, i = n.history, s = S.Pop, d = null, u = h();
  u == null && (u = 0, i.replaceState(z({}, i.state, {
    idx: u
  }), ""));
  function h() {
    return (i.state || {
      idx: null
    }).idx;
  }
  o(h, "getIndex");
  function y() {
    s = S.Pop;
    let p = h(), g = p == null ? null : p - u;
    u = p, d && d({
      action: s,
      location: m.location,
      delta: g
    });
  }
  o(y, "handlePop");
  function R(p, g) {
    s = S.Push;
    let v = ue(m.location, p, g);
    r && r(v, p), u = h() + 1;
    let N = Me(v, u), P = m.createHref(v);
    try {
      i.pushState(N, "", P);
    } catch (A) {
      if (A instanceof DOMException && A.name === "DataCloneError")
        throw A;
      n.location.assign(P);
    }
    l && d && d({
      action: s,
      location: m.location,
      delta: 1
    });
  }
  o(R, "push");
  function b(p, g) {
    s = S.Replace;
    let v = ue(m.location, p, g);
    r && r(v, p), u = h();
    let N = Me(v, u), P = m.createHref(v);
    i.replaceState(N, "", P), l && d && d({
      action: s,
      location: m.location,
      delta: 0
    });
  }
  o(b, "replace");
  function w(p) {
    let g = n.location.origin !== "null" ? n.location.origin : n.location.href, v = typeof p == "string" ? p : C(p);
    return E(g, "No window.location.(origin|href) available to create URL for href: " + v), new URL(v, g);
  }
  o(w, "createURL");
  let m = {
    get action() {
      return s;
    },
    get location() {
      return e(n, i);
    },
    listen(p) {
      if (d)
        throw new Error("A history only accepts one active listener");
      return n.addEventListener(Ue, y), d = p, () => {
        n.removeEventListener(Ue, y), d = null;
      };
    },
    createHref(p) {
      return t(n, p);
    },
    createURL: w,
    encodeLocation(p) {
      let g = w(p);
      return {
        pathname: g.pathname,
        search: g.search,
        hash: g.hash
      };
    },
    push: R,
    replace: b,
    go(p) {
      return i.go(p);
    }
  };
  return m;
}
o(ct, "getUrlBasedHistory");
var Te;
(function(e) {
  e.data = "data", e.deferred = "deferred", e.redirect = "redirect", e.error = "error";
})(Te || (Te = {}));
function U(e, t) {
  if (t === "/") return e;
  if (!e.toLowerCase().startsWith(t.toLowerCase()))
    return null;
  let r = t.endsWith("/") ? t.length - 1 : t.length, a = e.charAt(r);
  return a && a !== "/" ? null : e.slice(r) || "/";
}
o(U, "stripBasename");
function ce(e, t) {
  t === void 0 && (t = "/");
  let {
    pathname: r,
    search: a = "",
    hash: n = ""
  } = typeof e == "string" ? O(e) : e;
  return {
    pathname: r ? r.startsWith("/") ? r : dt(r, t) : t,
    search: ft(a),
    hash: ht(n)
  };
}
o(ce, "resolvePath");
function dt(e, t) {
  let r = t.replace(/\/+$/, "").split("/");
  return e.split("/").forEach((n) => {
    n === ".." ? r.length > 1 && r.pop() : n !== "." && r.push(n);
  }), r.length > 1 ? r.join("/") : "/";
}
o(dt, "resolvePathname");
function se(e, t, r, a) {
  return "Cannot include a '" + e + "' character in a manually specified " + ("`to." + t + "` field [" + JSON.stringify(a) + "].  Please separate it out to the ") + ("`to." + r + "` field. Alternatively you may provide the full path as ") + 'a string in <Link to="..."> and the router will parse it for you.';
}
o(se, "getInvalidPathError");
function de(e) {
  return e.filter((t, r) => r === 0 || t.route.path && t.route.path.length > 0);
}
o(de, "getPathContributingMatches");
function fe(e, t, r, a) {
  a === void 0 && (a = !1);
  let n;
  typeof e == "string" ? n = O(e) : (n = z({}, e), E(!n.pathname || !n.pathname.includes("?"), se("?", "pathname", "search", n)), E(!n.pathname || !n.pathname.includes("#"), se("#", "pathname", "hash", n)), E(!n.search || !n.search.includes("#"), se("#", "search", "hash", n)));
  let l = e === "" || n.pathname === "", i = l ? "/" : n.pathname, s;
  if (a || i == null)
    s = r;
  else {
    let y = t.length - 1;
    if (i.startsWith("..")) {
      let R = i.split("/");
      for (; R[0] === ".."; )
        R.shift(), y -= 1;
      n.pathname = R.join("/");
    }
    s = y >= 0 ? t[y] : "/";
  }
  let d = ce(n, s), u = i && i !== "/" && i.endsWith("/"), h = (l || i === ".") && r.endsWith("/");
  return !d.pathname.endsWith("/") && (u || h) && (d.pathname += "/"), d;
}
o(fe, "resolveTo");
var H = /* @__PURE__ */ o((e) => e.join("/").replace(/\/\/+/g, "/"), "joinPaths");
var ft = /* @__PURE__ */ o((e) => !e || e === "?" ? "" : e.startsWith("?") ? e : "?" + e, "normalizeSearch"), ht = /* @__PURE__ */ o((e) => !e || e === "#" ? "" : e.startsWith("#") ? e : "#" + e, "normalizeHash");
function Q(e) {
  return e != null && typeof e.status == "number" && typeof e.statusText == "string" && typeof e.internal == "boolean" && "data" in e;
}
o(Q, "isRouteErrorResponse");
var je = ["post", "put", "patch", "delete"], mr = new Set(je), pt = ["get", ...je], yr = new Set(pt);
var gr = Symbol("deferred");

// ../node_modules/react-router/dist/index.js
function he() {
  return he = Object.assign ? Object.assign.bind() : function(e) {
    for (var t = 1; t < arguments.length; t++) {
      var r = arguments[t];
      for (var a in r)
        Object.prototype.hasOwnProperty.call(r, a) && (e[a] = r[a]);
    }
    return e;
  }, he.apply(this, arguments);
}
o(he, "_extends");
var T = c.createContext(null);
T.displayName = "DataRouter";
var I = c.createContext(null);
I.displayName = "DataRouterState";
var bt = c.createContext(null);
bt.displayName = "Await";
var D = c.createContext(null);
D.displayName = "Navigation";
var W = c.createContext(null);
W.displayName = "Location";
var L = c.createContext({
  outlet: null,
  matches: [],
  isDataRoute: !1
});
L.displayName = "Route";
var ze = c.createContext(null);
ze.displayName = "RouteError";
function pe(e, t) {
  let {
    relative: r
  } = t === void 0 ? {} : t;
  K() || E(
    !1,
    // 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: a,
    navigator: n
  } = c.useContext(D), {
    hash: l,
    pathname: i,
    search: s
  } = j(e, {
    relative: r
  }), d = i;
  return a !== "/" && (d = i === "/" ? a : H([a, i])), n.createHref({
    pathname: d,
    search: s,
    hash: l
  });
}
o(pe, "useHref");
function K() {
  return c.useContext(W) != null;
}
o(K, "useInRouterContext");
function x() {
  return K() || E(
    !1,
    // 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."
  ), c.useContext(W).location;
}
o(x, "useLocation");
var He = "You should call navigate() in a React.useEffect(), not when your component is first rendered.";
function We(e) {
  c.useContext(D).static || c.useLayoutEffect(e);
}
o(We, "useIsomorphicLayoutEffect");
function $() {
  let {
    isDataRoute: e
  } = c.useContext(L);
  return e ? xt() : wt();
}
o($, "useNavigate");
function wt() {
  K() || E(
    !1,
    // 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 = c.useContext(T), {
    basename: t,
    navigator: r
  } = c.useContext(D), {
    matches: a
  } = c.useContext(L), {
    pathname: n
  } = x(), l = JSON.stringify(de(a).map((d) => d.pathnameBase)), i = c.useRef(!1);
  return We(() => {
    i.current = !0;
  }), c.useCallback(function(d, u) {
    if (u === void 0 && (u = {}), F(i.current, He), !i.current) return;
    if (typeof d == "number") {
      r.go(d);
      return;
    }
    let h = fe(d, JSON.parse(l), n, u.relative === "path");
    e == null && t !== "/" && (h.pathname = h.pathname === "/" ? t : H([t, h.pathname])), (u.replace ? r.replace : r.push)(h, u.state, u);
  }, [t, r, l, n, e]);
}
o(wt, "useNavigateUnstable");
var Nr = c.createContext(null);
function j(e, t) {
  let {
    relative: r
  } = t === void 0 ? {} : t, {
    matches: a
  } = c.useContext(L), {
    pathname: n
  } = x(), l = JSON.stringify(de(a).map((i) => i.pathnameBase));
  return c.useMemo(() => fe(e, JSON.parse(l), n, r === "path"), [e, l, n, r]);
}
o(j, "useResolvedPath");
function Nt() {
  let e = $e(), t = Q(e) ? e.status + " " + e.statusText : e instanceof Error ? e.message : JSON.stringify(e), r = e instanceof Error ? e.stack : null, a = "rgba(200,200,200, 0.5)", n = {
    padding: "0.5rem",
    backgroundColor: a
  }, l = {
    padding: "2px 4px",
    backgroundColor: a
  }, i = null;
  return console.error("Error handled by React Router default ErrorBoundary:", e), i = c.createElement(c.Fragment, null, c.createElement("p", null, "\u{1F4BF} Hey developer \u{1F44B}"), c.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", c.createElement("code", {
    style: l
  }, "ErrorBoundary"), " or", " ", c.createElement("code", {
    style: l
  }, "errorElement"), " prop on your route.")), c.createElement(c.Fragment, null, c.createElement("h2", null, "Unexpected Application Error!"), c.createElement("h3", {
    style: {
      fontStyle: "italic"
    }
  }, t), r ? c.createElement("pre", {
    style: n
  }, r) : null, i);
}
o(Nt, "DefaultErrorComponent");
var Dr = c.createElement(Nt, null);
var Ke = function(e) {
  return e.UseBlocker = "useBlocker", e.UseRevalidator = "useRevalidator", e.UseNavigateStable = "useNavigate", e;
}(Ke || {}), M = function(e) {
  return e.UseBlocker = "useBlocker", e.UseLoaderData = "useLoaderData", e.UseActionData = "useActionData", e.UseRouteError = "useRouteError", e.UseNavigation = "useNavigation", e.UseRouteLoaderData = "useRouteLoaderData", e.UseMatches = "useMatches", e.UseRevalidator = "useRevalidator", e.UseNavigateStable = "useNavigate", e.UseRouteId = "useRouteId", e;
}(M || {});
function me(e) {
  return e + " must be used within a data router.  See https://reactrouter.com/routers/picking-a-router.";
}
o(me, "getDataRouterConsoleError");
function Dt(e) {
  let t = c.useContext(T);
  return t || E(!1, me(e)), t;
}
o(Dt, "useDataRouterContext");
function ye(e) {
  let t = c.useContext(I);
  return t || E(!1, me(e)), t;
}
o(ye, "useDataRouterState");
function St(e) {
  let t = c.useContext(L);
  return t || E(!1, me(e)), t;
}
o(St, "useRouteContext");
function ge(e) {
  let t = St(e), r = t.matches[t.matches.length - 1];
  return r.route.id || E(!1, e + ' can only be used on routes that contain a unique "id"'), r.route.id;
}
o(ge, "useCurrentRouteId");
function ve() {
  return ge(M.UseRouteId);
}
o(ve, "useRouteId");
function Re() {
  return ye(M.UseNavigation).navigation;
}
o(Re, "useNavigation");
function Ee() {
  let {
    matches: e,
    loaderData: t
  } = ye(M.UseMatches);
  return c.useMemo(() => e.map((r) => {
    let {
      pathname: a,
      params: n
    } = r;
    return {
      id: r.route.id,
      pathname: a,
      params: n,
      data: t[r.route.id],
      handle: r.route.handle
    };
  }), [e, t]);
}
o(Ee, "useMatches");
function $e() {
  var e;
  let t = c.useContext(ze), r = ye(M.UseRouteError), a = ge(M.UseRouteError);
  return t || ((e = r.errors) == null ? void 0 : e[a]);
}
o($e, "useRouteError");
function xt() {
  let {
    router: e
  } = Dt(Ke.UseNavigateStable), t = ge(M.UseNavigateStable), r = c.useRef(!1);
  return We(() => {
    r.current = !0;
  }), c.useCallback(function(n, l) {
    l === void 0 && (l = {}), F(r.current, He), r.current && (typeof n == "number" ? e.navigate(n) : e.navigate(n, he({
      fromRouteId: t
    }, l)));
  }, [e, t]);
}
o(xt, "useNavigateStable");
var Pt = "startTransition", Sr = c[Pt];
function B(e) {
  let {
    basename: t = "/",
    children: r = null,
    location: a,
    navigationType: n = S.Pop,
    navigator: l,
    static: i = !1
  } = e;
  K() && E(!1, "You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");
  let s = t.replace(/^\/*/, "/"), d = c.useMemo(() => ({
    basename: s,
    navigator: l,
    static: i
  }), [s, l, i]);
  typeof a == "string" && (a = O(a));
  let {
    pathname: u = "/",
    search: h = "",
    hash: y = "",
    state: R = null,
    key: b = "default"
  } = a, w = c.useMemo(() => {
    let m = U(u, s);
    return m == null ? null : {
      location: {
        pathname: m,
        search: h,
        hash: y,
        state: R,
        key: b
      },
      navigationType: n
    };
  }, [s, u, h, y, R, b, n]);
  return F(w != null, '<Router basename="' + s + '"> is not able to match the URL ' + ('"' + u + h + y + '" because it does not start with the ') + "basename, so the <Router> won't render anything."), w == null ? null : c.createElement(D.Provider, {
    value: d
  }, c.createElement(W.Provider, {
    children: r,
    value: w
  }));
}
o(B, "Router");
var Ct = function(e) {
  return e[e.pending = 0] = "pending", e[e.success = 1] = "success", e[e.error = 2] = "error", e;
}(Ct || {}), xr = new Promise(() => {
});

// ../node_modules/react-router-dom/dist/index.js
function _() {
  return _ = Object.assign ? Object.assign.bind() : function(e) {
    for (var t = 1; t < arguments.length; t++) {
      var r = arguments[t];
      for (var a in r)
        Object.prototype.hasOwnProperty.call(r, a) && (e[a] = r[a]);
    }
    return e;
  }, _.apply(this, arguments);
}
o(_, "_extends");
function Ne(e, t) {
  if (e == null) return {};
  var r = {}, a = Object.keys(e), n, l;
  for (l = 0; l < a.length; l++)
    n = a[l], !(t.indexOf(n) >= 0) && (r[n] = e[n]);
  return r;
}
o(Ne, "_objectWithoutPropertiesLoose");
var Z = "get", ee = "application/x-www-form-urlencoded";
function ne(e) {
  return e != null && typeof e.tagName == "string";
}
o(ne, "isHtmlElement");
function At(e) {
  return ne(e) && e.tagName.toLowerCase() === "button";
}
o(At, "isButtonElement");
function Ft(e) {
  return ne(e) && e.tagName.toLowerCase() === "form";
}
o(Ft, "isFormElement");
function Ot(e) {
  return ne(e) && e.tagName.toLowerCase() === "input";
}
o(Ot, "isInputElement");
function Ut(e) {
  return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
}
o(Ut, "isModifiedEvent");
function Mt(e, t) {
  return e.button === 0 && // Ignore everything but left clicks
  (!t || t === "_self") && // Let browser handle "target=_blank" etc.
  !Ut(e);
}
o(Mt, "shouldProcessLinkClick");
var X = null;
function Tt() {
  if (X === null)
    try {
      new FormData(
        document.createElement("form"),
        // @ts-expect-error if FormData supports the submitter parameter, this will throw
        0
      ), X = !1;
    } catch {
      X = !0;
    }
  return X;
}
o(Tt, "isFormDataSubmitterSupported");
var It = /* @__PURE__ */ new Set(["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]);
function be(e) {
  return e != null && !It.has(e) ? (F(!1, '"' + e + '" is not a valid `encType` for `<Form>`/`<fetcher.Form>` ' + ('and will default to "' + ee + '"')), null) : e;
}
o(be, "getFormEncType");
function jt(e, t) {
  let r, a, n, l, i;
  if (Ft(e)) {
    let s = e.getAttribute("action");
    a = s ? U(s, t) : null, r = e.getAttribute("method") || Z, n = be(e.getAttribute("enctype")) || ee, l = new FormData(e);
  } else if (At(e) || Ot(e) && (e.type === "submit" || e.type === "image")) {
    let s = e.form;
    if (s == null)
      throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');
    let d = e.getAttribute("formaction") || s.getAttribute("action");
    if (a = d ? U(d, t) : null, r = e.getAttribute("formmethod") || s.getAttribute("method") || Z, n = be(e.getAttribute("formenctype")) || be(s.getAttribute("enctype")) || ee, l = new FormData(s, e), !Tt()) {
      let {
        name: u,
        type: h,
        value: y
      } = e;
      if (h === "image") {
        let R = u ? u + "." : "";
        l.append(R + "x", "0"), l.append(R + "y", "0");
      } else u && l.append(u, y);
    }
  } else {
    if (ne(e))
      throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');
    r = Z, a = null, n = ee, i = e;
  }
  return l && n === "text/plain" && (i = l, l = void 0), {
    action: a,
    method: r.toLowerCase(),
    encType: n,
    formData: l,
    body: i
  };
}
o(jt, "getFormSubmissionInfo");
var Bt = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset"], kt = ["aria-current", "caseSensitive", "className", "end", "style", "to", "children"], Vt = ["reloadDocument", "replace", "state", "method", "action", "onSubmit", "submit", "relative", "preventScrollReset"];
var zt = "startTransition", te = f[zt];
function Je(e) {
  let {
    basename: t,
    children: r,
    future: a,
    window: n
  } = e, l = f.useRef();
  l.current == null && (l.current = Ie({
    window: n,
    v5Compat: !0
  }));
  let i = l.current, [s, d] = f.useState({
    action: i.action,
    location: i.location
  }), {
    v7_startTransition: u
  } = a || {}, h = f.useCallback((y) => {
    u && te ? te(() => d(y)) : d(y);
  }, [d, u]);
  return f.useLayoutEffect(() => i.listen(h), [i, h]), f.createElement(B, {
    basename: t,
    children: r,
    location: s.location,
    navigationType: s.action,
    navigator: i
  });
}
o(Je, "BrowserRouter");
function Ht(e) {
  let {
    basename: t,
    children: r,
    future: a,
    history: n
  } = e, [l, i] = f.useState({
    action: n.action,
    location: n.location
  }), {
    v7_startTransition: s
  } = a || {}, d = f.useCallback((u) => {
    s && te ? te(() => i(u)) : i(u);
  }, [i, s]);
  return f.useLayoutEffect(() => n.listen(d), [n, d]), f.createElement(B, {
    basename: t,
    children: r,
    location: l.location,
    navigationType: l.action,
    navigator: n
  });
}
o(Ht, "HistoryRouter");
Ht.displayName = "unstable_HistoryRouter";
var Wt = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", Kt = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i, ae = f.forwardRef(/* @__PURE__ */ o(function(t, r) {
  let {
    onClick: a,
    relative: n,
    reloadDocument: l,
    replace: i,
    state: s,
    target: d,
    to: u,
    preventScrollReset: h
  } = t, y = Ne(t, Bt), {
    basename: R
  } = f.useContext(D), b, w = !1;
  if (typeof u == "string" && Kt.test(u) && (b = u, Wt))
    try {
      let v = new URL(window.location.href), N = u.startsWith("//") ? new URL(v.protocol + u) : new URL(u), P = U(N.pathname, R);
      N.origin === v.origin && P != null ? u = P + N.search + N.hash : w = !0;
    } catch {
      F(!1, '<Link to="' + u + '"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.');
    }
  let m = pe(u, {
    relative: n
  }), p = Qt(u, {
    replace: i,
    state: s,
    target: d,
    preventScrollReset: h,
    relative: n
  });
  function g(v) {
    a && a(v), v.defaultPrevented || p(v);
  }
  return o(g, "handleClick"), // eslint-disable-next-line jsx-a11y/anchor-has-content
  f.createElement("a", _({}, y, {
    href: b || m,
    onClick: w || l ? a : g,
    ref: r,
    target: d
  }));
}, "LinkWithRef"));
ae.displayName = "Link";
var $t = f.forwardRef(/* @__PURE__ */ o(function(t, r) {
  let {
    "aria-current": a = "page",
    caseSensitive: n = !1,
    className: l = "",
    end: i = !1,
    style: s,
    to: d,
    children: u
  } = t, h = Ne(t, kt), y = j(d, {
    relative: h.relative
  }), R = x(), b = f.useContext(I), {
    navigator: w
  } = f.useContext(D), m = w.encodeLocation ? w.encodeLocation(y).pathname : y.pathname, p = R.pathname, g = b && b.navigation && b.navigation.location ? b.navigation.location.pathname : null;
  n || (p = p.toLowerCase(), g = g ? g.toLowerCase() : null, m = m.toLowerCase());
  let v = p === m || !i && p.startsWith(m) && p.charAt(m.length) === "/", N = g != null && (g === m || !i && g.startsWith(m) && g.charAt(m.length) === "/"), P = v ? a : void 0, A;
  typeof l == "function" ? A = l({
    isActive: v,
    isPending: N
  }) : A = [l, v ? "active" : null, N ? "pending" : null].filter(Boolean).join(" ");
  let et = typeof s == "function" ? s({
    isActive: v,
    isPending: N
  }) : s;
  return f.createElement(ae, _({}, h, {
    "aria-current": P,
    className: A,
    ref: r,
    style: et,
    to: d
  }), typeof u == "function" ? u({
    isActive: v,
    isPending: N
  }) : u);
}, "NavLinkWithRef"));
$t.displayName = "NavLink";
var Yt = f.forwardRef((e, t) => {
  let r = Gt();
  return f.createElement(qe, _({}, e, {
    submit: r,
    ref: t
  }));
});
Yt.displayName = "Form";
var qe = f.forwardRef((e, t) => {
  let {
    reloadDocument: r,
    replace: a,
    state: n,
    method: l = Z,
    action: i,
    onSubmit: s,
    submit: d,
    relative: u,
    preventScrollReset: h
  } = e, y = Ne(e, Vt), R = l.toLowerCase() === "get" ? "get" : "post", b = Zt(i, {
    relative: u
  });
  return f.createElement("form", _({
    ref: t,
    method: R,
    action: b,
    onSubmit: r ? s : /* @__PURE__ */ o((m) => {
      if (s && s(m), m.defaultPrevented) return;
      m.preventDefault();
      let p = m.nativeEvent.submitter, g = p?.getAttribute("formmethod") || l;
      d(p || m.currentTarget, {
        method: g,
        replace: a,
        state: n,
        relative: u,
        preventScrollReset: h
      });
    }, "submitHandler")
  }, y));
});
qe.displayName = "FormImpl";
function Jt(e) {
  let {
    getKey: t,
    storageKey: r
  } = e;
  return er({
    getKey: t,
    storageKey: r
  }), null;
}
o(Jt, "ScrollRestoration");
Jt.displayName = "ScrollRestoration";
var re;
(function(e) {
  e.UseScrollRestoration = "useScrollRestoration", e.UseSubmit = "useSubmit", e.UseSubmitFetcher = "useSubmitFetcher", e.UseFetcher = "useFetcher";
})(re || (re = {}));
var we;
(function(e) {
  e.UseFetchers = "useFetchers", e.UseScrollRestoration = "useScrollRestoration";
})(we || (we = {}));
function Qe(e) {
  return e + " must be used within a data router.  See https://reactrouter.com/routers/picking-a-router.";
}
o(Qe, "getDataRouterConsoleError");
function Xe(e) {
  let t = f.useContext(T);
  return t || E(!1, Qe(e)), t;
}
o(Xe, "useDataRouterContext");
function qt(e) {
  let t = f.useContext(I);
  return t || E(!1, Qe(e)), t;
}
o(qt, "useDataRouterState");
function Qt(e, t) {
  let {
    target: r,
    replace: a,
    state: n,
    preventScrollReset: l,
    relative: i
  } = t === void 0 ? {} : t, s = $(), d = x(), u = j(e, {
    relative: i
  });
  return f.useCallback((h) => {
    if (Mt(h, r)) {
      h.preventDefault();
      let y = a !== void 0 ? a : C(d) === C(u);
      s(e, {
        replace: y,
        state: n,
        preventScrollReset: l,
        relative: i
      });
    }
  }, [d, s, u, a, n, r, e, l, i]);
}
o(Qt, "useLinkClickHandler");
function Xt() {
  if (typeof document > "u")
    throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");
}
o(Xt, "validateClientSideSubmission");
function Gt() {
  let {
    router: e
  } = Xe(re.UseSubmit), {
    basename: t
  } = f.useContext(D), r = ve();
  return f.useCallback(function(a, n) {
    n === void 0 && (n = {}), Xt();
    let {
      action: l,
      method: i,
      encType: s,
      formData: d,
      body: u
    } = jt(a, t);
    e.navigate(n.action || l, {
      preventScrollReset: n.preventScrollReset,
      formData: d,
      body: u,
      formMethod: n.method || i,
      formEncType: n.encType || s,
      replace: n.replace,
      state: n.state,
      fromRouteId: r
    });
  }, [e, t, r]);
}
o(Gt, "useSubmit");
function Zt(e, t) {
  let {
    relative: r
  } = t === void 0 ? {} : t, {
    basename: a
  } = f.useContext(D), n = f.useContext(L);
  n || E(!1, "useFormAction must be used inside a RouteContext");
  let [l] = n.matches.slice(-1), i = _({}, j(e || ".", {
    relative: r
  })), s = x();
  if (e == null && (i.search = s.search, l.route.index)) {
    let d = new URLSearchParams(i.search);
    d.delete("index"), i.search = d.toString() ? "?" + d.toString() : "";
  }
  return (!e || e === ".") && l.route.index && (i.search = i.search ? i.search.replace(/^\?/, "?index&") : "?index"), a !== "/" && (i.pathname = i.pathname === "/" ? a : H([a, i.pathname])), C(i);
}
o(Zt, "useFormAction");
var Ye = "react-router-scroll-positions", G = {};
function er(e) {
  let {
    getKey: t,
    storageKey: r
  } = e === void 0 ? {} : e, {
    router: a
  } = Xe(re.UseScrollRestoration), {
    restoreScrollPosition: n,
    preventScrollReset: l
  } = qt(we.UseScrollRestoration), {
    basename: i
  } = f.useContext(D), s = x(), d = Ee(), u = Re();
  f.useEffect(() => (window.history.scrollRestoration = "manual", () => {
    window.history.scrollRestoration = "auto";
  }), []), tr(f.useCallback(() => {
    if (u.state === "idle") {
      let h = (t ? t(s, d) : null) || s.key;
      G[h] = window.scrollY;
    }
    sessionStorage.setItem(r || Ye, JSON.stringify(G)), window.history.scrollRestoration = "auto";
  }, [r, t, u.state, s, d])), typeof document < "u" && (f.useLayoutEffect(() => {
    try {
      let h = sessionStorage.getItem(r || Ye);
      h && (G = JSON.parse(h));
    } catch {
    }
  }, [r]), f.useLayoutEffect(() => {
    let h = t && i !== "/" ? (R, b) => t(
      // Strip the basename to match useLocation()
      _({}, R, {
        pathname: U(R.pathname, i) || R.pathname
      }),
      b
    ) : t, y = a?.enableScrollRestoration(G, () => window.scrollY, h);
    return () => y && y();
  }, [a, i, t]), f.useLayoutEffect(() => {
    if (n !== !1) {
      if (typeof n == "number") {
        window.scrollTo(0, n);
        return;
      }
      if (s.hash) {
        let h = document.getElementById(decodeURIComponent(s.hash.slice(1)));
        if (h) {
          h.scrollIntoView();
          return;
        }
      }
      l !== !0 && window.scrollTo(0, 0);
    }
  }, [s, n, l]));
}
o(er, "useScrollRestoration");
function tr(e, t) {
  let {
    capture: r
  } = t || {};
  f.useEffect(() => {
    let a = r != null ? {
      capture: r
    } : void 0;
    return window.addEventListener("pagehide", e, a), () => {
      window.removeEventListener("pagehide", e, a);
    };
  }, [e, r]);
}
o(tr, "usePageHide");

// src/router/router.tsx
var { document: De } = ar, or = /* @__PURE__ */ o(() => `${De.location.pathname}?`, "getBase"), sn = /* @__PURE__ */ o(() => {
  let e = $();
  return nr((t, { plain: r, ...a } = {}) => {
    if (typeof t == "string" && t.startsWith("#")) {
      t === "#" ? e(De.location.search) : De.location.hash = t;
      return;
    }
    if (typeof t == "string") {
      let n = r ? t : `?path=${t}`;
      return e(n, a);
    }
    if (typeof t == "number")
      return e(t);
  }, []);
}, "useNavigate"), ir = /* @__PURE__ */ o(({ to: e, children: t, ...r }) => Y.createElement(ae, { to: `${or()}path=${e}`, ...r }, t), "Link");
ir.displayName = "QueryLink";
var Ge = /* @__PURE__ */ o(({ children: e }) => {
  let t = x(), { path: r, singleStory: a } = Fe(t), { viewMode: n, storyId: l, refId: i } = Le(r);
  return Y.createElement(Y.Fragment, null, e({
    path: r || "/",
    location: t,
    viewMode: n,
    storyId: l,
    refId: i,
    singleStory: a === "true"
  }));
}, "Location");
Ge.displayName = "QueryLocation";
function Ze({
  children: e,
  path: t,
  startsWith: r = !1
}) {
  return Y.createElement(Ge, null, ({ path: a, ...n }) => e({
    match: Oe(a, t, r),
    ...n
  }));
}
o(Ze, "Match");
Ze.displayName = "QueryMatch";
function lr(e) {
  let { children: t, ...r } = e;
  return r.startsWith === void 0 && (r.startsWith = !1), Y.createElement(Ze, { ...r }, ({ match: n }) => n ? t : null);
}
o(lr, "Route");
lr.displayName = "Route";
var un = /* @__PURE__ */ o((...e) => Je(...e), "LocationProvider"), cn = /* @__PURE__ */ o((...e) => B(...e), "BaseLocationProvider");
export {
  cn as BaseLocationProvider,
  J as DEEPLY_EQUAL,
  ir as Link,
  Ge as Location,
  un as LocationProvider,
  Ze as Match,
  lr as Route,
  dr as buildArgsParam,
  oe as deepDiff,
  Oe as getMatch,
  Le as parsePath,
  Fe as queryFromLocation,
  fr as stringifyQuery,
  sn as useNavigate
};
