@cccsaurora/clue-ui 1.5.0-dev.467 → 1.5.0-dev.471

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 (60) hide show
  1. package/{ActionForm-BT7_k0EL.js → ActionForm-DIAUGhSr.js} +5 -5
  2. package/{AnnotationDetails-Y_WoZhcI.js → AnnotationDetails-DmrYK0Qc.js} +2 -2
  3. package/{AnnotationPreview-cStKX0if.js → AnnotationPreview-DAswA7fu.js} +2 -2
  4. package/{ClueEnrichContext-C7sNEECP.js → ClueEnrichContext-B76X-cLH.js} +17 -21
  5. package/components/AnnotationBody.js +1 -1
  6. package/components/AnnotationDetailPopover.js +3 -3
  7. package/components/AnnotationDetails.js +3 -3
  8. package/components/AnnotationEntry.js +1 -1
  9. package/components/AnnotationPreview.js +2 -2
  10. package/components/ClassificationChip.js +2 -2
  11. package/components/EnrichedCard.js +2 -2
  12. package/components/EnrichedChip.js +4 -4
  13. package/components/EnrichedTypography.js +2 -2
  14. package/components/ErrorBoundary.js +2 -2
  15. package/components/RetryFailedEnrichments.js +1 -1
  16. package/components/SourcePicker.js +1 -1
  17. package/components/actions/ActionForm.js +1 -1
  18. package/components/actions/ExecutePopover.js +2 -2
  19. package/components/actions/ResultModal.js +2 -2
  20. package/components/actions/formats/index.js +1 -1
  21. package/components/display/graph/elements/NodeCard.js +2 -9
  22. package/components/display/icons/Iconified.js +1 -1
  23. package/components/display/markdown/index.js +1813 -665
  24. package/components/enrichment/EnrichPopover.js +1 -1
  25. package/components/fetchers/Fetcher.js +4 -4
  26. package/components/fetchers/FetcherResultView.js +1 -1
  27. package/components/fetchers/StatusChip.js +1 -1
  28. package/components/group/GroupControl.js +1 -1
  29. package/components/stats/QueryStatus.js +1 -1
  30. package/database/index.js +2 -2
  31. package/database/replication.js +2 -2
  32. package/hooks/ClueActionContext.js +2 -2
  33. package/hooks/ClueDatabaseContext.js +1 -1
  34. package/hooks/ClueEnrichContext.js +3 -3
  35. package/hooks/ClueFetcherContext.js +1 -1
  36. package/hooks/ClueGroupContext.js +1 -1
  37. package/hooks/CluePopupContext.js +2 -2
  38. package/hooks/ClueProvider.js +3 -3
  39. package/hooks/ClueUIPluginContext.js +1 -1
  40. package/hooks/selectors.js +2 -2
  41. package/hooks/useActionResult.js +1 -1
  42. package/hooks/useAnnotations.js +2 -2
  43. package/hooks/useClue.js +1 -1
  44. package/hooks/useClueActions.js +1 -1
  45. package/hooks/useClueTypeConfig.js +1 -1
  46. package/hooks/useErrors.js +1 -1
  47. package/hooks/useFetcherResult.js +1 -1
  48. package/{iconify-DJxl6dC-.js → iconify-CYJTToEF.js} +9 -9
  49. package/icons/Action.js +3 -3
  50. package/icons/Assessment.js +2 -2
  51. package/icons/Context.js +2 -2
  52. package/icons/Opinion.js +2 -2
  53. package/{index-hzIDv8Mx.js → index-8lXdRRpV.js} +541 -144
  54. package/{index-DpJxD74E.js → index-CPetQxOc.js} +2002 -882
  55. package/{index-CtFzsHDu.js → index-DT_sunCV.js} +1 -1
  56. package/main.js +5 -5
  57. package/package.json +3 -3
  58. package/plugins/store.js +1 -1
  59. package/{replication-C5IO7X30.js → replication-DDxxY_CX.js} +1 -1
  60. package/{store-DHP48fQB.js → store-C0DRfMxZ.js} +3 -3
@@ -1,14 +1,13 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useTheme, TableCell, TableRow, TableHead, TableContainer, Paper, Table, Box, Alert } from "@mui/material";
3
- import * as React from "react";
3
+ import * as React3 from "react";
4
4
  import { useMemo } from "react";
5
5
  import { useTranslation } from "react-i18next";
6
6
  import ReactMarkdown from "react-markdown";
7
- import "react-dom";
8
7
  import { Prism } from "react-syntax-highlighter";
9
8
  import remarkGfm from "remark-gfm";
10
9
  /**
11
- * @remix-run/router v1.23.2
10
+ * react-router v7.18.4
12
11
  *
13
12
  * Copyright (c) Remix Software Inc.
14
13
  *
@@ -17,26 +16,11 @@ import remarkGfm from "remark-gfm";
17
16
  *
18
17
  * @license MIT
19
18
  */
20
- function _extends$2() {
21
- _extends$2 = Object.assign ? Object.assign.bind() : function(target) {
22
- for (var i = 1; i < arguments.length; i++) {
23
- var source = arguments[i];
24
- for (var key in source) {
25
- if (Object.prototype.hasOwnProperty.call(source, key)) {
26
- target[key] = source[key];
27
- }
28
- }
29
- }
30
- return target;
31
- };
32
- return _extends$2.apply(this, arguments);
33
- }
34
- var Action;
35
- (function(Action2) {
36
- Action2["Pop"] = "POP";
37
- Action2["Push"] = "PUSH";
38
- Action2["Replace"] = "REPLACE";
39
- })(Action || (Action = {}));
19
+ var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i;
20
+ var PROTOCOL_RELATIVE_URL_REGEX = /^[\\/]{2}/;
21
+ function normalizeProtocolRelativeUrl(url, protocol) {
22
+ return protocol + url.replace(/\\/g, "/");
23
+ }
40
24
  function invariant(value, message) {
41
25
  if (value === false || value === null || typeof value === "undefined") {
42
26
  throw new Error(message);
@@ -51,14 +35,15 @@ function warning(cond, message) {
51
35
  }
52
36
  }
53
37
  }
54
- function createPath(_ref) {
55
- let {
56
- pathname = "/",
57
- search: search2 = "",
58
- hash = ""
59
- } = _ref;
60
- if (search2 && search2 !== "?") pathname += search2.charAt(0) === "?" ? search2 : "?" + search2;
61
- if (hash && hash !== "#") pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
38
+ function createPath({
39
+ pathname = "/",
40
+ search: search2 = "",
41
+ hash = ""
42
+ }) {
43
+ if (search2 && search2 !== "?")
44
+ pathname += search2.charAt(0) === "?" ? search2 : "?" + search2;
45
+ if (hash && hash !== "#")
46
+ pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
62
47
  return pathname;
63
48
  }
64
49
  function parsePath(path) {
@@ -66,13 +51,13 @@ function parsePath(path) {
66
51
  if (path) {
67
52
  let hashIndex = path.indexOf("#");
68
53
  if (hashIndex >= 0) {
69
- parsedPath.hash = path.substr(hashIndex);
70
- path = path.substr(0, hashIndex);
54
+ parsedPath.hash = path.substring(hashIndex);
55
+ path = path.substring(0, hashIndex);
71
56
  }
72
57
  let searchIndex = path.indexOf("?");
73
58
  if (searchIndex >= 0) {
74
- parsedPath.search = path.substr(searchIndex);
75
- path = path.substr(0, searchIndex);
59
+ parsedPath.search = path.substring(searchIndex);
60
+ path = path.substring(0, searchIndex);
76
61
  }
77
62
  if (path) {
78
63
  parsedPath.pathname = path;
@@ -80,44 +65,254 @@ function parsePath(path) {
80
65
  }
81
66
  return parsedPath;
82
67
  }
83
- var ResultType;
84
- (function(ResultType2) {
85
- ResultType2["data"] = "data";
86
- ResultType2["deferred"] = "deferred";
87
- ResultType2["redirect"] = "redirect";
88
- ResultType2["error"] = "error";
89
- })(ResultType || (ResultType = {}));
68
+ function matchRoutes(routes, locationArg, basename = "/") {
69
+ return matchRoutesImpl(routes, locationArg, basename, false);
70
+ }
71
+ function matchRoutesImpl(routes, locationArg, basename, allowPartial, precomputedBranches) {
72
+ let location2 = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
73
+ let pathname = stripBasename(location2.pathname || "/", basename);
74
+ if (pathname == null) {
75
+ return null;
76
+ }
77
+ let branches = flattenAndRankRoutes(routes);
78
+ let matches = null;
79
+ let decoded = decodePath(pathname);
80
+ for (let i = 0; matches == null && i < branches.length; ++i) {
81
+ matches = matchRouteBranch(
82
+ branches[i],
83
+ decoded,
84
+ allowPartial
85
+ );
86
+ }
87
+ return matches;
88
+ }
89
+ function flattenAndRankRoutes(routes) {
90
+ let branches = flattenRoutes(routes);
91
+ rankRouteBranches(branches);
92
+ return branches;
93
+ }
94
+ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
95
+ let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
96
+ let meta = {
97
+ relativePath: relativePath === void 0 ? route.path || "" : relativePath,
98
+ caseSensitive: route.caseSensitive === true,
99
+ childrenIndex: index,
100
+ route
101
+ };
102
+ if (meta.relativePath.startsWith("/")) {
103
+ if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
104
+ return;
105
+ }
106
+ invariant(
107
+ meta.relativePath.startsWith(parentPath),
108
+ `Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`
109
+ );
110
+ meta.relativePath = meta.relativePath.slice(parentPath.length);
111
+ }
112
+ let path = joinPaths([parentPath, meta.relativePath]);
113
+ let routesMeta = parentsMeta.concat(meta);
114
+ if (route.children && route.children.length > 0) {
115
+ invariant(
116
+ // Our types know better, but runtime JS may not!
117
+ // @ts-expect-error
118
+ route.index !== true,
119
+ `Index routes must not have child routes. Please remove all child routes from route path "${path}".`
120
+ );
121
+ flattenRoutes(
122
+ route.children,
123
+ branches,
124
+ routesMeta,
125
+ path,
126
+ hasParentOptionalSegments
127
+ );
128
+ }
129
+ if (route.path == null && !route.index) {
130
+ return;
131
+ }
132
+ branches.push({
133
+ path,
134
+ score: computeScore(path, route.index),
135
+ routesMeta: routesMeta.map((meta2, i) => {
136
+ let [matcher, params] = compilePath(
137
+ meta2.relativePath,
138
+ meta2.caseSensitive,
139
+ i === routesMeta.length - 1
140
+ );
141
+ return {
142
+ ...meta2,
143
+ matcher,
144
+ compiledParams: params
145
+ };
146
+ })
147
+ });
148
+ };
149
+ routes.forEach((route, index) => {
150
+ var _a;
151
+ if (route.path === "" || !((_a = route.path) == null ? void 0 : _a.includes("?"))) {
152
+ flattenRoute(route, index);
153
+ } else {
154
+ for (let exploded of explodeOptionalSegments(route.path)) {
155
+ flattenRoute(route, index, true, exploded);
156
+ }
157
+ }
158
+ });
159
+ return branches;
160
+ }
161
+ function explodeOptionalSegments(path) {
162
+ let segments = path.split("/");
163
+ if (segments.length === 0) return [];
164
+ let [first, ...rest] = segments;
165
+ let isOptional = first.endsWith("?");
166
+ let required = first.replace(/\?$/, "");
167
+ if (rest.length === 0) {
168
+ return isOptional ? [required, ""] : [required];
169
+ }
170
+ let restExploded = explodeOptionalSegments(rest.join("/"));
171
+ let result = [];
172
+ result.push(
173
+ ...restExploded.map(
174
+ (subpath) => subpath === "" ? required : [required, subpath].join("/")
175
+ )
176
+ );
177
+ if (isOptional) {
178
+ result.push(...restExploded);
179
+ }
180
+ return result.map(
181
+ (exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded
182
+ );
183
+ }
184
+ function rankRouteBranches(branches) {
185
+ branches.sort(
186
+ (a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(
187
+ a.routesMeta.map((meta) => meta.childrenIndex),
188
+ b.routesMeta.map((meta) => meta.childrenIndex)
189
+ )
190
+ );
191
+ }
192
+ var paramRe = /^:[\w-]+$/;
193
+ var dynamicSegmentValue = 3;
194
+ var indexRouteValue = 2;
195
+ var emptySegmentValue = 1;
196
+ var staticSegmentValue = 10;
197
+ var splatPenalty = -2;
198
+ var isSplat = (s2) => s2 === "*";
199
+ function computeScore(path, index) {
200
+ let segments = path.split("/");
201
+ let initialScore = segments.length;
202
+ if (segments.some(isSplat)) {
203
+ initialScore += splatPenalty;
204
+ }
205
+ if (index) {
206
+ initialScore += indexRouteValue;
207
+ }
208
+ return segments.filter((s2) => !isSplat(s2)).reduce(
209
+ (score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue),
210
+ initialScore
211
+ );
212
+ }
213
+ function compareIndexes(a, b) {
214
+ let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);
215
+ return siblings ? (
216
+ // If two routes are siblings, we should try to match the earlier sibling
217
+ // first. This allows people to have fine-grained control over the matching
218
+ // behavior by simply putting routes with identical paths in the order they
219
+ // want them tried.
220
+ a[a.length - 1] - b[b.length - 1]
221
+ ) : (
222
+ // Otherwise, it doesn't really make sense to rank non-siblings by index,
223
+ // so they sort equally.
224
+ 0
225
+ );
226
+ }
227
+ function matchRouteBranch(branch, pathname, allowPartial = false) {
228
+ let { routesMeta } = branch;
229
+ let matchedParams = {};
230
+ let matchedPathname = "/";
231
+ let matches = [];
232
+ for (let i = 0; i < routesMeta.length; ++i) {
233
+ let meta = routesMeta[i];
234
+ let end = i === routesMeta.length - 1;
235
+ let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
236
+ let pattern = {
237
+ path: meta.relativePath,
238
+ caseSensitive: meta.caseSensitive,
239
+ end
240
+ };
241
+ let match = (
242
+ // Use precomputed matcher if it exists
243
+ meta.matcher && meta.compiledParams ? matchPathImpl(
244
+ pattern,
245
+ remainingPathname,
246
+ meta.matcher,
247
+ meta.compiledParams
248
+ ) : matchPath(pattern, remainingPathname)
249
+ );
250
+ let route = meta.route;
251
+ if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
252
+ match = matchPath(
253
+ {
254
+ path: meta.relativePath,
255
+ caseSensitive: meta.caseSensitive,
256
+ end: false
257
+ },
258
+ remainingPathname
259
+ );
260
+ }
261
+ if (!match) {
262
+ return null;
263
+ }
264
+ Object.assign(matchedParams, match.params);
265
+ matches.push({
266
+ // TODO: Can this as be avoided?
267
+ params: matchedParams,
268
+ pathname: joinPaths([matchedPathname, match.pathname]),
269
+ pathnameBase: normalizePathname(
270
+ joinPaths([matchedPathname, match.pathnameBase])
271
+ ),
272
+ route
273
+ });
274
+ if (match.pathnameBase !== "/") {
275
+ matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
276
+ }
277
+ }
278
+ return matches;
279
+ }
90
280
  function matchPath(pattern, pathname) {
91
281
  if (typeof pattern === "string") {
92
- pattern = {
93
- path: pattern,
94
- caseSensitive: false,
95
- end: true
96
- };
282
+ pattern = { path: pattern, caseSensitive: false, end: true };
97
283
  }
98
- let [matcher, compiledParams] = compilePath(pattern.path, pattern.caseSensitive, pattern.end);
284
+ let [matcher, compiledParams] = compilePath(
285
+ pattern.path,
286
+ pattern.caseSensitive,
287
+ pattern.end
288
+ );
289
+ return matchPathImpl(pattern, pathname, matcher, compiledParams);
290
+ }
291
+ function matchPathImpl(pattern, pathname, matcher, compiledParams) {
99
292
  let match = pathname.match(matcher);
100
293
  if (!match) return null;
101
294
  let matchedPathname = match[0];
102
- let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
295
+ let pathnameBase = removeTrailingSlash(matchedPathname, 1);
103
296
  let captureGroups = match.slice(1);
104
- let params = compiledParams.reduce((memo, _ref, index) => {
105
- let {
106
- paramName,
107
- isOptional
108
- } = _ref;
109
- if (paramName === "*") {
110
- let splatValue = captureGroups[index] || "";
111
- pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
112
- }
113
- const value = captureGroups[index];
114
- if (isOptional && !value) {
115
- memo[paramName] = void 0;
116
- } else {
117
- memo[paramName] = (value || "").replace(/%2F/g, "/");
118
- }
119
- return memo;
120
- }, {});
297
+ let params = compiledParams.reduce(
298
+ (memo2, { paramName, isOptional }, index) => {
299
+ if (paramName === "*") {
300
+ let splatValue = captureGroups[index] || "";
301
+ pathnameBase = removeTrailingSlash(
302
+ matchedPathname.slice(0, matchedPathname.length - splatValue.length),
303
+ 1
304
+ );
305
+ }
306
+ const value = captureGroups[index];
307
+ if (isOptional && !value) {
308
+ memo2[paramName] = void 0;
309
+ } else {
310
+ memo2[paramName] = (value || "").replace(/%2F/g, "/");
311
+ }
312
+ return memo2;
313
+ },
314
+ {}
315
+ );
121
316
  return {
122
317
  params,
123
318
  pathname: matchedPathname,
@@ -125,26 +320,28 @@ function matchPath(pattern, pathname) {
125
320
  pattern
126
321
  };
127
322
  }
128
- function compilePath(path, caseSensitive, end) {
129
- if (caseSensitive === void 0) {
130
- caseSensitive = false;
131
- }
132
- if (end === void 0) {
133
- end = true;
134
- }
135
- warning(path === "*" || !path.endsWith("*") || path.endsWith("/*"), 'Route path "' + path + '" will be treated as if it were ' + ('"' + path.replace(/\*$/, "/*") + '" because the `*` character must ') + "always follow a `/` in the pattern. To get rid of this warning, " + ('please change the route path to "' + path.replace(/\*$/, "/*") + '".'));
323
+ function compilePath(path, caseSensitive = false, end = true) {
324
+ warning(
325
+ path === "*" || !path.endsWith("*") || path.endsWith("/*"),
326
+ `Route path "${path}" will be treated as if it were "${path.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${path.replace(/\*$/, "/*")}".`
327
+ );
136
328
  let params = [];
137
- let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (_, paramName, isOptional) => {
138
- params.push({
139
- paramName,
140
- isOptional: isOptional != null
141
- });
142
- return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
143
- });
329
+ let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(
330
+ /\/:([\w-]+)(\?)?/g,
331
+ (match, paramName, isOptional, index, str) => {
332
+ params.push({ paramName, isOptional: isOptional != null });
333
+ if (isOptional) {
334
+ let nextChar = str.charAt(index + match.length);
335
+ if (nextChar && nextChar !== "/") {
336
+ return "/([^\\/]*)";
337
+ }
338
+ return "(?:/([^\\/]*))?";
339
+ }
340
+ return "/([^\\/]+)";
341
+ }
342
+ ).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
144
343
  if (path.endsWith("*")) {
145
- params.push({
146
- paramName: "*"
147
- });
344
+ params.push({ paramName: "*" });
148
345
  regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
149
346
  } else if (end) {
150
347
  regexpSource += "\\/*$";
@@ -154,6 +351,17 @@ function compilePath(path, caseSensitive, end) {
154
351
  let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
155
352
  return [matcher, params];
156
353
  }
354
+ function decodePath(value) {
355
+ try {
356
+ return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
357
+ } catch (error) {
358
+ warning(
359
+ false,
360
+ `The URL path "${value}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${error}).`
361
+ );
362
+ return value;
363
+ }
364
+ }
157
365
  function stripBasename(pathname, basename) {
158
366
  if (basename === "/") return pathname;
159
367
  if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
@@ -166,12 +374,7 @@ function stripBasename(pathname, basename) {
166
374
  }
167
375
  return pathname.slice(startIndex) || "/";
168
376
  }
169
- const ABSOLUTE_URL_REGEX$1 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
170
- const isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX$1.test(url);
171
- function resolvePath(to, fromPathname) {
172
- if (fromPathname === void 0) {
173
- fromPathname = "/";
174
- }
377
+ function resolvePath(to, fromPathname = "/") {
175
378
  let {
176
379
  pathname: toPathname,
177
380
  search: search2 = "",
@@ -179,19 +382,11 @@ function resolvePath(to, fromPathname) {
179
382
  } = typeof to === "string" ? parsePath(to) : to;
180
383
  let pathname;
181
384
  if (toPathname) {
182
- if (isAbsoluteUrl(toPathname)) {
183
- pathname = toPathname;
385
+ toPathname = removeDoubleSlashes(toPathname);
386
+ if (toPathname.startsWith("/") || toPathname.startsWith("\\")) {
387
+ pathname = resolvePathname(toPathname.substring(1), "/");
184
388
  } else {
185
- if (toPathname.includes("//")) {
186
- let oldPathname = toPathname;
187
- toPathname = toPathname.replace(/\/\/+/g, "/");
188
- warning(false, "Pathnames cannot have embedded double slashes - normalizing " + (oldPathname + " -> " + toPathname));
189
- }
190
- if (toPathname.startsWith("/")) {
191
- pathname = resolvePathname(toPathname.substring(1), "/");
192
- } else {
193
- pathname = resolvePathname(toPathname, fromPathname);
194
- }
389
+ pathname = resolvePathname(toPathname, fromPathname);
195
390
  }
196
391
  } else {
197
392
  pathname = fromPathname;
@@ -203,7 +398,7 @@ function resolvePath(to, fromPathname) {
203
398
  };
204
399
  }
205
400
  function resolvePathname(relativePath, fromPathname) {
206
- let segments = fromPathname.replace(/\/+$/, "").split("/");
401
+ let segments = removeTrailingSlash(fromPathname).split("/");
207
402
  let relativeSegments = relativePath.split("/");
208
403
  relativeSegments.forEach((segment) => {
209
404
  if (segment === "..") {
@@ -215,30 +410,39 @@ function resolvePathname(relativePath, fromPathname) {
215
410
  return segments.length > 1 ? segments.join("/") : "/";
216
411
  }
217
412
  function getInvalidPathError(char, field, dest, path) {
218
- return "Cannot include a '" + char + "' character in a manually specified " + ("`to." + field + "` field [" + JSON.stringify(path) + "]. Please separate it out to the ") + ("`to." + dest + "` field. Alternatively you may provide the full path as ") + 'a string in <Link to="..."> and the router will parse it for you.';
413
+ return `Cannot include a '${char}' character in a manually specified \`to.${field}\` field [${JSON.stringify(
414
+ path
415
+ )}]. Please separate it out to the \`to.${dest}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`;
219
416
  }
220
417
  function getPathContributingMatches(matches) {
221
- return matches.filter((match, index) => index === 0 || match.route.path && match.route.path.length > 0);
418
+ return matches.filter(
419
+ (match, index) => index === 0 || match.route.path && match.route.path.length > 0
420
+ );
222
421
  }
223
- function getResolveToMatches(matches, v7_relativeSplatPath) {
422
+ function getResolveToMatches(matches) {
224
423
  let pathMatches = getPathContributingMatches(matches);
225
- if (v7_relativeSplatPath) {
226
- return pathMatches.map((match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase);
227
- }
228
- return pathMatches.map((match) => match.pathnameBase);
424
+ return pathMatches.map(
425
+ (match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase
426
+ );
229
427
  }
230
- function resolveTo(toArg, routePathnames, locationPathname, isPathRelative) {
231
- if (isPathRelative === void 0) {
232
- isPathRelative = false;
233
- }
428
+ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = false) {
234
429
  let to;
235
430
  if (typeof toArg === "string") {
236
431
  to = parsePath(toArg);
237
432
  } else {
238
- to = _extends$2({}, toArg);
239
- invariant(!to.pathname || !to.pathname.includes("?"), getInvalidPathError("?", "pathname", "search", to));
240
- invariant(!to.pathname || !to.pathname.includes("#"), getInvalidPathError("#", "pathname", "hash", to));
241
- invariant(!to.search || !to.search.includes("#"), getInvalidPathError("#", "search", "hash", to));
433
+ to = { ...toArg };
434
+ invariant(
435
+ !to.pathname || !to.pathname.includes("?"),
436
+ getInvalidPathError("?", "pathname", "search", to)
437
+ );
438
+ invariant(
439
+ !to.pathname || !to.pathname.includes("#"),
440
+ getInvalidPathError("#", "pathname", "hash", to)
441
+ );
442
+ invariant(
443
+ !to.search || !to.search.includes("#"),
444
+ getInvalidPathError("#", "search", "hash", to)
445
+ );
242
446
  }
243
447
  let isEmptyPath = toArg === "" || to.pathname === "";
244
448
  let toPathname = isEmptyPath ? "/" : to.pathname;
@@ -265,310 +469,787 @@ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative) {
265
469
  }
266
470
  return path;
267
471
  }
268
- const joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
269
- const normalizeSearch = (search2) => !search2 || search2 === "?" ? "" : search2.startsWith("?") ? search2 : "?" + search2;
270
- const normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
271
- const validMutationMethodsArr = ["post", "put", "patch", "delete"];
272
- new Set(validMutationMethodsArr);
273
- const validRequestMethodsArr = ["get", ...validMutationMethodsArr];
274
- new Set(validRequestMethodsArr);
275
- /**
276
- * React Router v6.30.3
277
- *
278
- * Copyright (c) Remix Software Inc.
279
- *
280
- * This source code is licensed under the MIT license found in the
281
- * LICENSE.md file in the root directory of this source tree.
282
- *
283
- * @license MIT
284
- */
285
- function _extends$1() {
286
- _extends$1 = Object.assign ? Object.assign.bind() : function(target) {
287
- for (var i = 1; i < arguments.length; i++) {
288
- var source = arguments[i];
289
- for (var key in source) {
290
- if (Object.prototype.hasOwnProperty.call(source, key)) {
291
- target[key] = source[key];
292
- }
472
+ var removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/");
473
+ var joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
474
+ function removeTrailingSlash(path, minLength = 0) {
475
+ let end = path.length;
476
+ while (end > minLength && path.charCodeAt(end - 1) === 47) {
477
+ end--;
478
+ }
479
+ return end === path.length ? path : path.slice(0, end);
480
+ }
481
+ var normalizePathname = (pathname) => removeTrailingSlash(pathname).replace(/^\/*/, "/");
482
+ var normalizeSearch = (search2) => !search2 || search2 === "?" ? "" : search2.startsWith("?") ? search2 : "?" + search2;
483
+ var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
484
+ var ErrorResponseImpl = class {
485
+ constructor(status, statusText, data2, internal = false) {
486
+ this.status = status;
487
+ this.statusText = statusText || "";
488
+ this.internal = internal;
489
+ if (data2 instanceof Error) {
490
+ this.data = data2.toString();
491
+ this.error = data2;
492
+ } else {
493
+ this.data = data2;
494
+ }
495
+ }
496
+ };
497
+ function isRouteErrorResponse(error) {
498
+ return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
499
+ }
500
+ function getRoutePattern(matches) {
501
+ let parts = matches.map((m) => m.route.path).filter(Boolean);
502
+ return joinPaths(parts) || "/";
503
+ }
504
+ var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
505
+ function parseToInfo(_to, basename) {
506
+ let to = _to;
507
+ if (typeof to !== "string" || !ABSOLUTE_URL_REGEX.test(to)) {
508
+ return {
509
+ absoluteURL: void 0,
510
+ isExternal: false,
511
+ to
512
+ };
513
+ }
514
+ let absoluteURL = to;
515
+ let isExternal = false;
516
+ if (isBrowser) {
517
+ try {
518
+ let currentUrl = new URL(window.location.href);
519
+ let targetUrl = PROTOCOL_RELATIVE_URL_REGEX.test(to) ? new URL(normalizeProtocolRelativeUrl(to, currentUrl.protocol)) : new URL(to);
520
+ let path = stripBasename(targetUrl.pathname, basename);
521
+ if (targetUrl.origin === currentUrl.origin && path != null) {
522
+ to = path + targetUrl.search + targetUrl.hash;
523
+ } else {
524
+ isExternal = true;
293
525
  }
526
+ } catch (e) {
527
+ warning(
528
+ false,
529
+ `<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
530
+ );
294
531
  }
295
- return target;
532
+ }
533
+ return {
534
+ absoluteURL,
535
+ isExternal,
536
+ to
296
537
  };
297
- return _extends$1.apply(this, arguments);
298
538
  }
299
- const DataRouterContext = /* @__PURE__ */ React.createContext(null);
300
- if (process.env.NODE_ENV !== "production") {
301
- DataRouterContext.displayName = "DataRouter";
539
+ Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
540
+ var DEFAULT_NAVIGATION_URL = new URL("http://localhost");
541
+ function getNavigatorCurrentUrl(navigator) {
542
+ if (navigator.createURL) {
543
+ return navigator.createURL("/");
544
+ }
545
+ try {
546
+ return new URL(navigator.createHref("/"), DEFAULT_NAVIGATION_URL);
547
+ } catch {
548
+ return DEFAULT_NAVIGATION_URL;
549
+ }
550
+ }
551
+ function isSameOrigin(a, b) {
552
+ return a.origin === b.origin && (a.origin !== "null" || a.protocol === b.protocol && a.host === b.host);
302
553
  }
303
- const DataRouterStateContext = /* @__PURE__ */ React.createContext(null);
304
- if (process.env.NODE_ENV !== "production") {
305
- DataRouterStateContext.displayName = "DataRouterState";
554
+ function isExplicitUrl(destination, target) {
555
+ if (destination.startsWith("//")) {
556
+ return true;
557
+ }
558
+ let protocol = target.protocol.toLowerCase();
559
+ if (!destination.toLowerCase().startsWith(protocol)) {
560
+ return false;
561
+ }
562
+ return target.host === "" || destination.slice(protocol.length).startsWith("//");
306
563
  }
307
- const AwaitContext = /* @__PURE__ */ React.createContext(null);
308
- if (process.env.NODE_ENV !== "production") {
309
- AwaitContext.displayName = "Await";
564
+ function validateNavigationTarget(original, resolved, currentUrl, externalPolicy) {
565
+ let originalUrl = null;
566
+ try {
567
+ originalUrl = original == null ? null : new URL(original, currentUrl);
568
+ } catch {
569
+ }
570
+ let resolvedUrl = new URL(resolved, currentUrl);
571
+ let originalIsExternal = originalUrl != null && !isSameOrigin(originalUrl, currentUrl);
572
+ let resolvedIsExternal = !isSameOrigin(resolvedUrl, currentUrl);
573
+ if (externalPolicy === "reject") {
574
+ if (originalIsExternal || resolvedIsExternal) {
575
+ throw new Error("External navigation is not allowed");
576
+ }
577
+ } else if (resolvedIsExternal) {
578
+ if (originalUrl == null || !isExplicitUrl(original, originalUrl) || !isSameOrigin(originalUrl, resolvedUrl)) {
579
+ throw new Error("External navigation is not allowed");
580
+ }
581
+ }
310
582
  }
311
- const NavigationContext = /* @__PURE__ */ React.createContext(null);
312
- if (process.env.NODE_ENV !== "production") {
313
- NavigationContext.displayName = "Navigation";
583
+ var validMutationMethodsArr = [
584
+ "POST",
585
+ "PUT",
586
+ "PATCH",
587
+ "DELETE"
588
+ ];
589
+ new Set(
590
+ validMutationMethodsArr
591
+ );
592
+ var validRequestMethodsArr = [
593
+ "GET",
594
+ ...validMutationMethodsArr
595
+ ];
596
+ new Set(validRequestMethodsArr);
597
+ var invalidProtocols = [
598
+ "about:",
599
+ "blob:",
600
+ "chrome:",
601
+ "chrome-untrusted:",
602
+ "content:",
603
+ "data:",
604
+ "devtools:",
605
+ "file:",
606
+ "filesystem:",
607
+ // eslint-disable-next-line no-script-url
608
+ "javascript:"
609
+ ];
610
+ function hasInvalidProtocol(location2) {
611
+ try {
612
+ return invalidProtocols.includes(new URL(location2).protocol);
613
+ } catch {
614
+ return false;
615
+ }
314
616
  }
315
- const LocationContext = /* @__PURE__ */ React.createContext(null);
316
- if (process.env.NODE_ENV !== "production") {
317
- LocationContext.displayName = "Location";
617
+ var DataRouterContext = React3.createContext(null);
618
+ DataRouterContext.displayName = "DataRouter";
619
+ var DataRouterStateContext = React3.createContext(null);
620
+ DataRouterStateContext.displayName = "DataRouterState";
621
+ var RSCRouterContext = React3.createContext(false);
622
+ function useIsRSCRouterContext() {
623
+ return React3.useContext(RSCRouterContext);
318
624
  }
319
- const RouteContext = /* @__PURE__ */ React.createContext({
625
+ var ViewTransitionContext = React3.createContext({
626
+ isTransitioning: false
627
+ });
628
+ ViewTransitionContext.displayName = "ViewTransition";
629
+ var FetchersContext = React3.createContext(
630
+ /* @__PURE__ */ new Map()
631
+ );
632
+ FetchersContext.displayName = "Fetchers";
633
+ var AwaitContext = React3.createContext(null);
634
+ AwaitContext.displayName = "Await";
635
+ var NavigationContext = React3.createContext(
636
+ null
637
+ );
638
+ NavigationContext.displayName = "Navigation";
639
+ var LocationContext = React3.createContext(
640
+ null
641
+ );
642
+ LocationContext.displayName = "Location";
643
+ var RouteContext = React3.createContext({
320
644
  outlet: null,
321
645
  matches: [],
322
646
  isDataRoute: false
323
647
  });
324
- if (process.env.NODE_ENV !== "production") {
325
- RouteContext.displayName = "Route";
648
+ RouteContext.displayName = "Route";
649
+ var RouteErrorContext = React3.createContext(null);
650
+ RouteErrorContext.displayName = "RouteError";
651
+ var ERROR_DIGEST_BASE = "REACT_ROUTER_ERROR";
652
+ var ERROR_DIGEST_REDIRECT = "REDIRECT";
653
+ var ERROR_DIGEST_ROUTE_ERROR_RESPONSE = "ROUTE_ERROR_RESPONSE";
654
+ function decodeRedirectErrorDigest(digest) {
655
+ if (digest.startsWith(`${ERROR_DIGEST_BASE}:${ERROR_DIGEST_REDIRECT}:{`)) {
656
+ try {
657
+ let parsed = JSON.parse(digest.slice(28));
658
+ if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string" && typeof parsed.location === "string" && typeof parsed.reloadDocument === "boolean" && typeof parsed.replace === "boolean") {
659
+ return parsed;
660
+ }
661
+ } catch {
662
+ }
663
+ }
326
664
  }
327
- const RouteErrorContext = /* @__PURE__ */ React.createContext(null);
328
- if (process.env.NODE_ENV !== "production") {
329
- RouteErrorContext.displayName = "RouteError";
665
+ function decodeRouteErrorResponseDigest(digest) {
666
+ if (digest.startsWith(
667
+ `${ERROR_DIGEST_BASE}:${ERROR_DIGEST_ROUTE_ERROR_RESPONSE}:{`
668
+ )) {
669
+ try {
670
+ let parsed = JSON.parse(digest.slice(40));
671
+ if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string") {
672
+ return new ErrorResponseImpl(
673
+ parsed.status,
674
+ parsed.statusText,
675
+ parsed.data
676
+ );
677
+ }
678
+ } catch {
679
+ }
680
+ }
330
681
  }
331
- function useHref(to, _temp) {
332
- let {
333
- relative
334
- } = _temp === void 0 ? {} : _temp;
335
- !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
336
- false,
682
+ function useHref(to, { relative } = {}) {
683
+ invariant(
684
+ useInRouterContext(),
337
685
  // TODO: This error is probably because they somehow have 2 versions of the
338
686
  // router loaded. We can help them understand how to avoid that.
339
- "useHref() may be used only in the context of a <Router> component."
340
- ) : invariant(false) : void 0;
341
- let {
342
- basename,
343
- navigator
344
- } = React.useContext(NavigationContext);
345
- let {
346
- hash,
347
- pathname,
348
- search: search2
349
- } = useResolvedPath(to, {
350
- relative
351
- });
687
+ `useHref() may be used only in the context of a <Router> component.`
688
+ );
689
+ let { basename, navigator } = React3.useContext(NavigationContext);
690
+ let { hash, pathname, search: search2 } = useResolvedPath(to, { relative });
352
691
  let joinedPathname = pathname;
353
692
  if (basename !== "/") {
354
693
  joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
355
694
  }
356
- return navigator.createHref({
357
- pathname: joinedPathname,
358
- search: search2,
359
- hash
360
- });
695
+ return navigator.createHref({ pathname: joinedPathname, search: search2, hash });
361
696
  }
362
697
  function useInRouterContext() {
363
- return React.useContext(LocationContext) != null;
698
+ return React3.useContext(LocationContext) != null;
364
699
  }
365
700
  function useLocation() {
366
- !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
367
- false,
701
+ invariant(
702
+ useInRouterContext(),
368
703
  // TODO: This error is probably because they somehow have 2 versions of the
369
704
  // router loaded. We can help them understand how to avoid that.
370
- "useLocation() may be used only in the context of a <Router> component."
371
- ) : invariant(false) : void 0;
372
- return React.useContext(LocationContext).location;
705
+ `useLocation() may be used only in the context of a <Router> component.`
706
+ );
707
+ return React3.useContext(LocationContext).location;
373
708
  }
374
- const navigateEffectWarning = "You should call navigate() in a React.useEffect(), not when your component is first rendered.";
709
+ var navigateEffectWarning = `You should call navigate() in a React.useEffect(), not when your component is first rendered.`;
375
710
  function useIsomorphicLayoutEffect(cb) {
376
- let isStatic = React.useContext(NavigationContext).static;
711
+ let isStatic = React3.useContext(NavigationContext).static;
377
712
  if (!isStatic) {
378
- React.useLayoutEffect(cb);
713
+ React3.useLayoutEffect(cb);
379
714
  }
380
715
  }
381
716
  function useNavigate() {
382
- let {
383
- isDataRoute
384
- } = React.useContext(RouteContext);
717
+ let { isDataRoute } = React3.useContext(RouteContext);
385
718
  return isDataRoute ? useNavigateStable() : useNavigateUnstable();
386
719
  }
387
720
  function useNavigateUnstable() {
388
- !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
389
- false,
721
+ invariant(
722
+ useInRouterContext(),
390
723
  // TODO: This error is probably because they somehow have 2 versions of the
391
724
  // router loaded. We can help them understand how to avoid that.
392
- "useNavigate() may be used only in the context of a <Router> component."
393
- ) : invariant(false) : void 0;
394
- let dataRouterContext = React.useContext(DataRouterContext);
395
- let {
396
- basename,
397
- future,
398
- navigator
399
- } = React.useContext(NavigationContext);
400
- let {
401
- matches
402
- } = React.useContext(RouteContext);
403
- let {
404
- pathname: locationPathname
405
- } = useLocation();
406
- let routePathnamesJson = JSON.stringify(getResolveToMatches(matches, future.v7_relativeSplatPath));
407
- let activeRef = React.useRef(false);
725
+ `useNavigate() may be used only in the context of a <Router> component.`
726
+ );
727
+ let dataRouterContext = React3.useContext(DataRouterContext);
728
+ let { basename, navigator } = React3.useContext(NavigationContext);
729
+ let { matches } = React3.useContext(RouteContext);
730
+ let { pathname: locationPathname } = useLocation();
731
+ let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
732
+ let activeRef = React3.useRef(false);
408
733
  useIsomorphicLayoutEffect(() => {
409
734
  activeRef.current = true;
410
735
  });
411
- let navigate = React.useCallback(function(to, options) {
412
- if (options === void 0) {
413
- options = {};
414
- }
415
- process.env.NODE_ENV !== "production" ? warning(activeRef.current, navigateEffectWarning) : void 0;
416
- if (!activeRef.current) return;
417
- if (typeof to === "number") {
418
- navigator.go(to);
419
- return;
420
- }
421
- let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path");
422
- if (dataRouterContext == null && basename !== "/") {
423
- path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
424
- }
425
- (!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
426
- }, [basename, navigator, routePathnamesJson, locationPathname, dataRouterContext]);
736
+ let navigate = React3.useCallback(
737
+ (to, options = {}) => {
738
+ warning(activeRef.current, navigateEffectWarning);
739
+ if (!activeRef.current) return;
740
+ if (typeof to === "number") {
741
+ navigator.go(to);
742
+ return;
743
+ }
744
+ let path = resolveTo(
745
+ to,
746
+ JSON.parse(routePathnamesJson),
747
+ locationPathname,
748
+ options.relative === "path"
749
+ );
750
+ if (dataRouterContext == null && basename !== "/") {
751
+ path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
752
+ }
753
+ validateNavigationTarget(
754
+ typeof to === "string" ? to : createPath(to),
755
+ navigator.createHref(path),
756
+ getNavigatorCurrentUrl(navigator),
757
+ "reject"
758
+ );
759
+ (!!options.replace ? navigator.replace : navigator.push)(
760
+ path,
761
+ options.state,
762
+ options
763
+ );
764
+ },
765
+ [
766
+ basename,
767
+ navigator,
768
+ routePathnamesJson,
769
+ locationPathname,
770
+ dataRouterContext
771
+ ]
772
+ );
427
773
  return navigate;
428
774
  }
429
- function useResolvedPath(to, _temp2) {
430
- let {
431
- relative
432
- } = _temp2 === void 0 ? {} : _temp2;
433
- let {
434
- future
435
- } = React.useContext(NavigationContext);
436
- let {
437
- matches
438
- } = React.useContext(RouteContext);
439
- let {
440
- pathname: locationPathname
441
- } = useLocation();
442
- let routePathnamesJson = JSON.stringify(getResolveToMatches(matches, future.v7_relativeSplatPath));
443
- return React.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
444
- }
445
- var DataRouterHook$1 = /* @__PURE__ */ (function(DataRouterHook2) {
446
- DataRouterHook2["UseBlocker"] = "useBlocker";
447
- DataRouterHook2["UseRevalidator"] = "useRevalidator";
448
- DataRouterHook2["UseNavigateStable"] = "useNavigate";
449
- return DataRouterHook2;
450
- })(DataRouterHook$1 || {});
451
- var DataRouterStateHook$1 = /* @__PURE__ */ (function(DataRouterStateHook2) {
452
- DataRouterStateHook2["UseBlocker"] = "useBlocker";
453
- DataRouterStateHook2["UseLoaderData"] = "useLoaderData";
454
- DataRouterStateHook2["UseActionData"] = "useActionData";
455
- DataRouterStateHook2["UseRouteError"] = "useRouteError";
456
- DataRouterStateHook2["UseNavigation"] = "useNavigation";
457
- DataRouterStateHook2["UseRouteLoaderData"] = "useRouteLoaderData";
458
- DataRouterStateHook2["UseMatches"] = "useMatches";
459
- DataRouterStateHook2["UseRevalidator"] = "useRevalidator";
460
- DataRouterStateHook2["UseNavigateStable"] = "useNavigate";
461
- DataRouterStateHook2["UseRouteId"] = "useRouteId";
462
- return DataRouterStateHook2;
463
- })(DataRouterStateHook$1 || {});
464
- function getDataRouterConsoleError$1(hookName) {
465
- return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router.";
466
- }
467
- function useDataRouterContext$1(hookName) {
468
- let ctx = React.useContext(DataRouterContext);
469
- !ctx ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError$1(hookName)) : invariant(false) : void 0;
470
- return ctx;
471
- }
472
- function useRouteContext(hookName) {
473
- let route = React.useContext(RouteContext);
474
- !route ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError$1(hookName)) : invariant(false) : void 0;
475
- return route;
476
- }
477
- function useCurrentRouteId(hookName) {
478
- let route = useRouteContext(hookName);
479
- let thisRoute = route.matches[route.matches.length - 1];
480
- !thisRoute.route.id ? process.env.NODE_ENV !== "production" ? invariant(false, hookName + ' can only be used on routes that contain a unique "id"') : invariant(false) : void 0;
481
- return thisRoute.route.id;
482
- }
483
- function useRouteId() {
484
- return useCurrentRouteId(DataRouterStateHook$1.UseRouteId);
775
+ React3.createContext(null);
776
+ function useResolvedPath(to, { relative } = {}) {
777
+ let { matches } = React3.useContext(RouteContext);
778
+ let { pathname: locationPathname } = useLocation();
779
+ let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
780
+ return React3.useMemo(
781
+ () => resolveTo(
782
+ to,
783
+ JSON.parse(routePathnamesJson),
784
+ locationPathname,
785
+ relative === "path"
786
+ ),
787
+ [to, routePathnamesJson, locationPathname, relative]
788
+ );
485
789
  }
486
- function useNavigateStable() {
487
- let {
488
- router
489
- } = useDataRouterContext$1(DataRouterHook$1.UseNavigateStable);
490
- let id = useCurrentRouteId(DataRouterStateHook$1.UseNavigateStable);
491
- let activeRef = React.useRef(false);
492
- useIsomorphicLayoutEffect(() => {
493
- activeRef.current = true;
494
- });
495
- let navigate = React.useCallback(function(to, options) {
496
- if (options === void 0) {
497
- options = {};
498
- }
499
- process.env.NODE_ENV !== "production" ? warning(activeRef.current, navigateEffectWarning) : void 0;
500
- if (!activeRef.current) return;
501
- if (typeof to === "number") {
502
- router.navigate(to);
790
+ function useRoutesImpl(routes, locationArg, dataRouterOpts) {
791
+ invariant(
792
+ useInRouterContext(),
793
+ // TODO: This error is probably because they somehow have 2 versions of the
794
+ // router loaded. We can help them understand how to avoid that.
795
+ `useRoutes() may be used only in the context of a <Router> component.`
796
+ );
797
+ let { navigator } = React3.useContext(NavigationContext);
798
+ let { matches: parentMatches } = React3.useContext(RouteContext);
799
+ let routeMatch = parentMatches[parentMatches.length - 1];
800
+ let parentParams = routeMatch ? routeMatch.params : {};
801
+ let parentPathname = routeMatch ? routeMatch.pathname : "/";
802
+ let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
803
+ let parentRoute = routeMatch && routeMatch.route;
804
+ {
805
+ let parentPath = parentRoute && parentRoute.path || "";
806
+ warningOnce(
807
+ parentPathname,
808
+ !parentRoute || parentPath.endsWith("*") || parentPath.endsWith("*?"),
809
+ `You rendered descendant <Routes> (or called \`useRoutes()\`) at "${parentPathname}" (under <Route path="${parentPath}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
810
+
811
+ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPath === "/" ? "*" : `${parentPath}/*`}">.`
812
+ );
813
+ }
814
+ let locationFromContext = useLocation();
815
+ let location2;
816
+ {
817
+ location2 = locationFromContext;
818
+ }
819
+ let pathname = location2.pathname || "/";
820
+ let remainingPathname = pathname;
821
+ if (parentPathnameBase !== "/") {
822
+ let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
823
+ let segments = pathname.replace(/^\//, "").split("/");
824
+ remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
825
+ }
826
+ let matches = dataRouterOpts && dataRouterOpts.state.matches.length ? (
827
+ // If we're in a data router, use the matches we've already identified but ensure
828
+ // we have the latest route instances from the manifest in case elements have changed
829
+ dataRouterOpts.state.matches.map(
830
+ (m) => Object.assign(m, {
831
+ route: dataRouterOpts.manifest[m.route.id] || m.route
832
+ })
833
+ )
834
+ ) : matchRoutes(routes, { pathname: remainingPathname });
835
+ {
836
+ warning(
837
+ parentRoute || matches != null,
838
+ `No routes matched location "${location2.pathname}${location2.search}${location2.hash}" `
839
+ );
840
+ warning(
841
+ matches == null || matches[matches.length - 1].route.element !== void 0 || matches[matches.length - 1].route.Component !== void 0 || matches[matches.length - 1].route.lazy !== void 0,
842
+ `Matched leaf route at location "${location2.pathname}${location2.search}${location2.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`
843
+ );
844
+ }
845
+ let renderedMatches = _renderMatches(
846
+ matches && matches.map(
847
+ (match) => Object.assign({}, match, {
848
+ params: Object.assign({}, parentParams, match.params),
849
+ pathname: joinPaths([
850
+ parentPathnameBase,
851
+ // Re-encode pathnames that were decoded inside matchRoutes.
852
+ // Pre-encode `%`, `?` and `#` ahead of `encodeLocation` because it uses
853
+ // `new URL()` internally and we need to prevent it from treating
854
+ // them as separators
855
+ navigator.encodeLocation ? navigator.encodeLocation(
856
+ match.pathname.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23")
857
+ ).pathname : match.pathname
858
+ ]),
859
+ pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
860
+ parentPathnameBase,
861
+ // Re-encode pathnames that were decoded inside matchRoutes
862
+ // Pre-encode `%`, `?` and `#` ahead of `encodeLocation` because it uses
863
+ // `new URL()` internally and we need to prevent it from treating
864
+ // them as separators
865
+ navigator.encodeLocation ? navigator.encodeLocation(
866
+ match.pathnameBase.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23")
867
+ ).pathname : match.pathnameBase
868
+ ])
869
+ })
870
+ ),
871
+ parentMatches,
872
+ dataRouterOpts
873
+ );
874
+ return renderedMatches;
875
+ }
876
+ function DefaultErrorComponent() {
877
+ let error = useRouteError();
878
+ let message = isRouteErrorResponse(error) ? `${error.status} ${error.statusText}` : error instanceof Error ? error.message : JSON.stringify(error);
879
+ let stack = error instanceof Error ? error.stack : null;
880
+ let lightgrey = "rgba(200,200,200, 0.5)";
881
+ let preStyles = { padding: "0.5rem", backgroundColor: lightgrey };
882
+ let codeStyles = { padding: "2px 4px", backgroundColor: lightgrey };
883
+ let devInfo = null;
884
+ {
885
+ console.error(
886
+ "Error handled by React Router default ErrorBoundary:",
887
+ error
888
+ );
889
+ devInfo = /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("p", null, "💿 Hey developer 👋"), /* @__PURE__ */ React3.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ React3.createElement("code", { style: codeStyles }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ React3.createElement("code", { style: codeStyles }, "errorElement"), " prop on your route."));
890
+ }
891
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ React3.createElement("h3", { style: { fontStyle: "italic" } }, message), stack ? /* @__PURE__ */ React3.createElement("pre", { style: preStyles }, stack) : null, devInfo);
892
+ }
893
+ var defaultErrorElement = /* @__PURE__ */ React3.createElement(DefaultErrorComponent, null);
894
+ var RenderErrorBoundary = class extends React3.Component {
895
+ constructor(props) {
896
+ super(props);
897
+ this.state = {
898
+ location: props.location,
899
+ revalidation: props.revalidation,
900
+ error: props.error
901
+ };
902
+ }
903
+ static getDerivedStateFromError(error) {
904
+ return { error };
905
+ }
906
+ static getDerivedStateFromProps(props, state) {
907
+ if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
908
+ return {
909
+ error: props.error,
910
+ location: props.location,
911
+ revalidation: props.revalidation
912
+ };
913
+ }
914
+ return {
915
+ error: props.error !== void 0 ? props.error : state.error,
916
+ location: state.location,
917
+ revalidation: props.revalidation || state.revalidation
918
+ };
919
+ }
920
+ componentDidCatch(error, errorInfo) {
921
+ if (this.props.onError) {
922
+ this.props.onError(error, errorInfo);
503
923
  } else {
504
- router.navigate(to, _extends$1({
505
- fromRouteId: id
506
- }, options));
924
+ console.error(
925
+ "React Router caught the following error during render",
926
+ error
927
+ );
507
928
  }
508
- }, [router, id]);
509
- return navigate;
510
- }
511
- new Promise(() => {
512
- });
513
- /**
514
- * React Router DOM v6.30.3
515
- *
516
- * Copyright (c) Remix Software Inc.
517
- *
518
- * This source code is licensed under the MIT license found in the
519
- * LICENSE.md file in the root directory of this source tree.
520
- *
521
- * @license MIT
522
- */
523
- function _extends() {
524
- _extends = Object.assign ? Object.assign.bind() : function(target) {
525
- for (var i = 1; i < arguments.length; i++) {
526
- var source = arguments[i];
527
- for (var key in source) {
528
- if (Object.prototype.hasOwnProperty.call(source, key)) {
529
- target[key] = source[key];
929
+ }
930
+ render() {
931
+ let error = this.state.error;
932
+ if (this.context && typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
933
+ const decoded = decodeRouteErrorResponseDigest(error.digest);
934
+ if (decoded) error = decoded;
935
+ }
936
+ let result = error !== void 0 ? /* @__PURE__ */ React3.createElement(RouteContext.Provider, { value: this.props.routeContext }, /* @__PURE__ */ React3.createElement(
937
+ RouteErrorContext.Provider,
938
+ {
939
+ value: error,
940
+ children: this.props.component
941
+ }
942
+ )) : this.props.children;
943
+ if (this.context) {
944
+ return /* @__PURE__ */ React3.createElement(RSCErrorHandler, { error }, result);
945
+ }
946
+ return result;
947
+ }
948
+ };
949
+ RenderErrorBoundary.contextType = RSCRouterContext;
950
+ var errorRedirectHandledMap = /* @__PURE__ */ new WeakMap();
951
+ function RSCErrorHandler({
952
+ children: children2,
953
+ error
954
+ }) {
955
+ let { basename, navigator } = React3.useContext(NavigationContext);
956
+ if (typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
957
+ let redirect2 = decodeRedirectErrorDigest(error.digest);
958
+ if (redirect2) {
959
+ let existingRedirect = errorRedirectHandledMap.get(error);
960
+ if (existingRedirect) throw existingRedirect;
961
+ let parsed = parseToInfo(redirect2.location, basename);
962
+ let target = parsed.absoluteURL || parsed.to;
963
+ validateNavigationTarget(
964
+ redirect2.location,
965
+ target,
966
+ getNavigatorCurrentUrl(navigator),
967
+ "allow-explicit"
968
+ );
969
+ if (hasInvalidProtocol(target)) {
970
+ throw new Error("Invalid redirect location");
971
+ }
972
+ if (isBrowser && !errorRedirectHandledMap.get(error)) {
973
+ if (parsed.isExternal || redirect2.reloadDocument) {
974
+ window.location.href = target;
975
+ } else {
976
+ const redirectPromise = Promise.resolve().then(
977
+ () => window.__reactRouterDataRouter.navigate(parsed.to, {
978
+ replace: redirect2.replace
979
+ })
980
+ );
981
+ errorRedirectHandledMap.set(error, redirectPromise);
982
+ throw redirectPromise;
530
983
  }
531
984
  }
985
+ return /* @__PURE__ */ React3.createElement("meta", { httpEquiv: "refresh", content: `0;url=${target}` });
532
986
  }
533
- return target;
534
- };
535
- return _extends.apply(this, arguments);
536
- }
537
- function _objectWithoutPropertiesLoose(source, excluded) {
538
- if (source == null) return {};
539
- var target = {};
540
- var sourceKeys = Object.keys(source);
541
- var key, i;
542
- for (i = 0; i < sourceKeys.length; i++) {
543
- key = sourceKeys[i];
544
- if (excluded.indexOf(key) >= 0) continue;
545
- target[key] = source[key];
546
- }
547
- return target;
548
- }
549
- const defaultMethod = "get";
550
- const defaultEncType = "application/x-www-form-urlencoded";
551
- function isHtmlElement(object) {
552
- return object != null && typeof object.tagName === "string";
553
- }
554
- function isButtonElement(object) {
555
- return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
556
- }
557
- function isFormElement(object) {
558
- return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
559
- }
560
- function isInputElement(object) {
561
- return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
987
+ }
988
+ return children2;
562
989
  }
563
- function isModifiedEvent(event) {
564
- return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
990
+ function RenderedRoute({ routeContext, match, children: children2 }) {
991
+ let dataRouterContext = React3.useContext(DataRouterContext);
992
+ if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
993
+ dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
994
+ }
995
+ return /* @__PURE__ */ React3.createElement(RouteContext.Provider, { value: routeContext }, children2);
996
+ }
997
+ function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
998
+ let dataRouterState = dataRouterOpts == null ? void 0 : dataRouterOpts.state;
999
+ if (matches == null) {
1000
+ if (!dataRouterState) {
1001
+ return null;
1002
+ }
1003
+ if (dataRouterState.errors) {
1004
+ matches = dataRouterState.matches;
1005
+ } else if (parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) {
1006
+ matches = dataRouterState.matches;
1007
+ } else {
1008
+ return null;
1009
+ }
1010
+ }
1011
+ let renderedMatches = matches;
1012
+ let errors = dataRouterState == null ? void 0 : dataRouterState.errors;
1013
+ if (errors != null) {
1014
+ let errorIndex = renderedMatches.findIndex(
1015
+ (m) => m.route.id && (errors == null ? void 0 : errors[m.route.id]) !== void 0
1016
+ );
1017
+ invariant(
1018
+ errorIndex >= 0,
1019
+ `Could not find a matching route for errors on route IDs: ${Object.keys(
1020
+ errors
1021
+ ).join(",")}`
1022
+ );
1023
+ renderedMatches = renderedMatches.slice(
1024
+ 0,
1025
+ Math.min(renderedMatches.length, errorIndex + 1)
1026
+ );
1027
+ }
1028
+ let renderFallback = false;
1029
+ let fallbackIndex = -1;
1030
+ if (dataRouterOpts && dataRouterState) {
1031
+ renderFallback = dataRouterState.renderFallback;
1032
+ for (let i = 0; i < renderedMatches.length; i++) {
1033
+ let match = renderedMatches[i];
1034
+ if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
1035
+ fallbackIndex = i;
1036
+ }
1037
+ if (match.route.id) {
1038
+ let { loaderData, errors: errors2 } = dataRouterState;
1039
+ let needsToRunLoader = match.route.loader && !loaderData.hasOwnProperty(match.route.id) && (!errors2 || errors2[match.route.id] === void 0);
1040
+ if (match.route.lazy || needsToRunLoader) {
1041
+ if (dataRouterOpts.isStatic) {
1042
+ renderFallback = true;
1043
+ }
1044
+ if (fallbackIndex >= 0) {
1045
+ renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
1046
+ } else {
1047
+ renderedMatches = [renderedMatches[0]];
1048
+ }
1049
+ break;
1050
+ }
1051
+ }
1052
+ }
1053
+ }
1054
+ let onErrorHandler = dataRouterOpts == null ? void 0 : dataRouterOpts.onError;
1055
+ let onError = dataRouterState && onErrorHandler ? (error, errorInfo) => {
1056
+ var _a, _b;
1057
+ onErrorHandler(error, {
1058
+ location: dataRouterState.location,
1059
+ params: ((_b = (_a = dataRouterState.matches) == null ? void 0 : _a[0]) == null ? void 0 : _b.params) ?? {},
1060
+ pattern: getRoutePattern(dataRouterState.matches),
1061
+ errorInfo
1062
+ });
1063
+ } : void 0;
1064
+ return renderedMatches.reduceRight(
1065
+ (outlet, match, index) => {
1066
+ let error;
1067
+ let shouldRenderHydrateFallback = false;
1068
+ let errorElement = null;
1069
+ let hydrateFallbackElement = null;
1070
+ if (dataRouterState) {
1071
+ error = errors && match.route.id ? errors[match.route.id] : void 0;
1072
+ errorElement = match.route.errorElement || defaultErrorElement;
1073
+ if (renderFallback) {
1074
+ if (fallbackIndex < 0 && index === 0) {
1075
+ warningOnce(
1076
+ "route-fallback",
1077
+ false,
1078
+ "No `HydrateFallback` element provided to render during initial hydration"
1079
+ );
1080
+ shouldRenderHydrateFallback = true;
1081
+ hydrateFallbackElement = null;
1082
+ } else if (fallbackIndex === index) {
1083
+ shouldRenderHydrateFallback = true;
1084
+ hydrateFallbackElement = match.route.hydrateFallbackElement || null;
1085
+ }
1086
+ }
1087
+ }
1088
+ let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
1089
+ let getChildren = () => {
1090
+ let children2;
1091
+ if (error) {
1092
+ children2 = errorElement;
1093
+ } else if (shouldRenderHydrateFallback) {
1094
+ children2 = hydrateFallbackElement;
1095
+ } else if (match.route.Component) {
1096
+ children2 = /* @__PURE__ */ React3.createElement(match.route.Component, null);
1097
+ } else if (match.route.element) {
1098
+ children2 = match.route.element;
1099
+ } else {
1100
+ children2 = outlet;
1101
+ }
1102
+ return /* @__PURE__ */ React3.createElement(
1103
+ RenderedRoute,
1104
+ {
1105
+ match,
1106
+ routeContext: {
1107
+ outlet,
1108
+ matches: matches2,
1109
+ isDataRoute: dataRouterState != null
1110
+ },
1111
+ children: children2
1112
+ }
1113
+ );
1114
+ };
1115
+ return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React3.createElement(
1116
+ RenderErrorBoundary,
1117
+ {
1118
+ location: dataRouterState.location,
1119
+ revalidation: dataRouterState.revalidation,
1120
+ component: errorElement,
1121
+ error,
1122
+ children: getChildren(),
1123
+ routeContext: { outlet: null, matches: matches2, isDataRoute: true },
1124
+ onError
1125
+ }
1126
+ ) : getChildren();
1127
+ },
1128
+ null
1129
+ );
1130
+ }
1131
+ function getDataRouterConsoleError(hookName) {
1132
+ return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
1133
+ }
1134
+ function useDataRouterContext(hookName) {
1135
+ let ctx = React3.useContext(DataRouterContext);
1136
+ invariant(ctx, getDataRouterConsoleError(hookName));
1137
+ return ctx;
1138
+ }
1139
+ function useDataRouterState(hookName) {
1140
+ let state = React3.useContext(DataRouterStateContext);
1141
+ invariant(state, getDataRouterConsoleError(hookName));
1142
+ return state;
1143
+ }
1144
+ function useRouteContext(hookName) {
1145
+ let route = React3.useContext(RouteContext);
1146
+ invariant(route, getDataRouterConsoleError(hookName));
1147
+ return route;
1148
+ }
1149
+ function useCurrentRouteId(hookName) {
1150
+ let route = useRouteContext(hookName);
1151
+ let thisRoute = route.matches[route.matches.length - 1];
1152
+ invariant(
1153
+ thisRoute.route.id,
1154
+ `${hookName} can only be used on routes that contain a unique "id"`
1155
+ );
1156
+ return thisRoute.route.id;
1157
+ }
1158
+ function useRouteId() {
1159
+ return useCurrentRouteId(
1160
+ "useRouteId"
1161
+ /* UseRouteId */
1162
+ );
1163
+ }
1164
+ function useRouteError() {
1165
+ var _a;
1166
+ let error = React3.useContext(RouteErrorContext);
1167
+ let state = useDataRouterState(
1168
+ "useRouteError"
1169
+ /* UseRouteError */
1170
+ );
1171
+ let routeId = useCurrentRouteId(
1172
+ "useRouteError"
1173
+ /* UseRouteError */
1174
+ );
1175
+ if (error !== void 0) {
1176
+ return error;
1177
+ }
1178
+ return (_a = state.errors) == null ? void 0 : _a[routeId];
1179
+ }
1180
+ function useNavigateStable() {
1181
+ let { router } = useDataRouterContext(
1182
+ "useNavigate"
1183
+ /* UseNavigateStable */
1184
+ );
1185
+ let id = useCurrentRouteId(
1186
+ "useNavigate"
1187
+ /* UseNavigateStable */
1188
+ );
1189
+ let activeRef = React3.useRef(false);
1190
+ useIsomorphicLayoutEffect(() => {
1191
+ activeRef.current = true;
1192
+ });
1193
+ let navigate = React3.useCallback(
1194
+ async (to, options = {}) => {
1195
+ warning(activeRef.current, navigateEffectWarning);
1196
+ if (!activeRef.current) return;
1197
+ if (typeof to === "number") {
1198
+ await router.navigate(to);
1199
+ } else {
1200
+ await router.navigate(to, { fromRouteId: id, ...options });
1201
+ }
1202
+ },
1203
+ [router, id]
1204
+ );
1205
+ return navigate;
1206
+ }
1207
+ var alreadyWarned = {};
1208
+ function warningOnce(key, cond, message) {
1209
+ if (!cond && !alreadyWarned[key]) {
1210
+ alreadyWarned[key] = true;
1211
+ warning(false, message);
1212
+ }
1213
+ }
1214
+ React3.memo(DataRoutes2);
1215
+ function DataRoutes2({
1216
+ routes,
1217
+ manifest,
1218
+ future,
1219
+ state,
1220
+ isStatic,
1221
+ onError
1222
+ }) {
1223
+ return useRoutesImpl(routes, void 0, {
1224
+ manifest,
1225
+ state,
1226
+ isStatic,
1227
+ onError
1228
+ });
1229
+ }
1230
+ var defaultMethod = "get";
1231
+ var defaultEncType = "application/x-www-form-urlencoded";
1232
+ function isHtmlElement(object) {
1233
+ return typeof HTMLElement !== "undefined" && object instanceof HTMLElement;
1234
+ }
1235
+ function isButtonElement(object) {
1236
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
1237
+ }
1238
+ function isFormElement(object) {
1239
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
1240
+ }
1241
+ function isInputElement(object) {
1242
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
1243
+ }
1244
+ function isModifiedEvent(event) {
1245
+ return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
565
1246
  }
566
1247
  function shouldProcessLinkClick(event, target) {
567
1248
  return event.button === 0 && // Ignore everything but left clicks
568
1249
  (!target || target === "_self") && // Let browser handle "target=_blank" etc.
569
1250
  !isModifiedEvent(event);
570
1251
  }
571
- let _formDataSupportsSubmitter = null;
1252
+ var _formDataSupportsSubmitter = null;
572
1253
  function isFormDataSubmitterSupported() {
573
1254
  if (_formDataSupportsSubmitter === null) {
574
1255
  try {
@@ -584,10 +1265,17 @@ function isFormDataSubmitterSupported() {
584
1265
  }
585
1266
  return _formDataSupportsSubmitter;
586
1267
  }
587
- const supportedFormEncTypes = /* @__PURE__ */ new Set(["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]);
1268
+ var supportedFormEncTypes = /* @__PURE__ */ new Set([
1269
+ "application/x-www-form-urlencoded",
1270
+ "multipart/form-data",
1271
+ "text/plain"
1272
+ ]);
588
1273
  function getFormEncType(encType) {
589
1274
  if (encType != null && !supportedFormEncTypes.has(encType)) {
590
- process.env.NODE_ENV !== "production" ? warning(false, '"' + encType + '" is not a valid `encType` for `<Form>`/`<fetcher.Form>` ' + ('and will default to "' + defaultEncType + '"')) : void 0;
1275
+ warning(
1276
+ false,
1277
+ `"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
1278
+ );
591
1279
  return null;
592
1280
  }
593
1281
  return encType;
@@ -607,7 +1295,9 @@ function getFormSubmissionInfo(target, basename) {
607
1295
  } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
608
1296
  let form = target.form;
609
1297
  if (form == null) {
610
- throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');
1298
+ throw new Error(
1299
+ `Cannot submit a <button> or <input type="submit"> without a <form>`
1300
+ );
611
1301
  }
612
1302
  let attr = target.getAttribute("formaction") || form.getAttribute("action");
613
1303
  action = attr ? stripBasename(attr, basename) : null;
@@ -615,21 +1305,19 @@ function getFormSubmissionInfo(target, basename) {
615
1305
  encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
616
1306
  formData = new FormData(form, target);
617
1307
  if (!isFormDataSubmitterSupported()) {
618
- let {
619
- name,
620
- type,
621
- value
622
- } = target;
1308
+ let { name, type, value } = target;
623
1309
  if (type === "image") {
624
- let prefix = name ? name + "." : "";
625
- formData.append(prefix + "x", "0");
626
- formData.append(prefix + "y", "0");
1310
+ let prefix = name ? `${name}.` : "";
1311
+ formData.append(`${prefix}x`, "0");
1312
+ formData.append(`${prefix}y`, "0");
627
1313
  } else if (name) {
628
1314
  formData.append(name, value);
629
1315
  }
630
1316
  }
631
1317
  } else if (isHtmlElement(target)) {
632
- throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');
1318
+ throw new Error(
1319
+ `Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
1320
+ );
633
1321
  } else {
634
1322
  method = defaultMethod;
635
1323
  action = null;
@@ -640,99 +1328,546 @@ function getFormSubmissionInfo(target, basename) {
640
1328
  body = formData;
641
1329
  formData = void 0;
642
1330
  }
643
- return {
644
- action,
645
- method: method.toLowerCase(),
646
- encType,
647
- formData,
648
- body
1331
+ return { action, method: method.toLowerCase(), encType, formData, body };
1332
+ }
1333
+ Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
1334
+ function invariant2(value, message) {
1335
+ if (value === false || value === null || typeof value === "undefined") {
1336
+ throw new Error(message);
1337
+ }
1338
+ }
1339
+ function singleFetchUrl(reqUrl, basename, trailingSlashAware, extension) {
1340
+ let url = typeof reqUrl === "string" ? new URL(
1341
+ reqUrl,
1342
+ // This can be called during the SSR flow via PrefetchPageLinksImpl so
1343
+ // don't assume window is available
1344
+ typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
1345
+ ) : reqUrl;
1346
+ if (trailingSlashAware) {
1347
+ if (url.pathname.endsWith("/")) {
1348
+ url.pathname = `${url.pathname}_.${extension}`;
1349
+ } else {
1350
+ url.pathname = `${url.pathname}.${extension}`;
1351
+ }
1352
+ } else {
1353
+ if (url.pathname === "/") {
1354
+ url.pathname = `_root.${extension}`;
1355
+ } else if (basename && stripBasename(url.pathname, basename) === "/") {
1356
+ url.pathname = `${removeTrailingSlash(basename)}/_root.${extension}`;
1357
+ } else {
1358
+ url.pathname = `${removeTrailingSlash(url.pathname)}.${extension}`;
1359
+ }
1360
+ }
1361
+ return url;
1362
+ }
1363
+ async function loadRouteModule(route, routeModulesCache) {
1364
+ if (route.id in routeModulesCache) {
1365
+ return routeModulesCache[route.id];
1366
+ }
1367
+ try {
1368
+ let routeModule = await import(
1369
+ /* @vite-ignore */
1370
+ /* webpackIgnore: true */
1371
+ route.module
1372
+ );
1373
+ routeModulesCache[route.id] = routeModule;
1374
+ return routeModule;
1375
+ } catch (error) {
1376
+ console.error(
1377
+ `Error loading route module \`${route.module}\`, reloading page...`
1378
+ );
1379
+ console.error(error);
1380
+ if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
1381
+ void 0) ;
1382
+ window.location.reload();
1383
+ return new Promise(() => {
1384
+ });
1385
+ }
1386
+ }
1387
+ function isHtmlLinkDescriptor(object) {
1388
+ if (object == null) {
1389
+ return false;
1390
+ }
1391
+ if (object.href == null) {
1392
+ return object.rel === "preload" && typeof object.imageSrcSet === "string" && typeof object.imageSizes === "string";
1393
+ }
1394
+ return typeof object.rel === "string" && typeof object.href === "string";
1395
+ }
1396
+ async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
1397
+ let links = await Promise.all(
1398
+ matches.map(async (match) => {
1399
+ let route = manifest.routes[match.route.id];
1400
+ if (route) {
1401
+ let mod = await loadRouteModule(route, routeModules);
1402
+ return mod.links ? mod.links() : [];
1403
+ }
1404
+ return [];
1405
+ })
1406
+ );
1407
+ return dedupeLinkDescriptors(
1408
+ links.flat(1).filter(isHtmlLinkDescriptor).filter((link) => link.rel === "stylesheet" || link.rel === "preload").map(
1409
+ (link) => link.rel === "stylesheet" ? { ...link, rel: "prefetch", as: "style" } : { ...link, rel: "prefetch" }
1410
+ )
1411
+ );
1412
+ }
1413
+ function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location2, mode) {
1414
+ let isNew = (match, index) => {
1415
+ if (!currentMatches[index]) return true;
1416
+ return match.route.id !== currentMatches[index].route.id;
1417
+ };
1418
+ let matchPathChanged = (match, index) => {
1419
+ var _a;
1420
+ return (
1421
+ // param change, /users/123 -> /users/456
1422
+ currentMatches[index].pathname !== match.pathname || // splat param changed, which is not present in match.path
1423
+ // e.g. /files/images/avatar.jpg -> files/finances.xls
1424
+ ((_a = currentMatches[index].route.path) == null ? void 0 : _a.endsWith("*")) && currentMatches[index].params["*"] !== match.params["*"]
1425
+ );
649
1426
  };
1427
+ if (mode === "assets") {
1428
+ return nextMatches.filter(
1429
+ (match, index) => isNew(match, index) || matchPathChanged(match, index)
1430
+ );
1431
+ }
1432
+ if (mode === "data") {
1433
+ return nextMatches.filter((match, index) => {
1434
+ var _a;
1435
+ let manifestRoute = manifest.routes[match.route.id];
1436
+ if (!manifestRoute || !manifestRoute.hasLoader) {
1437
+ return false;
1438
+ }
1439
+ if (isNew(match, index) || matchPathChanged(match, index)) {
1440
+ return true;
1441
+ }
1442
+ if (match.route.shouldRevalidate) {
1443
+ let routeChoice = match.route.shouldRevalidate({
1444
+ currentUrl: new URL(
1445
+ location2.pathname + location2.search + location2.hash,
1446
+ window.origin
1447
+ ),
1448
+ currentParams: ((_a = currentMatches[0]) == null ? void 0 : _a.params) || {},
1449
+ nextUrl: new URL(page, window.origin),
1450
+ nextParams: match.params,
1451
+ defaultShouldRevalidate: true
1452
+ });
1453
+ if (typeof routeChoice === "boolean") {
1454
+ return routeChoice;
1455
+ }
1456
+ }
1457
+ return true;
1458
+ });
1459
+ }
1460
+ return [];
650
1461
  }
651
- const _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "viewTransition"], _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "viewTransition", "children"], _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "viewTransition"];
652
- const REACT_ROUTER_VERSION = "6";
653
- try {
654
- window.__reactRouterVersion = REACT_ROUTER_VERSION;
655
- } catch (e) {
1462
+ function getModuleLinkHrefs(matches, manifest, { includeHydrateFallback } = {}) {
1463
+ return dedupeHrefs(
1464
+ matches.map((match) => {
1465
+ let route = manifest.routes[match.route.id];
1466
+ if (!route) return [];
1467
+ let hrefs = [route.module];
1468
+ if (route.clientActionModule) {
1469
+ hrefs = hrefs.concat(route.clientActionModule);
1470
+ }
1471
+ if (route.clientLoaderModule) {
1472
+ hrefs = hrefs.concat(route.clientLoaderModule);
1473
+ }
1474
+ if (includeHydrateFallback && route.hydrateFallbackModule) {
1475
+ hrefs = hrefs.concat(route.hydrateFallbackModule);
1476
+ }
1477
+ if (route.imports) {
1478
+ hrefs = hrefs.concat(route.imports);
1479
+ }
1480
+ return hrefs;
1481
+ }).flat(1)
1482
+ );
656
1483
  }
657
- const ViewTransitionContext = /* @__PURE__ */ React.createContext({
658
- isTransitioning: false
659
- });
660
- if (process.env.NODE_ENV !== "production") {
661
- ViewTransitionContext.displayName = "ViewTransition";
1484
+ function dedupeHrefs(hrefs) {
1485
+ return [...new Set(hrefs)];
1486
+ }
1487
+ function sortKeys(obj) {
1488
+ let sorted = {};
1489
+ let keys2 = Object.keys(obj).sort();
1490
+ for (let key of keys2) {
1491
+ sorted[key] = obj[key];
1492
+ }
1493
+ return sorted;
1494
+ }
1495
+ function dedupeLinkDescriptors(descriptors, preloads) {
1496
+ let set = /* @__PURE__ */ new Set();
1497
+ new Set(preloads);
1498
+ return descriptors.reduce((deduped, descriptor) => {
1499
+ let key = JSON.stringify(sortKeys(descriptor));
1500
+ if (!set.has(key)) {
1501
+ set.add(key);
1502
+ deduped.push({ key, link: descriptor });
1503
+ }
1504
+ return deduped;
1505
+ }, []);
1506
+ }
1507
+ function useDataRouterContext2() {
1508
+ let context = React3.useContext(DataRouterContext);
1509
+ invariant2(
1510
+ context,
1511
+ "You must render this element inside a <DataRouterContext.Provider> element"
1512
+ );
1513
+ return context;
662
1514
  }
663
- const FetchersContext = /* @__PURE__ */ React.createContext(/* @__PURE__ */ new Map());
664
- if (process.env.NODE_ENV !== "production") {
665
- FetchersContext.displayName = "Fetchers";
1515
+ function useDataRouterStateContext() {
1516
+ let context = React3.useContext(DataRouterStateContext);
1517
+ invariant2(
1518
+ context,
1519
+ "You must render this element inside a <DataRouterStateContext.Provider> element"
1520
+ );
1521
+ return context;
1522
+ }
1523
+ var FrameworkContext = React3.createContext(void 0);
1524
+ FrameworkContext.displayName = "FrameworkContext";
1525
+ function useFrameworkContext() {
1526
+ let context = React3.useContext(FrameworkContext);
1527
+ invariant2(
1528
+ context,
1529
+ "You must render this element inside a <HydratedRouter> element"
1530
+ );
1531
+ return context;
1532
+ }
1533
+ function usePrefetchBehavior(prefetch, theirElementProps) {
1534
+ let frameworkContext = React3.useContext(FrameworkContext);
1535
+ let [maybePrefetch, setMaybePrefetch] = React3.useState(false);
1536
+ let [shouldPrefetch, setShouldPrefetch] = React3.useState(false);
1537
+ let { onFocus, onBlur, onMouseEnter, onMouseLeave, onTouchStart } = theirElementProps;
1538
+ let ref = React3.useRef(null);
1539
+ React3.useEffect(() => {
1540
+ if (prefetch === "render") {
1541
+ setShouldPrefetch(true);
1542
+ }
1543
+ if (prefetch === "viewport") {
1544
+ let callback = (entries) => {
1545
+ entries.forEach((entry) => {
1546
+ setShouldPrefetch(entry.isIntersecting);
1547
+ });
1548
+ };
1549
+ let observer = new IntersectionObserver(callback, { threshold: 0.5 });
1550
+ if (ref.current) observer.observe(ref.current);
1551
+ return () => {
1552
+ observer.disconnect();
1553
+ };
1554
+ }
1555
+ }, [prefetch]);
1556
+ React3.useEffect(() => {
1557
+ if (maybePrefetch) {
1558
+ let id = setTimeout(() => {
1559
+ setShouldPrefetch(true);
1560
+ }, 100);
1561
+ return () => {
1562
+ clearTimeout(id);
1563
+ };
1564
+ }
1565
+ }, [maybePrefetch]);
1566
+ let setIntent = () => {
1567
+ setMaybePrefetch(true);
1568
+ };
1569
+ let cancelIntent = () => {
1570
+ setMaybePrefetch(false);
1571
+ setShouldPrefetch(false);
1572
+ };
1573
+ if (!frameworkContext) {
1574
+ return [false, ref, {}];
1575
+ }
1576
+ if (prefetch !== "intent") {
1577
+ return [shouldPrefetch, ref, {}];
1578
+ }
1579
+ return [
1580
+ shouldPrefetch,
1581
+ ref,
1582
+ {
1583
+ onFocus: composeEventHandlers(onFocus, setIntent),
1584
+ onBlur: composeEventHandlers(onBlur, cancelIntent),
1585
+ onMouseEnter: composeEventHandlers(onMouseEnter, setIntent),
1586
+ onMouseLeave: composeEventHandlers(onMouseLeave, cancelIntent),
1587
+ onTouchStart: composeEventHandlers(onTouchStart, setIntent)
1588
+ }
1589
+ ];
666
1590
  }
667
- if (process.env.NODE_ENV !== "production") ;
668
- const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
669
- const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
670
- const Link = /* @__PURE__ */ React.forwardRef(function LinkWithRef(_ref7, ref) {
671
- let {
1591
+ function composeEventHandlers(theirHandler, ourHandler) {
1592
+ return (event) => {
1593
+ theirHandler && theirHandler(event);
1594
+ if (!event.defaultPrevented) {
1595
+ ourHandler(event);
1596
+ }
1597
+ };
1598
+ }
1599
+ function PrefetchPageLinks({ page, ...linkProps }) {
1600
+ let rsc = useIsRSCRouterContext();
1601
+ let { nonce: contextNonce } = useFrameworkContext();
1602
+ let { router } = useDataRouterContext2();
1603
+ let matches = React3.useMemo(
1604
+ () => matchRoutes(router.routes, page, router.basename),
1605
+ [router.routes, page, router.basename]
1606
+ );
1607
+ if (!matches) {
1608
+ return null;
1609
+ }
1610
+ if (linkProps.nonce == null && contextNonce) {
1611
+ linkProps = { ...linkProps, nonce: contextNonce };
1612
+ }
1613
+ if (rsc) {
1614
+ return /* @__PURE__ */ React3.createElement(RSCPrefetchPageLinksImpl, { page, matches, ...linkProps });
1615
+ }
1616
+ return /* @__PURE__ */ React3.createElement(PrefetchPageLinksImpl, { page, matches, ...linkProps });
1617
+ }
1618
+ function useKeyedPrefetchLinks(matches) {
1619
+ let { manifest, routeModules } = useFrameworkContext();
1620
+ let [keyedPrefetchLinks, setKeyedPrefetchLinks] = React3.useState([]);
1621
+ React3.useEffect(() => {
1622
+ let interrupted = false;
1623
+ void getKeyedPrefetchLinks(matches, manifest, routeModules).then(
1624
+ (links) => {
1625
+ if (!interrupted) {
1626
+ setKeyedPrefetchLinks(links);
1627
+ }
1628
+ }
1629
+ );
1630
+ return () => {
1631
+ interrupted = true;
1632
+ };
1633
+ }, [matches, manifest, routeModules]);
1634
+ return keyedPrefetchLinks;
1635
+ }
1636
+ function RSCPrefetchPageLinksImpl({
1637
+ page,
1638
+ matches: nextMatches,
1639
+ ...linkProps
1640
+ }) {
1641
+ let location2 = useLocation();
1642
+ let { future } = useFrameworkContext();
1643
+ let { basename } = useDataRouterContext2();
1644
+ let dataHrefs = React3.useMemo(() => {
1645
+ if (page === location2.pathname + location2.search + location2.hash) {
1646
+ return [];
1647
+ }
1648
+ let url = singleFetchUrl(
1649
+ page,
1650
+ basename,
1651
+ future.v8_trailingSlashAwareDataRequests,
1652
+ "rsc"
1653
+ );
1654
+ let hasSomeRoutesWithShouldRevalidate = false;
1655
+ let targetRoutes = [];
1656
+ for (let match of nextMatches) {
1657
+ if (typeof match.route.shouldRevalidate === "function") {
1658
+ hasSomeRoutesWithShouldRevalidate = true;
1659
+ } else {
1660
+ targetRoutes.push(match.route.id);
1661
+ }
1662
+ }
1663
+ if (hasSomeRoutesWithShouldRevalidate && targetRoutes.length > 0) {
1664
+ url.searchParams.set("_routes", targetRoutes.join(","));
1665
+ }
1666
+ return [url.pathname + url.search];
1667
+ }, [
1668
+ basename,
1669
+ future.v8_trailingSlashAwareDataRequests,
1670
+ page,
1671
+ location2,
1672
+ nextMatches
1673
+ ]);
1674
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React3.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })));
1675
+ }
1676
+ function PrefetchPageLinksImpl({
1677
+ page,
1678
+ matches: nextMatches,
1679
+ ...linkProps
1680
+ }) {
1681
+ let location2 = useLocation();
1682
+ let { future, manifest, routeModules } = useFrameworkContext();
1683
+ let { basename } = useDataRouterContext2();
1684
+ let { loaderData, matches } = useDataRouterStateContext();
1685
+ let newMatchesForData = React3.useMemo(
1686
+ () => getNewMatchesForLinks(
1687
+ page,
1688
+ nextMatches,
1689
+ matches,
1690
+ manifest,
1691
+ location2,
1692
+ "data"
1693
+ ),
1694
+ [page, nextMatches, matches, manifest, location2]
1695
+ );
1696
+ let newMatchesForAssets = React3.useMemo(
1697
+ () => getNewMatchesForLinks(
1698
+ page,
1699
+ nextMatches,
1700
+ matches,
1701
+ manifest,
1702
+ location2,
1703
+ "assets"
1704
+ ),
1705
+ [page, nextMatches, matches, manifest, location2]
1706
+ );
1707
+ let dataHrefs = React3.useMemo(() => {
1708
+ if (page === location2.pathname + location2.search + location2.hash) {
1709
+ return [];
1710
+ }
1711
+ let routesParams = /* @__PURE__ */ new Set();
1712
+ let foundOptOutRoute = false;
1713
+ nextMatches.forEach((m) => {
1714
+ var _a;
1715
+ let manifestRoute = manifest.routes[m.route.id];
1716
+ if (!manifestRoute || !manifestRoute.hasLoader) {
1717
+ return;
1718
+ }
1719
+ if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && ((_a = routeModules[m.route.id]) == null ? void 0 : _a.shouldRevalidate)) {
1720
+ foundOptOutRoute = true;
1721
+ } else if (manifestRoute.hasClientLoader) {
1722
+ foundOptOutRoute = true;
1723
+ } else {
1724
+ routesParams.add(m.route.id);
1725
+ }
1726
+ });
1727
+ if (routesParams.size === 0) {
1728
+ return [];
1729
+ }
1730
+ let url = singleFetchUrl(
1731
+ page,
1732
+ basename,
1733
+ future.v8_trailingSlashAwareDataRequests,
1734
+ "data"
1735
+ );
1736
+ if (foundOptOutRoute && routesParams.size > 0) {
1737
+ url.searchParams.set(
1738
+ "_routes",
1739
+ nextMatches.filter((m) => routesParams.has(m.route.id)).map((m) => m.route.id).join(",")
1740
+ );
1741
+ }
1742
+ return [url.pathname + url.search];
1743
+ }, [
1744
+ basename,
1745
+ future.v8_trailingSlashAwareDataRequests,
1746
+ loaderData,
1747
+ location2,
1748
+ manifest,
1749
+ newMatchesForData,
1750
+ nextMatches,
1751
+ page,
1752
+ routeModules
1753
+ ]);
1754
+ let moduleHrefs = React3.useMemo(
1755
+ () => getModuleLinkHrefs(newMatchesForAssets, manifest),
1756
+ [newMatchesForAssets, manifest]
1757
+ );
1758
+ let keyedPrefetchLinks = useKeyedPrefetchLinks(newMatchesForAssets);
1759
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React3.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })), moduleHrefs.map((href) => /* @__PURE__ */ React3.createElement("link", { key: href, rel: "modulepreload", href, ...linkProps })), keyedPrefetchLinks.map(({ key, link }) => (
1760
+ // these don't spread `linkProps` because they are full link descriptors
1761
+ // already with their own props
1762
+ /* @__PURE__ */ React3.createElement(
1763
+ "link",
1764
+ {
1765
+ key,
1766
+ nonce: linkProps.nonce,
1767
+ ...link,
1768
+ crossOrigin: link.crossOrigin ?? linkProps.crossOrigin
1769
+ }
1770
+ )
1771
+ )));
1772
+ }
1773
+ function mergeRefs(...refs) {
1774
+ return (value) => {
1775
+ refs.forEach((ref) => {
1776
+ if (typeof ref === "function") {
1777
+ ref(value);
1778
+ } else if (ref != null) {
1779
+ ref.current = value;
1780
+ }
1781
+ });
1782
+ };
1783
+ }
1784
+ var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
1785
+ try {
1786
+ if (isBrowser2) {
1787
+ window.__reactRouterVersion = // @ts-expect-error
1788
+ "7.18.4";
1789
+ }
1790
+ } catch (e) {
1791
+ }
1792
+ var Link = React3.forwardRef(
1793
+ function LinkWithRef({
672
1794
  onClick,
1795
+ discover = "render",
1796
+ prefetch = "none",
673
1797
  relative,
674
1798
  reloadDocument,
675
- replace,
1799
+ replace: replace2,
1800
+ mask,
676
1801
  state,
677
1802
  target,
678
1803
  to,
679
1804
  preventScrollReset,
680
- viewTransition
681
- } = _ref7, rest = _objectWithoutPropertiesLoose(_ref7, _excluded);
682
- let {
683
- basename
684
- } = React.useContext(NavigationContext);
685
- let absoluteHref;
686
- let isExternal = false;
687
- if (typeof to === "string" && ABSOLUTE_URL_REGEX.test(to)) {
688
- absoluteHref = to;
689
- if (isBrowser) {
690
- try {
691
- let currentUrl = new URL(window.location.href);
692
- let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
693
- let path = stripBasename(targetUrl.pathname, basename);
694
- if (targetUrl.origin === currentUrl.origin && path != null) {
695
- to = path + targetUrl.search + targetUrl.hash;
696
- } else {
697
- isExternal = true;
698
- }
699
- } catch (e) {
700
- process.env.NODE_ENV !== "production" ? warning(false, '<Link to="' + to + '"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.') : void 0;
1805
+ viewTransition,
1806
+ defaultShouldRevalidate,
1807
+ ...rest
1808
+ }, forwardedRef) {
1809
+ let { basename, navigator, useTransitions } = React3.useContext(NavigationContext);
1810
+ let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX.test(to);
1811
+ let parsed = parseToInfo(to, basename);
1812
+ to = parsed.to;
1813
+ let href = useHref(to, { relative });
1814
+ let location2 = useLocation();
1815
+ let maskedHref = null;
1816
+ if (mask) {
1817
+ let resolved = resolveTo(
1818
+ mask,
1819
+ [],
1820
+ location2.mask ? location2.mask.pathname : "/",
1821
+ true
1822
+ );
1823
+ if (basename !== "/") {
1824
+ resolved.pathname = resolved.pathname === "/" ? basename : joinPaths([basename, resolved.pathname]);
701
1825
  }
1826
+ maskedHref = navigator.createHref(resolved);
702
1827
  }
1828
+ let [shouldPrefetch, prefetchRef, prefetchHandlers] = usePrefetchBehavior(
1829
+ prefetch,
1830
+ rest
1831
+ );
1832
+ let internalOnClick = useLinkClickHandler(to, {
1833
+ replace: replace2,
1834
+ mask,
1835
+ state,
1836
+ target,
1837
+ preventScrollReset,
1838
+ relative,
1839
+ viewTransition,
1840
+ defaultShouldRevalidate,
1841
+ useTransitions
1842
+ });
1843
+ function handleClick(event) {
1844
+ if (onClick) onClick(event);
1845
+ if (!event.defaultPrevented) {
1846
+ internalOnClick(event);
1847
+ }
1848
+ }
1849
+ let isSpaLink = !(parsed.isExternal || reloadDocument);
1850
+ let link = (
1851
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
1852
+ /* @__PURE__ */ React3.createElement(
1853
+ "a",
1854
+ {
1855
+ ...rest,
1856
+ ...prefetchHandlers,
1857
+ href: (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href,
1858
+ onClick: isSpaLink ? handleClick : onClick,
1859
+ ref: mergeRefs(forwardedRef, prefetchRef),
1860
+ target,
1861
+ "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
1862
+ }
1863
+ )
1864
+ );
1865
+ return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, link, /* @__PURE__ */ React3.createElement(PrefetchPageLinks, { page: href })) : link;
703
1866
  }
704
- let href = useHref(to, {
705
- relative
706
- });
707
- let internalOnClick = useLinkClickHandler(to, {
708
- replace,
709
- state,
710
- target,
711
- preventScrollReset,
712
- relative,
713
- viewTransition
714
- });
715
- function handleClick(event) {
716
- if (onClick) onClick(event);
717
- if (!event.defaultPrevented) {
718
- internalOnClick(event);
719
- }
720
- }
721
- return (
722
- // eslint-disable-next-line jsx-a11y/anchor-has-content
723
- /* @__PURE__ */ React.createElement("a", _extends({}, rest, {
724
- href: absoluteHref || href,
725
- onClick: isExternal || reloadDocument ? onClick : handleClick,
726
- ref,
727
- target
728
- }))
729
- );
730
- });
731
- if (process.env.NODE_ENV !== "production") {
732
- Link.displayName = "Link";
733
- }
734
- const NavLink = /* @__PURE__ */ React.forwardRef(function NavLinkWithRef(_ref8, ref) {
735
- let {
1867
+ );
1868
+ Link.displayName = "Link";
1869
+ var NavLink = React3.forwardRef(
1870
+ function NavLinkWithRef({
736
1871
  "aria-current": ariaCurrentProp = "page",
737
1872
  caseSensitive = false,
738
1873
  className: classNameProp = "",
@@ -740,222 +1875,236 @@ const NavLink = /* @__PURE__ */ React.forwardRef(function NavLinkWithRef(_ref8,
740
1875
  style: styleProp,
741
1876
  to,
742
1877
  viewTransition,
743
- children: children2
744
- } = _ref8, rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
745
- let path = useResolvedPath(to, {
746
- relative: rest.relative
747
- });
748
- let location2 = useLocation();
749
- let routerState = React.useContext(DataRouterStateContext);
750
- let {
751
- navigator,
752
- basename
753
- } = React.useContext(NavigationContext);
754
- let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
755
- // eslint-disable-next-line react-hooks/rules-of-hooks
756
- useViewTransitionState(path) && viewTransition === true;
757
- let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
758
- let locationPathname = location2.pathname;
759
- let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
760
- if (!caseSensitive) {
761
- locationPathname = locationPathname.toLowerCase();
762
- nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
763
- toPathname = toPathname.toLowerCase();
764
- }
765
- if (nextLocationPathname && basename) {
766
- nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
767
- }
768
- const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
769
- let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
770
- let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
771
- let renderProps = {
772
- isActive,
773
- isPending,
774
- isTransitioning
775
- };
776
- let ariaCurrent = isActive ? ariaCurrentProp : void 0;
777
- let className;
778
- if (typeof classNameProp === "function") {
779
- className = classNameProp(renderProps);
780
- } else {
781
- className = [classNameProp, isActive ? "active" : null, isPending ? "pending" : null, isTransitioning ? "transitioning" : null].filter(Boolean).join(" ");
1878
+ children: children2,
1879
+ ...rest
1880
+ }, ref) {
1881
+ let path = useResolvedPath(to, { relative: rest.relative });
1882
+ let location2 = useLocation();
1883
+ let routerState = React3.useContext(DataRouterStateContext);
1884
+ let { navigator, basename } = React3.useContext(NavigationContext);
1885
+ let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
1886
+ // eslint-disable-next-line react-hooks/rules-of-hooks
1887
+ useViewTransitionState(path) && viewTransition === true;
1888
+ let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
1889
+ let locationPathname = location2.pathname;
1890
+ let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
1891
+ if (!caseSensitive) {
1892
+ locationPathname = locationPathname.toLowerCase();
1893
+ nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
1894
+ toPathname = toPathname.toLowerCase();
1895
+ }
1896
+ if (nextLocationPathname && basename) {
1897
+ nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
1898
+ }
1899
+ const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
1900
+ let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
1901
+ let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
1902
+ let renderProps = {
1903
+ isActive,
1904
+ isPending,
1905
+ isTransitioning
1906
+ };
1907
+ let ariaCurrent = isActive ? ariaCurrentProp : void 0;
1908
+ let className;
1909
+ if (typeof classNameProp === "function") {
1910
+ className = classNameProp(renderProps);
1911
+ } else {
1912
+ className = [
1913
+ classNameProp,
1914
+ isActive ? "active" : null,
1915
+ isPending ? "pending" : null,
1916
+ isTransitioning ? "transitioning" : null
1917
+ ].filter(Boolean).join(" ");
1918
+ }
1919
+ let style2 = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
1920
+ return /* @__PURE__ */ React3.createElement(
1921
+ Link,
1922
+ {
1923
+ ...rest,
1924
+ "aria-current": ariaCurrent,
1925
+ className,
1926
+ ref,
1927
+ style: style2,
1928
+ to,
1929
+ viewTransition
1930
+ },
1931
+ typeof children2 === "function" ? children2(renderProps) : children2
1932
+ );
782
1933
  }
783
- let style2 = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
784
- return /* @__PURE__ */ React.createElement(Link, _extends({}, rest, {
785
- "aria-current": ariaCurrent,
786
- className,
787
- ref,
788
- style: style2,
789
- to,
790
- viewTransition
791
- }), typeof children2 === "function" ? children2(renderProps) : children2);
792
- });
793
- if (process.env.NODE_ENV !== "production") {
794
- NavLink.displayName = "NavLink";
795
- }
796
- const Form = /* @__PURE__ */ React.forwardRef((_ref9, forwardedRef) => {
797
- let {
1934
+ );
1935
+ NavLink.displayName = "NavLink";
1936
+ var Form = React3.forwardRef(
1937
+ ({
1938
+ discover = "render",
798
1939
  fetcherKey,
799
1940
  navigate,
800
1941
  reloadDocument,
801
- replace,
1942
+ replace: replace2,
802
1943
  state,
803
1944
  method = defaultMethod,
804
1945
  action,
805
1946
  onSubmit,
806
1947
  relative,
807
1948
  preventScrollReset,
808
- viewTransition
809
- } = _ref9, props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
810
- let submit = useSubmit();
811
- let formAction = useFormAction(action, {
812
- relative
813
- });
814
- let formMethod = method.toLowerCase() === "get" ? "get" : "post";
815
- let submitHandler = (event) => {
816
- onSubmit && onSubmit(event);
817
- if (event.defaultPrevented) return;
818
- event.preventDefault();
819
- let submitter = event.nativeEvent.submitter;
820
- let submitMethod = (submitter == null ? void 0 : submitter.getAttribute("formmethod")) || method;
821
- submit(submitter || event.currentTarget, {
822
- fetcherKey,
823
- method: submitMethod,
824
- navigate,
825
- replace,
826
- state,
827
- relative,
828
- preventScrollReset,
829
- viewTransition
830
- });
831
- };
832
- return /* @__PURE__ */ React.createElement("form", _extends({
833
- ref: forwardedRef,
834
- method: formMethod,
835
- action: formAction,
836
- onSubmit: reloadDocument ? onSubmit : submitHandler
837
- }, props));
838
- });
839
- if (process.env.NODE_ENV !== "production") {
840
- Form.displayName = "Form";
841
- }
842
- if (process.env.NODE_ENV !== "production") ;
843
- var DataRouterHook;
844
- (function(DataRouterHook2) {
845
- DataRouterHook2["UseScrollRestoration"] = "useScrollRestoration";
846
- DataRouterHook2["UseSubmit"] = "useSubmit";
847
- DataRouterHook2["UseSubmitFetcher"] = "useSubmitFetcher";
848
- DataRouterHook2["UseFetcher"] = "useFetcher";
849
- DataRouterHook2["useViewTransitionState"] = "useViewTransitionState";
850
- })(DataRouterHook || (DataRouterHook = {}));
851
- var DataRouterStateHook;
852
- (function(DataRouterStateHook2) {
853
- DataRouterStateHook2["UseFetcher"] = "useFetcher";
854
- DataRouterStateHook2["UseFetchers"] = "useFetchers";
855
- DataRouterStateHook2["UseScrollRestoration"] = "useScrollRestoration";
856
- })(DataRouterStateHook || (DataRouterStateHook = {}));
857
- function getDataRouterConsoleError(hookName) {
858
- return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router.";
859
- }
860
- function useDataRouterContext(hookName) {
861
- let ctx = React.useContext(DataRouterContext);
862
- !ctx ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
863
- return ctx;
864
- }
865
- function useLinkClickHandler(to, _temp) {
866
- let {
867
- target,
868
- replace: replaceProp,
869
- state,
870
- preventScrollReset,
871
- relative,
872
- viewTransition
873
- } = _temp === void 0 ? {} : _temp;
874
- let navigate = useNavigate();
875
- let location2 = useLocation();
876
- let path = useResolvedPath(to, {
877
- relative
878
- });
879
- return React.useCallback((event) => {
880
- if (shouldProcessLinkClick(event, target)) {
1949
+ viewTransition,
1950
+ defaultShouldRevalidate,
1951
+ ...props
1952
+ }, forwardedRef) => {
1953
+ let { useTransitions } = React3.useContext(NavigationContext);
1954
+ let submit = useSubmit();
1955
+ let formAction = useFormAction(action, { relative });
1956
+ let formMethod = method.toLowerCase() === "get" ? "get" : "post";
1957
+ let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX.test(action);
1958
+ let submitHandler = (event) => {
1959
+ onSubmit && onSubmit(event);
1960
+ if (event.defaultPrevented) return;
881
1961
  event.preventDefault();
882
- let replace = replaceProp !== void 0 ? replaceProp : createPath(location2) === createPath(path);
883
- navigate(to, {
884
- replace,
1962
+ let submitter = event.nativeEvent.submitter;
1963
+ let submitMethod = (submitter == null ? void 0 : submitter.getAttribute("formmethod")) || method;
1964
+ let doSubmit = () => submit(submitter || event.currentTarget, {
1965
+ fetcherKey,
1966
+ method: submitMethod,
1967
+ navigate,
1968
+ replace: replace2,
885
1969
  state,
886
- preventScrollReset,
887
1970
  relative,
888
- viewTransition
1971
+ preventScrollReset,
1972
+ viewTransition,
1973
+ defaultShouldRevalidate
889
1974
  });
890
- }
891
- }, [location2, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, viewTransition]);
892
- }
893
- function validateClientSideSubmission() {
894
- if (typeof document === "undefined") {
895
- throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");
1975
+ if (useTransitions && navigate !== false) {
1976
+ React3.startTransition(() => doSubmit());
1977
+ } else {
1978
+ doSubmit();
1979
+ }
1980
+ };
1981
+ return /* @__PURE__ */ React3.createElement(
1982
+ "form",
1983
+ {
1984
+ ref: forwardedRef,
1985
+ method: formMethod,
1986
+ action: formAction,
1987
+ onSubmit: reloadDocument ? onSubmit : submitHandler,
1988
+ ...props,
1989
+ "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
1990
+ }
1991
+ );
896
1992
  }
1993
+ );
1994
+ Form.displayName = "Form";
1995
+ function getDataRouterConsoleError2(hookName) {
1996
+ return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
1997
+ }
1998
+ function useDataRouterContext3(hookName) {
1999
+ let ctx = React3.useContext(DataRouterContext);
2000
+ invariant(ctx, getDataRouterConsoleError2(hookName));
2001
+ return ctx;
2002
+ }
2003
+ function useLinkClickHandler(to, {
2004
+ target,
2005
+ replace: replaceProp,
2006
+ mask,
2007
+ state,
2008
+ preventScrollReset,
2009
+ relative,
2010
+ viewTransition,
2011
+ defaultShouldRevalidate,
2012
+ useTransitions
2013
+ } = {}) {
2014
+ let navigate = useNavigate();
2015
+ let location2 = useLocation();
2016
+ let path = useResolvedPath(to, { relative });
2017
+ return React3.useCallback(
2018
+ (event) => {
2019
+ if (shouldProcessLinkClick(event, target)) {
2020
+ event.preventDefault();
2021
+ let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location2) === createPath(path);
2022
+ let doNavigate = () => navigate(to, {
2023
+ replace: replace2,
2024
+ mask,
2025
+ state,
2026
+ preventScrollReset,
2027
+ relative,
2028
+ viewTransition,
2029
+ defaultShouldRevalidate
2030
+ });
2031
+ if (useTransitions) {
2032
+ React3.startTransition(() => doNavigate());
2033
+ } else {
2034
+ doNavigate();
2035
+ }
2036
+ }
2037
+ },
2038
+ [
2039
+ location2,
2040
+ navigate,
2041
+ path,
2042
+ replaceProp,
2043
+ mask,
2044
+ state,
2045
+ target,
2046
+ to,
2047
+ preventScrollReset,
2048
+ relative,
2049
+ viewTransition,
2050
+ defaultShouldRevalidate,
2051
+ useTransitions
2052
+ ]
2053
+ );
897
2054
  }
898
- let fetcherId = 0;
899
- let getUniqueFetcherId = () => "__" + String(++fetcherId) + "__";
2055
+ var fetcherId = 0;
2056
+ var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
900
2057
  function useSubmit() {
901
- let {
902
- router
903
- } = useDataRouterContext(DataRouterHook.UseSubmit);
904
- let {
905
- basename
906
- } = React.useContext(NavigationContext);
2058
+ let { router } = useDataRouterContext3(
2059
+ "useSubmit"
2060
+ /* UseSubmit */
2061
+ );
2062
+ let { basename } = React3.useContext(NavigationContext);
907
2063
  let currentRouteId = useRouteId();
908
- return React.useCallback(function(target, options) {
909
- if (options === void 0) {
910
- options = {};
911
- }
912
- validateClientSideSubmission();
913
- let {
914
- action,
915
- method,
916
- encType,
917
- formData,
918
- body
919
- } = getFormSubmissionInfo(target, basename);
920
- if (options.navigate === false) {
921
- let key = options.fetcherKey || getUniqueFetcherId();
922
- router.fetch(key, currentRouteId, options.action || action, {
923
- preventScrollReset: options.preventScrollReset,
924
- formData,
925
- body,
926
- formMethod: options.method || method,
927
- formEncType: options.encType || encType,
928
- flushSync: options.flushSync
929
- });
930
- } else {
931
- router.navigate(options.action || action, {
932
- preventScrollReset: options.preventScrollReset,
933
- formData,
934
- body,
935
- formMethod: options.method || method,
936
- formEncType: options.encType || encType,
937
- replace: options.replace,
938
- state: options.state,
939
- fromRouteId: currentRouteId,
940
- flushSync: options.flushSync,
941
- viewTransition: options.viewTransition
942
- });
943
- }
944
- }, [router, basename, currentRouteId]);
2064
+ let routerFetch = router.fetch;
2065
+ let routerNavigate = router.navigate;
2066
+ return React3.useCallback(
2067
+ async (target, options = {}) => {
2068
+ let { action, method, encType, formData, body } = getFormSubmissionInfo(
2069
+ target,
2070
+ basename
2071
+ );
2072
+ if (options.navigate === false) {
2073
+ let key = options.fetcherKey || getUniqueFetcherId();
2074
+ await routerFetch(key, currentRouteId, options.action || action, {
2075
+ defaultShouldRevalidate: options.defaultShouldRevalidate,
2076
+ preventScrollReset: options.preventScrollReset,
2077
+ formData,
2078
+ body,
2079
+ formMethod: options.method || method,
2080
+ formEncType: options.encType || encType,
2081
+ flushSync: options.flushSync
2082
+ });
2083
+ } else {
2084
+ await routerNavigate(options.action || action, {
2085
+ defaultShouldRevalidate: options.defaultShouldRevalidate,
2086
+ preventScrollReset: options.preventScrollReset,
2087
+ formData,
2088
+ body,
2089
+ formMethod: options.method || method,
2090
+ formEncType: options.encType || encType,
2091
+ replace: options.replace,
2092
+ state: options.state,
2093
+ fromRouteId: currentRouteId,
2094
+ flushSync: options.flushSync,
2095
+ viewTransition: options.viewTransition
2096
+ });
2097
+ }
2098
+ },
2099
+ [routerFetch, routerNavigate, basename, currentRouteId]
2100
+ );
945
2101
  }
946
- function useFormAction(action, _temp2) {
947
- let {
948
- relative
949
- } = _temp2 === void 0 ? {} : _temp2;
950
- let {
951
- basename
952
- } = React.useContext(NavigationContext);
953
- let routeContext = React.useContext(RouteContext);
954
- !routeContext ? process.env.NODE_ENV !== "production" ? invariant(false, "useFormAction must be used inside a RouteContext") : invariant(false) : void 0;
2102
+ function useFormAction(action, { relative } = {}) {
2103
+ let { basename } = React3.useContext(NavigationContext);
2104
+ let routeContext = React3.useContext(RouteContext);
2105
+ invariant(routeContext, "useFormAction must be used inside a RouteContext");
955
2106
  let [match] = routeContext.matches.slice(-1);
956
- let path = _extends({}, useResolvedPath(action ? action : ".", {
957
- relative
958
- }));
2107
+ let path = { ...useResolvedPath(action ? action : ".", { relative }) };
959
2108
  let location2 = useLocation();
960
2109
  if (action == null) {
961
2110
  path.search = location2.search;
@@ -966,7 +2115,7 @@ function useFormAction(action, _temp2) {
966
2115
  params.delete("index");
967
2116
  indexValues.filter((v) => v).forEach((v) => params.append("index", v));
968
2117
  let qs = params.toString();
969
- path.search = qs ? "?" + qs : "";
2118
+ path.search = qs ? `?${qs}` : "";
970
2119
  }
971
2120
  }
972
2121
  if ((!action || action === ".") && match.route.index) {
@@ -977,18 +2126,17 @@ function useFormAction(action, _temp2) {
977
2126
  }
978
2127
  return createPath(path);
979
2128
  }
980
- function useViewTransitionState(to, opts) {
981
- if (opts === void 0) {
982
- opts = {};
983
- }
984
- let vtContext = React.useContext(ViewTransitionContext);
985
- !(vtContext != null) ? process.env.NODE_ENV !== "production" ? invariant(false, "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?") : invariant(false) : void 0;
986
- let {
987
- basename
988
- } = useDataRouterContext(DataRouterHook.useViewTransitionState);
989
- let path = useResolvedPath(to, {
990
- relative: opts.relative
991
- });
2129
+ function useViewTransitionState(to, { relative } = {}) {
2130
+ let vtContext = React3.useContext(ViewTransitionContext);
2131
+ invariant(
2132
+ vtContext != null,
2133
+ "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
2134
+ );
2135
+ let { basename } = useDataRouterContext3(
2136
+ "useViewTransitionState"
2137
+ /* useViewTransitionState */
2138
+ );
2139
+ let path = useResolvedPath(to, { relative });
992
2140
  if (!vtContext.isTransitioning) {
993
2141
  return false;
994
2142
  }