@hmlr/govuk-react-components-library 1.2.0 → 1.2.1

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