@workflow/web 4.1.28 → 4.1.30

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-BAmhYum_.js → app-juehGONX.js} +891 -613
  13. package/build/server/assets/{highlighted-body-B3W2YXNL-D2bE_zLh.js → highlighted-body-B3W2YXNL-DgD9LFQJ.js} +4 -2
  14. package/build/server/assets/index-BUlN7QFn.js +1164 -0
  15. package/build/server/assets/{index-Tv6_4f6I.js → index-C1by_z-e.js} +5 -3
  16. package/build/server/assets/{mermaid-3ZIDBTTL-Dn3iLq1N.js → mermaid-3ZIDBTTL-DBfS-ZH8.js} +4 -2
  17. package/build/server/assets/{server-build-D38evYCr.js → server-build-CgjoLYPd.js} +1797 -68
  18. package/build/server/assets/{token-lgwgo3i8.js → token-CP9u68ZL.js} +2 -2
  19. package/build/server/assets/{token-util-BzAlruRH.js → token-util-BrBJCxub.js} +2 -2
  20. package/build/server/index.js +2 -2
  21. package/package.json +9 -9
  22. package/build/server/assets/index-hBO56emR.js +0 -1286
@@ -704,7 +704,7 @@ function requireReactDom() {
704
704
  return reactDom.exports;
705
705
  }
706
706
  /**
707
- * react-router v7.13.1
707
+ * react-router v7.18.4
708
708
  *
709
709
  * Copyright (c) Remix Software Inc.
710
710
  *
@@ -719,6 +719,12 @@ var __typeError = (msg) => {
719
719
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
720
720
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
721
721
  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);
722
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
723
+ var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i;
724
+ var PROTOCOL_RELATIVE_URL_REGEX = /^[\\/]{2}/;
725
+ function normalizeProtocolRelativeUrl(url, protocol) {
726
+ return protocol + url.replace(/\\/g, "/");
727
+ }
722
728
  var PopStateEventType = "popstate";
723
729
  function isLocation(obj) {
724
730
  return typeof obj === "object" && obj != null && "pathname" in obj && "search" in obj && "hash" in obj && "state" in obj && "key" in obj;
@@ -773,14 +779,14 @@ function getHistoryState(location, index) {
773
779
  usr: location.state,
774
780
  key: location.key,
775
781
  idx: index,
776
- masked: location.unstable_mask ? {
782
+ masked: location.mask ? {
777
783
  pathname: location.pathname,
778
784
  search: location.search,
779
785
  hash: location.hash
780
786
  } : void 0
781
787
  };
782
788
  }
783
- function createLocation(current, to, state = null, key, unstable_mask) {
789
+ function createLocation(current, to, state = null, key, mask) {
784
790
  let location = {
785
791
  pathname: typeof current === "string" ? current : current.pathname,
786
792
  search: "",
@@ -792,7 +798,7 @@ function createLocation(current, to, state = null, key, unstable_mask) {
792
798
  // But that's a pretty big refactor to the current test suite so going to
793
799
  // keep as is for the time being and just let any incoming keys take precedence
794
800
  key: to && to.key || key || createKey(),
795
- unstable_mask
801
+ mask
796
802
  };
797
803
  return location;
798
804
  }
@@ -854,7 +860,7 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
854
860
  let location = isLocation(to) ? to : createLocation(history.location, to, state);
855
861
  index = getIndex() + 1;
856
862
  let historyState = getHistoryState(location, index);
857
- let url = history.createHref(location.unstable_mask || location);
863
+ let url = history.createHref(location.mask || location);
858
864
  try {
859
865
  globalHistory.pushState(historyState, "", url);
860
866
  } catch (error) {
@@ -872,14 +878,14 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
872
878
  let location = isLocation(to) ? to : createLocation(history.location, to, state);
873
879
  index = getIndex();
874
880
  let historyState = getHistoryState(location, index);
875
- let url = history.createHref(location.unstable_mask || location);
881
+ let url = history.createHref(location.mask || location);
876
882
  globalHistory.replaceState(historyState, "", url);
877
883
  if (v5Compat && listener) {
878
884
  listener({ action, location: history.location, delta: 0 });
879
885
  }
880
886
  }
881
887
  function createURL(to) {
882
- return createBrowserURLImpl(to);
888
+ return createBrowserURLImpl(window2, to);
883
889
  }
884
890
  let history = {
885
891
  get action() {
@@ -919,15 +925,15 @@ function getUrlBasedHistory(getLocation, createHref2, validateLocation, options
919
925
  };
920
926
  return history;
921
927
  }
922
- function createBrowserURLImpl(to, isAbsolute = false) {
928
+ function createBrowserURLImpl(windowImpl, to, isAbsolute = false) {
923
929
  let base = "http://localhost";
924
- if (typeof window !== "undefined") {
925
- base = window.location.origin !== "null" ? window.location.origin : window.location.href;
930
+ if (windowImpl) {
931
+ base = windowImpl.location.origin !== "null" ? windowImpl.location.origin : windowImpl.location.href;
926
932
  }
927
933
  invariant(base, "No window.location.(origin|href) available to create URL");
928
934
  let href = typeof to === "string" ? to : createPath(to);
929
935
  href = href.replace(/ $/, "%20");
930
- if (!isAbsolute && href.startsWith("//")) {
936
+ if (!isAbsolute && PROTOCOL_RELATIVE_URL_REGEX.test(href)) {
931
937
  href = base + href;
932
938
  }
933
939
  return new URL(href, base);
@@ -1065,17 +1071,16 @@ function mergeRouteUpdates(route, updates) {
1065
1071
  function matchRoutes(routes, locationArg, basename = "/") {
1066
1072
  return matchRoutesImpl(routes, locationArg, basename, false);
1067
1073
  }
1068
- function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
1074
+ function matchRoutesImpl(routes, locationArg, basename, allowPartial, precomputedBranches) {
1069
1075
  let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
1070
1076
  let pathname = stripBasename(location.pathname || "/", basename);
1071
1077
  if (pathname == null) {
1072
1078
  return null;
1073
1079
  }
1074
- let branches = flattenRoutes(routes);
1075
- rankRouteBranches(branches);
1080
+ let branches = precomputedBranches ?? flattenAndRankRoutes(routes);
1076
1081
  let matches = null;
1082
+ let decoded = decodePath(pathname);
1077
1083
  for (let i = 0; matches == null && i < branches.length; ++i) {
1078
- let decoded = decodePath(pathname);
1079
1084
  matches = matchRouteBranch(
1080
1085
  branches[i],
1081
1086
  decoded,
@@ -1095,6 +1100,11 @@ function convertRouteMatchToUiMatch(match, loaderData) {
1095
1100
  handle: route.handle
1096
1101
  };
1097
1102
  }
1103
+ function flattenAndRankRoutes(routes) {
1104
+ let branches = flattenRoutes(routes);
1105
+ rankRouteBranches(branches);
1106
+ return branches;
1107
+ }
1098
1108
  function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
1099
1109
  let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
1100
1110
  let meta = {
@@ -1136,7 +1146,18 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "",
1136
1146
  branches.push({
1137
1147
  path,
1138
1148
  score: computeScore(path, route.index),
1139
- routesMeta
1149
+ routesMeta: routesMeta.map((meta2, i) => {
1150
+ let [matcher, params] = compilePath(
1151
+ meta2.relativePath,
1152
+ meta2.caseSensitive,
1153
+ i === routesMeta.length - 1
1154
+ );
1155
+ return {
1156
+ ...meta2,
1157
+ matcher,
1158
+ compiledParams: params
1159
+ };
1160
+ })
1140
1161
  });
1141
1162
  };
1142
1163
  routes.forEach((route, index) => {
@@ -1226,9 +1247,19 @@ function matchRouteBranch(branch, pathname, allowPartial = false) {
1226
1247
  let meta = routesMeta[i];
1227
1248
  let end = i === routesMeta.length - 1;
1228
1249
  let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
1229
- let match = matchPath(
1230
- { path: meta.relativePath, caseSensitive: meta.caseSensitive, end },
1231
- remainingPathname
1250
+ let pattern = {
1251
+ path: meta.relativePath,
1252
+ caseSensitive: meta.caseSensitive,
1253
+ end
1254
+ };
1255
+ let match = (
1256
+ // Use precomputed matcher if it exists
1257
+ meta.matcher && meta.compiledParams ? matchPathImpl(
1258
+ pattern,
1259
+ remainingPathname,
1260
+ meta.matcher,
1261
+ meta.compiledParams
1262
+ ) : matchPath(pattern, remainingPathname)
1232
1263
  );
1233
1264
  let route = meta.route;
1234
1265
  if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
@@ -1269,16 +1300,22 @@ function matchPath(pattern, pathname) {
1269
1300
  pattern.caseSensitive,
1270
1301
  pattern.end
1271
1302
  );
1303
+ return matchPathImpl(pattern, pathname, matcher, compiledParams);
1304
+ }
1305
+ function matchPathImpl(pattern, pathname, matcher, compiledParams) {
1272
1306
  let match = pathname.match(matcher);
1273
1307
  if (!match) return null;
1274
1308
  let matchedPathname = match[0];
1275
- let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
1309
+ let pathnameBase = removeTrailingSlash(matchedPathname, 1);
1276
1310
  let captureGroups = match.slice(1);
1277
1311
  let params = compiledParams.reduce(
1278
1312
  (memo2, { paramName, isOptional }, index) => {
1279
1313
  if (paramName === "*") {
1280
1314
  let splatValue = captureGroups[index] || "";
1281
- pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
1315
+ pathnameBase = removeTrailingSlash(
1316
+ matchedPathname.slice(0, matchedPathname.length - splatValue.length),
1317
+ 1
1318
+ );
1282
1319
  }
1283
1320
  const value = captureGroups[index];
1284
1321
  if (isOptional && !value) {
@@ -1357,7 +1394,6 @@ function prependBasename({
1357
1394
  }) {
1358
1395
  return pathname === "/" ? basename : joinPaths([basename, pathname]);
1359
1396
  }
1360
- var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
1361
1397
  var isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX.test(url);
1362
1398
  function resolvePath(to, fromPathname = "/") {
1363
1399
  let {
@@ -1367,8 +1403,8 @@ function resolvePath(to, fromPathname = "/") {
1367
1403
  } = typeof to === "string" ? parsePath(to) : to;
1368
1404
  let pathname;
1369
1405
  if (toPathname) {
1370
- toPathname = toPathname.replace(/\/\/+/g, "/");
1371
- if (toPathname.startsWith("/")) {
1406
+ toPathname = removeDoubleSlashes(toPathname);
1407
+ if (toPathname.startsWith("/") || toPathname.startsWith("\\")) {
1372
1408
  pathname = resolvePathname(toPathname.substring(1), "/");
1373
1409
  } else {
1374
1410
  pathname = resolvePathname(toPathname, fromPathname);
@@ -1383,7 +1419,7 @@ function resolvePath(to, fromPathname = "/") {
1383
1419
  };
1384
1420
  }
1385
1421
  function resolvePathname(relativePath, fromPathname) {
1386
- let segments = fromPathname.replace(/\/+$/, "").split("/");
1422
+ let segments = removeTrailingSlash(fromPathname).split("/");
1387
1423
  let relativeSegments = relativePath.split("/");
1388
1424
  relativeSegments.forEach((segment) => {
1389
1425
  if (segment === "..") {
@@ -1454,8 +1490,16 @@ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = fal
1454
1490
  }
1455
1491
  return path;
1456
1492
  }
1457
- var joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
1458
- var normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
1493
+ var removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/");
1494
+ var joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
1495
+ function removeTrailingSlash(path, minLength = 0) {
1496
+ let end = path.length;
1497
+ while (end > minLength && path.charCodeAt(end - 1) === 47) {
1498
+ end--;
1499
+ }
1500
+ return end === path.length ? path : path.slice(0, end);
1501
+ }
1502
+ var normalizePathname = (pathname) => removeTrailingSlash(pathname).replace(/^\/*/, "/");
1459
1503
  var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
1460
1504
  var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
1461
1505
  var DataWithResponseInit = class {
@@ -1482,6 +1526,14 @@ var redirect = (url, init = 302) => {
1482
1526
  headers.set("Location", url);
1483
1527
  return new Response(null, { ...responseInit, headers });
1484
1528
  };
1529
+ var SUPPORTED_ERROR_TYPES = [
1530
+ "EvalError",
1531
+ "RangeError",
1532
+ "ReferenceError",
1533
+ "SyntaxError",
1534
+ "TypeError",
1535
+ "URIError"
1536
+ ];
1485
1537
  var ErrorResponseImpl = class {
1486
1538
  constructor(status, statusText, data2, internal = false) {
1487
1539
  this.status = status;
@@ -1499,7 +1551,8 @@ function isRouteErrorResponse(error) {
1499
1551
  return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
1500
1552
  }
1501
1553
  function getRoutePattern(matches) {
1502
- return matches.map((m) => m.route.path).filter(Boolean).join("/").replace(/\/\/*/g, "/") || "/";
1554
+ let parts = matches.map((m) => m.route.path).filter(Boolean);
1555
+ return joinPaths(parts) || "/";
1503
1556
  }
1504
1557
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
1505
1558
  function parseToInfo(_to, basename) {
@@ -1516,7 +1569,7 @@ function parseToInfo(_to, basename) {
1516
1569
  if (isBrowser) {
1517
1570
  try {
1518
1571
  let currentUrl = new URL(window.location.href);
1519
- let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
1572
+ let targetUrl = PROTOCOL_RELATIVE_URL_REGEX.test(to) ? new URL(normalizeProtocolRelativeUrl(to, currentUrl.protocol)) : new URL(to);
1520
1573
  let path = stripBasename(targetUrl.pathname, basename);
1521
1574
  if (targetUrl.origin === currentUrl.origin && path != null) {
1522
1575
  to = path + targetUrl.search + targetUrl.hash;
@@ -1732,11 +1785,11 @@ async function recurseRight(impls, info, handler, index) {
1732
1785
  };
1733
1786
  }
1734
1787
  function getHandlerInfo(args) {
1735
- let { request, context, params, unstable_pattern } = args;
1788
+ let { request, context, params, pattern } = args;
1736
1789
  return {
1737
1790
  request: getReadonlyRequest(request),
1738
1791
  params: { ...params },
1739
- unstable_pattern,
1792
+ pattern,
1740
1793
  context: getReadonlyContext(context)
1741
1794
  };
1742
1795
  }
@@ -1777,6 +1830,49 @@ function isPlainObject(thing) {
1777
1830
  const proto = Object.getPrototypeOf(thing);
1778
1831
  return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === objectProtoNames;
1779
1832
  }
1833
+ var DEFAULT_NAVIGATION_URL = new URL("http://localhost");
1834
+ function getNavigatorCurrentUrl(navigator) {
1835
+ if (navigator.createURL) {
1836
+ return navigator.createURL("/");
1837
+ }
1838
+ try {
1839
+ return new URL(navigator.createHref("/"), DEFAULT_NAVIGATION_URL);
1840
+ } catch {
1841
+ return DEFAULT_NAVIGATION_URL;
1842
+ }
1843
+ }
1844
+ function isSameOrigin(a, b) {
1845
+ return a.origin === b.origin && (a.origin !== "null" || a.protocol === b.protocol && a.host === b.host);
1846
+ }
1847
+ function isExplicitUrl(destination, target) {
1848
+ if (destination.startsWith("//")) {
1849
+ return true;
1850
+ }
1851
+ let protocol = target.protocol.toLowerCase();
1852
+ if (!destination.toLowerCase().startsWith(protocol)) {
1853
+ return false;
1854
+ }
1855
+ return target.host === "" || destination.slice(protocol.length).startsWith("//");
1856
+ }
1857
+ function validateNavigationTarget(original, resolved, currentUrl, externalPolicy) {
1858
+ let originalUrl = null;
1859
+ try {
1860
+ originalUrl = original == null ? null : new URL(original, currentUrl);
1861
+ } catch {
1862
+ }
1863
+ let resolvedUrl = new URL(resolved, currentUrl);
1864
+ let originalIsExternal = originalUrl != null && !isSameOrigin(originalUrl, currentUrl);
1865
+ let resolvedIsExternal = !isSameOrigin(resolvedUrl, currentUrl);
1866
+ if (externalPolicy === "reject") {
1867
+ if (originalIsExternal || resolvedIsExternal) {
1868
+ throw new Error("External navigation is not allowed");
1869
+ }
1870
+ } else if (resolvedIsExternal) {
1871
+ if (originalUrl == null || !isExplicitUrl(original, originalUrl) || !isSameOrigin(originalUrl, resolvedUrl)) {
1872
+ throw new Error("External navigation is not allowed");
1873
+ }
1874
+ }
1875
+ }
1780
1876
  var validMutationMethodsArr = [
1781
1877
  "POST",
1782
1878
  "PUT",
@@ -1796,6 +1892,8 @@ var redirectPreserveMethodStatusCodes = /* @__PURE__ */ new Set([307, 308]);
1796
1892
  var IDLE_NAVIGATION = {
1797
1893
  state: "idle",
1798
1894
  location: void 0,
1895
+ matches: void 0,
1896
+ historyAction: void 0,
1799
1897
  formMethod: void 0,
1800
1898
  formAction: void 0,
1801
1899
  formEncType: void 0,
@@ -1824,6 +1922,55 @@ var defaultMapRouteProperties = (route) => ({
1824
1922
  });
1825
1923
  var TRANSITIONS_STORAGE_KEY = "remix-router-transitions";
1826
1924
  var ResetLoaderDataSymbol = Symbol("ResetLoaderData");
1925
+ var _routes, _branches, _hmrRoutes, _hmrBranches;
1926
+ var DataRoutes = class {
1927
+ constructor(routes) {
1928
+ __privateAdd(this, _routes);
1929
+ __privateAdd(this, _branches);
1930
+ __privateAdd(this, _hmrRoutes);
1931
+ __privateAdd(this, _hmrBranches);
1932
+ __privateSet(this, _routes, routes);
1933
+ __privateSet(this, _branches, flattenAndRankRoutes(routes));
1934
+ }
1935
+ /** The stable route tree */
1936
+ get stableRoutes() {
1937
+ return __privateGet(this, _routes);
1938
+ }
1939
+ /** The in-flight route tree if one is active, otherwise the stable tree */
1940
+ get activeRoutes() {
1941
+ return __privateGet(this, _hmrRoutes) ?? __privateGet(this, _routes);
1942
+ }
1943
+ /** Pre-computed branches */
1944
+ get branches() {
1945
+ return __privateGet(this, _hmrBranches) ?? __privateGet(this, _branches);
1946
+ }
1947
+ get hasHMRRoutes() {
1948
+ return __privateGet(this, _hmrRoutes) != null;
1949
+ }
1950
+ /** Replace the stable route tree and recompute its branches */
1951
+ setRoutes(routes) {
1952
+ __privateSet(this, _routes, routes);
1953
+ __privateSet(this, _branches, flattenAndRankRoutes(routes));
1954
+ }
1955
+ /** Set a new in-flight route tree and recompute its branches */
1956
+ setHmrRoutes(routes) {
1957
+ __privateSet(this, _hmrRoutes, routes);
1958
+ __privateSet(this, _hmrBranches, flattenAndRankRoutes(routes));
1959
+ }
1960
+ /** Commit in-flight routes/branches to the stable slot and clear in-flight */
1961
+ commitHmrRoutes() {
1962
+ if (__privateGet(this, _hmrRoutes)) {
1963
+ __privateSet(this, _routes, __privateGet(this, _hmrRoutes));
1964
+ __privateSet(this, _branches, __privateGet(this, _hmrBranches));
1965
+ __privateSet(this, _hmrRoutes, void 0);
1966
+ __privateSet(this, _hmrBranches, void 0);
1967
+ }
1968
+ }
1969
+ };
1970
+ _routes = /* @__PURE__ */ new WeakMap();
1971
+ _branches = /* @__PURE__ */ new WeakMap();
1972
+ _hmrRoutes = /* @__PURE__ */ new WeakMap();
1973
+ _hmrBranches = /* @__PURE__ */ new WeakMap();
1827
1974
  function createRouter(init) {
1828
1975
  const routerWindow = init.window ? init.window : typeof window !== "undefined" ? window : void 0;
1829
1976
  const isBrowser3 = typeof routerWindow !== "undefined" && typeof routerWindow.document !== "undefined" && typeof routerWindow.document.createElement !== "undefined";
@@ -1834,8 +1981,8 @@ function createRouter(init) {
1834
1981
  let hydrationRouteProperties2 = init.hydrationRouteProperties || [];
1835
1982
  let _mapRouteProperties = init.mapRouteProperties || defaultMapRouteProperties;
1836
1983
  let mapRouteProperties2 = _mapRouteProperties;
1837
- if (init.unstable_instrumentations) {
1838
- let instrumentations = init.unstable_instrumentations;
1984
+ if (init.instrumentations) {
1985
+ let instrumentations = init.instrumentations;
1839
1986
  mapRouteProperties2 = (route) => {
1840
1987
  return {
1841
1988
  ..._mapRouteProperties(route),
@@ -1847,13 +1994,14 @@ function createRouter(init) {
1847
1994
  };
1848
1995
  }
1849
1996
  let manifest = {};
1850
- let dataRoutes = convertRoutesToDataRoutes(
1851
- init.routes,
1852
- mapRouteProperties2,
1853
- void 0,
1854
- manifest
1997
+ let dataRoutes = new DataRoutes(
1998
+ convertRoutesToDataRoutes(
1999
+ init.routes,
2000
+ mapRouteProperties2,
2001
+ void 0,
2002
+ manifest
2003
+ )
1855
2004
  );
1856
- let inFlightDataRoutes;
1857
2005
  let basename = init.basename || "/";
1858
2006
  if (!basename.startsWith("/")) {
1859
2007
  basename = `/${basename}`;
@@ -1864,11 +2012,18 @@ function createRouter(init) {
1864
2012
  };
1865
2013
  let unlistenHistory = null;
1866
2014
  let subscribers = /* @__PURE__ */ new Set();
2015
+ let bufferedInitialStateUpdate = null;
1867
2016
  let savedScrollPositions2 = null;
1868
2017
  let getScrollRestorationKey2 = null;
1869
2018
  let getScrollPosition = null;
1870
2019
  let initialScrollRestored = init.hydrationData != null;
1871
- let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
2020
+ let initialMatches = matchRoutesImpl(
2021
+ dataRoutes.activeRoutes,
2022
+ init.history.location,
2023
+ basename,
2024
+ false,
2025
+ dataRoutes.branches
2026
+ );
1872
2027
  let initialMatchesIsFOW = false;
1873
2028
  let initialErrors = null;
1874
2029
  let initialized;
@@ -1877,7 +2032,7 @@ function createRouter(init) {
1877
2032
  let error = getInternalRouterError(404, {
1878
2033
  pathname: init.history.location.pathname
1879
2034
  });
1880
- let { matches, route } = getShortCircuitMatches(dataRoutes);
2035
+ let { matches, route } = getShortCircuitMatches(dataRoutes.activeRoutes);
1881
2036
  initialized = true;
1882
2037
  renderFallback = !initialized;
1883
2038
  initialMatches = matches;
@@ -1886,7 +2041,7 @@ function createRouter(init) {
1886
2041
  if (initialMatches && !init.hydrationData) {
1887
2042
  let fogOfWar = checkFogOfWar(
1888
2043
  initialMatches,
1889
- dataRoutes,
2044
+ dataRoutes.activeRoutes,
1890
2045
  init.history.location.pathname
1891
2046
  );
1892
2047
  if (fogOfWar.active) {
@@ -1899,7 +2054,7 @@ function createRouter(init) {
1899
2054
  initialMatches = [];
1900
2055
  let fogOfWar = checkFogOfWar(
1901
2056
  null,
1902
- dataRoutes,
2057
+ dataRoutes.activeRoutes,
1903
2058
  init.history.location.pathname
1904
2059
  );
1905
2060
  if (fogOfWar.active && fogOfWar.matches) {
@@ -1923,10 +2078,11 @@ function createRouter(init) {
1923
2078
  relevantMatches = relevantMatches.slice(0, idx + 1);
1924
2079
  }
1925
2080
  renderFallback = false;
1926
- initialized = relevantMatches.every((m) => {
2081
+ initialized = true;
2082
+ relevantMatches.forEach((m) => {
1927
2083
  let status = getRouteHydrationStatus(m.route, loaderData, errors);
1928
2084
  renderFallback = renderFallback || status.renderFallback;
1929
- return !status.shouldLoad;
2085
+ initialized = initialized && !status.shouldLoad;
1930
2086
  });
1931
2087
  }
1932
2088
  }
@@ -2038,11 +2194,21 @@ function createRouter(init) {
2038
2194
  }
2039
2195
  subscribers.clear();
2040
2196
  pendingNavigationController && pendingNavigationController.abort();
2041
- state.fetchers.forEach((_, key) => deleteFetcher(key));
2197
+ state.fetchers.forEach((_, key) => deleteFetcher(state.fetchers, key));
2042
2198
  state.blockers.forEach((_, key) => deleteBlocker(key));
2043
2199
  }
2044
2200
  function subscribe(fn) {
2045
2201
  subscribers.add(fn);
2202
+ if (bufferedInitialStateUpdate) {
2203
+ let { newErrors } = bufferedInitialStateUpdate;
2204
+ bufferedInitialStateUpdate = null;
2205
+ fn(state, {
2206
+ deletedFetchers: [],
2207
+ newErrors,
2208
+ viewTransitionOpts: void 0,
2209
+ flushSync: false
2210
+ });
2211
+ }
2046
2212
  return () => subscribers.delete(fn);
2047
2213
  }
2048
2214
  function updateState(newState, opts = {}) {
@@ -2079,6 +2245,9 @@ function createRouter(init) {
2079
2245
  unmountedFetchers.push(key);
2080
2246
  }
2081
2247
  });
2248
+ if (subscribers.size === 0) {
2249
+ bufferedInitialStateUpdate = { newErrors: newState.errors ?? null };
2250
+ }
2082
2251
  [...subscribers].forEach(
2083
2252
  (subscriber) => subscriber(state, {
2084
2253
  deletedFetchers: unmountedFetchers,
@@ -2087,7 +2256,7 @@ function createRouter(init) {
2087
2256
  flushSync: opts.flushSync === true
2088
2257
  })
2089
2258
  );
2090
- unmountedFetchers.forEach((key) => deleteFetcher(key));
2259
+ unmountedFetchers.forEach((key) => deleteFetcher(state.fetchers, key));
2091
2260
  mountedFetchers.forEach((key) => state.fetchers.delete(key));
2092
2261
  }
2093
2262
  function completeNavigation(location, newState, { flushSync } = {}) {
@@ -2118,10 +2287,7 @@ function createRouter(init) {
2118
2287
  }
2119
2288
  let restoreScrollPosition = isUninterruptedRevalidation ? false : getSavedScrollPosition(location, newState.matches || state.matches);
2120
2289
  let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && ((_b = location.state) == null ? void 0 : _b._isRedirect) !== true;
2121
- if (inFlightDataRoutes) {
2122
- dataRoutes = inFlightDataRoutes;
2123
- inFlightDataRoutes = void 0;
2124
- }
2290
+ dataRoutes.commitHmrRoutes();
2125
2291
  if (isUninterruptedRevalidation) ;
2126
2292
  else if (pendingAction === "POP") ;
2127
2293
  else if (pendingAction === "PUSH") {
@@ -2130,7 +2296,7 @@ function createRouter(init) {
2130
2296
  init.history.replace(location, location.state);
2131
2297
  }
2132
2298
  let viewTransitionOpts;
2133
- if (pendingAction === "POP") {
2299
+ if (pendingAction === "POP" && !isUninterruptedRevalidation && location !== state.location) {
2134
2300
  let priorPaths = appliedViewTransitions.get(state.location.pathname);
2135
2301
  if (priorPaths && priorPaths.has(location.pathname)) {
2136
2302
  viewTransitionOpts = {
@@ -2212,17 +2378,27 @@ function createRouter(init) {
2212
2378
  opts
2213
2379
  );
2214
2380
  let maskPath;
2215
- if (opts == null ? void 0 : opts.unstable_mask) {
2216
- let partialPath = typeof opts.unstable_mask === "string" ? parsePath(opts.unstable_mask) : {
2217
- ...state.location.unstable_mask,
2218
- ...opts.unstable_mask
2381
+ if (opts == null ? void 0 : opts.mask) {
2382
+ let partialPath = typeof opts.mask === "string" ? parsePath(opts.mask) : {
2383
+ ...state.location.mask,
2384
+ ...opts.mask
2219
2385
  };
2220
2386
  maskPath = {
2221
- pathname: "",
2222
- search: "",
2223
- hash: "",
2224
- ...partialPath
2387
+ pathname: partialPath.pathname ?? "",
2388
+ search: partialPath.search ?? "",
2389
+ hash: partialPath.hash ?? ""
2225
2390
  };
2391
+ if (PROTOCOL_RELATIVE_URL_REGEX.test(maskPath.pathname)) {
2392
+ throw new Error("External navigation is not allowed");
2393
+ } else if (maskPath.pathname.startsWith("\\")) {
2394
+ maskPath.pathname = maskPath.pathname.replace(/^\\+/, "/");
2395
+ }
2396
+ validateNavigationTarget(
2397
+ typeof opts.mask === "string" ? opts.mask : createPath(opts.mask),
2398
+ createPath(maskPath),
2399
+ init.history.createURL("/"),
2400
+ "reject"
2401
+ );
2226
2402
  }
2227
2403
  let currentLocation = state.location;
2228
2404
  let nextLocation = createLocation(
@@ -2236,6 +2412,12 @@ function createRouter(init) {
2236
2412
  ...nextLocation,
2237
2413
  ...init.history.encodeLocation(nextLocation)
2238
2414
  };
2415
+ validateNavigationTarget(
2416
+ to == null ? init.history.createHref(state.location) : typeof to === "string" ? to : createPath(to),
2417
+ init.history.createHref(nextLocation.mask || nextLocation),
2418
+ init.history.createURL("/"),
2419
+ "reject"
2420
+ );
2239
2421
  let userReplace = opts && opts.replace != null ? opts.replace : void 0;
2240
2422
  let historyAction = "PUSH";
2241
2423
  if (userReplace === true) {
@@ -2281,7 +2463,7 @@ function createRouter(init) {
2281
2463
  replace: opts && opts.replace,
2282
2464
  enableViewTransition: opts && opts.viewTransition,
2283
2465
  flushSync,
2284
- callSiteDefaultShouldRevalidate: opts && opts.unstable_defaultShouldRevalidate
2466
+ callSiteDefaultShouldRevalidate: opts && opts.defaultShouldRevalidate
2285
2467
  });
2286
2468
  }
2287
2469
  function revalidate() {
@@ -2319,12 +2501,17 @@ function createRouter(init) {
2319
2501
  saveScrollPosition(state.location, state.matches);
2320
2502
  pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;
2321
2503
  pendingViewTransitionEnabled = (opts && opts.enableViewTransition) === true;
2322
- let routesToUse = inFlightDataRoutes || dataRoutes;
2323
- let loadingNavigation = opts && opts.overrideNavigation;
2504
+ let routesToUse = dataRoutes.activeRoutes;
2324
2505
  let matches = (opts == null ? void 0 : opts.initialHydration) && state.matches && state.matches.length > 0 && !initialMatchesIsFOW ? (
2325
2506
  // `matchRoutes()` has already been called if we're in here via `router.initialize()`
2326
2507
  state.matches
2327
- ) : matchRoutes(routesToUse, location, basename);
2508
+ ) : matchRoutesImpl(
2509
+ routesToUse,
2510
+ location,
2511
+ basename,
2512
+ false,
2513
+ dataRoutes.branches
2514
+ );
2328
2515
  let flushSync = (opts && opts.flushSync) === true;
2329
2516
  if (matches && state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
2330
2517
  completeNavigation(location, { matches }, { flushSync });
@@ -2351,6 +2538,11 @@ function createRouter(init) {
2351
2538
  );
2352
2539
  return;
2353
2540
  }
2541
+ let loadingNavigation = opts && opts.overrideNavigation ? {
2542
+ ...opts.overrideNavigation,
2543
+ matches,
2544
+ historyAction
2545
+ } : void 0;
2354
2546
  pendingNavigationController = new AbortController();
2355
2547
  let request = createClientSideRequest(
2356
2548
  init.history,
@@ -2371,6 +2563,7 @@ function createRouter(init) {
2371
2563
  location,
2372
2564
  opts.submission,
2373
2565
  matches,
2566
+ historyAction,
2374
2567
  scopedContext,
2375
2568
  fogOfWar.active,
2376
2569
  opts && opts.initialHydration === true,
@@ -2395,7 +2588,12 @@ function createRouter(init) {
2395
2588
  }
2396
2589
  matches = actionResult.matches || matches;
2397
2590
  pendingActionResult = actionResult.pendingActionResult;
2398
- loadingNavigation = getLoadingNavigation(location, opts.submission);
2591
+ loadingNavigation = getLoadingNavigation(
2592
+ location,
2593
+ matches,
2594
+ historyAction,
2595
+ opts.submission
2596
+ );
2399
2597
  flushSync = false;
2400
2598
  fogOfWar.active = false;
2401
2599
  request = createClientSideRequest(
@@ -2408,11 +2606,13 @@ function createRouter(init) {
2408
2606
  shortCircuited,
2409
2607
  matches: updatedMatches,
2410
2608
  loaderData,
2411
- errors
2609
+ errors,
2610
+ workingFetchers
2412
2611
  } = await handleLoaders(
2413
2612
  request,
2414
2613
  location,
2415
2614
  matches,
2615
+ historyAction,
2416
2616
  scopedContext,
2417
2617
  fogOfWar.active,
2418
2618
  loadingNavigation,
@@ -2432,12 +2632,18 @@ function createRouter(init) {
2432
2632
  matches: updatedMatches || matches,
2433
2633
  ...getActionDataForCommit(pendingActionResult),
2434
2634
  loaderData,
2435
- errors
2635
+ errors,
2636
+ ...workingFetchers ? { fetchers: workingFetchers } : {}
2436
2637
  });
2437
2638
  }
2438
- async function handleAction(request, location, submission, matches, scopedContext, isFogOfWar, initialHydration, opts = {}) {
2639
+ async function handleAction(request, location, submission, matches, historyAction, scopedContext, isFogOfWar, initialHydration, opts = {}) {
2439
2640
  interruptActiveLoads();
2440
- let navigation = getSubmittingNavigation(location, submission);
2641
+ let navigation = getSubmittingNavigation(
2642
+ location,
2643
+ matches,
2644
+ historyAction,
2645
+ submission
2646
+ );
2441
2647
  updateState({ navigation }, { flushSync: opts.flushSync === true });
2442
2648
  if (isFogOfWar) {
2443
2649
  let discoverResult = await discoverRoutes(
@@ -2449,7 +2655,9 @@ function createRouter(init) {
2449
2655
  return { shortCircuited: true };
2450
2656
  } else if (discoverResult.type === "error") {
2451
2657
  if (discoverResult.partialMatches.length === 0) {
2452
- let { matches: matches2, route } = getShortCircuitMatches(dataRoutes);
2658
+ let { matches: matches2, route } = getShortCircuitMatches(
2659
+ dataRoutes.activeRoutes
2660
+ );
2453
2661
  return {
2454
2662
  matches: matches2,
2455
2663
  pendingActionResult: [
@@ -2506,6 +2714,7 @@ function createRouter(init) {
2506
2714
  mapRouteProperties2,
2507
2715
  manifest,
2508
2716
  request,
2717
+ location,
2509
2718
  matches,
2510
2719
  actionMatch,
2511
2720
  initialHydration ? [] : hydrationRouteProperties2,
@@ -2513,6 +2722,7 @@ function createRouter(init) {
2513
2722
  );
2514
2723
  let results = await callDataStrategy(
2515
2724
  request,
2725
+ location,
2516
2726
  dsMatches,
2517
2727
  scopedContext,
2518
2728
  null
@@ -2568,8 +2778,8 @@ function createRouter(init) {
2568
2778
  pendingActionResult: [actionMatch.route.id, result]
2569
2779
  };
2570
2780
  }
2571
- async function handleLoaders(request, location, matches, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult, callSiteDefaultShouldRevalidate) {
2572
- let loadingNavigation = overrideNavigation || getLoadingNavigation(location, submission);
2781
+ async function handleLoaders(request, location, matches, historyAction, scopedContext, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult, callSiteDefaultShouldRevalidate) {
2782
+ let loadingNavigation = overrideNavigation || getLoadingNavigation(location, matches, historyAction, submission);
2573
2783
  let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
2574
2784
  let shouldUpdateNavigationState = !isUninterruptedRevalidation && !initialHydration;
2575
2785
  if (isFogOfWar) {
@@ -2594,7 +2804,9 @@ function createRouter(init) {
2594
2804
  return { shortCircuited: true };
2595
2805
  } else if (discoverResult.type === "error") {
2596
2806
  if (discoverResult.partialMatches.length === 0) {
2597
- let { matches: matches2, route } = getShortCircuitMatches(dataRoutes);
2807
+ let { matches: matches2, route } = getShortCircuitMatches(
2808
+ dataRoutes.activeRoutes
2809
+ );
2598
2810
  return {
2599
2811
  matches: matches2,
2600
2812
  loaderData: {},
@@ -2626,7 +2838,7 @@ function createRouter(init) {
2626
2838
  matches = discoverResult.matches;
2627
2839
  }
2628
2840
  }
2629
- let routesToUse = inFlightDataRoutes || dataRoutes;
2841
+ let routesToUse = dataRoutes.activeRoutes;
2630
2842
  let { dsMatches, revalidatingFetchers } = getMatchesToLoad(
2631
2843
  request,
2632
2844
  scopedContext,
@@ -2647,6 +2859,7 @@ function createRouter(init) {
2647
2859
  routesToUse,
2648
2860
  basename,
2649
2861
  init.patchRoutesOnNavigation != null,
2862
+ dataRoutes.branches,
2650
2863
  pendingActionResult,
2651
2864
  callSiteDefaultShouldRevalidate
2652
2865
  );
@@ -2654,7 +2867,8 @@ function createRouter(init) {
2654
2867
  if (!init.dataStrategy && !dsMatches.some((m) => m.shouldLoad) && !dsMatches.some(
2655
2868
  (m) => m.route.middleware && m.route.middleware.length > 0
2656
2869
  ) && revalidatingFetchers.length === 0) {
2657
- let updatedFetchers2 = markFetchRedirectsDone();
2870
+ let workingFetchers2 = new Map(state.fetchers);
2871
+ let didUpdateFetcherRedirects2 = markFetchRedirectsDone(workingFetchers2);
2658
2872
  completeNavigation(
2659
2873
  location,
2660
2874
  {
@@ -2663,7 +2877,7 @@ function createRouter(init) {
2663
2877
  // Commit pending error if we're short circuiting
2664
2878
  errors: pendingActionResult && isErrorResult(pendingActionResult[1]) ? { [pendingActionResult[0]]: pendingActionResult[1].error } : null,
2665
2879
  ...getActionDataForCommit(pendingActionResult),
2666
- ...updatedFetchers2 ? { fetchers: new Map(state.fetchers) } : {}
2880
+ ...didUpdateFetcherRedirects2 ? { fetchers: workingFetchers2 } : {}
2667
2881
  },
2668
2882
  { flushSync }
2669
2883
  );
@@ -2700,6 +2914,7 @@ function createRouter(init) {
2700
2914
  dsMatches,
2701
2915
  revalidatingFetchers,
2702
2916
  request,
2917
+ location,
2703
2918
  scopedContext
2704
2919
  );
2705
2920
  if (request.signal.aborted) {
@@ -2727,25 +2942,30 @@ function createRouter(init) {
2727
2942
  });
2728
2943
  return { shortCircuited: true };
2729
2944
  }
2945
+ let workingFetchers = new Map(state.fetchers);
2730
2946
  let { loaderData, errors } = processLoaderData(
2731
2947
  state,
2732
2948
  matches,
2733
2949
  loaderResults,
2734
2950
  pendingActionResult,
2735
2951
  revalidatingFetchers,
2736
- fetcherResults
2952
+ fetcherResults,
2953
+ workingFetchers
2737
2954
  );
2738
2955
  if (initialHydration && state.errors) {
2739
2956
  errors = { ...state.errors, ...errors };
2740
2957
  }
2741
- let updatedFetchers = markFetchRedirectsDone();
2742
- let didAbortFetchLoads = abortStaleFetchLoads(pendingNavigationLoadId);
2743
- let shouldUpdateFetchers = updatedFetchers || didAbortFetchLoads || revalidatingFetchers.length > 0;
2958
+ let didUpdateFetcherRedirects = markFetchRedirectsDone(workingFetchers);
2959
+ let didAbortFetchLoads = abortStaleFetchLoads(
2960
+ pendingNavigationLoadId,
2961
+ workingFetchers
2962
+ );
2963
+ let shouldUpdateFetchers = didUpdateFetcherRedirects || didAbortFetchLoads || revalidatingFetchers.length > 0;
2744
2964
  return {
2745
2965
  matches,
2746
2966
  loaderData,
2747
2967
  errors,
2748
- ...shouldUpdateFetchers ? { fetchers: new Map(state.fetchers) } : {}
2968
+ ...shouldUpdateFetchers ? { workingFetchers } : {}
2749
2969
  };
2750
2970
  }
2751
2971
  function getUpdatedActionData(pendingActionResult) {
@@ -2762,20 +2982,21 @@ function createRouter(init) {
2762
2982
  }
2763
2983
  }
2764
2984
  function getUpdatedRevalidatingFetchers(revalidatingFetchers) {
2985
+ let workingFetchers = new Map(state.fetchers);
2765
2986
  revalidatingFetchers.forEach((rf) => {
2766
- let fetcher = state.fetchers.get(rf.key);
2987
+ let fetcher = workingFetchers.get(rf.key);
2767
2988
  let revalidatingFetcher = getLoadingFetcher(
2768
2989
  void 0,
2769
2990
  fetcher ? fetcher.data : void 0
2770
2991
  );
2771
- state.fetchers.set(rf.key, revalidatingFetcher);
2992
+ workingFetchers.set(rf.key, revalidatingFetcher);
2772
2993
  });
2773
- return new Map(state.fetchers);
2994
+ return workingFetchers;
2774
2995
  }
2775
2996
  async function fetch2(key, routeId, href, opts) {
2776
2997
  abortFetcher(key);
2777
2998
  let flushSync = (opts && opts.flushSync) === true;
2778
- let routesToUse = inFlightDataRoutes || dataRoutes;
2999
+ let routesToUse = dataRoutes.activeRoutes;
2779
3000
  let normalizedPath = normalizeTo(
2780
3001
  state.location,
2781
3002
  state.matches,
@@ -2784,7 +3005,13 @@ function createRouter(init) {
2784
3005
  routeId,
2785
3006
  opts == null ? void 0 : opts.relative
2786
3007
  );
2787
- let matches = matchRoutes(routesToUse, normalizedPath, basename);
3008
+ let matches = matchRoutesImpl(
3009
+ routesToUse,
3010
+ normalizedPath,
3011
+ basename,
3012
+ false,
3013
+ dataRoutes.branches
3014
+ );
2788
3015
  let fogOfWar = checkFogOfWar(matches, routesToUse, normalizedPath);
2789
3016
  if (fogOfWar.active && fogOfWar.matches) {
2790
3017
  matches = fogOfWar.matches;
@@ -2820,7 +3047,7 @@ function createRouter(init) {
2820
3047
  flushSync,
2821
3048
  preventScrollReset,
2822
3049
  submission,
2823
- opts && opts.unstable_defaultShouldRevalidate
3050
+ opts && opts.defaultShouldRevalidate
2824
3051
  );
2825
3052
  return;
2826
3053
  }
@@ -2891,6 +3118,7 @@ function createRouter(init) {
2891
3118
  mapRouteProperties2,
2892
3119
  manifest,
2893
3120
  fetchRequest,
3121
+ path,
2894
3122
  requestMatches,
2895
3123
  match,
2896
3124
  hydrationRouteProperties2,
@@ -2898,6 +3126,7 @@ function createRouter(init) {
2898
3126
  );
2899
3127
  let actionResults = await callDataStrategy(
2900
3128
  fetchRequest,
3129
+ path,
2901
3130
  fetchMatches,
2902
3131
  scopedContext,
2903
3132
  key
@@ -2948,13 +3177,17 @@ function createRouter(init) {
2948
3177
  nextLocation,
2949
3178
  abortController.signal
2950
3179
  );
2951
- let routesToUse = inFlightDataRoutes || dataRoutes;
2952
- let matches = state.navigation.state !== "idle" ? matchRoutes(routesToUse, state.navigation.location, basename) : state.matches;
3180
+ let routesToUse = dataRoutes.activeRoutes;
3181
+ let matches = state.navigation.state !== "idle" ? matchRoutesImpl(
3182
+ routesToUse,
3183
+ state.navigation.location,
3184
+ basename,
3185
+ false,
3186
+ dataRoutes.branches
3187
+ ) : state.matches;
2953
3188
  invariant(matches, "Didn't find any matches after fetcher action");
2954
3189
  let loadId = ++incrementingLoadId;
2955
3190
  fetchReloadIds.set(key, loadId);
2956
- let loadFetcher = getLoadingFetcher(submission, actionResult.data);
2957
- state.fetchers.set(key, loadFetcher);
2958
3191
  let { dsMatches, revalidatingFetchers } = getMatchesToLoad(
2959
3192
  revalidationRequest,
2960
3193
  scopedContext,
@@ -2975,23 +3208,27 @@ function createRouter(init) {
2975
3208
  routesToUse,
2976
3209
  basename,
2977
3210
  init.patchRoutesOnNavigation != null,
3211
+ dataRoutes.branches,
2978
3212
  [match.route.id, actionResult],
2979
3213
  callSiteDefaultShouldRevalidate
2980
3214
  );
3215
+ let loadFetcher = getLoadingFetcher(submission, actionResult.data);
3216
+ let workingFetchers = new Map(state.fetchers);
3217
+ workingFetchers.set(key, loadFetcher);
2981
3218
  revalidatingFetchers.filter((rf) => rf.key !== key).forEach((rf) => {
2982
3219
  let staleKey = rf.key;
2983
- let existingFetcher2 = state.fetchers.get(staleKey);
3220
+ let existingFetcher2 = workingFetchers.get(staleKey);
2984
3221
  let revalidatingFetcher = getLoadingFetcher(
2985
3222
  void 0,
2986
3223
  existingFetcher2 ? existingFetcher2.data : void 0
2987
3224
  );
2988
- state.fetchers.set(staleKey, revalidatingFetcher);
3225
+ workingFetchers.set(staleKey, revalidatingFetcher);
2989
3226
  abortFetcher(staleKey);
2990
3227
  if (rf.controller) {
2991
3228
  fetchControllers.set(staleKey, rf.controller);
2992
3229
  }
2993
3230
  });
2994
- updateState({ fetchers: new Map(state.fetchers) });
3231
+ updateState({ fetchers: workingFetchers });
2995
3232
  let abortPendingFetchRevalidations = () => revalidatingFetchers.forEach((rf) => abortFetcher(rf.key));
2996
3233
  abortController.signal.addEventListener(
2997
3234
  "abort",
@@ -3001,6 +3238,7 @@ function createRouter(init) {
3001
3238
  dsMatches,
3002
3239
  revalidatingFetchers,
3003
3240
  revalidationRequest,
3241
+ nextLocation,
3004
3242
  scopedContext
3005
3243
  );
3006
3244
  if (abortController.signal.aborted) {
@@ -3013,12 +3251,16 @@ function createRouter(init) {
3013
3251
  fetchReloadIds.delete(key);
3014
3252
  fetchControllers.delete(key);
3015
3253
  revalidatingFetchers.forEach((r) => fetchControllers.delete(r.key));
3016
- if (state.fetchers.has(key)) {
3017
- let doneFetcher = getDoneFetcher(actionResult.data);
3018
- state.fetchers.set(key, doneFetcher);
3019
- }
3254
+ let fetcherIsMounted = state.fetchers.has(key);
3255
+ let getRedirectStateWithDoneFetcher = (s) => {
3256
+ if (!fetcherIsMounted) return s;
3257
+ let workingFetchers2 = new Map(s.fetchers);
3258
+ workingFetchers2.set(key, getDoneFetcher(actionResult.data));
3259
+ return { ...s, fetchers: workingFetchers2 };
3260
+ };
3020
3261
  let redirect2 = findRedirect(loaderResults);
3021
3262
  if (redirect2) {
3263
+ state = getRedirectStateWithDoneFetcher(state);
3022
3264
  return startRedirectNavigation(
3023
3265
  revalidationRequest,
3024
3266
  redirect2.result,
@@ -3029,6 +3271,7 @@ function createRouter(init) {
3029
3271
  redirect2 = findRedirect(fetcherResults);
3030
3272
  if (redirect2) {
3031
3273
  fetchRedirectIds.add(redirect2.key);
3274
+ state = getRedirectStateWithDoneFetcher(state);
3032
3275
  return startRedirectNavigation(
3033
3276
  revalidationRequest,
3034
3277
  redirect2.result,
@@ -3036,15 +3279,20 @@ function createRouter(init) {
3036
3279
  { preventScrollReset }
3037
3280
  );
3038
3281
  }
3282
+ let finalFetchers = new Map(state.fetchers);
3283
+ if (fetcherIsMounted) {
3284
+ finalFetchers.set(key, getDoneFetcher(actionResult.data));
3285
+ }
3039
3286
  let { loaderData, errors } = processLoaderData(
3040
3287
  state,
3041
3288
  matches,
3042
3289
  loaderResults,
3043
3290
  void 0,
3044
3291
  revalidatingFetchers,
3045
- fetcherResults
3292
+ fetcherResults,
3293
+ finalFetchers
3046
3294
  );
3047
- abortStaleFetchLoads(loadId);
3295
+ abortStaleFetchLoads(loadId, finalFetchers);
3048
3296
  if (state.navigation.state === "loading" && loadId > pendingNavigationLoadId) {
3049
3297
  invariant(pendingAction, "Expected pending action");
3050
3298
  pendingNavigationController && pendingNavigationController.abort();
@@ -3052,7 +3300,7 @@ function createRouter(init) {
3052
3300
  matches,
3053
3301
  loaderData,
3054
3302
  errors,
3055
- fetchers: new Map(state.fetchers)
3303
+ fetchers: finalFetchers
3056
3304
  });
3057
3305
  } else {
3058
3306
  updateState({
@@ -3063,7 +3311,7 @@ function createRouter(init) {
3063
3311
  matches,
3064
3312
  errors
3065
3313
  ),
3066
- fetchers: new Map(state.fetchers)
3314
+ fetchers: finalFetchers
3067
3315
  });
3068
3316
  isRevalidationRequired = false;
3069
3317
  }
@@ -3115,6 +3363,7 @@ function createRouter(init) {
3115
3363
  mapRouteProperties2,
3116
3364
  manifest,
3117
3365
  fetchRequest,
3366
+ path,
3118
3367
  matches,
3119
3368
  match,
3120
3369
  hydrationRouteProperties2,
@@ -3122,11 +3371,20 @@ function createRouter(init) {
3122
3371
  );
3123
3372
  let results = await callDataStrategy(
3124
3373
  fetchRequest,
3374
+ path,
3125
3375
  dsMatches,
3126
3376
  scopedContext,
3127
3377
  key
3128
3378
  );
3129
3379
  let result = results[match.route.id];
3380
+ if (!result) {
3381
+ for (let match2 of matches) {
3382
+ if (results[match2.route.id]) {
3383
+ result = results[match2.route.id];
3384
+ break;
3385
+ }
3386
+ }
3387
+ }
3130
3388
  if (fetchControllers.get(key) === abortController) {
3131
3389
  fetchControllers.delete(key);
3132
3390
  }
@@ -3170,12 +3428,20 @@ function createRouter(init) {
3170
3428
  }
3171
3429
  let location = redirect2.response.headers.get("Location");
3172
3430
  invariant(location, "Expected a Location header on the redirect Response");
3431
+ let originalLocation = location;
3432
+ let currentUrl = new URL(request.url);
3173
3433
  location = normalizeRedirectLocation(
3174
3434
  location,
3175
- new URL(request.url),
3435
+ currentUrl,
3176
3436
  basename,
3177
3437
  init.history
3178
3438
  );
3439
+ validateNavigationTarget(
3440
+ originalLocation,
3441
+ location,
3442
+ currentUrl,
3443
+ "allow-explicit"
3444
+ );
3179
3445
  let redirectLocation = createLocation(state.location, location, {
3180
3446
  _isRedirect: true
3181
3447
  });
@@ -3184,7 +3450,7 @@ function createRouter(init) {
3184
3450
  if (redirect2.response.headers.has("X-Remix-Reload-Document")) {
3185
3451
  isDocumentReload = true;
3186
3452
  } else if (isAbsoluteUrl(location)) {
3187
- const url = createBrowserURLImpl(location, true);
3453
+ const url = createBrowserURLImpl(routerWindow, location, true);
3188
3454
  isDocumentReload = // Hard reload if it's an absolute URL to a new origin
3189
3455
  url.origin !== routerWindow.location.origin || // Hard reload if it's an absolute URL that does not match our basename
3190
3456
  stripBasename(url.pathname, basename) == null;
@@ -3218,6 +3484,8 @@ function createRouter(init) {
3218
3484
  } else {
3219
3485
  let overrideNavigation = getLoadingNavigation(
3220
3486
  redirectLocation,
3487
+ [],
3488
+ redirectNavigationType,
3221
3489
  submission
3222
3490
  );
3223
3491
  await startNavigation(redirectNavigationType, redirectLocation, {
@@ -3230,7 +3498,7 @@ function createRouter(init) {
3230
3498
  });
3231
3499
  }
3232
3500
  }
3233
- async function callDataStrategy(request, matches, scopedContext, fetcherKey) {
3501
+ async function callDataStrategy(request, path, matches, scopedContext, fetcherKey) {
3234
3502
  var _a;
3235
3503
  let results;
3236
3504
  let dataResults = {};
@@ -3238,6 +3506,7 @@ function createRouter(init) {
3238
3506
  results = await callDataStrategyImpl(
3239
3507
  dataStrategyImpl,
3240
3508
  request,
3509
+ path,
3241
3510
  matches,
3242
3511
  fetcherKey,
3243
3512
  scopedContext,
@@ -3289,9 +3558,10 @@ function createRouter(init) {
3289
3558
  }
3290
3559
  return dataResults;
3291
3560
  }
3292
- async function callLoadersAndMaybeResolveData(matches, fetchersToLoad, request, scopedContext) {
3561
+ async function callLoadersAndMaybeResolveData(matches, fetchersToLoad, request, location, scopedContext) {
3293
3562
  let loaderResultsPromise = callDataStrategy(
3294
3563
  request,
3564
+ location,
3295
3565
  matches,
3296
3566
  scopedContext,
3297
3567
  null
@@ -3301,6 +3571,7 @@ function createRouter(init) {
3301
3571
  if (f.matches && f.match && f.request && f.controller) {
3302
3572
  let results = await callDataStrategy(
3303
3573
  f.request,
3574
+ f.path,
3304
3575
  f.matches,
3305
3576
  scopedContext,
3306
3577
  f.key
@@ -3339,21 +3610,23 @@ function createRouter(init) {
3339
3610
  });
3340
3611
  }
3341
3612
  function updateFetcherState(key, fetcher, opts = {}) {
3342
- state.fetchers.set(key, fetcher);
3613
+ let workingFetchers = new Map(state.fetchers);
3614
+ workingFetchers.set(key, fetcher);
3343
3615
  updateState(
3344
- { fetchers: new Map(state.fetchers) },
3616
+ { fetchers: workingFetchers },
3345
3617
  { flushSync: (opts && opts.flushSync) === true }
3346
3618
  );
3347
3619
  }
3348
3620
  function setFetcherError(key, routeId, error, opts = {}) {
3349
3621
  let boundaryMatch = findNearestBoundary(state.matches, routeId);
3350
- deleteFetcher(key);
3622
+ let workingFetchers = new Map(state.fetchers);
3623
+ deleteFetcher(workingFetchers, key);
3351
3624
  updateState(
3352
3625
  {
3353
3626
  errors: {
3354
3627
  [boundaryMatch.route.id]: error
3355
3628
  },
3356
- fetchers: new Map(state.fetchers)
3629
+ fetchers: workingFetchers
3357
3630
  },
3358
3631
  { flushSync: (opts && opts.flushSync) === true }
3359
3632
  );
@@ -3369,7 +3642,7 @@ function createRouter(init) {
3369
3642
  abortFetcher(key, opts == null ? void 0 : opts.reason);
3370
3643
  updateFetcherState(key, getDoneFetcher(null));
3371
3644
  }
3372
- function deleteFetcher(key) {
3645
+ function deleteFetcher(fetchers, key) {
3373
3646
  let fetcher = state.fetchers.get(key);
3374
3647
  if (fetchControllers.has(key) && !(fetcher && fetcher.state === "loading" && fetchReloadIds.has(key))) {
3375
3648
  abortFetcher(key);
@@ -3379,7 +3652,7 @@ function createRouter(init) {
3379
3652
  fetchRedirectIds.delete(key);
3380
3653
  fetchersQueuedForDeletion.delete(key);
3381
3654
  cancelledFetcherLoads.delete(key);
3382
- state.fetchers.delete(key);
3655
+ fetchers.delete(key);
3383
3656
  }
3384
3657
  function queueFetcherForDeletion(key) {
3385
3658
  let count = (activeFetchers.get(key) || 0) - 1;
@@ -3398,33 +3671,34 @@ function createRouter(init) {
3398
3671
  fetchControllers.delete(key);
3399
3672
  }
3400
3673
  }
3401
- function markFetchersDone(keys) {
3674
+ function markFetchersDone(keys, fetchers) {
3402
3675
  for (let key of keys) {
3403
- let fetcher = getFetcher(key);
3676
+ let fetcher = fetchers.get(key);
3677
+ invariant(fetcher, `Expected fetcher: ${key}`);
3404
3678
  let doneFetcher = getDoneFetcher(fetcher.data);
3405
- state.fetchers.set(key, doneFetcher);
3679
+ fetchers.set(key, doneFetcher);
3406
3680
  }
3407
3681
  }
3408
- function markFetchRedirectsDone() {
3682
+ function markFetchRedirectsDone(fetchers) {
3409
3683
  let doneKeys = [];
3410
- let updatedFetchers = false;
3684
+ let didUpdateFetchers = false;
3411
3685
  for (let key of fetchRedirectIds) {
3412
- let fetcher = state.fetchers.get(key);
3686
+ let fetcher = fetchers.get(key);
3413
3687
  invariant(fetcher, `Expected fetcher: ${key}`);
3414
3688
  if (fetcher.state === "loading") {
3415
3689
  fetchRedirectIds.delete(key);
3416
3690
  doneKeys.push(key);
3417
- updatedFetchers = true;
3691
+ didUpdateFetchers = true;
3418
3692
  }
3419
3693
  }
3420
- markFetchersDone(doneKeys);
3421
- return updatedFetchers;
3694
+ markFetchersDone(doneKeys, fetchers);
3695
+ return didUpdateFetchers;
3422
3696
  }
3423
- function abortStaleFetchLoads(landedId) {
3697
+ function abortStaleFetchLoads(landedId, fetchers) {
3424
3698
  let yeetedKeys = [];
3425
3699
  for (let [key, id] of fetchReloadIds) {
3426
3700
  if (id < landedId) {
3427
- let fetcher = state.fetchers.get(key);
3701
+ let fetcher = fetchers.get(key);
3428
3702
  invariant(fetcher, `Expected fetcher: ${key}`);
3429
3703
  if (fetcher.state === "loading") {
3430
3704
  abortFetcher(key);
@@ -3433,7 +3707,7 @@ function createRouter(init) {
3433
3707
  }
3434
3708
  }
3435
3709
  }
3436
- markFetchersDone(yeetedKeys);
3710
+ markFetchersDone(yeetedKeys, fetchers);
3437
3711
  return yeetedKeys.length > 0;
3438
3712
  }
3439
3713
  function getBlocker(key, fn) {
@@ -3480,7 +3754,7 @@ function createRouter(init) {
3480
3754
  }
3481
3755
  function handleNavigational404(pathname) {
3482
3756
  let error = getInternalRouterError(404, { pathname });
3483
- let routesToUse = inFlightDataRoutes || dataRoutes;
3757
+ let routesToUse = dataRoutes.activeRoutes;
3484
3758
  let { matches, route } = getShortCircuitMatches(routesToUse);
3485
3759
  return { notFoundMatches: matches, route, error };
3486
3760
  }
@@ -3529,12 +3803,14 @@ function createRouter(init) {
3529
3803
  }
3530
3804
  function checkFogOfWar(matches, routesToUse, pathname) {
3531
3805
  if (init.patchRoutesOnNavigation) {
3806
+ let activeBranches = dataRoutes.branches;
3532
3807
  if (!matches) {
3533
3808
  let fogMatches = matchRoutesImpl(
3534
3809
  routesToUse,
3535
3810
  pathname,
3536
3811
  basename,
3537
- true
3812
+ true,
3813
+ activeBranches
3538
3814
  );
3539
3815
  return { active: true, matches: fogMatches || [] };
3540
3816
  } else {
@@ -3543,7 +3819,8 @@ function createRouter(init) {
3543
3819
  routesToUse,
3544
3820
  pathname,
3545
3821
  basename,
3546
- true
3822
+ true,
3823
+ activeBranches
3547
3824
  );
3548
3825
  return { active: true, matches: partialMatches };
3549
3826
  }
@@ -3557,8 +3834,6 @@ function createRouter(init) {
3557
3834
  }
3558
3835
  let partialMatches = matches;
3559
3836
  while (true) {
3560
- let isNonHMR = inFlightDataRoutes == null;
3561
- let routesToUse = inFlightDataRoutes || dataRoutes;
3562
3837
  let localManifest = manifest;
3563
3838
  try {
3564
3839
  await init.patchRoutesOnNavigation({
@@ -3571,7 +3846,7 @@ function createRouter(init) {
3571
3846
  patchRoutesImpl(
3572
3847
  routeId,
3573
3848
  children,
3574
- routesToUse,
3849
+ dataRoutes,
3575
3850
  localManifest,
3576
3851
  mapRouteProperties2,
3577
3852
  false
@@ -3580,25 +3855,29 @@ function createRouter(init) {
3580
3855
  });
3581
3856
  } catch (e) {
3582
3857
  return { type: "error", error: e, partialMatches };
3583
- } finally {
3584
- if (isNonHMR && !signal.aborted) {
3585
- dataRoutes = [...dataRoutes];
3586
- }
3587
3858
  }
3588
3859
  if (signal.aborted) {
3589
3860
  return { type: "aborted" };
3590
3861
  }
3591
- let newMatches = matchRoutes(routesToUse, pathname, basename);
3862
+ let activeBranches = dataRoutes.branches;
3863
+ let newMatches = matchRoutesImpl(
3864
+ dataRoutes.activeRoutes,
3865
+ pathname,
3866
+ basename,
3867
+ false,
3868
+ activeBranches
3869
+ );
3592
3870
  let newPartialMatches = null;
3593
3871
  if (newMatches) {
3594
3872
  if (Object.keys(newMatches[0].params).length === 0) {
3595
3873
  return { type: "success", matches: newMatches };
3596
3874
  } else {
3597
3875
  newPartialMatches = matchRoutesImpl(
3598
- routesToUse,
3876
+ dataRoutes.activeRoutes,
3599
3877
  pathname,
3600
3878
  basename,
3601
- true
3879
+ true,
3880
+ activeBranches
3602
3881
  );
3603
3882
  let matchedDeeper = newPartialMatches && partialMatches.length < newPartialMatches.length && compareMatches(
3604
3883
  partialMatches,
@@ -3611,10 +3890,11 @@ function createRouter(init) {
3611
3890
  }
3612
3891
  if (!newPartialMatches) {
3613
3892
  newPartialMatches = matchRoutesImpl(
3614
- routesToUse,
3893
+ dataRoutes.activeRoutes,
3615
3894
  pathname,
3616
3895
  basename,
3617
- true
3896
+ true,
3897
+ activeBranches
3618
3898
  );
3619
3899
  }
3620
3900
  if (!newPartialMatches || compareMatches(partialMatches, newPartialMatches)) {
@@ -3628,26 +3908,25 @@ function createRouter(init) {
3628
3908
  }
3629
3909
  function _internalSetRoutes(newRoutes) {
3630
3910
  manifest = {};
3631
- inFlightDataRoutes = convertRoutesToDataRoutes(
3632
- newRoutes,
3633
- mapRouteProperties2,
3634
- void 0,
3635
- manifest
3911
+ dataRoutes.setHmrRoutes(
3912
+ convertRoutesToDataRoutes(
3913
+ newRoutes,
3914
+ mapRouteProperties2,
3915
+ void 0,
3916
+ manifest
3917
+ )
3636
3918
  );
3637
3919
  }
3638
3920
  function patchRoutes(routeId, children, unstable_allowElementMutations = false) {
3639
- let isNonHMR = inFlightDataRoutes == null;
3640
- let routesToUse = inFlightDataRoutes || dataRoutes;
3641
3921
  patchRoutesImpl(
3642
3922
  routeId,
3643
3923
  children,
3644
- routesToUse,
3924
+ dataRoutes,
3645
3925
  manifest,
3646
3926
  mapRouteProperties2,
3647
3927
  unstable_allowElementMutations
3648
3928
  );
3649
- if (isNonHMR) {
3650
- dataRoutes = [...dataRoutes];
3929
+ if (!dataRoutes.hasHMRRoutes) {
3651
3930
  updateState({});
3652
3931
  }
3653
3932
  }
@@ -3662,7 +3941,13 @@ function createRouter(init) {
3662
3941
  return state;
3663
3942
  },
3664
3943
  get routes() {
3665
- return dataRoutes;
3944
+ return dataRoutes.stableRoutes;
3945
+ },
3946
+ get branches() {
3947
+ return dataRoutes.branches;
3948
+ },
3949
+ get manifest() {
3950
+ return manifest;
3666
3951
  },
3667
3952
  get window() {
3668
3953
  return routerWindow;
@@ -3676,6 +3961,7 @@ function createRouter(init) {
3676
3961
  // Passthrough to history-aware createHref used by useHref so we get proper
3677
3962
  // hash-aware URLs in DOM paths
3678
3963
  createHref: (to) => init.history.createHref(to),
3964
+ createURL: (to) => init.history.createURL(to),
3679
3965
  encodeLocation: (to) => init.history.encodeLocation(to),
3680
3966
  getFetcher,
3681
3967
  resetFetcher,
@@ -3692,10 +3978,10 @@ function createRouter(init) {
3692
3978
  updateState(newState);
3693
3979
  }
3694
3980
  };
3695
- if (init.unstable_instrumentations) {
3981
+ if (init.instrumentations) {
3696
3982
  router = instrumentClientSideRouter(
3697
3983
  router,
3698
- init.unstable_instrumentations.map((i) => i.router).filter(Boolean)
3984
+ init.instrumentations.map((i) => i.router).filter(Boolean)
3699
3985
  );
3700
3986
  }
3701
3987
  return router;
@@ -3854,7 +4140,7 @@ function normalizeNavigateOptions(isFetcher, path, opts) {
3854
4140
  parsedPath.search = `?${searchParams}`;
3855
4141
  return { path: createPath(parsedPath), submission };
3856
4142
  }
3857
- function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, hasPatchRoutesOnNavigation, pendingActionResult, callSiteDefaultShouldRevalidate) {
4143
+ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest, history, state, matches, submission, location, lazyRoutePropertiesToSkip, initialHydration, isRevalidationRequired, cancelledFetcherLoads, fetchersQueuedForDeletion, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, hasPatchRoutesOnNavigation, branches, pendingActionResult, callSiteDefaultShouldRevalidate) {
3858
4144
  var _a;
3859
4145
  let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
3860
4146
  let currentUrl = history.createURL(state.location);
@@ -3903,6 +4189,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
3903
4189
  mapRouteProperties2,
3904
4190
  manifest,
3905
4191
  request,
4192
+ location,
3906
4193
  pattern,
3907
4194
  match,
3908
4195
  lazyRoutePropertiesToSkip,
@@ -3933,6 +4220,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
3933
4220
  mapRouteProperties2,
3934
4221
  manifest,
3935
4222
  request,
4223
+ location,
3936
4224
  pattern,
3937
4225
  match,
3938
4226
  lazyRoutePropertiesToSkip,
@@ -3949,7 +4237,13 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
3949
4237
  }
3950
4238
  let fetcher = state.fetchers.get(key);
3951
4239
  let isMidInitialLoad = fetcher && fetcher.state !== "idle" && fetcher.data === void 0;
3952
- let fetcherMatches = matchRoutes(routesToUse, f.path, basename);
4240
+ let fetcherMatches = matchRoutesImpl(
4241
+ routesToUse,
4242
+ f.path,
4243
+ basename ?? "/",
4244
+ false,
4245
+ branches
4246
+ );
3953
4247
  if (!fetcherMatches) {
3954
4248
  if (hasPatchRoutesOnNavigation && isMidInitialLoad) {
3955
4249
  return;
@@ -3982,6 +4276,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
3982
4276
  mapRouteProperties2,
3983
4277
  manifest,
3984
4278
  fetchRequest,
4279
+ f.path,
3985
4280
  fetcherMatches,
3986
4281
  fetcherMatch,
3987
4282
  lazyRoutePropertiesToSkip,
@@ -3993,6 +4288,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
3993
4288
  mapRouteProperties2,
3994
4289
  manifest,
3995
4290
  fetchRequest,
4291
+ f.path,
3996
4292
  fetcherMatches,
3997
4293
  fetcherMatch,
3998
4294
  lazyRoutePropertiesToSkip,
@@ -4017,6 +4313,7 @@ function getMatchesToLoad(request, scopedContext, mapRouteProperties2, manifest,
4017
4313
  mapRouteProperties2,
4018
4314
  manifest,
4019
4315
  fetchRequest,
4316
+ f.path,
4020
4317
  fetcherMatches,
4021
4318
  fetcherMatch,
4022
4319
  lazyRoutePropertiesToSkip,
@@ -4087,7 +4384,7 @@ function shouldRevalidateLoader(loaderMatch, arg) {
4087
4384
  }
4088
4385
  return arg.defaultShouldRevalidate;
4089
4386
  }
4090
- function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2, allowElementMutations) {
4387
+ function patchRoutesImpl(routeId, children, dataRoutes, manifest, mapRouteProperties2, allowElementMutations) {
4091
4388
  let childrenToPatch;
4092
4389
  if (routeId) {
4093
4390
  let route = manifest[routeId];
@@ -4100,7 +4397,7 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
4100
4397
  }
4101
4398
  childrenToPatch = route.children;
4102
4399
  } else {
4103
- childrenToPatch = routesToUse;
4400
+ childrenToPatch = dataRoutes.activeRoutes;
4104
4401
  }
4105
4402
  let uniqueChildren = [];
4106
4403
  let existingChildren = [];
@@ -4143,6 +4440,9 @@ function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRoutePrope
4143
4440
  });
4144
4441
  }
4145
4442
  }
4443
+ if (!dataRoutes.hasHMRRoutes) {
4444
+ dataRoutes.setRoutes([...dataRoutes.activeRoutes]);
4445
+ }
4146
4446
  }
4147
4447
  function isSameRoute(newRoute, existingRoute) {
4148
4448
  var _a;
@@ -4376,17 +4676,12 @@ function runClientMiddlewarePipeline(args, handler) {
4376
4676
  }
4377
4677
  }
4378
4678
  async function runMiddlewarePipeline(args, handler, processResult, isResult, errorHandler) {
4379
- let { matches, request, params, context, unstable_pattern } = args;
4679
+ let { matches, ...dataFnArgs } = args;
4380
4680
  let tuples = matches.flatMap(
4381
4681
  (m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
4382
4682
  );
4383
4683
  let result = await callRouteMiddleware(
4384
- {
4385
- request,
4386
- params,
4387
- context,
4388
- unstable_pattern
4389
- },
4684
+ dataFnArgs,
4390
4685
  tuples,
4391
4686
  handler,
4392
4687
  processResult,
@@ -4464,7 +4759,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
4464
4759
  handler: lazyRoutePromises.lazyHandlerPromise
4465
4760
  };
4466
4761
  }
4467
- function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
4762
+ function getDataStrategyMatch(mapRouteProperties2, manifest, request, path, pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
4468
4763
  let isUsingNewApi = false;
4469
4764
  let _lazyPromises = getDataStrategyMatchLazyPromises(
4470
4765
  mapRouteProperties2,
@@ -4504,7 +4799,8 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_p
4504
4799
  if (callHandler && (isMutationMethod(request.method) || !isMiddlewareOnlyRoute)) {
4505
4800
  return callLoaderOrAction({
4506
4801
  request,
4507
- unstable_pattern,
4802
+ path,
4803
+ pattern,
4508
4804
  match,
4509
4805
  lazyHandlerPromise: _lazyPromises == null ? void 0 : _lazyPromises.handler,
4510
4806
  lazyRoutePromise: _lazyPromises == null ? void 0 : _lazyPromises.route,
@@ -4516,7 +4812,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_p
4516
4812
  }
4517
4813
  };
4518
4814
  }
4519
- function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request, matches, targetMatch, lazyRoutePropertiesToSkip, scopedContext, shouldRevalidateArgs = null) {
4815
+ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request, path, matches, targetMatch, lazyRoutePropertiesToSkip, scopedContext, shouldRevalidateArgs = null) {
4520
4816
  return matches.map((match) => {
4521
4817
  if (match.route.id !== targetMatch.route.id) {
4522
4818
  return {
@@ -4538,6 +4834,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
4538
4834
  mapRouteProperties2,
4539
4835
  manifest,
4540
4836
  request,
4837
+ path,
4541
4838
  getRoutePattern(matches),
4542
4839
  match,
4543
4840
  lazyRoutePropertiesToSkip,
@@ -4547,7 +4844,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
4547
4844
  );
4548
4845
  });
4549
4846
  }
4550
- async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherKey, scopedContext, isStaticHandler) {
4847
+ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fetcherKey, scopedContext, isStaticHandler) {
4551
4848
  if (matches.some((m) => {
4552
4849
  var _a;
4553
4850
  return (_a = m._lazyPromises) == null ? void 0 : _a.middleware;
@@ -4559,7 +4856,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
4559
4856
  }
4560
4857
  let dataStrategyArgs = {
4561
4858
  request,
4562
- unstable_pattern: getRoutePattern(matches),
4859
+ url: createDataFunctionUrl(request, path),
4860
+ pattern: getRoutePattern(matches),
4563
4861
  params: matches[0].params,
4564
4862
  context: scopedContext,
4565
4863
  matches
@@ -4599,7 +4897,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
4599
4897
  }
4600
4898
  async function callLoaderOrAction({
4601
4899
  request,
4602
- unstable_pattern,
4900
+ path,
4901
+ pattern,
4603
4902
  match,
4604
4903
  lazyHandlerPromise,
4605
4904
  lazyRoutePromise,
@@ -4626,7 +4925,8 @@ async function callLoaderOrAction({
4626
4925
  return handler(
4627
4926
  {
4628
4927
  request,
4629
- unstable_pattern,
4928
+ url: createDataFunctionUrl(request, path),
4929
+ pattern,
4630
4930
  params: match.params,
4631
4931
  context: scopedContext
4632
4932
  },
@@ -4784,34 +5084,43 @@ function normalizeRelativeRoutingRedirectResponse(response, request, routeId, ma
4784
5084
  }
4785
5085
  return response;
4786
5086
  }
5087
+ var invalidProtocols = [
5088
+ "about:",
5089
+ "blob:",
5090
+ "chrome:",
5091
+ "chrome-untrusted:",
5092
+ "content:",
5093
+ "data:",
5094
+ "devtools:",
5095
+ "file:",
5096
+ "filesystem:",
5097
+ // eslint-disable-next-line no-script-url
5098
+ "javascript:"
5099
+ ];
5100
+ function hasInvalidProtocol(location) {
5101
+ try {
5102
+ return invalidProtocols.includes(new URL(location).protocol);
5103
+ } catch {
5104
+ return false;
5105
+ }
5106
+ }
4787
5107
  function normalizeRedirectLocation(location, currentUrl, basename, historyInstance) {
4788
- let invalidProtocols = [
4789
- "about:",
4790
- "blob:",
4791
- "chrome:",
4792
- "chrome-untrusted:",
4793
- "content:",
4794
- "data:",
4795
- "devtools:",
4796
- "file:",
4797
- "filesystem:",
4798
- // eslint-disable-next-line no-script-url
4799
- "javascript:"
4800
- ];
4801
5108
  if (isAbsoluteUrl(location)) {
4802
5109
  let normalizedLocation = location;
4803
- let url = normalizedLocation.startsWith("//") ? new URL(currentUrl.protocol + normalizedLocation) : new URL(normalizedLocation);
4804
- if (invalidProtocols.includes(url.protocol)) {
5110
+ let url = PROTOCOL_RELATIVE_URL_REGEX.test(normalizedLocation) ? new URL(
5111
+ normalizeProtocolRelativeUrl(normalizedLocation, currentUrl.protocol)
5112
+ ) : new URL(normalizedLocation);
5113
+ if (hasInvalidProtocol(url.toString())) {
4805
5114
  throw new Error("Invalid redirect location");
4806
5115
  }
4807
5116
  let isSameBasename = stripBasename(url.pathname, basename) != null;
4808
5117
  if (url.origin === currentUrl.origin && isSameBasename) {
4809
- return url.pathname + url.search + url.hash;
5118
+ return removeDoubleSlashes(url.pathname) + url.search + url.hash;
4810
5119
  }
4811
5120
  }
4812
5121
  try {
4813
5122
  let url = historyInstance.createURL(location);
4814
- if (invalidProtocols.includes(url.protocol)) {
5123
+ if (hasInvalidProtocol(url.toString())) {
4815
5124
  throw new Error("Invalid redirect location");
4816
5125
  }
4817
5126
  } catch (e) {
@@ -4837,6 +5146,24 @@ function createClientSideRequest(history, location, signal, submission) {
4837
5146
  }
4838
5147
  return new Request(url, init);
4839
5148
  }
5149
+ function createDataFunctionUrl(request, path) {
5150
+ let url = new URL(request.url);
5151
+ let parsed = typeof path === "string" ? parsePath(path) : path;
5152
+ url.pathname = parsed.pathname || "/";
5153
+ if (parsed.search) {
5154
+ let searchParams = new URLSearchParams(parsed.search);
5155
+ let indexValues = searchParams.getAll("index");
5156
+ searchParams.delete("index");
5157
+ for (let value of indexValues.filter(Boolean)) {
5158
+ searchParams.append("index", value);
5159
+ }
5160
+ url.search = searchParams.size ? `?${searchParams.toString()}` : "";
5161
+ } else {
5162
+ url.search = "";
5163
+ }
5164
+ url.hash = parsed.hash || "";
5165
+ return url;
5166
+ }
4840
5167
  function convertFormDataToSearchParams(formData) {
4841
5168
  let searchParams = new URLSearchParams();
4842
5169
  for (let [key, value] of formData.entries()) {
@@ -4916,7 +5243,7 @@ function processRouteLoaderData(matches, results, pendingActionResult, isStaticH
4916
5243
  loaderHeaders
4917
5244
  };
4918
5245
  }
4919
- function processLoaderData(state, matches, results, pendingActionResult, revalidatingFetchers, fetcherResults) {
5246
+ function processLoaderData(state, matches, results, pendingActionResult, revalidatingFetchers, fetcherResults, workingFetchers) {
4920
5247
  let { loaderData, errors } = processRouteLoaderData(
4921
5248
  matches,
4922
5249
  results,
@@ -4937,12 +5264,12 @@ function processLoaderData(state, matches, results, pendingActionResult, revalid
4937
5264
  [boundaryMatch.route.id]: result.error
4938
5265
  };
4939
5266
  }
4940
- state.fetchers.delete(key);
5267
+ workingFetchers.delete(key);
4941
5268
  } else if (isRedirectResult(result)) {
4942
5269
  invariant(false, "Unhandled fetcher revalidation redirect");
4943
5270
  } else {
4944
5271
  let doneFetcher = getDoneFetcher(result.data);
4945
- state.fetchers.set(key, doneFetcher);
5272
+ workingFetchers.set(key, doneFetcher);
4946
5273
  }
4947
5274
  });
4948
5275
  return { loaderData, errors };
@@ -5147,11 +5474,13 @@ function getSubmissionFromNavigation(navigation) {
5147
5474
  };
5148
5475
  }
5149
5476
  }
5150
- function getLoadingNavigation(location, submission) {
5477
+ function getLoadingNavigation(location, matches, historyAction, submission) {
5151
5478
  if (submission) {
5152
5479
  let navigation = {
5153
5480
  state: "loading",
5154
5481
  location,
5482
+ matches,
5483
+ historyAction,
5155
5484
  formMethod: submission.formMethod,
5156
5485
  formAction: submission.formAction,
5157
5486
  formEncType: submission.formEncType,
@@ -5164,6 +5493,8 @@ function getLoadingNavigation(location, submission) {
5164
5493
  let navigation = {
5165
5494
  state: "loading",
5166
5495
  location,
5496
+ matches,
5497
+ historyAction,
5167
5498
  formMethod: void 0,
5168
5499
  formAction: void 0,
5169
5500
  formEncType: void 0,
@@ -5174,10 +5505,12 @@ function getLoadingNavigation(location, submission) {
5174
5505
  return navigation;
5175
5506
  }
5176
5507
  }
5177
- function getSubmittingNavigation(location, submission) {
5508
+ function getSubmittingNavigation(location, matches, historyAction, submission) {
5178
5509
  let navigation = {
5179
5510
  state: "submitting",
5180
5511
  location,
5512
+ matches,
5513
+ historyAction,
5181
5514
  formMethod: submission.formMethod,
5182
5515
  formAction: submission.formAction,
5183
5516
  formEncType: submission.formEncType,
@@ -5438,6 +5771,12 @@ function useNavigateUnstable() {
5438
5771
  if (dataRouterContext == null && basename !== "/") {
5439
5772
  path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
5440
5773
  }
5774
+ validateNavigationTarget(
5775
+ typeof to === "string" ? to : createPath(to),
5776
+ navigator.createHref(path),
5777
+ getNavigatorCurrentUrl(navigator),
5778
+ "reject"
5779
+ );
5441
5780
  (!!options.replace ? navigator.replace : navigator.push)(
5442
5781
  path,
5443
5782
  options.state,
@@ -5465,7 +5804,7 @@ function useOutlet(context) {
5465
5804
  function useParams() {
5466
5805
  let { matches } = reactExports.useContext(RouteContext);
5467
5806
  let routeMatch = matches[matches.length - 1];
5468
- return routeMatch ? routeMatch.params : {};
5807
+ return (routeMatch == null ? void 0 : routeMatch.params) ?? {};
5469
5808
  }
5470
5809
  function useResolvedPath(to, { relative } = {}) {
5471
5810
  let { matches } = reactExports.useContext(RouteContext);
@@ -5517,7 +5856,15 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5517
5856
  let segments = pathname.replace(/^\//, "").split("/");
5518
5857
  remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
5519
5858
  }
5520
- let matches = matchRoutes(routes, { pathname: remainingPathname });
5859
+ let matches = dataRouterOpts && dataRouterOpts.state.matches.length ? (
5860
+ // If we're in a data router, use the matches we've already identified but ensure
5861
+ // we have the latest route instances from the manifest in case elements have changed
5862
+ dataRouterOpts.state.matches.map(
5863
+ (m) => Object.assign(m, {
5864
+ route: dataRouterOpts.manifest[m.route.id] || m.route
5865
+ })
5866
+ )
5867
+ ) : matchRoutes(routes, { pathname: remainingPathname });
5521
5868
  {
5522
5869
  warning(
5523
5870
  parentRoute || matches != null,
@@ -5535,21 +5882,21 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
5535
5882
  pathname: joinPaths([
5536
5883
  parentPathnameBase,
5537
5884
  // Re-encode pathnames that were decoded inside matchRoutes.
5538
- // Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
5885
+ // Pre-encode `%`, `?` and `#` ahead of `encodeLocation` because it uses
5539
5886
  // `new URL()` internally and we need to prevent it from treating
5540
5887
  // them as separators
5541
5888
  navigator.encodeLocation ? navigator.encodeLocation(
5542
- match.pathname.replace(/\?/g, "%3F").replace(/#/g, "%23")
5889
+ match.pathname.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23")
5543
5890
  ).pathname : match.pathname
5544
5891
  ]),
5545
5892
  pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
5546
5893
  parentPathnameBase,
5547
5894
  // Re-encode pathnames that were decoded inside matchRoutes
5548
- // Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
5895
+ // Pre-encode `%`, `?` and `#` ahead of `encodeLocation` because it uses
5549
5896
  // `new URL()` internally and we need to prevent it from treating
5550
5897
  // them as separators
5551
5898
  navigator.encodeLocation ? navigator.encodeLocation(
5552
- match.pathnameBase.replace(/\?/g, "%3F").replace(/#/g, "%23")
5899
+ match.pathnameBase.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23")
5553
5900
  ).pathname : match.pathnameBase
5554
5901
  ])
5555
5902
  })
@@ -5638,16 +5985,26 @@ function RSCErrorHandler({
5638
5985
  children,
5639
5986
  error
5640
5987
  }) {
5641
- let { basename } = reactExports.useContext(NavigationContext);
5988
+ let { basename, navigator } = reactExports.useContext(NavigationContext);
5642
5989
  if (typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
5643
5990
  let redirect2 = decodeRedirectErrorDigest(error.digest);
5644
5991
  if (redirect2) {
5645
5992
  let existingRedirect = errorRedirectHandledMap.get(error);
5646
5993
  if (existingRedirect) throw existingRedirect;
5647
5994
  let parsed = parseToInfo(redirect2.location, basename);
5995
+ let target = parsed.absoluteURL || parsed.to;
5996
+ validateNavigationTarget(
5997
+ redirect2.location,
5998
+ target,
5999
+ getNavigatorCurrentUrl(navigator),
6000
+ "allow-explicit"
6001
+ );
6002
+ if (hasInvalidProtocol(target)) {
6003
+ throw new Error("Invalid redirect location");
6004
+ }
5648
6005
  if (isBrowser && !errorRedirectHandledMap.get(error)) {
5649
6006
  if (parsed.isExternal || redirect2.reloadDocument) {
5650
- window.location.href = parsed.absoluteURL || parsed.to;
6007
+ window.location.href = target;
5651
6008
  } else {
5652
6009
  const redirectPromise = Promise.resolve().then(
5653
6010
  () => window.__reactRouterDataRouter.navigate(parsed.to, {
@@ -5658,13 +6015,7 @@ function RSCErrorHandler({
5658
6015
  throw redirectPromise;
5659
6016
  }
5660
6017
  }
5661
- return /* @__PURE__ */ reactExports.createElement(
5662
- "meta",
5663
- {
5664
- httpEquiv: "refresh",
5665
- content: `0;url=${parsed.absoluteURL || parsed.to}`
5666
- }
5667
- );
6018
+ return /* @__PURE__ */ reactExports.createElement("meta", { httpEquiv: "refresh", content: `0;url=${target}` });
5668
6019
  }
5669
6020
  }
5670
6021
  return children;
@@ -5739,7 +6090,7 @@ function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
5739
6090
  onErrorHandler(error, {
5740
6091
  location: dataRouterState.location,
5741
6092
  params: ((_b = (_a = dataRouterState.matches) == null ? void 0 : _a[0]) == null ? void 0 : _b.params) ?? {},
5742
- unstable_pattern: getRoutePattern(dataRouterState.matches),
6093
+ pattern: getRoutePattern(dataRouterState.matches),
5743
6094
  errorInfo
5744
6095
  });
5745
6096
  } : void 0;
@@ -5848,7 +6199,10 @@ function useNavigation() {
5848
6199
  "useNavigation"
5849
6200
  /* UseNavigation */
5850
6201
  );
5851
- return state.navigation;
6202
+ return reactExports.useMemo(() => {
6203
+ let { matches, historyAction, ...rest } = state.navigation;
6204
+ return rest;
6205
+ }, [state.navigation]);
5852
6206
  }
5853
6207
  function useMatches() {
5854
6208
  let { matches, loaderData } = useDataRouterState(
@@ -6026,10 +6380,10 @@ function RouterProvider({
6026
6380
  router,
6027
6381
  flushSync: reactDomFlushSyncImpl,
6028
6382
  onError,
6029
- unstable_useTransitions
6383
+ useTransitions
6030
6384
  }) {
6031
6385
  let unstable_rsc = useIsRSCRouterContext();
6032
- unstable_useTransitions = unstable_rsc || unstable_useTransitions;
6386
+ useTransitions = unstable_rsc || useTransitions;
6033
6387
  let [_state, setStateImpl] = reactExports.useState(router.state);
6034
6388
  let [state, setOptimisticState] = useOptimisticSafe(_state);
6035
6389
  let [pendingState, setPendingState] = reactExports.useState();
@@ -6049,7 +6403,7 @@ function RouterProvider({
6049
6403
  return onError(error, {
6050
6404
  location: newState.location,
6051
6405
  params: ((_a = newState.matches[0]) == null ? void 0 : _a.params) ?? {},
6052
- unstable_pattern: getRoutePattern(newState.matches)
6406
+ pattern: getRoutePattern(newState.matches)
6053
6407
  });
6054
6408
  }
6055
6409
  );
@@ -6072,11 +6426,11 @@ function RouterProvider({
6072
6426
  if (!viewTransitionOpts || !isViewTransitionAvailable) {
6073
6427
  if (reactDomFlushSyncImpl && flushSync) {
6074
6428
  reactDomFlushSyncImpl(() => setStateImpl(newState));
6075
- } else if (unstable_useTransitions === false) {
6429
+ } else if (useTransitions === false) {
6076
6430
  setStateImpl(newState);
6077
6431
  } else {
6078
6432
  reactExports.startTransition(() => {
6079
- if (unstable_useTransitions === true) {
6433
+ if (useTransitions === true) {
6080
6434
  setOptimisticState((s) => getOptimisticRouterState(s, newState));
6081
6435
  }
6082
6436
  setStateImpl(newState);
@@ -6134,7 +6488,7 @@ function RouterProvider({
6134
6488
  reactDomFlushSyncImpl,
6135
6489
  transition,
6136
6490
  renderDfd,
6137
- unstable_useTransitions,
6491
+ useTransitions,
6138
6492
  setOptimisticState,
6139
6493
  onError
6140
6494
  ]
@@ -6150,11 +6504,11 @@ function RouterProvider({
6150
6504
  let newState = pendingState;
6151
6505
  let renderPromise = renderDfd.promise;
6152
6506
  let transition2 = router.window.document.startViewTransition(async () => {
6153
- if (unstable_useTransitions === false) {
6507
+ if (useTransitions === false) {
6154
6508
  setStateImpl(newState);
6155
6509
  } else {
6156
6510
  reactExports.startTransition(() => {
6157
- if (unstable_useTransitions === true) {
6511
+ if (useTransitions === true) {
6158
6512
  setOptimisticState((s) => getOptimisticRouterState(s, newState));
6159
6513
  }
6160
6514
  setStateImpl(newState);
@@ -6174,7 +6528,7 @@ function RouterProvider({
6174
6528
  pendingState,
6175
6529
  renderDfd,
6176
6530
  router.window,
6177
- unstable_useTransitions,
6531
+ useTransitions,
6178
6532
  setOptimisticState
6179
6533
  ]);
6180
6534
  reactExports.useEffect(() => {
@@ -6197,6 +6551,7 @@ function RouterProvider({
6197
6551
  let navigator = reactExports.useMemo(() => {
6198
6552
  return {
6199
6553
  createHref: router.createHref,
6554
+ createURL: router.createURL,
6200
6555
  encodeLocation: router.encodeLocation,
6201
6556
  go: (n) => router.navigate(n),
6202
6557
  push: (to, state2, opts) => router.navigate(to, {
@@ -6228,12 +6583,13 @@ function RouterProvider({
6228
6583
  location: state.location,
6229
6584
  navigationType: state.historyAction,
6230
6585
  navigator,
6231
- unstable_useTransitions
6586
+ useTransitions
6232
6587
  },
6233
6588
  /* @__PURE__ */ reactExports.createElement(
6234
6589
  MemoizedDataRoutes,
6235
6590
  {
6236
6591
  routes: router.routes,
6592
+ manifest: router.manifest,
6237
6593
  future: router.future,
6238
6594
  state,
6239
6595
  isStatic: false,
@@ -6256,15 +6612,21 @@ function getOptimisticRouterState(currentState, newState) {
6256
6612
  fetchers: newState.fetchers
6257
6613
  };
6258
6614
  }
6259
- var MemoizedDataRoutes = reactExports.memo(DataRoutes);
6260
- function DataRoutes({
6615
+ var MemoizedDataRoutes = reactExports.memo(DataRoutes2);
6616
+ function DataRoutes2({
6261
6617
  routes,
6618
+ manifest,
6262
6619
  future,
6263
6620
  state,
6264
6621
  isStatic,
6265
6622
  onError
6266
6623
  }) {
6267
- return useRoutesImpl(routes, void 0, { state, isStatic, onError });
6624
+ return useRoutesImpl(routes, void 0, {
6625
+ manifest,
6626
+ state,
6627
+ isStatic,
6628
+ onError
6629
+ });
6268
6630
  }
6269
6631
  function Outlet(props) {
6270
6632
  return useOutlet(props.context);
@@ -6276,7 +6638,7 @@ function Router({
6276
6638
  navigationType = "POP",
6277
6639
  navigator,
6278
6640
  static: staticProp = false,
6279
- unstable_useTransitions
6641
+ useTransitions
6280
6642
  }) {
6281
6643
  invariant(
6282
6644
  !useInRouterContext(),
@@ -6288,10 +6650,10 @@ function Router({
6288
6650
  basename,
6289
6651
  navigator,
6290
6652
  static: staticProp,
6291
- unstable_useTransitions,
6653
+ useTransitions,
6292
6654
  future: {}
6293
6655
  }),
6294
- [basename, navigator, staticProp, unstable_useTransitions]
6656
+ [basename, navigator, staticProp, useTransitions]
6295
6657
  );
6296
6658
  if (typeof locationProp === "string") {
6297
6659
  locationProp = parsePath(locationProp);
@@ -6302,7 +6664,7 @@ function Router({
6302
6664
  hash = "",
6303
6665
  state = null,
6304
6666
  key = "default",
6305
- unstable_mask
6667
+ mask
6306
6668
  } = locationProp;
6307
6669
  let locationContext = reactExports.useMemo(() => {
6308
6670
  let trailingPathname = stripBasename(pathname, basename);
@@ -6316,20 +6678,11 @@ function Router({
6316
6678
  hash,
6317
6679
  state,
6318
6680
  key,
6319
- unstable_mask
6681
+ mask
6320
6682
  },
6321
6683
  navigationType
6322
6684
  };
6323
- }, [
6324
- basename,
6325
- pathname,
6326
- search,
6327
- hash,
6328
- state,
6329
- key,
6330
- navigationType,
6331
- unstable_mask
6332
- ]);
6685
+ }, [basename, pathname, search, hash, state, key, navigationType, mask]);
6333
6686
  warning(
6334
6687
  locationContext != null,
6335
6688
  `<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.`
@@ -6683,7 +7036,7 @@ function hydrate(index) {
6683
7036
  continue;
6684
7037
  case TYPE_ERROR:
6685
7038
  const [, message, errorType] = value;
6686
- let error = errorType && globalObj && globalObj[errorType] ? new globalObj[errorType](message) : new Error(message);
7039
+ let error = errorType && globalObj && SUPPORTED_ERROR_TYPES.includes(errorType) && errorType in globalObj && typeof globalObj[errorType] === "function" ? new globalObj[errorType](message) : new Error(message);
6687
7040
  hydrated[index2] = error;
6688
7041
  set(error);
6689
7042
  continue;
@@ -6901,11 +7254,9 @@ function getTurboStreamSingleFetchDataStrategy(getRouter, manifest, routeModules
6901
7254
  (match) => {
6902
7255
  let manifestRoute = manifest.routes[match.route.id];
6903
7256
  invariant2(manifestRoute, "Route not found in manifest");
6904
- let routeModule = routeModules[match.route.id];
6905
7257
  return {
6906
7258
  hasLoader: manifestRoute.hasLoader,
6907
- hasClientLoader: manifestRoute.hasClientLoader,
6908
- hasShouldRevalidate: Boolean(routeModule == null ? void 0 : routeModule.shouldRevalidate)
7259
+ hasClientLoader: manifestRoute.hasClientLoader
6909
7260
  };
6910
7261
  },
6911
7262
  fetchAndDecodeViaTurboStream,
@@ -7025,13 +7376,12 @@ async function singleFetchLoaderNavigationStrategy(args, router, getRouteInfo, f
7025
7376
  async (m, i) => m.resolve(async (handler) => {
7026
7377
  routeDfds[i].resolve();
7027
7378
  let routeId = m.route.id;
7028
- let { hasLoader, hasClientLoader, hasShouldRevalidate } = getRouteInfo(m);
7379
+ let { hasLoader, hasClientLoader } = getRouteInfo(m);
7029
7380
  let defaultShouldRevalidate = !m.shouldRevalidateArgs || m.shouldRevalidateArgs.actionStatus == null || m.shouldRevalidateArgs.actionStatus < 400;
7030
7381
  let shouldCall = m.shouldCallHandler(defaultShouldRevalidate);
7031
7382
  if (!shouldCall) {
7032
7383
  foundOptOutRoute || (foundOptOutRoute = m.shouldRevalidateArgs != null && // This is a revalidation,
7033
- hasLoader && // for a route with a server loader,
7034
- hasShouldRevalidate === true);
7384
+ hasLoader);
7035
7385
  return;
7036
7386
  }
7037
7387
  if (shouldAllowOptOut(m) && hasClientLoader) {
@@ -7173,9 +7523,9 @@ function singleFetchUrl(reqUrl, basename, trailingSlashAware, extension) {
7173
7523
  if (url.pathname === "/") {
7174
7524
  url.pathname = `_root.${extension}`;
7175
7525
  } else if (basename && stripBasename(url.pathname, basename) === "/") {
7176
- url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
7526
+ url.pathname = `${removeTrailingSlash(basename)}/_root.${extension}`;
7177
7527
  } else {
7178
- url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
7528
+ url.pathname = `${removeTrailingSlash(url.pathname)}.${extension}`;
7179
7529
  }
7180
7530
  }
7181
7531
  return url;
@@ -7250,7 +7600,8 @@ function decodeViaTurboStream(body, global) {
7250
7600
  if (type === "SanitizedError") {
7251
7601
  let [name, message, stack] = rest;
7252
7602
  let Constructor = Error;
7253
- if (name && name in global && typeof global[name] === "function") {
7603
+ if (name && SUPPORTED_ERROR_TYPES.includes(name) && name in global && // @ts-expect-error
7604
+ typeof global[name] === "function") {
7254
7605
  Constructor = global[name];
7255
7606
  }
7256
7607
  let error = new Constructor(message);
@@ -7566,9 +7917,11 @@ function isPreloadSupported() {
7566
7917
  return _isPreloadSupported;
7567
7918
  }
7568
7919
  function RemixRootDefaultHydrateFallback() {
7920
+ let { nonce } = useFrameworkContext();
7569
7921
  return /* @__PURE__ */ reactExports.createElement(BoundaryShell, { title: "Loading...", renderScripts: true }, /* @__PURE__ */ reactExports.createElement(
7570
7922
  "script",
7571
7923
  {
7924
+ nonce,
7572
7925
  dangerouslySetInnerHTML: {
7573
7926
  __html: `
7574
7927
  console.log(
@@ -7709,39 +8062,38 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
7709
8062
  let hasInitialError = initialState && initialState.errors && route.id in initialState.errors;
7710
8063
  let initialError = hasInitialError ? (_b = initialState == null ? void 0 : initialState.errors) == null ? void 0 : _b[route.id] : void 0;
7711
8064
  let isHydrationRequest = needsRevalidation == null && (((_c = routeModule.clientLoader) == null ? void 0 : _c.hydrate) === true || !route.hasLoader);
7712
- dataRoute.loader = async ({ request, params, context, unstable_pattern }, singleFetch) => {
7713
- try {
7714
- let result = await prefetchStylesAndCallHandler(async () => {
7715
- invariant2(
7716
- routeModule,
7717
- "No `routeModule` available for critical-route loader"
7718
- );
7719
- if (!routeModule.clientLoader) {
7720
- return fetchServerLoader(singleFetch);
7721
- }
7722
- return routeModule.clientLoader({
7723
- request,
7724
- params,
7725
- context,
7726
- unstable_pattern,
7727
- async serverLoader() {
7728
- preventInvalidServerHandlerCall("loader", route);
7729
- if (isHydrationRequest) {
7730
- if (hasInitialData) {
7731
- return initialData;
7732
- }
7733
- if (hasInitialError) {
7734
- throw initialError;
7735
- }
8065
+ dataRoute.loader = async ({ request, params, context, pattern, url }, singleFetch) => {
8066
+ let _isHydrationRequest = isHydrationRequest;
8067
+ isHydrationRequest = false;
8068
+ let result = await prefetchStylesAndCallHandler(async () => {
8069
+ invariant2(
8070
+ routeModule,
8071
+ "No `routeModule` available for critical-route loader"
8072
+ );
8073
+ if (!routeModule.clientLoader) {
8074
+ return fetchServerLoader(singleFetch);
8075
+ }
8076
+ return routeModule.clientLoader({
8077
+ request,
8078
+ params,
8079
+ context,
8080
+ pattern,
8081
+ url,
8082
+ async serverLoader() {
8083
+ preventInvalidServerHandlerCall("loader", route);
8084
+ if (_isHydrationRequest) {
8085
+ if (hasInitialData) {
8086
+ return initialData;
8087
+ }
8088
+ if (hasInitialError) {
8089
+ throw initialError;
7736
8090
  }
7737
- return fetchServerLoader(singleFetch);
7738
8091
  }
7739
- });
8092
+ return fetchServerLoader(singleFetch);
8093
+ }
7740
8094
  });
7741
- return result;
7742
- } finally {
7743
- isHydrationRequest = false;
7744
- }
8095
+ });
8096
+ return result;
7745
8097
  };
7746
8098
  dataRoute.loader.hydrate = shouldHydrateRouteLoader(
7747
8099
  route.id,
@@ -7749,7 +8101,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
7749
8101
  route.hasLoader,
7750
8102
  isSpaMode
7751
8103
  );
7752
- dataRoute.action = ({ request, params, context, unstable_pattern }, singleFetch) => {
8104
+ dataRoute.action = ({ request, params, context, pattern, url }, singleFetch) => {
7753
8105
  return prefetchStylesAndCallHandler(async () => {
7754
8106
  invariant2(
7755
8107
  routeModule,
@@ -7765,7 +8117,8 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
7765
8117
  request,
7766
8118
  params,
7767
8119
  context,
7768
- unstable_pattern,
8120
+ pattern,
8121
+ url,
7769
8122
  async serverAction() {
7770
8123
  preventInvalidServerHandlerCall("action", route);
7771
8124
  return fetchServerAction(singleFetch);
@@ -7945,6 +8298,21 @@ var nextPaths = /* @__PURE__ */ new Set();
7945
8298
  var discoveredPathsMaxSize = 1e3;
7946
8299
  var discoveredPaths = /* @__PURE__ */ new Set();
7947
8300
  var URL_LIMIT = 7680;
8301
+ function getPathsWithAncestors(paths) {
8302
+ let result = /* @__PURE__ */ new Set();
8303
+ paths.forEach((path) => {
8304
+ if (!path.startsWith("/")) {
8305
+ path = `/${path}`;
8306
+ }
8307
+ for (let i = 1; i < path.length; i++) {
8308
+ if (path[i] === "/") {
8309
+ result.add(path.slice(0, i));
8310
+ }
8311
+ }
8312
+ result.add(path);
8313
+ });
8314
+ return Array.from(result);
8315
+ }
7948
8316
  function isFogOfWarEnabled(routeDiscovery, ssr) {
7949
8317
  return routeDiscovery.mode === "lazy" && ssr === true;
7950
8318
  }
@@ -7958,7 +8326,13 @@ function getPartialManifest({ sri, ...manifest }, router) {
7958
8326
  segments.pop();
7959
8327
  }
7960
8328
  paths.forEach((path) => {
7961
- let matches = matchRoutes(router.routes, path, router.basename);
8329
+ let matches = matchRoutesImpl(
8330
+ router.routes,
8331
+ path,
8332
+ router.basename || "/",
8333
+ false,
8334
+ router.branches
8335
+ );
7962
8336
  if (matches) {
7963
8337
  matches.forEach((m) => routeIds.add(m.route.id));
7964
8338
  }
@@ -8057,13 +8431,11 @@ function useFogOFWarDiscovery(router, manifest, routeModules, ssr, routeDiscover
8057
8431
  }
8058
8432
  function getManifestPath(_manifestPath, basename) {
8059
8433
  let manifestPath = _manifestPath || "/__manifest";
8060
- if (basename == null) {
8061
- return manifestPath;
8062
- }
8063
- return `${basename}${manifestPath}`.replace(/\/+/g, "/");
8434
+ return basename == null ? manifestPath : joinPaths([basename, manifestPath]);
8064
8435
  }
8065
8436
  var MANIFEST_VERSION_STORAGE_KEY = "react-router-manifest-version";
8066
8437
  async function fetchAndApplyManifestPatches(paths, errorReloadPath, manifest, routeModules, ssr, isSpaMode, basename, manifestPath, patchRoutes, signal) {
8438
+ paths = getPathsWithAncestors(paths);
8067
8439
  const searchParams = new URLSearchParams();
8068
8440
  searchParams.set("paths", paths.sort().join(","));
8069
8441
  searchParams.set("version", manifest.version);
@@ -8254,13 +8626,22 @@ function getActiveMatches(matches, errors, isSpaMode) {
8254
8626
  }
8255
8627
  var CRITICAL_CSS_DATA_ATTRIBUTE = "data-react-router-critical-css";
8256
8628
  function Links({ nonce, crossOrigin }) {
8257
- let { isSpaMode, manifest, routeModules, criticalCss } = useFrameworkContext();
8629
+ let {
8630
+ isSpaMode,
8631
+ manifest,
8632
+ routeModules,
8633
+ criticalCss,
8634
+ nonce: contextNonce
8635
+ } = useFrameworkContext();
8258
8636
  let { errors, matches: routerMatches } = useDataRouterStateContext();
8259
8637
  let matches = getActiveMatches(routerMatches, errors, isSpaMode);
8260
8638
  let keyedLinks = reactExports.useMemo(
8261
8639
  () => getKeyedLinksForMatches(matches, routeModules, manifest),
8262
8640
  [matches, routeModules, manifest]
8263
8641
  );
8642
+ if (nonce == null && contextNonce) {
8643
+ nonce = contextNonce;
8644
+ }
8264
8645
  return /* @__PURE__ */ reactExports.createElement(reactExports.Fragment, null, typeof criticalCss === "string" ? /* @__PURE__ */ reactExports.createElement(
8265
8646
  "style",
8266
8647
  {
@@ -8298,6 +8679,8 @@ function Links({ nonce, crossOrigin }) {
8298
8679
  ));
8299
8680
  }
8300
8681
  function PrefetchPageLinks({ page, ...linkProps }) {
8682
+ let rsc = useIsRSCRouterContext();
8683
+ let { nonce: contextNonce } = useFrameworkContext();
8301
8684
  let { router } = useDataRouterContext2();
8302
8685
  let matches = reactExports.useMemo(
8303
8686
  () => matchRoutes(router.routes, page, router.basename),
@@ -8306,6 +8689,12 @@ function PrefetchPageLinks({ page, ...linkProps }) {
8306
8689
  if (!matches) {
8307
8690
  return null;
8308
8691
  }
8692
+ if (linkProps.nonce == null && contextNonce) {
8693
+ linkProps = { ...linkProps, nonce: contextNonce };
8694
+ }
8695
+ if (rsc) {
8696
+ return /* @__PURE__ */ reactExports.createElement(RSCPrefetchPageLinksImpl, { page, matches, ...linkProps });
8697
+ }
8309
8698
  return /* @__PURE__ */ reactExports.createElement(PrefetchPageLinksImpl, { page, matches, ...linkProps });
8310
8699
  }
8311
8700
  function useKeyedPrefetchLinks(matches) {
@@ -8326,6 +8715,46 @@ function useKeyedPrefetchLinks(matches) {
8326
8715
  }, [matches, manifest, routeModules]);
8327
8716
  return keyedPrefetchLinks;
8328
8717
  }
8718
+ function RSCPrefetchPageLinksImpl({
8719
+ page,
8720
+ matches: nextMatches,
8721
+ ...linkProps
8722
+ }) {
8723
+ let location = useLocation();
8724
+ let { future } = useFrameworkContext();
8725
+ let { basename } = useDataRouterContext2();
8726
+ let dataHrefs = reactExports.useMemo(() => {
8727
+ if (page === location.pathname + location.search + location.hash) {
8728
+ return [];
8729
+ }
8730
+ let url = singleFetchUrl(
8731
+ page,
8732
+ basename,
8733
+ future.v8_trailingSlashAwareDataRequests,
8734
+ "rsc"
8735
+ );
8736
+ let hasSomeRoutesWithShouldRevalidate = false;
8737
+ let targetRoutes = [];
8738
+ for (let match of nextMatches) {
8739
+ if (typeof match.route.shouldRevalidate === "function") {
8740
+ hasSomeRoutesWithShouldRevalidate = true;
8741
+ } else {
8742
+ targetRoutes.push(match.route.id);
8743
+ }
8744
+ }
8745
+ if (hasSomeRoutesWithShouldRevalidate && targetRoutes.length > 0) {
8746
+ url.searchParams.set("_routes", targetRoutes.join(","));
8747
+ }
8748
+ return [url.pathname + url.search];
8749
+ }, [
8750
+ basename,
8751
+ future.v8_trailingSlashAwareDataRequests,
8752
+ page,
8753
+ location,
8754
+ nextMatches
8755
+ ]);
8756
+ return /* @__PURE__ */ reactExports.createElement(reactExports.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ reactExports.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })));
8757
+ }
8329
8758
  function PrefetchPageLinksImpl({
8330
8759
  page,
8331
8760
  matches: nextMatches,
@@ -8383,7 +8812,7 @@ function PrefetchPageLinksImpl({
8383
8812
  let url = singleFetchUrl(
8384
8813
  page,
8385
8814
  basename,
8386
- future.unstable_trailingSlashAwareDataRequests,
8815
+ future.v8_trailingSlashAwareDataRequests,
8387
8816
  "data"
8388
8817
  );
8389
8818
  if (foundOptOutRoute && routesParams.size > 0) {
@@ -8395,7 +8824,7 @@ function PrefetchPageLinksImpl({
8395
8824
  return [url.pathname + url.search];
8396
8825
  }, [
8397
8826
  basename,
8398
- future.unstable_trailingSlashAwareDataRequests,
8827
+ future.v8_trailingSlashAwareDataRequests,
8399
8828
  loaderData,
8400
8829
  location,
8401
8830
  manifest,
@@ -8516,7 +8945,7 @@ function Meta() {
8516
8945
  dangerouslySetInnerHTML: { __html: escapeHtml(json) }
8517
8946
  }
8518
8947
  );
8519
- } catch (err) {
8948
+ } catch (e) {
8520
8949
  return null;
8521
8950
  }
8522
8951
  }
@@ -8537,12 +8966,16 @@ function Scripts(scriptProps) {
8537
8966
  isSpaMode,
8538
8967
  renderMeta,
8539
8968
  routeDiscovery,
8540
- ssr
8969
+ ssr,
8970
+ nonce: contextNonce
8541
8971
  } = useFrameworkContext();
8542
8972
  let { router, static: isStatic, staticContext } = useDataRouterContext2();
8543
8973
  let { matches: routerMatches } = useDataRouterStateContext();
8544
8974
  let isRSCRouterContext = useIsRSCRouterContext();
8545
8975
  let enableFogOfWar = isFogOfWarEnabled(routeDiscovery, ssr);
8976
+ if (scriptProps.nonce == null && contextNonce) {
8977
+ scriptProps = { ...scriptProps, nonce: contextNonce };
8978
+ }
8546
8979
  if (renderMeta) {
8547
8980
  renderMeta.didRenderScripts = true;
8548
8981
  }
@@ -8633,13 +9066,16 @@ import(${JSON.stringify(manifest.entry.module)});`;
8633
9066
  }
8634
9067
  ));
8635
9068
  }, []);
8636
- let preloads = isHydrated || isRSCRouterContext ? [] : dedupe(
8637
- manifest.entry.imports.concat(
8638
- getModuleLinkHrefs(matches, manifest, {
8639
- includeHydrateFallback: true
8640
- })
9069
+ let preloads = isHydrated || isRSCRouterContext ? [] : [
9070
+ // Dedupe through a Set
9071
+ ...new Set(
9072
+ manifest.entry.imports.concat(
9073
+ getModuleLinkHrefs(matches, manifest, {
9074
+ includeHydrateFallback: true
9075
+ })
9076
+ )
8641
9077
  )
8642
- );
9078
+ ];
8643
9079
  let sri = typeof manifest.sri === "object" ? manifest.sri : {};
8644
9080
  warnOnce(
8645
9081
  !isRSCRouterContext,
@@ -8665,6 +9101,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
8665
9101
  href: manifest.url,
8666
9102
  crossOrigin: scriptProps.crossOrigin,
8667
9103
  integrity: sri[manifest.url],
9104
+ nonce: scriptProps.nonce,
8668
9105
  suppressHydrationWarning: true
8669
9106
  }
8670
9107
  ) : null, /* @__PURE__ */ reactExports.createElement(
@@ -8674,6 +9111,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
8674
9111
  href: manifest.entry.module,
8675
9112
  crossOrigin: scriptProps.crossOrigin,
8676
9113
  integrity: sri[manifest.entry.module],
9114
+ nonce: scriptProps.nonce,
8677
9115
  suppressHydrationWarning: true
8678
9116
  }
8679
9117
  ), preloads.map((path) => /* @__PURE__ */ reactExports.createElement(
@@ -8684,13 +9122,11 @@ import(${JSON.stringify(manifest.entry.module)});`;
8684
9122
  href: path,
8685
9123
  crossOrigin: scriptProps.crossOrigin,
8686
9124
  integrity: sri[path],
9125
+ nonce: scriptProps.nonce,
8687
9126
  suppressHydrationWarning: true
8688
9127
  }
8689
9128
  )), initialScripts);
8690
9129
  }
8691
- function dedupe(array) {
8692
- return [...new Set(array)];
8693
- }
8694
9130
  function mergeRefs(...refs) {
8695
9131
  return (value) => {
8696
9132
  refs.forEach((ref) => {
@@ -8734,10 +9170,12 @@ function RemixRootDefaultErrorBoundary({
8734
9170
  error,
8735
9171
  isOutsideRemixApp
8736
9172
  }) {
9173
+ let { nonce } = useFrameworkContext();
8737
9174
  console.error(error);
8738
9175
  let heyDeveloper = /* @__PURE__ */ reactExports.createElement(
8739
9176
  "script",
8740
9177
  {
9178
+ nonce,
8741
9179
  dangerouslySetInnerHTML: {
8742
9180
  __html: `
8743
9181
  console.log(
@@ -8802,11 +9240,10 @@ var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "un
8802
9240
  try {
8803
9241
  if (isBrowser2) {
8804
9242
  window.__reactRouterVersion = // @ts-expect-error
8805
- "7.13.1";
9243
+ "7.18.4";
8806
9244
  }
8807
9245
  } catch (e) {
8808
9246
  }
8809
- var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
8810
9247
  var Link = reactExports.forwardRef(
8811
9248
  function LinkWithRef({
8812
9249
  onClick,
@@ -8815,27 +9252,27 @@ var Link = reactExports.forwardRef(
8815
9252
  relative,
8816
9253
  reloadDocument,
8817
9254
  replace: replace2,
8818
- unstable_mask,
9255
+ mask,
8819
9256
  state,
8820
9257
  target,
8821
9258
  to,
8822
9259
  preventScrollReset,
8823
9260
  viewTransition,
8824
- unstable_defaultShouldRevalidate,
9261
+ defaultShouldRevalidate,
8825
9262
  ...rest
8826
9263
  }, forwardedRef) {
8827
- let { basename, navigator, unstable_useTransitions } = reactExports.useContext(NavigationContext);
8828
- let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
9264
+ let { basename, navigator, useTransitions } = reactExports.useContext(NavigationContext);
9265
+ let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX.test(to);
8829
9266
  let parsed = parseToInfo(to, basename);
8830
9267
  to = parsed.to;
8831
9268
  let href = useHref(to, { relative });
8832
9269
  let location = useLocation();
8833
9270
  let maskedHref = null;
8834
- if (unstable_mask) {
9271
+ if (mask) {
8835
9272
  let resolved = resolveTo(
8836
- unstable_mask,
9273
+ mask,
8837
9274
  [],
8838
- location.unstable_mask ? location.unstable_mask.pathname : "/",
9275
+ location.mask ? location.mask.pathname : "/",
8839
9276
  true
8840
9277
  );
8841
9278
  if (basename !== "/") {
@@ -8849,14 +9286,14 @@ var Link = reactExports.forwardRef(
8849
9286
  );
8850
9287
  let internalOnClick = useLinkClickHandler(to, {
8851
9288
  replace: replace2,
8852
- unstable_mask,
9289
+ mask,
8853
9290
  state,
8854
9291
  target,
8855
9292
  preventScrollReset,
8856
9293
  relative,
8857
9294
  viewTransition,
8858
- unstable_defaultShouldRevalidate,
8859
- unstable_useTransitions
9295
+ defaultShouldRevalidate,
9296
+ useTransitions
8860
9297
  });
8861
9298
  function handleClick(event) {
8862
9299
  if (onClick) onClick(event);
@@ -8965,14 +9402,14 @@ var Form = reactExports.forwardRef(
8965
9402
  relative,
8966
9403
  preventScrollReset,
8967
9404
  viewTransition,
8968
- unstable_defaultShouldRevalidate,
9405
+ defaultShouldRevalidate,
8969
9406
  ...props
8970
9407
  }, forwardedRef) => {
8971
- let { unstable_useTransitions } = reactExports.useContext(NavigationContext);
9408
+ let { useTransitions } = reactExports.useContext(NavigationContext);
8972
9409
  let submit = useSubmit();
8973
9410
  let formAction = useFormAction(action, { relative });
8974
9411
  let formMethod = method.toLowerCase() === "get" ? "get" : "post";
8975
- let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX2.test(action);
9412
+ let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX.test(action);
8976
9413
  let submitHandler = (event) => {
8977
9414
  onSubmit && onSubmit(event);
8978
9415
  if (event.defaultPrevented) return;
@@ -8988,9 +9425,9 @@ var Form = reactExports.forwardRef(
8988
9425
  relative,
8989
9426
  preventScrollReset,
8990
9427
  viewTransition,
8991
- unstable_defaultShouldRevalidate
9428
+ defaultShouldRevalidate
8992
9429
  });
8993
- if (unstable_useTransitions && navigate !== false) {
9430
+ if (useTransitions && navigate !== false) {
8994
9431
  reactExports.startTransition(() => doSubmit());
8995
9432
  } else {
8996
9433
  doSubmit();
@@ -9054,6 +9491,9 @@ function ScrollRestoration({
9054
9491
  sessionStorage.removeItem(storageKey2);
9055
9492
  }
9056
9493
  }).toString();
9494
+ if (props.nonce == null && (remixContext == null ? void 0 : remixContext.nonce)) {
9495
+ props.nonce = remixContext.nonce;
9496
+ }
9057
9497
  return /* @__PURE__ */ reactExports.createElement(
9058
9498
  "script",
9059
9499
  {
@@ -9084,13 +9524,13 @@ function useDataRouterState2(hookName) {
9084
9524
  function useLinkClickHandler(to, {
9085
9525
  target,
9086
9526
  replace: replaceProp,
9087
- unstable_mask,
9527
+ mask,
9088
9528
  state,
9089
9529
  preventScrollReset,
9090
9530
  relative,
9091
9531
  viewTransition,
9092
- unstable_defaultShouldRevalidate,
9093
- unstable_useTransitions
9532
+ defaultShouldRevalidate,
9533
+ useTransitions
9094
9534
  } = {}) {
9095
9535
  let navigate = useNavigate();
9096
9536
  let location = useLocation();
@@ -9102,14 +9542,14 @@ function useLinkClickHandler(to, {
9102
9542
  let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
9103
9543
  let doNavigate = () => navigate(to, {
9104
9544
  replace: replace2,
9105
- unstable_mask,
9545
+ mask,
9106
9546
  state,
9107
9547
  preventScrollReset,
9108
9548
  relative,
9109
9549
  viewTransition,
9110
- unstable_defaultShouldRevalidate
9550
+ defaultShouldRevalidate
9111
9551
  });
9112
- if (unstable_useTransitions) {
9552
+ if (useTransitions) {
9113
9553
  reactExports.startTransition(() => doNavigate());
9114
9554
  } else {
9115
9555
  doNavigate();
@@ -9121,15 +9561,15 @@ function useLinkClickHandler(to, {
9121
9561
  navigate,
9122
9562
  path,
9123
9563
  replaceProp,
9124
- unstable_mask,
9564
+ mask,
9125
9565
  state,
9126
9566
  target,
9127
9567
  to,
9128
9568
  preventScrollReset,
9129
9569
  relative,
9130
9570
  viewTransition,
9131
- unstable_defaultShouldRevalidate,
9132
- unstable_useTransitions
9571
+ defaultShouldRevalidate,
9572
+ useTransitions
9133
9573
  ]
9134
9574
  );
9135
9575
  }
@@ -9186,7 +9626,7 @@ function useSubmit() {
9186
9626
  if (options.navigate === false) {
9187
9627
  let key = options.fetcherKey || getUniqueFetcherId();
9188
9628
  await routerFetch(key, currentRouteId, options.action || action, {
9189
- unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
9629
+ defaultShouldRevalidate: options.defaultShouldRevalidate,
9190
9630
  preventScrollReset: options.preventScrollReset,
9191
9631
  formData,
9192
9632
  body,
@@ -9196,7 +9636,7 @@ function useSubmit() {
9196
9636
  });
9197
9637
  } else {
9198
9638
  await routerNavigate(options.action || action, {
9199
- unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
9639
+ defaultShouldRevalidate: options.defaultShouldRevalidate,
9200
9640
  preventScrollReset: options.preventScrollReset,
9201
9641
  formData,
9202
9642
  body,
@@ -9392,11 +9832,10 @@ export {
9392
9832
  useNavigate as B,
9393
9833
  useSearchParams as C,
9394
9834
  ReactDOM as D,
9395
- ErrorResponseImpl as E,
9835
+ useLocation as E,
9396
9836
  FrameworkContext as F,
9397
- useLocation as G,
9398
- useParams as H,
9399
- React as I,
9837
+ useParams as G,
9838
+ React as H,
9400
9839
  Links as L,
9401
9840
  Meta as M,
9402
9841
  NO_BODY_STATUS_CODES as N,