@workflow/web 4.1.27 → 4.1.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/build/client/assets/{encryption-CVDhlDp_.js → encryption-Cu4jq70Y.js} +2 -2
  2. package/build/client/assets/{entry.client-C_C46bD6.js → entry.client-C7XgFTHI.js} +7 -205
  3. package/build/client/assets/{highlighted-body-B3W2YXNL-DNE7dweN.js → highlighted-body-B3W2YXNL-B6-MkXV1.js} +2 -2
  4. package/build/client/assets/{home-BcCTbe4i.js → home-Yy5gk_jJ.js} +4 -4
  5. package/build/client/assets/{index-BsV8i_Jn.js → index-BQ-Xa8kF.js} +769 -330
  6. package/build/client/assets/{index-DhdkuKp5.js → index-CXBr7N7m.js} +1 -1
  7. package/build/client/assets/{manifest-f88c7f34.js → manifest-e13ef35a.js} +1 -1
  8. package/build/client/assets/{mermaid-3ZIDBTTL-B1-N6W83.js → mermaid-3ZIDBTTL-DV4S4pTo.js} +7 -7
  9. package/build/client/assets/{root-C2Eu3fUP.js → root-DQQlQnXn.js} +2 -2
  10. package/build/client/assets/{run-detail-CyImB2zR.js → run-detail-rocfw9Z5.js} +5 -5
  11. package/build/client/assets/{workflow-graph-viewer-lj3vdGSs.js → workflow-graph-viewer-De_-9tJh.js} +3 -3
  12. package/build/server/assets/{app-uVbY_-qI.js → app-kk7f8nyn.js} +873 -597
  13. package/build/server/assets/{highlighted-body-B3W2YXNL-BAlPxI2y.js → highlighted-body-B3W2YXNL-2B4n3nOV.js} +2 -2
  14. package/build/server/assets/index-BUlN7QFn.js +1164 -0
  15. package/build/server/assets/{index-ClImPOu-.js → index-z6exFZED.js} +3 -3
  16. package/build/server/assets/{mermaid-3ZIDBTTL-Ccs470KM.js → mermaid-3ZIDBTTL-KuzOfT5O.js} +2 -2
  17. package/build/server/assets/{server-build-tMGygzbW.js → server-build-DFhWV1xt.js} +37 -18
  18. package/build/server/assets/{token-NxX4H9ze.js → token-BwhgGurx.js} +2 -2
  19. package/build/server/assets/{token-util-CXI_HnNu.js → token-util-ByZXsHfd.js} +2 -2
  20. package/build/server/index.js +1 -1
  21. package/package.json +9 -9
  22. package/build/server/assets/index-hBO56emR.js +0 -1286
@@ -1439,7 +1439,7 @@ const React = /* @__PURE__ */ _mergeNamespaces({
1439
1439
  default: ReactExports
1440
1440
  }, [reactExports]);
1441
1441
  /**
1442
- * react-router v7.13.1
1442
+ * react-router v7.18.4
1443
1443
  *
1444
1444
  * Copyright (c) Remix Software Inc.
1445
1445
  *
@@ -1454,6 +1454,11 @@ var __typeError = (msg) => {
1454
1454
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
1455
1455
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1456
1456
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1457
+ var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i;
1458
+ var PROTOCOL_RELATIVE_URL_REGEX = /^[\\/]{2}/;
1459
+ function normalizeProtocolRelativeUrl(url, protocol) {
1460
+ return protocol + url.replace(/\\/g, "/");
1461
+ }
1457
1462
  function invariant$1(value, message) {
1458
1463
  if (value === false || value === null || typeof value === "undefined") {
1459
1464
  throw new Error(message);
@@ -1471,7 +1476,7 @@ function warning(cond, message) {
1471
1476
  function createKey() {
1472
1477
  return Math.random().toString(36).substring(2, 10);
1473
1478
  }
1474
- function createLocation(current, to, state = null, key, unstable_mask) {
1479
+ function createLocation(current, to, state = null, key, mask) {
1475
1480
  let location = {
1476
1481
  pathname: typeof current === "string" ? current : current.pathname,
1477
1482
  search: "",
@@ -1483,7 +1488,7 @@ function createLocation(current, to, state = null, key, unstable_mask) {
1483
1488
  // But that's a pretty big refactor to the current test suite so going to
1484
1489
  // keep as is for the time being and just let any incoming keys take precedence
1485
1490
  key: to && to.key || key || createKey(),
1486
- unstable_mask
1491
+ mask
1487
1492
  };
1488
1493
  return location;
1489
1494
  }
@@ -1650,17 +1655,16 @@ function mergeRouteUpdates(route, updates) {
1650
1655
  function matchRoutes(routes, locationArg, basename = "/") {
1651
1656
  return matchRoutesImpl(routes, locationArg, basename, false);
1652
1657
  }
1653
- function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
1658
+ function matchRoutesImpl(routes, locationArg, basename, allowPartial, precomputedBranches) {
1654
1659
  let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
1655
1660
  let pathname = stripBasename(location.pathname || "/", basename);
1656
1661
  if (pathname == null) {
1657
1662
  return null;
1658
1663
  }
1659
- let branches = flattenRoutes(routes);
1660
- rankRouteBranches(branches);
1664
+ let branches = precomputedBranches ?? flattenAndRankRoutes(routes);
1661
1665
  let matches = null;
1666
+ let decoded = decodePath(pathname);
1662
1667
  for (let i = 0; matches == null && i < branches.length; ++i) {
1663
- let decoded = decodePath(pathname);
1664
1668
  matches = matchRouteBranch(
1665
1669
  branches[i],
1666
1670
  decoded,
@@ -1680,6 +1684,11 @@ function convertRouteMatchToUiMatch(match, loaderData) {
1680
1684
  handle: route.handle
1681
1685
  };
1682
1686
  }
1687
+ function flattenAndRankRoutes(routes) {
1688
+ let branches = flattenRoutes(routes);
1689
+ rankRouteBranches(branches);
1690
+ return branches;
1691
+ }
1683
1692
  function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
1684
1693
  let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
1685
1694
  let meta = {
@@ -1721,7 +1730,18 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "",
1721
1730
  branches.push({
1722
1731
  path,
1723
1732
  score: computeScore(path, route.index),
1724
- routesMeta
1733
+ routesMeta: routesMeta.map((meta2, i) => {
1734
+ let [matcher, params] = compilePath(
1735
+ meta2.relativePath,
1736
+ meta2.caseSensitive,
1737
+ i === routesMeta.length - 1
1738
+ );
1739
+ return {
1740
+ ...meta2,
1741
+ matcher,
1742
+ compiledParams: params
1743
+ };
1744
+ })
1725
1745
  });
1726
1746
  };
1727
1747
  routes.forEach((route, index) => {
@@ -1811,9 +1831,19 @@ function matchRouteBranch(branch, pathname, allowPartial = false) {
1811
1831
  let meta = routesMeta[i];
1812
1832
  let end = i === routesMeta.length - 1;
1813
1833
  let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
1814
- let match = matchPath(
1815
- { path: meta.relativePath, caseSensitive: meta.caseSensitive, end },
1816
- remainingPathname
1834
+ let pattern = {
1835
+ path: meta.relativePath,
1836
+ caseSensitive: meta.caseSensitive,
1837
+ end
1838
+ };
1839
+ let match = (
1840
+ // Use precomputed matcher if it exists
1841
+ meta.matcher && meta.compiledParams ? matchPathImpl(
1842
+ pattern,
1843
+ remainingPathname,
1844
+ meta.matcher,
1845
+ meta.compiledParams
1846
+ ) : matchPath(pattern, remainingPathname)
1817
1847
  );
1818
1848
  let route = meta.route;
1819
1849
  if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
@@ -1854,16 +1884,22 @@ function matchPath(pattern, pathname) {
1854
1884
  pattern.caseSensitive,
1855
1885
  pattern.end
1856
1886
  );
1887
+ return matchPathImpl(pattern, pathname, matcher, compiledParams);
1888
+ }
1889
+ function matchPathImpl(pattern, pathname, matcher, compiledParams) {
1857
1890
  let match = pathname.match(matcher);
1858
1891
  if (!match) return null;
1859
1892
  let matchedPathname = match[0];
1860
- let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
1893
+ let pathnameBase = removeTrailingSlash(matchedPathname, 1);
1861
1894
  let captureGroups = match.slice(1);
1862
1895
  let params = compiledParams.reduce(
1863
1896
  (memo2, { paramName, isOptional }, index) => {
1864
1897
  if (paramName === "*") {
1865
1898
  let splatValue = captureGroups[index] || "";
1866
- pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
1899
+ pathnameBase = removeTrailingSlash(
1900
+ matchedPathname.slice(0, matchedPathname.length - splatValue.length),
1901
+ 1
1902
+ );
1867
1903
  }
1868
1904
  const value = captureGroups[index];
1869
1905
  if (isOptional && !value) {
@@ -1942,7 +1978,6 @@ function prependBasename({
1942
1978
  }) {
1943
1979
  return pathname === "/" ? basename : joinPaths([basename, pathname]);
1944
1980
  }
1945
- var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
1946
1981
  var isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX.test(url);
1947
1982
  function resolvePath(to, fromPathname = "/") {
1948
1983
  let {
@@ -1952,8 +1987,8 @@ function resolvePath(to, fromPathname = "/") {
1952
1987
  } = typeof to === "string" ? parsePath(to) : to;
1953
1988
  let pathname;
1954
1989
  if (toPathname) {
1955
- toPathname = toPathname.replace(/\/\/+/g, "/");
1956
- if (toPathname.startsWith("/")) {
1990
+ toPathname = removeDoubleSlashes(toPathname);
1991
+ if (toPathname.startsWith("/") || toPathname.startsWith("\\")) {
1957
1992
  pathname = resolvePathname(toPathname.substring(1), "/");
1958
1993
  } else {
1959
1994
  pathname = resolvePathname(toPathname, fromPathname);
@@ -1968,7 +2003,7 @@ function resolvePath(to, fromPathname = "/") {
1968
2003
  };
1969
2004
  }
1970
2005
  function resolvePathname(relativePath, fromPathname) {
1971
- let segments = fromPathname.replace(/\/+$/, "").split("/");
2006
+ let segments = removeTrailingSlash(fromPathname).split("/");
1972
2007
  let relativeSegments = relativePath.split("/");
1973
2008
  relativeSegments.forEach((segment) => {
1974
2009
  if (segment === "..") {
@@ -2039,8 +2074,16 @@ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = fal
2039
2074
  }
2040
2075
  return path;
2041
2076
  }
2042
- var joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
2043
- var normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
2077
+ var removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/");
2078
+ var joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
2079
+ function removeTrailingSlash(path, minLength = 0) {
2080
+ let end = path.length;
2081
+ while (end > minLength && path.charCodeAt(end - 1) === 47) {
2082
+ end--;
2083
+ }
2084
+ return end === path.length ? path : path.slice(0, end);
2085
+ }
2086
+ var normalizePathname = (pathname) => removeTrailingSlash(pathname).replace(/^\/*/, "/");
2044
2087
  var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
2045
2088
  var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
2046
2089
  var redirect = (url, init = 302) => {
@@ -2064,6 +2107,14 @@ var replace = (url, init) => {
2064
2107
  response.headers.set("X-Remix-Replace", "true");
2065
2108
  return response;
2066
2109
  };
2110
+ var SUPPORTED_ERROR_TYPES = [
2111
+ "EvalError",
2112
+ "RangeError",
2113
+ "ReferenceError",
2114
+ "SyntaxError",
2115
+ "TypeError",
2116
+ "URIError"
2117
+ ];
2067
2118
  var ErrorResponseImpl = class {
2068
2119
  constructor(status, statusText, data2, internal = false) {
2069
2120
  this.status = status;
@@ -2081,7 +2132,8 @@ function isRouteErrorResponse(error) {
2081
2132
  return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
2082
2133
  }
2083
2134
  function getRoutePattern(matches) {
2084
- return matches.map((m) => m.route.path).filter(Boolean).join("/").replace(/\/\/*/g, "/") || "/";
2135
+ let parts = matches.map((m) => m.route.path).filter(Boolean);
2136
+ return joinPaths(parts) || "/";
2085
2137
  }
2086
2138
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
2087
2139
  function parseToInfo(_to, basename) {
@@ -2098,7 +2150,7 @@ function parseToInfo(_to, basename) {
2098
2150
  if (isBrowser) {
2099
2151
  try {
2100
2152
  let currentUrl = new URL(window.location.href);
2101
- let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
2153
+ let targetUrl = PROTOCOL_RELATIVE_URL_REGEX.test(to) ? new URL(normalizeProtocolRelativeUrl(to, currentUrl.protocol)) : new URL(to);
2102
2154
  let path = stripBasename(targetUrl.pathname, basename);
2103
2155
  if (targetUrl.origin === currentUrl.origin && path != null) {
2104
2156
  to = path + targetUrl.search + targetUrl.hash;
@@ -2290,11 +2342,11 @@ async function recurseRight(impls, info, handler, index) {
2290
2342
  };
2291
2343
  }
2292
2344
  function getHandlerInfo(args) {
2293
- let { request, context, params, unstable_pattern } = args;
2345
+ let { request, context, params, pattern } = args;
2294
2346
  return {
2295
2347
  request: getReadonlyRequest(request),
2296
2348
  params: { ...params },
2297
- unstable_pattern,
2349
+ pattern,
2298
2350
  context: getReadonlyContext(context)
2299
2351
  };
2300
2352
  }
@@ -2326,6 +2378,49 @@ function isPlainObject(thing) {
2326
2378
  const proto = Object.getPrototypeOf(thing);
2327
2379
  return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === objectProtoNames;
2328
2380
  }
2381
+ var DEFAULT_NAVIGATION_URL = new URL("http://localhost");
2382
+ function getNavigatorCurrentUrl(navigator) {
2383
+ if (navigator.createURL) {
2384
+ return navigator.createURL("/");
2385
+ }
2386
+ try {
2387
+ return new URL(navigator.createHref("/"), DEFAULT_NAVIGATION_URL);
2388
+ } catch {
2389
+ return DEFAULT_NAVIGATION_URL;
2390
+ }
2391
+ }
2392
+ function isSameOrigin(a, b) {
2393
+ return a.origin === b.origin && (a.origin !== "null" || a.protocol === b.protocol && a.host === b.host);
2394
+ }
2395
+ function isExplicitUrl(destination, target) {
2396
+ if (destination.startsWith("//")) {
2397
+ return true;
2398
+ }
2399
+ let protocol = target.protocol.toLowerCase();
2400
+ if (!destination.toLowerCase().startsWith(protocol)) {
2401
+ return false;
2402
+ }
2403
+ return target.host === "" || destination.slice(protocol.length).startsWith("//");
2404
+ }
2405
+ function validateNavigationTarget(original, resolved, currentUrl, externalPolicy) {
2406
+ let originalUrl = null;
2407
+ try {
2408
+ originalUrl = original == null ? null : new URL(original, currentUrl);
2409
+ } catch {
2410
+ }
2411
+ let resolvedUrl = new URL(resolved, currentUrl);
2412
+ let originalIsExternal = originalUrl != null && !isSameOrigin(originalUrl, currentUrl);
2413
+ let resolvedIsExternal = !isSameOrigin(resolvedUrl, currentUrl);
2414
+ if (externalPolicy === "reject") {
2415
+ if (originalIsExternal || resolvedIsExternal) {
2416
+ throw new Error("External navigation is not allowed");
2417
+ }
2418
+ } else if (resolvedIsExternal) {
2419
+ if (originalUrl == null || !isExplicitUrl(original, originalUrl) || !isSameOrigin(originalUrl, resolvedUrl)) {
2420
+ throw new Error("External navigation is not allowed");
2421
+ }
2422
+ }
2423
+ }
2329
2424
  var validMutationMethodsArr = [
2330
2425
  "POST",
2331
2426
  "PUT",
@@ -2344,6 +2439,8 @@ var redirectStatusCodes = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
2344
2439
  var IDLE_NAVIGATION = {
2345
2440
  state: "idle",
2346
2441
  location: void 0,
2442
+ matches: void 0,
2443
+ historyAction: void 0,
2347
2444
  formMethod: void 0,
2348
2445
  formAction: void 0,
2349
2446
  formEncType: void 0,
@@ -2380,8 +2477,11 @@ function createStaticHandler(routes, opts) {
2380
2477
  let basename = (opts ? opts.basename : null) || "/";
2381
2478
  let _mapRouteProperties = (opts == null ? void 0 : opts.mapRouteProperties) || defaultMapRouteProperties;
2382
2479
  let mapRouteProperties2 = _mapRouteProperties;
2383
- if (opts == null ? void 0 : opts.unstable_instrumentations) {
2384
- let instrumentations = opts.unstable_instrumentations;
2480
+ ({
2481
+ ...opts == null ? void 0 : opts.future
2482
+ });
2483
+ if (opts == null ? void 0 : opts.instrumentations) {
2484
+ let instrumentations = opts.instrumentations;
2385
2485
  mapRouteProperties2 = (route) => {
2386
2486
  return {
2387
2487
  ..._mapRouteProperties(route),
@@ -2398,18 +2498,31 @@ function createStaticHandler(routes, opts) {
2398
2498
  void 0,
2399
2499
  manifest
2400
2500
  );
2501
+ let routeBranches = flattenAndRankRoutes(dataRoutes);
2401
2502
  async function query(request, {
2402
2503
  requestContext,
2403
2504
  filterMatchesToLoad,
2404
2505
  skipLoaderErrorBubbling,
2405
2506
  skipRevalidation,
2406
2507
  dataStrategy,
2407
- generateMiddlewareResponse
2508
+ generateMiddlewareResponse,
2509
+ normalizePath
2408
2510
  } = {}) {
2409
- let url = new URL(request.url);
2511
+ let normalizePathImpl = normalizePath || defaultNormalizePath;
2410
2512
  let method = request.method;
2411
- let location = createLocation("", createPath(url), null, "default");
2412
- let matches = matchRoutes(dataRoutes, location, basename);
2513
+ let location = createLocation(
2514
+ "",
2515
+ normalizePathImpl(request),
2516
+ null,
2517
+ "default"
2518
+ );
2519
+ let matches = matchRoutesImpl(
2520
+ dataRoutes,
2521
+ location,
2522
+ basename,
2523
+ false,
2524
+ routeBranches
2525
+ );
2413
2526
  requestContext = requestContext != null ? requestContext : new RouterContextProvider();
2414
2527
  if (!isValidMethod(method) && method !== "HEAD") {
2415
2528
  let error = getInternalRouterError(405, { method });
@@ -2461,7 +2574,8 @@ function createStaticHandler(routes, opts) {
2461
2574
  let response = await runServerMiddlewarePipeline(
2462
2575
  {
2463
2576
  request,
2464
- unstable_pattern: getRoutePattern(matches),
2577
+ url: createDataFunctionUrl(request, location),
2578
+ pattern: getRoutePattern(matches),
2465
2579
  matches,
2466
2580
  params: matches[0].params,
2467
2581
  // If we're calling middleware then it must be enabled so we can cast
@@ -2578,12 +2692,24 @@ function createStaticHandler(routes, opts) {
2578
2692
  routeId,
2579
2693
  requestContext,
2580
2694
  dataStrategy,
2581
- generateMiddlewareResponse
2695
+ generateMiddlewareResponse,
2696
+ normalizePath
2582
2697
  } = {}) {
2583
- let url = new URL(request.url);
2698
+ let normalizePathImpl = normalizePath || defaultNormalizePath;
2584
2699
  let method = request.method;
2585
- let location = createLocation("", createPath(url), null, "default");
2586
- let matches = matchRoutes(dataRoutes, location, basename);
2700
+ let location = createLocation(
2701
+ "",
2702
+ normalizePathImpl(request),
2703
+ null,
2704
+ "default"
2705
+ );
2706
+ let matches = matchRoutesImpl(
2707
+ dataRoutes,
2708
+ location,
2709
+ basename,
2710
+ false,
2711
+ routeBranches
2712
+ );
2587
2713
  requestContext = requestContext != null ? requestContext : new RouterContextProvider();
2588
2714
  if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
2589
2715
  throw getInternalRouterError(405, { method });
@@ -2608,7 +2734,8 @@ function createStaticHandler(routes, opts) {
2608
2734
  let response = await runServerMiddlewarePipeline(
2609
2735
  {
2610
2736
  request,
2611
- unstable_pattern: getRoutePattern(matches),
2737
+ url: createDataFunctionUrl(request, location),
2738
+ pattern: getRoutePattern(matches),
2612
2739
  matches,
2613
2740
  params: matches[0].params,
2614
2741
  // If we're calling middleware then it must be enabled so we can cast
@@ -2685,6 +2812,7 @@ function createStaticHandler(routes, opts) {
2685
2812
  if (isMutationMethod(request.method)) {
2686
2813
  let result2 = await submit(
2687
2814
  request,
2815
+ location,
2688
2816
  matches,
2689
2817
  routeMatch || getTargetMatch(matches, location),
2690
2818
  requestContext,
@@ -2698,6 +2826,7 @@ function createStaticHandler(routes, opts) {
2698
2826
  }
2699
2827
  let result = await loadRouteData(
2700
2828
  request,
2829
+ location,
2701
2830
  matches,
2702
2831
  requestContext,
2703
2832
  dataStrategy,
@@ -2723,7 +2852,7 @@ function createStaticHandler(routes, opts) {
2723
2852
  throw e;
2724
2853
  }
2725
2854
  }
2726
- async function submit(request, matches, actionMatch, requestContext, dataStrategy, skipLoaderErrorBubbling, isRouteRequest, filterMatchesToLoad, skipRevalidation) {
2855
+ async function submit(request, location, matches, actionMatch, requestContext, dataStrategy, skipLoaderErrorBubbling, isRouteRequest, filterMatchesToLoad, skipRevalidation) {
2727
2856
  let result;
2728
2857
  if (!actionMatch.route.action && !actionMatch.route.lazy) {
2729
2858
  let error = getInternalRouterError(405, {
@@ -2743,6 +2872,7 @@ function createStaticHandler(routes, opts) {
2743
2872
  mapRouteProperties2,
2744
2873
  manifest,
2745
2874
  request,
2875
+ location,
2746
2876
  matches,
2747
2877
  actionMatch,
2748
2878
  [],
@@ -2750,6 +2880,7 @@ function createStaticHandler(routes, opts) {
2750
2880
  );
2751
2881
  let results = await callDataStrategy(
2752
2882
  request,
2883
+ location,
2753
2884
  dsMatches,
2754
2885
  isRouteRequest,
2755
2886
  requestContext,
@@ -2823,6 +2954,7 @@ function createStaticHandler(routes, opts) {
2823
2954
  let boundaryMatch = skipLoaderErrorBubbling ? actionMatch : findNearestBoundary(matches, actionMatch.route.id);
2824
2955
  let handlerContext2 = await loadRouteData(
2825
2956
  loaderRequest,
2957
+ location,
2826
2958
  matches,
2827
2959
  requestContext,
2828
2960
  dataStrategy,
@@ -2842,6 +2974,7 @@ function createStaticHandler(routes, opts) {
2842
2974
  }
2843
2975
  let handlerContext = await loadRouteData(
2844
2976
  loaderRequest,
2977
+ location,
2845
2978
  matches,
2846
2979
  requestContext,
2847
2980
  dataStrategy,
@@ -2859,7 +2992,7 @@ function createStaticHandler(routes, opts) {
2859
2992
  actionHeaders: result.headers ? { [actionMatch.route.id]: result.headers } : {}
2860
2993
  };
2861
2994
  }
2862
- async function loadRouteData(request, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, pendingActionResult) {
2995
+ async function loadRouteData(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, pendingActionResult) {
2863
2996
  let isRouteRequest = routeMatch != null;
2864
2997
  if (isRouteRequest && !(routeMatch == null ? void 0 : routeMatch.route.loader) && !(routeMatch == null ? void 0 : routeMatch.route.lazy)) {
2865
2998
  throw getInternalRouterError(400, {
@@ -2874,6 +3007,7 @@ function createStaticHandler(routes, opts) {
2874
3007
  mapRouteProperties2,
2875
3008
  manifest,
2876
3009
  request,
3010
+ location,
2877
3011
  matches,
2878
3012
  routeMatch,
2879
3013
  [],
@@ -2891,6 +3025,7 @@ function createStaticHandler(routes, opts) {
2891
3025
  mapRouteProperties2,
2892
3026
  manifest,
2893
3027
  request,
3028
+ location,
2894
3029
  pattern,
2895
3030
  match,
2896
3031
  [],
@@ -2902,6 +3037,7 @@ function createStaticHandler(routes, opts) {
2902
3037
  mapRouteProperties2,
2903
3038
  manifest,
2904
3039
  request,
3040
+ location,
2905
3041
  pattern,
2906
3042
  match,
2907
3043
  [],
@@ -2923,6 +3059,7 @@ function createStaticHandler(routes, opts) {
2923
3059
  }
2924
3060
  let results = await callDataStrategy(
2925
3061
  request,
3062
+ location,
2926
3063
  dsMatches,
2927
3064
  isRouteRequest,
2928
3065
  requestContext,
@@ -2943,10 +3080,11 @@ function createStaticHandler(routes, opts) {
2943
3080
  matches
2944
3081
  };
2945
3082
  }
2946
- async function callDataStrategy(request, matches, isRouteRequest, requestContext, dataStrategy) {
3083
+ async function callDataStrategy(request, location, matches, isRouteRequest, requestContext, dataStrategy) {
2947
3084
  let results = await callDataStrategyImpl(
2948
3085
  dataStrategy || defaultDataStrategy,
2949
3086
  request,
3087
+ location,
2950
3088
  matches,
2951
3089
  null,
2952
3090
  requestContext
@@ -2982,6 +3120,7 @@ function createStaticHandler(routes, opts) {
2982
3120
  }
2983
3121
  return {
2984
3122
  dataRoutes,
3123
+ _internalRouteBranches: routeBranches,
2985
3124
  query,
2986
3125
  queryRoute
2987
3126
  };
@@ -3005,6 +3144,14 @@ function throwStaticHandlerAbortedError(request, isRouteRequest) {
3005
3144
  `${method}() call aborted without an \`AbortSignal.reason\`: ${request.method} ${request.url}`
3006
3145
  );
3007
3146
  }
3147
+ function defaultNormalizePath(request) {
3148
+ let url = new URL(request.url);
3149
+ return {
3150
+ pathname: url.pathname,
3151
+ search: url.search,
3152
+ hash: url.hash
3153
+ };
3154
+ }
3008
3155
  function normalizeTo(location, matches, basename, to, fromRouteId, relative) {
3009
3156
  let contextualMatches;
3010
3157
  let activeRouteMatch;
@@ -3242,17 +3389,12 @@ function runServerMiddlewarePipeline(args, handler, errorHandler) {
3242
3389
  }
3243
3390
  }
3244
3391
  async function runMiddlewarePipeline(args, handler, processResult, isResult, errorHandler) {
3245
- let { matches, request, params, context, unstable_pattern } = args;
3392
+ let { matches, ...dataFnArgs } = args;
3246
3393
  let tuples = matches.flatMap(
3247
3394
  (m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
3248
3395
  );
3249
3396
  let result = await callRouteMiddleware(
3250
- {
3251
- request,
3252
- params,
3253
- context,
3254
- unstable_pattern
3255
- },
3397
+ dataFnArgs,
3256
3398
  tuples,
3257
3399
  handler,
3258
3400
  processResult,
@@ -3330,7 +3472,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
3330
3472
  handler: lazyRoutePromises.lazyHandlerPromise
3331
3473
  };
3332
3474
  }
3333
- function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
3475
+ function getDataStrategyMatch(mapRouteProperties2, manifest, request, path, pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
3334
3476
  let isUsingNewApi = false;
3335
3477
  let _lazyPromises = getDataStrategyMatchLazyPromises(
3336
3478
  mapRouteProperties2,
@@ -3364,7 +3506,8 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_p
3364
3506
  if (callHandler && (isMutationMethod(request.method) || !isMiddlewareOnlyRoute)) {
3365
3507
  return callLoaderOrAction({
3366
3508
  request,
3367
- unstable_pattern,
3509
+ path,
3510
+ pattern,
3368
3511
  match,
3369
3512
  lazyHandlerPromise: _lazyPromises == null ? void 0 : _lazyPromises.handler,
3370
3513
  lazyRoutePromise: _lazyPromises == null ? void 0 : _lazyPromises.route,
@@ -3376,7 +3519,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_p
3376
3519
  }
3377
3520
  };
3378
3521
  }
3379
- function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request, matches, targetMatch, lazyRoutePropertiesToSkip, scopedContext, shouldRevalidateArgs = null) {
3522
+ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request, path, matches, targetMatch, lazyRoutePropertiesToSkip, scopedContext, shouldRevalidateArgs = null) {
3380
3523
  return matches.map((match) => {
3381
3524
  if (match.route.id !== targetMatch.route.id) {
3382
3525
  return {
@@ -3398,6 +3541,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
3398
3541
  mapRouteProperties2,
3399
3542
  manifest,
3400
3543
  request,
3544
+ path,
3401
3545
  getRoutePattern(matches),
3402
3546
  match,
3403
3547
  lazyRoutePropertiesToSkip,
@@ -3407,7 +3551,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
3407
3551
  );
3408
3552
  });
3409
3553
  }
3410
- async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherKey, scopedContext, isStaticHandler) {
3554
+ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fetcherKey, scopedContext, isStaticHandler) {
3411
3555
  if (matches.some((m) => {
3412
3556
  var _a;
3413
3557
  return (_a = m._lazyPromises) == null ? void 0 : _a.middleware;
@@ -3419,7 +3563,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
3419
3563
  }
3420
3564
  let dataStrategyArgs = {
3421
3565
  request,
3422
- unstable_pattern: getRoutePattern(matches),
3566
+ url: createDataFunctionUrl(request, path),
3567
+ pattern: getRoutePattern(matches),
3423
3568
  params: matches[0].params,
3424
3569
  context: scopedContext,
3425
3570
  matches
@@ -3450,7 +3595,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
3450
3595
  }
3451
3596
  async function callLoaderOrAction({
3452
3597
  request,
3453
- unstable_pattern,
3598
+ path,
3599
+ pattern,
3454
3600
  match,
3455
3601
  lazyHandlerPromise,
3456
3602
  lazyRoutePromise,
@@ -3477,7 +3623,8 @@ async function callLoaderOrAction({
3477
3623
  return handler(
3478
3624
  {
3479
3625
  request,
3480
- unstable_pattern,
3626
+ url: createDataFunctionUrl(request, path),
3627
+ pattern,
3481
3628
  params: match.params,
3482
3629
  context: scopedContext
3483
3630
  },
@@ -3635,6 +3782,44 @@ function normalizeRelativeRoutingRedirectResponse(response, request, routeId, ma
3635
3782
  }
3636
3783
  return response;
3637
3784
  }
3785
+ var invalidProtocols = [
3786
+ "about:",
3787
+ "blob:",
3788
+ "chrome:",
3789
+ "chrome-untrusted:",
3790
+ "content:",
3791
+ "data:",
3792
+ "devtools:",
3793
+ "file:",
3794
+ "filesystem:",
3795
+ // eslint-disable-next-line no-script-url
3796
+ "javascript:"
3797
+ ];
3798
+ function hasInvalidProtocol(location) {
3799
+ try {
3800
+ return invalidProtocols.includes(new URL(location).protocol);
3801
+ } catch {
3802
+ return false;
3803
+ }
3804
+ }
3805
+ function createDataFunctionUrl(request, path) {
3806
+ let url = new URL(request.url);
3807
+ let parsed = typeof path === "string" ? parsePath(path) : path;
3808
+ url.pathname = parsed.pathname || "/";
3809
+ if (parsed.search) {
3810
+ let searchParams = new URLSearchParams(parsed.search);
3811
+ let indexValues = searchParams.getAll("index");
3812
+ searchParams.delete("index");
3813
+ for (let value of indexValues.filter(Boolean)) {
3814
+ searchParams.append("index", value);
3815
+ }
3816
+ url.search = searchParams.size ? `?${searchParams.toString()}` : "";
3817
+ } else {
3818
+ url.search = "";
3819
+ }
3820
+ url.hash = parsed.hash || "";
3821
+ return url;
3822
+ }
3638
3823
  function processRouteLoaderData(matches, results, pendingActionResult, isStaticHandler = false, skipLoaderErrorBubbling = false) {
3639
3824
  let loaderData = {};
3640
3825
  let errors = null;
@@ -3945,6 +4130,12 @@ function useNavigateUnstable() {
3945
4130
  if (dataRouterContext == null && basename !== "/") {
3946
4131
  path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
3947
4132
  }
4133
+ validateNavigationTarget(
4134
+ typeof to === "string" ? to : createPath(to),
4135
+ navigator.createHref(path),
4136
+ getNavigatorCurrentUrl(navigator),
4137
+ "reject"
4138
+ );
3948
4139
  (!!options.replace ? navigator.replace : navigator.push)(
3949
4140
  path,
3950
4141
  options.state,
@@ -3972,7 +4163,7 @@ function useOutlet(context) {
3972
4163
  function useParams() {
3973
4164
  let { matches } = reactExports.useContext(RouteContext);
3974
4165
  let routeMatch = matches[matches.length - 1];
3975
- return routeMatch ? routeMatch.params : {};
4166
+ return (routeMatch == null ? void 0 : routeMatch.params) ?? {};
3976
4167
  }
3977
4168
  function useResolvedPath(to, { relative } = {}) {
3978
4169
  let { matches } = reactExports.useContext(RouteContext);
@@ -4024,7 +4215,15 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
4024
4215
  let segments = pathname.replace(/^\//, "").split("/");
4025
4216
  remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
4026
4217
  }
4027
- let matches = matchRoutes(routes, { pathname: remainingPathname });
4218
+ let matches = dataRouterOpts && dataRouterOpts.state.matches.length ? (
4219
+ // If we're in a data router, use the matches we've already identified but ensure
4220
+ // we have the latest route instances from the manifest in case elements have changed
4221
+ dataRouterOpts.state.matches.map(
4222
+ (m) => Object.assign(m, {
4223
+ route: dataRouterOpts.manifest[m.route.id] || m.route
4224
+ })
4225
+ )
4226
+ ) : matchRoutes(routes, { pathname: remainingPathname });
4028
4227
  {
4029
4228
  warning(
4030
4229
  parentRoute || matches != null,
@@ -4042,21 +4241,21 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
4042
4241
  pathname: joinPaths([
4043
4242
  parentPathnameBase,
4044
4243
  // Re-encode pathnames that were decoded inside matchRoutes.
4045
- // Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
4244
+ // Pre-encode `%`, `?` and `#` ahead of `encodeLocation` because it uses
4046
4245
  // `new URL()` internally and we need to prevent it from treating
4047
4246
  // them as separators
4048
4247
  navigator.encodeLocation ? navigator.encodeLocation(
4049
- match.pathname.replace(/\?/g, "%3F").replace(/#/g, "%23")
4248
+ match.pathname.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23")
4050
4249
  ).pathname : match.pathname
4051
4250
  ]),
4052
4251
  pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
4053
4252
  parentPathnameBase,
4054
4253
  // Re-encode pathnames that were decoded inside matchRoutes
4055
- // Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
4254
+ // Pre-encode `%`, `?` and `#` ahead of `encodeLocation` because it uses
4056
4255
  // `new URL()` internally and we need to prevent it from treating
4057
4256
  // them as separators
4058
4257
  navigator.encodeLocation ? navigator.encodeLocation(
4059
- match.pathnameBase.replace(/\?/g, "%3F").replace(/#/g, "%23")
4258
+ match.pathnameBase.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23")
4060
4259
  ).pathname : match.pathnameBase
4061
4260
  ])
4062
4261
  })
@@ -4145,16 +4344,26 @@ function RSCErrorHandler({
4145
4344
  children,
4146
4345
  error
4147
4346
  }) {
4148
- let { basename } = reactExports.useContext(NavigationContext);
4347
+ let { basename, navigator } = reactExports.useContext(NavigationContext);
4149
4348
  if (typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
4150
4349
  let redirect2 = decodeRedirectErrorDigest(error.digest);
4151
4350
  if (redirect2) {
4152
4351
  let existingRedirect = errorRedirectHandledMap.get(error);
4153
4352
  if (existingRedirect) throw existingRedirect;
4154
4353
  let parsed = parseToInfo(redirect2.location, basename);
4354
+ let target = parsed.absoluteURL || parsed.to;
4355
+ validateNavigationTarget(
4356
+ redirect2.location,
4357
+ target,
4358
+ getNavigatorCurrentUrl(navigator),
4359
+ "allow-explicit"
4360
+ );
4361
+ if (hasInvalidProtocol(target)) {
4362
+ throw new Error("Invalid redirect location");
4363
+ }
4155
4364
  if (isBrowser && !errorRedirectHandledMap.get(error)) {
4156
4365
  if (parsed.isExternal || redirect2.reloadDocument) {
4157
- window.location.href = parsed.absoluteURL || parsed.to;
4366
+ window.location.href = target;
4158
4367
  } else {
4159
4368
  const redirectPromise = Promise.resolve().then(
4160
4369
  () => window.__reactRouterDataRouter.navigate(parsed.to, {
@@ -4165,13 +4374,7 @@ function RSCErrorHandler({
4165
4374
  throw redirectPromise;
4166
4375
  }
4167
4376
  }
4168
- return /* @__PURE__ */ reactExports.createElement(
4169
- "meta",
4170
- {
4171
- httpEquiv: "refresh",
4172
- content: `0;url=${parsed.absoluteURL || parsed.to}`
4173
- }
4174
- );
4377
+ return /* @__PURE__ */ reactExports.createElement("meta", { httpEquiv: "refresh", content: `0;url=${target}` });
4175
4378
  }
4176
4379
  }
4177
4380
  return children;
@@ -4246,7 +4449,7 @@ function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
4246
4449
  onErrorHandler(error, {
4247
4450
  location: dataRouterState.location,
4248
4451
  params: ((_b = (_a = dataRouterState.matches) == null ? void 0 : _a[0]) == null ? void 0 : _b.params) ?? {},
4249
- unstable_pattern: getRoutePattern(dataRouterState.matches),
4452
+ pattern: getRoutePattern(dataRouterState.matches),
4250
4453
  errorInfo
4251
4454
  });
4252
4455
  } : void 0;
@@ -4355,7 +4558,10 @@ function useNavigation() {
4355
4558
  "useNavigation"
4356
4559
  /* UseNavigation */
4357
4560
  );
4358
- return state.navigation;
4561
+ return reactExports.useMemo(() => {
4562
+ let { matches, historyAction, ...rest } = state.navigation;
4563
+ return rest;
4564
+ }, [state.navigation]);
4359
4565
  }
4360
4566
  function useMatches() {
4361
4567
  let { matches, loaderData } = useDataRouterState(
@@ -4496,15 +4702,21 @@ function mapRouteProperties(route) {
4496
4702
  }
4497
4703
  return updates;
4498
4704
  }
4499
- reactExports.memo(DataRoutes);
4500
- function DataRoutes({
4705
+ reactExports.memo(DataRoutes2);
4706
+ function DataRoutes2({
4501
4707
  routes,
4708
+ manifest,
4502
4709
  future,
4503
4710
  state,
4504
4711
  isStatic,
4505
4712
  onError
4506
4713
  }) {
4507
- return useRoutesImpl(routes, void 0, { state, isStatic, onError });
4714
+ return useRoutesImpl(routes, void 0, {
4715
+ manifest,
4716
+ state,
4717
+ isStatic,
4718
+ onError
4719
+ });
4508
4720
  }
4509
4721
  function Outlet(props) {
4510
4722
  return useOutlet(props.context);
@@ -4516,7 +4728,7 @@ function Router({
4516
4728
  navigationType = "POP",
4517
4729
  navigator,
4518
4730
  static: staticProp = false,
4519
- unstable_useTransitions
4731
+ useTransitions
4520
4732
  }) {
4521
4733
  invariant$1(
4522
4734
  !useInRouterContext(),
@@ -4528,10 +4740,10 @@ function Router({
4528
4740
  basename,
4529
4741
  navigator,
4530
4742
  static: staticProp,
4531
- unstable_useTransitions,
4743
+ useTransitions,
4532
4744
  future: {}
4533
4745
  }),
4534
- [basename, navigator, staticProp, unstable_useTransitions]
4746
+ [basename, navigator, staticProp, useTransitions]
4535
4747
  );
4536
4748
  if (typeof locationProp === "string") {
4537
4749
  locationProp = parsePath(locationProp);
@@ -4542,7 +4754,7 @@ function Router({
4542
4754
  hash = "",
4543
4755
  state = null,
4544
4756
  key = "default",
4545
- unstable_mask
4757
+ mask
4546
4758
  } = locationProp;
4547
4759
  let locationContext = reactExports.useMemo(() => {
4548
4760
  let trailingPathname = stripBasename(pathname, basename);
@@ -4556,20 +4768,11 @@ function Router({
4556
4768
  hash,
4557
4769
  state,
4558
4770
  key,
4559
- unstable_mask
4771
+ mask
4560
4772
  },
4561
4773
  navigationType
4562
4774
  };
4563
- }, [
4564
- basename,
4565
- pathname,
4566
- search,
4567
- hash,
4568
- state,
4569
- key,
4570
- navigationType,
4571
- unstable_mask
4572
- ]);
4775
+ }, [basename, pathname, search, hash, state, key, navigationType, mask]);
4573
4776
  warning(
4574
4777
  locationContext != null,
4575
4778
  `<Router basename="${basename}"> is not able to match the URL "${pathname}${search}${hash}" because it does not start with the basename, so the <Router> won't render anything.`
@@ -4778,7 +4981,10 @@ function createLineSplittingTransform() {
4778
4981
  }
4779
4982
  });
4780
4983
  }
4781
- function flatten(input) {
4984
+ var TIME_LIMIT_MS = 1;
4985
+ var getNow = () => Date.now();
4986
+ var yieldToMain = () => new Promise((resolve) => setTimeout(resolve, 0));
4987
+ async function flatten(input) {
4782
4988
  const { indices } = this;
4783
4989
  const existing = indices.get(input);
4784
4990
  if (existing) return [existing];
@@ -4790,55 +4996,76 @@ function flatten(input) {
4790
4996
  if (input === 0 && 1 / input < 0) return NEGATIVE_ZERO;
4791
4997
  const index = this.index++;
4792
4998
  indices.set(input, index);
4793
- stringify.call(this, input, index);
4999
+ const stack = [[input, index]];
5000
+ await stringify.call(this, stack);
4794
5001
  return index;
4795
5002
  }
4796
- function stringify(input, index) {
4797
- const { deferred, plugins, postPlugins } = this;
5003
+ async function stringify(stack) {
5004
+ const { deferred, indices, plugins, postPlugins } = this;
4798
5005
  const str = this.stringified;
4799
- const stack = [[input, index]];
5006
+ let lastYieldTime = getNow();
5007
+ const flattenValue = (value) => {
5008
+ const existing = indices.get(value);
5009
+ if (existing) return [existing];
5010
+ if (value === void 0) return UNDEFINED;
5011
+ if (value === null) return NULL;
5012
+ if (Number.isNaN(value)) return NAN;
5013
+ if (value === Number.POSITIVE_INFINITY) return POSITIVE_INFINITY;
5014
+ if (value === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY;
5015
+ if (value === 0 && 1 / value < 0) return NEGATIVE_ZERO;
5016
+ const index = this.index++;
5017
+ indices.set(value, index);
5018
+ stack.push([value, index]);
5019
+ return index;
5020
+ };
5021
+ let i = 0;
4800
5022
  while (stack.length > 0) {
4801
- const [input2, index2] = stack.pop();
4802
- const partsForObj = (obj) => Object.keys(obj).map((k) => `"_${flatten.call(this, k)}":${flatten.call(this, obj[k])}`).join(",");
5023
+ const now = getNow();
5024
+ if (++i % 6e3 === 0 && now - lastYieldTime >= TIME_LIMIT_MS) {
5025
+ await yieldToMain();
5026
+ lastYieldTime = getNow();
5027
+ }
5028
+ const [input, index] = stack.pop();
5029
+ const partsForObj = (obj) => Object.keys(obj).map((k) => `"_${flattenValue(k)}":${flattenValue(obj[k])}`).join(",");
4803
5030
  let error = null;
4804
- switch (typeof input2) {
5031
+ switch (typeof input) {
4805
5032
  case "boolean":
4806
5033
  case "number":
4807
5034
  case "string":
4808
- str[index2] = JSON.stringify(input2);
5035
+ str[index] = JSON.stringify(input);
4809
5036
  break;
4810
5037
  case "bigint":
4811
- str[index2] = `["${TYPE_BIGINT}","${input2}"]`;
5038
+ str[index] = `["${TYPE_BIGINT}","${input}"]`;
4812
5039
  break;
4813
5040
  case "symbol": {
4814
- const keyFor = Symbol.keyFor(input2);
5041
+ const keyFor = Symbol.keyFor(input);
4815
5042
  if (!keyFor) {
4816
5043
  error = new Error(
4817
5044
  "Cannot encode symbol unless created with Symbol.for()"
4818
5045
  );
4819
5046
  } else {
4820
- str[index2] = `["${TYPE_SYMBOL}",${JSON.stringify(keyFor)}]`;
5047
+ str[index] = `["${TYPE_SYMBOL}",${JSON.stringify(keyFor)}]`;
4821
5048
  }
4822
5049
  break;
4823
5050
  }
4824
5051
  case "object": {
4825
- if (!input2) {
4826
- str[index2] = `${NULL}`;
5052
+ if (!input) {
5053
+ str[index] = `${NULL}`;
4827
5054
  break;
4828
5055
  }
4829
- const isArray = Array.isArray(input2);
5056
+ const isArray = Array.isArray(input);
4830
5057
  let pluginHandled = false;
4831
5058
  if (!isArray && plugins) {
4832
5059
  for (const plugin of plugins) {
4833
- const pluginResult = plugin(input2);
5060
+ const pluginResult = plugin(input);
4834
5061
  if (Array.isArray(pluginResult)) {
4835
5062
  pluginHandled = true;
4836
5063
  const [pluginIdentifier, ...rest] = pluginResult;
4837
- str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
5064
+ str[index] = `[${JSON.stringify(pluginIdentifier)}`;
4838
5065
  if (rest.length > 0) {
4839
- str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
5066
+ str[index] += `,${rest.map((v) => flattenValue(v)).join(",")}`;
4840
5067
  }
4841
- str[index2] += "]";
5068
+ str[index] += "]";
4842
5069
  break;
4843
5070
  }
4844
5071
  }
@@ -4846,46 +5073,43 @@ function stringify(input, index) {
4846
5073
  if (!pluginHandled) {
4847
5074
  let result = isArray ? "[" : "{";
4848
5075
  if (isArray) {
4849
- for (let i = 0; i < input2.length; i++)
4850
- result += (i ? "," : "") + (i in input2 ? flatten.call(this, input2[i]) : HOLE);
4851
- str[index2] = `${result}]`;
4852
- } else if (input2 instanceof Date) {
4853
- const dateTime = input2.getTime();
4854
- str[index2] = `["${TYPE_DATE}",${Number.isNaN(dateTime) ? JSON.stringify("invalid") : dateTime}]`;
4855
- } else if (input2 instanceof URL) {
4856
- str[index2] = `["${TYPE_URL}",${JSON.stringify(input2.href)}]`;
4857
- } else if (input2 instanceof RegExp) {
4858
- str[index2] = `["${TYPE_REGEXP}",${JSON.stringify(
4859
- input2.source
4860
- )},${JSON.stringify(input2.flags)}]`;
4861
- } else if (input2 instanceof Set) {
4862
- if (input2.size > 0) {
4863
- str[index2] = `["${TYPE_SET}",${[...input2].map((val) => flatten.call(this, val)).join(",")}]`;
5076
+ for (let i2 = 0; i2 < input.length; i2++)
5077
+ result += (i2 ? "," : "") + (i2 in input ? flattenValue(input[i2]) : HOLE);
5078
+ str[index] = `${result}]`;
5079
+ } else if (input instanceof Date) {
5080
+ const dateTime = input.getTime();
5081
+ str[index] = `["${TYPE_DATE}",${Number.isNaN(dateTime) ? JSON.stringify("invalid") : dateTime}]`;
5082
+ } else if (input instanceof URL) {
5083
+ str[index] = `["${TYPE_URL}",${JSON.stringify(input.href)}]`;
5084
+ } else if (input instanceof RegExp) {
5085
+ str[index] = `["${TYPE_REGEXP}",${JSON.stringify(
5086
+ input.source
5087
+ )},${JSON.stringify(input.flags)}]`;
5088
+ } else if (input instanceof Set) {
5089
+ if (input.size > 0) {
5090
+ str[index] = `["${TYPE_SET}",${[...input].map((val) => flattenValue(val)).join(",")}]`;
4864
5091
  } else {
4865
- str[index2] = `["${TYPE_SET}"]`;
5092
+ str[index] = `["${TYPE_SET}"]`;
4866
5093
  }
4867
- } else if (input2 instanceof Map) {
4868
- if (input2.size > 0) {
4869
- str[index2] = `["${TYPE_MAP}",${[...input2].flatMap(([k, v]) => [
4870
- flatten.call(this, k),
4871
- flatten.call(this, v)
4872
- ]).join(",")}]`;
5094
+ } else if (input instanceof Map) {
5095
+ if (input.size > 0) {
5096
+ str[index] = `["${TYPE_MAP}",${[...input].flatMap(([k, v]) => [flattenValue(k), flattenValue(v)]).join(",")}]`;
4873
5097
  } else {
4874
- str[index2] = `["${TYPE_MAP}"]`;
5098
+ str[index] = `["${TYPE_MAP}"]`;
4875
5099
  }
4876
- } else if (input2 instanceof Promise) {
4877
- str[index2] = `["${TYPE_PROMISE}",${index2}]`;
4878
- deferred[index2] = input2;
4879
- } else if (input2 instanceof Error) {
4880
- str[index2] = `["${TYPE_ERROR}",${JSON.stringify(input2.message)}`;
4881
- if (input2.name !== "Error") {
4882
- str[index2] += `,${JSON.stringify(input2.name)}`;
5100
+ } else if (input instanceof Promise) {
5101
+ str[index] = `["${TYPE_PROMISE}",${index}]`;
5102
+ deferred[index] = input;
5103
+ } else if (input instanceof Error) {
5104
+ str[index] = `["${TYPE_ERROR}",${JSON.stringify(input.message)}`;
5105
+ if (input.name !== "Error") {
5106
+ str[index] += `,${JSON.stringify(input.name)}`;
4883
5107
  }
4884
- str[index2] += "]";
4885
- } else if (Object.getPrototypeOf(input2) === null) {
4886
- str[index2] = `["${TYPE_NULL_OBJECT}",{${partsForObj(input2)}}]`;
4887
- } else if (isPlainObject2(input2)) {
4888
- str[index2] = `{${partsForObj(input2)}}`;
5108
+ str[index] += "]";
5109
+ } else if (Object.getPrototypeOf(input) === null) {
5110
+ str[index] = `["${TYPE_NULL_OBJECT}",{${partsForObj(input)}}]`;
5111
+ } else if (isPlainObject2(input)) {
5112
+ str[index] = `{${partsForObj(input)}}`;
4889
5113
  } else {
4890
5114
  error = new Error("Cannot encode object with prototype");
4891
5115
  }
@@ -4893,19 +5117,19 @@ function stringify(input, index) {
4893
5117
  break;
4894
5118
  }
4895
5119
  default: {
4896
- const isArray = Array.isArray(input2);
5120
+ const isArray = Array.isArray(input);
4897
5121
  let pluginHandled = false;
4898
5122
  if (!isArray && plugins) {
4899
5123
  for (const plugin of plugins) {
4900
- const pluginResult = plugin(input2);
5124
+ const pluginResult = plugin(input);
4901
5125
  if (Array.isArray(pluginResult)) {
4902
5126
  pluginHandled = true;
4903
5127
  const [pluginIdentifier, ...rest] = pluginResult;
4904
- str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
5128
+ str[index] = `[${JSON.stringify(pluginIdentifier)}`;
4905
5129
  if (rest.length > 0) {
4906
- str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
5130
+ str[index] += `,${rest.map((v) => flattenValue(v)).join(",")}`;
4907
5131
  }
4908
- str[index2] += "]";
5132
+ str[index] += "]";
4909
5133
  break;
4910
5134
  }
4911
5135
  }
@@ -4919,15 +5143,15 @@ function stringify(input, index) {
4919
5143
  let pluginHandled = false;
4920
5144
  if (postPlugins) {
4921
5145
  for (const plugin of postPlugins) {
4922
- const pluginResult = plugin(input2);
5146
+ const pluginResult = plugin(input);
4923
5147
  if (Array.isArray(pluginResult)) {
4924
5148
  pluginHandled = true;
4925
5149
  const [pluginIdentifier, ...rest] = pluginResult;
4926
- str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
5150
+ str[index] = `[${JSON.stringify(pluginIdentifier)}`;
4927
5151
  if (rest.length > 0) {
4928
- str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
5152
+ str[index] += `,${rest.map((v) => flattenValue(v)).join(",")}`;
4929
5153
  }
4930
- str[index2] += "]";
5154
+ str[index] += "]";
4931
5155
  break;
4932
5156
  }
4933
5157
  }
@@ -5087,7 +5311,7 @@ function hydrate(index) {
5087
5311
  continue;
5088
5312
  case TYPE_ERROR:
5089
5313
  const [, message, errorType] = value;
5090
- let error = errorType && globalObj && globalObj[errorType] ? new globalObj[errorType](message) : new Error(message);
5314
+ let error = errorType && globalObj && SUPPORTED_ERROR_TYPES.includes(errorType) && errorType in globalObj && typeof globalObj[errorType] === "function" ? new globalObj[errorType](message) : new Error(message);
5091
5315
  hydrated[index2] = error;
5092
5316
  set(error);
5093
5317
  continue;
@@ -5260,7 +5484,7 @@ async function decodeDeferred(reader) {
5260
5484
  }
5261
5485
  }
5262
5486
  function encode(input, options) {
5263
- const { plugins, postPlugins, signal, onComplete } = options ?? {};
5487
+ const { onComplete, plugins, postPlugins, signal } = options ?? {};
5264
5488
  const encoder = {
5265
5489
  deferred: {},
5266
5490
  index: 0,
@@ -5274,7 +5498,7 @@ function encode(input, options) {
5274
5498
  let lastSentIndex = 0;
5275
5499
  const readable = new ReadableStream({
5276
5500
  async start(controller) {
5277
- const id = flatten.call(encoder, input);
5501
+ const id = await flatten.call(encoder, input);
5278
5502
  if (Array.isArray(id)) {
5279
5503
  throw new Error("This should never happen");
5280
5504
  }
@@ -5289,6 +5513,7 @@ function encode(input, options) {
5289
5513
  lastSentIndex = encoder.stringified.length - 1;
5290
5514
  }
5291
5515
  const seenPromises = /* @__PURE__ */ new WeakSet();
5516
+ let processingChain = Promise.resolve();
5292
5517
  if (Object.keys(encoder.deferred).length) {
5293
5518
  let raceDone;
5294
5519
  const racePromise = new Promise((resolve, reject) => {
@@ -5316,65 +5541,71 @@ function encode(input, options) {
5316
5541
  deferred
5317
5542
  ]).then(
5318
5543
  (resolved) => {
5319
- const id2 = flatten.call(encoder, resolved);
5320
- if (Array.isArray(id2)) {
5321
- controller.enqueue(
5322
- textEncoder.encode(
5323
- `${TYPE_PROMISE}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
5544
+ processingChain = processingChain.then(async () => {
5545
+ const id2 = await flatten.call(encoder, resolved);
5546
+ if (Array.isArray(id2)) {
5547
+ controller.enqueue(
5548
+ textEncoder.encode(
5549
+ `${TYPE_PROMISE}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
5324
5550
  `
5325
- )
5326
- );
5327
- encoder.index++;
5328
- lastSentIndex++;
5329
- } else if (id2 < 0) {
5330
- controller.enqueue(
5331
- textEncoder.encode(
5332
- `${TYPE_PROMISE}${deferredId}:${id2}
5551
+ )
5552
+ );
5553
+ encoder.index++;
5554
+ lastSentIndex++;
5555
+ } else if (id2 < 0) {
5556
+ controller.enqueue(
5557
+ textEncoder.encode(
5558
+ `${TYPE_PROMISE}${deferredId}:${id2}
5333
5559
  `
5334
- )
5335
- );
5336
- } else {
5337
- const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
5338
- controller.enqueue(
5339
- textEncoder.encode(
5340
- `${TYPE_PROMISE}${deferredId}:[${values}]
5560
+ )
5561
+ );
5562
+ } else {
5563
+ const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
5564
+ controller.enqueue(
5565
+ textEncoder.encode(
5566
+ `${TYPE_PROMISE}${deferredId}:[${values}]
5341
5567
  `
5342
- )
5343
- );
5344
- lastSentIndex = encoder.stringified.length - 1;
5345
- }
5568
+ )
5569
+ );
5570
+ lastSentIndex = encoder.stringified.length - 1;
5571
+ }
5572
+ });
5573
+ return processingChain;
5346
5574
  },
5347
5575
  (reason) => {
5348
- if (!reason || typeof reason !== "object" || !(reason instanceof Error)) {
5349
- reason = new Error("An unknown error occurred");
5350
- }
5351
- const id2 = flatten.call(encoder, reason);
5352
- if (Array.isArray(id2)) {
5353
- controller.enqueue(
5354
- textEncoder.encode(
5355
- `${TYPE_ERROR}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
5576
+ processingChain = processingChain.then(async () => {
5577
+ if (!reason || typeof reason !== "object" || !(reason instanceof Error)) {
5578
+ reason = new Error("An unknown error occurred");
5579
+ }
5580
+ const id2 = await flatten.call(encoder, reason);
5581
+ if (Array.isArray(id2)) {
5582
+ controller.enqueue(
5583
+ textEncoder.encode(
5584
+ `${TYPE_ERROR}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
5356
5585
  `
5357
- )
5358
- );
5359
- encoder.index++;
5360
- lastSentIndex++;
5361
- } else if (id2 < 0) {
5362
- controller.enqueue(
5363
- textEncoder.encode(
5364
- `${TYPE_ERROR}${deferredId}:${id2}
5586
+ )
5587
+ );
5588
+ encoder.index++;
5589
+ lastSentIndex++;
5590
+ } else if (id2 < 0) {
5591
+ controller.enqueue(
5592
+ textEncoder.encode(
5593
+ `${TYPE_ERROR}${deferredId}:${id2}
5365
5594
  `
5366
- )
5367
- );
5368
- } else {
5369
- const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
5370
- controller.enqueue(
5371
- textEncoder.encode(
5372
- `${TYPE_ERROR}${deferredId}:[${values}]
5595
+ )
5596
+ );
5597
+ } else {
5598
+ const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
5599
+ controller.enqueue(
5600
+ textEncoder.encode(
5601
+ `${TYPE_ERROR}${deferredId}:[${values}]
5373
5602
  `
5374
- )
5375
- );
5376
- lastSentIndex = encoder.stringified.length - 1;
5377
- }
5603
+ )
5604
+ );
5605
+ lastSentIndex = encoder.stringified.length - 1;
5606
+ }
5607
+ });
5608
+ return processingChain;
5378
5609
  }
5379
5610
  ).finally(() => {
5380
5611
  delete encoder.deferred[Number(deferredId)];
@@ -5386,8 +5617,9 @@ function encode(input, options) {
5386
5617
  raceDone();
5387
5618
  }
5388
5619
  await Promise.all(Object.values(encoder.deferred));
5389
- onComplete == null ? void 0 : onComplete();
5620
+ await processingChain;
5390
5621
  controller.close();
5622
+ onComplete == null ? void 0 : onComplete();
5391
5623
  }
5392
5624
  });
5393
5625
  return readable;
@@ -5494,9 +5726,9 @@ function singleFetchUrl(reqUrl, basename, trailingSlashAware, extension) {
5494
5726
  if (url.pathname === "/") {
5495
5727
  url.pathname = `_root.${extension}`;
5496
5728
  } else if (basename && stripBasename(url.pathname, basename) === "/") {
5497
- url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
5729
+ url.pathname = `${removeTrailingSlash(basename)}/_root.${extension}`;
5498
5730
  } else {
5499
- url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
5731
+ url.pathname = `${removeTrailingSlash(url.pathname)}.${extension}`;
5500
5732
  }
5501
5733
  }
5502
5734
  return url;
@@ -5508,7 +5740,8 @@ function decodeViaTurboStream(body, global2) {
5508
5740
  if (type === "SanitizedError") {
5509
5741
  let [name, message, stack] = rest;
5510
5742
  let Constructor = Error;
5511
- if (name && name in global2 && typeof global2[name] === "function") {
5743
+ if (name && SUPPORTED_ERROR_TYPES.includes(name) && name in global2 && // @ts-expect-error
5744
+ typeof global2[name] === "function") {
5512
5745
  Constructor = global2[name];
5513
5746
  }
5514
5747
  let error = new Constructor(message);
@@ -5699,9 +5932,11 @@ function dedupeLinkDescriptors(descriptors, preloads) {
5699
5932
  }, []);
5700
5933
  }
5701
5934
  function RemixRootDefaultHydrateFallback() {
5935
+ let { nonce } = useFrameworkContext();
5702
5936
  return /* @__PURE__ */ reactExports.createElement(BoundaryShell, { title: "Loading...", renderScripts: true }, /* @__PURE__ */ reactExports.createElement(
5703
5937
  "script",
5704
5938
  {
5939
+ nonce,
5705
5940
  dangerouslySetInnerHTML: {
5706
5941
  __html: `
5707
5942
  console.log(
@@ -5797,6 +6032,7 @@ function getRouteModuleComponent(routeModule) {
5797
6032
  function shouldHydrateRouteLoader(routeId, clientLoader, hasLoader, isSpaMode) {
5798
6033
  return isSpaMode && routeId !== "root" || clientLoader != null && (clientLoader.hydrate === true || hasLoader !== true);
5799
6034
  }
6035
+ var URL_LIMIT = 7680;
5800
6036
  function isFogOfWarEnabled(routeDiscovery, ssr) {
5801
6037
  return routeDiscovery.mode === "lazy" && ssr === true;
5802
6038
  }
@@ -5810,7 +6046,13 @@ function getPartialManifest({ sri, ...manifest }, router) {
5810
6046
  segments.pop();
5811
6047
  }
5812
6048
  paths.forEach((path) => {
5813
- let matches = matchRoutes(router.routes, path, router.basename);
6049
+ let matches = matchRoutesImpl(
6050
+ router.routes,
6051
+ path,
6052
+ router.basename || "/",
6053
+ false,
6054
+ router.branches
6055
+ );
5814
6056
  if (matches) {
5815
6057
  matches.forEach((m) => routeIds.add(m.route.id));
5816
6058
  }
@@ -5827,10 +6069,7 @@ function getPartialManifest({ sri, ...manifest }, router) {
5827
6069
  }
5828
6070
  function getManifestPath(_manifestPath, basename) {
5829
6071
  let manifestPath = _manifestPath || "/__manifest";
5830
- if (basename == null) {
5831
- return manifestPath;
5832
- }
5833
- return `${basename}${manifestPath}`.replace(/\/+/g, "/");
6072
+ return basename == null ? manifestPath : joinPaths([basename, manifestPath]);
5834
6073
  }
5835
6074
  function useDataRouterContext2() {
5836
6075
  let context = reactExports.useContext(DataRouterContext);
@@ -5936,13 +6175,22 @@ function getActiveMatches(matches, errors, isSpaMode) {
5936
6175
  }
5937
6176
  var CRITICAL_CSS_DATA_ATTRIBUTE = "data-react-router-critical-css";
5938
6177
  function Links({ nonce, crossOrigin }) {
5939
- let { isSpaMode, manifest, routeModules, criticalCss } = useFrameworkContext();
6178
+ let {
6179
+ isSpaMode,
6180
+ manifest,
6181
+ routeModules,
6182
+ criticalCss,
6183
+ nonce: contextNonce
6184
+ } = useFrameworkContext();
5940
6185
  let { errors, matches: routerMatches } = useDataRouterStateContext();
5941
6186
  let matches = getActiveMatches(routerMatches, errors, isSpaMode);
5942
6187
  let keyedLinks = reactExports.useMemo(
5943
6188
  () => getKeyedLinksForMatches(matches, routeModules, manifest),
5944
6189
  [matches, routeModules, manifest]
5945
6190
  );
6191
+ if (nonce == null && contextNonce) {
6192
+ nonce = contextNonce;
6193
+ }
5946
6194
  return /* @__PURE__ */ reactExports.createElement(reactExports.Fragment, null, typeof criticalCss === "string" ? /* @__PURE__ */ reactExports.createElement(
5947
6195
  "style",
5948
6196
  {
@@ -5980,6 +6228,8 @@ function Links({ nonce, crossOrigin }) {
5980
6228
  ));
5981
6229
  }
5982
6230
  function PrefetchPageLinks({ page, ...linkProps }) {
6231
+ let rsc = useIsRSCRouterContext();
6232
+ let { nonce: contextNonce } = useFrameworkContext();
5983
6233
  let { router } = useDataRouterContext2();
5984
6234
  let matches = reactExports.useMemo(
5985
6235
  () => matchRoutes(router.routes, page, router.basename),
@@ -5988,6 +6238,12 @@ function PrefetchPageLinks({ page, ...linkProps }) {
5988
6238
  if (!matches) {
5989
6239
  return null;
5990
6240
  }
6241
+ if (linkProps.nonce == null && contextNonce) {
6242
+ linkProps = { ...linkProps, nonce: contextNonce };
6243
+ }
6244
+ if (rsc) {
6245
+ return /* @__PURE__ */ reactExports.createElement(RSCPrefetchPageLinksImpl, { page, matches, ...linkProps });
6246
+ }
5991
6247
  return /* @__PURE__ */ reactExports.createElement(PrefetchPageLinksImpl, { page, matches, ...linkProps });
5992
6248
  }
5993
6249
  function useKeyedPrefetchLinks(matches) {
@@ -6008,6 +6264,46 @@ function useKeyedPrefetchLinks(matches) {
6008
6264
  }, [matches, manifest, routeModules]);
6009
6265
  return keyedPrefetchLinks;
6010
6266
  }
6267
+ function RSCPrefetchPageLinksImpl({
6268
+ page,
6269
+ matches: nextMatches,
6270
+ ...linkProps
6271
+ }) {
6272
+ let location = useLocation();
6273
+ let { future } = useFrameworkContext();
6274
+ let { basename } = useDataRouterContext2();
6275
+ let dataHrefs = reactExports.useMemo(() => {
6276
+ if (page === location.pathname + location.search + location.hash) {
6277
+ return [];
6278
+ }
6279
+ let url = singleFetchUrl(
6280
+ page,
6281
+ basename,
6282
+ future.v8_trailingSlashAwareDataRequests,
6283
+ "rsc"
6284
+ );
6285
+ let hasSomeRoutesWithShouldRevalidate = false;
6286
+ let targetRoutes = [];
6287
+ for (let match of nextMatches) {
6288
+ if (typeof match.route.shouldRevalidate === "function") {
6289
+ hasSomeRoutesWithShouldRevalidate = true;
6290
+ } else {
6291
+ targetRoutes.push(match.route.id);
6292
+ }
6293
+ }
6294
+ if (hasSomeRoutesWithShouldRevalidate && targetRoutes.length > 0) {
6295
+ url.searchParams.set("_routes", targetRoutes.join(","));
6296
+ }
6297
+ return [url.pathname + url.search];
6298
+ }, [
6299
+ basename,
6300
+ future.v8_trailingSlashAwareDataRequests,
6301
+ page,
6302
+ location,
6303
+ nextMatches
6304
+ ]);
6305
+ return /* @__PURE__ */ reactExports.createElement(reactExports.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ reactExports.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })));
6306
+ }
6011
6307
  function PrefetchPageLinksImpl({
6012
6308
  page,
6013
6309
  matches: nextMatches,
@@ -6065,7 +6361,7 @@ function PrefetchPageLinksImpl({
6065
6361
  let url = singleFetchUrl(
6066
6362
  page,
6067
6363
  basename,
6068
- future.unstable_trailingSlashAwareDataRequests,
6364
+ future.v8_trailingSlashAwareDataRequests,
6069
6365
  "data"
6070
6366
  );
6071
6367
  if (foundOptOutRoute && routesParams.size > 0) {
@@ -6077,7 +6373,7 @@ function PrefetchPageLinksImpl({
6077
6373
  return [url.pathname + url.search];
6078
6374
  }, [
6079
6375
  basename,
6080
- future.unstable_trailingSlashAwareDataRequests,
6376
+ future.v8_trailingSlashAwareDataRequests,
6081
6377
  loaderData,
6082
6378
  location,
6083
6379
  manifest,
@@ -6198,7 +6494,7 @@ function Meta() {
6198
6494
  dangerouslySetInnerHTML: { __html: escapeHtml(json) }
6199
6495
  }
6200
6496
  );
6201
- } catch (err) {
6497
+ } catch (e) {
6202
6498
  return null;
6203
6499
  }
6204
6500
  }
@@ -6219,12 +6515,16 @@ function Scripts(scriptProps) {
6219
6515
  isSpaMode,
6220
6516
  renderMeta,
6221
6517
  routeDiscovery,
6222
- ssr
6518
+ ssr,
6519
+ nonce: contextNonce
6223
6520
  } = useFrameworkContext();
6224
6521
  let { router, static: isStatic, staticContext } = useDataRouterContext2();
6225
6522
  let { matches: routerMatches } = useDataRouterStateContext();
6226
6523
  let isRSCRouterContext = useIsRSCRouterContext();
6227
6524
  let enableFogOfWar = isFogOfWarEnabled(routeDiscovery, ssr);
6525
+ if (scriptProps.nonce == null && contextNonce) {
6526
+ scriptProps = { ...scriptProps, nonce: contextNonce };
6527
+ }
6228
6528
  if (renderMeta) {
6229
6529
  renderMeta.didRenderScripts = true;
6230
6530
  }
@@ -6315,13 +6615,16 @@ import(${JSON.stringify(manifest.entry.module)});`;
6315
6615
  }
6316
6616
  ));
6317
6617
  }, []);
6318
- let preloads = isHydrated || isRSCRouterContext ? [] : dedupe(
6319
- manifest.entry.imports.concat(
6320
- getModuleLinkHrefs(matches, manifest, {
6321
- includeHydrateFallback: true
6322
- })
6618
+ let preloads = isHydrated || isRSCRouterContext ? [] : [
6619
+ // Dedupe through a Set
6620
+ ...new Set(
6621
+ manifest.entry.imports.concat(
6622
+ getModuleLinkHrefs(matches, manifest, {
6623
+ includeHydrateFallback: true
6624
+ })
6625
+ )
6323
6626
  )
6324
- );
6627
+ ];
6325
6628
  let sri = typeof manifest.sri === "object" ? manifest.sri : {};
6326
6629
  warnOnce(
6327
6630
  !isRSCRouterContext,
@@ -6347,6 +6650,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
6347
6650
  href: manifest.url,
6348
6651
  crossOrigin: scriptProps.crossOrigin,
6349
6652
  integrity: sri[manifest.url],
6653
+ nonce: scriptProps.nonce,
6350
6654
  suppressHydrationWarning: true
6351
6655
  }
6352
6656
  ) : null, /* @__PURE__ */ reactExports.createElement(
@@ -6356,6 +6660,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
6356
6660
  href: manifest.entry.module,
6357
6661
  crossOrigin: scriptProps.crossOrigin,
6358
6662
  integrity: sri[manifest.entry.module],
6663
+ nonce: scriptProps.nonce,
6359
6664
  suppressHydrationWarning: true
6360
6665
  }
6361
6666
  ), preloads.map((path) => /* @__PURE__ */ reactExports.createElement(
@@ -6366,13 +6671,11 @@ import(${JSON.stringify(manifest.entry.module)});`;
6366
6671
  href: path,
6367
6672
  crossOrigin: scriptProps.crossOrigin,
6368
6673
  integrity: sri[path],
6674
+ nonce: scriptProps.nonce,
6369
6675
  suppressHydrationWarning: true
6370
6676
  }
6371
6677
  )), initialScripts);
6372
6678
  }
6373
- function dedupe(array) {
6374
- return [...new Set(array)];
6375
- }
6376
6679
  function mergeRefs(...refs) {
6377
6680
  return (value) => {
6378
6681
  refs.forEach((ref) => {
@@ -6416,10 +6719,12 @@ function RemixRootDefaultErrorBoundary({
6416
6719
  error,
6417
6720
  isOutsideRemixApp
6418
6721
  }) {
6722
+ let { nonce } = useFrameworkContext();
6419
6723
  console.error(error);
6420
6724
  let heyDeveloper = /* @__PURE__ */ reactExports.createElement(
6421
6725
  "script",
6422
6726
  {
6727
+ nonce,
6423
6728
  dangerouslySetInnerHTML: {
6424
6729
  __html: `
6425
6730
  console.log(
@@ -6484,11 +6789,10 @@ var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "un
6484
6789
  try {
6485
6790
  if (isBrowser2) {
6486
6791
  window.__reactRouterVersion = // @ts-expect-error
6487
- "7.13.1";
6792
+ "7.18.4";
6488
6793
  }
6489
6794
  } catch (e) {
6490
6795
  }
6491
- var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
6492
6796
  var Link = reactExports.forwardRef(
6493
6797
  function LinkWithRef({
6494
6798
  onClick,
@@ -6497,27 +6801,27 @@ var Link = reactExports.forwardRef(
6497
6801
  relative,
6498
6802
  reloadDocument,
6499
6803
  replace: replace2,
6500
- unstable_mask,
6804
+ mask,
6501
6805
  state,
6502
6806
  target,
6503
6807
  to,
6504
6808
  preventScrollReset,
6505
6809
  viewTransition,
6506
- unstable_defaultShouldRevalidate,
6810
+ defaultShouldRevalidate,
6507
6811
  ...rest
6508
6812
  }, forwardedRef) {
6509
- let { basename, navigator, unstable_useTransitions } = reactExports.useContext(NavigationContext);
6510
- let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
6813
+ let { basename, navigator, useTransitions } = reactExports.useContext(NavigationContext);
6814
+ let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX.test(to);
6511
6815
  let parsed = parseToInfo(to, basename);
6512
6816
  to = parsed.to;
6513
6817
  let href = useHref(to, { relative });
6514
6818
  let location = useLocation();
6515
6819
  let maskedHref = null;
6516
- if (unstable_mask) {
6820
+ if (mask) {
6517
6821
  let resolved = resolveTo(
6518
- unstable_mask,
6822
+ mask,
6519
6823
  [],
6520
- location.unstable_mask ? location.unstable_mask.pathname : "/",
6824
+ location.mask ? location.mask.pathname : "/",
6521
6825
  true
6522
6826
  );
6523
6827
  if (basename !== "/") {
@@ -6531,14 +6835,14 @@ var Link = reactExports.forwardRef(
6531
6835
  );
6532
6836
  let internalOnClick = useLinkClickHandler(to, {
6533
6837
  replace: replace2,
6534
- unstable_mask,
6838
+ mask,
6535
6839
  state,
6536
6840
  target,
6537
6841
  preventScrollReset,
6538
6842
  relative,
6539
6843
  viewTransition,
6540
- unstable_defaultShouldRevalidate,
6541
- unstable_useTransitions
6844
+ defaultShouldRevalidate,
6845
+ useTransitions
6542
6846
  });
6543
6847
  function handleClick(event) {
6544
6848
  if (onClick) onClick(event);
@@ -6647,14 +6951,14 @@ var Form = reactExports.forwardRef(
6647
6951
  relative,
6648
6952
  preventScrollReset,
6649
6953
  viewTransition,
6650
- unstable_defaultShouldRevalidate,
6954
+ defaultShouldRevalidate,
6651
6955
  ...props
6652
6956
  }, forwardedRef) => {
6653
- let { unstable_useTransitions } = reactExports.useContext(NavigationContext);
6957
+ let { useTransitions } = reactExports.useContext(NavigationContext);
6654
6958
  let submit = useSubmit();
6655
6959
  let formAction = useFormAction(action, { relative });
6656
6960
  let formMethod = method.toLowerCase() === "get" ? "get" : "post";
6657
- let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX2.test(action);
6961
+ let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX.test(action);
6658
6962
  let submitHandler = (event) => {
6659
6963
  onSubmit && onSubmit(event);
6660
6964
  if (event.defaultPrevented) return;
@@ -6670,9 +6974,9 @@ var Form = reactExports.forwardRef(
6670
6974
  relative,
6671
6975
  preventScrollReset,
6672
6976
  viewTransition,
6673
- unstable_defaultShouldRevalidate
6977
+ defaultShouldRevalidate
6674
6978
  });
6675
- if (unstable_useTransitions && navigate !== false) {
6979
+ if (useTransitions && navigate !== false) {
6676
6980
  reactExports.startTransition(() => doSubmit());
6677
6981
  } else {
6678
6982
  doSubmit();
@@ -6736,6 +7040,9 @@ function ScrollRestoration({
6736
7040
  sessionStorage.removeItem(storageKey2);
6737
7041
  }
6738
7042
  }).toString();
7043
+ if (props.nonce == null && (remixContext == null ? void 0 : remixContext.nonce)) {
7044
+ props.nonce = remixContext.nonce;
7045
+ }
6739
7046
  return /* @__PURE__ */ reactExports.createElement(
6740
7047
  "script",
6741
7048
  {
@@ -6766,13 +7073,13 @@ function useDataRouterState2(hookName) {
6766
7073
  function useLinkClickHandler(to, {
6767
7074
  target,
6768
7075
  replace: replaceProp,
6769
- unstable_mask,
7076
+ mask,
6770
7077
  state,
6771
7078
  preventScrollReset,
6772
7079
  relative,
6773
7080
  viewTransition,
6774
- unstable_defaultShouldRevalidate,
6775
- unstable_useTransitions
7081
+ defaultShouldRevalidate,
7082
+ useTransitions
6776
7083
  } = {}) {
6777
7084
  let navigate = useNavigate();
6778
7085
  let location = useLocation();
@@ -6784,14 +7091,14 @@ function useLinkClickHandler(to, {
6784
7091
  let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
6785
7092
  let doNavigate = () => navigate(to, {
6786
7093
  replace: replace2,
6787
- unstable_mask,
7094
+ mask,
6788
7095
  state,
6789
7096
  preventScrollReset,
6790
7097
  relative,
6791
7098
  viewTransition,
6792
- unstable_defaultShouldRevalidate
7099
+ defaultShouldRevalidate
6793
7100
  });
6794
- if (unstable_useTransitions) {
7101
+ if (useTransitions) {
6795
7102
  reactExports.startTransition(() => doNavigate());
6796
7103
  } else {
6797
7104
  doNavigate();
@@ -6803,15 +7110,15 @@ function useLinkClickHandler(to, {
6803
7110
  navigate,
6804
7111
  path,
6805
7112
  replaceProp,
6806
- unstable_mask,
7113
+ mask,
6807
7114
  state,
6808
7115
  target,
6809
7116
  to,
6810
7117
  preventScrollReset,
6811
7118
  relative,
6812
7119
  viewTransition,
6813
- unstable_defaultShouldRevalidate,
6814
- unstable_useTransitions
7120
+ defaultShouldRevalidate,
7121
+ useTransitions
6815
7122
  ]
6816
7123
  );
6817
7124
  }
@@ -6868,7 +7175,7 @@ function useSubmit() {
6868
7175
  if (options.navigate === false) {
6869
7176
  let key = options.fetcherKey || getUniqueFetcherId();
6870
7177
  await routerFetch(key, currentRouteId, options.action || action, {
6871
- unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
7178
+ defaultShouldRevalidate: options.defaultShouldRevalidate,
6872
7179
  preventScrollReset: options.preventScrollReset,
6873
7180
  formData,
6874
7181
  body,
@@ -6878,7 +7185,7 @@ function useSubmit() {
6878
7185
  });
6879
7186
  } else {
6880
7187
  await routerNavigate(options.action || action, {
6881
- unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
7188
+ defaultShouldRevalidate: options.defaultShouldRevalidate,
6882
7189
  preventScrollReset: options.preventScrollReset,
6883
7190
  formData,
6884
7191
  body,
@@ -7090,7 +7397,7 @@ function StaticRouterProvider({
7090
7397
  let data2 = {
7091
7398
  loaderData: context.loaderData,
7092
7399
  actionData: context.actionData,
7093
- errors: serializeErrors$1(context.errors)
7400
+ errors: serializeErrors(context.errors)
7094
7401
  };
7095
7402
  let json = escapeHtml(JSON.stringify(JSON.stringify(data2)));
7096
7403
  hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`;
@@ -7104,11 +7411,12 @@ function StaticRouterProvider({
7104
7411
  navigationType: state.historyAction,
7105
7412
  navigator: dataRouterContext.navigator,
7106
7413
  static: dataRouterContext.static,
7107
- unstable_useTransitions: false
7414
+ useTransitions: false
7108
7415
  },
7109
7416
  /* @__PURE__ */ reactExports.createElement(
7110
- DataRoutes,
7417
+ DataRoutes2,
7111
7418
  {
7419
+ manifest: router.manifest,
7112
7420
  routes: router.routes,
7113
7421
  future: router.future,
7114
7422
  state,
@@ -7124,7 +7432,7 @@ function StaticRouterProvider({
7124
7432
  }
7125
7433
  ) : null);
7126
7434
  }
7127
- function serializeErrors$1(errors) {
7435
+ function serializeErrors(errors) {
7128
7436
  if (!errors) return null;
7129
7437
  let entries = Object.entries(errors);
7130
7438
  let serialized = {};
@@ -7201,6 +7509,8 @@ function createStaticRouter(routes, context, opts = {}) {
7201
7509
  get future() {
7202
7510
  return {
7203
7511
  v8_middleware: false,
7512
+ v8_passThroughRequests: false,
7513
+ v8_trailingSlashAwareDataRequests: false,
7204
7514
  ...opts == null ? void 0 : opts.future
7205
7515
  };
7206
7516
  },
@@ -7225,6 +7535,12 @@ function createStaticRouter(routes, context, opts = {}) {
7225
7535
  get routes() {
7226
7536
  return dataRoutes;
7227
7537
  },
7538
+ get branches() {
7539
+ return opts.branches;
7540
+ },
7541
+ get manifest() {
7542
+ return manifest;
7543
+ },
7228
7544
  get window() {
7229
7545
  return void 0;
7230
7546
  },
@@ -7284,174 +7600,13 @@ function createHref(to) {
7284
7600
  function encodeLocation(to) {
7285
7601
  let href = typeof to === "string" ? to : createPath(to);
7286
7602
  href = href.replace(/ $/, "%20");
7287
- let encoded = ABSOLUTE_URL_REGEX3.test(href) ? new URL(href) : new URL(href, "http://localhost");
7603
+ let encoded = ABSOLUTE_URL_REGEX.test(href) ? new URL(href) : new URL(href, "http://localhost");
7288
7604
  return {
7289
7605
  pathname: encoded.pathname,
7290
7606
  search: encoded.search,
7291
7607
  hash: encoded.hash
7292
7608
  };
7293
7609
  }
7294
- var ABSOLUTE_URL_REGEX3 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
7295
- var dist = {};
7296
- var hasRequiredDist;
7297
- function requireDist() {
7298
- if (hasRequiredDist) return dist;
7299
- hasRequiredDist = 1;
7300
- Object.defineProperty(dist, "__esModule", { value: true });
7301
- dist.parse = parse;
7302
- dist.serialize = serialize;
7303
- const cookieNameRegExp = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/;
7304
- const cookieValueRegExp = /^[\u0021-\u003A\u003C-\u007E]*$/;
7305
- const domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
7306
- const pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
7307
- const __toString = Object.prototype.toString;
7308
- const NullObject = /* @__PURE__ */ (() => {
7309
- const C = function() {
7310
- };
7311
- C.prototype = /* @__PURE__ */ Object.create(null);
7312
- return C;
7313
- })();
7314
- function parse(str, options) {
7315
- const obj = new NullObject();
7316
- const len = str.length;
7317
- if (len < 2)
7318
- return obj;
7319
- const dec = (options == null ? void 0 : options.decode) || decode2;
7320
- let index = 0;
7321
- do {
7322
- const eqIdx = str.indexOf("=", index);
7323
- if (eqIdx === -1)
7324
- break;
7325
- const colonIdx = str.indexOf(";", index);
7326
- const endIdx = colonIdx === -1 ? len : colonIdx;
7327
- if (eqIdx > endIdx) {
7328
- index = str.lastIndexOf(";", eqIdx - 1) + 1;
7329
- continue;
7330
- }
7331
- const keyStartIdx = startIndex(str, index, eqIdx);
7332
- const keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
7333
- const key = str.slice(keyStartIdx, keyEndIdx);
7334
- if (obj[key] === void 0) {
7335
- let valStartIdx = startIndex(str, eqIdx + 1, endIdx);
7336
- let valEndIdx = endIndex(str, endIdx, valStartIdx);
7337
- const value = dec(str.slice(valStartIdx, valEndIdx));
7338
- obj[key] = value;
7339
- }
7340
- index = endIdx + 1;
7341
- } while (index < len);
7342
- return obj;
7343
- }
7344
- function startIndex(str, index, max) {
7345
- do {
7346
- const code = str.charCodeAt(index);
7347
- if (code !== 32 && code !== 9)
7348
- return index;
7349
- } while (++index < max);
7350
- return max;
7351
- }
7352
- function endIndex(str, index, min) {
7353
- while (index > min) {
7354
- const code = str.charCodeAt(--index);
7355
- if (code !== 32 && code !== 9)
7356
- return index + 1;
7357
- }
7358
- return min;
7359
- }
7360
- function serialize(name, val, options) {
7361
- const enc = (options == null ? void 0 : options.encode) || encodeURIComponent;
7362
- if (!cookieNameRegExp.test(name)) {
7363
- throw new TypeError(`argument name is invalid: ${name}`);
7364
- }
7365
- const value = enc(val);
7366
- if (!cookieValueRegExp.test(value)) {
7367
- throw new TypeError(`argument val is invalid: ${val}`);
7368
- }
7369
- let str = name + "=" + value;
7370
- if (!options)
7371
- return str;
7372
- if (options.maxAge !== void 0) {
7373
- if (!Number.isInteger(options.maxAge)) {
7374
- throw new TypeError(`option maxAge is invalid: ${options.maxAge}`);
7375
- }
7376
- str += "; Max-Age=" + options.maxAge;
7377
- }
7378
- if (options.domain) {
7379
- if (!domainValueRegExp.test(options.domain)) {
7380
- throw new TypeError(`option domain is invalid: ${options.domain}`);
7381
- }
7382
- str += "; Domain=" + options.domain;
7383
- }
7384
- if (options.path) {
7385
- if (!pathValueRegExp.test(options.path)) {
7386
- throw new TypeError(`option path is invalid: ${options.path}`);
7387
- }
7388
- str += "; Path=" + options.path;
7389
- }
7390
- if (options.expires) {
7391
- if (!isDate(options.expires) || !Number.isFinite(options.expires.valueOf())) {
7392
- throw new TypeError(`option expires is invalid: ${options.expires}`);
7393
- }
7394
- str += "; Expires=" + options.expires.toUTCString();
7395
- }
7396
- if (options.httpOnly) {
7397
- str += "; HttpOnly";
7398
- }
7399
- if (options.secure) {
7400
- str += "; Secure";
7401
- }
7402
- if (options.partitioned) {
7403
- str += "; Partitioned";
7404
- }
7405
- if (options.priority) {
7406
- const priority = typeof options.priority === "string" ? options.priority.toLowerCase() : void 0;
7407
- switch (priority) {
7408
- case "low":
7409
- str += "; Priority=Low";
7410
- break;
7411
- case "medium":
7412
- str += "; Priority=Medium";
7413
- break;
7414
- case "high":
7415
- str += "; Priority=High";
7416
- break;
7417
- default:
7418
- throw new TypeError(`option priority is invalid: ${options.priority}`);
7419
- }
7420
- }
7421
- if (options.sameSite) {
7422
- const sameSite = typeof options.sameSite === "string" ? options.sameSite.toLowerCase() : options.sameSite;
7423
- switch (sameSite) {
7424
- case true:
7425
- case "strict":
7426
- str += "; SameSite=Strict";
7427
- break;
7428
- case "lax":
7429
- str += "; SameSite=Lax";
7430
- break;
7431
- case "none":
7432
- str += "; SameSite=None";
7433
- break;
7434
- default:
7435
- throw new TypeError(`option sameSite is invalid: ${options.sameSite}`);
7436
- }
7437
- }
7438
- return str;
7439
- }
7440
- function decode2(str) {
7441
- if (str.indexOf("%") === -1)
7442
- return str;
7443
- try {
7444
- return decodeURIComponent(str);
7445
- } catch (e) {
7446
- return str;
7447
- }
7448
- }
7449
- function isDate(val) {
7450
- return __toString.call(val) === "[object Date]";
7451
- }
7452
- return dist;
7453
- }
7454
- requireDist();
7455
7610
  var setCookie = { exports: {} };
7456
7611
  var hasRequiredSetCookie;
7457
7612
  function requireSetCookie() {
@@ -7637,7 +7792,7 @@ function requireSetCookie() {
7637
7792
  }
7638
7793
  var setCookieExports = /* @__PURE__ */ requireSetCookie();
7639
7794
  /**
7640
- * react-router v7.13.1
7795
+ * react-router v7.18.4
7641
7796
  *
7642
7797
  * Copyright (c) Remix Software Inc.
7643
7798
  *
@@ -7677,7 +7832,9 @@ function ServerRouter({
7677
7832
  delete context.staticHandlerContext.loaderData[routeId];
7678
7833
  }
7679
7834
  }
7680
- let router = createStaticRouter(routes, context.staticHandlerContext);
7835
+ let router = createStaticRouter(routes, context.staticHandlerContext, {
7836
+ branches: context.branches
7837
+ });
7681
7838
  return /* @__PURE__ */ reactExports.createElement(reactExports.Fragment, null, /* @__PURE__ */ reactExports.createElement(
7682
7839
  FrameworkContext.Provider,
7683
7840
  {
@@ -7690,6 +7847,7 @@ function ServerRouter({
7690
7847
  ssr: context.ssr,
7691
7848
  isSpaMode: context.isSpaMode,
7692
7849
  routeDiscovery: context.routeDiscovery,
7850
+ nonce,
7693
7851
  serializeError: context.serializeError,
7694
7852
  renderMeta: context.renderMeta
7695
7853
  }
@@ -7745,52 +7903,43 @@ function serializeError(error, serverMode) {
7745
7903
  stack: sanitized.stack
7746
7904
  };
7747
7905
  }
7748
- function serializeErrors(errors, serverMode) {
7749
- if (!errors) return null;
7750
- let entries = Object.entries(errors);
7751
- let serialized = {};
7752
- for (let [key, val] of entries) {
7753
- if (isRouteErrorResponse(val)) {
7754
- serialized[key] = { ...val, __type: "RouteErrorResponse" };
7755
- } else if (val instanceof Error) {
7756
- let sanitized = sanitizeError(val, serverMode);
7757
- serialized[key] = {
7758
- message: sanitized.message,
7759
- stack: sanitized.stack,
7760
- __type: "Error",
7761
- // If this is a subclass (i.e., ReferenceError), send up the type so we
7762
- // can re-create the same type during hydration. This will only apply
7763
- // in dev mode since all production errors are sanitized to normal
7764
- // Error instances
7765
- ...sanitized.name !== "Error" ? {
7766
- __subType: sanitized.name
7767
- } : {}
7768
- };
7769
- } else {
7770
- serialized[key] = val;
7771
- }
7906
+ function invariant(value, message) {
7907
+ if (value === false || value === null || typeof value === "undefined") {
7908
+ console.error(
7909
+ "The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
7910
+ );
7911
+ throw new Error(message);
7772
7912
  }
7773
- return serialized;
7774
7913
  }
7775
- function matchServerRoutes(routes, pathname, basename) {
7776
- let matches = matchRoutes(
7777
- routes,
7914
+ function matchServerRoutes(manifest, dataRoutes, branches, pathname, basename) {
7915
+ let matches = matchRoutesImpl(
7916
+ dataRoutes,
7778
7917
  pathname,
7779
- basename
7918
+ basename ?? "/",
7919
+ false,
7920
+ branches
7780
7921
  );
7781
7922
  if (!matches) return null;
7782
- return matches.map((match) => ({
7783
- params: match.params,
7784
- pathname: match.pathname,
7785
- route: match.route
7786
- }));
7923
+ return matches.map((match) => {
7924
+ let route = manifest[match.route.id];
7925
+ invariant(
7926
+ route,
7927
+ `Route with id "${match.route.id}" not found in manifest.`
7928
+ );
7929
+ return {
7930
+ params: match.params,
7931
+ pathname: match.pathname,
7932
+ route
7933
+ };
7934
+ });
7787
7935
  }
7788
- async function callRouteHandler(handler, args) {
7936
+ async function callRouteHandler(handler, args, future) {
7789
7937
  let result = await handler({
7790
- request: stripRoutesParam(stripIndexParam(args.request)),
7938
+ request: future.v8_passThroughRequests ? args.request : stripRoutesParam(stripIndexParam(args.request)),
7939
+ url: args.url,
7791
7940
  params: args.params,
7792
7941
  context: args.context,
7793
- unstable_pattern: args.unstable_pattern
7942
+ pattern: args.pattern
7794
7943
  });
7795
7944
  if (isDataWithResponseInit(result) && result.init && result.init.status && isRedirectStatusCode(result.init.status)) {
7796
7945
  throw new Response(null, result.init);
@@ -7835,23 +7984,14 @@ function stripRoutesParam(request) {
7835
7984
  }
7836
7985
  return new Request(url.href, init);
7837
7986
  }
7838
- function invariant(value, message) {
7839
- if (value === false || value === null || typeof value === "undefined") {
7840
- console.error(
7841
- "The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
7842
- );
7843
- throw new Error(message);
7844
- }
7845
- }
7846
7987
  var globalDevServerHooksKey = "__reactRouterDevServerHooks";
7847
7988
  function getDevServerHooks() {
7848
7989
  return globalThis[globalDevServerHooksKey];
7849
7990
  }
7850
7991
  function getBuildTimeHeader(request, headerName) {
7851
- var _a;
7852
7992
  if (typeof process !== "undefined") {
7853
7993
  try {
7854
- if (((_a = process.env) == null ? void 0 : _a.IS_RR_BUILD_REQUEST) === "yes") {
7994
+ if (process.env.hasOwnProperty("IS_RR_BUILD_REQUEST") && process.env.IS_RR_BUILD_REQUEST === "yes") {
7855
7995
  return request.headers.get(headerName);
7856
7996
  }
7857
7997
  } catch (e) {
@@ -7872,12 +8012,6 @@ function groupRoutesByParentId(manifest) {
7872
8012
  });
7873
8013
  return routes;
7874
8014
  }
7875
- function createRoutes(manifest, parentId = "", routesByParentId = groupRoutesByParentId(manifest)) {
7876
- return (routesByParentId[parentId] || []).map((route) => ({
7877
- ...route,
7878
- children: createRoutes(manifest, route.id, routesByParentId)
7879
- }));
7880
- }
7881
8015
  function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesByParentId = groupRoutesByParentId(manifest)) {
7882
8016
  return (routesByParentId[parentId] || []).map((route) => {
7883
8017
  let commonRoute = {
@@ -7928,10 +8062,14 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
7928
8062
  return result.data;
7929
8063
  }
7930
8064
  }
7931
- let val = await callRouteHandler(route.module.loader, args);
8065
+ let val = await callRouteHandler(
8066
+ route.module.loader,
8067
+ args,
8068
+ future
8069
+ );
7932
8070
  return val;
7933
8071
  } : void 0,
7934
- action: route.module.action ? (args) => callRouteHandler(route.module.action, args) : void 0,
8072
+ action: route.module.action ? (args) => callRouteHandler(route.module.action, args, future) : void 0,
7935
8073
  handle: route.module.handle
7936
8074
  };
7937
8075
  return route.index ? {
@@ -8021,28 +8159,29 @@ function prependCookies(parentHeaders, childHeaders) {
8021
8159
  });
8022
8160
  }
8023
8161
  }
8024
- function throwIfPotentialCSRFAttack(headers, allowedActionOrigins) {
8025
- let originHeader = headers.get("origin");
8162
+ function throwIfPotentialCSRFAttack(request, allowedActionOrigins) {
8163
+ let originHeader = request.headers.get("origin");
8026
8164
  let originDomain = null;
8165
+ let originUrl = null;
8027
8166
  try {
8028
- originDomain = typeof originHeader === "string" && originHeader !== "null" ? new URL(originHeader).host : originHeader;
8167
+ if (typeof originHeader === "string" && originHeader !== "null") {
8168
+ originUrl = new URL(originHeader);
8169
+ originDomain = originUrl.host;
8170
+ } else {
8171
+ originDomain = originHeader;
8172
+ }
8029
8173
  } catch {
8030
8174
  throw new Error(
8031
8175
  `\`origin\` header is not a valid URL. Aborting the action.`
8032
8176
  );
8033
8177
  }
8034
- let host = parseHostHeader(headers);
8035
- if (originDomain && (!host || originDomain !== host.value)) {
8178
+ let requestUrl = new URL(request.url);
8179
+ let originMatchesRequest = originUrl ? originUrl.origin === requestUrl.origin : originDomain === requestUrl.host;
8180
+ if (originDomain && !originMatchesRequest) {
8036
8181
  if (!isAllowedOrigin(originDomain, allowedActionOrigins)) {
8037
- if (host) {
8038
- throw new Error(
8039
- `${host.type} header does not match \`origin\` header from a forwarded action request. Aborting the action.`
8040
- );
8041
- } else {
8042
- throw new Error(
8043
- "`x-forwarded-host` or `host` headers are not provided. One of these is needed to compare the `origin` header from a forwarded action request. Aborting the action."
8044
- );
8045
- }
8182
+ throw new Error(
8183
+ "The `request.url` origin does not match `origin` header from a forwarded action request. Aborting the action."
8184
+ );
8046
8185
  }
8047
8186
  }
8048
8187
  }
@@ -8090,18 +8229,38 @@ function isAllowedOrigin(originDomain, allowedActionOrigins = []) {
8090
8229
  (allowedOrigin) => allowedOrigin && (allowedOrigin === originDomain || matchWildcardDomain(originDomain, allowedOrigin))
8091
8230
  );
8092
8231
  }
8093
- function parseHostHeader(headers) {
8094
- var _a;
8095
- let forwardedHostHeader = headers.get("x-forwarded-host");
8096
- let forwardedHostValue = (_a = forwardedHostHeader == null ? void 0 : forwardedHostHeader.split(",")[0]) == null ? void 0 : _a.trim();
8097
- let hostHeader = headers.get("host");
8098
- return forwardedHostValue ? {
8099
- type: "x-forwarded-host",
8100
- value: forwardedHostValue
8101
- } : hostHeader ? {
8102
- type: "host",
8103
- value: hostHeader
8104
- } : void 0;
8232
+ function getNormalizedPath(request, basename, future) {
8233
+ basename = basename || "/";
8234
+ let url = new URL(request.url);
8235
+ let pathname = url.pathname;
8236
+ if (future == null ? void 0 : future.v8_trailingSlashAwareDataRequests) {
8237
+ if (pathname.endsWith("/_.data")) {
8238
+ pathname = pathname.replace(/_\.data$/, "");
8239
+ } else {
8240
+ pathname = pathname.replace(/\.data$/, "");
8241
+ }
8242
+ } else {
8243
+ if (stripBasename(pathname, basename) === "/_root.data") {
8244
+ pathname = basename;
8245
+ } else if (pathname.endsWith(".data")) {
8246
+ pathname = pathname.replace(/\.data$/, "");
8247
+ }
8248
+ if (stripBasename(pathname, basename) !== "/" && pathname.endsWith("/")) {
8249
+ pathname = pathname.slice(0, -1);
8250
+ }
8251
+ }
8252
+ let searchParams = new URLSearchParams(url.search);
8253
+ searchParams.delete("_routes");
8254
+ let search = searchParams.toString();
8255
+ if (search) {
8256
+ search = `?${search}`;
8257
+ }
8258
+ return {
8259
+ pathname,
8260
+ search,
8261
+ // No hashes on the server
8262
+ hash: ""
8263
+ };
8105
8264
  }
8106
8265
  var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
8107
8266
  ...NO_BODY_STATUS_CODES,
@@ -8111,13 +8270,13 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
8111
8270
  try {
8112
8271
  try {
8113
8272
  throwIfPotentialCSRFAttack(
8114
- request.headers,
8273
+ request,
8115
8274
  Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []
8116
8275
  );
8117
8276
  } catch (e) {
8118
8277
  return handleQueryError(new Error("Bad Request"), 400);
8119
8278
  }
8120
- let handlerRequest = new Request(handlerUrl, {
8279
+ let handlerRequest = build.future.v8_passThroughRequests ? request : new Request(handlerUrl, {
8121
8280
  method: request.method,
8122
8281
  body: request.body,
8123
8282
  headers: request.headers,
@@ -8135,7 +8294,8 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
8135
8294
  } catch (error) {
8136
8295
  return handleQueryError(error);
8137
8296
  }
8138
- } : void 0
8297
+ } : void 0,
8298
+ normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
8139
8299
  });
8140
8300
  return handleQueryResult(result);
8141
8301
  } catch (error) {
@@ -8184,7 +8344,7 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
8184
8344
  let routesParam = new URL(request.url).searchParams.get("_routes");
8185
8345
  let loadRouteIds = routesParam ? new Set(routesParam.split(",")) : null;
8186
8346
  try {
8187
- let handlerRequest = new Request(handlerUrl, {
8347
+ let handlerRequest = build.future.v8_passThroughRequests ? request : new Request(handlerUrl, {
8188
8348
  headers: request.headers,
8189
8349
  signal: request.signal
8190
8350
  });
@@ -8199,7 +8359,8 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
8199
8359
  } catch (error) {
8200
8360
  return handleQueryError(error);
8201
8361
  }
8202
- } : void 0
8362
+ } : void 0,
8363
+ normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
8203
8364
  });
8204
8365
  return handleQueryResult(result);
8205
8366
  } catch (error) {
@@ -8317,14 +8478,24 @@ function getSingleFetchRedirect(status, headers, basename) {
8317
8478
  function encodeViaTurboStream(data2, requestSignal, streamTimeout, serverMode) {
8318
8479
  let controller = new AbortController();
8319
8480
  let timeoutId = setTimeout(
8320
- () => controller.abort(new Error("Server Timeout")),
8481
+ () => {
8482
+ controller.abort(new Error("Server Timeout"));
8483
+ cleanupCallbacks();
8484
+ },
8321
8485
  typeof streamTimeout === "number" ? streamTimeout : 4950
8322
8486
  );
8323
- let clearStreamTimeout = () => clearTimeout(timeoutId);
8324
- requestSignal.addEventListener("abort", clearStreamTimeout);
8487
+ let abortControllerOnRequestAbort = () => {
8488
+ controller.abort(requestSignal.reason);
8489
+ cleanupCallbacks();
8490
+ };
8491
+ requestSignal.addEventListener("abort", abortControllerOnRequestAbort);
8492
+ let cleanupCallbacks = () => {
8493
+ clearTimeout(timeoutId);
8494
+ requestSignal.removeEventListener("abort", abortControllerOnRequestAbort);
8495
+ };
8325
8496
  return encode(data2, {
8326
8497
  signal: controller.signal,
8327
- onComplete: clearStreamTimeout,
8498
+ onComplete: cleanupCallbacks,
8328
8499
  plugins: [
8329
8500
  (value) => {
8330
8501
  if (value instanceof Error) {
@@ -8354,12 +8525,12 @@ function encodeViaTurboStream(data2, requestSignal, streamTimeout, serverMode) {
8354
8525
  });
8355
8526
  }
8356
8527
  function derive(build, mode) {
8357
- let routes = createRoutes(build.routes);
8358
8528
  let dataRoutes = createStaticHandlerDataRoutes(build.routes, build.future);
8359
8529
  let serverMode = isServerMode(mode) ? mode : "production";
8360
8530
  let staticHandler = createStaticHandler(dataRoutes, {
8361
8531
  basename: build.basename,
8362
- unstable_instrumentations: build.entry.module.unstable_instrumentations
8532
+ instrumentations: build.entry.module.instrumentations,
8533
+ future: build.future
8363
8534
  });
8364
8535
  let errorHandler = build.entry.module.handleError || ((error, { request }) => {
8365
8536
  if (serverMode !== "test" && !request.signal.aborted) {
@@ -8396,36 +8567,23 @@ function derive(build, mode) {
8396
8567
  } else {
8397
8568
  loadContext = initialContext || {};
8398
8569
  }
8399
- let url = new URL(request.url);
8400
- let normalizedBasename = build.basename || "/";
8401
- let normalizedPath = url.pathname;
8402
- if (build.future.unstable_trailingSlashAwareDataRequests) {
8403
- if (normalizedPath.endsWith("/_.data")) {
8404
- normalizedPath = normalizedPath.replace(/_.data$/, "");
8405
- } else {
8406
- normalizedPath = normalizedPath.replace(/\.data$/, "");
8407
- }
8408
- } else {
8409
- if (stripBasename(normalizedPath, normalizedBasename) === "/_root.data") {
8410
- normalizedPath = normalizedBasename;
8411
- } else if (normalizedPath.endsWith(".data")) {
8412
- normalizedPath = normalizedPath.replace(/\.data$/, "");
8413
- }
8414
- if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
8415
- normalizedPath = normalizedPath.slice(0, -1);
8416
- }
8417
- }
8570
+ let requestUrl = new URL(request.url);
8571
+ let normalizedPathname = getNormalizedPath(
8572
+ request,
8573
+ build.basename,
8574
+ build.future
8575
+ ).pathname;
8418
8576
  let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
8419
8577
  if (!build.ssr) {
8420
- let decodedPath = decodeURI(normalizedPath);
8421
- if (normalizedBasename !== "/") {
8422
- let strippedPath = stripBasename(decodedPath, normalizedBasename);
8578
+ let decodedPath = decodeURI(normalizedPathname);
8579
+ if (build.basename && build.basename !== "/") {
8580
+ let strippedPath = stripBasename(decodedPath, build.basename);
8423
8581
  if (strippedPath == null) {
8424
8582
  errorHandler(
8425
8583
  new ErrorResponseImpl(
8426
8584
  404,
8427
8585
  "Not Found",
8428
- `Refusing to prerender the \`${decodedPath}\` path because it does not start with the basename \`${normalizedBasename}\``
8586
+ `Refusing to prerender the \`${decodedPath}\` path because it does not start with the basename \`${build.basename}\``
8429
8587
  ),
8430
8588
  {
8431
8589
  context: loadContext,
@@ -8442,8 +8600,8 @@ function derive(build, mode) {
8442
8600
  }
8443
8601
  if (build.prerender.length === 0) {
8444
8602
  isSpaMode = true;
8445
- } else if (!build.prerender.includes(decodedPath) && !build.prerender.includes(decodedPath + "/")) {
8446
- if (url.pathname.endsWith(".data")) {
8603
+ } else if (!build.prerender.includes(decodedPath.replace(/\/$/, "")) && !build.prerender.includes(decodedPath.replace(/[^/]$/, "/"))) {
8604
+ if (requestUrl.pathname.endsWith(".data")) {
8447
8605
  errorHandler(
8448
8606
  new ErrorResponseImpl(
8449
8607
  404,
@@ -8467,36 +8625,40 @@ function derive(build, mode) {
8467
8625
  }
8468
8626
  let manifestUrl = getManifestPath(
8469
8627
  build.routeDiscovery.manifestPath,
8470
- normalizedBasename
8628
+ build.basename
8471
8629
  );
8472
- if (url.pathname === manifestUrl) {
8630
+ if (build.routeDiscovery.mode === "lazy" && requestUrl.pathname === manifestUrl) {
8473
8631
  try {
8474
- let res = await handleManifestRequest(build, routes, url);
8632
+ let res = await handleManifestRequest(
8633
+ build,
8634
+ staticHandler.dataRoutes,
8635
+ staticHandler._internalRouteBranches,
8636
+ requestUrl
8637
+ );
8475
8638
  return res;
8476
8639
  } catch (e) {
8477
8640
  handleError(e);
8478
8641
  return new Response("Unknown Server Error", { status: 500 });
8479
8642
  }
8480
8643
  }
8481
- let matches = matchServerRoutes(routes, normalizedPath, build.basename);
8644
+ let matches = matchServerRoutes(
8645
+ build.routes,
8646
+ staticHandler.dataRoutes,
8647
+ staticHandler._internalRouteBranches,
8648
+ normalizedPathname,
8649
+ build.basename
8650
+ );
8482
8651
  if (matches && matches.length > 0) {
8483
8652
  Object.assign(params, matches[0].params);
8484
8653
  }
8485
8654
  let response;
8486
- if (url.pathname.endsWith(".data")) {
8487
- let handlerUrl = new URL(request.url);
8488
- handlerUrl.pathname = normalizedPath;
8489
- let singleFetchMatches = matchServerRoutes(
8490
- routes,
8491
- handlerUrl.pathname,
8492
- build.basename
8493
- );
8655
+ if (requestUrl.pathname.endsWith(".data")) {
8494
8656
  response = await handleSingleFetchRequest(
8495
8657
  serverMode,
8496
8658
  build,
8497
8659
  staticHandler,
8498
8660
  request,
8499
- handlerUrl,
8661
+ normalizedPathname,
8500
8662
  loadContext,
8501
8663
  handleError
8502
8664
  );
@@ -8511,7 +8673,7 @@ function derive(build, mode) {
8511
8673
  if (build.entry.module.handleDataRequest) {
8512
8674
  response = await build.entry.module.handleDataRequest(response, {
8513
8675
  context: loadContext,
8514
- params: singleFetchMatches ? singleFetchMatches[0].params : {},
8676
+ params: matches ? matches[0].params : {},
8515
8677
  request
8516
8678
  });
8517
8679
  if (isRedirectResponse(response)) {
@@ -8534,7 +8696,7 @@ function derive(build, mode) {
8534
8696
  handleError
8535
8697
  );
8536
8698
  } else {
8537
- let { pathname } = url;
8699
+ let { pathname } = requestUrl;
8538
8700
  let criticalCss = void 0;
8539
8701
  if (build.unstable_getCriticalCss) {
8540
8702
  criticalCss = await build.unstable_getCriticalCss({ pathname });
@@ -8561,15 +8723,13 @@ function derive(build, mode) {
8561
8723
  }
8562
8724
  return response;
8563
8725
  };
8564
- if (build.entry.module.unstable_instrumentations) {
8726
+ if (build.entry.module.instrumentations) {
8565
8727
  requestHandler = instrumentHandler(
8566
8728
  requestHandler,
8567
- build.entry.module.unstable_instrumentations.map((i) => i.handler).filter(Boolean)
8729
+ build.entry.module.instrumentations.map((i) => i.handler).filter(Boolean)
8568
8730
  );
8569
8731
  }
8570
8732
  return {
8571
- routes,
8572
- dataRoutes,
8573
8733
  serverMode,
8574
8734
  staticHandler,
8575
8735
  errorHandler,
@@ -8578,7 +8738,6 @@ function derive(build, mode) {
8578
8738
  }
8579
8739
  var createRequestHandler$1 = (build, mode) => {
8580
8740
  let _build;
8581
- let routes;
8582
8741
  let serverMode;
8583
8742
  let staticHandler;
8584
8743
  let errorHandler;
@@ -8587,14 +8746,12 @@ var createRequestHandler$1 = (build, mode) => {
8587
8746
  _build = typeof build === "function" ? await build() : build;
8588
8747
  if (typeof build === "function") {
8589
8748
  let derived = derive(_build, mode);
8590
- routes = derived.routes;
8591
8749
  serverMode = derived.serverMode;
8592
8750
  staticHandler = derived.staticHandler;
8593
8751
  errorHandler = derived.errorHandler;
8594
8752
  _requestHandler = derived.requestHandler;
8595
- } else if (!routes || !serverMode || !staticHandler || !errorHandler || !_requestHandler) {
8753
+ } else if (!serverMode || !staticHandler || !errorHandler || !_requestHandler) {
8596
8754
  let derived = derive(_build, mode);
8597
- routes = derived.routes;
8598
8755
  serverMode = derived.serverMode;
8599
8756
  staticHandler = derived.staticHandler;
8600
8757
  errorHandler = derived.errorHandler;
@@ -8603,7 +8760,13 @@ var createRequestHandler$1 = (build, mode) => {
8603
8760
  return _requestHandler(request, initialContext);
8604
8761
  };
8605
8762
  };
8606
- async function handleManifestRequest(build, routes, url) {
8763
+ async function handleManifestRequest(build, dataRoutes, branches, url) {
8764
+ if (url.toString().length > URL_LIMIT) {
8765
+ return new Response(null, {
8766
+ statusText: "Bad Request",
8767
+ status: 400
8768
+ });
8769
+ }
8607
8770
  if (build.assets.version !== url.searchParams.get("version")) {
8608
8771
  return new Response(null, {
8609
8772
  status: 204,
@@ -8614,21 +8777,19 @@ async function handleManifestRequest(build, routes, url) {
8614
8777
  }
8615
8778
  let patches = {};
8616
8779
  if (url.searchParams.has("paths")) {
8617
- let paths = /* @__PURE__ */ new Set();
8618
8780
  let pathParam = url.searchParams.get("paths") || "";
8619
- let requestedPaths = pathParam.split(",").filter(Boolean);
8620
- requestedPaths.forEach((path) => {
8781
+ let paths = new Set(pathParam.split(",").filter(Boolean));
8782
+ for (let path of paths) {
8621
8783
  if (!path.startsWith("/")) {
8622
8784
  path = `/${path}`;
8623
8785
  }
8624
- let segments = path.split("/").slice(1);
8625
- segments.forEach((_, i) => {
8626
- let partialPath = segments.slice(0, i + 1).join("/");
8627
- paths.add(`/${partialPath}`);
8628
- });
8629
- });
8630
- for (let path of paths) {
8631
- let matches = matchServerRoutes(routes, path, build.basename);
8786
+ let matches = matchServerRoutes(
8787
+ build.routes,
8788
+ dataRoutes,
8789
+ branches,
8790
+ path,
8791
+ build.basename
8792
+ );
8632
8793
  if (matches) {
8633
8794
  for (let match of matches) {
8634
8795
  let routeId = match.route.id;
@@ -8647,8 +8808,10 @@ async function handleManifestRequest(build, routes, url) {
8647
8808
  }
8648
8809
  return new Response("Invalid Request", { status: 400 });
8649
8810
  }
8650
- async function handleSingleFetchRequest(serverMode, build, staticHandler, request, handlerUrl, loadContext, handleError) {
8651
- let response = request.method !== "GET" ? await singleFetchAction(
8811
+ async function handleSingleFetchRequest(serverMode, build, staticHandler, request, normalizedPath, loadContext, handleError) {
8812
+ let handlerUrl = new URL(request.url);
8813
+ handlerUrl.pathname = normalizedPath;
8814
+ let response = isMutationMethod(request.method) ? await singleFetchAction(
8652
8815
  build,
8653
8816
  serverMode,
8654
8817
  staticHandler,
@@ -8669,10 +8832,10 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
8669
8832
  }
8670
8833
  async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, isSpaMode, criticalCss) {
8671
8834
  try {
8672
- if (request.method === "POST") {
8835
+ if (isMutationMethod(request.method)) {
8673
8836
  try {
8674
8837
  throwIfPotentialCSRFAttack(
8675
- request.headers,
8838
+ request,
8676
8839
  Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []
8677
8840
  );
8678
8841
  } catch (e) {
@@ -8693,7 +8856,8 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
8693
8856
  handleError(error);
8694
8857
  return new Response(null, { status: 500 });
8695
8858
  }
8696
- } : void 0
8859
+ } : void 0,
8860
+ normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
8697
8861
  });
8698
8862
  if (!isResponse(result)) {
8699
8863
  result = await renderHtml(result, isSpaMode);
@@ -8719,7 +8883,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
8719
8883
  let state = {
8720
8884
  loaderData: context.loaderData,
8721
8885
  actionData: context.actionData,
8722
- errors: serializeErrors(context.errors, serverMode)
8886
+ errors: context.errors
8723
8887
  };
8724
8888
  let baseServerHandoff = {
8725
8889
  basename: build.basename,
@@ -8730,6 +8894,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
8730
8894
  };
8731
8895
  let entryContext = {
8732
8896
  manifest: build.assets,
8897
+ branches: staticHandler._internalRouteBranches,
8733
8898
  routeModules: createEntryRouteModules(build.routes),
8734
8899
  staticHandlerContext: context,
8735
8900
  criticalCss,
@@ -8784,7 +8949,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
8784
8949
  let state2 = {
8785
8950
  loaderData: context.loaderData,
8786
8951
  actionData: context.actionData,
8787
- errors: serializeErrors(context.errors, serverMode)
8952
+ errors: context.errors
8788
8953
  };
8789
8954
  entryContext = {
8790
8955
  ...entryContext,
@@ -8825,7 +8990,8 @@ async function handleResourceRequest(serverMode, build, staticHandler, routeId,
8825
8990
  } catch (error) {
8826
8991
  return handleQueryRouteError(error);
8827
8992
  }
8828
- } : void 0
8993
+ } : void 0,
8994
+ normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
8829
8995
  });
8830
8996
  return handleQueryRouteResult(result);
8831
8997
  } catch (error) {
@@ -8984,7 +9150,7 @@ function RSCDefaultRootErrorBoundaryImpl({
8984
9150
  ), heyDeveloper);
8985
9151
  }
8986
9152
  /**
8987
- * @react-router/node v7.13.1
9153
+ * @react-router/node v7.18.4
8988
9154
  *
8989
9155
  * Copyright (c) Remix Software Inc.
8990
9156
  *
@@ -8996,22 +9162,117 @@ function RSCDefaultRootErrorBoundaryImpl({
8996
9162
  async function writeReadableStreamToWritable(stream, writable) {
8997
9163
  let reader = stream.getReader();
8998
9164
  let flushable = writable;
9165
+ let writableError = monitorWritableError(writable);
8999
9166
  try {
9000
9167
  while (true) {
9001
- let { done, value } = await reader.read();
9168
+ writableError.throwIfClosed();
9169
+ let { done, value } = await writableError.race(reader.read());
9002
9170
  if (done) {
9003
9171
  writable.end();
9004
9172
  break;
9005
9173
  }
9006
- writable.write(value);
9174
+ writableError.throwIfClosed();
9175
+ let canContinueWriting = writable.write(value);
9007
9176
  if (typeof flushable.flush === "function") {
9008
9177
  flushable.flush();
9009
9178
  }
9179
+ if (!canContinueWriting) {
9180
+ await waitForDrain(writable, writableError);
9181
+ }
9010
9182
  }
9011
9183
  } catch (error) {
9012
- writable.destroy(error);
9184
+ try {
9185
+ reader.cancel(error instanceof WritableClosedError ? void 0 : error).catch(() => {
9186
+ });
9187
+ } catch {
9188
+ }
9189
+ destroyWritable(writable, error);
9013
9190
  throw error;
9191
+ } finally {
9192
+ writableError.cleanup();
9193
+ try {
9194
+ reader.releaseLock();
9195
+ } catch {
9196
+ }
9197
+ }
9198
+ }
9199
+ var WritableClosedError = class extends Error {
9200
+ };
9201
+ function destroyWritable(writable, error) {
9202
+ if (error instanceof WritableClosedError || writable.destroyed) {
9203
+ return;
9014
9204
  }
9205
+ writable.once("error", () => {
9206
+ });
9207
+ writable.destroy(error);
9208
+ }
9209
+ function monitorWritableError(writable) {
9210
+ let writableStartedDestroyed = writable.destroyed;
9211
+ let settled = false;
9212
+ let writableErrorEmitted = false;
9213
+ let writableError;
9214
+ let rejectWritableError;
9215
+ let writableErrorPromise = new Promise((_, reject2) => {
9216
+ rejectWritableError = reject2;
9217
+ });
9218
+ writableErrorPromise.catch(() => {
9219
+ });
9220
+ function cleanup() {
9221
+ if (!writableStartedDestroyed && writable.destroyed && writable.errored && !writableErrorEmitted) {
9222
+ return;
9223
+ }
9224
+ writable.off("error", onError);
9225
+ writable.off("close", onClose);
9226
+ }
9227
+ function reject(error) {
9228
+ if (settled) {
9229
+ return;
9230
+ }
9231
+ settled = true;
9232
+ writableError = error;
9233
+ cleanup();
9234
+ rejectWritableError(error);
9235
+ }
9236
+ function onError(error) {
9237
+ writableErrorEmitted = true;
9238
+ reject(error);
9239
+ }
9240
+ function onClose() {
9241
+ reject(new WritableClosedError("Writable closed before stream finished"));
9242
+ }
9243
+ writable.once("error", onError);
9244
+ writable.once("close", onClose);
9245
+ return {
9246
+ cleanup,
9247
+ race(promise) {
9248
+ return Promise.race([promise, writableErrorPromise]);
9249
+ },
9250
+ throwIfClosed() {
9251
+ if (writableError) {
9252
+ throw writableError;
9253
+ }
9254
+ if (writable.destroyed || writable.writableEnded) {
9255
+ throw new WritableClosedError(
9256
+ "Cannot write to a destroyed or ended writable stream"
9257
+ );
9258
+ }
9259
+ }
9260
+ };
9261
+ }
9262
+ function waitForDrain(writable, writableError) {
9263
+ let cleanup = () => {
9264
+ };
9265
+ let drainPromise = new Promise((resolve) => {
9266
+ function onDrain() {
9267
+ cleanup();
9268
+ resolve();
9269
+ }
9270
+ cleanup = function cleanup2() {
9271
+ writable.off("drain", onDrain);
9272
+ };
9273
+ writable.once("drain", onDrain);
9274
+ });
9275
+ return writableError.race(drainPromise).finally(cleanup);
9015
9276
  }
9016
9277
  var createReadableStreamFromReadable = (source) => {
9017
9278
  let pump = new StreamPump(source);
@@ -9062,7 +9323,7 @@ var StreamPump = class {
9062
9323
  if (available <= 0) {
9063
9324
  this.pause();
9064
9325
  }
9065
- } catch (error) {
9326
+ } catch (e) {
9066
9327
  this.controller.error(
9067
9328
  new Error(
9068
9329
  "Could not create Buffer, chunk must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object"
@@ -9096,7 +9357,7 @@ var StreamPump = class {
9096
9357
  }
9097
9358
  };
9098
9359
  /**
9099
- * @react-router/express v7.13.1
9360
+ * @react-router/express v7.18.4
9100
9361
  *
9101
9362
  * Copyright (c) Remix Software Inc.
9102
9363
  *
@@ -9138,13 +9399,14 @@ function createRemixHeaders(requestHeaders) {
9138
9399
  return headers;
9139
9400
  }
9140
9401
  function createRemixRequest(req, res) {
9141
- var _a, _b;
9142
- let [, hostnamePortStr] = ((_a = req.get("X-Forwarded-Host")) == null ? void 0 : _a.split(":")) ?? [];
9143
- let [, hostPortStr] = ((_b = req.get("host")) == null ? void 0 : _b.split(":")) ?? [];
9402
+ var _a, _b, _c;
9403
+ let [, hostnamePortStr] = ((_a = req.app) == null ? void 0 : _a.enabled("trust proxy")) ? ((_b = req.get("X-Forwarded-Host")) == null ? void 0 : _b.split(":")) ?? [] : [];
9404
+ let [, hostPortStr] = ((_c = req.get("host")) == null ? void 0 : _c.split(":")) ?? [];
9144
9405
  let hostnamePort = Number.parseInt(hostnamePortStr, 10);
9145
9406
  let hostPort = Number.parseInt(hostPortStr, 10);
9146
9407
  let port = Number.isSafeInteger(hostnamePort) ? hostnamePort : Number.isSafeInteger(hostPort) ? hostPort : "";
9147
- let resolvedHost = `${req.hostname}${port ? `:${port}` : ""}`;
9408
+ let hostname = req.hostname.split(/[\\/?#@]/)[0] || "localhost";
9409
+ let resolvedHost = `${hostname}${port ? `:${port}` : ""}`;
9148
9410
  let url = new URL(`${req.protocol}://${resolvedHost}${req.originalUrl}`);
9149
9411
  let controller = new AbortController();
9150
9412
  let init = {
@@ -9161,26 +9423,40 @@ function createRemixRequest(req, res) {
9161
9423
  return new Request(url.href, init);
9162
9424
  }
9163
9425
  async function sendRemixResponse(res, nodeResponse) {
9164
- var _a;
9426
+ var _a, _b;
9427
+ if (isResponseClosed(res)) {
9428
+ await ((_a = nodeResponse.body) == null ? void 0 : _a.cancel());
9429
+ return;
9430
+ }
9165
9431
  res.statusMessage = nodeResponse.statusText;
9166
9432
  res.status(nodeResponse.status);
9167
9433
  for (let [key, value] of nodeResponse.headers.entries()) {
9168
9434
  res.append(key, value);
9169
9435
  }
9170
- if ((_a = nodeResponse.headers.get("Content-Type")) == null ? void 0 : _a.match(/text\/event-stream/i)) {
9436
+ if ((_b = nodeResponse.headers.get("Content-Type")) == null ? void 0 : _b.match(/text\/event-stream/i)) {
9171
9437
  res.flushHeaders();
9172
9438
  }
9173
9439
  if (nodeResponse.body) {
9174
- await writeReadableStreamToWritable(nodeResponse.body, res);
9440
+ try {
9441
+ await writeReadableStreamToWritable(nodeResponse.body, res);
9442
+ } catch (error) {
9443
+ if (isResponseClosed(res)) {
9444
+ return;
9445
+ }
9446
+ throw error;
9447
+ }
9175
9448
  } else {
9176
9449
  res.end();
9177
9450
  }
9178
9451
  }
9452
+ function isResponseClosed(res) {
9453
+ return res.destroyed || res.writableEnded;
9454
+ }
9179
9455
  const app = express();
9180
9456
  app.all(
9181
9457
  "/{*splat}",
9182
9458
  createRequestHandler({
9183
- build: () => import("./server-build-tMGygzbW.js").then((n) => n.a7)
9459
+ build: () => import("./server-build-DFhWV1xt.js").then((n) => n.a7)
9184
9460
  })
9185
9461
  );
9186
9462
  app.use(