useblocks 1.1.46 → 1.1.53

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 (82) hide show
  1. package/iframe/js/amp.BP7EklKo.js +1 -0
  2. package/iframe/js/iframe-eblock.js +1 -1
  3. package/iframe/js/iframe.js +1 -1
  4. package/iframe/js/rules.4N5s3OV-.js +1 -1
  5. package/monacoeditorwork/css.worker.bundle.js +40524 -40442
  6. package/monacoeditorwork/editor.worker.bundle.js +9740 -9697
  7. package/monacoeditorwork/html.worker.bundle.js +50513 -50431
  8. package/monacoeditorwork/json.worker.bundle.js +14570 -14527
  9. package/monacoeditorwork/ts.worker.bundle.js +119593 -119455
  10. package/npm-publish.manifest.json +7 -7
  11. package/package.json +1 -1
  12. package/runtime/@ant-design/cssinjs/index.js +1 -1
  13. package/runtime/@ant-design/icons/index.js +2 -2
  14. package/runtime/README.md +1 -1
  15. package/runtime/THIRD_PARTY_LICENSES.txt +71 -43
  16. package/runtime/antd/index.js +1 -1
  17. package/runtime/react/index.js +3 -3
  18. package/runtime/react/jsx-runtime/index.js +1 -1
  19. package/runtime/react-dom/client/index.js +4 -4
  20. package/runtime/react-dom/index.js +3 -3
  21. package/runtime/react-router-dom/index.js +2 -2
  22. package/singlepage_headless_plugin.html +1 -1
  23. package/static/core/{6b8432a3.js → 139e4380.js} +3 -3
  24. package/static/core/{90ec6d2b2.js → 1995fb0a2.js} +182 -153
  25. package/static/core/{6df04323.js → 1f5e1fc9.js} +573 -554
  26. package/static/core/31e98e6e.js +2095 -0
  27. package/static/core/5318562c.js +924 -0
  28. package/static/core/{6e2d88d5.js → 75737a9d.js} +6209 -6155
  29. package/static/core/{cc8f145d.js → 9929a348.js} +64 -64
  30. package/static/core/b408f33a.js +655 -0
  31. package/static/core/{526b23c2.js → bc7e3d2b.js} +7 -7
  32. package/static/core/{4eb628d3.js → c3058168.js} +3958 -3702
  33. package/static/core/ce0410b1.js +467 -0
  34. package/static/core/{b9529b8a.js → d1eb3c68.js} +17060 -16835
  35. package/static/core/{b8b730b2.js → dc1f9e4f.js} +17 -17
  36. package/static/core/{4a2af478.js → e1d239ab.js} +41 -41
  37. package/static/core/{9c1c1b89.js → e5e07f1d.js} +856 -755
  38. package/static/core/{350eac23.js → ebd852b6.js} +1756 -1702
  39. package/static/core/{cefd6620.js → ee0ddb51.js} +7782 -6601
  40. package/static/core/{a321a57d.js → f3cff4c9.js} +159 -159
  41. package/static/esm/{dab4cdfd.js → 448d4bb0.js} +70 -70
  42. package/static/esm/{7c5227f0.js → d180c108.js} +50 -47
  43. package/static/runtime/{DownloadOutlined-CgJ8OpH_.js → DownloadOutlined-Dg_G2xO7.js} +4 -4
  44. package/static/runtime/client-CfXgU5Vo.js +7580 -0
  45. package/static/runtime/{defineProperty-B-FyVNQF.js → defineProperty-C_9hhJHt.js} +1 -1
  46. package/static/runtime/dom-export-CHgQ7Ws9.js +8069 -0
  47. package/static/runtime/{es-DnZp8dh1.js → es-BPfImJ0x.js} +5 -5
  48. package/static/runtime/{es-B2DS-PLP.js → es-DcH6fwd6.js} +2 -2
  49. package/static/runtime/{es-deqzngIL.js → es-_OY-D9g1.js} +2 -2
  50. package/static/runtime/{jsx-dev-runtime-Wj1_6O79.js → jsx-dev-runtime-DDukXY54.js} +2 -2
  51. package/static/runtime/jsx-runtime-BodCQYDg.js +22 -0
  52. package/static/runtime/react-BHNx_xzv.js +290 -0
  53. package/static/runtime/react-dom-CyByzibb.js +127 -0
  54. package/two_step_headless_plugin.html +1 -1
  55. package/ui-kit/index.js +49 -47
  56. package/{useblocks-core.2116f1b9.js → useblocks-core.2a5dade1.js} +82 -76
  57. package/useblocks-esm.js +628 -3198
  58. package/useblocks.d.ts +184 -52
  59. package/useblocks.js +818 -12588
  60. package/vite/index.cjs +46 -21
  61. package/vite/index.d.ts +0 -1
  62. package/vite/index.js +46 -21
  63. package/vite/pluginDev/index.d.ts +0 -1
  64. package/webpack/index.cjs +46 -21
  65. package/webpack/index.d.ts +0 -1
  66. package/webpack/index.js +46 -21
  67. package/webpack/pluginDev/index.d.ts +0 -1
  68. package/iframe/js/amp.CVC2Iq48.js +0 -1
  69. package/static/core/35e13192.js +0 -463
  70. package/static/core/9421a704.js +0 -869
  71. package/static/core/9c79239d.js +0 -2063
  72. package/static/core/df0652cc.js +0 -1119
  73. package/static/esm/2fb07398.js +0 -3480
  74. package/static/esm/352121c5.js +0 -55
  75. package/static/esm/64966e1c.js +0 -18
  76. package/static/runtime/client-CM3WFcip.js +0 -7
  77. package/static/runtime/dist-DUS42Hru.js +0 -3421
  78. package/static/runtime/jsx-runtime-DmPQfqtr.js +0 -28
  79. package/static/runtime/react-DIf5CLST.js +0 -258
  80. package/static/runtime/react-dom-Cc3IcUkg.js +0 -5604
  81. /package/iframe/{iframe-eblock.2116f1b9.html → iframe-eblock.2a5dade1.html} +0 -0
  82. /package/iframe/{iframe.2116f1b9.html → iframe.2a5dade1.html} +0 -0
@@ -1,3421 +0,0 @@
1
- import { n as Xa, r as $r } from "./rolldown-runtime-Bklm4c_g.js";
2
- import { t as Qa } from "./react-DIf5CLST.js";
3
- import { t as Za } from "./react-dom-Cc3IcUkg.js";
4
- var c = $r(Qa()), qa = $r(Za());
5
- function W() {
6
- return W = Object.assign ? Object.assign.bind() : function(e) {
7
- for (var t = 1; t < arguments.length; t++) {
8
- var r = arguments[t];
9
- for (var a in r) ({}).hasOwnProperty.call(r, a) && (e[a] = r[a]);
10
- }
11
- return e;
12
- }, W.apply(null, arguments);
13
- }
14
- var K;
15
- (function(e) {
16
- e.Pop = "POP", e.Push = "PUSH", e.Replace = "REPLACE";
17
- })(K || (K = {}));
18
- var xr = "popstate";
19
- function Jr(e) {
20
- e === void 0 && (e = {});
21
- let { initialEntries: t = ["/"], initialIndex: r, v5Compat: a = !1 } = e, n;
22
- n = t.map((p, y) => h(p, typeof p == "string" ? null : p.state, y === 0 ? "default" : void 0));
23
- let i = l(r ?? n.length - 1), o = K.Pop, s = null;
24
- function l(p) {
25
- return Math.min(Math.max(p, 0), n.length - 1);
26
- }
27
- function d() {
28
- return n[i];
29
- }
30
- function h(p, y, b) {
31
- y === void 0 && (y = null);
32
- let x = ze(n ? d().pathname : "/", p, y, b);
33
- return ye(x.pathname.charAt(0) === "/", "relative pathnames are not supported in memory history: " + JSON.stringify(p)), x;
34
- }
35
- function v(p) {
36
- return typeof p == "string" ? p : me(p);
37
- }
38
- return {
39
- get index() {
40
- return i;
41
- },
42
- get action() {
43
- return o;
44
- },
45
- get location() {
46
- return d();
47
- },
48
- createHref: v,
49
- createURL(p) {
50
- return new URL(v(p), "http://localhost");
51
- },
52
- encodeLocation(p) {
53
- let y = typeof p == "string" ? de(p) : p;
54
- return {
55
- pathname: y.pathname || "",
56
- search: y.search || "",
57
- hash: y.hash || ""
58
- };
59
- },
60
- push(p, y) {
61
- o = K.Push;
62
- let b = h(p, y);
63
- i += 1, n.splice(i, n.length, b), a && s && s({
64
- action: o,
65
- location: b,
66
- delta: 1
67
- });
68
- },
69
- replace(p, y) {
70
- o = K.Replace;
71
- let b = h(p, y);
72
- n[i] = b, a && s && s({
73
- action: o,
74
- location: b,
75
- delta: 0
76
- });
77
- },
78
- go(p) {
79
- o = K.Pop;
80
- let y = l(i + p), b = n[y];
81
- i = y, s && s({
82
- action: o,
83
- location: b,
84
- delta: p
85
- });
86
- },
87
- listen(p) {
88
- return s = p, () => {
89
- s = null;
90
- };
91
- }
92
- };
93
- }
94
- function Yr(e) {
95
- e === void 0 && (e = {});
96
- function t(a, n) {
97
- let { pathname: i, search: o, hash: s } = a.location;
98
- return ze("", {
99
- pathname: i,
100
- search: o,
101
- hash: s
102
- }, n.state && n.state.usr || null, n.state && n.state.key || "default");
103
- }
104
- function r(a, n) {
105
- return typeof n == "string" ? n : me(n);
106
- }
107
- return Xr(t, r, null, e);
108
- }
109
- function Gr(e) {
110
- e === void 0 && (e = {});
111
- function t(n, i) {
112
- let { pathname: o = "/", search: s = "", hash: l = "" } = de(n.location.hash.substr(1));
113
- return !o.startsWith("/") && !o.startsWith(".") && (o = "/" + o), ze("", {
114
- pathname: o,
115
- search: s,
116
- hash: l
117
- }, i.state && i.state.usr || null, i.state && i.state.key || "default");
118
- }
119
- function r(n, i) {
120
- let o = n.document.querySelector("base"), s = "";
121
- if (o && o.getAttribute("href")) {
122
- let l = n.location.href, d = l.indexOf("#");
123
- s = d === -1 ? l : l.slice(0, d);
124
- }
125
- return s + "#" + (typeof i == "string" ? i : me(i));
126
- }
127
- function a(n, i) {
128
- ye(n.pathname.charAt(0) === "/", "relative pathnames are not supported in hash history.push(" + JSON.stringify(i) + ")");
129
- }
130
- return Xr(t, r, a, e);
131
- }
132
- function _(e, t) {
133
- if (e === !1 || e === null || typeof e > "u") throw new Error(t);
134
- }
135
- function ye(e, t) {
136
- if (!e) try {
137
- throw new Error(t);
138
- } catch {}
139
- }
140
- function en() {
141
- return Math.random().toString(36).substr(2, 8);
142
- }
143
- function Pr(e, t) {
144
- return {
145
- usr: e.state,
146
- key: e.key,
147
- idx: t
148
- };
149
- }
150
- function ze(e, t, r, a) {
151
- return r === void 0 && (r = null), W({
152
- pathname: typeof e == "string" ? e : e.pathname,
153
- search: "",
154
- hash: ""
155
- }, typeof t == "string" ? de(t) : t, {
156
- state: r,
157
- key: t && t.key || a || en()
158
- });
159
- }
160
- function me(e) {
161
- let { pathname: t = "/", search: r = "", hash: a = "" } = e;
162
- return r && r !== "?" && (t += r.charAt(0) === "?" ? r : "?" + r), a && a !== "#" && (t += a.charAt(0) === "#" ? a : "#" + a), t;
163
- }
164
- function de(e) {
165
- let t = {};
166
- if (e) {
167
- let r = e.indexOf("#");
168
- r >= 0 && (t.hash = e.substr(r), e = e.substr(0, r));
169
- let a = e.indexOf("?");
170
- a >= 0 && (t.search = e.substr(a), e = e.substr(0, a)), e && (t.pathname = e);
171
- }
172
- return t;
173
- }
174
- function Xr(e, t, r, a) {
175
- a === void 0 && (a = {});
176
- let { window: n = document.defaultView, v5Compat: i = !1 } = a, o = n.history, s = K.Pop, l = null, d = h();
177
- d == null && (d = 0, o.replaceState(W({}, o.state, { idx: d }), ""));
178
- function h() {
179
- return (o.state || { idx: null }).idx;
180
- }
181
- function v() {
182
- s = K.Pop;
183
- let R = h(), F = R == null ? null : R - d;
184
- d = R, l && l({
185
- action: s,
186
- location: x.location,
187
- delta: F
188
- });
189
- }
190
- function p(R, F) {
191
- s = K.Push;
192
- let S = ze(x.location, R, F);
193
- r && r(S, R), d = h() + 1;
194
- let I = Pr(S, d), j = x.createHref(S);
195
- try {
196
- o.pushState(I, "", j);
197
- } catch ($) {
198
- if ($ instanceof DOMException && $.name === "DataCloneError") throw $;
199
- n.location.assign(j);
200
- }
201
- i && l && l({
202
- action: s,
203
- location: x.location,
204
- delta: 1
205
- });
206
- }
207
- function y(R, F) {
208
- s = K.Replace;
209
- let S = ze(x.location, R, F);
210
- r && r(S, R), d = h();
211
- let I = Pr(S, d), j = x.createHref(S);
212
- o.replaceState(I, "", j), i && l && l({
213
- action: s,
214
- location: x.location,
215
- delta: 0
216
- });
217
- }
218
- function b(R) {
219
- let F = n.location.origin !== "null" ? n.location.origin : n.location.href, S = typeof R == "string" ? R : me(R);
220
- return S = S.replace(/ $/, "%20"), _(F, "No window.location.(origin|href) available to create URL for href: " + S), new URL(S, F);
221
- }
222
- let x = {
223
- get action() {
224
- return s;
225
- },
226
- get location() {
227
- return e(n, o);
228
- },
229
- listen(R) {
230
- if (l) throw new Error("A history only accepts one active listener");
231
- return n.addEventListener(xr, v), l = R, () => {
232
- n.removeEventListener(xr, v), l = null;
233
- };
234
- },
235
- createHref(R) {
236
- return t(n, R);
237
- },
238
- createURL: b,
239
- encodeLocation(R) {
240
- let F = b(R);
241
- return {
242
- pathname: F.pathname,
243
- search: F.search,
244
- hash: F.hash
245
- };
246
- },
247
- push: p,
248
- replace: y,
249
- go(R) {
250
- return o.go(R);
251
- }
252
- };
253
- return x;
254
- }
255
- var B;
256
- (function(e) {
257
- e.data = "data", e.deferred = "deferred", e.redirect = "redirect", e.error = "error";
258
- })(B || (B = {}));
259
- var tn = new Set([
260
- "lazy",
261
- "caseSensitive",
262
- "path",
263
- "id",
264
- "index",
265
- "children"
266
- ]);
267
- function rn(e) {
268
- return e.index === !0;
269
- }
270
- function Ut(e, t, r, a) {
271
- return r === void 0 && (r = []), a === void 0 && (a = {}), e.map((n, i) => {
272
- let o = [...r, String(i)], s = typeof n.id == "string" ? n.id : o.join("-");
273
- if (_(n.index !== !0 || !n.children, "Cannot specify children on an index route"), _(!a[s], "Found a route id collision on id \"" + s + `". Route id's must be globally unique within Data Router usages`), rn(n)) {
274
- let l = W({}, n, t(n), { id: s });
275
- return a[s] = l, l;
276
- } else {
277
- let l = W({}, n, t(n), {
278
- id: s,
279
- children: void 0
280
- });
281
- return a[s] = l, n.children && (l.children = Ut(n.children, t, o, a)), l;
282
- }
283
- });
284
- }
285
- function De(e, t, r) {
286
- return r === void 0 && (r = "/"), Mt(e, t, r, !1);
287
- }
288
- function Mt(e, t, r, a) {
289
- let n = ne((typeof t == "string" ? de(t) : t).pathname || "/", r);
290
- if (n == null) return null;
291
- let i = Zr(e);
292
- an(i);
293
- let o = null, s = ea(n);
294
- for (let l = 0; o == null && l < i.length; ++l) o = hn(i[l], s, a);
295
- return o;
296
- }
297
- function Qr(e, t) {
298
- let { route: r, pathname: a, params: n } = e;
299
- return {
300
- id: r.id,
301
- pathname: a,
302
- params: n,
303
- data: t[r.id],
304
- handle: r.handle
305
- };
306
- }
307
- function Zr(e, t, r, a) {
308
- t === void 0 && (t = []), r === void 0 && (r = []), a === void 0 && (a = "");
309
- let n = (i, o, s) => {
310
- let l = {
311
- relativePath: s === void 0 ? i.path || "" : s,
312
- caseSensitive: i.caseSensitive === !0,
313
- childrenIndex: o,
314
- route: i
315
- };
316
- l.relativePath.startsWith("/") && (_(l.relativePath.startsWith(a), "Absolute route path \"" + l.relativePath + "\" nested under path " + ("\"" + a + "\" is not valid. An absolute child route path ") + "must start with the combined path of all its parent routes."), l.relativePath = l.relativePath.slice(a.length));
317
- let d = ge([a, l.relativePath]), h = r.concat(l);
318
- i.children && i.children.length > 0 && (_(i.index !== !0, "Index routes must not have child routes. Please remove " + ("all child routes from route path \"" + d + "\".")), Zr(i.children, t, h, d)), !(i.path == null && !i.index) && t.push({
319
- path: d,
320
- score: dn(d, i.index),
321
- routesMeta: h
322
- });
323
- };
324
- return e.forEach((i, o) => {
325
- var s;
326
- if (i.path === "" || !((s = i.path) != null && s.includes("?"))) n(i, o);
327
- else for (let l of qr(i.path)) n(i, o, l);
328
- }), t;
329
- }
330
- function qr(e) {
331
- let t = e.split("/");
332
- if (t.length === 0) return [];
333
- let [r, ...a] = t, n = r.endsWith("?"), i = r.replace(/\?$/, "");
334
- if (a.length === 0) return n ? [i, ""] : [i];
335
- let o = qr(a.join("/")), s = [];
336
- return s.push(...o.map((l) => l === "" ? i : [i, l].join("/"))), n && s.push(...o), s.map((l) => e.startsWith("/") && l === "" ? "/" : l);
337
- }
338
- function an(e) {
339
- e.sort((t, r) => t.score !== r.score ? r.score - t.score : fn(t.routesMeta.map((a) => a.childrenIndex), r.routesMeta.map((a) => a.childrenIndex)));
340
- }
341
- var nn = /^:[\w-]+$/, on = 3, ln = 2, sn = 1, un = 10, cn = -2, Cr = (e) => e === "*";
342
- function dn(e, t) {
343
- let r = e.split("/"), a = r.length;
344
- return r.some(Cr) && (a += cn), t && (a += ln), r.filter((n) => !Cr(n)).reduce((n, i) => n + (nn.test(i) ? on : i === "" ? sn : un), a);
345
- }
346
- function fn(e, t) {
347
- return e.length === t.length && e.slice(0, -1).every((r, a) => r === t[a]) ? e[e.length - 1] - t[t.length - 1] : 0;
348
- }
349
- function hn(e, t, r) {
350
- r === void 0 && (r = !1);
351
- let { routesMeta: a } = e, n = {}, i = "/", o = [];
352
- for (let s = 0; s < a.length; ++s) {
353
- let l = a[s], d = s === a.length - 1, h = i === "/" ? t : t.slice(i.length) || "/", v = Qe({
354
- path: l.relativePath,
355
- caseSensitive: l.caseSensitive,
356
- end: d
357
- }, h), p = l.route;
358
- if (!v && d && r && !a[a.length - 1].route.index && (v = Qe({
359
- path: l.relativePath,
360
- caseSensitive: l.caseSensitive,
361
- end: !1
362
- }, h)), !v) return null;
363
- Object.assign(n, v.params), o.push({
364
- params: n,
365
- pathname: ge([i, v.pathname]),
366
- pathnameBase: yn(ge([i, v.pathnameBase])),
367
- route: p
368
- }), v.pathnameBase !== "/" && (i = ge([i, v.pathnameBase]));
369
- }
370
- return o;
371
- }
372
- function vn(e, t) {
373
- t === void 0 && (t = {});
374
- let r = e;
375
- r.endsWith("*") && r !== "*" && !r.endsWith("/*") && (ye(!1, "Route path \"" + r + "\" will be treated as if it were " + ("\"" + r.replace(/\*$/, "/*") + "\" because the `*` character must ") + "always follow a `/` in the pattern. To get rid of this warning, " + ("please change the route path to \"" + r.replace(/\*$/, "/*") + "\".")), r = r.replace(/\*$/, "/*"));
376
- const a = r.startsWith("/") ? "/" : "", n = (i) => i == null ? "" : typeof i == "string" ? i : String(i);
377
- return a + r.split(/\/+/).map((i, o, s) => {
378
- if (o === s.length - 1 && i === "*") return n(t["*"]);
379
- const l = i.match(/^:([\w-]+)(\??)$/);
380
- if (l) {
381
- const [, d, h] = l;
382
- let v = t[d];
383
- return _(h === "?" || v != null, "Missing \":" + d + "\" param"), n(v);
384
- }
385
- return i.replace(/\?$/g, "");
386
- }).filter((i) => !!i).join("/");
387
- }
388
- function Qe(e, t) {
389
- typeof e == "string" && (e = {
390
- path: e,
391
- caseSensitive: !1,
392
- end: !0
393
- });
394
- let [r, a] = mn(e.path, e.caseSensitive, e.end), n = t.match(r);
395
- if (!n) return null;
396
- let i = n[0], o = i.replace(/(.)\/+$/, "$1"), s = n.slice(1);
397
- return {
398
- params: a.reduce((l, d, h) => {
399
- let { paramName: v, isOptional: p } = d;
400
- if (v === "*") {
401
- let b = s[h] || "";
402
- o = i.slice(0, i.length - b.length).replace(/(.)\/+$/, "$1");
403
- }
404
- const y = s[h];
405
- return p && !y ? l[v] = void 0 : l[v] = (y || "").replace(/%2F/g, "/"), l;
406
- }, {}),
407
- pathname: i,
408
- pathnameBase: o,
409
- pattern: e
410
- };
411
- }
412
- function mn(e, t, r) {
413
- t === void 0 && (t = !1), r === void 0 && (r = !0), ye(e === "*" || !e.endsWith("*") || e.endsWith("/*"), "Route path \"" + e + "\" will be treated as if it were " + ("\"" + e.replace(/\*$/, "/*") + "\" because the `*` character must ") + "always follow a `/` in the pattern. To get rid of this warning, " + ("please change the route path to \"" + e.replace(/\*$/, "/*") + "\"."));
414
- let a = [], n = "^" + e.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (i, o, s) => (a.push({
415
- paramName: o,
416
- isOptional: s != null
417
- }), s ? "/?([^\\/]+)?" : "/([^\\/]+)"));
418
- return e.endsWith("*") ? (a.push({ paramName: "*" }), n += e === "*" || e === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$") : r ? n += "\\/*$" : e !== "" && e !== "/" && (n += "(?:(?=\\/|$))"), [new RegExp(n, t ? void 0 : "i"), a];
419
- }
420
- function ea(e) {
421
- try {
422
- return e.split("/").map((t) => decodeURIComponent(t).replace(/\//g, "%2F")).join("/");
423
- } catch (t) {
424
- return ye(!1, "The URL path \"" + e + "\" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent " + ("encoding (" + t + ").")), e;
425
- }
426
- }
427
- function ne(e, t) {
428
- if (t === "/") return e;
429
- if (!e.toLowerCase().startsWith(t.toLowerCase())) return null;
430
- let r = t.endsWith("/") ? t.length - 1 : t.length, a = e.charAt(r);
431
- return a && a !== "/" ? null : e.slice(r) || "/";
432
- }
433
- var pn = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i, gn = (e) => pn.test(e);
434
- function ta(e, t) {
435
- t === void 0 && (t = "/");
436
- let { pathname: r, search: a = "", hash: n = "" } = typeof e == "string" ? de(e) : e, i;
437
- if (r) if (gn(r)) i = r;
438
- else {
439
- if (r.includes("//")) {
440
- let o = r;
441
- r = qt(r), ye(!1, "Pathnames cannot have embedded double slashes - normalizing " + (o + " -> " + r));
442
- }
443
- r.startsWith("/") ? i = Lr(r.substring(1), "/") : i = Lr(r, t);
444
- }
445
- else i = t;
446
- return {
447
- pathname: i,
448
- search: wn(a),
449
- hash: bn(n)
450
- };
451
- }
452
- function Lr(e, t) {
453
- let r = t.replace(/\/+$/, "").split("/");
454
- return e.split("/").forEach((a) => {
455
- a === ".." ? r.length > 1 && r.pop() : a !== "." && r.push(a);
456
- }), r.length > 1 ? r.join("/") : "/";
457
- }
458
- function Vt(e, t, r, a) {
459
- return "Cannot include a '" + e + "' character in a manually specified " + ("`to." + t + "` field [" + JSON.stringify(a) + "]. Please separate it out to the ") + ("`to." + r + "` field. Alternatively you may provide the full path as ") + "a string in <Link to=\"...\"> and the router will parse it for you.";
460
- }
461
- function ra(e) {
462
- return e.filter((t, r) => r === 0 || t.route.path && t.route.path.length > 0);
463
- }
464
- function It(e, t) {
465
- let r = ra(e);
466
- return t ? r.map((a, n) => n === r.length - 1 ? a.pathname : a.pathnameBase) : r.map((a) => a.pathnameBase);
467
- }
468
- function Nt(e, t, r, a) {
469
- a === void 0 && (a = !1);
470
- let n;
471
- typeof e == "string" ? n = de(e) : (n = W({}, e), _(!n.pathname || !n.pathname.includes("?"), Vt("?", "pathname", "search", n)), _(!n.pathname || !n.pathname.includes("#"), Vt("#", "pathname", "hash", n)), _(!n.search || !n.search.includes("#"), Vt("#", "search", "hash", n)));
472
- let i = e === "" || n.pathname === "", o = i ? "/" : n.pathname, s;
473
- if (o == null) s = r;
474
- else {
475
- let v = t.length - 1;
476
- if (!a && o.startsWith("..")) {
477
- let p = o.split("/");
478
- for (; p[0] === "..";) p.shift(), v -= 1;
479
- n.pathname = p.join("/");
480
- }
481
- s = v >= 0 ? t[v] : "/";
482
- }
483
- let l = ta(n, s), d = o && o !== "/" && o.endsWith("/"), h = (i || o === ".") && r.endsWith("/");
484
- return !l.pathname.endsWith("/") && (d || h) && (l.pathname += "/"), l;
485
- }
486
- var qt = (e) => e.replace(/\/\/+/g, "/"), ge = (e) => qt(e.join("/")), yn = (e) => e.replace(/\/+$/, "").replace(/^\/*/, "/"), wn = (e) => !e || e === "?" ? "" : e.startsWith("?") ? e : "?" + e, bn = (e) => !e || e === "#" ? "" : e.startsWith("#") ? e : "#" + e, En = function(t, r) {
487
- r === void 0 && (r = {});
488
- let a = typeof r == "number" ? { status: r } : r, n = new Headers(a.headers);
489
- return n.has("Content-Type") || n.set("Content-Type", "application/json; charset=utf-8"), new Response(JSON.stringify(t), W({}, a, { headers: n }));
490
- }, Ft = class extends Error {}, Rn = class {
491
- constructor(e, t) {
492
- this.pendingKeysSet = new Set(), this.subscribers = new Set(), this.deferredKeys = [], _(e && typeof e == "object" && !Array.isArray(e), "defer() only accepts plain objects");
493
- let r;
494
- this.abortPromise = new Promise((n, i) => r = i), this.controller = new AbortController();
495
- let a = () => r(new Ft("Deferred data aborted"));
496
- this.unlistenAbortSignal = () => this.controller.signal.removeEventListener("abort", a), this.controller.signal.addEventListener("abort", a), this.data = Object.entries(e).reduce((n, i) => {
497
- let [o, s] = i;
498
- return Object.assign(n, { [o]: this.trackPromise(o, s) });
499
- }, {}), this.done && this.unlistenAbortSignal(), this.init = t;
500
- }
501
- trackPromise(e, t) {
502
- if (!(t instanceof Promise)) return t;
503
- this.deferredKeys.push(e), this.pendingKeysSet.add(e);
504
- let r = Promise.race([t, this.abortPromise]).then((a) => this.onSettle(r, e, void 0, a), (a) => this.onSettle(r, e, a));
505
- return r.catch(() => {}), Object.defineProperty(r, "_tracked", { get: () => !0 }), r;
506
- }
507
- onSettle(e, t, r, a) {
508
- if (this.controller.signal.aborted && r instanceof Ft) return this.unlistenAbortSignal(), Object.defineProperty(e, "_error", { get: () => r }), Promise.reject(r);
509
- if (this.pendingKeysSet.delete(t), this.done && this.unlistenAbortSignal(), r === void 0 && a === void 0) {
510
- let n = new Error("Deferred data for key \"" + t + "\" resolved/rejected with `undefined`, you must resolve/reject with a value or `null`.");
511
- return Object.defineProperty(e, "_error", { get: () => n }), this.emit(!1, t), Promise.reject(n);
512
- }
513
- return a === void 0 ? (Object.defineProperty(e, "_error", { get: () => r }), this.emit(!1, t), Promise.reject(r)) : (Object.defineProperty(e, "_data", { get: () => a }), this.emit(!1, t), a);
514
- }
515
- emit(e, t) {
516
- this.subscribers.forEach((r) => r(e, t));
517
- }
518
- subscribe(e) {
519
- return this.subscribers.add(e), () => this.subscribers.delete(e);
520
- }
521
- cancel() {
522
- this.controller.abort(), this.pendingKeysSet.forEach((e, t) => this.pendingKeysSet.delete(t)), this.emit(!0);
523
- }
524
- async resolveData(e) {
525
- let t = !1;
526
- if (!this.done) {
527
- let r = () => this.cancel();
528
- e.addEventListener("abort", r), t = await new Promise((a) => {
529
- this.subscribe((n) => {
530
- e.removeEventListener("abort", r), (n || this.done) && a(n);
531
- });
532
- });
533
- }
534
- return t;
535
- }
536
- get done() {
537
- return this.pendingKeysSet.size === 0;
538
- }
539
- get unwrappedData() {
540
- return _(this.data !== null && this.done, "Can only unwrap data on initialized and settled deferreds"), Object.entries(this.data).reduce((e, t) => {
541
- let [r, a] = t;
542
- return Object.assign(e, { [r]: xn(a) });
543
- }, {});
544
- }
545
- get pendingKeys() {
546
- return Array.from(this.pendingKeysSet);
547
- }
548
- };
549
- function Sn(e) {
550
- return e instanceof Promise && e._tracked === !0;
551
- }
552
- function xn(e) {
553
- if (!Sn(e)) return e;
554
- if (e._error) throw e._error;
555
- return e._data;
556
- }
557
- var Pn = function(t, r) {
558
- return r === void 0 && (r = {}), new Rn(t, typeof r == "number" ? { status: r } : r);
559
- }, er = function(t, r) {
560
- r === void 0 && (r = 302);
561
- let a = r;
562
- typeof a == "number" ? a = { status: a } : typeof a.status > "u" && (a.status = 302);
563
- let n = new Headers(a.headers);
564
- return n.set("Location", t), new Response(null, W({}, a, { headers: n }));
565
- }, Cn = (e, t) => {
566
- let r = er(e, t);
567
- return r.headers.set("X-Remix-Reload-Document", "true"), r;
568
- }, Ln = (e, t) => {
569
- let r = er(e, t);
570
- return r.headers.set("X-Remix-Replace", "true"), r;
571
- }, ct = class {
572
- constructor(e, t, r, a) {
573
- a === void 0 && (a = !1), this.status = e, this.statusText = t || "", this.internal = a, r instanceof Error ? (this.data = r.toString(), this.error = r) : this.data = r;
574
- }
575
- };
576
- function Ze(e) {
577
- return e != null && typeof e.status == "number" && typeof e.statusText == "string" && typeof e.internal == "boolean" && "data" in e;
578
- }
579
- var aa = [
580
- "post",
581
- "put",
582
- "patch",
583
- "delete"
584
- ], Dn = new Set(aa), Tn = ["get", ...aa], Mn = new Set(Tn), _n = new Set([
585
- 301,
586
- 302,
587
- 303,
588
- 307,
589
- 308
590
- ]), Un = new Set([307, 308]), $t = {
591
- state: "idle",
592
- location: void 0,
593
- formMethod: void 0,
594
- formAction: void 0,
595
- formEncType: void 0,
596
- formData: void 0,
597
- json: void 0,
598
- text: void 0
599
- }, na = {
600
- state: "idle",
601
- data: void 0,
602
- formMethod: void 0,
603
- formAction: void 0,
604
- formEncType: void 0,
605
- formData: void 0,
606
- json: void 0,
607
- text: void 0
608
- }, Xe = {
609
- state: "unblocked",
610
- proceed: void 0,
611
- reset: void 0,
612
- location: void 0
613
- }, tr = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i, Fn = (e) => ({ hasErrorBoundary: !!e.hasErrorBoundary }), oa = "remix-router-transitions";
614
- function rr(e) {
615
- const t = e.window ? e.window : typeof window < "u" ? window : void 0, r = typeof t < "u" && typeof t.document < "u" && typeof t.document.createElement < "u", a = !r;
616
- _(e.routes.length > 0, "You must provide a non-empty routes array to createRouter");
617
- let n;
618
- if (e.mapRouteProperties) n = e.mapRouteProperties;
619
- else if (e.detectErrorBoundary) {
620
- let u = e.detectErrorBoundary;
621
- n = (f) => ({ hasErrorBoundary: u(f) });
622
- } else n = Fn;
623
- let i = {}, o = Ut(e.routes, n, void 0, i), s, l = e.basename || "/", d = e.dataStrategy || Nn, h = e.patchRoutesOnNavigation, v = W({
624
- v7_fetcherPersist: !1,
625
- v7_normalizeFormMethod: !1,
626
- v7_partialHydration: !1,
627
- v7_prependBasename: !1,
628
- v7_relativeSplatPath: !1,
629
- v7_skipActionErrorRevalidation: !1
630
- }, e.future), p = null, y = new Set(), b = null, x = null, R = null, F = e.hydrationData != null, S = De(o, e.history.location, l), I = !1, j = null;
631
- if (S == null && !h) {
632
- let u = re(404, { pathname: e.history.location.pathname }), { matches: f, route: m } = jr(o);
633
- S = f, j = { [m.id]: u };
634
- }
635
- S && !e.hydrationData && Rt(S, o, e.history.location.pathname).active && (S = null);
636
- let $;
637
- if (S) if (S.some((u) => u.route.lazy)) $ = !1;
638
- else if (!S.some((u) => u.route.loader)) $ = !0;
639
- else if (v.v7_partialHydration) {
640
- let u = e.hydrationData ? e.hydrationData.loaderData : null, f = e.hydrationData ? e.hydrationData.errors : null;
641
- if (f) {
642
- let m = S.findIndex((w) => f[w.route.id] !== void 0);
643
- $ = S.slice(0, m + 1).every((w) => !Qt(w.route, u, f));
644
- } else $ = S.every((m) => !Qt(m.route, u, f));
645
- } else $ = e.hydrationData != null;
646
- else if ($ = !1, S = [], v.v7_partialHydration) {
647
- let u = Rt(null, o, e.history.location.pathname);
648
- u.active && u.matches && (I = !0, S = u.matches);
649
- }
650
- let fe, g = {
651
- historyAction: e.history.action,
652
- location: e.history.location,
653
- matches: S,
654
- initialized: $,
655
- navigation: $t,
656
- restoreScrollPosition: e.hydrationData != null ? !1 : null,
657
- preventScrollReset: !1,
658
- revalidation: "idle",
659
- loaderData: e.hydrationData && e.hydrationData.loaderData || {},
660
- actionData: e.hydrationData && e.hydrationData.actionData || null,
661
- errors: e.hydrationData && e.hydrationData.errors || j,
662
- fetchers: new Map(),
663
- blockers: new Map()
664
- }, U = K.Pop, z = !1, O, Q = !1, G = new Map(), ie = null, te = !1, we = !1, pt = [], gt = new Set(), Z = new Map(), yt = 0, nt = -1, He = new Map(), be = new Set(), Ke = new Map(), ot = new Map(), he = new Set(), Ae = new Map(), Oe = new Map(), wt;
665
- function Fa() {
666
- if (p = e.history.listen((u) => {
667
- let { action: f, location: m, delta: w } = u;
668
- if (wt) {
669
- wt(), wt = void 0;
670
- return;
671
- }
672
- ye(Oe.size === 0 || w != null, "You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");
673
- let E = br({
674
- currentLocation: g.location,
675
- nextLocation: m,
676
- historyAction: f
677
- });
678
- if (E && w != null) {
679
- let D = new Promise((T) => {
680
- wt = T;
681
- });
682
- e.history.go(w * -1), Et(E, {
683
- state: "blocked",
684
- location: m,
685
- proceed() {
686
- Et(E, {
687
- state: "proceeding",
688
- proceed: void 0,
689
- reset: void 0,
690
- location: m
691
- }), D.then(() => e.history.go(w));
692
- },
693
- reset() {
694
- let T = new Map(g.blockers);
695
- T.set(E, Xe), ee({ blockers: T });
696
- }
697
- });
698
- return;
699
- }
700
- return Ie(f, m);
701
- }), r) {
702
- Qn(t, G);
703
- let u = () => Zn(t, G);
704
- t.addEventListener("pagehide", u), ie = () => t.removeEventListener("pagehide", u);
705
- }
706
- return g.initialized || Ie(K.Pop, g.location, { initialHydration: !0 }), fe;
707
- }
708
- function Aa() {
709
- p && p(), ie && ie(), y.clear(), O && O.abort(), g.fetchers.forEach((u, f) => bt(f)), g.blockers.forEach((u, f) => wr(f));
710
- }
711
- function Oa(u) {
712
- return y.add(u), () => y.delete(u);
713
- }
714
- function ee(u, f) {
715
- f === void 0 && (f = {}), g = W({}, g, u);
716
- let m = [], w = [];
717
- v.v7_fetcherPersist && g.fetchers.forEach((E, D) => {
718
- E.state === "idle" && (he.has(D) ? w.push(D) : m.push(D));
719
- }), he.forEach((E) => {
720
- !g.fetchers.has(E) && !Z.has(E) && w.push(E);
721
- }), [...y].forEach((E) => E(g, {
722
- deletedFetchers: w,
723
- viewTransitionOpts: f.viewTransitionOpts,
724
- flushSync: f.flushSync === !0
725
- })), v.v7_fetcherPersist ? (m.forEach((E) => g.fetchers.delete(E)), w.forEach((E) => bt(E))) : w.forEach((E) => he.delete(E));
726
- }
727
- function We(u, f, m) {
728
- var w, E;
729
- let { flushSync: D } = m === void 0 ? {} : m, T = g.actionData != null && g.navigation.formMethod != null && ve(g.navigation.formMethod) && g.navigation.state === "loading" && ((w = u.state) == null ? void 0 : w._isRedirect) !== !0, C;
730
- f.actionData ? Object.keys(f.actionData).length > 0 ? C = f.actionData : C = null : T ? C = g.actionData : C = null;
731
- let P = f.loaderData ? Ir(g.loaderData, f.loaderData, f.matches || [], f.errors) : g.loaderData, M = g.blockers;
732
- M.size > 0 && (M = new Map(M), M.forEach((H, N) => M.set(N, Xe)));
733
- let L = z === !0 || g.navigation.formMethod != null && ve(g.navigation.formMethod) && ((E = u.state) == null ? void 0 : E._isRedirect) !== !0;
734
- s && (o = s, s = void 0), te || U === K.Pop || (U === K.Push ? e.history.push(u, u.state) : U === K.Replace && e.history.replace(u, u.state));
735
- let A;
736
- if (U === K.Pop) {
737
- let H = G.get(g.location.pathname);
738
- H && H.has(u.pathname) ? A = {
739
- currentLocation: g.location,
740
- nextLocation: u
741
- } : G.has(u.pathname) && (A = {
742
- currentLocation: u,
743
- nextLocation: g.location
744
- });
745
- } else if (Q) {
746
- let H = G.get(g.location.pathname);
747
- H ? H.add(u.pathname) : (H = new Set([u.pathname]), G.set(g.location.pathname, H)), A = {
748
- currentLocation: g.location,
749
- nextLocation: u
750
- };
751
- }
752
- ee(W({}, f, {
753
- actionData: C,
754
- loaderData: P,
755
- historyAction: U,
756
- location: u,
757
- initialized: !0,
758
- navigation: $t,
759
- revalidation: "idle",
760
- restoreScrollPosition: Rr(u, f.matches || g.matches),
761
- preventScrollReset: L,
762
- blockers: M
763
- }), {
764
- viewTransitionOpts: A,
765
- flushSync: D === !0
766
- }), U = K.Pop, z = !1, Q = !1, te = !1, we = !1, pt = [];
767
- }
768
- async function fr(u, f) {
769
- if (typeof u == "number") {
770
- e.history.go(u);
771
- return;
772
- }
773
- let m = Xt(g.location, g.matches, l, v.v7_prependBasename, u, v.v7_relativeSplatPath, f?.fromRouteId, f?.relative), { path: w, submission: E, error: D } = Dr(v.v7_normalizeFormMethod, !1, m, f), T = g.location, C = ze(g.location, w, f && f.state);
774
- C = W({}, C, e.history.encodeLocation(C));
775
- let P = f && f.replace != null ? f.replace : void 0, M = K.Push;
776
- P === !0 ? M = K.Replace : P === !1 || E != null && ve(E.formMethod) && E.formAction === g.location.pathname + g.location.search && (M = K.Replace);
777
- let L = f && "preventScrollReset" in f ? f.preventScrollReset === !0 : void 0, A = (f && f.flushSync) === !0, H = br({
778
- currentLocation: T,
779
- nextLocation: C,
780
- historyAction: M
781
- });
782
- if (H) {
783
- Et(H, {
784
- state: "blocked",
785
- location: C,
786
- proceed() {
787
- Et(H, {
788
- state: "proceeding",
789
- proceed: void 0,
790
- reset: void 0,
791
- location: C
792
- }), fr(u, f);
793
- },
794
- reset() {
795
- let N = new Map(g.blockers);
796
- N.set(H, Xe), ee({ blockers: N });
797
- }
798
- });
799
- return;
800
- }
801
- return await Ie(M, C, {
802
- submission: E,
803
- pendingError: D,
804
- preventScrollReset: L,
805
- replace: f && f.replace,
806
- enableViewTransition: f && f.viewTransition,
807
- flushSync: A
808
- });
809
- }
810
- function Ia() {
811
- if (Ht(), ee({ revalidation: "loading" }), g.navigation.state !== "submitting") {
812
- if (g.navigation.state === "idle") {
813
- Ie(g.historyAction, g.location, { startUninterruptedRevalidation: !0 });
814
- return;
815
- }
816
- Ie(U || g.historyAction, g.navigation.location, {
817
- overrideNavigation: g.navigation,
818
- enableViewTransition: Q === !0
819
- });
820
- }
821
- }
822
- async function Ie(u, f, m) {
823
- O && O.abort(), O = null, U = u, te = (m && m.startUninterruptedRevalidation) === !0, $a(g.location, g.matches), z = (m && m.preventScrollReset) === !0, Q = (m && m.enableViewTransition) === !0;
824
- let w = s || o, E = m && m.overrideNavigation, D = m != null && m.initialHydration && g.matches && g.matches.length > 0 && !I ? g.matches : De(w, f, l), T = (m && m.flushSync) === !0;
825
- if (D && g.initialized && !we && Kn(g.location, f) && !(m && m.submission && ve(m.submission.formMethod))) {
826
- We(f, { matches: D }, { flushSync: T });
827
- return;
828
- }
829
- let C = Rt(D, w, f.pathname);
830
- if (C.active && C.matches && (D = C.matches), !D) {
831
- let { error: J, notFoundMatches: q, route: Y } = Kt(f.pathname);
832
- We(f, {
833
- matches: q,
834
- loaderData: {},
835
- errors: { [Y.id]: J }
836
- }, { flushSync: T });
837
- return;
838
- }
839
- O = new AbortController();
840
- let P = Ye(e.history, f, O.signal, m && m.submission), M;
841
- if (m && m.pendingError) M = [ke(D).route.id, {
842
- type: B.error,
843
- error: m.pendingError
844
- }];
845
- else if (m && m.submission && ve(m.submission.formMethod)) {
846
- let J = await Na(P, f, m.submission, D, C.active, {
847
- replace: m.replace,
848
- flushSync: T
849
- });
850
- if (J.shortCircuited) return;
851
- if (J.pendingActionResult) {
852
- let [q, Y] = J.pendingActionResult;
853
- if (le(Y) && Ze(Y.error) && Y.error.status === 404) {
854
- O = null, We(f, {
855
- matches: J.matches,
856
- loaderData: {},
857
- errors: { [q]: Y.error }
858
- });
859
- return;
860
- }
861
- }
862
- D = J.matches || D, M = J.pendingActionResult, E = Jt(f, m.submission), T = !1, C.active = !1, P = Ye(e.history, P.url, P.signal);
863
- }
864
- let { shortCircuited: L, matches: A, loaderData: H, errors: N } = await ja(P, f, D, C.active, E, m && m.submission, m && m.fetcherSubmission, m && m.replace, m && m.initialHydration === !0, T, M);
865
- L || (O = null, We(f, W({ matches: A || D }, Nr(M), {
866
- loaderData: H,
867
- errors: N
868
- })));
869
- }
870
- async function Na(u, f, m, w, E, D) {
871
- if (D === void 0 && (D = {}), Ht(), ee({ navigation: Gn(f, m) }, { flushSync: D.flushSync === !0 }), E) {
872
- let P = await St(w, f.pathname, u.signal);
873
- if (P.type === "aborted") return { shortCircuited: !0 };
874
- if (P.type === "error") {
875
- let M = ke(P.partialMatches).route.id;
876
- return {
877
- matches: P.partialMatches,
878
- pendingActionResult: [M, {
879
- type: B.error,
880
- error: P.error
881
- }]
882
- };
883
- } else if (P.matches) w = P.matches;
884
- else {
885
- let { notFoundMatches: M, error: L, route: A } = Kt(f.pathname);
886
- return {
887
- matches: M,
888
- pendingActionResult: [A.id, {
889
- type: B.error,
890
- error: L
891
- }]
892
- };
893
- }
894
- }
895
- let T, C = ut(w, f);
896
- if (!C.route.action && !C.route.lazy) T = {
897
- type: B.error,
898
- error: re(405, {
899
- method: u.method,
900
- pathname: f.pathname,
901
- routeId: C.route.id
902
- })
903
- };
904
- else if (T = (await it("action", g, u, [C], w, null))[C.route.id], u.signal.aborted) return { shortCircuited: !0 };
905
- if (Be(T)) {
906
- let P;
907
- return D && D.replace != null ? P = D.replace : P = Fr(T.response.headers.get("Location"), new URL(u.url), l, e.history) === g.location.pathname + g.location.search, await Ne(u, T, !0, {
908
- submission: m,
909
- replace: P
910
- }), { shortCircuited: !0 };
911
- }
912
- if (Te(T)) throw re(400, { type: "defer-action" });
913
- if (le(T)) {
914
- let P = ke(w, C.route.id);
915
- return (D && D.replace) !== !0 && (U = K.Push), {
916
- matches: w,
917
- pendingActionResult: [P.route.id, T]
918
- };
919
- }
920
- return {
921
- matches: w,
922
- pendingActionResult: [C.route.id, T]
923
- };
924
- }
925
- async function ja(u, f, m, w, E, D, T, C, P, M, L) {
926
- let A = E || Jt(f, D), H = D || T || Br(A), N = !te && (!v.v7_partialHydration || !P);
927
- if (w) {
928
- if (N) {
929
- let X = hr(L);
930
- ee(W({ navigation: A }, X !== void 0 ? { actionData: X } : {}), { flushSync: M });
931
- }
932
- let k = await St(m, f.pathname, u.signal);
933
- if (k.type === "aborted") return { shortCircuited: !0 };
934
- if (k.type === "error") {
935
- let X = ke(k.partialMatches).route.id;
936
- return {
937
- matches: k.partialMatches,
938
- loaderData: {},
939
- errors: { [X]: k.error }
940
- };
941
- } else if (k.matches) m = k.matches;
942
- else {
943
- let { error: X, notFoundMatches: V, route: Je } = Kt(f.pathname);
944
- return {
945
- matches: V,
946
- loaderData: {},
947
- errors: { [Je.id]: X }
948
- };
949
- }
950
- }
951
- let J = s || o, [q, Y] = Mr(e.history, g, m, H, f, v.v7_partialHydration && P === !0, v.v7_skipActionErrorRevalidation, we, pt, gt, he, Ke, be, J, l, L);
952
- if (Wt((k) => !(m && m.some((X) => X.route.id === k)) || q && q.some((X) => X.route.id === k)), nt = ++yt, q.length === 0 && Y.length === 0) {
953
- let k = gr();
954
- return We(f, W({
955
- matches: m,
956
- loaderData: {},
957
- errors: L && le(L[1]) ? { [L[0]]: L[1].error } : null
958
- }, Nr(L), k ? { fetchers: new Map(g.fetchers) } : {}), { flushSync: M }), { shortCircuited: !0 };
959
- }
960
- if (N) {
961
- let k = {};
962
- if (!w) {
963
- k.navigation = A;
964
- let X = hr(L);
965
- X !== void 0 && (k.actionData = X);
966
- }
967
- Y.length > 0 && (k.fetchers = ka(Y)), ee(k, { flushSync: M });
968
- }
969
- Y.forEach((k) => {
970
- xe(k.key), k.controller && Z.set(k.key, k.controller);
971
- });
972
- let Re = () => Y.forEach((k) => xe(k.key));
973
- O && O.signal.addEventListener("abort", Re);
974
- let { loaderResults: Ve, fetcherResults: xt } = await vr(g, m, q, Y, u);
975
- if (u.signal.aborted) return { shortCircuited: !0 };
976
- O && O.signal.removeEventListener("abort", Re), Y.forEach((k) => Z.delete(k.key));
977
- let Pe = Lt(Ve);
978
- if (Pe) return await Ne(u, Pe.result, !0, { replace: C }), { shortCircuited: !0 };
979
- if (Pe = Lt(xt), Pe) return be.add(Pe.key), await Ne(u, Pe.result, !0, { replace: C }), { shortCircuited: !0 };
980
- let { loaderData: je, errors: $e } = Or(g, m, Ve, L, Y, xt, Ae);
981
- Ae.forEach((k, X) => {
982
- k.subscribe((V) => {
983
- (V || k.done) && Ae.delete(X);
984
- });
985
- }), v.v7_partialHydration && P && g.errors && ($e = W({}, g.errors, $e));
986
- let Pt = gr(), Ct = yr(nt), Ce = Pt || Ct || Y.length > 0;
987
- return W({
988
- matches: m,
989
- loaderData: je,
990
- errors: $e
991
- }, Ce ? { fetchers: new Map(g.fetchers) } : {});
992
- }
993
- function hr(u) {
994
- if (u && !le(u[1])) return { [u[0]]: u[1].data };
995
- if (g.actionData) return Object.keys(g.actionData).length === 0 ? null : g.actionData;
996
- }
997
- function ka(u) {
998
- return u.forEach((f) => {
999
- let m = g.fetchers.get(f.key), w = lt(void 0, m ? m.data : void 0);
1000
- g.fetchers.set(f.key, w);
1001
- }), new Map(g.fetchers);
1002
- }
1003
- function Ba(u, f, m, w) {
1004
- if (a) throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");
1005
- xe(u);
1006
- let E = (w && w.flushSync) === !0, D = s || o, T = Xt(g.location, g.matches, l, v.v7_prependBasename, m, v.v7_relativeSplatPath, f, w?.relative), C = De(D, T, l), P = Rt(C, D, T);
1007
- if (P.active && P.matches && (C = P.matches), !C) {
1008
- Ee(u, f, re(404, { pathname: T }), { flushSync: E });
1009
- return;
1010
- }
1011
- let { path: M, submission: L, error: A } = Dr(v.v7_normalizeFormMethod, !0, T, w);
1012
- if (A) {
1013
- Ee(u, f, A, { flushSync: E });
1014
- return;
1015
- }
1016
- let H = ut(C, M), N = (w && w.preventScrollReset) === !0;
1017
- if (L && ve(L.formMethod)) {
1018
- za(u, f, M, H, C, P.active, E, N, L);
1019
- return;
1020
- }
1021
- Ke.set(u, {
1022
- routeId: f,
1023
- path: M
1024
- }), Ha(u, f, M, H, C, P.active, E, N, L);
1025
- }
1026
- async function za(u, f, m, w, E, D, T, C, P) {
1027
- Ht(), Ke.delete(u);
1028
- function M(V) {
1029
- return !V.route.action && !V.route.lazy ? (Ee(u, f, re(405, {
1030
- method: P.formMethod,
1031
- pathname: m,
1032
- routeId: f
1033
- }), { flushSync: T }), !0) : !1;
1034
- }
1035
- if (!D && M(w)) return;
1036
- Se(u, Xn(P, g.fetchers.get(u)), { flushSync: T });
1037
- let L = new AbortController(), A = Ye(e.history, m, L.signal, P);
1038
- if (D) {
1039
- let V = await St(E, new URL(A.url).pathname, A.signal, u);
1040
- if (V.type === "aborted") return;
1041
- if (V.type === "error") {
1042
- Ee(u, f, V.error, { flushSync: T });
1043
- return;
1044
- } else if (V.matches) {
1045
- if (E = V.matches, w = ut(E, m), M(w)) return;
1046
- } else {
1047
- Ee(u, f, re(404, { pathname: m }), { flushSync: T });
1048
- return;
1049
- }
1050
- }
1051
- Z.set(u, L);
1052
- let H = yt, N = (await it("action", g, A, [w], E, u))[w.route.id];
1053
- if (A.signal.aborted) {
1054
- Z.get(u) === L && Z.delete(u);
1055
- return;
1056
- }
1057
- if (v.v7_fetcherPersist && he.has(u)) {
1058
- if (Be(N) || le(N)) {
1059
- Se(u, Le(void 0));
1060
- return;
1061
- }
1062
- } else {
1063
- if (Be(N)) if (Z.delete(u), nt > H) {
1064
- Se(u, Le(void 0));
1065
- return;
1066
- } else return be.add(u), Se(u, lt(P)), Ne(A, N, !1, {
1067
- fetcherSubmission: P,
1068
- preventScrollReset: C
1069
- });
1070
- if (le(N)) {
1071
- Ee(u, f, N.error);
1072
- return;
1073
- }
1074
- }
1075
- if (Te(N)) throw re(400, { type: "defer-action" });
1076
- let J = g.navigation.location || g.location, q = Ye(e.history, J, L.signal), Y = s || o, Re = g.navigation.state !== "idle" ? De(Y, g.navigation.location, l) : g.matches;
1077
- _(Re, "Didn't find any matches after fetcher action");
1078
- let Ve = ++yt;
1079
- He.set(u, Ve);
1080
- let xt = lt(P, N.data);
1081
- g.fetchers.set(u, xt);
1082
- let [Pe, je] = Mr(e.history, g, Re, P, J, !1, v.v7_skipActionErrorRevalidation, we, pt, gt, he, Ke, be, Y, l, [w.route.id, N]);
1083
- je.filter((V) => V.key !== u).forEach((V) => {
1084
- let Je = V.key, Sr = g.fetchers.get(Je), Ga = lt(void 0, Sr ? Sr.data : void 0);
1085
- g.fetchers.set(Je, Ga), xe(Je), V.controller && Z.set(Je, V.controller);
1086
- }), ee({ fetchers: new Map(g.fetchers) });
1087
- let $e = () => je.forEach((V) => xe(V.key));
1088
- L.signal.addEventListener("abort", $e);
1089
- let { loaderResults: Pt, fetcherResults: Ct } = await vr(g, Re, Pe, je, q);
1090
- if (L.signal.aborted) return;
1091
- L.signal.removeEventListener("abort", $e), He.delete(u), Z.delete(u), je.forEach((V) => Z.delete(V.key));
1092
- let Ce = Lt(Pt);
1093
- if (Ce) return Ne(q, Ce.result, !1, { preventScrollReset: C });
1094
- if (Ce = Lt(Ct), Ce) return be.add(Ce.key), Ne(q, Ce.result, !1, { preventScrollReset: C });
1095
- let { loaderData: k, errors: X } = Or(g, Re, Pt, void 0, je, Ct, Ae);
1096
- if (g.fetchers.has(u)) {
1097
- let V = Le(N.data);
1098
- g.fetchers.set(u, V);
1099
- }
1100
- yr(Ve), g.navigation.state === "loading" && Ve > nt ? (_(U, "Expected pending action"), O && O.abort(), We(g.navigation.location, {
1101
- matches: Re,
1102
- loaderData: k,
1103
- errors: X,
1104
- fetchers: new Map(g.fetchers)
1105
- })) : (ee({
1106
- errors: X,
1107
- loaderData: Ir(g.loaderData, k, Re, X),
1108
- fetchers: new Map(g.fetchers)
1109
- }), we = !1);
1110
- }
1111
- async function Ha(u, f, m, w, E, D, T, C, P) {
1112
- let M = g.fetchers.get(u);
1113
- Se(u, lt(P, M ? M.data : void 0), { flushSync: T });
1114
- let L = new AbortController(), A = Ye(e.history, m, L.signal);
1115
- if (D) {
1116
- let J = await St(E, new URL(A.url).pathname, A.signal, u);
1117
- if (J.type === "aborted") return;
1118
- if (J.type === "error") {
1119
- Ee(u, f, J.error, { flushSync: T });
1120
- return;
1121
- } else if (J.matches) E = J.matches, w = ut(E, m);
1122
- else {
1123
- Ee(u, f, re(404, { pathname: m }), { flushSync: T });
1124
- return;
1125
- }
1126
- }
1127
- Z.set(u, L);
1128
- let H = yt, N = (await it("loader", g, A, [w], E, u))[w.route.id];
1129
- if (Te(N) && (N = await ar(N, A.signal, !0) || N), Z.get(u) === L && Z.delete(u), !A.signal.aborted) {
1130
- if (he.has(u)) {
1131
- Se(u, Le(void 0));
1132
- return;
1133
- }
1134
- if (Be(N)) if (nt > H) {
1135
- Se(u, Le(void 0));
1136
- return;
1137
- } else {
1138
- be.add(u), await Ne(A, N, !1, { preventScrollReset: C });
1139
- return;
1140
- }
1141
- if (le(N)) {
1142
- Ee(u, f, N.error);
1143
- return;
1144
- }
1145
- _(!Te(N), "Unhandled fetcher deferred data"), Se(u, Le(N.data));
1146
- }
1147
- }
1148
- async function Ne(u, f, m, w) {
1149
- let { submission: E, fetcherSubmission: D, preventScrollReset: T, replace: C } = w === void 0 ? {} : w;
1150
- f.response.headers.has("X-Remix-Revalidate") && (we = !0);
1151
- let P = f.response.headers.get("Location");
1152
- _(P, "Expected a Location header on the redirect Response"), P = Fr(P, new URL(u.url), l, e.history);
1153
- let M = ze(g.location, P, { _isRedirect: !0 });
1154
- if (r) {
1155
- let q = !1;
1156
- if (f.response.headers.has("X-Remix-Reload-Document")) q = !0;
1157
- else if (tr.test(P)) {
1158
- const Y = e.history.createURL(P);
1159
- q = Y.origin !== t.location.origin || ne(Y.pathname, l) == null;
1160
- }
1161
- if (q) {
1162
- C ? t.location.replace(P) : t.location.assign(P);
1163
- return;
1164
- }
1165
- }
1166
- O = null;
1167
- let L = C === !0 || f.response.headers.has("X-Remix-Replace") ? K.Replace : K.Push, { formMethod: A, formAction: H, formEncType: N } = g.navigation;
1168
- !E && !D && A && H && N && (E = Br(g.navigation));
1169
- let J = E || D;
1170
- Un.has(f.response.status) && J && ve(J.formMethod) ? await Ie(L, M, {
1171
- submission: W({}, J, { formAction: P }),
1172
- preventScrollReset: T || z,
1173
- enableViewTransition: m ? Q : void 0
1174
- }) : await Ie(L, M, {
1175
- overrideNavigation: Jt(M, E),
1176
- fetcherSubmission: D,
1177
- preventScrollReset: T || z,
1178
- enableViewTransition: m ? Q : void 0
1179
- });
1180
- }
1181
- async function it(u, f, m, w, E, D) {
1182
- let T, C = {};
1183
- try {
1184
- T = await jn(d, u, f, m, w, E, D, i, n);
1185
- } catch (P) {
1186
- return w.forEach((M) => {
1187
- C[M.route.id] = {
1188
- type: B.error,
1189
- error: P
1190
- };
1191
- }), C;
1192
- }
1193
- for (let [P, M] of Object.entries(T)) if (Wn(M)) {
1194
- let L = M.result;
1195
- C[P] = {
1196
- type: B.redirect,
1197
- response: zn(L, m, P, E, l, v.v7_relativeSplatPath)
1198
- };
1199
- } else C[P] = await Bn(M);
1200
- return C;
1201
- }
1202
- async function vr(u, f, m, w, E) {
1203
- let D = u.matches, T = it("loader", u, E, m, f, null), C = Promise.all(w.map(async (L) => {
1204
- if (L.matches && L.match && L.controller) {
1205
- let A = (await it("loader", u, Ye(e.history, L.path, L.controller.signal), [L.match], L.matches, L.key))[L.match.route.id];
1206
- return { [L.key]: A };
1207
- } else return Promise.resolve({ [L.key]: {
1208
- type: B.error,
1209
- error: re(404, { pathname: L.path })
1210
- } });
1211
- })), P = await T, M = (await C).reduce((L, A) => Object.assign(L, A), {});
1212
- return await Promise.all([Jn(f, P, E.signal, D, u.loaderData), Yn(f, M, w)]), {
1213
- loaderResults: P,
1214
- fetcherResults: M
1215
- };
1216
- }
1217
- function Ht() {
1218
- we = !0, pt.push(...Wt()), Ke.forEach((u, f) => {
1219
- Z.has(f) && gt.add(f), xe(f);
1220
- });
1221
- }
1222
- function Se(u, f, m) {
1223
- m === void 0 && (m = {}), g.fetchers.set(u, f), ee({ fetchers: new Map(g.fetchers) }, { flushSync: (m && m.flushSync) === !0 });
1224
- }
1225
- function Ee(u, f, m, w) {
1226
- w === void 0 && (w = {});
1227
- let E = ke(g.matches, f);
1228
- bt(u), ee({
1229
- errors: { [E.route.id]: m },
1230
- fetchers: new Map(g.fetchers)
1231
- }, { flushSync: (w && w.flushSync) === !0 });
1232
- }
1233
- function mr(u) {
1234
- return ot.set(u, (ot.get(u) || 0) + 1), he.has(u) && he.delete(u), g.fetchers.get(u) || na;
1235
- }
1236
- function bt(u) {
1237
- let f = g.fetchers.get(u);
1238
- Z.has(u) && !(f && f.state === "loading" && He.has(u)) && xe(u), Ke.delete(u), He.delete(u), be.delete(u), v.v7_fetcherPersist && he.delete(u), gt.delete(u), g.fetchers.delete(u);
1239
- }
1240
- function Ka(u) {
1241
- let f = (ot.get(u) || 0) - 1;
1242
- f <= 0 ? (ot.delete(u), he.add(u), v.v7_fetcherPersist || bt(u)) : ot.set(u, f), ee({ fetchers: new Map(g.fetchers) });
1243
- }
1244
- function xe(u) {
1245
- let f = Z.get(u);
1246
- f && (f.abort(), Z.delete(u));
1247
- }
1248
- function pr(u) {
1249
- for (let f of u) {
1250
- let m = Le(mr(f).data);
1251
- g.fetchers.set(f, m);
1252
- }
1253
- }
1254
- function gr() {
1255
- let u = [], f = !1;
1256
- for (let m of be) {
1257
- let w = g.fetchers.get(m);
1258
- _(w, "Expected fetcher: " + m), w.state === "loading" && (be.delete(m), u.push(m), f = !0);
1259
- }
1260
- return pr(u), f;
1261
- }
1262
- function yr(u) {
1263
- let f = [];
1264
- for (let [m, w] of He) if (w < u) {
1265
- let E = g.fetchers.get(m);
1266
- _(E, "Expected fetcher: " + m), E.state === "loading" && (xe(m), He.delete(m), f.push(m));
1267
- }
1268
- return pr(f), f.length > 0;
1269
- }
1270
- function Wa(u, f) {
1271
- let m = g.blockers.get(u) || Xe;
1272
- return Oe.get(u) !== f && Oe.set(u, f), m;
1273
- }
1274
- function wr(u) {
1275
- g.blockers.delete(u), Oe.delete(u);
1276
- }
1277
- function Et(u, f) {
1278
- let m = g.blockers.get(u) || Xe;
1279
- _(m.state === "unblocked" && f.state === "blocked" || m.state === "blocked" && f.state === "blocked" || m.state === "blocked" && f.state === "proceeding" || m.state === "blocked" && f.state === "unblocked" || m.state === "proceeding" && f.state === "unblocked", "Invalid blocker state transition: " + m.state + " -> " + f.state);
1280
- let w = new Map(g.blockers);
1281
- w.set(u, f), ee({ blockers: w });
1282
- }
1283
- function br(u) {
1284
- let { currentLocation: f, nextLocation: m, historyAction: w } = u;
1285
- if (Oe.size === 0) return;
1286
- Oe.size > 1 && ye(!1, "A router only supports one blocker at a time");
1287
- let E = Array.from(Oe.entries()), [D, T] = E[E.length - 1], C = g.blockers.get(D);
1288
- if (!(C && C.state === "proceeding") && T({
1289
- currentLocation: f,
1290
- nextLocation: m,
1291
- historyAction: w
1292
- })) return D;
1293
- }
1294
- function Kt(u) {
1295
- let f = re(404, { pathname: u }), { matches: m, route: w } = jr(s || o);
1296
- return Wt(), {
1297
- notFoundMatches: m,
1298
- route: w,
1299
- error: f
1300
- };
1301
- }
1302
- function Wt(u) {
1303
- let f = [];
1304
- return Ae.forEach((m, w) => {
1305
- (!u || u(w)) && (m.cancel(), f.push(w), Ae.delete(w));
1306
- }), f;
1307
- }
1308
- function Va(u, f, m) {
1309
- if (b = u, R = f, x = m || null, !F && g.navigation === $t) {
1310
- F = !0;
1311
- let w = Rr(g.location, g.matches);
1312
- w != null && ee({ restoreScrollPosition: w });
1313
- }
1314
- return () => {
1315
- b = null, R = null, x = null;
1316
- };
1317
- }
1318
- function Er(u, f) {
1319
- return x && x(u, f.map((m) => Qr(m, g.loaderData))) || u.key;
1320
- }
1321
- function $a(u, f) {
1322
- if (b && R) {
1323
- let m = Er(u, f);
1324
- b[m] = R();
1325
- }
1326
- }
1327
- function Rr(u, f) {
1328
- if (b) {
1329
- let m = Er(u, f), w = b[m];
1330
- if (typeof w == "number") return w;
1331
- }
1332
- return null;
1333
- }
1334
- function Rt(u, f, m) {
1335
- if (h) if (u) {
1336
- if (Object.keys(u[0].params).length > 0) return {
1337
- active: !0,
1338
- matches: Mt(f, m, l, !0)
1339
- };
1340
- } else return {
1341
- active: !0,
1342
- matches: Mt(f, m, l, !0) || []
1343
- };
1344
- return {
1345
- active: !1,
1346
- matches: null
1347
- };
1348
- }
1349
- async function St(u, f, m, w) {
1350
- if (!h) return {
1351
- type: "success",
1352
- matches: u
1353
- };
1354
- let E = u;
1355
- for (;;) {
1356
- let D = s == null, T = s || o, C = i;
1357
- try {
1358
- await h({
1359
- signal: m,
1360
- path: f,
1361
- matches: E,
1362
- fetcherKey: w,
1363
- patch: (L, A) => {
1364
- m.aborted || Ur(L, A, T, C, n);
1365
- }
1366
- });
1367
- } catch (L) {
1368
- return {
1369
- type: "error",
1370
- error: L,
1371
- partialMatches: E
1372
- };
1373
- } finally {
1374
- D && !m.aborted && (o = [...o]);
1375
- }
1376
- if (m.aborted) return { type: "aborted" };
1377
- let P = De(T, f, l);
1378
- if (P) return {
1379
- type: "success",
1380
- matches: P
1381
- };
1382
- let M = Mt(T, f, l, !0);
1383
- if (!M || E.length === M.length && E.every((L, A) => L.route.id === M[A].route.id)) return {
1384
- type: "success",
1385
- matches: null
1386
- };
1387
- E = M;
1388
- }
1389
- }
1390
- function Ja(u) {
1391
- i = {}, s = Ut(u, n, void 0, i);
1392
- }
1393
- function Ya(u, f) {
1394
- let m = s == null;
1395
- Ur(u, f, s || o, i, n), m && (o = [...o], ee({}));
1396
- }
1397
- return fe = {
1398
- get basename() {
1399
- return l;
1400
- },
1401
- get future() {
1402
- return v;
1403
- },
1404
- get state() {
1405
- return g;
1406
- },
1407
- get routes() {
1408
- return o;
1409
- },
1410
- get window() {
1411
- return t;
1412
- },
1413
- initialize: Fa,
1414
- subscribe: Oa,
1415
- enableScrollRestoration: Va,
1416
- navigate: fr,
1417
- fetch: Ba,
1418
- revalidate: Ia,
1419
- createHref: (u) => e.history.createHref(u),
1420
- encodeLocation: (u) => e.history.encodeLocation(u),
1421
- getFetcher: mr,
1422
- deleteFetcher: Ka,
1423
- dispose: Aa,
1424
- getBlocker: Wa,
1425
- deleteBlocker: wr,
1426
- patchRoutes: Ya,
1427
- _internalFetchControllers: Z,
1428
- _internalActiveDeferreds: Ae,
1429
- _internalSetRoutes: Ja
1430
- }, fe;
1431
- }
1432
- function An(e) {
1433
- return e != null && ("formData" in e && e.formData != null || "body" in e && e.body !== void 0);
1434
- }
1435
- function Xt(e, t, r, a, n, i, o, s) {
1436
- let l, d;
1437
- if (o) {
1438
- l = [];
1439
- for (let v of t) if (l.push(v), v.route.id === o) {
1440
- d = v;
1441
- break;
1442
- }
1443
- } else l = t, d = t[t.length - 1];
1444
- let h = Nt(n || ".", It(l, i), ne(e.pathname, r) || e.pathname, s === "path");
1445
- if (n == null && (h.search = e.search, h.hash = e.hash), (n == null || n === "" || n === ".") && d) {
1446
- let v = nr(h.search);
1447
- if (d.route.index && !v) h.search = h.search ? h.search.replace(/^\?/, "?index&") : "?index";
1448
- else if (!d.route.index && v) {
1449
- let p = new URLSearchParams(h.search), y = p.getAll("index");
1450
- p.delete("index"), y.filter((x) => x).forEach((x) => p.append("index", x));
1451
- let b = p.toString();
1452
- h.search = b ? "?" + b : "";
1453
- }
1454
- }
1455
- return a && r !== "/" && (h.pathname = h.pathname === "/" ? r : ge([r, h.pathname])), me(h);
1456
- }
1457
- function Dr(e, t, r, a) {
1458
- if (!a || !An(a)) return { path: r };
1459
- if (a.formMethod && !$n(a.formMethod)) return {
1460
- path: r,
1461
- error: re(405, { method: a.formMethod })
1462
- };
1463
- let n = () => ({
1464
- path: r,
1465
- error: re(400, { type: "invalid-body" })
1466
- }), i = a.formMethod || "get", o = e ? i.toUpperCase() : i.toLowerCase(), s = sa(r);
1467
- if (a.body !== void 0) {
1468
- if (a.formEncType === "text/plain") {
1469
- if (!ve(o)) return n();
1470
- let p = typeof a.body == "string" ? a.body : a.body instanceof FormData || a.body instanceof URLSearchParams ? Array.from(a.body.entries()).reduce((y, b) => {
1471
- let [x, R] = b;
1472
- return "" + y + x + "=" + R + `
1473
- `;
1474
- }, "") : String(a.body);
1475
- return {
1476
- path: r,
1477
- submission: {
1478
- formMethod: o,
1479
- formAction: s,
1480
- formEncType: a.formEncType,
1481
- formData: void 0,
1482
- json: void 0,
1483
- text: p
1484
- }
1485
- };
1486
- } else if (a.formEncType === "application/json") {
1487
- if (!ve(o)) return n();
1488
- try {
1489
- let p = typeof a.body == "string" ? JSON.parse(a.body) : a.body;
1490
- return {
1491
- path: r,
1492
- submission: {
1493
- formMethod: o,
1494
- formAction: s,
1495
- formEncType: a.formEncType,
1496
- formData: void 0,
1497
- json: p,
1498
- text: void 0
1499
- }
1500
- };
1501
- } catch {
1502
- return n();
1503
- }
1504
- }
1505
- }
1506
- _(typeof FormData == "function", "FormData is not available in this environment");
1507
- let l, d;
1508
- if (a.formData) l = Zt(a.formData), d = a.formData;
1509
- else if (a.body instanceof FormData) l = Zt(a.body), d = a.body;
1510
- else if (a.body instanceof URLSearchParams) l = a.body, d = Ar(l);
1511
- else if (a.body == null) l = new URLSearchParams(), d = new FormData();
1512
- else try {
1513
- l = new URLSearchParams(a.body), d = Ar(l);
1514
- } catch {
1515
- return n();
1516
- }
1517
- let h = {
1518
- formMethod: o,
1519
- formAction: s,
1520
- formEncType: a && a.formEncType || "application/x-www-form-urlencoded",
1521
- formData: d,
1522
- json: void 0,
1523
- text: void 0
1524
- };
1525
- if (ve(h.formMethod)) return {
1526
- path: r,
1527
- submission: h
1528
- };
1529
- let v = de(r);
1530
- return t && v.search && nr(v.search) && l.append("index", ""), v.search = "?" + l, {
1531
- path: me(v),
1532
- submission: h
1533
- };
1534
- }
1535
- function Tr(e, t, r) {
1536
- r === void 0 && (r = !1);
1537
- let a = e.findIndex((n) => n.route.id === t);
1538
- return a >= 0 ? e.slice(0, r ? a + 1 : a) : e;
1539
- }
1540
- function Mr(e, t, r, a, n, i, o, s, l, d, h, v, p, y, b, x) {
1541
- let R = x ? le(x[1]) ? x[1].error : x[1].data : void 0, F = e.createURL(t.location), S = e.createURL(n), I = r;
1542
- i && t.errors ? I = Tr(r, Object.keys(t.errors)[0], !0) : x && le(x[1]) && (I = Tr(r, x[0]));
1543
- let j = x ? x[1].statusCode : void 0, $ = o && j && j >= 400, fe = I.filter((U, z) => {
1544
- let { route: O } = U;
1545
- if (O.lazy) return !0;
1546
- if (O.loader == null) return !1;
1547
- if (i) return Qt(O, t.loaderData, t.errors);
1548
- if (On(t.loaderData, t.matches[z], U) || l.some((ie) => ie === U.route.id)) return !0;
1549
- let Q = t.matches[z], G = U;
1550
- return _r(U, W({
1551
- currentUrl: F,
1552
- currentParams: Q.params,
1553
- nextUrl: S,
1554
- nextParams: G.params
1555
- }, a, {
1556
- actionResult: R,
1557
- actionStatus: j,
1558
- defaultShouldRevalidate: $ ? !1 : s || F.pathname + F.search === S.pathname + S.search || F.search !== S.search || ia(Q, G)
1559
- }));
1560
- }), g = [];
1561
- return v.forEach((U, z) => {
1562
- if (i || !r.some((te) => te.route.id === U.routeId) || h.has(z)) return;
1563
- let O = De(y, U.path, b);
1564
- if (!O) {
1565
- g.push({
1566
- key: z,
1567
- routeId: U.routeId,
1568
- path: U.path,
1569
- matches: null,
1570
- match: null,
1571
- controller: null
1572
- });
1573
- return;
1574
- }
1575
- let Q = t.fetchers.get(z), G = ut(O, U.path), ie = !1;
1576
- p.has(z) ? ie = !1 : d.has(z) ? (d.delete(z), ie = !0) : Q && Q.state !== "idle" && Q.data === void 0 ? ie = s : ie = _r(G, W({
1577
- currentUrl: F,
1578
- currentParams: t.matches[t.matches.length - 1].params,
1579
- nextUrl: S,
1580
- nextParams: r[r.length - 1].params
1581
- }, a, {
1582
- actionResult: R,
1583
- actionStatus: j,
1584
- defaultShouldRevalidate: $ ? !1 : s
1585
- })), ie && g.push({
1586
- key: z,
1587
- routeId: U.routeId,
1588
- path: U.path,
1589
- matches: O,
1590
- match: G,
1591
- controller: new AbortController()
1592
- });
1593
- }), [fe, g];
1594
- }
1595
- function Qt(e, t, r) {
1596
- if (e.lazy) return !0;
1597
- if (!e.loader) return !1;
1598
- let a = t != null && t[e.id] !== void 0, n = r != null && r[e.id] !== void 0;
1599
- return !a && n ? !1 : typeof e.loader == "function" && e.loader.hydrate === !0 ? !0 : !a && !n;
1600
- }
1601
- function On(e, t, r) {
1602
- let a = !t || r.route.id !== t.route.id, n = e[r.route.id] === void 0;
1603
- return a || n;
1604
- }
1605
- function ia(e, t) {
1606
- let r = e.route.path;
1607
- return e.pathname !== t.pathname || r != null && r.endsWith("*") && e.params["*"] !== t.params["*"];
1608
- }
1609
- function _r(e, t) {
1610
- if (e.route.shouldRevalidate) {
1611
- let r = e.route.shouldRevalidate(t);
1612
- if (typeof r == "boolean") return r;
1613
- }
1614
- return t.defaultShouldRevalidate;
1615
- }
1616
- function Ur(e, t, r, a, n) {
1617
- var i;
1618
- let o;
1619
- if (e) {
1620
- let l = a[e];
1621
- _(l, "No route found to patch children into: routeId = " + e), l.children || (l.children = []), o = l.children;
1622
- } else o = r;
1623
- let s = Ut(t.filter((l) => !o.some((d) => la(l, d))), n, [
1624
- e || "_",
1625
- "patch",
1626
- String(((i = o) == null ? void 0 : i.length) || "0")
1627
- ], a);
1628
- o.push(...s);
1629
- }
1630
- function la(e, t) {
1631
- return "id" in e && "id" in t && e.id === t.id ? !0 : e.index === t.index && e.path === t.path && e.caseSensitive === t.caseSensitive ? (!e.children || e.children.length === 0) && (!t.children || t.children.length === 0) ? !0 : e.children.every((r, a) => {
1632
- var n;
1633
- return (n = t.children) == null ? void 0 : n.some((i) => la(r, i));
1634
- }) : !1;
1635
- }
1636
- async function In(e, t, r) {
1637
- if (!e.lazy) return;
1638
- let a = await e.lazy();
1639
- if (!e.lazy) return;
1640
- let n = r[e.id];
1641
- _(n, "No route found in manifest");
1642
- let i = {};
1643
- for (let o in a) {
1644
- let s = n[o] !== void 0 && o !== "hasErrorBoundary";
1645
- ye(!s, "Route \"" + n.id + "\" has a static property \"" + o + "\" defined but its lazy function is also returning a value for this property. " + ("The lazy route property \"" + o + "\" will be ignored.")), !s && !tn.has(o) && (i[o] = a[o]);
1646
- }
1647
- Object.assign(n, i), Object.assign(n, W({}, t(n), { lazy: void 0 }));
1648
- }
1649
- async function Nn(e) {
1650
- let { matches: t } = e, r = t.filter((a) => a.shouldLoad);
1651
- return (await Promise.all(r.map((a) => a.resolve()))).reduce((a, n, i) => Object.assign(a, { [r[i].route.id]: n }), {});
1652
- }
1653
- async function jn(e, t, r, a, n, i, o, s, l, d) {
1654
- let h = i.map((p) => p.route.lazy ? In(p.route, l, s) : void 0), v = await e({
1655
- matches: i.map((p, y) => {
1656
- let b = h[y], x = n.some((F) => F.route.id === p.route.id);
1657
- return W({}, p, {
1658
- shouldLoad: x,
1659
- resolve: async (F) => (F && a.method === "GET" && (p.route.lazy || p.route.loader) && (x = !0), x ? kn(t, a, p, b, F, d) : Promise.resolve({
1660
- type: B.data,
1661
- result: void 0
1662
- }))
1663
- });
1664
- }),
1665
- request: a,
1666
- params: i[0].params,
1667
- fetcherKey: o,
1668
- context: d
1669
- });
1670
- try {
1671
- await Promise.all(h);
1672
- } catch {}
1673
- return v;
1674
- }
1675
- async function kn(e, t, r, a, n, i) {
1676
- let o, s, l = (d) => {
1677
- let h, v = new Promise((b, x) => h = x);
1678
- s = () => h(), t.signal.addEventListener("abort", s);
1679
- let p = (b) => typeof d != "function" ? Promise.reject(new Error("You cannot call the handler for a route which defines a boolean " + ("\"" + e + "\" [routeId: " + r.route.id + "]"))) : d({
1680
- request: t,
1681
- params: r.params,
1682
- context: i
1683
- }, ...b !== void 0 ? [b] : []), y = (async () => {
1684
- try {
1685
- return {
1686
- type: "data",
1687
- result: await (n ? n((b) => p(b)) : p())
1688
- };
1689
- } catch (b) {
1690
- return {
1691
- type: "error",
1692
- result: b
1693
- };
1694
- }
1695
- })();
1696
- return Promise.race([y, v]);
1697
- };
1698
- try {
1699
- let d = r.route[e];
1700
- if (a) if (d) {
1701
- let h, [v] = await Promise.all([l(d).catch((p) => {
1702
- h = p;
1703
- }), a]);
1704
- if (h !== void 0) throw h;
1705
- o = v;
1706
- } else if (await a, d = r.route[e], d) o = await l(d);
1707
- else if (e === "action") {
1708
- let h = new URL(t.url), v = h.pathname + h.search;
1709
- throw re(405, {
1710
- method: t.method,
1711
- pathname: v,
1712
- routeId: r.route.id
1713
- });
1714
- } else return {
1715
- type: B.data,
1716
- result: void 0
1717
- };
1718
- else if (d) o = await l(d);
1719
- else {
1720
- let h = new URL(t.url);
1721
- throw re(404, { pathname: h.pathname + h.search });
1722
- }
1723
- _(o.result !== void 0, "You defined " + (e === "action" ? "an action" : "a loader") + " for route " + ("\"" + r.route.id + "\" but didn't return anything from your `" + e + "` ") + "function. Please return a value or `null`.");
1724
- } catch (d) {
1725
- return {
1726
- type: B.error,
1727
- result: d
1728
- };
1729
- } finally {
1730
- s && t.signal.removeEventListener("abort", s);
1731
- }
1732
- return o;
1733
- }
1734
- async function Bn(e) {
1735
- let { result: t, type: r } = e;
1736
- if (ua(t)) {
1737
- let v;
1738
- try {
1739
- let p = t.headers.get("Content-Type");
1740
- p && /\bapplication\/json\b/.test(p) ? t.body == null ? v = null : v = await t.json() : v = await t.text();
1741
- } catch (p) {
1742
- return {
1743
- type: B.error,
1744
- error: p
1745
- };
1746
- }
1747
- return r === B.error ? {
1748
- type: B.error,
1749
- error: new ct(t.status, t.statusText, v),
1750
- statusCode: t.status,
1751
- headers: t.headers
1752
- } : {
1753
- type: B.data,
1754
- data: v,
1755
- statusCode: t.status,
1756
- headers: t.headers
1757
- };
1758
- }
1759
- if (r === B.error) {
1760
- if (kr(t)) {
1761
- var a, n;
1762
- if (t.data instanceof Error) {
1763
- var i, o;
1764
- return {
1765
- type: B.error,
1766
- error: t.data,
1767
- statusCode: (i = t.init) == null ? void 0 : i.status,
1768
- headers: (o = t.init) != null && o.headers ? new Headers(t.init.headers) : void 0
1769
- };
1770
- }
1771
- return {
1772
- type: B.error,
1773
- error: new ct(((a = t.init) == null ? void 0 : a.status) || 500, void 0, t.data),
1774
- statusCode: Ze(t) ? t.status : void 0,
1775
- headers: (n = t.init) != null && n.headers ? new Headers(t.init.headers) : void 0
1776
- };
1777
- }
1778
- return {
1779
- type: B.error,
1780
- error: t,
1781
- statusCode: Ze(t) ? t.status : void 0
1782
- };
1783
- }
1784
- if (Vn(t)) {
1785
- var s, l;
1786
- return {
1787
- type: B.deferred,
1788
- deferredData: t,
1789
- statusCode: (s = t.init) == null ? void 0 : s.status,
1790
- headers: ((l = t.init) == null ? void 0 : l.headers) && new Headers(t.init.headers)
1791
- };
1792
- }
1793
- if (kr(t)) {
1794
- var d, h;
1795
- return {
1796
- type: B.data,
1797
- data: t.data,
1798
- statusCode: (d = t.init) == null ? void 0 : d.status,
1799
- headers: (h = t.init) != null && h.headers ? new Headers(t.init.headers) : void 0
1800
- };
1801
- }
1802
- return {
1803
- type: B.data,
1804
- data: t
1805
- };
1806
- }
1807
- function zn(e, t, r, a, n, i) {
1808
- let o = e.headers.get("Location");
1809
- if (_(o, "Redirects returned/thrown from loaders/actions must have a Location header"), !tr.test(o)) {
1810
- let s = a.slice(0, a.findIndex((l) => l.route.id === r) + 1);
1811
- o = Xt(new URL(t.url), s, n, !0, o, i), e.headers.set("Location", o);
1812
- }
1813
- return e;
1814
- }
1815
- function Fr(e, t, r, a) {
1816
- let n = [
1817
- "about:",
1818
- "blob:",
1819
- "chrome:",
1820
- "chrome-untrusted:",
1821
- "content:",
1822
- "data:",
1823
- "devtools:",
1824
- "file:",
1825
- "filesystem:",
1826
- "javascript:"
1827
- ];
1828
- if (tr.test(e)) {
1829
- let i = e, o = i.startsWith("//") ? new URL(t.protocol + i) : new URL(i);
1830
- if (n.includes(o.protocol)) throw new Error("Invalid redirect location");
1831
- let s = ne(o.pathname, r) != null;
1832
- if (o.origin === t.origin && s) return qt(o.pathname) + o.search + o.hash;
1833
- }
1834
- try {
1835
- let i = a.createURL(e);
1836
- if (n.includes(i.protocol)) throw new Error("Invalid redirect location");
1837
- } catch {}
1838
- return e;
1839
- }
1840
- function Ye(e, t, r, a) {
1841
- let n = e.createURL(sa(t)).toString(), i = { signal: r };
1842
- if (a && ve(a.formMethod)) {
1843
- let { formMethod: o, formEncType: s } = a;
1844
- i.method = o.toUpperCase(), s === "application/json" ? (i.headers = new Headers({ "Content-Type": s }), i.body = JSON.stringify(a.json)) : s === "text/plain" ? i.body = a.text : s === "application/x-www-form-urlencoded" && a.formData ? i.body = Zt(a.formData) : i.body = a.formData;
1845
- }
1846
- return new Request(n, i);
1847
- }
1848
- function Zt(e) {
1849
- let t = new URLSearchParams();
1850
- for (let [r, a] of e.entries()) t.append(r, typeof a == "string" ? a : a.name);
1851
- return t;
1852
- }
1853
- function Ar(e) {
1854
- let t = new FormData();
1855
- for (let [r, a] of e.entries()) t.append(r, a);
1856
- return t;
1857
- }
1858
- function Hn(e, t, r, a, n) {
1859
- let i = {}, o = null, s, l = !1, d = {}, h = r && le(r[1]) ? r[1].error : void 0;
1860
- return e.forEach((v) => {
1861
- if (!(v.route.id in t)) return;
1862
- let p = v.route.id, y = t[p];
1863
- if (_(!Be(y), "Cannot handle redirect results in processLoaderData"), le(y)) {
1864
- let b = y.error;
1865
- if (h !== void 0 && (b = h, h = void 0), o = o || {}, n) o[p] = b;
1866
- else {
1867
- let x = ke(e, p);
1868
- o[x.route.id] == null && (o[x.route.id] = b);
1869
- }
1870
- i[p] = void 0, l || (l = !0, s = Ze(y.error) ? y.error.status : 500), y.headers && (d[p] = y.headers);
1871
- } else Te(y) ? (a.set(p, y.deferredData), i[p] = y.deferredData.data, y.statusCode != null && y.statusCode !== 200 && !l && (s = y.statusCode), y.headers && (d[p] = y.headers)) : (i[p] = y.data, y.statusCode && y.statusCode !== 200 && !l && (s = y.statusCode), y.headers && (d[p] = y.headers));
1872
- }), h !== void 0 && r && (o = { [r[0]]: h }, i[r[0]] = void 0), {
1873
- loaderData: i,
1874
- errors: o,
1875
- statusCode: s || 200,
1876
- loaderHeaders: d
1877
- };
1878
- }
1879
- function Or(e, t, r, a, n, i, o) {
1880
- let { loaderData: s, errors: l } = Hn(t, r, a, o, !1);
1881
- return n.forEach((d) => {
1882
- let { key: h, match: v, controller: p } = d, y = i[h];
1883
- if (_(y, "Did not find corresponding fetcher result"), !(p && p.signal.aborted)) if (le(y)) {
1884
- let b = ke(e.matches, v?.route.id);
1885
- l && l[b.route.id] || (l = W({}, l, { [b.route.id]: y.error })), e.fetchers.delete(h);
1886
- } else if (Be(y)) _(!1, "Unhandled fetcher revalidation redirect");
1887
- else if (Te(y)) _(!1, "Unhandled fetcher deferred data");
1888
- else {
1889
- let b = Le(y.data);
1890
- e.fetchers.set(h, b);
1891
- }
1892
- }), {
1893
- loaderData: s,
1894
- errors: l
1895
- };
1896
- }
1897
- function Ir(e, t, r, a) {
1898
- let n = W({}, t);
1899
- for (let i of r) {
1900
- let o = i.route.id;
1901
- if (t.hasOwnProperty(o) ? t[o] !== void 0 && (n[o] = t[o]) : e[o] !== void 0 && i.route.loader && (n[o] = e[o]), a && a.hasOwnProperty(o)) break;
1902
- }
1903
- return n;
1904
- }
1905
- function Nr(e) {
1906
- return e ? le(e[1]) ? { actionData: {} } : { actionData: { [e[0]]: e[1].data } } : {};
1907
- }
1908
- function ke(e, t) {
1909
- return (t ? e.slice(0, e.findIndex((r) => r.route.id === t) + 1) : [...e]).reverse().find((r) => r.route.hasErrorBoundary === !0) || e[0];
1910
- }
1911
- function jr(e) {
1912
- let t = e.length === 1 ? e[0] : e.find((r) => r.index || !r.path || r.path === "/") || { id: "__shim-error-route__" };
1913
- return {
1914
- matches: [{
1915
- params: {},
1916
- pathname: "",
1917
- pathnameBase: "",
1918
- route: t
1919
- }],
1920
- route: t
1921
- };
1922
- }
1923
- function re(e, t) {
1924
- let { pathname: r, routeId: a, method: n, type: i, message: o } = t === void 0 ? {} : t, s = "Unknown Server Error", l = "Unknown @remix-run/router error";
1925
- return e === 400 ? (s = "Bad Request", n && r && a ? l = "You made a " + n + " request to \"" + r + "\" but " + ("did not provide a `loader` for route \"" + a + "\", ") + "so there is no way to handle the request." : i === "defer-action" ? l = "defer() is not supported in actions" : i === "invalid-body" && (l = "Unable to encode submission body")) : e === 403 ? (s = "Forbidden", l = "Route \"" + a + "\" does not match URL \"" + r + "\"") : e === 404 ? (s = "Not Found", l = "No route matches URL \"" + r + "\"") : e === 405 && (s = "Method Not Allowed", n && r && a ? l = "You made a " + n.toUpperCase() + " request to \"" + r + "\" but " + ("did not provide an `action` for route \"" + a + "\", ") + "so there is no way to handle the request." : n && (l = "Invalid request method \"" + n.toUpperCase() + "\"")), new ct(e || 500, s, new Error(l), !0);
1926
- }
1927
- function Lt(e) {
1928
- let t = Object.entries(e);
1929
- for (let r = t.length - 1; r >= 0; r--) {
1930
- let [a, n] = t[r];
1931
- if (Be(n)) return {
1932
- key: a,
1933
- result: n
1934
- };
1935
- }
1936
- }
1937
- function sa(e) {
1938
- let t = typeof e == "string" ? de(e) : e;
1939
- return me(W({}, t, { hash: "" }));
1940
- }
1941
- function Kn(e, t) {
1942
- return e.pathname !== t.pathname || e.search !== t.search ? !1 : e.hash === "" ? t.hash !== "" : e.hash === t.hash ? !0 : t.hash !== "";
1943
- }
1944
- function Wn(e) {
1945
- return ua(e.result) && _n.has(e.result.status);
1946
- }
1947
- function Te(e) {
1948
- return e.type === B.deferred;
1949
- }
1950
- function le(e) {
1951
- return e.type === B.error;
1952
- }
1953
- function Be(e) {
1954
- return (e && e.type) === B.redirect;
1955
- }
1956
- function kr(e) {
1957
- return typeof e == "object" && e != null && "type" in e && "data" in e && "init" in e && e.type === "DataWithResponseInit";
1958
- }
1959
- function Vn(e) {
1960
- let t = e;
1961
- return t && typeof t == "object" && typeof t.data == "object" && typeof t.subscribe == "function" && typeof t.cancel == "function" && typeof t.resolveData == "function";
1962
- }
1963
- function ua(e) {
1964
- return e != null && typeof e.status == "number" && typeof e.statusText == "string" && typeof e.headers == "object" && typeof e.body < "u";
1965
- }
1966
- function $n(e) {
1967
- return Mn.has(e.toLowerCase());
1968
- }
1969
- function ve(e) {
1970
- return Dn.has(e.toLowerCase());
1971
- }
1972
- async function Jn(e, t, r, a, n) {
1973
- let i = Object.entries(t);
1974
- for (let o = 0; o < i.length; o++) {
1975
- let [s, l] = i[o], d = e.find((p) => p?.route.id === s);
1976
- if (!d) continue;
1977
- let h = a.find((p) => p.route.id === d.route.id), v = h != null && !ia(h, d) && (n && n[d.route.id]) !== void 0;
1978
- Te(l) && v && await ar(l, r, !1).then((p) => {
1979
- p && (t[s] = p);
1980
- });
1981
- }
1982
- }
1983
- async function Yn(e, t, r) {
1984
- for (let a = 0; a < r.length; a++) {
1985
- let { key: n, routeId: i, controller: o } = r[a], s = t[n];
1986
- e.find((l) => l?.route.id === i) && Te(s) && (_(o, "Expected an AbortController for revalidating fetcher deferred result"), await ar(s, o.signal, !0).then((l) => {
1987
- l && (t[n] = l);
1988
- }));
1989
- }
1990
- }
1991
- async function ar(e, t, r) {
1992
- if (r === void 0 && (r = !1), !await e.deferredData.resolveData(t)) {
1993
- if (r) try {
1994
- return {
1995
- type: B.data,
1996
- data: e.deferredData.unwrappedData
1997
- };
1998
- } catch (a) {
1999
- return {
2000
- type: B.error,
2001
- error: a
2002
- };
2003
- }
2004
- return {
2005
- type: B.data,
2006
- data: e.deferredData.data
2007
- };
2008
- }
2009
- }
2010
- function nr(e) {
2011
- return new URLSearchParams(e).getAll("index").some((t) => t === "");
2012
- }
2013
- function ut(e, t) {
2014
- let r = typeof t == "string" ? de(t).search : t.search;
2015
- if (e[e.length - 1].route.index && nr(r || "")) return e[e.length - 1];
2016
- let a = ra(e);
2017
- return a[a.length - 1];
2018
- }
2019
- function Br(e) {
2020
- let { formMethod: t, formAction: r, formEncType: a, text: n, formData: i, json: o } = e;
2021
- if (!(!t || !r || !a)) {
2022
- if (n != null) return {
2023
- formMethod: t,
2024
- formAction: r,
2025
- formEncType: a,
2026
- formData: void 0,
2027
- json: void 0,
2028
- text: n
2029
- };
2030
- if (i != null) return {
2031
- formMethod: t,
2032
- formAction: r,
2033
- formEncType: a,
2034
- formData: i,
2035
- json: void 0,
2036
- text: void 0
2037
- };
2038
- if (o !== void 0) return {
2039
- formMethod: t,
2040
- formAction: r,
2041
- formEncType: a,
2042
- formData: void 0,
2043
- json: o,
2044
- text: void 0
2045
- };
2046
- }
2047
- }
2048
- function Jt(e, t) {
2049
- return t ? {
2050
- state: "loading",
2051
- location: e,
2052
- formMethod: t.formMethod,
2053
- formAction: t.formAction,
2054
- formEncType: t.formEncType,
2055
- formData: t.formData,
2056
- json: t.json,
2057
- text: t.text
2058
- } : {
2059
- state: "loading",
2060
- location: e,
2061
- formMethod: void 0,
2062
- formAction: void 0,
2063
- formEncType: void 0,
2064
- formData: void 0,
2065
- json: void 0,
2066
- text: void 0
2067
- };
2068
- }
2069
- function Gn(e, t) {
2070
- return {
2071
- state: "submitting",
2072
- location: e,
2073
- formMethod: t.formMethod,
2074
- formAction: t.formAction,
2075
- formEncType: t.formEncType,
2076
- formData: t.formData,
2077
- json: t.json,
2078
- text: t.text
2079
- };
2080
- }
2081
- function lt(e, t) {
2082
- return e ? {
2083
- state: "loading",
2084
- formMethod: e.formMethod,
2085
- formAction: e.formAction,
2086
- formEncType: e.formEncType,
2087
- formData: e.formData,
2088
- json: e.json,
2089
- text: e.text,
2090
- data: t
2091
- } : {
2092
- state: "loading",
2093
- formMethod: void 0,
2094
- formAction: void 0,
2095
- formEncType: void 0,
2096
- formData: void 0,
2097
- json: void 0,
2098
- text: void 0,
2099
- data: t
2100
- };
2101
- }
2102
- function Xn(e, t) {
2103
- return {
2104
- state: "submitting",
2105
- formMethod: e.formMethod,
2106
- formAction: e.formAction,
2107
- formEncType: e.formEncType,
2108
- formData: e.formData,
2109
- json: e.json,
2110
- text: e.text,
2111
- data: t ? t.data : void 0
2112
- };
2113
- }
2114
- function Le(e) {
2115
- return {
2116
- state: "idle",
2117
- formMethod: void 0,
2118
- formAction: void 0,
2119
- formEncType: void 0,
2120
- formData: void 0,
2121
- json: void 0,
2122
- text: void 0,
2123
- data: e
2124
- };
2125
- }
2126
- function Qn(e, t) {
2127
- try {
2128
- let r = e.sessionStorage.getItem(oa);
2129
- if (r) {
2130
- let a = JSON.parse(r);
2131
- for (let [n, i] of Object.entries(a || {})) i && Array.isArray(i) && t.set(n, new Set(i || []));
2132
- }
2133
- } catch {}
2134
- }
2135
- function Zn(e, t) {
2136
- if (t.size > 0) {
2137
- let r = {};
2138
- for (let [a, n] of t) r[a] = [...n];
2139
- try {
2140
- e.sessionStorage.setItem(oa, JSON.stringify(r));
2141
- } catch (a) {
2142
- ye(!1, "Failed to save applied view transitions in sessionStorage (" + a + ").");
2143
- }
2144
- }
2145
- }
2146
- function Me() {
2147
- return Me = Object.assign ? Object.assign.bind() : function(e) {
2148
- for (var t = 1; t < arguments.length; t++) {
2149
- var r = arguments[t];
2150
- for (var a in r) ({}).hasOwnProperty.call(r, a) && (e[a] = r[a]);
2151
- }
2152
- return e;
2153
- }, Me.apply(null, arguments);
2154
- }
2155
- var et = c.createContext(null), ht = c.createContext(null), At = c.createContext(null), se = c.createContext(null), tt = c.createContext(null), ue = c.createContext({
2156
- outlet: null,
2157
- matches: [],
2158
- isDataRoute: !1
2159
- }), ca = c.createContext(null);
2160
- function da(e, t) {
2161
- let { relative: r } = t === void 0 ? {} : t;
2162
- !Ue() && _(!1);
2163
- let { basename: a, navigator: n } = c.useContext(se), { hash: i, pathname: o, search: s } = rt(e, { relative: r }), l = o;
2164
- return a !== "/" && (l = o === "/" ? a : ge([a, o])), n.createHref({
2165
- pathname: l,
2166
- search: s,
2167
- hash: i
2168
- });
2169
- }
2170
- function Ue() {
2171
- return c.useContext(tt) != null;
2172
- }
2173
- function pe() {
2174
- return !Ue() && _(!1), c.useContext(tt).location;
2175
- }
2176
- function qn() {
2177
- return c.useContext(tt).navigationType;
2178
- }
2179
- function eo(e) {
2180
- !Ue() && _(!1);
2181
- let { pathname: t } = pe();
2182
- return c.useMemo(() => Qe(e, ea(t)), [t, e]);
2183
- }
2184
- function fa(e) {
2185
- c.useContext(se).static || c.useLayoutEffect(e);
2186
- }
2187
- function jt() {
2188
- let { isDataRoute: e } = c.useContext(ue);
2189
- return e ? po() : to();
2190
- }
2191
- function to() {
2192
- !Ue() && _(!1);
2193
- let e = c.useContext(et), { basename: t, future: r, navigator: a } = c.useContext(se), { matches: n } = c.useContext(ue), { pathname: i } = pe(), o = JSON.stringify(It(n, r.v7_relativeSplatPath)), s = c.useRef(!1);
2194
- return fa(() => {
2195
- s.current = !0;
2196
- }), c.useCallback(function(l, d) {
2197
- if (d === void 0 && (d = {}), !s.current) return;
2198
- if (typeof l == "number") {
2199
- a.go(l);
2200
- return;
2201
- }
2202
- let h = Nt(l, JSON.parse(o), i, d.relative === "path");
2203
- e == null && t !== "/" && (h.pathname = h.pathname === "/" ? t : ge([t, h.pathname])), (d.replace ? a.replace : a.push)(h, d.state, d);
2204
- }, [
2205
- t,
2206
- a,
2207
- o,
2208
- i,
2209
- e
2210
- ]);
2211
- }
2212
- var ha = c.createContext(null);
2213
- function ro() {
2214
- return c.useContext(ha);
2215
- }
2216
- function va(e) {
2217
- let t = c.useContext(ue).outlet;
2218
- return t && c.createElement(ha.Provider, { value: e }, t);
2219
- }
2220
- function ao() {
2221
- let { matches: e } = c.useContext(ue), t = e[e.length - 1];
2222
- return t ? t.params : {};
2223
- }
2224
- function rt(e, t) {
2225
- let { relative: r } = t === void 0 ? {} : t, { future: a } = c.useContext(se), { matches: n } = c.useContext(ue), { pathname: i } = pe(), o = JSON.stringify(It(n, a.v7_relativeSplatPath));
2226
- return c.useMemo(() => Nt(e, JSON.parse(o), i, r === "path"), [
2227
- e,
2228
- o,
2229
- i,
2230
- r
2231
- ]);
2232
- }
2233
- function ma(e, t) {
2234
- return pa(e, t);
2235
- }
2236
- function pa(e, t, r, a) {
2237
- !Ue() && _(!1);
2238
- let { navigator: n } = c.useContext(se), { matches: i } = c.useContext(ue), o = i[i.length - 1], s = o ? o.params : {};
2239
- o && o.pathname;
2240
- let l = o ? o.pathnameBase : "/";
2241
- o && o.route;
2242
- let d = pe(), h;
2243
- if (t) {
2244
- var v;
2245
- let R = typeof t == "string" ? de(t) : t;
2246
- !(l === "/" || (v = R.pathname) != null && v.startsWith(l)) && _(!1), h = R;
2247
- } else h = d;
2248
- let p = h.pathname || "/", y = p;
2249
- if (l !== "/") {
2250
- let R = l.replace(/^\//, "").split("/");
2251
- y = "/" + p.replace(/^\//, "").split("/").slice(R.length).join("/");
2252
- }
2253
- let b = De(e, { pathname: y }), x = ga(b && b.map((R) => Object.assign({}, R, {
2254
- params: Object.assign({}, s, R.params),
2255
- pathname: ge([l, n.encodeLocation ? n.encodeLocation(R.pathname).pathname : R.pathname]),
2256
- pathnameBase: R.pathnameBase === "/" ? l : ge([l, n.encodeLocation ? n.encodeLocation(R.pathnameBase).pathname : R.pathnameBase])
2257
- })), i, r, a);
2258
- return t && x ? c.createElement(tt.Provider, { value: {
2259
- location: Me({
2260
- pathname: "/",
2261
- search: "",
2262
- hash: "",
2263
- state: null,
2264
- key: "default"
2265
- }, h),
2266
- navigationType: K.Pop
2267
- } }, x) : x;
2268
- }
2269
- function no() {
2270
- let e = Ea(), t = Ze(e) ? e.status + " " + e.statusText : e instanceof Error ? e.message : JSON.stringify(e), r = e instanceof Error ? e.stack : null;
2271
- return c.createElement(c.Fragment, null, c.createElement("h2", null, "Unexpected Application Error!"), c.createElement("h3", { style: { fontStyle: "italic" } }, t), r ? c.createElement("pre", { style: {
2272
- padding: "0.5rem",
2273
- backgroundColor: "rgba(200,200,200, 0.5)"
2274
- } }, r) : null, null);
2275
- }
2276
- var oo = c.createElement(no, null), io = class extends c.Component {
2277
- constructor(e) {
2278
- super(e), this.state = {
2279
- location: e.location,
2280
- revalidation: e.revalidation,
2281
- error: e.error
2282
- };
2283
- }
2284
- static getDerivedStateFromError(e) {
2285
- return { error: e };
2286
- }
2287
- static getDerivedStateFromProps(e, t) {
2288
- return t.location !== e.location || t.revalidation !== "idle" && e.revalidation === "idle" ? {
2289
- error: e.error,
2290
- location: e.location,
2291
- revalidation: e.revalidation
2292
- } : {
2293
- error: e.error !== void 0 ? e.error : t.error,
2294
- location: t.location,
2295
- revalidation: e.revalidation || t.revalidation
2296
- };
2297
- }
2298
- componentDidCatch(e, t) {}
2299
- render() {
2300
- return this.state.error !== void 0 ? c.createElement(ue.Provider, { value: this.props.routeContext }, c.createElement(ca.Provider, {
2301
- value: this.state.error,
2302
- children: this.props.component
2303
- })) : this.props.children;
2304
- }
2305
- };
2306
- function lo(e) {
2307
- let { routeContext: t, match: r, children: a } = e, n = c.useContext(et);
2308
- return n && n.static && n.staticContext && (r.route.errorElement || r.route.ErrorBoundary) && (n.staticContext._deepestRenderedBoundaryId = r.route.id), c.createElement(ue.Provider, { value: t }, a);
2309
- }
2310
- function ga(e, t, r, a) {
2311
- var n;
2312
- if (t === void 0 && (t = []), r === void 0 && (r = null), a === void 0 && (a = null), e == null) {
2313
- var i;
2314
- if (!r) return null;
2315
- if (r.errors) e = r.matches;
2316
- else if ((i = a) != null && i.v7_partialHydration && t.length === 0 && !r.initialized && r.matches.length > 0) e = r.matches;
2317
- else return null;
2318
- }
2319
- let o = e, s = (n = r) == null ? void 0 : n.errors;
2320
- if (s != null) {
2321
- let h = o.findIndex((v) => v.route.id && s?.[v.route.id] !== void 0);
2322
- !(h >= 0) && _(!1), o = o.slice(0, Math.min(o.length, h + 1));
2323
- }
2324
- let l = !1, d = -1;
2325
- if (r && a && a.v7_partialHydration) for (let h = 0; h < o.length; h++) {
2326
- let v = o[h];
2327
- if ((v.route.HydrateFallback || v.route.hydrateFallbackElement) && (d = h), v.route.id) {
2328
- let { loaderData: p, errors: y } = r, b = v.route.loader && p[v.route.id] === void 0 && (!y || y[v.route.id] === void 0);
2329
- if (v.route.lazy || b) {
2330
- l = !0, d >= 0 ? o = o.slice(0, d + 1) : o = [o[0]];
2331
- break;
2332
- }
2333
- }
2334
- }
2335
- return o.reduceRight((h, v, p) => {
2336
- let y, b = !1, x = null, R = null;
2337
- r && (y = s && v.route.id ? s[v.route.id] : void 0, x = v.route.errorElement || oo, l && (d < 0 && p === 0 ? (go("route-fallback", !1, "No `HydrateFallback` element provided to render during initial hydration"), b = !0, R = null) : d === p && (b = !0, R = v.route.hydrateFallbackElement || null)));
2338
- let F = t.concat(o.slice(0, p + 1)), S = () => {
2339
- let I;
2340
- return y ? I = x : b ? I = R : v.route.Component ? I = c.createElement(v.route.Component, null) : v.route.element ? I = v.route.element : I = h, c.createElement(lo, {
2341
- match: v,
2342
- routeContext: {
2343
- outlet: h,
2344
- matches: F,
2345
- isDataRoute: r != null
2346
- },
2347
- children: I
2348
- });
2349
- };
2350
- return r && (v.route.ErrorBoundary || v.route.errorElement || p === 0) ? c.createElement(io, {
2351
- location: r.location,
2352
- revalidation: r.revalidation,
2353
- component: x,
2354
- error: y,
2355
- children: S(),
2356
- routeContext: {
2357
- outlet: null,
2358
- matches: F,
2359
- isDataRoute: !0
2360
- }
2361
- }) : S();
2362
- }, null);
2363
- }
2364
- var kt = (function(e) {
2365
- return e.UseBlocker = "useBlocker", e.UseRevalidator = "useRevalidator", e.UseNavigateStable = "useNavigate", e;
2366
- })(kt || {}), oe = (function(e) {
2367
- return e.UseBlocker = "useBlocker", e.UseLoaderData = "useLoaderData", e.UseActionData = "useActionData", e.UseRouteError = "useRouteError", e.UseNavigation = "useNavigation", e.UseRouteLoaderData = "useRouteLoaderData", e.UseMatches = "useMatches", e.UseRevalidator = "useRevalidator", e.UseNavigateStable = "useNavigate", e.UseRouteId = "useRouteId", e;
2368
- })(oe || {});
2369
- function or(e) {
2370
- let t = c.useContext(et);
2371
- return !t && _(!1), t;
2372
- }
2373
- function Fe(e) {
2374
- let t = c.useContext(ht);
2375
- return !t && _(!1), t;
2376
- }
2377
- function so(e) {
2378
- let t = c.useContext(ue);
2379
- return !t && _(!1), t;
2380
- }
2381
- function vt(e) {
2382
- let t = so(e), r = t.matches[t.matches.length - 1];
2383
- return !r.route.id && _(!1), r.route.id;
2384
- }
2385
- function ya() {
2386
- return vt(oe.UseRouteId);
2387
- }
2388
- function wa() {
2389
- return Fe(oe.UseNavigation).navigation;
2390
- }
2391
- function uo() {
2392
- let e = or(kt.UseRevalidator), t = Fe(oe.UseRevalidator);
2393
- return c.useMemo(() => ({
2394
- revalidate: e.router.revalidate,
2395
- state: t.revalidation
2396
- }), [e.router.revalidate, t.revalidation]);
2397
- }
2398
- function ba() {
2399
- let { matches: e, loaderData: t } = Fe(oe.UseMatches);
2400
- return c.useMemo(() => e.map((r) => Qr(r, t)), [e, t]);
2401
- }
2402
- function co() {
2403
- let e = Fe(oe.UseLoaderData), t = vt(oe.UseLoaderData);
2404
- if (!(e.errors && e.errors[t] != null)) return e.loaderData[t];
2405
- }
2406
- function fo(e) {
2407
- return Fe(oe.UseRouteLoaderData).loaderData[e];
2408
- }
2409
- function ho() {
2410
- let e = Fe(oe.UseActionData), t = vt(oe.UseLoaderData);
2411
- return e.actionData ? e.actionData[t] : void 0;
2412
- }
2413
- function Ea() {
2414
- var e;
2415
- let t = c.useContext(ca), r = Fe(oe.UseRouteError), a = vt(oe.UseRouteError);
2416
- return t !== void 0 ? t : (e = r.errors) == null ? void 0 : e[a];
2417
- }
2418
- function Ra() {
2419
- return c.useContext(At)?._data;
2420
- }
2421
- function vo() {
2422
- return c.useContext(At)?._error;
2423
- }
2424
- var mo = 0;
2425
- function Sa(e) {
2426
- let { router: t, basename: r } = or(kt.UseBlocker), a = Fe(oe.UseBlocker), [n, i] = c.useState(""), o = c.useCallback((s) => {
2427
- if (typeof e != "function") return !!e;
2428
- if (r === "/") return e(s);
2429
- let { currentLocation: l, nextLocation: d, historyAction: h } = s;
2430
- return e({
2431
- currentLocation: Me({}, l, { pathname: ne(l.pathname, r) || l.pathname }),
2432
- nextLocation: Me({}, d, { pathname: ne(d.pathname, r) || d.pathname }),
2433
- historyAction: h
2434
- });
2435
- }, [r, e]);
2436
- return c.useEffect(() => {
2437
- let s = String(++mo);
2438
- return i(s), () => t.deleteBlocker(s);
2439
- }, [t]), c.useEffect(() => {
2440
- n !== "" && t.getBlocker(n, o);
2441
- }, [
2442
- t,
2443
- n,
2444
- o
2445
- ]), n && a.blockers.has(n) ? a.blockers.get(n) : Xe;
2446
- }
2447
- function po() {
2448
- let { router: e } = or(kt.UseNavigateStable), t = vt(oe.UseNavigateStable), r = c.useRef(!1);
2449
- return fa(() => {
2450
- r.current = !0;
2451
- }), c.useCallback(function(a, n) {
2452
- n === void 0 && (n = {}), r.current && (typeof a == "number" ? e.navigate(a) : e.navigate(a, Me({ fromRouteId: t }, n)));
2453
- }, [e, t]);
2454
- }
2455
- var zr = {};
2456
- function go(e, t, r) {
2457
- !t && !zr[e] && (zr[e] = !0);
2458
- }
2459
- var Ge = (e, t, r) => ("" + t + ("You can use the `" + e + "` future flag to opt-in early. ") + ("For more information, see " + r + "."), void 0);
2460
- function mt(e, t) {
2461
- e?.v7_startTransition === void 0 && Ge("v7_startTransition", "React Router will begin wrapping state updates in `React.startTransition` in v7", "https://reactrouter.com/v6/upgrading/future#v7_starttransition"), e?.v7_relativeSplatPath === void 0 && (!t || t.v7_relativeSplatPath === void 0) && Ge("v7_relativeSplatPath", "Relative route resolution within Splat routes is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_relativesplatpath"), t && (t.v7_fetcherPersist === void 0 && Ge("v7_fetcherPersist", "The persistence behavior of fetchers is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_fetcherpersist"), t.v7_normalizeFormMethod === void 0 && Ge("v7_normalizeFormMethod", "Casing of `formMethod` fields is being normalized to uppercase in v7", "https://reactrouter.com/v6/upgrading/future#v7_normalizeformmethod"), t.v7_partialHydration === void 0 && Ge("v7_partialHydration", "`RouterProvider` hydration behavior is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_partialhydration"), t.v7_skipActionErrorRevalidation === void 0 && Ge("v7_skipActionErrorRevalidation", "The revalidation behavior after 4xx/5xx `action` responses is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_skipactionerrorrevalidation"));
2462
- }
2463
- var Hr = c.startTransition;
2464
- function yo(e) {
2465
- let { basename: t, children: r, initialEntries: a, initialIndex: n, future: i } = e, o = c.useRef();
2466
- o.current == null && (o.current = Jr({
2467
- initialEntries: a,
2468
- initialIndex: n,
2469
- v5Compat: !0
2470
- }));
2471
- let s = o.current, [l, d] = c.useState({
2472
- action: s.action,
2473
- location: s.location
2474
- }), { v7_startTransition: h } = i || {}, v = c.useCallback((p) => {
2475
- h && Hr ? Hr(() => d(p)) : d(p);
2476
- }, [d, h]);
2477
- return c.useLayoutEffect(() => s.listen(v), [s, v]), c.useEffect(() => mt(i), [i]), c.createElement(at, {
2478
- basename: t,
2479
- children: r,
2480
- location: l.location,
2481
- navigationType: l.action,
2482
- navigator: s,
2483
- future: i
2484
- });
2485
- }
2486
- function wo(e) {
2487
- let { to: t, replace: r, state: a, relative: n } = e;
2488
- !Ue() && _(!1);
2489
- let { future: i, static: o } = c.useContext(se), { matches: s } = c.useContext(ue), { pathname: l } = pe(), d = jt(), h = Nt(t, It(s, i.v7_relativeSplatPath), l, n === "path"), v = JSON.stringify(h);
2490
- return c.useEffect(() => d(JSON.parse(v), {
2491
- replace: r,
2492
- state: a,
2493
- relative: n
2494
- }), [
2495
- d,
2496
- v,
2497
- n,
2498
- r,
2499
- a
2500
- ]), null;
2501
- }
2502
- function bo(e) {
2503
- return va(e.context);
2504
- }
2505
- function xa(e) {
2506
- _(!1);
2507
- }
2508
- function at(e) {
2509
- let { basename: t = "/", children: r = null, location: a, navigationType: n = K.Pop, navigator: i, static: o = !1, future: s } = e;
2510
- Ue() && _(!1);
2511
- let l = t.replace(/^\/*/, "/"), d = c.useMemo(() => ({
2512
- basename: l,
2513
- navigator: i,
2514
- static: o,
2515
- future: Me({ v7_relativeSplatPath: !1 }, s)
2516
- }), [
2517
- l,
2518
- s,
2519
- i,
2520
- o
2521
- ]);
2522
- typeof a == "string" && (a = de(a));
2523
- let { pathname: h = "/", search: v = "", hash: p = "", state: y = null, key: b = "default" } = a, x = c.useMemo(() => {
2524
- let R = ne(h, l);
2525
- return R == null ? null : {
2526
- location: {
2527
- pathname: R,
2528
- search: v,
2529
- hash: p,
2530
- state: y,
2531
- key: b
2532
- },
2533
- navigationType: n
2534
- };
2535
- }, [
2536
- l,
2537
- h,
2538
- v,
2539
- p,
2540
- y,
2541
- b,
2542
- n
2543
- ]);
2544
- return x == null ? null : c.createElement(se.Provider, { value: d }, c.createElement(tt.Provider, {
2545
- children: r,
2546
- value: x
2547
- }));
2548
- }
2549
- function Eo(e) {
2550
- let { children: t, location: r } = e;
2551
- return ma(dt(t), r);
2552
- }
2553
- function Ro(e) {
2554
- let { children: t, errorElement: r, resolve: a } = e;
2555
- return c.createElement(xo, {
2556
- resolve: a,
2557
- errorElement: r
2558
- }, c.createElement(Po, null, t));
2559
- }
2560
- var ce = (function(e) {
2561
- return e[e.pending = 0] = "pending", e[e.success = 1] = "success", e[e.error = 2] = "error", e;
2562
- })(ce || {}), So = new Promise(() => {}), xo = class extends c.Component {
2563
- constructor(e) {
2564
- super(e), this.state = { error: null };
2565
- }
2566
- static getDerivedStateFromError(e) {
2567
- return { error: e };
2568
- }
2569
- componentDidCatch(e, t) {}
2570
- render() {
2571
- let { children: e, errorElement: t, resolve: r } = this.props, a = null, n = ce.pending;
2572
- if (!(r instanceof Promise)) n = ce.success, a = Promise.resolve(), Object.defineProperty(a, "_tracked", { get: () => !0 }), Object.defineProperty(a, "_data", { get: () => r });
2573
- else if (this.state.error) {
2574
- n = ce.error;
2575
- let i = this.state.error;
2576
- a = Promise.reject().catch(() => {}), Object.defineProperty(a, "_tracked", { get: () => !0 }), Object.defineProperty(a, "_error", { get: () => i });
2577
- } else r._tracked ? (a = r, n = "_error" in a ? ce.error : "_data" in a ? ce.success : ce.pending) : (n = ce.pending, Object.defineProperty(r, "_tracked", { get: () => !0 }), a = r.then((i) => Object.defineProperty(r, "_data", { get: () => i }), (i) => Object.defineProperty(r, "_error", { get: () => i })));
2578
- if (n === ce.error && a._error instanceof Ft) throw So;
2579
- if (n === ce.error && !t) throw a._error;
2580
- if (n === ce.error) return c.createElement(At.Provider, {
2581
- value: a,
2582
- children: t
2583
- });
2584
- if (n === ce.success) return c.createElement(At.Provider, {
2585
- value: a,
2586
- children: e
2587
- });
2588
- throw a;
2589
- }
2590
- };
2591
- function Po(e) {
2592
- let { children: t } = e, r = Ra(), a = typeof t == "function" ? t(r) : t;
2593
- return c.createElement(c.Fragment, null, a);
2594
- }
2595
- function dt(e, t) {
2596
- t === void 0 && (t = []);
2597
- let r = [];
2598
- return c.Children.forEach(e, (a, n) => {
2599
- if (!c.isValidElement(a)) return;
2600
- let i = [...t, n];
2601
- if (a.type === c.Fragment) {
2602
- r.push.apply(r, dt(a.props.children, i));
2603
- return;
2604
- }
2605
- a.type !== xa && _(!1), !(!a.props.index || !a.props.children) && _(!1);
2606
- let o = {
2607
- id: a.props.id || i.join("-"),
2608
- caseSensitive: a.props.caseSensitive,
2609
- element: a.props.element,
2610
- Component: a.props.Component,
2611
- index: a.props.index,
2612
- path: a.props.path,
2613
- loader: a.props.loader,
2614
- action: a.props.action,
2615
- errorElement: a.props.errorElement,
2616
- ErrorBoundary: a.props.ErrorBoundary,
2617
- hasErrorBoundary: a.props.ErrorBoundary != null || a.props.errorElement != null,
2618
- shouldRevalidate: a.props.shouldRevalidate,
2619
- handle: a.props.handle,
2620
- lazy: a.props.lazy
2621
- };
2622
- a.props.children && (o.children = dt(a.props.children, i)), r.push(o);
2623
- }), r;
2624
- }
2625
- function Co(e) {
2626
- return ga(e);
2627
- }
2628
- function ir(e) {
2629
- let t = { hasErrorBoundary: e.ErrorBoundary != null || e.errorElement != null };
2630
- return e.Component && Object.assign(t, {
2631
- element: c.createElement(e.Component),
2632
- Component: void 0
2633
- }), e.HydrateFallback && Object.assign(t, {
2634
- hydrateFallbackElement: c.createElement(e.HydrateFallback),
2635
- HydrateFallback: void 0
2636
- }), e.ErrorBoundary && Object.assign(t, {
2637
- errorElement: c.createElement(e.ErrorBoundary),
2638
- ErrorBoundary: void 0
2639
- }), t;
2640
- }
2641
- function Lo(e, t) {
2642
- return rr({
2643
- basename: t?.basename,
2644
- future: Me({}, t?.future, { v7_prependBasename: !0 }),
2645
- history: Jr({
2646
- initialEntries: t?.initialEntries,
2647
- initialIndex: t?.initialIndex
2648
- }),
2649
- hydrationData: t?.hydrationData,
2650
- routes: e,
2651
- mapRouteProperties: ir,
2652
- dataStrategy: t?.dataStrategy,
2653
- patchRoutesOnNavigation: t?.patchRoutesOnNavigation
2654
- }).initialize();
2655
- }
2656
- var hi = Xa({
2657
- AbortedDeferredError: () => Ft,
2658
- Await: () => Ro,
2659
- BrowserRouter: () => Go,
2660
- Form: () => La,
2661
- HashRouter: () => Xo,
2662
- Link: () => Ca,
2663
- MemoryRouter: () => yo,
2664
- NavLink: () => ei,
2665
- Navigate: () => wo,
2666
- NavigationType: () => K,
2667
- Outlet: () => bo,
2668
- Route: () => xa,
2669
- Router: () => at,
2670
- RouterProvider: () => $o,
2671
- Routes: () => Eo,
2672
- ScrollRestoration: () => ti,
2673
- UNSAFE_DataRouterContext: () => et,
2674
- UNSAFE_DataRouterStateContext: () => ht,
2675
- UNSAFE_ErrorResponseImpl: () => ct,
2676
- UNSAFE_FetchersContext: () => ur,
2677
- UNSAFE_LocationContext: () => tt,
2678
- UNSAFE_NavigationContext: () => se,
2679
- UNSAFE_RouteContext: () => ue,
2680
- UNSAFE_ViewTransitionContext: () => sr,
2681
- UNSAFE_useRouteId: () => ya,
2682
- UNSAFE_useScrollRestoration: () => _a,
2683
- createBrowserRouter: () => zo,
2684
- createHashRouter: () => Ho,
2685
- createMemoryRouter: () => Lo,
2686
- createPath: () => me,
2687
- createRoutesFromChildren: () => dt,
2688
- createRoutesFromElements: () => dt,
2689
- createSearchParams: () => Ot,
2690
- defer: () => Pn,
2691
- generatePath: () => vn,
2692
- isRouteErrorResponse: () => Ze,
2693
- json: () => En,
2694
- matchPath: () => Qe,
2695
- matchRoutes: () => De,
2696
- parsePath: () => de,
2697
- redirect: () => er,
2698
- redirectDocument: () => Cn,
2699
- renderMatches: () => Co,
2700
- replace: () => Ln,
2701
- resolvePath: () => ta,
2702
- unstable_HistoryRouter: () => Qo,
2703
- unstable_usePrompt: () => ui,
2704
- useActionData: () => ho,
2705
- useAsyncError: () => vo,
2706
- useAsyncValue: () => Ra,
2707
- useBeforeUnload: () => li,
2708
- useBlocker: () => Sa,
2709
- useFetcher: () => oi,
2710
- useFetchers: () => ii,
2711
- useFormAction: () => Ma,
2712
- useHref: () => da,
2713
- useInRouterContext: () => Ue,
2714
- useLinkClickHandler: () => Da,
2715
- useLoaderData: () => co,
2716
- useLocation: () => pe,
2717
- useMatch: () => eo,
2718
- useMatches: () => ba,
2719
- useNavigate: () => jt,
2720
- useNavigation: () => wa,
2721
- useNavigationType: () => qn,
2722
- useOutlet: () => va,
2723
- useOutletContext: () => ro,
2724
- useParams: () => ao,
2725
- useResolvedPath: () => rt,
2726
- useRevalidator: () => uo,
2727
- useRouteError: () => Ea,
2728
- useRouteLoaderData: () => fo,
2729
- useRoutes: () => ma,
2730
- useSearchParams: () => ri,
2731
- useSubmit: () => dr,
2732
- useViewTransitionState: () => Ua
2733
- });
2734
- function ae() {
2735
- return ae = Object.assign ? Object.assign.bind() : function(e) {
2736
- for (var t = 1; t < arguments.length; t++) {
2737
- var r = arguments[t];
2738
- for (var a in r) ({}).hasOwnProperty.call(r, a) && (e[a] = r[a]);
2739
- }
2740
- return e;
2741
- }, ae.apply(null, arguments);
2742
- }
2743
- function lr(e, t) {
2744
- if (e == null) return {};
2745
- var r = {};
2746
- for (var a in e) if ({}.hasOwnProperty.call(e, a)) {
2747
- if (t.indexOf(a) !== -1) continue;
2748
- r[a] = e[a];
2749
- }
2750
- return r;
2751
- }
2752
- var _t = "get", Yt = "application/x-www-form-urlencoded";
2753
- function Bt(e) {
2754
- return e != null && typeof e.tagName == "string";
2755
- }
2756
- function Do(e) {
2757
- return Bt(e) && e.tagName.toLowerCase() === "button";
2758
- }
2759
- function To(e) {
2760
- return Bt(e) && e.tagName.toLowerCase() === "form";
2761
- }
2762
- function Mo(e) {
2763
- return Bt(e) && e.tagName.toLowerCase() === "input";
2764
- }
2765
- function _o(e) {
2766
- return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
2767
- }
2768
- function Uo(e, t) {
2769
- return e.button === 0 && (!t || t === "_self") && !_o(e);
2770
- }
2771
- function Ot(e) {
2772
- return e === void 0 && (e = ""), new URLSearchParams(typeof e == "string" || Array.isArray(e) || e instanceof URLSearchParams ? e : Object.keys(e).reduce((t, r) => {
2773
- let a = e[r];
2774
- return t.concat(Array.isArray(a) ? a.map((n) => [r, n]) : [[r, a]]);
2775
- }, []));
2776
- }
2777
- function Fo(e, t) {
2778
- let r = Ot(e);
2779
- return t && t.forEach((a, n) => {
2780
- r.has(n) || t.getAll(n).forEach((i) => {
2781
- r.append(n, i);
2782
- });
2783
- }), r;
2784
- }
2785
- var Dt = null;
2786
- function Ao() {
2787
- if (Dt === null) try {
2788
- new FormData(document.createElement("form"), 0), Dt = !1;
2789
- } catch {
2790
- Dt = !0;
2791
- }
2792
- return Dt;
2793
- }
2794
- var Oo = new Set([
2795
- "application/x-www-form-urlencoded",
2796
- "multipart/form-data",
2797
- "text/plain"
2798
- ]);
2799
- function Gt(e) {
2800
- return e != null && !Oo.has(e) ? null : e;
2801
- }
2802
- function Io(e, t) {
2803
- let r, a, n, i, o;
2804
- if (To(e)) {
2805
- let s = e.getAttribute("action");
2806
- a = s ? ne(s, t) : null, r = e.getAttribute("method") || _t, n = Gt(e.getAttribute("enctype")) || Yt, i = new FormData(e);
2807
- } else if (Do(e) || Mo(e) && (e.type === "submit" || e.type === "image")) {
2808
- let s = e.form;
2809
- if (s == null) throw new Error("Cannot submit a <button> or <input type=\"submit\"> without a <form>");
2810
- let l = e.getAttribute("formaction") || s.getAttribute("action");
2811
- if (a = l ? ne(l, t) : null, r = e.getAttribute("formmethod") || s.getAttribute("method") || _t, n = Gt(e.getAttribute("formenctype")) || Gt(s.getAttribute("enctype")) || Yt, i = new FormData(s, e), !Ao()) {
2812
- let { name: d, type: h, value: v } = e;
2813
- if (h === "image") {
2814
- let p = d ? d + "." : "";
2815
- i.append(p + "x", "0"), i.append(p + "y", "0");
2816
- } else d && i.append(d, v);
2817
- }
2818
- } else {
2819
- if (Bt(e)) throw new Error("Cannot submit element that is not <form>, <button>, or <input type=\"submit|image\">");
2820
- r = _t, a = null, n = Yt, o = e;
2821
- }
2822
- return i && n === "text/plain" && (o = i, i = void 0), {
2823
- action: a,
2824
- method: r.toLowerCase(),
2825
- encType: n,
2826
- formData: i,
2827
- body: o
2828
- };
2829
- }
2830
- var No = [
2831
- "onClick",
2832
- "relative",
2833
- "reloadDocument",
2834
- "replace",
2835
- "state",
2836
- "target",
2837
- "to",
2838
- "preventScrollReset",
2839
- "viewTransition"
2840
- ], jo = [
2841
- "aria-current",
2842
- "caseSensitive",
2843
- "className",
2844
- "end",
2845
- "style",
2846
- "to",
2847
- "viewTransition",
2848
- "children"
2849
- ], ko = [
2850
- "fetcherKey",
2851
- "navigate",
2852
- "reloadDocument",
2853
- "replace",
2854
- "state",
2855
- "method",
2856
- "action",
2857
- "onSubmit",
2858
- "relative",
2859
- "preventScrollReset",
2860
- "viewTransition"
2861
- ], Bo = "6";
2862
- try {
2863
- window.__reactRouterVersion = Bo;
2864
- } catch {}
2865
- function zo(e, t) {
2866
- return rr({
2867
- basename: t?.basename,
2868
- future: ae({}, t?.future, { v7_prependBasename: !0 }),
2869
- history: Yr({ window: t?.window }),
2870
- hydrationData: t?.hydrationData || Pa(),
2871
- routes: e,
2872
- mapRouteProperties: ir,
2873
- dataStrategy: t?.dataStrategy,
2874
- patchRoutesOnNavigation: t?.patchRoutesOnNavigation,
2875
- window: t?.window
2876
- }).initialize();
2877
- }
2878
- function Ho(e, t) {
2879
- return rr({
2880
- basename: t?.basename,
2881
- future: ae({}, t?.future, { v7_prependBasename: !0 }),
2882
- history: Gr({ window: t?.window }),
2883
- hydrationData: t?.hydrationData || Pa(),
2884
- routes: e,
2885
- mapRouteProperties: ir,
2886
- dataStrategy: t?.dataStrategy,
2887
- patchRoutesOnNavigation: t?.patchRoutesOnNavigation,
2888
- window: t?.window
2889
- }).initialize();
2890
- }
2891
- function Pa() {
2892
- var e;
2893
- let t = (e = window) == null ? void 0 : e.__staticRouterHydrationData;
2894
- return t && t.errors && (t = ae({}, t, { errors: Ko(t.errors) })), t;
2895
- }
2896
- function Ko(e) {
2897
- if (!e) return null;
2898
- let t = Object.entries(e), r = {};
2899
- for (let [a, n] of t) if (n && n.__type === "RouteErrorResponse") r[a] = new ct(n.status, n.statusText, n.data, n.internal === !0);
2900
- else if (n && n.__type === "Error") {
2901
- if (n.__subType) {
2902
- let i = window[n.__subType];
2903
- if (typeof i == "function") try {
2904
- let o = new i(n.message);
2905
- o.stack = "", r[a] = o;
2906
- } catch {}
2907
- }
2908
- if (r[a] == null) {
2909
- let i = new Error(n.message);
2910
- i.stack = "", r[a] = i;
2911
- }
2912
- } else r[a] = n;
2913
- return r;
2914
- }
2915
- var sr = c.createContext({ isTransitioning: !1 }), ur = c.createContext(new Map()), _e = c.startTransition, Kr = qa.flushSync, Wr = c.useId;
2916
- function Wo(e) {
2917
- _e ? _e(e) : e();
2918
- }
2919
- function st(e) {
2920
- Kr ? Kr(e) : e();
2921
- }
2922
- var Vo = class {
2923
- constructor() {
2924
- this.status = "pending", this.promise = new Promise((e, t) => {
2925
- this.resolve = (r) => {
2926
- this.status === "pending" && (this.status = "resolved", e(r));
2927
- }, this.reject = (r) => {
2928
- this.status === "pending" && (this.status = "rejected", t(r));
2929
- };
2930
- });
2931
- }
2932
- };
2933
- function $o(e) {
2934
- let { fallbackElement: t, router: r, future: a } = e, [n, i] = c.useState(r.state), [o, s] = c.useState(), [l, d] = c.useState({ isTransitioning: !1 }), [h, v] = c.useState(), [p, y] = c.useState(), [b, x] = c.useState(), R = c.useRef(new Map()), { v7_startTransition: F } = a || {}, S = c.useCallback((U) => {
2935
- F ? Wo(U) : U();
2936
- }, [F]), I = c.useCallback((U, z) => {
2937
- let { deletedFetchers: O, flushSync: Q, viewTransitionOpts: G } = z;
2938
- U.fetchers.forEach((te, we) => {
2939
- te.data !== void 0 && R.current.set(we, te.data);
2940
- }), O.forEach((te) => R.current.delete(te));
2941
- let ie = r.window == null || r.window.document == null || typeof r.window.document.startViewTransition != "function";
2942
- if (!G || ie) {
2943
- Q ? st(() => i(U)) : S(() => i(U));
2944
- return;
2945
- }
2946
- if (Q) {
2947
- st(() => {
2948
- p && (h && h.resolve(), p.skipTransition()), d({
2949
- isTransitioning: !0,
2950
- flushSync: !0,
2951
- currentLocation: G.currentLocation,
2952
- nextLocation: G.nextLocation
2953
- });
2954
- });
2955
- let te = r.window.document.startViewTransition(() => {
2956
- st(() => i(U));
2957
- });
2958
- te.finished.finally(() => {
2959
- st(() => {
2960
- v(void 0), y(void 0), s(void 0), d({ isTransitioning: !1 });
2961
- });
2962
- }), st(() => y(te));
2963
- return;
2964
- }
2965
- p ? (h && h.resolve(), p.skipTransition(), x({
2966
- state: U,
2967
- currentLocation: G.currentLocation,
2968
- nextLocation: G.nextLocation
2969
- })) : (s(U), d({
2970
- isTransitioning: !0,
2971
- flushSync: !1,
2972
- currentLocation: G.currentLocation,
2973
- nextLocation: G.nextLocation
2974
- }));
2975
- }, [
2976
- r.window,
2977
- p,
2978
- h,
2979
- R,
2980
- S
2981
- ]);
2982
- c.useLayoutEffect(() => r.subscribe(I), [r, I]), c.useEffect(() => {
2983
- l.isTransitioning && !l.flushSync && v(new Vo());
2984
- }, [l]), c.useEffect(() => {
2985
- if (h && o && r.window) {
2986
- let U = o, z = h.promise, O = r.window.document.startViewTransition(async () => {
2987
- S(() => i(U)), await z;
2988
- });
2989
- O.finished.finally(() => {
2990
- v(void 0), y(void 0), s(void 0), d({ isTransitioning: !1 });
2991
- }), y(O);
2992
- }
2993
- }, [
2994
- S,
2995
- o,
2996
- h,
2997
- r.window
2998
- ]), c.useEffect(() => {
2999
- h && o && n.location.key === o.location.key && h.resolve();
3000
- }, [
3001
- h,
3002
- p,
3003
- n.location,
3004
- o
3005
- ]), c.useEffect(() => {
3006
- !l.isTransitioning && b && (s(b.state), d({
3007
- isTransitioning: !0,
3008
- flushSync: !1,
3009
- currentLocation: b.currentLocation,
3010
- nextLocation: b.nextLocation
3011
- }), x(void 0));
3012
- }, [l.isTransitioning, b]), c.useEffect(() => {}, []);
3013
- let j = c.useMemo(() => ({
3014
- createHref: r.createHref,
3015
- encodeLocation: r.encodeLocation,
3016
- go: (U) => r.navigate(U),
3017
- push: (U, z, O) => r.navigate(U, {
3018
- state: z,
3019
- preventScrollReset: O?.preventScrollReset
3020
- }),
3021
- replace: (U, z, O) => r.navigate(U, {
3022
- replace: !0,
3023
- state: z,
3024
- preventScrollReset: O?.preventScrollReset
3025
- })
3026
- }), [r]), $ = r.basename || "/", fe = c.useMemo(() => ({
3027
- router: r,
3028
- navigator: j,
3029
- static: !1,
3030
- basename: $
3031
- }), [
3032
- r,
3033
- j,
3034
- $
3035
- ]), g = c.useMemo(() => ({ v7_relativeSplatPath: r.future.v7_relativeSplatPath }), [r.future.v7_relativeSplatPath]);
3036
- return c.useEffect(() => mt(a, r.future), [a, r.future]), c.createElement(c.Fragment, null, c.createElement(et.Provider, { value: fe }, c.createElement(ht.Provider, { value: n }, c.createElement(ur.Provider, { value: R.current }, c.createElement(sr.Provider, { value: l }, c.createElement(at, {
3037
- basename: $,
3038
- location: n.location,
3039
- navigationType: n.historyAction,
3040
- navigator: j,
3041
- future: g
3042
- }, n.initialized || r.future.v7_partialHydration ? c.createElement(Jo, {
3043
- routes: r.routes,
3044
- future: r.future,
3045
- state: n
3046
- }) : t))))), null);
3047
- }
3048
- var Jo = c.memo(Yo);
3049
- function Yo(e) {
3050
- let { routes: t, future: r, state: a } = e;
3051
- return pa(t, void 0, a, r);
3052
- }
3053
- function Go(e) {
3054
- let { basename: t, children: r, future: a, window: n } = e, i = c.useRef();
3055
- i.current == null && (i.current = Yr({
3056
- window: n,
3057
- v5Compat: !0
3058
- }));
3059
- let o = i.current, [s, l] = c.useState({
3060
- action: o.action,
3061
- location: o.location
3062
- }), { v7_startTransition: d } = a || {}, h = c.useCallback((v) => {
3063
- d && _e ? _e(() => l(v)) : l(v);
3064
- }, [l, d]);
3065
- return c.useLayoutEffect(() => o.listen(h), [o, h]), c.useEffect(() => mt(a), [a]), c.createElement(at, {
3066
- basename: t,
3067
- children: r,
3068
- location: s.location,
3069
- navigationType: s.action,
3070
- navigator: o,
3071
- future: a
3072
- });
3073
- }
3074
- function Xo(e) {
3075
- let { basename: t, children: r, future: a, window: n } = e, i = c.useRef();
3076
- i.current == null && (i.current = Gr({
3077
- window: n,
3078
- v5Compat: !0
3079
- }));
3080
- let o = i.current, [s, l] = c.useState({
3081
- action: o.action,
3082
- location: o.location
3083
- }), { v7_startTransition: d } = a || {}, h = c.useCallback((v) => {
3084
- d && _e ? _e(() => l(v)) : l(v);
3085
- }, [l, d]);
3086
- return c.useLayoutEffect(() => o.listen(h), [o, h]), c.useEffect(() => mt(a), [a]), c.createElement(at, {
3087
- basename: t,
3088
- children: r,
3089
- location: s.location,
3090
- navigationType: s.action,
3091
- navigator: o,
3092
- future: a
3093
- });
3094
- }
3095
- function Qo(e) {
3096
- let { basename: t, children: r, future: a, history: n } = e, [i, o] = c.useState({
3097
- action: n.action,
3098
- location: n.location
3099
- }), { v7_startTransition: s } = a || {}, l = c.useCallback((d) => {
3100
- s && _e ? _e(() => o(d)) : o(d);
3101
- }, [o, s]);
3102
- return c.useLayoutEffect(() => n.listen(l), [n, l]), c.useEffect(() => mt(a), [a]), c.createElement(at, {
3103
- basename: t,
3104
- children: r,
3105
- location: i.location,
3106
- navigationType: i.action,
3107
- navigator: n,
3108
- future: a
3109
- });
3110
- }
3111
- var Zo = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", qo = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i, Ca = c.forwardRef(function(t, r) {
3112
- let { onClick: a, relative: n, reloadDocument: i, replace: o, state: s, target: l, to: d, preventScrollReset: h, viewTransition: v } = t, p = lr(t, No), { basename: y } = c.useContext(se), b, x = !1;
3113
- if (typeof d == "string" && qo.test(d) && (b = d, Zo)) try {
3114
- let I = new URL(window.location.href), j = d.startsWith("//") ? new URL(I.protocol + d) : new URL(d), $ = ne(j.pathname, y);
3115
- j.origin === I.origin && $ != null ? d = $ + j.search + j.hash : x = !0;
3116
- } catch {}
3117
- let R = da(d, { relative: n }), F = Da(d, {
3118
- replace: o,
3119
- state: s,
3120
- target: l,
3121
- preventScrollReset: h,
3122
- relative: n,
3123
- viewTransition: v
3124
- });
3125
- function S(I) {
3126
- a && a(I), I.defaultPrevented || F(I);
3127
- }
3128
- return c.createElement("a", ae({}, p, {
3129
- href: b || R,
3130
- onClick: x || i ? a : S,
3131
- ref: r,
3132
- target: l
3133
- }));
3134
- }), ei = c.forwardRef(function(t, r) {
3135
- let { "aria-current": a = "page", caseSensitive: n = !1, className: i = "", end: o = !1, style: s, to: l, viewTransition: d, children: h } = t, v = lr(t, jo), p = rt(l, { relative: v.relative }), y = pe(), b = c.useContext(ht), { navigator: x, basename: R } = c.useContext(se), F = b != null && Ua(p) && d === !0, S = x.encodeLocation ? x.encodeLocation(p).pathname : p.pathname, I = y.pathname, j = b && b.navigation && b.navigation.location ? b.navigation.location.pathname : null;
3136
- n || (I = I.toLowerCase(), j = j ? j.toLowerCase() : null, S = S.toLowerCase()), j && R && (j = ne(j, R) || j);
3137
- const $ = S !== "/" && S.endsWith("/") ? S.length - 1 : S.length;
3138
- let fe = I === S || !o && I.startsWith(S) && I.charAt($) === "/", g = j != null && (j === S || !o && j.startsWith(S) && j.charAt(S.length) === "/"), U = {
3139
- isActive: fe,
3140
- isPending: g,
3141
- isTransitioning: F
3142
- }, z = fe ? a : void 0, O;
3143
- typeof i == "function" ? O = i(U) : O = [
3144
- i,
3145
- fe ? "active" : null,
3146
- g ? "pending" : null,
3147
- F ? "transitioning" : null
3148
- ].filter(Boolean).join(" ");
3149
- let Q = typeof s == "function" ? s(U) : s;
3150
- return c.createElement(Ca, ae({}, v, {
3151
- "aria-current": z,
3152
- className: O,
3153
- ref: r,
3154
- style: Q,
3155
- to: l,
3156
- viewTransition: d
3157
- }), typeof h == "function" ? h(U) : h);
3158
- }), La = c.forwardRef((e, t) => {
3159
- let { fetcherKey: r, navigate: a, reloadDocument: n, replace: i, state: o, method: s = _t, action: l, onSubmit: d, relative: h, preventScrollReset: v, viewTransition: p } = e, y = lr(e, ko), b = dr(), x = Ma(l, { relative: h }), R = s.toLowerCase() === "get" ? "get" : "post", F = (S) => {
3160
- if (d && d(S), S.defaultPrevented) return;
3161
- S.preventDefault();
3162
- let I = S.nativeEvent.submitter, j = I?.getAttribute("formmethod") || s;
3163
- b(I || S.currentTarget, {
3164
- fetcherKey: r,
3165
- method: j,
3166
- navigate: a,
3167
- replace: i,
3168
- state: o,
3169
- relative: h,
3170
- preventScrollReset: v,
3171
- viewTransition: p
3172
- });
3173
- };
3174
- return c.createElement("form", ae({
3175
- ref: t,
3176
- method: R,
3177
- action: x,
3178
- onSubmit: n ? d : F
3179
- }, y));
3180
- });
3181
- function ti(e) {
3182
- let { getKey: t, storageKey: r } = e;
3183
- return _a({
3184
- getKey: t,
3185
- storageKey: r
3186
- }), null;
3187
- }
3188
- var qe;
3189
- (function(e) {
3190
- e.UseScrollRestoration = "useScrollRestoration", e.UseSubmit = "useSubmit", e.UseSubmitFetcher = "useSubmitFetcher", e.UseFetcher = "useFetcher", e.useViewTransitionState = "useViewTransitionState";
3191
- })(qe || (qe = {}));
3192
- var ft;
3193
- (function(e) {
3194
- e.UseFetcher = "useFetcher", e.UseFetchers = "useFetchers", e.UseScrollRestoration = "useScrollRestoration";
3195
- })(ft || (ft = {}));
3196
- function zt(e) {
3197
- let t = c.useContext(et);
3198
- return !t && _(!1), t;
3199
- }
3200
- function cr(e) {
3201
- let t = c.useContext(ht);
3202
- return !t && _(!1), t;
3203
- }
3204
- function Da(e, t) {
3205
- let { target: r, replace: a, state: n, preventScrollReset: i, relative: o, viewTransition: s } = t === void 0 ? {} : t, l = jt(), d = pe(), h = rt(e, { relative: o });
3206
- return c.useCallback((v) => {
3207
- if (Uo(v, r)) {
3208
- v.preventDefault();
3209
- let p = a !== void 0 ? a : me(d) === me(h);
3210
- l(e, {
3211
- replace: p,
3212
- state: n,
3213
- preventScrollReset: i,
3214
- relative: o,
3215
- viewTransition: s
3216
- });
3217
- }
3218
- }, [
3219
- d,
3220
- l,
3221
- h,
3222
- a,
3223
- n,
3224
- r,
3225
- e,
3226
- i,
3227
- o,
3228
- s
3229
- ]);
3230
- }
3231
- function ri(e) {
3232
- let t = c.useRef(Ot(e)), r = c.useRef(!1), a = pe(), n = c.useMemo(() => Fo(a.search, r.current ? null : t.current), [a.search]), i = jt();
3233
- return [n, c.useCallback((o, s) => {
3234
- const l = Ot(typeof o == "function" ? o(n) : o);
3235
- r.current = !0, i("?" + l, s);
3236
- }, [i, n])];
3237
- }
3238
- function ai() {
3239
- if (typeof document > "u") throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");
3240
- }
3241
- var ni = 0, Ta = () => "__" + String(++ni) + "__";
3242
- function dr() {
3243
- let { router: e } = zt(qe.UseSubmit), { basename: t } = c.useContext(se), r = ya();
3244
- return c.useCallback(function(a, n) {
3245
- n === void 0 && (n = {}), ai();
3246
- let { action: i, method: o, encType: s, formData: l, body: d } = Io(a, t);
3247
- if (n.navigate === !1) {
3248
- let h = n.fetcherKey || Ta();
3249
- e.fetch(h, r, n.action || i, {
3250
- preventScrollReset: n.preventScrollReset,
3251
- formData: l,
3252
- body: d,
3253
- formMethod: n.method || o,
3254
- formEncType: n.encType || s,
3255
- flushSync: n.flushSync
3256
- });
3257
- } else e.navigate(n.action || i, {
3258
- preventScrollReset: n.preventScrollReset,
3259
- formData: l,
3260
- body: d,
3261
- formMethod: n.method || o,
3262
- formEncType: n.encType || s,
3263
- replace: n.replace,
3264
- state: n.state,
3265
- fromRouteId: r,
3266
- flushSync: n.flushSync,
3267
- viewTransition: n.viewTransition
3268
- });
3269
- }, [
3270
- e,
3271
- t,
3272
- r
3273
- ]);
3274
- }
3275
- function Ma(e, t) {
3276
- let { relative: r } = t === void 0 ? {} : t, { basename: a } = c.useContext(se), n = c.useContext(ue);
3277
- !n && _(!1);
3278
- let [i] = n.matches.slice(-1), o = ae({}, rt(e || ".", { relative: r })), s = pe();
3279
- if (e == null) {
3280
- o.search = s.search;
3281
- let l = new URLSearchParams(o.search), d = l.getAll("index");
3282
- if (d.some((h) => h === "")) {
3283
- l.delete("index"), d.filter((v) => v).forEach((v) => l.append("index", v));
3284
- let h = l.toString();
3285
- o.search = h ? "?" + h : "";
3286
- }
3287
- }
3288
- return (!e || e === ".") && i.route.index && (o.search = o.search ? o.search.replace(/^\?/, "?index&") : "?index"), a !== "/" && (o.pathname = o.pathname === "/" ? a : ge([a, o.pathname])), me(o);
3289
- }
3290
- function oi(e) {
3291
- var t;
3292
- let { key: r } = e === void 0 ? {} : e, { router: a } = zt(qe.UseFetcher), n = cr(ft.UseFetcher), i = c.useContext(ur), o = c.useContext(ue), s = (t = o.matches[o.matches.length - 1]) == null ? void 0 : t.route.id;
3293
- !i && _(!1), !o && _(!1), s == null && _(!1);
3294
- let l = Wr ? Wr() : "", [d, h] = c.useState(r || l);
3295
- r && r !== d ? h(r) : d || h(Ta()), c.useEffect(() => (a.getFetcher(d), () => {
3296
- a.deleteFetcher(d);
3297
- }), [a, d]);
3298
- let v = c.useCallback((F, S) => {
3299
- !s && _(!1), a.fetch(d, s, F, S);
3300
- }, [
3301
- d,
3302
- s,
3303
- a
3304
- ]), p = dr(), y = c.useCallback((F, S) => {
3305
- p(F, ae({}, S, {
3306
- navigate: !1,
3307
- fetcherKey: d
3308
- }));
3309
- }, [d, p]), b = c.useMemo(() => c.forwardRef((F, S) => c.createElement(La, ae({}, F, {
3310
- navigate: !1,
3311
- fetcherKey: d,
3312
- ref: S
3313
- }))), [d]), x = n.fetchers.get(d) || na, R = i.get(d);
3314
- return c.useMemo(() => ae({
3315
- Form: b,
3316
- submit: y,
3317
- load: v
3318
- }, x, { data: R }), [
3319
- b,
3320
- y,
3321
- v,
3322
- x,
3323
- R
3324
- ]);
3325
- }
3326
- function ii() {
3327
- let e = cr(ft.UseFetchers);
3328
- return Array.from(e.fetchers.entries()).map((t) => {
3329
- let [r, a] = t;
3330
- return ae({}, a, { key: r });
3331
- });
3332
- }
3333
- var Vr = "react-router-scroll-positions", Tt = {};
3334
- function _a(e) {
3335
- let { getKey: t, storageKey: r } = e === void 0 ? {} : e, { router: a } = zt(qe.UseScrollRestoration), { restoreScrollPosition: n, preventScrollReset: i } = cr(ft.UseScrollRestoration), { basename: o } = c.useContext(se), s = pe(), l = ba(), d = wa();
3336
- c.useEffect(() => (window.history.scrollRestoration = "manual", () => {
3337
- window.history.scrollRestoration = "auto";
3338
- }), []), si(c.useCallback(() => {
3339
- if (d.state === "idle") {
3340
- let h = (t ? t(s, l) : null) || s.key;
3341
- Tt[h] = window.scrollY;
3342
- }
3343
- try {
3344
- sessionStorage.setItem(r || Vr, JSON.stringify(Tt));
3345
- } catch {}
3346
- window.history.scrollRestoration = "auto";
3347
- }, [
3348
- r,
3349
- t,
3350
- d.state,
3351
- s,
3352
- l
3353
- ])), typeof document < "u" && (c.useLayoutEffect(() => {
3354
- try {
3355
- let h = sessionStorage.getItem(r || Vr);
3356
- h && (Tt = JSON.parse(h));
3357
- } catch {}
3358
- }, [r]), c.useLayoutEffect(() => {
3359
- let h = t && o !== "/" ? (p, y) => t(ae({}, p, { pathname: ne(p.pathname, o) || p.pathname }), y) : t, v = a?.enableScrollRestoration(Tt, () => window.scrollY, h);
3360
- return () => v && v();
3361
- }, [
3362
- a,
3363
- o,
3364
- t
3365
- ]), c.useLayoutEffect(() => {
3366
- if (n !== !1) {
3367
- if (typeof n == "number") {
3368
- window.scrollTo(0, n);
3369
- return;
3370
- }
3371
- if (s.hash) {
3372
- let h = document.getElementById(decodeURIComponent(s.hash.slice(1)));
3373
- if (h) {
3374
- h.scrollIntoView();
3375
- return;
3376
- }
3377
- }
3378
- i !== !0 && window.scrollTo(0, 0);
3379
- }
3380
- }, [
3381
- s,
3382
- n,
3383
- i
3384
- ]));
3385
- }
3386
- function li(e, t) {
3387
- let { capture: r } = t || {};
3388
- c.useEffect(() => {
3389
- let a = r != null ? { capture: r } : void 0;
3390
- return window.addEventListener("beforeunload", e, a), () => {
3391
- window.removeEventListener("beforeunload", e, a);
3392
- };
3393
- }, [e, r]);
3394
- }
3395
- function si(e, t) {
3396
- let { capture: r } = t || {};
3397
- c.useEffect(() => {
3398
- let a = r != null ? { capture: r } : void 0;
3399
- return window.addEventListener("pagehide", e, a), () => {
3400
- window.removeEventListener("pagehide", e, a);
3401
- };
3402
- }, [e, r]);
3403
- }
3404
- function ui(e) {
3405
- let { when: t, message: r } = e, a = Sa(t);
3406
- c.useEffect(() => {
3407
- a.state === "blocked" && (window.confirm(r) ? setTimeout(a.proceed, 0) : a.reset());
3408
- }, [a, r]), c.useEffect(() => {
3409
- a.state === "blocked" && !t && a.reset();
3410
- }, [a, t]);
3411
- }
3412
- function Ua(e, t) {
3413
- t === void 0 && (t = {});
3414
- let r = c.useContext(sr);
3415
- r == null && _(!1);
3416
- let { basename: a } = zt(qe.useViewTransitionState), n = rt(e, { relative: t.relative });
3417
- if (!r.isTransitioning) return !1;
3418
- let i = ne(r.currentLocation.pathname, a) || r.currentLocation.pathname, o = ne(r.nextLocation.pathname, a) || r.nextLocation.pathname;
3419
- return Qe(n.pathname, o) != null || Qe(n.pathname, i) != null;
3420
- }
3421
- export { va as $, wo as A, ho as B, dr as C, ht as D, et as E, at as F, Ue as G, Ra as H, Eo as I, eo as J, co as K, Lo as L, bo as M, xa as N, tt as O, ue as P, qn as Q, dt as R, ri as S, ta as St, Ro as T, Sa as U, vo as V, da as W, jt as X, ba as Y, wa as Z, ii as _, De as _t, Qo as a, ya as at, ui as b, Cn as bt, $o as c, Ft as ct, zo as d, me as dt, ro as et, Ho as f, Pn as ft, oi as g, Qe as gt, li as h, En as ht, Xo as i, Ea as it, se as j, yo as k, ti as l, K as lt, hi as m, Ze as mt, ur as n, rt as nt, Ca as o, fo as ot, Ot as p, vn as pt, pe as q, La as r, uo as rt, ei as s, ma as st, Go as t, ao as tt, sr as u, ct as ut, Ma as v, de as vt, Ua as w, _a as x, Ln as xt, Da as y, er as yt, Co as z };