react-router 0.0.0-experimental-c19b79d → 0.0.0-experimental-31a822c5f

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 (70) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/dist/development/browser-B4aBBnx8.d.ts +310 -0
  3. package/dist/development/browser-CN2w9Cbu.d.mts +310 -0
  4. package/dist/development/{chunk-LUB73E44.js → chunk-CZ7KRWQZ.js} +827 -64
  5. package/dist/development/{chunk-AGOH44BE.mjs → chunk-FXUONXY4.mjs} +132 -808
  6. package/dist/development/chunk-SE36CWVW.js +1308 -0
  7. package/dist/development/chunk-T5RKBXBV.js +188 -0
  8. package/dist/development/{chunk-IMKEG5CI.mjs → chunk-WTUOISGV.mjs} +2 -2
  9. package/dist/development/dom-export.d.mts +48 -3
  10. package/dist/development/dom-export.d.ts +48 -1
  11. package/dist/development/dom-export.js +703 -18
  12. package/dist/development/dom-export.mjs +687 -9
  13. package/dist/development/{index-react-server-client-DKvU8YRr.d.ts → index-react-server-client-BOJoTiaG.d.ts} +134 -134
  14. package/dist/{production/index-react-server-client-2EDmGlsZ.d.mts → development/index-react-server-client-CuQLmpku.d.mts} +1 -2
  15. package/dist/development/index-react-server-client.d.mts +2 -3
  16. package/dist/development/index-react-server-client.d.ts +2 -2
  17. package/dist/development/index-react-server-client.js +4 -4
  18. package/dist/development/index-react-server-client.mjs +2 -2
  19. package/dist/development/index-react-server.js +1 -1
  20. package/dist/development/index-react-server.mjs +1 -1
  21. package/dist/development/index.d.mts +9 -316
  22. package/dist/development/index.d.ts +9 -358
  23. package/dist/development/index.js +82 -914
  24. package/dist/development/index.mjs +3 -9
  25. package/dist/development/lib/types/internal.d.mts +2 -3
  26. package/dist/development/lib/types/internal.d.ts +2 -2
  27. package/dist/development/lib/types/internal.js +1 -1
  28. package/dist/development/lib/types/internal.mjs +1 -1
  29. package/dist/{production/register-BrVEYTED.d.mts → development/register-BblEgJPm.d.mts} +1 -1
  30. package/dist/development/{register-D8NQoPsO.d.ts → register-D18raRVf.d.ts} +1 -1
  31. package/dist/development/{context-BqL5Eckq.d.mts → route-data-nQS6GSUI.d.mts} +472 -2
  32. package/dist/development/{routeModules-BmVo7q9e.d.ts → routeModules-9wlxglVk.d.ts} +12 -12
  33. package/dist/production/browser-B4aBBnx8.d.ts +310 -0
  34. package/dist/production/browser-CN2w9Cbu.d.mts +310 -0
  35. package/dist/production/{chunk-2L5AG5Y5.js → chunk-DRKUM6HW.js} +827 -64
  36. package/dist/production/{chunk-AODJW4D3.mjs → chunk-IGF74WUC.mjs} +132 -808
  37. package/dist/production/{chunk-UOQCOPF6.mjs → chunk-RUSRTUHT.mjs} +2 -2
  38. package/dist/production/chunk-UU3LJMU6.js +188 -0
  39. package/dist/production/chunk-YVVCGSEG.js +1308 -0
  40. package/dist/production/dom-export.d.mts +48 -3
  41. package/dist/production/dom-export.d.ts +48 -1
  42. package/dist/production/dom-export.js +703 -18
  43. package/dist/production/dom-export.mjs +687 -9
  44. package/dist/production/{index-react-server-client-DKvU8YRr.d.ts → index-react-server-client-BOJoTiaG.d.ts} +134 -134
  45. package/dist/{development/index-react-server-client-2EDmGlsZ.d.mts → production/index-react-server-client-CuQLmpku.d.mts} +1 -2
  46. package/dist/production/index-react-server-client.d.mts +2 -3
  47. package/dist/production/index-react-server-client.d.ts +2 -2
  48. package/dist/production/index-react-server-client.js +4 -4
  49. package/dist/production/index-react-server-client.mjs +2 -2
  50. package/dist/production/index-react-server.js +1 -1
  51. package/dist/production/index-react-server.mjs +1 -1
  52. package/dist/production/index.d.mts +9 -316
  53. package/dist/production/index.d.ts +9 -358
  54. package/dist/production/index.js +82 -914
  55. package/dist/production/index.mjs +3 -9
  56. package/dist/production/lib/types/internal.d.mts +2 -3
  57. package/dist/production/lib/types/internal.d.ts +2 -2
  58. package/dist/production/lib/types/internal.js +1 -1
  59. package/dist/production/lib/types/internal.mjs +1 -1
  60. package/dist/{development/register-BrVEYTED.d.mts → production/register-BblEgJPm.d.mts} +1 -1
  61. package/dist/production/{register-D8NQoPsO.d.ts → register-D18raRVf.d.ts} +1 -1
  62. package/dist/production/{context-BqL5Eckq.d.mts → route-data-nQS6GSUI.d.mts} +472 -2
  63. package/dist/production/{routeModules-BmVo7q9e.d.ts → routeModules-9wlxglVk.d.ts} +12 -12
  64. package/package.json +1 -1
  65. package/dist/development/browser-z32v5KVN.d.mts +0 -46
  66. package/dist/development/chunk-2G2U5HGB.js +0 -2089
  67. package/dist/development/route-data-CDwqkzPE.d.mts +0 -473
  68. package/dist/production/browser-z32v5KVN.d.mts +0 -46
  69. package/dist/production/chunk-FGRCWJDI.js +0 -2089
  70. package/dist/production/route-data-CDwqkzPE.d.mts +0 -473
@@ -0,0 +1,1308 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
2
+ * react-router v0.0.0-experimental-31a822c5f
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+ var _chunkCZ7KRWQZjs = require('./chunk-CZ7KRWQZ.js');
52
+
53
+ // lib/dom/dom.ts
54
+ var defaultMethod = "get";
55
+ var defaultEncType = "application/x-www-form-urlencoded";
56
+ function isHtmlElement(object) {
57
+ return object != null && typeof object.tagName === "string";
58
+ }
59
+ function isButtonElement(object) {
60
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
61
+ }
62
+ function isFormElement(object) {
63
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
64
+ }
65
+ function isInputElement(object) {
66
+ return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
67
+ }
68
+ function isModifiedEvent(event) {
69
+ return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
70
+ }
71
+ function shouldProcessLinkClick(event, target) {
72
+ return event.button === 0 && // Ignore everything but left clicks
73
+ (!target || target === "_self") && // Let browser handle "target=_blank" etc.
74
+ !isModifiedEvent(event);
75
+ }
76
+ function createSearchParams(init = "") {
77
+ return new URLSearchParams(
78
+ typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
79
+ let value = init[key];
80
+ return memo.concat(
81
+ Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]
82
+ );
83
+ }, [])
84
+ );
85
+ }
86
+ function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
87
+ let searchParams = createSearchParams(locationSearch);
88
+ if (defaultSearchParams) {
89
+ defaultSearchParams.forEach((_, key) => {
90
+ if (!searchParams.has(key)) {
91
+ defaultSearchParams.getAll(key).forEach((value) => {
92
+ searchParams.append(key, value);
93
+ });
94
+ }
95
+ });
96
+ }
97
+ return searchParams;
98
+ }
99
+ var _formDataSupportsSubmitter = null;
100
+ function isFormDataSubmitterSupported() {
101
+ if (_formDataSupportsSubmitter === null) {
102
+ try {
103
+ new FormData(
104
+ document.createElement("form"),
105
+ // @ts-expect-error if FormData supports the submitter parameter, this will throw
106
+ 0
107
+ );
108
+ _formDataSupportsSubmitter = false;
109
+ } catch (e) {
110
+ _formDataSupportsSubmitter = true;
111
+ }
112
+ }
113
+ return _formDataSupportsSubmitter;
114
+ }
115
+ var supportedFormEncTypes = /* @__PURE__ */ new Set([
116
+ "application/x-www-form-urlencoded",
117
+ "multipart/form-data",
118
+ "text/plain"
119
+ ]);
120
+ function getFormEncType(encType) {
121
+ if (encType != null && !supportedFormEncTypes.has(encType)) {
122
+ _chunkCZ7KRWQZjs.warning.call(void 0,
123
+ false,
124
+ `"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
125
+ );
126
+ return null;
127
+ }
128
+ return encType;
129
+ }
130
+ function getFormSubmissionInfo(target, basename) {
131
+ let method;
132
+ let action;
133
+ let encType;
134
+ let formData;
135
+ let body;
136
+ if (isFormElement(target)) {
137
+ let attr = target.getAttribute("action");
138
+ action = attr ? _chunkCZ7KRWQZjs.stripBasename.call(void 0, attr, basename) : null;
139
+ method = target.getAttribute("method") || defaultMethod;
140
+ encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
141
+ formData = new FormData(target);
142
+ } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
143
+ let form = target.form;
144
+ if (form == null) {
145
+ throw new Error(
146
+ `Cannot submit a <button> or <input type="submit"> without a <form>`
147
+ );
148
+ }
149
+ let attr = target.getAttribute("formaction") || form.getAttribute("action");
150
+ action = attr ? _chunkCZ7KRWQZjs.stripBasename.call(void 0, attr, basename) : null;
151
+ method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
152
+ encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
153
+ formData = new FormData(form, target);
154
+ if (!isFormDataSubmitterSupported()) {
155
+ let { name, type, value } = target;
156
+ if (type === "image") {
157
+ let prefix = name ? `${name}.` : "";
158
+ formData.append(`${prefix}x`, "0");
159
+ formData.append(`${prefix}y`, "0");
160
+ } else if (name) {
161
+ formData.append(name, value);
162
+ }
163
+ }
164
+ } else if (isHtmlElement(target)) {
165
+ throw new Error(
166
+ `Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
167
+ );
168
+ } else {
169
+ method = defaultMethod;
170
+ action = null;
171
+ encType = defaultEncType;
172
+ body = target;
173
+ }
174
+ if (formData && encType === "text/plain") {
175
+ body = formData;
176
+ formData = void 0;
177
+ }
178
+ return { action, method: method.toLowerCase(), encType, formData, body };
179
+ }
180
+
181
+ // lib/dom/lib.tsx
182
+ var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
183
+ var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
184
+ try {
185
+ if (isBrowser) {
186
+ window.__reactRouterVersion = // @ts-expect-error
187
+ "0.0.0-experimental-31a822c5f";
188
+ }
189
+ } catch (e) {
190
+ }
191
+ function createBrowserRouter(routes, opts) {
192
+ return _chunkCZ7KRWQZjs.createRouter.call(void 0, {
193
+ basename: _optionalChain([opts, 'optionalAccess', _2 => _2.basename]),
194
+ getContext: _optionalChain([opts, 'optionalAccess', _3 => _3.getContext]),
195
+ future: _optionalChain([opts, 'optionalAccess', _4 => _4.future]),
196
+ history: _chunkCZ7KRWQZjs.createBrowserHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _5 => _5.window]) }),
197
+ hydrationData: _optionalChain([opts, 'optionalAccess', _6 => _6.hydrationData]) || parseHydrationData(),
198
+ routes,
199
+ mapRouteProperties: _chunkCZ7KRWQZjs.mapRouteProperties,
200
+ hydrationRouteProperties: _chunkCZ7KRWQZjs.hydrationRouteProperties,
201
+ dataStrategy: _optionalChain([opts, 'optionalAccess', _7 => _7.dataStrategy]),
202
+ patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _8 => _8.patchRoutesOnNavigation]),
203
+ window: _optionalChain([opts, 'optionalAccess', _9 => _9.window])
204
+ }).initialize();
205
+ }
206
+ function createHashRouter(routes, opts) {
207
+ return _chunkCZ7KRWQZjs.createRouter.call(void 0, {
208
+ basename: _optionalChain([opts, 'optionalAccess', _10 => _10.basename]),
209
+ getContext: _optionalChain([opts, 'optionalAccess', _11 => _11.getContext]),
210
+ future: _optionalChain([opts, 'optionalAccess', _12 => _12.future]),
211
+ history: _chunkCZ7KRWQZjs.createHashHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _13 => _13.window]) }),
212
+ hydrationData: _optionalChain([opts, 'optionalAccess', _14 => _14.hydrationData]) || parseHydrationData(),
213
+ routes,
214
+ mapRouteProperties: _chunkCZ7KRWQZjs.mapRouteProperties,
215
+ hydrationRouteProperties: _chunkCZ7KRWQZjs.hydrationRouteProperties,
216
+ dataStrategy: _optionalChain([opts, 'optionalAccess', _15 => _15.dataStrategy]),
217
+ patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _16 => _16.patchRoutesOnNavigation]),
218
+ window: _optionalChain([opts, 'optionalAccess', _17 => _17.window])
219
+ }).initialize();
220
+ }
221
+ function parseHydrationData() {
222
+ let state = _optionalChain([window, 'optionalAccess', _18 => _18.__staticRouterHydrationData]);
223
+ if (state && state.errors) {
224
+ state = {
225
+ ...state,
226
+ errors: deserializeErrors(state.errors)
227
+ };
228
+ }
229
+ return state;
230
+ }
231
+ function deserializeErrors(errors) {
232
+ if (!errors) return null;
233
+ let entries = Object.entries(errors);
234
+ let serialized = {};
235
+ for (let [key, val] of entries) {
236
+ if (val && val.__type === "RouteErrorResponse") {
237
+ serialized[key] = new (0, _chunkCZ7KRWQZjs.ErrorResponseImpl)(
238
+ val.status,
239
+ val.statusText,
240
+ val.data,
241
+ val.internal === true
242
+ );
243
+ } else if (val && val.__type === "Error") {
244
+ if (val.__subType) {
245
+ let ErrorConstructor = window[val.__subType];
246
+ if (typeof ErrorConstructor === "function") {
247
+ try {
248
+ let error = new ErrorConstructor(val.message);
249
+ error.stack = "";
250
+ serialized[key] = error;
251
+ } catch (e) {
252
+ }
253
+ }
254
+ }
255
+ if (serialized[key] == null) {
256
+ let error = new Error(val.message);
257
+ error.stack = "";
258
+ serialized[key] = error;
259
+ }
260
+ } else {
261
+ serialized[key] = val;
262
+ }
263
+ }
264
+ return serialized;
265
+ }
266
+ function BrowserRouter({
267
+ basename,
268
+ children,
269
+ window: window2
270
+ }) {
271
+ let historyRef = React.useRef();
272
+ if (historyRef.current == null) {
273
+ historyRef.current = _chunkCZ7KRWQZjs.createBrowserHistory.call(void 0, { window: window2, v5Compat: true });
274
+ }
275
+ let history = historyRef.current;
276
+ let [state, setStateImpl] = React.useState({
277
+ action: history.action,
278
+ location: history.location
279
+ });
280
+ let setState = React.useCallback(
281
+ (newState) => {
282
+ React.startTransition(() => setStateImpl(newState));
283
+ },
284
+ [setStateImpl]
285
+ );
286
+ React.useLayoutEffect(() => history.listen(setState), [history, setState]);
287
+ return /* @__PURE__ */ React.createElement(
288
+ _chunkCZ7KRWQZjs.Router,
289
+ {
290
+ basename,
291
+ children,
292
+ location: state.location,
293
+ navigationType: state.action,
294
+ navigator: history
295
+ }
296
+ );
297
+ }
298
+ function HashRouter({ basename, children, window: window2 }) {
299
+ let historyRef = React.useRef();
300
+ if (historyRef.current == null) {
301
+ historyRef.current = _chunkCZ7KRWQZjs.createHashHistory.call(void 0, { window: window2, v5Compat: true });
302
+ }
303
+ let history = historyRef.current;
304
+ let [state, setStateImpl] = React.useState({
305
+ action: history.action,
306
+ location: history.location
307
+ });
308
+ let setState = React.useCallback(
309
+ (newState) => {
310
+ React.startTransition(() => setStateImpl(newState));
311
+ },
312
+ [setStateImpl]
313
+ );
314
+ React.useLayoutEffect(() => history.listen(setState), [history, setState]);
315
+ return /* @__PURE__ */ React.createElement(
316
+ _chunkCZ7KRWQZjs.Router,
317
+ {
318
+ basename,
319
+ children,
320
+ location: state.location,
321
+ navigationType: state.action,
322
+ navigator: history
323
+ }
324
+ );
325
+ }
326
+ function HistoryRouter({
327
+ basename,
328
+ children,
329
+ history
330
+ }) {
331
+ let [state, setStateImpl] = React.useState({
332
+ action: history.action,
333
+ location: history.location
334
+ });
335
+ let setState = React.useCallback(
336
+ (newState) => {
337
+ React.startTransition(() => setStateImpl(newState));
338
+ },
339
+ [setStateImpl]
340
+ );
341
+ React.useLayoutEffect(() => history.listen(setState), [history, setState]);
342
+ return /* @__PURE__ */ React.createElement(
343
+ _chunkCZ7KRWQZjs.Router,
344
+ {
345
+ basename,
346
+ children,
347
+ location: state.location,
348
+ navigationType: state.action,
349
+ navigator: history
350
+ }
351
+ );
352
+ }
353
+ HistoryRouter.displayName = "unstable_HistoryRouter";
354
+ var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
355
+ var Link = React.forwardRef(
356
+ function LinkWithRef({
357
+ onClick,
358
+ discover = "render",
359
+ prefetch = "none",
360
+ relative,
361
+ reloadDocument,
362
+ replace,
363
+ state,
364
+ target,
365
+ to,
366
+ preventScrollReset,
367
+ viewTransition,
368
+ ...rest
369
+ }, forwardedRef) {
370
+ let { basename } = React.useContext(_chunkCZ7KRWQZjs.NavigationContext);
371
+ let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX.test(to);
372
+ let absoluteHref;
373
+ let isExternal = false;
374
+ if (typeof to === "string" && isAbsolute) {
375
+ absoluteHref = to;
376
+ if (isBrowser) {
377
+ try {
378
+ let currentUrl = new URL(window.location.href);
379
+ let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
380
+ let path = _chunkCZ7KRWQZjs.stripBasename.call(void 0, targetUrl.pathname, basename);
381
+ if (targetUrl.origin === currentUrl.origin && path != null) {
382
+ to = path + targetUrl.search + targetUrl.hash;
383
+ } else {
384
+ isExternal = true;
385
+ }
386
+ } catch (e) {
387
+ _chunkCZ7KRWQZjs.warning.call(void 0,
388
+ false,
389
+ `<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
390
+ );
391
+ }
392
+ }
393
+ }
394
+ let href = _chunkCZ7KRWQZjs.useHref.call(void 0, to, { relative });
395
+ let [shouldPrefetch, prefetchRef, prefetchHandlers] = _chunkCZ7KRWQZjs.usePrefetchBehavior.call(void 0,
396
+ prefetch,
397
+ rest
398
+ );
399
+ let internalOnClick = useLinkClickHandler(to, {
400
+ replace,
401
+ state,
402
+ target,
403
+ preventScrollReset,
404
+ relative,
405
+ viewTransition
406
+ });
407
+ function handleClick(event) {
408
+ if (onClick) onClick(event);
409
+ if (!event.defaultPrevented) {
410
+ internalOnClick(event);
411
+ }
412
+ }
413
+ let link = (
414
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
415
+ /* @__PURE__ */ React.createElement(
416
+ "a",
417
+ {
418
+ ...rest,
419
+ ...prefetchHandlers,
420
+ href: absoluteHref || href,
421
+ onClick: isExternal || reloadDocument ? onClick : handleClick,
422
+ ref: _chunkCZ7KRWQZjs.mergeRefs.call(void 0, forwardedRef, prefetchRef),
423
+ target,
424
+ "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
425
+ }
426
+ )
427
+ );
428
+ return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React.createElement(React.Fragment, null, link, /* @__PURE__ */ React.createElement(_chunkCZ7KRWQZjs.PrefetchPageLinks, { page: href })) : link;
429
+ }
430
+ );
431
+ Link.displayName = "Link";
432
+ var NavLink = React.forwardRef(
433
+ function NavLinkWithRef({
434
+ "aria-current": ariaCurrentProp = "page",
435
+ caseSensitive = false,
436
+ className: classNameProp = "",
437
+ end = false,
438
+ style: styleProp,
439
+ to,
440
+ viewTransition,
441
+ children,
442
+ ...rest
443
+ }, ref) {
444
+ let path = _chunkCZ7KRWQZjs.useResolvedPath.call(void 0, to, { relative: rest.relative });
445
+ let location = _chunkCZ7KRWQZjs.useLocation.call(void 0, );
446
+ let routerState = React.useContext(_chunkCZ7KRWQZjs.DataRouterStateContext);
447
+ let { navigator, basename } = React.useContext(_chunkCZ7KRWQZjs.NavigationContext);
448
+ let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
449
+ // eslint-disable-next-line react-hooks/rules-of-hooks
450
+ useViewTransitionState(path) && viewTransition === true;
451
+ let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
452
+ let locationPathname = location.pathname;
453
+ let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
454
+ if (!caseSensitive) {
455
+ locationPathname = locationPathname.toLowerCase();
456
+ nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
457
+ toPathname = toPathname.toLowerCase();
458
+ }
459
+ if (nextLocationPathname && basename) {
460
+ nextLocationPathname = _chunkCZ7KRWQZjs.stripBasename.call(void 0, nextLocationPathname, basename) || nextLocationPathname;
461
+ }
462
+ const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
463
+ let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
464
+ let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
465
+ let renderProps = {
466
+ isActive,
467
+ isPending,
468
+ isTransitioning
469
+ };
470
+ let ariaCurrent = isActive ? ariaCurrentProp : void 0;
471
+ let className;
472
+ if (typeof classNameProp === "function") {
473
+ className = classNameProp(renderProps);
474
+ } else {
475
+ className = [
476
+ classNameProp,
477
+ isActive ? "active" : null,
478
+ isPending ? "pending" : null,
479
+ isTransitioning ? "transitioning" : null
480
+ ].filter(Boolean).join(" ");
481
+ }
482
+ let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
483
+ return /* @__PURE__ */ React.createElement(
484
+ Link,
485
+ {
486
+ ...rest,
487
+ "aria-current": ariaCurrent,
488
+ className,
489
+ ref,
490
+ style,
491
+ to,
492
+ viewTransition
493
+ },
494
+ typeof children === "function" ? children(renderProps) : children
495
+ );
496
+ }
497
+ );
498
+ NavLink.displayName = "NavLink";
499
+ var Form = React.forwardRef(
500
+ ({
501
+ discover = "render",
502
+ fetcherKey,
503
+ navigate,
504
+ reloadDocument,
505
+ replace,
506
+ state,
507
+ method = defaultMethod,
508
+ action,
509
+ onSubmit,
510
+ relative,
511
+ preventScrollReset,
512
+ viewTransition,
513
+ ...props
514
+ }, forwardedRef) => {
515
+ let submit = useSubmit();
516
+ let formAction = useFormAction(action, { relative });
517
+ let formMethod = method.toLowerCase() === "get" ? "get" : "post";
518
+ let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX.test(action);
519
+ let submitHandler = (event) => {
520
+ onSubmit && onSubmit(event);
521
+ if (event.defaultPrevented) return;
522
+ event.preventDefault();
523
+ let submitter = event.nativeEvent.submitter;
524
+ let submitMethod = _optionalChain([submitter, 'optionalAccess', _19 => _19.getAttribute, 'call', _20 => _20("formmethod")]) || method;
525
+ submit(submitter || event.currentTarget, {
526
+ fetcherKey,
527
+ method: submitMethod,
528
+ navigate,
529
+ replace,
530
+ state,
531
+ relative,
532
+ preventScrollReset,
533
+ viewTransition
534
+ });
535
+ };
536
+ return /* @__PURE__ */ React.createElement(
537
+ "form",
538
+ {
539
+ ref: forwardedRef,
540
+ method: formMethod,
541
+ action: formAction,
542
+ onSubmit: reloadDocument ? onSubmit : submitHandler,
543
+ ...props,
544
+ "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
545
+ }
546
+ );
547
+ }
548
+ );
549
+ Form.displayName = "Form";
550
+ function ScrollRestoration({
551
+ getKey,
552
+ storageKey,
553
+ ...props
554
+ }) {
555
+ let remixContext = React.useContext(_chunkCZ7KRWQZjs.FrameworkContext);
556
+ let { basename } = React.useContext(_chunkCZ7KRWQZjs.NavigationContext);
557
+ let location = _chunkCZ7KRWQZjs.useLocation.call(void 0, );
558
+ let matches = _chunkCZ7KRWQZjs.useMatches.call(void 0, );
559
+ useScrollRestoration({ getKey, storageKey });
560
+ let ssrKey = React.useMemo(
561
+ () => {
562
+ if (!remixContext || !getKey) return null;
563
+ let userKey = getScrollRestorationKey(
564
+ location,
565
+ matches,
566
+ basename,
567
+ getKey
568
+ );
569
+ return userKey !== location.key ? userKey : null;
570
+ },
571
+ // Nah, we only need this the first time for the SSR render
572
+ // eslint-disable-next-line react-hooks/exhaustive-deps
573
+ []
574
+ );
575
+ if (!remixContext || remixContext.isSpaMode) {
576
+ return null;
577
+ }
578
+ let restoreScroll = ((storageKey2, restoreKey) => {
579
+ if (!window.history.state || !window.history.state.key) {
580
+ let key = Math.random().toString(32).slice(2);
581
+ window.history.replaceState({ key }, "");
582
+ }
583
+ try {
584
+ let positions = JSON.parse(sessionStorage.getItem(storageKey2) || "{}");
585
+ let storedY = positions[restoreKey || window.history.state.key];
586
+ if (typeof storedY === "number") {
587
+ window.scrollTo(0, storedY);
588
+ }
589
+ } catch (error) {
590
+ console.error(error);
591
+ sessionStorage.removeItem(storageKey2);
592
+ }
593
+ }).toString();
594
+ return /* @__PURE__ */ React.createElement(
595
+ "script",
596
+ {
597
+ ...props,
598
+ suppressHydrationWarning: true,
599
+ dangerouslySetInnerHTML: {
600
+ __html: `(${restoreScroll})(${JSON.stringify(
601
+ storageKey || SCROLL_RESTORATION_STORAGE_KEY
602
+ )}, ${JSON.stringify(ssrKey)})`
603
+ }
604
+ }
605
+ );
606
+ }
607
+ ScrollRestoration.displayName = "ScrollRestoration";
608
+ function getDataRouterConsoleError(hookName) {
609
+ return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
610
+ }
611
+ function useDataRouterContext(hookName) {
612
+ let ctx = React.useContext(_chunkCZ7KRWQZjs.DataRouterContext);
613
+ _chunkCZ7KRWQZjs.invariant.call(void 0, ctx, getDataRouterConsoleError(hookName));
614
+ return ctx;
615
+ }
616
+ function useDataRouterState(hookName) {
617
+ let state = React.useContext(_chunkCZ7KRWQZjs.DataRouterStateContext);
618
+ _chunkCZ7KRWQZjs.invariant.call(void 0, state, getDataRouterConsoleError(hookName));
619
+ return state;
620
+ }
621
+ function useLinkClickHandler(to, {
622
+ target,
623
+ replace: replaceProp,
624
+ state,
625
+ preventScrollReset,
626
+ relative,
627
+ viewTransition
628
+ } = {}) {
629
+ let navigate = _chunkCZ7KRWQZjs.useNavigate.call(void 0, );
630
+ let location = _chunkCZ7KRWQZjs.useLocation.call(void 0, );
631
+ let path = _chunkCZ7KRWQZjs.useResolvedPath.call(void 0, to, { relative });
632
+ return React.useCallback(
633
+ (event) => {
634
+ if (shouldProcessLinkClick(event, target)) {
635
+ event.preventDefault();
636
+ let replace = replaceProp !== void 0 ? replaceProp : _chunkCZ7KRWQZjs.createPath.call(void 0, location) === _chunkCZ7KRWQZjs.createPath.call(void 0, path);
637
+ navigate(to, {
638
+ replace,
639
+ state,
640
+ preventScrollReset,
641
+ relative,
642
+ viewTransition
643
+ });
644
+ }
645
+ },
646
+ [
647
+ location,
648
+ navigate,
649
+ path,
650
+ replaceProp,
651
+ state,
652
+ target,
653
+ to,
654
+ preventScrollReset,
655
+ relative,
656
+ viewTransition
657
+ ]
658
+ );
659
+ }
660
+ function useSearchParams(defaultInit) {
661
+ _chunkCZ7KRWQZjs.warning.call(void 0,
662
+ typeof URLSearchParams !== "undefined",
663
+ `You cannot use the \`useSearchParams\` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.`
664
+ );
665
+ let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));
666
+ let hasSetSearchParamsRef = React.useRef(false);
667
+ let location = _chunkCZ7KRWQZjs.useLocation.call(void 0, );
668
+ let searchParams = React.useMemo(
669
+ () => (
670
+ // Only merge in the defaults if we haven't yet called setSearchParams.
671
+ // Once we call that we want those to take precedence, otherwise you can't
672
+ // remove a param with setSearchParams({}) if it has an initial value
673
+ getSearchParamsForLocation(
674
+ location.search,
675
+ hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
676
+ )
677
+ ),
678
+ [location.search]
679
+ );
680
+ let navigate = _chunkCZ7KRWQZjs.useNavigate.call(void 0, );
681
+ let setSearchParams = React.useCallback(
682
+ (nextInit, navigateOptions) => {
683
+ const newSearchParams = createSearchParams(
684
+ typeof nextInit === "function" ? nextInit(new URLSearchParams(searchParams)) : nextInit
685
+ );
686
+ hasSetSearchParamsRef.current = true;
687
+ navigate("?" + newSearchParams, navigateOptions);
688
+ },
689
+ [navigate, searchParams]
690
+ );
691
+ return [searchParams, setSearchParams];
692
+ }
693
+ var fetcherId = 0;
694
+ var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
695
+ function useSubmit() {
696
+ let { router } = useDataRouterContext("useSubmit" /* UseSubmit */);
697
+ let { basename } = React.useContext(_chunkCZ7KRWQZjs.NavigationContext);
698
+ let currentRouteId = _chunkCZ7KRWQZjs.useRouteId.call(void 0, );
699
+ return React.useCallback(
700
+ async (target, options = {}) => {
701
+ let { action, method, encType, formData, body } = getFormSubmissionInfo(
702
+ target,
703
+ basename
704
+ );
705
+ if (options.navigate === false) {
706
+ let key = options.fetcherKey || getUniqueFetcherId();
707
+ await router.fetch(key, currentRouteId, options.action || action, {
708
+ preventScrollReset: options.preventScrollReset,
709
+ formData,
710
+ body,
711
+ formMethod: options.method || method,
712
+ formEncType: options.encType || encType,
713
+ flushSync: options.flushSync
714
+ });
715
+ } else {
716
+ await router.navigate(options.action || action, {
717
+ preventScrollReset: options.preventScrollReset,
718
+ formData,
719
+ body,
720
+ formMethod: options.method || method,
721
+ formEncType: options.encType || encType,
722
+ replace: options.replace,
723
+ state: options.state,
724
+ fromRouteId: currentRouteId,
725
+ flushSync: options.flushSync,
726
+ viewTransition: options.viewTransition
727
+ });
728
+ }
729
+ },
730
+ [router, basename, currentRouteId]
731
+ );
732
+ }
733
+ function useFormAction(action, { relative } = {}) {
734
+ let { basename } = React.useContext(_chunkCZ7KRWQZjs.NavigationContext);
735
+ let routeContext = React.useContext(_chunkCZ7KRWQZjs.RouteContext);
736
+ _chunkCZ7KRWQZjs.invariant.call(void 0, routeContext, "useFormAction must be used inside a RouteContext");
737
+ let [match] = routeContext.matches.slice(-1);
738
+ let path = { ..._chunkCZ7KRWQZjs.useResolvedPath.call(void 0, action ? action : ".", { relative }) };
739
+ let location = _chunkCZ7KRWQZjs.useLocation.call(void 0, );
740
+ if (action == null) {
741
+ path.search = location.search;
742
+ let params = new URLSearchParams(path.search);
743
+ let indexValues = params.getAll("index");
744
+ let hasNakedIndexParam = indexValues.some((v) => v === "");
745
+ if (hasNakedIndexParam) {
746
+ params.delete("index");
747
+ indexValues.filter((v) => v).forEach((v) => params.append("index", v));
748
+ let qs = params.toString();
749
+ path.search = qs ? `?${qs}` : "";
750
+ }
751
+ }
752
+ if ((!action || action === ".") && match.route.index) {
753
+ path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
754
+ }
755
+ if (basename !== "/") {
756
+ path.pathname = path.pathname === "/" ? basename : _chunkCZ7KRWQZjs.joinPaths.call(void 0, [basename, path.pathname]);
757
+ }
758
+ return _chunkCZ7KRWQZjs.createPath.call(void 0, path);
759
+ }
760
+ function useFetcher({
761
+ key
762
+ } = {}) {
763
+ let { router } = useDataRouterContext("useFetcher" /* UseFetcher */);
764
+ let state = useDataRouterState("useFetcher" /* UseFetcher */);
765
+ let fetcherData = React.useContext(_chunkCZ7KRWQZjs.FetchersContext);
766
+ let route = React.useContext(_chunkCZ7KRWQZjs.RouteContext);
767
+ let routeId = _optionalChain([route, 'access', _21 => _21.matches, 'access', _22 => _22[route.matches.length - 1], 'optionalAccess', _23 => _23.route, 'access', _24 => _24.id]);
768
+ _chunkCZ7KRWQZjs.invariant.call(void 0, fetcherData, `useFetcher must be used inside a FetchersContext`);
769
+ _chunkCZ7KRWQZjs.invariant.call(void 0, route, `useFetcher must be used inside a RouteContext`);
770
+ _chunkCZ7KRWQZjs.invariant.call(void 0,
771
+ routeId != null,
772
+ `useFetcher can only be used on routes that contain a unique "id"`
773
+ );
774
+ let defaultKey = React.useId();
775
+ let [fetcherKey, setFetcherKey] = React.useState(key || defaultKey);
776
+ if (key && key !== fetcherKey) {
777
+ setFetcherKey(key);
778
+ }
779
+ React.useEffect(() => {
780
+ router.getFetcher(fetcherKey);
781
+ return () => router.deleteFetcher(fetcherKey);
782
+ }, [router, fetcherKey]);
783
+ let load = React.useCallback(
784
+ async (href, opts) => {
785
+ _chunkCZ7KRWQZjs.invariant.call(void 0, routeId, "No routeId available for fetcher.load()");
786
+ await router.fetch(fetcherKey, routeId, href, opts);
787
+ },
788
+ [fetcherKey, routeId, router]
789
+ );
790
+ let submitImpl = useSubmit();
791
+ let submit = React.useCallback(
792
+ async (target, opts) => {
793
+ await submitImpl(target, {
794
+ ...opts,
795
+ navigate: false,
796
+ fetcherKey
797
+ });
798
+ },
799
+ [fetcherKey, submitImpl]
800
+ );
801
+ let unstable_reset = React.useCallback((opts) => router.resetFetcher(fetcherKey, opts), [router, fetcherKey]);
802
+ let FetcherForm = React.useMemo(() => {
803
+ let FetcherForm2 = React.forwardRef(
804
+ (props, ref) => {
805
+ return /* @__PURE__ */ React.createElement(Form, { ...props, navigate: false, fetcherKey, ref });
806
+ }
807
+ );
808
+ FetcherForm2.displayName = "fetcher.Form";
809
+ return FetcherForm2;
810
+ }, [fetcherKey]);
811
+ let fetcher = state.fetchers.get(fetcherKey) || _chunkCZ7KRWQZjs.IDLE_FETCHER;
812
+ let data = fetcherData.get(fetcherKey);
813
+ let fetcherWithComponents = React.useMemo(
814
+ () => ({
815
+ Form: FetcherForm,
816
+ submit,
817
+ load,
818
+ unstable_reset,
819
+ ...fetcher,
820
+ data
821
+ }),
822
+ [FetcherForm, submit, load, unstable_reset, fetcher, data]
823
+ );
824
+ return fetcherWithComponents;
825
+ }
826
+ function useFetchers() {
827
+ let state = useDataRouterState("useFetchers" /* UseFetchers */);
828
+ return Array.from(state.fetchers.entries()).map(([key, fetcher]) => ({
829
+ ...fetcher,
830
+ key
831
+ }));
832
+ }
833
+ var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
834
+ var savedScrollPositions = {};
835
+ function getScrollRestorationKey(location, matches, basename, getKey) {
836
+ let key = null;
837
+ if (getKey) {
838
+ if (basename !== "/") {
839
+ key = getKey(
840
+ {
841
+ ...location,
842
+ pathname: _chunkCZ7KRWQZjs.stripBasename.call(void 0, location.pathname, basename) || location.pathname
843
+ },
844
+ matches
845
+ );
846
+ } else {
847
+ key = getKey(location, matches);
848
+ }
849
+ }
850
+ if (key == null) {
851
+ key = location.key;
852
+ }
853
+ return key;
854
+ }
855
+ function useScrollRestoration({
856
+ getKey,
857
+ storageKey
858
+ } = {}) {
859
+ let { router } = useDataRouterContext("useScrollRestoration" /* UseScrollRestoration */);
860
+ let { restoreScrollPosition, preventScrollReset } = useDataRouterState(
861
+ "useScrollRestoration" /* UseScrollRestoration */
862
+ );
863
+ let { basename } = React.useContext(_chunkCZ7KRWQZjs.NavigationContext);
864
+ let location = _chunkCZ7KRWQZjs.useLocation.call(void 0, );
865
+ let matches = _chunkCZ7KRWQZjs.useMatches.call(void 0, );
866
+ let navigation = _chunkCZ7KRWQZjs.useNavigation.call(void 0, );
867
+ React.useEffect(() => {
868
+ window.history.scrollRestoration = "manual";
869
+ return () => {
870
+ window.history.scrollRestoration = "auto";
871
+ };
872
+ }, []);
873
+ usePageHide(
874
+ React.useCallback(() => {
875
+ if (navigation.state === "idle") {
876
+ let key = getScrollRestorationKey(location, matches, basename, getKey);
877
+ savedScrollPositions[key] = window.scrollY;
878
+ }
879
+ try {
880
+ sessionStorage.setItem(
881
+ storageKey || SCROLL_RESTORATION_STORAGE_KEY,
882
+ JSON.stringify(savedScrollPositions)
883
+ );
884
+ } catch (error) {
885
+ _chunkCZ7KRWQZjs.warning.call(void 0,
886
+ false,
887
+ `Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${error}).`
888
+ );
889
+ }
890
+ window.history.scrollRestoration = "auto";
891
+ }, [navigation.state, getKey, basename, location, matches, storageKey])
892
+ );
893
+ if (typeof document !== "undefined") {
894
+ React.useLayoutEffect(() => {
895
+ try {
896
+ let sessionPositions = sessionStorage.getItem(
897
+ storageKey || SCROLL_RESTORATION_STORAGE_KEY
898
+ );
899
+ if (sessionPositions) {
900
+ savedScrollPositions = JSON.parse(sessionPositions);
901
+ }
902
+ } catch (e) {
903
+ }
904
+ }, [storageKey]);
905
+ React.useLayoutEffect(() => {
906
+ let disableScrollRestoration = _optionalChain([router, 'optionalAccess', _25 => _25.enableScrollRestoration, 'call', _26 => _26(
907
+ savedScrollPositions,
908
+ () => window.scrollY,
909
+ getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
910
+ )]);
911
+ return () => disableScrollRestoration && disableScrollRestoration();
912
+ }, [router, basename, getKey]);
913
+ React.useLayoutEffect(() => {
914
+ if (restoreScrollPosition === false) {
915
+ return;
916
+ }
917
+ if (typeof restoreScrollPosition === "number") {
918
+ window.scrollTo(0, restoreScrollPosition);
919
+ return;
920
+ }
921
+ try {
922
+ if (location.hash) {
923
+ let el = document.getElementById(
924
+ decodeURIComponent(location.hash.slice(1))
925
+ );
926
+ if (el) {
927
+ el.scrollIntoView();
928
+ return;
929
+ }
930
+ }
931
+ } catch (e2) {
932
+ _chunkCZ7KRWQZjs.warning.call(void 0,
933
+ false,
934
+ `"${location.hash.slice(
935
+ 1
936
+ )}" is not a decodable element ID. The view will not scroll to it.`
937
+ );
938
+ }
939
+ if (preventScrollReset === true) {
940
+ return;
941
+ }
942
+ window.scrollTo(0, 0);
943
+ }, [location, restoreScrollPosition, preventScrollReset]);
944
+ }
945
+ }
946
+ function useBeforeUnload(callback, options) {
947
+ let { capture } = options || {};
948
+ React.useEffect(() => {
949
+ let opts = capture != null ? { capture } : void 0;
950
+ window.addEventListener("beforeunload", callback, opts);
951
+ return () => {
952
+ window.removeEventListener("beforeunload", callback, opts);
953
+ };
954
+ }, [callback, capture]);
955
+ }
956
+ function usePageHide(callback, options) {
957
+ let { capture } = options || {};
958
+ React.useEffect(() => {
959
+ let opts = capture != null ? { capture } : void 0;
960
+ window.addEventListener("pagehide", callback, opts);
961
+ return () => {
962
+ window.removeEventListener("pagehide", callback, opts);
963
+ };
964
+ }, [callback, capture]);
965
+ }
966
+ function usePrompt({
967
+ when,
968
+ message
969
+ }) {
970
+ let blocker = _chunkCZ7KRWQZjs.useBlocker.call(void 0, when);
971
+ React.useEffect(() => {
972
+ if (blocker.state === "blocked") {
973
+ let proceed = window.confirm(message);
974
+ if (proceed) {
975
+ setTimeout(blocker.proceed, 0);
976
+ } else {
977
+ blocker.reset();
978
+ }
979
+ }
980
+ }, [blocker, message]);
981
+ React.useEffect(() => {
982
+ if (blocker.state === "blocked" && !when) {
983
+ blocker.reset();
984
+ }
985
+ }, [blocker, when]);
986
+ }
987
+ function useViewTransitionState(to, { relative } = {}) {
988
+ let vtContext = React.useContext(_chunkCZ7KRWQZjs.ViewTransitionContext);
989
+ _chunkCZ7KRWQZjs.invariant.call(void 0,
990
+ vtContext != null,
991
+ "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
992
+ );
993
+ let { basename } = useDataRouterContext(
994
+ "useViewTransitionState" /* useViewTransitionState */
995
+ );
996
+ let path = _chunkCZ7KRWQZjs.useResolvedPath.call(void 0, to, { relative });
997
+ if (!vtContext.isTransitioning) {
998
+ return false;
999
+ }
1000
+ let currentPath = _chunkCZ7KRWQZjs.stripBasename.call(void 0, vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
1001
+ let nextPath = _chunkCZ7KRWQZjs.stripBasename.call(void 0, vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
1002
+ return _chunkCZ7KRWQZjs.matchPath.call(void 0, path.pathname, nextPath) != null || _chunkCZ7KRWQZjs.matchPath.call(void 0, path.pathname, currentPath) != null;
1003
+ }
1004
+
1005
+ // lib/dom/server.tsx
1006
+
1007
+ function StaticRouter({
1008
+ basename,
1009
+ children,
1010
+ location: locationProp = "/"
1011
+ }) {
1012
+ if (typeof locationProp === "string") {
1013
+ locationProp = _chunkCZ7KRWQZjs.parsePath.call(void 0, locationProp);
1014
+ }
1015
+ let action = "POP" /* Pop */;
1016
+ let location = {
1017
+ pathname: locationProp.pathname || "/",
1018
+ search: locationProp.search || "",
1019
+ hash: locationProp.hash || "",
1020
+ state: locationProp.state != null ? locationProp.state : null,
1021
+ key: locationProp.key || "default"
1022
+ };
1023
+ let staticNavigator = getStatelessNavigator();
1024
+ return /* @__PURE__ */ React2.createElement(
1025
+ _chunkCZ7KRWQZjs.Router,
1026
+ {
1027
+ basename,
1028
+ children,
1029
+ location,
1030
+ navigationType: action,
1031
+ navigator: staticNavigator,
1032
+ static: true
1033
+ }
1034
+ );
1035
+ }
1036
+ function StaticRouterProvider({
1037
+ context,
1038
+ router,
1039
+ hydrate = true,
1040
+ nonce
1041
+ }) {
1042
+ _chunkCZ7KRWQZjs.invariant.call(void 0,
1043
+ router && context,
1044
+ "You must provide `router` and `context` to <StaticRouterProvider>"
1045
+ );
1046
+ let dataRouterContext = {
1047
+ router,
1048
+ navigator: getStatelessNavigator(),
1049
+ static: true,
1050
+ staticContext: context,
1051
+ basename: context.basename || "/"
1052
+ };
1053
+ let fetchersContext = /* @__PURE__ */ new Map();
1054
+ let hydrateScript = "";
1055
+ if (hydrate !== false) {
1056
+ let data = {
1057
+ loaderData: context.loaderData,
1058
+ actionData: context.actionData,
1059
+ errors: serializeErrors(context.errors)
1060
+ };
1061
+ let json = htmlEscape(JSON.stringify(JSON.stringify(data)));
1062
+ hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`;
1063
+ }
1064
+ let { state } = dataRouterContext.router;
1065
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(_chunkCZ7KRWQZjs.DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React2.createElement(_chunkCZ7KRWQZjs.DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React2.createElement(_chunkCZ7KRWQZjs.FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React2.createElement(_chunkCZ7KRWQZjs.ViewTransitionContext.Provider, { value: { isTransitioning: false } }, /* @__PURE__ */ React2.createElement(
1066
+ _chunkCZ7KRWQZjs.Router,
1067
+ {
1068
+ basename: dataRouterContext.basename,
1069
+ location: state.location,
1070
+ navigationType: state.historyAction,
1071
+ navigator: dataRouterContext.navigator,
1072
+ static: dataRouterContext.static
1073
+ },
1074
+ /* @__PURE__ */ React2.createElement(
1075
+ DataRoutes,
1076
+ {
1077
+ routes: router.routes,
1078
+ future: router.future,
1079
+ state
1080
+ }
1081
+ )
1082
+ ))))), hydrateScript ? /* @__PURE__ */ React2.createElement(
1083
+ "script",
1084
+ {
1085
+ suppressHydrationWarning: true,
1086
+ nonce,
1087
+ dangerouslySetInnerHTML: { __html: hydrateScript }
1088
+ }
1089
+ ) : null);
1090
+ }
1091
+ function DataRoutes({
1092
+ routes,
1093
+ future,
1094
+ state
1095
+ }) {
1096
+ return _chunkCZ7KRWQZjs.useRoutesImpl.call(void 0, routes, void 0, state, void 0, future);
1097
+ }
1098
+ function serializeErrors(errors) {
1099
+ if (!errors) return null;
1100
+ let entries = Object.entries(errors);
1101
+ let serialized = {};
1102
+ for (let [key, val] of entries) {
1103
+ if (_chunkCZ7KRWQZjs.isRouteErrorResponse.call(void 0, val)) {
1104
+ serialized[key] = { ...val, __type: "RouteErrorResponse" };
1105
+ } else if (val instanceof Error) {
1106
+ serialized[key] = {
1107
+ message: val.message,
1108
+ __type: "Error",
1109
+ // If this is a subclass (i.e., ReferenceError), send up the type so we
1110
+ // can re-create the same type during hydration.
1111
+ ...val.name !== "Error" ? {
1112
+ __subType: val.name
1113
+ } : {}
1114
+ };
1115
+ } else {
1116
+ serialized[key] = val;
1117
+ }
1118
+ }
1119
+ return serialized;
1120
+ }
1121
+ function getStatelessNavigator() {
1122
+ return {
1123
+ createHref,
1124
+ encodeLocation,
1125
+ push(to) {
1126
+ throw new Error(
1127
+ `You cannot use navigator.push() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(to)})\` somewhere in your app.`
1128
+ );
1129
+ },
1130
+ replace(to) {
1131
+ throw new Error(
1132
+ `You cannot use navigator.replace() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(to)}, { replace: true })\` somewhere in your app.`
1133
+ );
1134
+ },
1135
+ go(delta) {
1136
+ throw new Error(
1137
+ `You cannot use navigator.go() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${delta})\` somewhere in your app.`
1138
+ );
1139
+ },
1140
+ back() {
1141
+ throw new Error(
1142
+ `You cannot use navigator.back() on the server because it is a stateless environment.`
1143
+ );
1144
+ },
1145
+ forward() {
1146
+ throw new Error(
1147
+ `You cannot use navigator.forward() on the server because it is a stateless environment.`
1148
+ );
1149
+ }
1150
+ };
1151
+ }
1152
+ function createStaticHandler2(routes, opts) {
1153
+ return _chunkCZ7KRWQZjs.createStaticHandler.call(void 0, routes, {
1154
+ ...opts,
1155
+ mapRouteProperties: _chunkCZ7KRWQZjs.mapRouteProperties
1156
+ });
1157
+ }
1158
+ function createStaticRouter(routes, context, opts = {}) {
1159
+ let manifest = {};
1160
+ let dataRoutes = _chunkCZ7KRWQZjs.convertRoutesToDataRoutes.call(void 0,
1161
+ routes,
1162
+ _chunkCZ7KRWQZjs.mapRouteProperties,
1163
+ void 0,
1164
+ manifest
1165
+ );
1166
+ let matches = context.matches.map((match) => {
1167
+ let route = manifest[match.route.id] || match.route;
1168
+ return {
1169
+ ...match,
1170
+ route
1171
+ };
1172
+ });
1173
+ let msg = (method) => `You cannot use router.${method}() on the server because it is a stateless environment`;
1174
+ return {
1175
+ get basename() {
1176
+ return context.basename;
1177
+ },
1178
+ get future() {
1179
+ return {
1180
+ v8_middleware: false,
1181
+ ..._optionalChain([opts, 'optionalAccess', _27 => _27.future])
1182
+ };
1183
+ },
1184
+ get state() {
1185
+ return {
1186
+ historyAction: "POP" /* Pop */,
1187
+ location: context.location,
1188
+ matches,
1189
+ loaderData: context.loaderData,
1190
+ actionData: context.actionData,
1191
+ errors: context.errors,
1192
+ initialized: true,
1193
+ navigation: _chunkCZ7KRWQZjs.IDLE_NAVIGATION,
1194
+ restoreScrollPosition: null,
1195
+ preventScrollReset: false,
1196
+ revalidation: "idle",
1197
+ fetchers: /* @__PURE__ */ new Map(),
1198
+ blockers: /* @__PURE__ */ new Map()
1199
+ };
1200
+ },
1201
+ get routes() {
1202
+ return dataRoutes;
1203
+ },
1204
+ get window() {
1205
+ return void 0;
1206
+ },
1207
+ initialize() {
1208
+ throw msg("initialize");
1209
+ },
1210
+ subscribe() {
1211
+ throw msg("subscribe");
1212
+ },
1213
+ enableScrollRestoration() {
1214
+ throw msg("enableScrollRestoration");
1215
+ },
1216
+ navigate() {
1217
+ throw msg("navigate");
1218
+ },
1219
+ fetch() {
1220
+ throw msg("fetch");
1221
+ },
1222
+ revalidate() {
1223
+ throw msg("revalidate");
1224
+ },
1225
+ createHref,
1226
+ encodeLocation,
1227
+ getFetcher() {
1228
+ return _chunkCZ7KRWQZjs.IDLE_FETCHER;
1229
+ },
1230
+ deleteFetcher() {
1231
+ throw msg("deleteFetcher");
1232
+ },
1233
+ resetFetcher() {
1234
+ throw msg("resetFetcher");
1235
+ },
1236
+ dispose() {
1237
+ throw msg("dispose");
1238
+ },
1239
+ getBlocker() {
1240
+ return _chunkCZ7KRWQZjs.IDLE_BLOCKER;
1241
+ },
1242
+ deleteBlocker() {
1243
+ throw msg("deleteBlocker");
1244
+ },
1245
+ patchRoutes() {
1246
+ throw msg("patchRoutes");
1247
+ },
1248
+ _internalFetchControllers: /* @__PURE__ */ new Map(),
1249
+ _internalSetRoutes() {
1250
+ throw msg("_internalSetRoutes");
1251
+ },
1252
+ _internalSetStateDoNotUseOrYouWillBreakYourApp() {
1253
+ throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
1254
+ }
1255
+ };
1256
+ }
1257
+ function createHref(to) {
1258
+ return typeof to === "string" ? to : _chunkCZ7KRWQZjs.createPath.call(void 0, to);
1259
+ }
1260
+ function encodeLocation(to) {
1261
+ let href = typeof to === "string" ? to : _chunkCZ7KRWQZjs.createPath.call(void 0, to);
1262
+ href = href.replace(/ $/, "%20");
1263
+ let encoded = ABSOLUTE_URL_REGEX2.test(href) ? new URL(href) : new URL(href, "http://localhost");
1264
+ return {
1265
+ pathname: encoded.pathname,
1266
+ search: encoded.search,
1267
+ hash: encoded.hash
1268
+ };
1269
+ }
1270
+ var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
1271
+ var ESCAPE_LOOKUP = {
1272
+ "&": "\\u0026",
1273
+ ">": "\\u003e",
1274
+ "<": "\\u003c",
1275
+ "\u2028": "\\u2028",
1276
+ "\u2029": "\\u2029"
1277
+ };
1278
+ var ESCAPE_REGEX = /[&><\u2028\u2029]/g;
1279
+ function htmlEscape(str) {
1280
+ return str.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
1281
+ }
1282
+
1283
+
1284
+
1285
+
1286
+
1287
+
1288
+
1289
+
1290
+
1291
+
1292
+
1293
+
1294
+
1295
+
1296
+
1297
+
1298
+
1299
+
1300
+
1301
+
1302
+
1303
+
1304
+
1305
+
1306
+
1307
+
1308
+ exports.createSearchParams = createSearchParams; exports.createBrowserRouter = createBrowserRouter; exports.createHashRouter = createHashRouter; exports.BrowserRouter = BrowserRouter; exports.HashRouter = HashRouter; exports.HistoryRouter = HistoryRouter; exports.Link = Link; exports.NavLink = NavLink; exports.Form = Form; exports.ScrollRestoration = ScrollRestoration; exports.useLinkClickHandler = useLinkClickHandler; exports.useSearchParams = useSearchParams; exports.useSubmit = useSubmit; exports.useFormAction = useFormAction; exports.useFetcher = useFetcher; exports.useFetchers = useFetchers; exports.useScrollRestoration = useScrollRestoration; exports.useBeforeUnload = useBeforeUnload; exports.usePrompt = usePrompt; exports.useViewTransitionState = useViewTransitionState; exports.StaticRouter = StaticRouter; exports.StaticRouterProvider = StaticRouterProvider; exports.createStaticHandler = createStaticHandler2; exports.createStaticRouter = createStaticRouter;