PluginProbe
Gutenberg / 22.5.3
Gutenberg v22.5.3
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / build / modules / route / index.js

index.js in Gutenberg 22.5.3, at build/modules/route/index.js

5,570 lines 177.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var __create = Object.create;
2 var __defProp = Object.defineProperty;
3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4 var __getOwnPropNames = Object.getOwnPropertyNames;
5 var __getProtoOf = Object.getPrototypeOf;
6 var __hasOwnProp = Object.prototype.hasOwnProperty;
7 var __commonJS = (cb, mod) => function __require() {
8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9 };
10 var __copyProps = (to, from, except, desc) => {
11 if (from && typeof from === "object" || typeof from === "function") {
12 for (let key of __getOwnPropNames(from))
13 if (!__hasOwnProp.call(to, key) && key !== except)
14 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15 }
16 return to;
17 };
18 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19 // If the importer is in node compatibility mode or this is not an ESM
20 // file that has been converted to a CommonJS file using a Babel-
21 // compatible transform (i.e. "__esModule" has not been set), then set
22 // "default" to the CommonJS "module.exports" for node compatibility.
23 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24 mod
25 ));
26
27 // vendor-external:react/jsx-runtime
28 var require_jsx_runtime = __commonJS({
29 "vendor-external:react/jsx-runtime"(exports, module) {
30 module.exports = window.ReactJSXRuntime;
31 }
32 });
33
34 // vendor-external:react
35 var require_react = __commonJS({
36 "vendor-external:react"(exports, module) {
37 module.exports = window.React;
38 }
39 });
40
41 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
42 var require_use_sync_external_store_shim_development = __commonJS({
43 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
44 "use strict";
45 (function() {
46 function is(x, y) {
47 return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
48 }
49 function useSyncExternalStore$2(subscribe2, getSnapshot) {
50 didWarnOld18Alpha || void 0 === React12.startTransition || (didWarnOld18Alpha = true, console.error(
51 "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
52 ));
53 var value = getSnapshot();
54 if (!didWarnUncachedGetSnapshot) {
55 var cachedValue = getSnapshot();
56 objectIs(value, cachedValue) || (console.error(
57 "The result of getSnapshot should be cached to avoid an infinite loop"
58 ), didWarnUncachedGetSnapshot = true);
59 }
60 cachedValue = useState4({
61 inst: { value, getSnapshot }
62 });
63 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
64 useLayoutEffect3(
65 function() {
66 inst.value = value;
67 inst.getSnapshot = getSnapshot;
68 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
69 },
70 [subscribe2, value, getSnapshot]
71 );
72 useEffect5(
73 function() {
74 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
75 return subscribe2(function() {
76 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
77 });
78 },
79 [subscribe2]
80 );
81 useDebugValue(value);
82 return value;
83 }
84 function checkIfSnapshotChanged(inst) {
85 var latestGetSnapshot = inst.getSnapshot;
86 inst = inst.value;
87 try {
88 var nextValue = latestGetSnapshot();
89 return !objectIs(inst, nextValue);
90 } catch (error) {
91 return true;
92 }
93 }
94 function useSyncExternalStore$1(subscribe2, getSnapshot) {
95 return getSnapshot();
96 }
97 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
98 var React12 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState4 = React12.useState, useEffect5 = React12.useEffect, useLayoutEffect3 = React12.useLayoutEffect, useDebugValue = React12.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
99 exports.useSyncExternalStore = void 0 !== React12.useSyncExternalStore ? React12.useSyncExternalStore : shim;
100 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
101 })();
102 }
103 });
104
105 // node_modules/use-sync-external-store/shim/index.js
106 var require_shim = __commonJS({
107 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
108 "use strict";
109 if (false) {
110 module.exports = null;
111 } else {
112 module.exports = require_use_sync_external_store_shim_development();
113 }
114 }
115 });
116
117 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
118 var require_with_selector_development = __commonJS({
119 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
120 "use strict";
121 (function() {
122 function is(x, y) {
123 return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
124 }
125 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
126 var React12 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = shim.useSyncExternalStore, useRef7 = React12.useRef, useEffect5 = React12.useEffect, useMemo3 = React12.useMemo, useDebugValue = React12.useDebugValue;
127 exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector, isEqual) {
128 var instRef = useRef7(null);
129 if (null === instRef.current) {
130 var inst = { hasValue: false, value: null };
131 instRef.current = inst;
132 } else inst = instRef.current;
133 instRef = useMemo3(
134 function() {
135 function memoizedSelector(nextSnapshot) {
136 if (!hasMemo) {
137 hasMemo = true;
138 memoizedSnapshot = nextSnapshot;
139 nextSnapshot = selector(nextSnapshot);
140 if (void 0 !== isEqual && inst.hasValue) {
141 var currentSelection = inst.value;
142 if (isEqual(currentSelection, nextSnapshot))
143 return memoizedSelection = currentSelection;
144 }
145 return memoizedSelection = nextSnapshot;
146 }
147 currentSelection = memoizedSelection;
148 if (objectIs(memoizedSnapshot, nextSnapshot))
149 return currentSelection;
150 var nextSelection = selector(nextSnapshot);
151 if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
152 return memoizedSnapshot = nextSnapshot, currentSelection;
153 memoizedSnapshot = nextSnapshot;
154 return memoizedSelection = nextSelection;
155 }
156 var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
157 return [
158 function() {
159 return memoizedSelector(getSnapshot());
160 },
161 null === maybeGetServerSnapshot ? void 0 : function() {
162 return memoizedSelector(maybeGetServerSnapshot());
163 }
164 ];
165 },
166 [getSnapshot, getServerSnapshot, selector, isEqual]
167 );
168 var value = useSyncExternalStore(subscribe2, instRef[0], instRef[1]);
169 useEffect5(
170 function() {
171 inst.hasValue = true;
172 inst.value = value;
173 },
174 [value]
175 );
176 useDebugValue(value);
177 return value;
178 };
179 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
180 })();
181 }
182 });
183
184 // node_modules/use-sync-external-store/shim/with-selector.js
185 var require_with_selector = __commonJS({
186 "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
187 "use strict";
188 if (false) {
189 module.exports = null;
190 } else {
191 module.exports = require_with_selector_development();
192 }
193 }
194 });
195
196 // vendor-external:react-dom
197 var require_react_dom = __commonJS({
198 "vendor-external:react-dom"(exports, module) {
199 module.exports = window.ReactDOM;
200 }
201 });
202
203 // package-external:@wordpress/private-apis
204 var require_private_apis = __commonJS({
205 "package-external:@wordpress/private-apis"(exports, module) {
206 module.exports = window.wp.privateApis;
207 }
208 });
209
210 // node_modules/@tanstack/store/dist/esm/scheduler.js
211 var __storeToDerived = /* @__PURE__ */ new WeakMap();
212 var __derivedToStore = /* @__PURE__ */ new WeakMap();
213 var __depsThatHaveWrittenThisTick = {
214 current: []
215 };
216 var __isFlushing = false;
217 var __batchDepth = 0;
218 var __pendingUpdates = /* @__PURE__ */ new Set();
219 var __initialBatchValues = /* @__PURE__ */ new Map();
220 function __flush_internals(relatedVals) {
221 for (const derived of relatedVals) {
222 if (__depsThatHaveWrittenThisTick.current.includes(derived)) {
223 continue;
224 }
225 __depsThatHaveWrittenThisTick.current.push(derived);
226 derived.recompute();
227 const stores = __derivedToStore.get(derived);
228 if (stores) {
229 for (const store of stores) {
230 const relatedLinkedDerivedVals = __storeToDerived.get(store);
231 if (!(relatedLinkedDerivedVals == null ? void 0 : relatedLinkedDerivedVals.length)) continue;
232 __flush_internals(relatedLinkedDerivedVals);
233 }
234 }
235 }
236 }
237 function __notifyListeners(store) {
238 const value = {
239 prevVal: store.prevState,
240 currentVal: store.state
241 };
242 for (const listener of store.listeners) {
243 listener(value);
244 }
245 }
246 function __notifyDerivedListeners(derived) {
247 const value = {
248 prevVal: derived.prevState,
249 currentVal: derived.state
250 };
251 for (const listener of derived.listeners) {
252 listener(value);
253 }
254 }
255 function __flush(store) {
256 if (__batchDepth > 0 && !__initialBatchValues.has(store)) {
257 __initialBatchValues.set(store, store.prevState);
258 }
259 __pendingUpdates.add(store);
260 if (__batchDepth > 0) return;
261 if (__isFlushing) return;
262 try {
263 __isFlushing = true;
264 while (__pendingUpdates.size > 0) {
265 const stores = Array.from(__pendingUpdates);
266 __pendingUpdates.clear();
267 for (const store2 of stores) {
268 const prevState = __initialBatchValues.get(store2) ?? store2.prevState;
269 store2.prevState = prevState;
270 __notifyListeners(store2);
271 }
272 for (const store2 of stores) {
273 const derivedVals = __storeToDerived.get(store2);
274 if (!derivedVals) continue;
275 __depsThatHaveWrittenThisTick.current.push(store2);
276 __flush_internals(derivedVals);
277 }
278 for (const store2 of stores) {
279 const derivedVals = __storeToDerived.get(store2);
280 if (!derivedVals) continue;
281 for (const derived of derivedVals) {
282 __notifyDerivedListeners(derived);
283 }
284 }
285 }
286 } finally {
287 __isFlushing = false;
288 __depsThatHaveWrittenThisTick.current = [];
289 __initialBatchValues.clear();
290 }
291 }
292 function batch(fn) {
293 __batchDepth++;
294 try {
295 fn();
296 } finally {
297 __batchDepth--;
298 if (__batchDepth === 0) {
299 const pendingUpdateToFlush = __pendingUpdates.values().next().value;
300 if (pendingUpdateToFlush) {
301 __flush(pendingUpdateToFlush);
302 }
303 }
304 }
305 }
306
307 // node_modules/@tanstack/store/dist/esm/types.js
308 function isUpdaterFunction(updater) {
309 return typeof updater === "function";
310 }
311
312 // node_modules/@tanstack/store/dist/esm/store.js
313 var Store = class {
314 constructor(initialState, options) {
315 this.listeners = /* @__PURE__ */ new Set();
316 this.subscribe = (listener) => {
317 var _a, _b;
318 this.listeners.add(listener);
319 const unsub = (_b = (_a = this.options) == null ? void 0 : _a.onSubscribe) == null ? void 0 : _b.call(_a, listener, this);
320 return () => {
321 this.listeners.delete(listener);
322 unsub == null ? void 0 : unsub();
323 };
324 };
325 this.prevState = initialState;
326 this.state = initialState;
327 this.options = options;
328 }
329 setState(updater) {
330 var _a, _b, _c;
331 this.prevState = this.state;
332 if ((_a = this.options) == null ? void 0 : _a.updateFn) {
333 this.state = this.options.updateFn(this.prevState)(updater);
334 } else {
335 if (isUpdaterFunction(updater)) {
336 this.state = updater(this.prevState);
337 } else {
338 this.state = updater;
339 }
340 }
341 (_c = (_b = this.options) == null ? void 0 : _b.onUpdate) == null ? void 0 : _c.call(_b);
342 __flush(this);
343 }
344 };
345
346 // node_modules/@tanstack/history/dist/esm/index.js
347 var stateIndexKey = "__TSR_index";
348 var popStateEvent = "popstate";
349 var beforeUnloadEvent = "beforeunload";
350 function createHistory(opts) {
351 let location = opts.getLocation();
352 const subscribers = /* @__PURE__ */ new Set();
353 const notify = (action) => {
354 location = opts.getLocation();
355 subscribers.forEach((subscriber) => subscriber({ location, action }));
356 };
357 const handleIndexChange = (action) => {
358 if (opts.notifyOnIndexChange ?? true) notify(action);
359 else location = opts.getLocation();
360 };
361 const tryNavigation = async ({
362 task,
363 navigateOpts,
364 ...actionInfo
365 }) => {
366 const ignoreBlocker = navigateOpts?.ignoreBlocker ?? false;
367 if (ignoreBlocker) {
368 task();
369 return;
370 }
371 const blockers = opts.getBlockers?.() ?? [];
372 const isPushOrReplace = actionInfo.type === "PUSH" || actionInfo.type === "REPLACE";
373 if (typeof document !== "undefined" && blockers.length && isPushOrReplace) {
374 for (const blocker of blockers) {
375 const nextLocation = parseHref(actionInfo.path, actionInfo.state);
376 const isBlocked = await blocker.blockerFn({
377 currentLocation: location,
378 nextLocation,
379 action: actionInfo.type
380 });
381 if (isBlocked) {
382 opts.onBlocked?.();
383 return;
384 }
385 }
386 }
387 task();
388 };
389 return {
390 get location() {
391 return location;
392 },
393 get length() {
394 return opts.getLength();
395 },
396 subscribers,
397 subscribe: (cb) => {
398 subscribers.add(cb);
399 return () => {
400 subscribers.delete(cb);
401 };
402 },
403 push: (path, state, navigateOpts) => {
404 const currentIndex = location.state[stateIndexKey];
405 state = assignKeyAndIndex(currentIndex + 1, state);
406 tryNavigation({
407 task: () => {
408 opts.pushState(path, state);
409 notify({ type: "PUSH" });
410 },
411 navigateOpts,
412 type: "PUSH",
413 path,
414 state
415 });
416 },
417 replace: (path, state, navigateOpts) => {
418 const currentIndex = location.state[stateIndexKey];
419 state = assignKeyAndIndex(currentIndex, state);
420 tryNavigation({
421 task: () => {
422 opts.replaceState(path, state);
423 notify({ type: "REPLACE" });
424 },
425 navigateOpts,
426 type: "REPLACE",
427 path,
428 state
429 });
430 },
431 go: (index, navigateOpts) => {
432 tryNavigation({
433 task: () => {
434 opts.go(index);
435 handleIndexChange({ type: "GO", index });
436 },
437 navigateOpts,
438 type: "GO"
439 });
440 },
441 back: (navigateOpts) => {
442 tryNavigation({
443 task: () => {
444 opts.back(navigateOpts?.ignoreBlocker ?? false);
445 handleIndexChange({ type: "BACK" });
446 },
447 navigateOpts,
448 type: "BACK"
449 });
450 },
451 forward: (navigateOpts) => {
452 tryNavigation({
453 task: () => {
454 opts.forward(navigateOpts?.ignoreBlocker ?? false);
455 handleIndexChange({ type: "FORWARD" });
456 },
457 navigateOpts,
458 type: "FORWARD"
459 });
460 },
461 canGoBack: () => location.state[stateIndexKey] !== 0,
462 createHref: (str) => opts.createHref(str),
463 block: (blocker) => {
464 if (!opts.setBlockers) return () => {
465 };
466 const blockers = opts.getBlockers?.() ?? [];
467 opts.setBlockers([...blockers, blocker]);
468 return () => {
469 const blockers2 = opts.getBlockers?.() ?? [];
470 opts.setBlockers?.(blockers2.filter((b) => b !== blocker));
471 };
472 },
473 flush: () => opts.flush?.(),
474 destroy: () => opts.destroy?.(),
475 notify
476 };
477 }
478 function assignKeyAndIndex(index, state) {
479 if (!state) {
480 state = {};
481 }
482 const key = createRandomKey();
483 return {
484 ...state,
485 key,
486 // TODO: Remove in v2 - use __TSR_key instead
487 __TSR_key: key,
488 [stateIndexKey]: index
489 };
490 }
491 function createBrowserHistory(opts) {
492 const win = opts?.window ?? (typeof document !== "undefined" ? window : void 0);
493 const originalPushState = win.history.pushState;
494 const originalReplaceState = win.history.replaceState;
495 let blockers = [];
496 const _getBlockers = () => blockers;
497 const _setBlockers = (newBlockers) => blockers = newBlockers;
498 const createHref = opts?.createHref ?? ((path) => path);
499 const parseLocation = opts?.parseLocation ?? (() => parseHref(
500 `${win.location.pathname}${win.location.search}${win.location.hash}`,
501 win.history.state
502 ));
503 if (!win.history.state?.__TSR_key && !win.history.state?.key) {
504 const addedKey = createRandomKey();
505 win.history.replaceState(
506 {
507 [stateIndexKey]: 0,
508 key: addedKey,
509 // TODO: Remove in v2 - use __TSR_key instead
510 __TSR_key: addedKey
511 },
512 ""
513 );
514 }
515 let currentLocation = parseLocation();
516 let rollbackLocation;
517 let nextPopIsGo = false;
518 let ignoreNextPop = false;
519 let skipBlockerNextPop = false;
520 let ignoreNextBeforeUnload = false;
521 const getLocation = () => currentLocation;
522 let next;
523 let scheduled;
524 const flush = () => {
525 if (!next) {
526 return;
527 }
528 history._ignoreSubscribers = true;
529 (next.isPush ? win.history.pushState : win.history.replaceState)(
530 next.state,
531 "",
532 next.href
533 );
534 history._ignoreSubscribers = false;
535 next = void 0;
536 scheduled = void 0;
537 rollbackLocation = void 0;
538 };
539 const queueHistoryAction = (type, destHref, state) => {
540 const href = createHref(destHref);
541 if (!scheduled) {
542 rollbackLocation = currentLocation;
543 }
544 currentLocation = parseHref(destHref, state);
545 next = {
546 href,
547 state,
548 isPush: next?.isPush || type === "push"
549 };
550 if (!scheduled) {
551 scheduled = Promise.resolve().then(() => flush());
552 }
553 };
554 const onPushPop = (type) => {
555 currentLocation = parseLocation();
556 history.notify({ type });
557 };
558 const onPushPopEvent = async () => {
559 if (ignoreNextPop) {
560 ignoreNextPop = false;
561 return;
562 }
563 const nextLocation = parseLocation();
564 const delta = nextLocation.state[stateIndexKey] - currentLocation.state[stateIndexKey];
565 const isForward = delta === 1;
566 const isBack = delta === -1;
567 const isGo = !isForward && !isBack || nextPopIsGo;
568 nextPopIsGo = false;
569 const action = isGo ? "GO" : isBack ? "BACK" : "FORWARD";
570 const notify = isGo ? {
571 type: "GO",
572 index: delta
573 } : {
574 type: isBack ? "BACK" : "FORWARD"
575 };
576 if (skipBlockerNextPop) {
577 skipBlockerNextPop = false;
578 } else {
579 const blockers2 = _getBlockers();
580 if (typeof document !== "undefined" && blockers2.length) {
581 for (const blocker of blockers2) {
582 const isBlocked = await blocker.blockerFn({
583 currentLocation,
584 nextLocation,
585 action
586 });
587 if (isBlocked) {
588 ignoreNextPop = true;
589 win.history.go(1);
590 history.notify(notify);
591 return;
592 }
593 }
594 }
595 }
596 currentLocation = parseLocation();
597 history.notify(notify);
598 };
599 const onBeforeUnload = (e) => {
600 if (ignoreNextBeforeUnload) {
601 ignoreNextBeforeUnload = false;
602 return;
603 }
604 let shouldBlock = false;
605 const blockers2 = _getBlockers();
606 if (typeof document !== "undefined" && blockers2.length) {
607 for (const blocker of blockers2) {
608 const shouldHaveBeforeUnload = blocker.enableBeforeUnload ?? true;
609 if (shouldHaveBeforeUnload === true) {
610 shouldBlock = true;
611 break;
612 }
613 if (typeof shouldHaveBeforeUnload === "function" && shouldHaveBeforeUnload() === true) {
614 shouldBlock = true;
615 break;
616 }
617 }
618 }
619 if (shouldBlock) {
620 e.preventDefault();
621 return e.returnValue = "";
622 }
623 return;
624 };
625 const history = createHistory({
626 getLocation,
627 getLength: () => win.history.length,
628 pushState: (href, state) => queueHistoryAction("push", href, state),
629 replaceState: (href, state) => queueHistoryAction("replace", href, state),
630 back: (ignoreBlocker) => {
631 if (ignoreBlocker) skipBlockerNextPop = true;
632 ignoreNextBeforeUnload = true;
633 return win.history.back();
634 },
635 forward: (ignoreBlocker) => {
636 if (ignoreBlocker) skipBlockerNextPop = true;
637 ignoreNextBeforeUnload = true;
638 win.history.forward();
639 },
640 go: (n) => {
641 nextPopIsGo = true;
642 win.history.go(n);
643 },
644 createHref: (href) => createHref(href),
645 flush,
646 destroy: () => {
647 win.history.pushState = originalPushState;
648 win.history.replaceState = originalReplaceState;
649 win.removeEventListener(beforeUnloadEvent, onBeforeUnload, {
650 capture: true
651 });
652 win.removeEventListener(popStateEvent, onPushPopEvent);
653 },
654 onBlocked: () => {
655 if (rollbackLocation && currentLocation !== rollbackLocation) {
656 currentLocation = rollbackLocation;
657 }
658 },
659 getBlockers: _getBlockers,
660 setBlockers: _setBlockers,
661 notifyOnIndexChange: false
662 });
663 win.addEventListener(beforeUnloadEvent, onBeforeUnload, { capture: true });
664 win.addEventListener(popStateEvent, onPushPopEvent);
665 win.history.pushState = function(...args) {
666 const res = originalPushState.apply(win.history, args);
667 if (!history._ignoreSubscribers) onPushPop("PUSH");
668 return res;
669 };
670 win.history.replaceState = function(...args) {
671 const res = originalReplaceState.apply(win.history, args);
672 if (!history._ignoreSubscribers) onPushPop("REPLACE");
673 return res;
674 };
675 return history;
676 }
677 function parseHref(href, state) {
678 const hashIndex = href.indexOf("#");
679 const searchIndex = href.indexOf("?");
680 const addedKey = createRandomKey();
681 return {
682 href,
683 pathname: href.substring(
684 0,
685 hashIndex > 0 ? searchIndex > 0 ? Math.min(hashIndex, searchIndex) : hashIndex : searchIndex > 0 ? searchIndex : href.length
686 ),
687 hash: hashIndex > -1 ? href.substring(hashIndex) : "",
688 search: searchIndex > -1 ? href.slice(searchIndex, hashIndex === -1 ? void 0 : hashIndex) : "",
689 state: state || { [stateIndexKey]: 0, key: addedKey, __TSR_key: addedKey }
690 };
691 }
692 function createRandomKey() {
693 return (Math.random() + 1).toString(36).substring(7);
694 }
695
696 // node_modules/@tanstack/router-core/dist/esm/utils.js
697 function last(arr) {
698 return arr[arr.length - 1];
699 }
700 function isFunction(d) {
701 return typeof d === "function";
702 }
703 function functionalUpdate(updater, previous) {
704 if (isFunction(updater)) {
705 return updater(previous);
706 }
707 return updater;
708 }
709 var hasOwn = Object.prototype.hasOwnProperty;
710 function replaceEqualDeep(prev, _next) {
711 if (prev === _next) {
712 return prev;
713 }
714 const next = _next;
715 const array = isPlainArray(prev) && isPlainArray(next);
716 if (!array && !(isPlainObject(prev) && isPlainObject(next))) return next;
717 const prevItems = array ? prev : getEnumerableOwnKeys(prev);
718 if (!prevItems) return next;
719 const nextItems = array ? next : getEnumerableOwnKeys(next);
720 if (!nextItems) return next;
721 const prevSize = prevItems.length;
722 const nextSize = nextItems.length;
723 const copy = array ? new Array(nextSize) : {};
724 let equalItems = 0;
725 for (let i = 0; i < nextSize; i++) {
726 const key = array ? i : nextItems[i];
727 const p = prev[key];
728 const n = next[key];
729 if (p === n) {
730 copy[key] = p;
731 if (array ? i < prevSize : hasOwn.call(prev, key)) equalItems++;
732 continue;
733 }
734 if (p === null || n === null || typeof p !== "object" || typeof n !== "object") {
735 copy[key] = n;
736 continue;
737 }
738 const v = replaceEqualDeep(p, n);
739 copy[key] = v;
740 if (v === p) equalItems++;
741 }
742 return prevSize === nextSize && equalItems === prevSize ? prev : copy;
743 }
744 function getEnumerableOwnKeys(o) {
745 const keys = [];
746 const names = Object.getOwnPropertyNames(o);
747 for (const name of names) {
748 if (!Object.prototype.propertyIsEnumerable.call(o, name)) return false;
749 keys.push(name);
750 }
751 const symbols = Object.getOwnPropertySymbols(o);
752 for (const symbol of symbols) {
753 if (!Object.prototype.propertyIsEnumerable.call(o, symbol)) return false;
754 keys.push(symbol);
755 }
756 return keys;
757 }
758 function isPlainObject(o) {
759 if (!hasObjectPrototype(o)) {
760 return false;
761 }
762 const ctor = o.constructor;
763 if (typeof ctor === "undefined") {
764 return true;
765 }
766 const prot = ctor.prototype;
767 if (!hasObjectPrototype(prot)) {
768 return false;
769 }
770 if (!prot.hasOwnProperty("isPrototypeOf")) {
771 return false;
772 }
773 return true;
774 }
775 function hasObjectPrototype(o) {
776 return Object.prototype.toString.call(o) === "[object Object]";
777 }
778 function isPlainArray(value) {
779 return Array.isArray(value) && value.length === Object.keys(value).length;
780 }
781 function deepEqual(a, b, opts) {
782 if (a === b) {
783 return true;
784 }
785 if (typeof a !== typeof b) {
786 return false;
787 }
788 if (Array.isArray(a) && Array.isArray(b)) {
789 if (a.length !== b.length) return false;
790 for (let i = 0, l = a.length; i < l; i++) {
791 if (!deepEqual(a[i], b[i], opts)) return false;
792 }
793 return true;
794 }
795 if (isPlainObject(a) && isPlainObject(b)) {
796 const ignoreUndefined = opts?.ignoreUndefined ?? true;
797 if (opts?.partial) {
798 for (const k in b) {
799 if (!ignoreUndefined || b[k] !== void 0) {
800 if (!deepEqual(a[k], b[k], opts)) return false;
801 }
802 }
803 return true;
804 }
805 let aCount = 0;
806 if (!ignoreUndefined) {
807 aCount = Object.keys(a).length;
808 } else {
809 for (const k in a) {
810 if (a[k] !== void 0) aCount++;
811 }
812 }
813 let bCount = 0;
814 for (const k in b) {
815 if (!ignoreUndefined || b[k] !== void 0) {
816 bCount++;
817 if (bCount > aCount || !deepEqual(a[k], b[k], opts)) return false;
818 }
819 }
820 return aCount === bCount;
821 }
822 return false;
823 }
824 function createControlledPromise(onResolve) {
825 let resolveLoadPromise;
826 let rejectLoadPromise;
827 const controlledPromise = new Promise((resolve, reject) => {
828 resolveLoadPromise = resolve;
829 rejectLoadPromise = reject;
830 });
831 controlledPromise.status = "pending";
832 controlledPromise.resolve = (value) => {
833 controlledPromise.status = "resolved";
834 controlledPromise.value = value;
835 resolveLoadPromise(value);
836 onResolve?.(value);
837 };
838 controlledPromise.reject = (e) => {
839 controlledPromise.status = "rejected";
840 rejectLoadPromise(e);
841 };
842 return controlledPromise;
843 }
844 function isPromise(value) {
845 return Boolean(
846 value && typeof value === "object" && typeof value.then === "function"
847 );
848 }
849 function findLast(array, predicate) {
850 for (let i = array.length - 1; i >= 0; i--) {
851 const item = array[i];
852 if (predicate(item)) return item;
853 }
854 return void 0;
855 }
856 var DECODE_IGNORE_LIST = Array.from(
857 (/* @__PURE__ */ new Map([
858 ["%", "%25"],
859 ["\\", "%5C"],
860 ["/", "%2F"],
861 [";", "%3B"],
862 [":", "%3A"],
863 ["@", "%40"],
864 ["&", "%26"],
865 ["=", "%3D"],
866 ["+", "%2B"],
867 ["$", "%24"],
868 [",", "%2C"]
869 ])).values()
870 );
871 function decodePathSegment(part, decodeIgnore = DECODE_IGNORE_LIST, startIndex = 0) {
872 function decode2(part2) {
873 try {
874 return decodeURIComponent(part2);
875 } catch {
876 return part2.replaceAll(/%[0-9A-Fa-f]{2}/g, (match) => {
877 try {
878 return decodeURIComponent(match);
879 } catch {
880 return match;
881 }
882 });
883 }
884 }
885 if (part === "" || !part.match(/%[0-9A-Fa-f]{2}/g)) return part;
886 for (let i = startIndex; i < decodeIgnore.length; i++) {
887 const char = decodeIgnore[i];
888 if (char && part.includes(char)) {
889 const partsToDecode = part.split(char);
890 const partsToJoin = [];
891 for (const partToDecode of partsToDecode) {
892 partsToJoin.push(decodePathSegment(partToDecode, decodeIgnore, i + 1));
893 }
894 return partsToJoin.join(char);
895 }
896 }
897 return decode2(part);
898 }
899
900 // node_modules/tiny-invariant/dist/esm/tiny-invariant.js
901 var isProduction = false;
902 var prefix = "Invariant failed";
903 function invariant(condition, message) {
904 if (condition) {
905 return;
906 }
907 if (isProduction) {
908 throw new Error(prefix);
909 }
910 var provided = typeof message === "function" ? message() : message;
911 var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
912 throw new Error(value);
913 }
914
915 // node_modules/@tanstack/router-core/dist/esm/path.js
916 var SEGMENT_TYPE_PATHNAME = 0;
917 var SEGMENT_TYPE_PARAM = 1;
918 var SEGMENT_TYPE_WILDCARD = 2;
919 var SEGMENT_TYPE_OPTIONAL_PARAM = 3;
920 function joinPaths(paths) {
921 return cleanPath(
922 paths.filter((val) => {
923 return val !== void 0;
924 }).join("/")
925 );
926 }
927 function cleanPath(path) {
928 return path.replace(/\/{2,}/g, "/");
929 }
930 function trimPathLeft(path) {
931 return path === "/" ? path : path.replace(/^\/{1,}/, "");
932 }
933 function trimPathRight(path) {
934 return path === "/" ? path : path.replace(/\/{1,}$/, "");
935 }
936 function trimPath(path) {
937 return trimPathRight(trimPathLeft(path));
938 }
939 function removeTrailingSlash(value, basepath) {
940 if (value?.endsWith("/") && value !== "/" && value !== `${basepath}/`) {
941 return value.slice(0, -1);
942 }
943 return value;
944 }
945 function exactPathTest(pathName1, pathName2, basepath) {
946 return removeTrailingSlash(pathName1, basepath) === removeTrailingSlash(pathName2, basepath);
947 }
948 function segmentToString(segment) {
949 const { type, value } = segment;
950 if (type === SEGMENT_TYPE_PATHNAME) {
951 return value;
952 }
953 const { prefixSegment, suffixSegment } = segment;
954 if (type === SEGMENT_TYPE_PARAM) {
955 const param = value.substring(1);
956 if (prefixSegment && suffixSegment) {
957 return `${prefixSegment}{$${param}}${suffixSegment}`;
958 } else if (prefixSegment) {
959 return `${prefixSegment}{$${param}}`;
960 } else if (suffixSegment) {
961 return `{$${param}}${suffixSegment}`;
962 }
963 }
964 if (type === SEGMENT_TYPE_OPTIONAL_PARAM) {
965 const param = value.substring(1);
966 if (prefixSegment && suffixSegment) {
967 return `${prefixSegment}{-$${param}}${suffixSegment}`;
968 } else if (prefixSegment) {
969 return `${prefixSegment}{-$${param}}`;
970 } else if (suffixSegment) {
971 return `{-$${param}}${suffixSegment}`;
972 }
973 return `{-$${param}}`;
974 }
975 if (type === SEGMENT_TYPE_WILDCARD) {
976 if (prefixSegment && suffixSegment) {
977 return `${prefixSegment}{$}${suffixSegment}`;
978 } else if (prefixSegment) {
979 return `${prefixSegment}{$}`;
980 } else if (suffixSegment) {
981 return `{$}${suffixSegment}`;
982 }
983 }
984 return value;
985 }
986 function resolvePath({
987 base,
988 to,
989 trailingSlash = "never",
990 parseCache
991 }) {
992 let baseSegments = parsePathname(base, parseCache).slice();
993 const toSegments = parsePathname(to, parseCache);
994 if (baseSegments.length > 1 && last(baseSegments)?.value === "/") {
995 baseSegments.pop();
996 }
997 for (let index = 0, length = toSegments.length; index < length; index++) {
998 const toSegment = toSegments[index];
999 const value = toSegment.value;
1000 if (value === "/") {
1001 if (!index) {
1002 baseSegments = [toSegment];
1003 } else if (index === length - 1) {
1004 baseSegments.push(toSegment);
1005 } else ;
1006 } else if (value === "..") {
1007 baseSegments.pop();
1008 } else if (value === ".") ;
1009 else {
1010 baseSegments.push(toSegment);
1011 }
1012 }
1013 if (baseSegments.length > 1) {
1014 if (last(baseSegments).value === "/") {
1015 if (trailingSlash === "never") {
1016 baseSegments.pop();
1017 }
1018 } else if (trailingSlash === "always") {
1019 baseSegments.push({ type: SEGMENT_TYPE_PATHNAME, value: "/" });
1020 }
1021 }
1022 const segmentValues = baseSegments.map(segmentToString);
1023 const joined = joinPaths(segmentValues);
1024 return joined;
1025 }
1026 var parsePathname = (pathname, cache) => {
1027 if (!pathname) return [];
1028 const cached = cache?.get(pathname);
1029 if (cached) return cached;
1030 const parsed = baseParsePathname(pathname);
1031 cache?.set(pathname, parsed);
1032 return parsed;
1033 };
1034 var PARAM_RE = /^\$.{1,}$/;
1035 var PARAM_W_CURLY_BRACES_RE = /^(.*?)\{(\$[a-zA-Z_$][a-zA-Z0-9_$]*)\}(.*)$/;
1036 var OPTIONAL_PARAM_W_CURLY_BRACES_RE = /^(.*?)\{-(\$[a-zA-Z_$][a-zA-Z0-9_$]*)\}(.*)$/;
1037 var WILDCARD_RE = /^\$$/;
1038 var WILDCARD_W_CURLY_BRACES_RE = /^(.*?)\{\$\}(.*)$/;
1039 function baseParsePathname(pathname) {
1040 pathname = cleanPath(pathname);
1041 const segments = [];
1042 if (pathname.slice(0, 1) === "/") {
1043 pathname = pathname.substring(1);
1044 segments.push({
1045 type: SEGMENT_TYPE_PATHNAME,
1046 value: "/"
1047 });
1048 }
1049 if (!pathname) {
1050 return segments;
1051 }
1052 const split = pathname.split("/").filter(Boolean);
1053 segments.push(
1054 ...split.map((part) => {
1055 const wildcardBracesMatch = part.match(WILDCARD_W_CURLY_BRACES_RE);
1056 if (wildcardBracesMatch) {
1057 const prefix2 = wildcardBracesMatch[1];
1058 const suffix = wildcardBracesMatch[2];
1059 return {
1060 type: SEGMENT_TYPE_WILDCARD,
1061 value: "$",
1062 prefixSegment: prefix2 || void 0,
1063 suffixSegment: suffix || void 0
1064 };
1065 }
1066 const optionalParamBracesMatch = part.match(
1067 OPTIONAL_PARAM_W_CURLY_BRACES_RE
1068 );
1069 if (optionalParamBracesMatch) {
1070 const prefix2 = optionalParamBracesMatch[1];
1071 const paramName = optionalParamBracesMatch[2];
1072 const suffix = optionalParamBracesMatch[3];
1073 return {
1074 type: SEGMENT_TYPE_OPTIONAL_PARAM,
1075 value: paramName,
1076 // Now just $paramName (no prefix)
1077 prefixSegment: prefix2 || void 0,
1078 suffixSegment: suffix || void 0
1079 };
1080 }
1081 const paramBracesMatch = part.match(PARAM_W_CURLY_BRACES_RE);
1082 if (paramBracesMatch) {
1083 const prefix2 = paramBracesMatch[1];
1084 const paramName = paramBracesMatch[2];
1085 const suffix = paramBracesMatch[3];
1086 return {
1087 type: SEGMENT_TYPE_PARAM,
1088 value: "" + paramName,
1089 prefixSegment: prefix2 || void 0,
1090 suffixSegment: suffix || void 0
1091 };
1092 }
1093 if (PARAM_RE.test(part)) {
1094 const paramName = part.substring(1);
1095 return {
1096 type: SEGMENT_TYPE_PARAM,
1097 value: "$" + paramName,
1098 prefixSegment: void 0,
1099 suffixSegment: void 0
1100 };
1101 }
1102 if (WILDCARD_RE.test(part)) {
1103 return {
1104 type: SEGMENT_TYPE_WILDCARD,
1105 value: "$",
1106 prefixSegment: void 0,
1107 suffixSegment: void 0
1108 };
1109 }
1110 return {
1111 type: SEGMENT_TYPE_PATHNAME,
1112 value: decodePathSegment(part)
1113 };
1114 })
1115 );
1116 if (pathname.slice(-1) === "/") {
1117 pathname = pathname.substring(1);
1118 segments.push({
1119 type: SEGMENT_TYPE_PATHNAME,
1120 value: "/"
1121 });
1122 }
1123 return segments;
1124 }
1125 function interpolatePath({
1126 path,
1127 params,
1128 leaveWildcards,
1129 leaveParams,
1130 decodeCharMap,
1131 parseCache
1132 }) {
1133 const interpolatedPathSegments = parsePathname(path, parseCache);
1134 function encodeParam(key) {
1135 const value = params[key];
1136 const isValueString = typeof value === "string";
1137 if (key === "*" || key === "_splat") {
1138 return isValueString ? encodeURI(value) : value;
1139 } else {
1140 return isValueString ? encodePathParam(value, decodeCharMap) : value;
1141 }
1142 }
1143 let isMissingParams = false;
1144 const usedParams = {};
1145 const interpolatedPath = joinPaths(
1146 interpolatedPathSegments.map((segment) => {
1147 if (segment.type === SEGMENT_TYPE_PATHNAME) {
1148 return segment.value;
1149 }
1150 if (segment.type === SEGMENT_TYPE_WILDCARD) {
1151 usedParams._splat = params._splat;
1152 usedParams["*"] = params._splat;
1153 const segmentPrefix = segment.prefixSegment || "";
1154 const segmentSuffix = segment.suffixSegment || "";
1155 if (!params._splat) {
1156 isMissingParams = true;
1157 if (leaveWildcards) {
1158 return `${segmentPrefix}${segment.value}${segmentSuffix}`;
1159 }
1160 if (segmentPrefix || segmentSuffix) {
1161 return `${segmentPrefix}${segmentSuffix}`;
1162 }
1163 return void 0;
1164 }
1165 const value = encodeParam("_splat");
1166 if (leaveWildcards) {
1167 return `${segmentPrefix}${segment.value}${value ?? ""}${segmentSuffix}`;
1168 }
1169 return `${segmentPrefix}${value}${segmentSuffix}`;
1170 }
1171 if (segment.type === SEGMENT_TYPE_PARAM) {
1172 const key = segment.value.substring(1);
1173 if (!isMissingParams && !(key in params)) {
1174 isMissingParams = true;
1175 }
1176 usedParams[key] = params[key];
1177 const segmentPrefix = segment.prefixSegment || "";
1178 const segmentSuffix = segment.suffixSegment || "";
1179 if (leaveParams) {
1180 const value = encodeParam(segment.value);
1181 return `${segmentPrefix}${segment.value}${value ?? ""}${segmentSuffix}`;
1182 }
1183 return `${segmentPrefix}${encodeParam(key) ?? "undefined"}${segmentSuffix}`;
1184 }
1185 if (segment.type === SEGMENT_TYPE_OPTIONAL_PARAM) {
1186 const key = segment.value.substring(1);
1187 const segmentPrefix = segment.prefixSegment || "";
1188 const segmentSuffix = segment.suffixSegment || "";
1189 if (!(key in params) || params[key] == null) {
1190 if (leaveWildcards) {
1191 return `${segmentPrefix}${key}${segmentSuffix}`;
1192 }
1193 if (segmentPrefix || segmentSuffix) {
1194 return `${segmentPrefix}${segmentSuffix}`;
1195 }
1196 return void 0;
1197 }
1198 usedParams[key] = params[key];
1199 if (leaveParams) {
1200 const value = encodeParam(segment.value);
1201 return `${segmentPrefix}${segment.value}${value ?? ""}${segmentSuffix}`;
1202 }
1203 if (leaveWildcards) {
1204 return `${segmentPrefix}${key}${encodeParam(key) ?? ""}${segmentSuffix}`;
1205 }
1206 return `${segmentPrefix}${encodeParam(key) ?? ""}${segmentSuffix}`;
1207 }
1208 return segment.value;
1209 })
1210 );
1211 return { usedParams, interpolatedPath, isMissingParams };
1212 }
1213 function encodePathParam(value, decodeCharMap) {
1214 let encoded = encodeURIComponent(value);
1215 if (decodeCharMap) {
1216 for (const [encodedChar, char] of decodeCharMap) {
1217 encoded = encoded.replaceAll(encodedChar, char);
1218 }
1219 }
1220 return encoded;
1221 }
1222 function matchPathname(currentPathname, matchLocation, parseCache) {
1223 const pathParams = matchByPath(currentPathname, matchLocation, parseCache);
1224 if (matchLocation.to && !pathParams) {
1225 return;
1226 }
1227 return pathParams ?? {};
1228 }
1229 function matchByPath(from, {
1230 to,
1231 fuzzy,
1232 caseSensitive
1233 }, parseCache) {
1234 const stringTo = to;
1235 const baseSegments = parsePathname(
1236 from.startsWith("/") ? from : `/${from}`,
1237 parseCache
1238 );
1239 const routeSegments = parsePathname(
1240 stringTo.startsWith("/") ? stringTo : `/${stringTo}`,
1241 parseCache
1242 );
1243 const params = {};
1244 const result = isMatch(
1245 baseSegments,
1246 routeSegments,
1247 params,
1248 fuzzy,
1249 caseSensitive
1250 );
1251 return result ? params : void 0;
1252 }
1253 function isMatch(baseSegments, routeSegments, params, fuzzy, caseSensitive) {
1254 let baseIndex = 0;
1255 let routeIndex = 0;
1256 while (baseIndex < baseSegments.length || routeIndex < routeSegments.length) {
1257 const baseSegment = baseSegments[baseIndex];
1258 const routeSegment = routeSegments[routeIndex];
1259 if (routeSegment) {
1260 if (routeSegment.type === SEGMENT_TYPE_WILDCARD) {
1261 const remainingBaseSegments = baseSegments.slice(baseIndex);
1262 let _splat;
1263 if (routeSegment.prefixSegment || routeSegment.suffixSegment) {
1264 if (!baseSegment) return false;
1265 const prefix2 = routeSegment.prefixSegment || "";
1266 const suffix = routeSegment.suffixSegment || "";
1267 const baseValue = baseSegment.value;
1268 if ("prefixSegment" in routeSegment) {
1269 if (!baseValue.startsWith(prefix2)) {
1270 return false;
1271 }
1272 }
1273 if ("suffixSegment" in routeSegment) {
1274 if (!baseSegments[baseSegments.length - 1]?.value.endsWith(suffix)) {
1275 return false;
1276 }
1277 }
1278 let rejoinedSplat = decodeURI(
1279 joinPaths(remainingBaseSegments.map((d) => d.value))
1280 );
1281 if (prefix2 && rejoinedSplat.startsWith(prefix2)) {
1282 rejoinedSplat = rejoinedSplat.slice(prefix2.length);
1283 }
1284 if (suffix && rejoinedSplat.endsWith(suffix)) {
1285 rejoinedSplat = rejoinedSplat.slice(
1286 0,
1287 rejoinedSplat.length - suffix.length
1288 );
1289 }
1290 _splat = rejoinedSplat;
1291 } else {
1292 _splat = decodeURI(
1293 joinPaths(remainingBaseSegments.map((d) => d.value))
1294 );
1295 }
1296 params["*"] = _splat;
1297 params["_splat"] = _splat;
1298 return true;
1299 }
1300 if (routeSegment.type === SEGMENT_TYPE_PATHNAME) {
1301 if (routeSegment.value === "/" && !baseSegment?.value) {
1302 routeIndex++;
1303 continue;
1304 }
1305 if (baseSegment) {
1306 if (caseSensitive) {
1307 if (routeSegment.value !== baseSegment.value) {
1308 return false;
1309 }
1310 } else if (routeSegment.value.toLowerCase() !== baseSegment.value.toLowerCase()) {
1311 return false;
1312 }
1313 baseIndex++;
1314 routeIndex++;
1315 continue;
1316 } else {
1317 return false;
1318 }
1319 }
1320 if (routeSegment.type === SEGMENT_TYPE_PARAM) {
1321 if (!baseSegment) {
1322 return false;
1323 }
1324 if (baseSegment.value === "/") {
1325 return false;
1326 }
1327 let _paramValue = "";
1328 let matched = false;
1329 if (routeSegment.prefixSegment || routeSegment.suffixSegment) {
1330 const prefix2 = routeSegment.prefixSegment || "";
1331 const suffix = routeSegment.suffixSegment || "";
1332 const baseValue = baseSegment.value;
1333 if (prefix2 && !baseValue.startsWith(prefix2)) {
1334 return false;
1335 }
1336 if (suffix && !baseValue.endsWith(suffix)) {
1337 return false;
1338 }
1339 let paramValue = baseValue;
1340 if (prefix2 && paramValue.startsWith(prefix2)) {
1341 paramValue = paramValue.slice(prefix2.length);
1342 }
1343 if (suffix && paramValue.endsWith(suffix)) {
1344 paramValue = paramValue.slice(0, paramValue.length - suffix.length);
1345 }
1346 _paramValue = decodeURIComponent(paramValue);
1347 matched = true;
1348 } else {
1349 _paramValue = decodeURIComponent(baseSegment.value);
1350 matched = true;
1351 }
1352 if (matched) {
1353 params[routeSegment.value.substring(1)] = _paramValue;
1354 baseIndex++;
1355 }
1356 routeIndex++;
1357 continue;
1358 }
1359 if (routeSegment.type === SEGMENT_TYPE_OPTIONAL_PARAM) {
1360 if (!baseSegment) {
1361 routeIndex++;
1362 continue;
1363 }
1364 if (baseSegment.value === "/") {
1365 routeIndex++;
1366 continue;
1367 }
1368 let _paramValue = "";
1369 let matched = false;
1370 if (routeSegment.prefixSegment || routeSegment.suffixSegment) {
1371 const prefix2 = routeSegment.prefixSegment || "";
1372 const suffix = routeSegment.suffixSegment || "";
1373 const baseValue = baseSegment.value;
1374 if ((!prefix2 || baseValue.startsWith(prefix2)) && (!suffix || baseValue.endsWith(suffix))) {
1375 let paramValue = baseValue;
1376 if (prefix2 && paramValue.startsWith(prefix2)) {
1377 paramValue = paramValue.slice(prefix2.length);
1378 }
1379 if (suffix && paramValue.endsWith(suffix)) {
1380 paramValue = paramValue.slice(
1381 0,
1382 paramValue.length - suffix.length
1383 );
1384 }
1385 _paramValue = decodeURIComponent(paramValue);
1386 matched = true;
1387 }
1388 } else {
1389 let shouldMatchOptional = true;
1390 for (let lookAhead = routeIndex + 1; lookAhead < routeSegments.length; lookAhead++) {
1391 const futureRouteSegment = routeSegments[lookAhead];
1392 if (futureRouteSegment?.type === SEGMENT_TYPE_PATHNAME && futureRouteSegment.value === baseSegment.value) {
1393 shouldMatchOptional = false;
1394 break;
1395 }
1396 if (futureRouteSegment?.type === SEGMENT_TYPE_PARAM || futureRouteSegment?.type === SEGMENT_TYPE_WILDCARD) {
1397 if (baseSegments.length < routeSegments.length) {
1398 shouldMatchOptional = false;
1399 }
1400 break;
1401 }
1402 }
1403 if (shouldMatchOptional) {
1404 _paramValue = decodeURIComponent(baseSegment.value);
1405 matched = true;
1406 }
1407 }
1408 if (matched) {
1409 params[routeSegment.value.substring(1)] = _paramValue;
1410 baseIndex++;
1411 }
1412 routeIndex++;
1413 continue;
1414 }
1415 }
1416 if (baseIndex < baseSegments.length && routeIndex >= routeSegments.length) {
1417 params["**"] = joinPaths(
1418 baseSegments.slice(baseIndex).map((d) => d.value)
1419 );
1420 return !!fuzzy && routeSegments[routeSegments.length - 1]?.value !== "/";
1421 }
1422 if (routeIndex < routeSegments.length && baseIndex >= baseSegments.length) {
1423 for (let i = routeIndex; i < routeSegments.length; i++) {
1424 if (routeSegments[i]?.type !== SEGMENT_TYPE_OPTIONAL_PARAM) {
1425 return false;
1426 }
1427 }
1428 break;
1429 }
1430 break;
1431 }
1432 return true;
1433 }
1434
1435 // node_modules/@tanstack/router-core/dist/esm/process-route-tree.js
1436 var SLASH_SCORE = 0.75;
1437 var STATIC_SEGMENT_SCORE = 1;
1438 var REQUIRED_PARAM_BASE_SCORE = 0.5;
1439 var OPTIONAL_PARAM_BASE_SCORE = 0.4;
1440 var WILDCARD_PARAM_BASE_SCORE = 0.25;
1441 var STATIC_AFTER_DYNAMIC_BONUS_SCORE = 0.2;
1442 var BOTH_PRESENCE_BASE_SCORE = 0.05;
1443 var PREFIX_PRESENCE_BASE_SCORE = 0.02;
1444 var SUFFIX_PRESENCE_BASE_SCORE = 0.01;
1445 var PREFIX_LENGTH_SCORE_MULTIPLIER = 2e-4;
1446 var SUFFIX_LENGTH_SCORE_MULTIPLIER = 1e-4;
1447 function handleParam(segment, baseScore) {
1448 if (segment.prefixSegment && segment.suffixSegment) {
1449 return baseScore + BOTH_PRESENCE_BASE_SCORE + PREFIX_LENGTH_SCORE_MULTIPLIER * segment.prefixSegment.length + SUFFIX_LENGTH_SCORE_MULTIPLIER * segment.suffixSegment.length;
1450 }
1451 if (segment.prefixSegment) {
1452 return baseScore + PREFIX_PRESENCE_BASE_SCORE + PREFIX_LENGTH_SCORE_MULTIPLIER * segment.prefixSegment.length;
1453 }
1454 if (segment.suffixSegment) {
1455 return baseScore + SUFFIX_PRESENCE_BASE_SCORE + SUFFIX_LENGTH_SCORE_MULTIPLIER * segment.suffixSegment.length;
1456 }
1457 return baseScore;
1458 }
1459 function sortRoutes(routes) {
1460 const scoredRoutes = [];
1461 routes.forEach((d, i) => {
1462 if (d.isRoot || !d.path) {
1463 return;
1464 }
1465 const trimmed = trimPathLeft(d.fullPath);
1466 let parsed = parsePathname(trimmed);
1467 let skip = 0;
1468 while (parsed.length > skip + 1 && parsed[skip]?.value === "/") {
1469 skip++;
1470 }
1471 if (skip > 0) parsed = parsed.slice(skip);
1472 let optionalParamCount = 0;
1473 let hasStaticAfter = false;
1474 const scores = parsed.map((segment, index) => {
1475 if (segment.value === "/") {
1476 return SLASH_SCORE;
1477 }
1478 if (segment.type === SEGMENT_TYPE_PATHNAME) {
1479 return STATIC_SEGMENT_SCORE;
1480 }
1481 let baseScore = void 0;
1482 if (segment.type === SEGMENT_TYPE_PARAM) {
1483 baseScore = REQUIRED_PARAM_BASE_SCORE;
1484 } else if (segment.type === SEGMENT_TYPE_OPTIONAL_PARAM) {
1485 baseScore = OPTIONAL_PARAM_BASE_SCORE;
1486 optionalParamCount++;
1487 } else {
1488 baseScore = WILDCARD_PARAM_BASE_SCORE;
1489 }
1490 for (let i2 = index + 1; i2 < parsed.length; i2++) {
1491 const nextSegment = parsed[i2];
1492 if (nextSegment.type === SEGMENT_TYPE_PATHNAME && nextSegment.value !== "/") {
1493 hasStaticAfter = true;
1494 return handleParam(
1495 segment,
1496 baseScore + STATIC_AFTER_DYNAMIC_BONUS_SCORE
1497 );
1498 }
1499 }
1500 return handleParam(segment, baseScore);
1501 });
1502 scoredRoutes.push({
1503 child: d,
1504 trimmed,
1505 parsed,
1506 index: i,
1507 scores,
1508 optionalParamCount,
1509 hasStaticAfter
1510 });
1511 });
1512 const flatRoutes = scoredRoutes.sort((a, b) => {
1513 const minLength = Math.min(a.scores.length, b.scores.length);
1514 for (let i = 0; i < minLength; i++) {
1515 if (a.scores[i] !== b.scores[i]) {
1516 return b.scores[i] - a.scores[i];
1517 }
1518 }
1519 if (a.scores.length !== b.scores.length) {
1520 if (a.optionalParamCount !== b.optionalParamCount) {
1521 if (a.hasStaticAfter === b.hasStaticAfter) {
1522 return a.optionalParamCount - b.optionalParamCount;
1523 } else if (a.hasStaticAfter && !b.hasStaticAfter) {
1524 return -1;
1525 } else if (!a.hasStaticAfter && b.hasStaticAfter) {
1526 return 1;
1527 }
1528 }
1529 return b.scores.length - a.scores.length;
1530 }
1531 for (let i = 0; i < minLength; i++) {
1532 if (a.parsed[i].value !== b.parsed[i].value) {
1533 return a.parsed[i].value > b.parsed[i].value ? 1 : -1;
1534 }
1535 }
1536 return a.index - b.index;
1537 }).map((d, i) => {
1538 d.child.rank = i;
1539 return d.child;
1540 });
1541 return flatRoutes;
1542 }
1543 function processRouteTree({
1544 routeTree,
1545 initRoute
1546 }) {
1547 const routesById = {};
1548 const routesByPath = {};
1549 const recurseRoutes = (childRoutes) => {
1550 childRoutes.forEach((childRoute, i) => {
1551 initRoute?.(childRoute, i);
1552 const existingRoute = routesById[childRoute.id];
1553 invariant(
1554 !existingRoute,
1555 `Duplicate routes found with id: ${String(childRoute.id)}`
1556 );
1557 routesById[childRoute.id] = childRoute;
1558 if (!childRoute.isRoot && childRoute.path) {
1559 const trimmedFullPath = trimPathRight(childRoute.fullPath);
1560 if (!routesByPath[trimmedFullPath] || childRoute.fullPath.endsWith("/")) {
1561 routesByPath[trimmedFullPath] = childRoute;
1562 }
1563 }
1564 const children = childRoute.children;
1565 if (children?.length) {
1566 recurseRoutes(children);
1567 }
1568 });
1569 };
1570 recurseRoutes([routeTree]);
1571 const flatRoutes = sortRoutes(Object.values(routesById));
1572 return { routesById, routesByPath, flatRoutes };
1573 }
1574
1575 // node_modules/@tanstack/router-core/dist/esm/not-found.js
1576 function notFound(options = {}) {
1577 options.isNotFound = true;
1578 if (options.throw) throw options;
1579 return options;
1580 }
1581 function isNotFound(obj) {
1582 return !!obj?.isNotFound;
1583 }
1584
1585 // node_modules/@tanstack/router-core/dist/esm/scroll-restoration.js
1586 function getSafeSessionStorage() {
1587 try {
1588 if (typeof window !== "undefined" && typeof window.sessionStorage === "object") {
1589 return window.sessionStorage;
1590 }
1591 } catch {
1592 }
1593 return void 0;
1594 }
1595 var storageKey = "tsr-scroll-restoration-v1_3";
1596 var throttle = (fn, wait) => {
1597 let timeout;
1598 return (...args) => {
1599 if (!timeout) {
1600 timeout = setTimeout(() => {
1601 fn(...args);
1602 timeout = null;
1603 }, wait);
1604 }
1605 };
1606 };
1607 function createScrollRestorationCache() {
1608 const safeSessionStorage = getSafeSessionStorage();
1609 if (!safeSessionStorage) {
1610 return null;
1611 }
1612 const persistedState = safeSessionStorage.getItem(storageKey);
1613 let state = persistedState ? JSON.parse(persistedState) : {};
1614 return {
1615 state,
1616 // This setter is simply to make sure that we set the sessionStorage right
1617 // after the state is updated. It doesn't necessarily need to be a functional
1618 // update.
1619 set: (updater) => (state = functionalUpdate(updater, state) || state, safeSessionStorage.setItem(storageKey, JSON.stringify(state)))
1620 };
1621 }
1622 var scrollRestorationCache = createScrollRestorationCache();
1623 var defaultGetScrollRestorationKey = (location) => {
1624 return location.state.__TSR_key || location.href;
1625 };
1626 function getCssSelector(el) {
1627 const path = [];
1628 let parent;
1629 while (parent = el.parentNode) {
1630 path.push(
1631 `${el.tagName}:nth-child(${Array.prototype.indexOf.call(parent.children, el) + 1})`
1632 );
1633 el = parent;
1634 }
1635 return `${path.reverse().join(" > ")}`.toLowerCase();
1636 }
1637 var ignoreScroll = false;
1638 function restoreScroll({
1639 storageKey: storageKey2,
1640 key,
1641 behavior,
1642 shouldScrollRestoration,
1643 scrollToTopSelectors,
1644 location
1645 }) {
1646 let byKey;
1647 try {
1648 byKey = JSON.parse(sessionStorage.getItem(storageKey2) || "{}");
1649 } catch (error) {
1650 console.error(error);
1651 return;
1652 }
1653 const resolvedKey = key || window.history.state?.__TSR_key;
1654 const elementEntries = byKey[resolvedKey];
1655 ignoreScroll = true;
1656 scroll: {
1657 if (shouldScrollRestoration && elementEntries && Object.keys(elementEntries).length > 0) {
1658 for (const elementSelector in elementEntries) {
1659 const entry = elementEntries[elementSelector];
1660 if (elementSelector === "window") {
1661 window.scrollTo({
1662 top: entry.scrollY,
1663 left: entry.scrollX,
1664 behavior
1665 });
1666 } else if (elementSelector) {
1667 const element = document.querySelector(elementSelector);
1668 if (element) {
1669 element.scrollLeft = entry.scrollX;
1670 element.scrollTop = entry.scrollY;
1671 }
1672 }
1673 }
1674 break scroll;
1675 }
1676 const hash = (location ?? window.location).hash.split("#", 2)[1];
1677 if (hash) {
1678 const hashScrollIntoViewOptions = window.history.state?.__hashScrollIntoViewOptions ?? true;
1679 if (hashScrollIntoViewOptions) {
1680 const el = document.getElementById(hash);
1681 if (el) {
1682 el.scrollIntoView(hashScrollIntoViewOptions);
1683 }
1684 }
1685 break scroll;
1686 }
1687 const scrollOptions = { top: 0, left: 0, behavior };
1688 window.scrollTo(scrollOptions);
1689 if (scrollToTopSelectors) {
1690 for (const selector of scrollToTopSelectors) {
1691 if (selector === "window") continue;
1692 const element = typeof selector === "function" ? selector() : document.querySelector(selector);
1693 if (element) element.scrollTo(scrollOptions);
1694 }
1695 }
1696 }
1697 ignoreScroll = false;
1698 }
1699 function setupScrollRestoration(router, force) {
1700 if (!scrollRestorationCache && !router.isServer) {
1701 return;
1702 }
1703 const shouldScrollRestoration = force ?? router.options.scrollRestoration ?? false;
1704 if (shouldScrollRestoration) {
1705 router.isScrollRestoring = true;
1706 }
1707 if (router.isServer || router.isScrollRestorationSetup || !scrollRestorationCache) {
1708 return;
1709 }
1710 router.isScrollRestorationSetup = true;
1711 ignoreScroll = false;
1712 const getKey = router.options.getScrollRestorationKey || defaultGetScrollRestorationKey;
1713 window.history.scrollRestoration = "manual";
1714 const onScroll = (event) => {
1715 if (ignoreScroll || !router.isScrollRestoring) {
1716 return;
1717 }
1718 let elementSelector = "";
1719 if (event.target === document || event.target === window) {
1720 elementSelector = "window";
1721 } else {
1722 const attrId = event.target.getAttribute(
1723 "data-scroll-restoration-id"
1724 );
1725 if (attrId) {
1726 elementSelector = `[data-scroll-restoration-id="${attrId}"]`;
1727 } else {
1728 elementSelector = getCssSelector(event.target);
1729 }
1730 }
1731 const restoreKey = getKey(router.state.location);
1732 scrollRestorationCache.set((state) => {
1733 const keyEntry = state[restoreKey] ||= {};
1734 const elementEntry = keyEntry[elementSelector] ||= {};
1735 if (elementSelector === "window") {
1736 elementEntry.scrollX = window.scrollX || 0;
1737 elementEntry.scrollY = window.scrollY || 0;
1738 } else if (elementSelector) {
1739 const element = document.querySelector(elementSelector);
1740 if (element) {
1741 elementEntry.scrollX = element.scrollLeft || 0;
1742 elementEntry.scrollY = element.scrollTop || 0;
1743 }
1744 }
1745 return state;
1746 });
1747 };
1748 if (typeof document !== "undefined") {
1749 document.addEventListener("scroll", throttle(onScroll, 100), true);
1750 }
1751 router.subscribe("onRendered", (event) => {
1752 const cacheKey = getKey(event.toLocation);
1753 if (!router.resetNextScroll) {
1754 router.resetNextScroll = true;
1755 return;
1756 }
1757 if (typeof router.options.scrollRestoration === "function") {
1758 const shouldRestore = router.options.scrollRestoration({
1759 location: router.latestLocation
1760 });
1761 if (!shouldRestore) {
1762 return;
1763 }
1764 }
1765 restoreScroll({
1766 storageKey,
1767 key: cacheKey,
1768 behavior: router.options.scrollRestorationBehavior,
1769 shouldScrollRestoration: router.isScrollRestoring,
1770 scrollToTopSelectors: router.options.scrollToTopSelectors,
1771 location: router.history.location
1772 });
1773 if (router.isScrollRestoring) {
1774 scrollRestorationCache.set((state) => {
1775 state[cacheKey] ||= {};
1776 return state;
1777 });
1778 }
1779 });
1780 }
1781 function handleHashScroll(router) {
1782 if (typeof document !== "undefined" && document.querySelector) {
1783 const hashScrollIntoViewOptions = router.state.location.state.__hashScrollIntoViewOptions ?? true;
1784 if (hashScrollIntoViewOptions && router.state.location.hash !== "") {
1785 const el = document.getElementById(router.state.location.hash);
1786 if (el) {
1787 el.scrollIntoView(hashScrollIntoViewOptions);
1788 }
1789 }
1790 }
1791 }
1792
1793 // node_modules/@tanstack/router-core/dist/esm/qss.js
1794 function encode(obj, stringify = String) {
1795 const result = new URLSearchParams();
1796 for (const key in obj) {
1797 const val = obj[key];
1798 if (val !== void 0) {
1799 result.set(key, stringify(val));
1800 }
1801 }
1802 return result.toString();
1803 }
1804 function toValue(str) {
1805 if (!str) return "";
1806 if (str === "false") return false;
1807 if (str === "true") return true;
1808 return +str * 0 === 0 && +str + "" === str ? +str : str;
1809 }
1810 function decode(str) {
1811 const searchParams = new URLSearchParams(str);
1812 const result = {};
1813 for (const [key, value] of searchParams.entries()) {
1814 const previousValue = result[key];
1815 if (previousValue == null) {
1816 result[key] = toValue(value);
1817 } else if (Array.isArray(previousValue)) {
1818 previousValue.push(toValue(value));
1819 } else {
1820 result[key] = [previousValue, toValue(value)];
1821 }
1822 }
1823 return result;
1824 }
1825
1826 // node_modules/@tanstack/router-core/dist/esm/searchParams.js
1827 var defaultParseSearch = parseSearchWith(JSON.parse);
1828 var defaultStringifySearch = stringifySearchWith(
1829 JSON.stringify,
1830 JSON.parse
1831 );
1832 function parseSearchWith(parser) {
1833 return (searchStr) => {
1834 if (searchStr[0] === "?") {
1835 searchStr = searchStr.substring(1);
1836 }
1837 const query = decode(searchStr);
1838 for (const key in query) {
1839 const value = query[key];
1840 if (typeof value === "string") {
1841 try {
1842 query[key] = parser(value);
1843 } catch (_err) {
1844 }
1845 }
1846 }
1847 return query;
1848 };
1849 }
1850 function stringifySearchWith(stringify, parser) {
1851 const hasParser = typeof parser === "function";
1852 function stringifyValue(val) {
1853 if (typeof val === "object" && val !== null) {
1854 try {
1855 return stringify(val);
1856 } catch (_err) {
1857 }
1858 } else if (hasParser && typeof val === "string") {
1859 try {
1860 parser(val);
1861 return stringify(val);
1862 } catch (_err) {
1863 }
1864 }
1865 return val;
1866 }
1867 return (search) => {
1868 const searchStr = encode(search, stringifyValue);
1869 return searchStr ? `?${searchStr}` : "";
1870 };
1871 }
1872
1873 // node_modules/@tanstack/router-core/dist/esm/root.js
1874 var rootRouteId = "__root__";
1875
1876 // node_modules/@tanstack/router-core/dist/esm/redirect.js
1877 function redirect(opts) {
1878 opts.statusCode = opts.statusCode || opts.code || 307;
1879 if (!opts.reloadDocument && typeof opts.href === "string") {
1880 try {
1881 new URL(opts.href);
1882 opts.reloadDocument = true;
1883 } catch {
1884 }
1885 }
1886 const headers = new Headers(opts.headers);
1887 if (opts.href && headers.get("Location") === null) {
1888 headers.set("Location", opts.href);
1889 }
1890 const response = new Response(null, {
1891 status: opts.statusCode,
1892 headers
1893 });
1894 response.options = opts;
1895 if (opts.throw) {
1896 throw response;
1897 }
1898 return response;
1899 }
1900 function isRedirect(obj) {
1901 return obj instanceof Response && !!obj.options;
1902 }
1903
1904 // node_modules/@tanstack/router-core/dist/esm/lru-cache.js
1905 function createLRUCache(max) {
1906 const cache = /* @__PURE__ */ new Map();
1907 let oldest;
1908 let newest;
1909 const touch = (entry) => {
1910 if (!entry.next) return;
1911 if (!entry.prev) {
1912 entry.next.prev = void 0;
1913 oldest = entry.next;
1914 entry.next = void 0;
1915 if (newest) {
1916 entry.prev = newest;
1917 newest.next = entry;
1918 }
1919 } else {
1920 entry.prev.next = entry.next;
1921 entry.next.prev = entry.prev;
1922 entry.next = void 0;
1923 if (newest) {
1924 newest.next = entry;
1925 entry.prev = newest;
1926 }
1927 }
1928 newest = entry;
1929 };
1930 return {
1931 get(key) {
1932 const entry = cache.get(key);
1933 if (!entry) return void 0;
1934 touch(entry);
1935 return entry.value;
1936 },
1937 set(key, value) {
1938 if (cache.size >= max && oldest) {
1939 const toDelete = oldest;
1940 cache.delete(toDelete.key);
1941 if (toDelete.next) {
1942 oldest = toDelete.next;
1943 toDelete.next.prev = void 0;
1944 }
1945 if (toDelete === newest) {
1946 newest = void 0;
1947 }
1948 }
1949 const existing = cache.get(key);
1950 if (existing) {
1951 existing.value = value;
1952 touch(existing);
1953 } else {
1954 const entry = { key, value, prev: newest };
1955 if (newest) newest.next = entry;
1956 newest = entry;
1957 if (!oldest) oldest = entry;
1958 cache.set(key, entry);
1959 }
1960 }
1961 };
1962 }
1963
1964 // node_modules/@tanstack/router-core/dist/esm/load-matches.js
1965 var triggerOnReady = (inner) => {
1966 if (!inner.rendered) {
1967 inner.rendered = true;
1968 return inner.onReady?.();
1969 }
1970 };
1971 var resolvePreload = (inner, matchId) => {
1972 return !!(inner.preload && !inner.router.state.matches.some((d) => d.id === matchId));
1973 };
1974 var _handleNotFound = (inner, err) => {
1975 const routeCursor = inner.router.routesById[err.routeId ?? ""] ?? inner.router.routeTree;
1976 if (!routeCursor.options.notFoundComponent && inner.router.options?.defaultNotFoundComponent) {
1977 routeCursor.options.notFoundComponent = inner.router.options.defaultNotFoundComponent;
1978 }
1979 invariant(
1980 routeCursor.options.notFoundComponent,
1981 "No notFoundComponent found. Please set a notFoundComponent on your route or provide a defaultNotFoundComponent to the router."
1982 );
1983 const matchForRoute = inner.matches.find((m) => m.routeId === routeCursor.id);
1984 invariant(matchForRoute, "Could not find match for route: " + routeCursor.id);
1985 inner.updateMatch(matchForRoute.id, (prev) => ({
1986 ...prev,
1987 status: "notFound",
1988 error: err,
1989 isFetching: false
1990 }));
1991 if (err.routerCode === "BEFORE_LOAD" && routeCursor.parentRoute) {
1992 err.routeId = routeCursor.parentRoute.id;
1993 _handleNotFound(inner, err);
1994 }
1995 };
1996 var handleRedirectAndNotFound = (inner, match, err) => {
1997 if (!isRedirect(err) && !isNotFound(err)) return;
1998 if (isRedirect(err) && err.redirectHandled && !err.options.reloadDocument) {
1999 throw err;
2000 }
2001 if (match) {
2002 match._nonReactive.beforeLoadPromise?.resolve();
2003 match._nonReactive.loaderPromise?.resolve();
2004 match._nonReactive.beforeLoadPromise = void 0;
2005 match._nonReactive.loaderPromise = void 0;
2006 const status = isRedirect(err) ? "redirected" : "notFound";
2007 inner.updateMatch(match.id, (prev) => ({
2008 ...prev,
2009 status,
2010 isFetching: false,
2011 error: err
2012 }));
2013 if (isNotFound(err) && !err.routeId) {
2014 err.routeId = match.routeId;
2015 }
2016 match._nonReactive.loadPromise?.resolve();
2017 }
2018 if (isRedirect(err)) {
2019 inner.rendered = true;
2020 err.options._fromLocation = inner.location;
2021 err.redirectHandled = true;
2022 err = inner.router.resolveRedirect(err);
2023 throw err;
2024 } else {
2025 _handleNotFound(inner, err);
2026 throw err;
2027 }
2028 };
2029 var shouldSkipLoader = (inner, matchId) => {
2030 const match = inner.router.getMatch(matchId);
2031 if (!inner.router.isServer && match._nonReactive.dehydrated) {
2032 return true;
2033 }
2034 if (inner.router.isServer && match.ssr === false) {
2035 return true;
2036 }
2037 return false;
2038 };
2039 var handleSerialError = (inner, index, err, routerCode) => {
2040 const { id: matchId, routeId } = inner.matches[index];
2041 const route = inner.router.looseRoutesById[routeId];
2042 if (err instanceof Promise) {
2043 throw err;
2044 }
2045 err.routerCode = routerCode;
2046 inner.firstBadMatchIndex ??= index;
2047 handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err);
2048 try {
2049 route.options.onError?.(err);
2050 } catch (errorHandlerErr) {
2051 err = errorHandlerErr;
2052 handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err);
2053 }
2054 inner.updateMatch(matchId, (prev) => {
2055 prev._nonReactive.beforeLoadPromise?.resolve();
2056 prev._nonReactive.beforeLoadPromise = void 0;
2057 prev._nonReactive.loadPromise?.resolve();
2058 return {
2059 ...prev,
2060 error: err,
2061 status: "error",
2062 isFetching: false,
2063 updatedAt: Date.now(),
2064 abortController: new AbortController()
2065 };
2066 });
2067 };
2068 var isBeforeLoadSsr = (inner, matchId, index, route) => {
2069 const existingMatch = inner.router.getMatch(matchId);
2070 const parentMatchId = inner.matches[index - 1]?.id;
2071 const parentMatch = parentMatchId ? inner.router.getMatch(parentMatchId) : void 0;
2072 if (inner.router.isShell()) {
2073 existingMatch.ssr = matchId === rootRouteId;
2074 return;
2075 }
2076 if (parentMatch?.ssr === false) {
2077 existingMatch.ssr = false;
2078 return;
2079 }
2080 const parentOverride = (tempSsr2) => {
2081 if (tempSsr2 === true && parentMatch?.ssr === "data-only") {
2082 return "data-only";
2083 }
2084 return tempSsr2;
2085 };
2086 const defaultSsr = inner.router.options.defaultSsr ?? true;
2087 if (route.options.ssr === void 0) {
2088 existingMatch.ssr = parentOverride(defaultSsr);
2089 return;
2090 }
2091 if (typeof route.options.ssr !== "function") {
2092 existingMatch.ssr = parentOverride(route.options.ssr);
2093 return;
2094 }
2095 const { search, params } = existingMatch;
2096 const ssrFnContext = {
2097 search: makeMaybe(search, existingMatch.searchError),
2098 params: makeMaybe(params, existingMatch.paramsError),
2099 location: inner.location,
2100 matches: inner.matches.map((match) => ({
2101 index: match.index,
2102 pathname: match.pathname,
2103 fullPath: match.fullPath,
2104 staticData: match.staticData,
2105 id: match.id,
2106 routeId: match.routeId,
2107 search: makeMaybe(match.search, match.searchError),
2108 params: makeMaybe(match.params, match.paramsError),
2109 ssr: match.ssr
2110 }))
2111 };
2112 const tempSsr = route.options.ssr(ssrFnContext);
2113 if (isPromise(tempSsr)) {
2114 return tempSsr.then((ssr) => {
2115 existingMatch.ssr = parentOverride(ssr ?? defaultSsr);
2116 });
2117 }
2118 existingMatch.ssr = parentOverride(tempSsr ?? defaultSsr);
2119 return;
2120 };
2121 var setupPendingTimeout = (inner, matchId, route, match) => {
2122 if (match._nonReactive.pendingTimeout !== void 0) return;
2123 const pendingMs = route.options.pendingMs ?? inner.router.options.defaultPendingMs;
2124 const shouldPending = !!(inner.onReady && !inner.router.isServer && !resolvePreload(inner, matchId) && (route.options.loader || route.options.beforeLoad || routeNeedsPreload(route)) && typeof pendingMs === "number" && pendingMs !== Infinity && (route.options.pendingComponent ?? inner.router.options?.defaultPendingComponent));
2125 if (shouldPending) {
2126 const pendingTimeout = setTimeout(() => {
2127 triggerOnReady(inner);
2128 }, pendingMs);
2129 match._nonReactive.pendingTimeout = pendingTimeout;
2130 }
2131 };
2132 var preBeforeLoadSetup = (inner, matchId, route) => {
2133 const existingMatch = inner.router.getMatch(matchId);
2134 if (!existingMatch._nonReactive.beforeLoadPromise && !existingMatch._nonReactive.loaderPromise)
2135 return;
2136 setupPendingTimeout(inner, matchId, route, existingMatch);
2137 const then = () => {
2138 const match = inner.router.getMatch(matchId);
2139 if (match.preload && (match.status === "redirected" || match.status === "notFound")) {
2140 handleRedirectAndNotFound(inner, match, match.error);
2141 }
2142 };
2143 return existingMatch._nonReactive.beforeLoadPromise ? existingMatch._nonReactive.beforeLoadPromise.then(then) : then();
2144 };
2145 var executeBeforeLoad = (inner, matchId, index, route) => {
2146 const match = inner.router.getMatch(matchId);
2147 const prevLoadPromise = match._nonReactive.loadPromise;
2148 match._nonReactive.loadPromise = createControlledPromise(() => {
2149 prevLoadPromise?.resolve();
2150 });
2151 const { paramsError, searchError } = match;
2152 if (paramsError) {
2153 handleSerialError(inner, index, paramsError, "PARSE_PARAMS");
2154 }
2155 if (searchError) {
2156 handleSerialError(inner, index, searchError, "VALIDATE_SEARCH");
2157 }
2158 setupPendingTimeout(inner, matchId, route, match);
2159 const abortController = new AbortController();
2160 const parentMatchId = inner.matches[index - 1]?.id;
2161 const parentMatch = parentMatchId ? inner.router.getMatch(parentMatchId) : void 0;
2162 const parentMatchContext = parentMatch?.context ?? inner.router.options.context ?? void 0;
2163 const context = { ...parentMatchContext, ...match.__routeContext };
2164 let isPending = false;
2165 const pending = () => {
2166 if (isPending) return;
2167 isPending = true;
2168 inner.updateMatch(matchId, (prev) => ({
2169 ...prev,
2170 isFetching: "beforeLoad",
2171 fetchCount: prev.fetchCount + 1,
2172 abortController,
2173 context
2174 }));
2175 };
2176 const resolve = () => {
2177 match._nonReactive.beforeLoadPromise?.resolve();
2178 match._nonReactive.beforeLoadPromise = void 0;
2179 inner.updateMatch(matchId, (prev) => ({
2180 ...prev,
2181 isFetching: false
2182 }));
2183 };
2184 if (!route.options.beforeLoad) {
2185 batch(() => {
2186 pending();
2187 resolve();
2188 });
2189 return;
2190 }
2191 match._nonReactive.beforeLoadPromise = createControlledPromise();
2192 const { search, params, cause } = match;
2193 const preload = resolvePreload(inner, matchId);
2194 const beforeLoadFnContext = {
2195 search,
2196 abortController,
2197 params,
2198 preload,
2199 context,
2200 location: inner.location,
2201 navigate: (opts) => inner.router.navigate({
2202 ...opts,
2203 _fromLocation: inner.location
2204 }),
2205 buildLocation: inner.router.buildLocation,
2206 cause: preload ? "preload" : cause,
2207 matches: inner.matches,
2208 ...inner.router.options.additionalContext
2209 };
2210 const updateContext = (beforeLoadContext2) => {
2211 if (beforeLoadContext2 === void 0) {
2212 batch(() => {
2213 pending();
2214 resolve();
2215 });
2216 return;
2217 }
2218 if (isRedirect(beforeLoadContext2) || isNotFound(beforeLoadContext2)) {
2219 pending();
2220 handleSerialError(inner, index, beforeLoadContext2, "BEFORE_LOAD");
2221 }
2222 batch(() => {
2223 pending();
2224 inner.updateMatch(matchId, (prev) => ({
2225 ...prev,
2226 __beforeLoadContext: beforeLoadContext2,
2227 context: {
2228 ...prev.context,
2229 ...beforeLoadContext2
2230 }
2231 }));
2232 resolve();
2233 });
2234 };
2235 let beforeLoadContext;
2236 try {
2237 beforeLoadContext = route.options.beforeLoad(beforeLoadFnContext);
2238 if (isPromise(beforeLoadContext)) {
2239 pending();
2240 return beforeLoadContext.catch((err) => {
2241 handleSerialError(inner, index, err, "BEFORE_LOAD");
2242 }).then(updateContext);
2243 }
2244 } catch (err) {
2245 pending();
2246 handleSerialError(inner, index, err, "BEFORE_LOAD");
2247 }
2248 updateContext(beforeLoadContext);
2249 return;
2250 };
2251 var handleBeforeLoad = (inner, index) => {
2252 const { id: matchId, routeId } = inner.matches[index];
2253 const route = inner.router.looseRoutesById[routeId];
2254 const serverSsr = () => {
2255 if (inner.router.isServer) {
2256 const maybePromise = isBeforeLoadSsr(inner, matchId, index, route);
2257 if (isPromise(maybePromise)) return maybePromise.then(queueExecution);
2258 }
2259 return queueExecution();
2260 };
2261 const execute = () => executeBeforeLoad(inner, matchId, index, route);
2262 const queueExecution = () => {
2263 if (shouldSkipLoader(inner, matchId)) return;
2264 const result = preBeforeLoadSetup(inner, matchId, route);
2265 return isPromise(result) ? result.then(execute) : execute();
2266 };
2267 return serverSsr();
2268 };
2269 var executeHead = (inner, matchId, route) => {
2270 const match = inner.router.getMatch(matchId);
2271 if (!match) {
2272 return;
2273 }
2274 if (!route.options.head && !route.options.scripts && !route.options.headers) {
2275 return;
2276 }
2277 const assetContext = {
2278 matches: inner.matches,
2279 match,
2280 params: match.params,
2281 loaderData: match.loaderData
2282 };
2283 return Promise.all([
2284 route.options.head?.(assetContext),
2285 route.options.scripts?.(assetContext),
2286 route.options.headers?.(assetContext)
2287 ]).then(([headFnContent, scripts, headers]) => {
2288 const meta = headFnContent?.meta;
2289 const links = headFnContent?.links;
2290 const headScripts = headFnContent?.scripts;
2291 const styles = headFnContent?.styles;
2292 return {
2293 meta,
2294 links,
2295 headScripts,
2296 headers,
2297 scripts,
2298 styles
2299 };
2300 });
2301 };
2302 var getLoaderContext = (inner, matchId, index, route) => {
2303 const parentMatchPromise = inner.matchPromises[index - 1];
2304 const { params, loaderDeps, abortController, context, cause } = inner.router.getMatch(matchId);
2305 const preload = resolvePreload(inner, matchId);
2306 return {
2307 params,
2308 deps: loaderDeps,
2309 preload: !!preload,
2310 parentMatchPromise,
2311 abortController,
2312 context,
2313 location: inner.location,
2314 navigate: (opts) => inner.router.navigate({
2315 ...opts,
2316 _fromLocation: inner.location
2317 }),
2318 cause: preload ? "preload" : cause,
2319 route,
2320 ...inner.router.options.additionalContext
2321 };
2322 };
2323 var runLoader = async (inner, matchId, index, route) => {
2324 try {
2325 const match = inner.router.getMatch(matchId);
2326 try {
2327 if (!inner.router.isServer || match.ssr === true) {
2328 loadRouteChunk(route);
2329 }
2330 const loaderResult = route.options.loader?.(
2331 getLoaderContext(inner, matchId, index, route)
2332 );
2333 const loaderResultIsPromise = route.options.loader && isPromise(loaderResult);
2334 const willLoadSomething = !!(loaderResultIsPromise || route._lazyPromise || route._componentsPromise || route.options.head || route.options.scripts || route.options.headers || match._nonReactive.minPendingPromise);
2335 if (willLoadSomething) {
2336 inner.updateMatch(matchId, (prev) => ({
2337 ...prev,
2338 isFetching: "loader"
2339 }));
2340 }
2341 if (route.options.loader) {
2342 const loaderData = loaderResultIsPromise ? await loaderResult : loaderResult;
2343 handleRedirectAndNotFound(
2344 inner,
2345 inner.router.getMatch(matchId),
2346 loaderData
2347 );
2348 if (loaderData !== void 0) {
2349 inner.updateMatch(matchId, (prev) => ({
2350 ...prev,
2351 loaderData
2352 }));
2353 }
2354 }
2355 if (route._lazyPromise) await route._lazyPromise;
2356 const headResult = executeHead(inner, matchId, route);
2357 const head = headResult ? await headResult : void 0;
2358 const pendingPromise = match._nonReactive.minPendingPromise;
2359 if (pendingPromise) await pendingPromise;
2360 if (route._componentsPromise) await route._componentsPromise;
2361 inner.updateMatch(matchId, (prev) => ({
2362 ...prev,
2363 error: void 0,
2364 status: "success",
2365 isFetching: false,
2366 updatedAt: Date.now(),
2367 ...head
2368 }));
2369 } catch (e) {
2370 let error = e;
2371 const pendingPromise = match._nonReactive.minPendingPromise;
2372 if (pendingPromise) await pendingPromise;
2373 if (isNotFound(e)) {
2374 await route.options.notFoundComponent?.preload?.();
2375 }
2376 handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), e);
2377 try {
2378 route.options.onError?.(e);
2379 } catch (onErrorError) {
2380 error = onErrorError;
2381 handleRedirectAndNotFound(
2382 inner,
2383 inner.router.getMatch(matchId),
2384 onErrorError
2385 );
2386 }
2387 const headResult = executeHead(inner, matchId, route);
2388 const head = headResult ? await headResult : void 0;
2389 inner.updateMatch(matchId, (prev) => ({
2390 ...prev,
2391 error,
2392 status: "error",
2393 isFetching: false,
2394 ...head
2395 }));
2396 }
2397 } catch (err) {
2398 const match = inner.router.getMatch(matchId);
2399 if (match) {
2400 const headResult = executeHead(inner, matchId, route);
2401 if (headResult) {
2402 const head = await headResult;
2403 inner.updateMatch(matchId, (prev) => ({
2404 ...prev,
2405 ...head
2406 }));
2407 }
2408 match._nonReactive.loaderPromise = void 0;
2409 }
2410 handleRedirectAndNotFound(inner, match, err);
2411 }
2412 };
2413 var loadRouteMatch = async (inner, index) => {
2414 const { id: matchId, routeId } = inner.matches[index];
2415 let loaderShouldRunAsync = false;
2416 let loaderIsRunningAsync = false;
2417 const route = inner.router.looseRoutesById[routeId];
2418 if (shouldSkipLoader(inner, matchId)) {
2419 if (inner.router.isServer) {
2420 const headResult = executeHead(inner, matchId, route);
2421 if (headResult) {
2422 const head = await headResult;
2423 inner.updateMatch(matchId, (prev) => ({
2424 ...prev,
2425 ...head
2426 }));
2427 }
2428 return inner.router.getMatch(matchId);
2429 }
2430 } else {
2431 const prevMatch = inner.router.getMatch(matchId);
2432 if (prevMatch._nonReactive.loaderPromise) {
2433 if (prevMatch.status === "success" && !inner.sync && !prevMatch.preload) {
2434 return prevMatch;
2435 }
2436 await prevMatch._nonReactive.loaderPromise;
2437 const match2 = inner.router.getMatch(matchId);
2438 if (match2.error) {
2439 handleRedirectAndNotFound(inner, match2, match2.error);
2440 }
2441 } else {
2442 const age = Date.now() - prevMatch.updatedAt;
2443 const preload = resolvePreload(inner, matchId);
2444 const staleAge = preload ? route.options.preloadStaleTime ?? inner.router.options.defaultPreloadStaleTime ?? 3e4 : route.options.staleTime ?? inner.router.options.defaultStaleTime ?? 0;
2445 const shouldReloadOption = route.options.shouldReload;
2446 const shouldReload = typeof shouldReloadOption === "function" ? shouldReloadOption(getLoaderContext(inner, matchId, index, route)) : shouldReloadOption;
2447 const nextPreload = !!preload && !inner.router.state.matches.some((d) => d.id === matchId);
2448 const match2 = inner.router.getMatch(matchId);
2449 match2._nonReactive.loaderPromise = createControlledPromise();
2450 if (nextPreload !== match2.preload) {
2451 inner.updateMatch(matchId, (prev) => ({
2452 ...prev,
2453 preload: nextPreload
2454 }));
2455 }
2456 const { status, invalid } = match2;
2457 loaderShouldRunAsync = status === "success" && (invalid || (shouldReload ?? age > staleAge));
2458 if (preload && route.options.preload === false) ;
2459 else if (loaderShouldRunAsync && !inner.sync) {
2460 loaderIsRunningAsync = true;
2461 (async () => {
2462 try {
2463 await runLoader(inner, matchId, index, route);
2464 const match3 = inner.router.getMatch(matchId);
2465 match3._nonReactive.loaderPromise?.resolve();
2466 match3._nonReactive.loadPromise?.resolve();
2467 match3._nonReactive.loaderPromise = void 0;
2468 } catch (err) {
2469 if (isRedirect(err)) {
2470 await inner.router.navigate(err.options);
2471 }
2472 }
2473 })();
2474 } else if (status !== "success" || loaderShouldRunAsync && inner.sync) {
2475 await runLoader(inner, matchId, index, route);
2476 } else {
2477 const headResult = executeHead(inner, matchId, route);
2478 if (headResult) {
2479 const head = await headResult;
2480 inner.updateMatch(matchId, (prev) => ({
2481 ...prev,
2482 ...head
2483 }));
2484 }
2485 }
2486 }
2487 }
2488 const match = inner.router.getMatch(matchId);
2489 if (!loaderIsRunningAsync) {
2490 match._nonReactive.loaderPromise?.resolve();
2491 match._nonReactive.loadPromise?.resolve();
2492 }
2493 clearTimeout(match._nonReactive.pendingTimeout);
2494 match._nonReactive.pendingTimeout = void 0;
2495 if (!loaderIsRunningAsync) match._nonReactive.loaderPromise = void 0;
2496 match._nonReactive.dehydrated = void 0;
2497 const nextIsFetching = loaderIsRunningAsync ? match.isFetching : false;
2498 if (nextIsFetching !== match.isFetching || match.invalid !== false) {
2499 inner.updateMatch(matchId, (prev) => ({
2500 ...prev,
2501 isFetching: nextIsFetching,
2502 invalid: false
2503 }));
2504 return inner.router.getMatch(matchId);
2505 } else {
2506 return match;
2507 }
2508 };
2509 async function loadMatches(arg) {
2510 const inner = Object.assign(arg, {
2511 matchPromises: []
2512 });
2513 if (!inner.router.isServer && inner.router.state.matches.some((d) => d._forcePending)) {
2514 triggerOnReady(inner);
2515 }
2516 try {
2517 for (let i = 0; i < inner.matches.length; i++) {
2518 const beforeLoad = handleBeforeLoad(inner, i);
2519 if (isPromise(beforeLoad)) await beforeLoad;
2520 }
2521 const max = inner.firstBadMatchIndex ?? inner.matches.length;
2522 for (let i = 0; i < max; i++) {
2523 inner.matchPromises.push(loadRouteMatch(inner, i));
2524 }
2525 await Promise.all(inner.matchPromises);
2526 const readyPromise = triggerOnReady(inner);
2527 if (isPromise(readyPromise)) await readyPromise;
2528 } catch (err) {
2529 if (isNotFound(err) && !inner.preload) {
2530 const readyPromise = triggerOnReady(inner);
2531 if (isPromise(readyPromise)) await readyPromise;
2532 throw err;
2533 }
2534 if (isRedirect(err)) {
2535 throw err;
2536 }
2537 }
2538 return inner.matches;
2539 }
2540 async function loadRouteChunk(route) {
2541 if (!route._lazyLoaded && route._lazyPromise === void 0) {
2542 if (route.lazyFn) {
2543 route._lazyPromise = route.lazyFn().then((lazyRoute) => {
2544 const { id: _id, ...options } = lazyRoute.options;
2545 Object.assign(route.options, options);
2546 route._lazyLoaded = true;
2547 route._lazyPromise = void 0;
2548 });
2549 } else {
2550 route._lazyLoaded = true;
2551 }
2552 }
2553 if (!route._componentsLoaded && route._componentsPromise === void 0) {
2554 const loadComponents = () => {
2555 const preloads = [];
2556 for (const type of componentTypes) {
2557 const preload = route.options[type]?.preload;
2558 if (preload) preloads.push(preload());
2559 }
2560 if (preloads.length)
2561 return Promise.all(preloads).then(() => {
2562 route._componentsLoaded = true;
2563 route._componentsPromise = void 0;
2564 });
2565 route._componentsLoaded = true;
2566 route._componentsPromise = void 0;
2567 return;
2568 };
2569 route._componentsPromise = route._lazyPromise ? route._lazyPromise.then(loadComponents) : loadComponents();
2570 }
2571 return route._componentsPromise;
2572 }
2573 function makeMaybe(value, error) {
2574 if (error) {
2575 return { status: "error", error };
2576 }
2577 return { status: "success", value };
2578 }
2579 function routeNeedsPreload(route) {
2580 for (const componentType of componentTypes) {
2581 if (route.options[componentType]?.preload) {
2582 return true;
2583 }
2584 }
2585 return false;
2586 }
2587 var componentTypes = [
2588 "component",
2589 "errorComponent",
2590 "pendingComponent",
2591 "notFoundComponent"
2592 ];
2593
2594 // node_modules/@tanstack/router-core/dist/esm/rewrite.js
2595 function composeRewrites(rewrites) {
2596 return {
2597 input: ({ url }) => {
2598 for (const rewrite of rewrites) {
2599 url = executeRewriteInput(rewrite, url);
2600 }
2601 return url;
2602 },
2603 output: ({ url }) => {
2604 for (let i = rewrites.length - 1; i >= 0; i--) {
2605 url = executeRewriteOutput(rewrites[i], url);
2606 }
2607 return url;
2608 }
2609 };
2610 }
2611 function rewriteBasepath(opts) {
2612 const trimmedBasepath = trimPath(opts.basepath);
2613 const normalizedBasepath = `/${trimmedBasepath}`;
2614 const normalizedBasepathWithSlash = `${normalizedBasepath}/`;
2615 const checkBasepath = opts.caseSensitive ? normalizedBasepath : normalizedBasepath.toLowerCase();
2616 const checkBasepathWithSlash = opts.caseSensitive ? normalizedBasepathWithSlash : normalizedBasepathWithSlash.toLowerCase();
2617 return {
2618 input: ({ url }) => {
2619 const pathname = opts.caseSensitive ? url.pathname : url.pathname.toLowerCase();
2620 if (pathname === checkBasepath) {
2621 url.pathname = "/";
2622 } else if (pathname.startsWith(checkBasepathWithSlash)) {
2623 url.pathname = url.pathname.slice(normalizedBasepath.length);
2624 }
2625 return url;
2626 },
2627 output: ({ url }) => {
2628 url.pathname = joinPaths(["/", trimmedBasepath, url.pathname]);
2629 return url;
2630 }
2631 };
2632 }
2633 function executeRewriteInput(rewrite, url) {
2634 const res = rewrite?.input?.({ url });
2635 if (res) {
2636 if (typeof res === "string") {
2637 return new URL(res);
2638 } else if (res instanceof URL) {
2639 return res;
2640 }
2641 }
2642 return url;
2643 }
2644 function executeRewriteOutput(rewrite, url) {
2645 const res = rewrite?.output?.({ url });
2646 if (res) {
2647 if (typeof res === "string") {
2648 return new URL(res);
2649 } else if (res instanceof URL) {
2650 return res;
2651 }
2652 }
2653 return url;
2654 }
2655
2656 // node_modules/@tanstack/router-core/dist/esm/router.js
2657 function getLocationChangeInfo(routerState) {
2658 const fromLocation = routerState.resolvedLocation;
2659 const toLocation = routerState.location;
2660 const pathChanged = fromLocation?.pathname !== toLocation.pathname;
2661 const hrefChanged = fromLocation?.href !== toLocation.href;
2662 const hashChanged = fromLocation?.hash !== toLocation.hash;
2663 return { fromLocation, toLocation, pathChanged, hrefChanged, hashChanged };
2664 }
2665 var RouterCore = class {
2666 /**
2667 * @deprecated Use the `createRouter` function instead
2668 */
2669 constructor(options) {
2670 this.tempLocationKey = `${Math.round(
2671 Math.random() * 1e7
2672 )}`;
2673 this.resetNextScroll = true;
2674 this.shouldViewTransition = void 0;
2675 this.isViewTransitionTypesSupported = void 0;
2676 this.subscribers = /* @__PURE__ */ new Set();
2677 this.isScrollRestoring = false;
2678 this.isScrollRestorationSetup = false;
2679 this.startTransition = (fn) => fn();
2680 this.update = (newOptions) => {
2681 if (newOptions.notFoundRoute) {
2682 console.warn(
2683 "The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info."
2684 );
2685 }
2686 const prevOptions = this.options;
2687 const prevBasepath = this.basepath ?? prevOptions?.basepath ?? "/";
2688 const basepathWasUnset = this.basepath === void 0;
2689 const prevRewriteOption = prevOptions?.rewrite;
2690 this.options = {
2691 ...prevOptions,
2692 ...newOptions
2693 };
2694 this.isServer = this.options.isServer ?? typeof document === "undefined";
2695 this.pathParamsDecodeCharMap = this.options.pathParamsAllowedCharacters ? new Map(
2696 this.options.pathParamsAllowedCharacters.map((char) => [
2697 encodeURIComponent(char),
2698 char
2699 ])
2700 ) : void 0;
2701 if (!this.history || this.options.history && this.options.history !== this.history) {
2702 if (!this.options.history) {
2703 if (!this.isServer) {
2704 this.history = createBrowserHistory();
2705 }
2706 } else {
2707 this.history = this.options.history;
2708 }
2709 }
2710 this.origin = this.options.origin;
2711 if (!this.origin) {
2712 if (!this.isServer && window?.origin && window.origin !== "null") {
2713 this.origin = window.origin;
2714 } else {
2715 this.origin = "http://localhost";
2716 }
2717 }
2718 if (this.history) {
2719 this.updateLatestLocation();
2720 }
2721 if (this.options.routeTree !== this.routeTree) {
2722 this.routeTree = this.options.routeTree;
2723 this.buildRouteTree();
2724 }
2725 if (!this.__store && this.latestLocation) {
2726 this.__store = new Store(getInitialRouterState(this.latestLocation), {
2727 onUpdate: () => {
2728 this.__store.state = {
2729 ...this.state,
2730 cachedMatches: this.state.cachedMatches.filter(
2731 (d) => !["redirected"].includes(d.status)
2732 )
2733 };
2734 }
2735 });
2736 setupScrollRestoration(this);
2737 }
2738 let needsLocationUpdate = false;
2739 const nextBasepath = this.options.basepath ?? "/";
2740 const nextRewriteOption = this.options.rewrite;
2741 const basepathChanged = basepathWasUnset || prevBasepath !== nextBasepath;
2742 const rewriteChanged = prevRewriteOption !== nextRewriteOption;
2743 if (basepathChanged || rewriteChanged) {
2744 this.basepath = nextBasepath;
2745 const rewrites = [];
2746 if (trimPath(nextBasepath) !== "") {
2747 rewrites.push(
2748 rewriteBasepath({
2749 basepath: nextBasepath
2750 })
2751 );
2752 }
2753 if (nextRewriteOption) {
2754 rewrites.push(nextRewriteOption);
2755 }
2756 this.rewrite = rewrites.length === 0 ? void 0 : rewrites.length === 1 ? rewrites[0] : composeRewrites(rewrites);
2757 if (this.history) {
2758 this.updateLatestLocation();
2759 }
2760 needsLocationUpdate = true;
2761 }
2762 if (needsLocationUpdate && this.__store) {
2763 this.__store.state = {
2764 ...this.state,
2765 location: this.latestLocation
2766 };
2767 }
2768 if (typeof window !== "undefined" && "CSS" in window && typeof window.CSS?.supports === "function") {
2769 this.isViewTransitionTypesSupported = window.CSS.supports(
2770 "selector(:active-view-transition-type(a)"
2771 );
2772 }
2773 };
2774 this.updateLatestLocation = () => {
2775 this.latestLocation = this.parseLocation(
2776 this.history.location,
2777 this.latestLocation
2778 );
2779 };
2780 this.buildRouteTree = () => {
2781 const { routesById, routesByPath, flatRoutes } = processRouteTree({
2782 routeTree: this.routeTree,
2783 initRoute: (route, i) => {
2784 route.init({
2785 originalIndex: i
2786 });
2787 }
2788 });
2789 this.routesById = routesById;
2790 this.routesByPath = routesByPath;
2791 this.flatRoutes = flatRoutes;
2792 const notFoundRoute = this.options.notFoundRoute;
2793 if (notFoundRoute) {
2794 notFoundRoute.init({
2795 originalIndex: 99999999999
2796 });
2797 this.routesById[notFoundRoute.id] = notFoundRoute;
2798 }
2799 };
2800 this.subscribe = (eventType, fn) => {
2801 const listener = {
2802 eventType,
2803 fn
2804 };
2805 this.subscribers.add(listener);
2806 return () => {
2807 this.subscribers.delete(listener);
2808 };
2809 };
2810 this.emit = (routerEvent) => {
2811 this.subscribers.forEach((listener) => {
2812 if (listener.eventType === routerEvent.type) {
2813 listener.fn(routerEvent);
2814 }
2815 });
2816 };
2817 this.parseLocation = (locationToParse, previousLocation) => {
2818 const parse = ({
2819 href,
2820 state
2821 }) => {
2822 const fullUrl = new URL(href, this.origin);
2823 const url = executeRewriteInput(this.rewrite, fullUrl);
2824 const parsedSearch = this.options.parseSearch(url.search);
2825 const searchStr = this.options.stringifySearch(parsedSearch);
2826 url.search = searchStr;
2827 const fullPath = url.href.replace(url.origin, "");
2828 const { pathname, hash } = url;
2829 return {
2830 href: fullPath,
2831 publicHref: href,
2832 url: url.href,
2833 pathname,
2834 searchStr,
2835 search: replaceEqualDeep(previousLocation?.search, parsedSearch),
2836 hash: hash.split("#").reverse()[0] ?? "",
2837 state: replaceEqualDeep(previousLocation?.state, state)
2838 };
2839 };
2840 const location = parse(locationToParse);
2841 const { __tempLocation, __tempKey } = location.state;
2842 if (__tempLocation && (!__tempKey || __tempKey === this.tempLocationKey)) {
2843 const parsedTempLocation = parse(__tempLocation);
2844 parsedTempLocation.state.key = location.state.key;
2845 parsedTempLocation.state.__TSR_key = location.state.__TSR_key;
2846 delete parsedTempLocation.state.__tempLocation;
2847 return {
2848 ...parsedTempLocation,
2849 maskedLocation: location
2850 };
2851 }
2852 return location;
2853 };
2854 this.resolvePathWithBase = (from, path) => {
2855 const resolvedPath = resolvePath({
2856 base: from,
2857 to: cleanPath(path),
2858 trailingSlash: this.options.trailingSlash,
2859 parseCache: this.parsePathnameCache
2860 });
2861 return resolvedPath;
2862 };
2863 this.matchRoutes = (pathnameOrNext, locationSearchOrOpts, opts) => {
2864 if (typeof pathnameOrNext === "string") {
2865 return this.matchRoutesInternal(
2866 {
2867 pathname: pathnameOrNext,
2868 search: locationSearchOrOpts
2869 },
2870 opts
2871 );
2872 }
2873 return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts);
2874 };
2875 this.parsePathnameCache = createLRUCache(1e3);
2876 this.getMatchedRoutes = (pathname, routePathname) => {
2877 return getMatchedRoutes({
2878 pathname,
2879 routePathname,
2880 caseSensitive: this.options.caseSensitive,
2881 routesByPath: this.routesByPath,
2882 routesById: this.routesById,
2883 flatRoutes: this.flatRoutes,
2884 parseCache: this.parsePathnameCache
2885 });
2886 };
2887 this.cancelMatch = (id) => {
2888 const match = this.getMatch(id);
2889 if (!match) return;
2890 match.abortController.abort();
2891 clearTimeout(match._nonReactive.pendingTimeout);
2892 match._nonReactive.pendingTimeout = void 0;
2893 };
2894 this.cancelMatches = () => {
2895 this.state.pendingMatches?.forEach((match) => {
2896 this.cancelMatch(match.id);
2897 });
2898 };
2899 this.buildLocation = (opts) => {
2900 const build = (dest = {}) => {
2901 const currentLocation = dest._fromLocation || this.latestLocation;
2902 const allCurrentLocationMatches = this.matchRoutes(currentLocation, {
2903 _buildLocation: true
2904 });
2905 const lastMatch = last(allCurrentLocationMatches);
2906 if (dest.from && true && dest._isNavigate) {
2907 const allFromMatches = this.getMatchedRoutes(
2908 dest.from,
2909 void 0
2910 ).matchedRoutes;
2911 const matchedFrom = findLast(allCurrentLocationMatches, (d) => {
2912 return comparePaths(d.fullPath, dest.from);
2913 });
2914 const matchedCurrent = findLast(allFromMatches, (d) => {
2915 return comparePaths(d.fullPath, lastMatch.fullPath);
2916 });
2917 if (!matchedFrom && !matchedCurrent) {
2918 console.warn(`Could not find match for from: ${dest.from}`);
2919 }
2920 }
2921 const defaultedFromPath = dest.unsafeRelative === "path" ? currentLocation.pathname : dest.from ?? lastMatch.fullPath;
2922 const fromPath = this.resolvePathWithBase(defaultedFromPath, ".");
2923 const fromSearch = lastMatch.search;
2924 const fromParams = { ...lastMatch.params };
2925 const nextTo = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
2926 const nextParams = dest.params === false || dest.params === null ? {} : (dest.params ?? true) === true ? fromParams : Object.assign(
2927 fromParams,
2928 functionalUpdate(dest.params, fromParams)
2929 );
2930 const interpolatedNextTo = interpolatePath({
2931 path: nextTo,
2932 params: nextParams,
2933 parseCache: this.parsePathnameCache
2934 }).interpolatedPath;
2935 const destRoutes = this.matchRoutes(interpolatedNextTo, void 0, {
2936 _buildLocation: true
2937 }).map((d) => this.looseRoutesById[d.routeId]);
2938 if (Object.keys(nextParams).length > 0) {
2939 for (const route of destRoutes) {
2940 const fn = route.options.params?.stringify ?? route.options.stringifyParams;
2941 if (fn) {
2942 Object.assign(nextParams, fn(nextParams));
2943 }
2944 }
2945 }
2946 const nextPathname = decodePathSegment(
2947 interpolatePath({
2948 // Use the original template path for interpolation
2949 // This preserves the original parameter syntax including optional parameters
2950 path: nextTo,
2951 params: nextParams,
2952 leaveWildcards: false,
2953 leaveParams: opts.leaveParams,
2954 decodeCharMap: this.pathParamsDecodeCharMap,
2955 parseCache: this.parsePathnameCache
2956 }).interpolatedPath
2957 );
2958 let nextSearch = fromSearch;
2959 if (opts._includeValidateSearch && this.options.search?.strict) {
2960 const validatedSearch = {};
2961 destRoutes.forEach((route) => {
2962 if (route.options.validateSearch) {
2963 try {
2964 Object.assign(
2965 validatedSearch,
2966 validateSearch(route.options.validateSearch, {
2967 ...validatedSearch,
2968 ...nextSearch
2969 })
2970 );
2971 } catch {
2972 }
2973 }
2974 });
2975 nextSearch = validatedSearch;
2976 }
2977 nextSearch = applySearchMiddleware({
2978 search: nextSearch,
2979 dest,
2980 destRoutes,
2981 _includeValidateSearch: opts._includeValidateSearch
2982 });
2983 nextSearch = replaceEqualDeep(fromSearch, nextSearch);
2984 const searchStr = this.options.stringifySearch(nextSearch);
2985 const hash = dest.hash === true ? currentLocation.hash : dest.hash ? functionalUpdate(dest.hash, currentLocation.hash) : void 0;
2986 const hashStr = hash ? `#${hash}` : "";
2987 let nextState = dest.state === true ? currentLocation.state : dest.state ? functionalUpdate(dest.state, currentLocation.state) : {};
2988 nextState = replaceEqualDeep(currentLocation.state, nextState);
2989 const fullPath = `${nextPathname}${searchStr}${hashStr}`;
2990 const url = new URL(fullPath, this.origin);
2991 const rewrittenUrl = executeRewriteOutput(this.rewrite, url);
2992 return {
2993 publicHref: rewrittenUrl.pathname + rewrittenUrl.search + rewrittenUrl.hash,
2994 href: fullPath,
2995 url: rewrittenUrl.href,
2996 pathname: nextPathname,
2997 search: nextSearch,
2998 searchStr,
2999 state: nextState,
3000 hash: hash ?? "",
3001 unmaskOnReload: dest.unmaskOnReload
3002 };
3003 };
3004 const buildWithMatches = (dest = {}, maskedDest) => {
3005 const next = build(dest);
3006 let maskedNext = maskedDest ? build(maskedDest) : void 0;
3007 if (!maskedNext) {
3008 let params = {};
3009 const foundMask = this.options.routeMasks?.find((d) => {
3010 const match = matchPathname(
3011 next.pathname,
3012 {
3013 to: d.from,
3014 caseSensitive: false,
3015 fuzzy: false
3016 },
3017 this.parsePathnameCache
3018 );
3019 if (match) {
3020 params = match;
3021 return true;
3022 }
3023 return false;
3024 });
3025 if (foundMask) {
3026 const { from: _from, ...maskProps } = foundMask;
3027 maskedDest = {
3028 from: opts.from,
3029 ...maskProps,
3030 params
3031 };
3032 maskedNext = build(maskedDest);
3033 }
3034 }
3035 if (maskedNext) {
3036 next.maskedLocation = maskedNext;
3037 }
3038 return next;
3039 };
3040 if (opts.mask) {
3041 return buildWithMatches(opts, {
3042 from: opts.from,
3043 ...opts.mask
3044 });
3045 }
3046 return buildWithMatches(opts);
3047 };
3048 this.commitLocation = ({
3049 viewTransition,
3050 ignoreBlocker,
3051 ...next
3052 }) => {
3053 const isSameState = () => {
3054 const ignoredProps = [
3055 "key",
3056 // TODO: Remove in v2 - use __TSR_key instead
3057 "__TSR_key",
3058 "__TSR_index",
3059 "__hashScrollIntoViewOptions"
3060 ];
3061 ignoredProps.forEach((prop) => {
3062 next.state[prop] = this.latestLocation.state[prop];
3063 });
3064 const isEqual = deepEqual(next.state, this.latestLocation.state);
3065 ignoredProps.forEach((prop) => {
3066 delete next.state[prop];
3067 });
3068 return isEqual;
3069 };
3070 const isSameUrl = trimPathRight(this.latestLocation.href) === trimPathRight(next.href);
3071 const previousCommitPromise = this.commitLocationPromise;
3072 this.commitLocationPromise = createControlledPromise(() => {
3073 previousCommitPromise?.resolve();
3074 });
3075 if (isSameUrl && isSameState()) {
3076 this.load();
3077 } else {
3078 let { maskedLocation, hashScrollIntoView, ...nextHistory } = next;
3079 if (maskedLocation) {
3080 nextHistory = {
3081 ...maskedLocation,
3082 state: {
3083 ...maskedLocation.state,
3084 __tempKey: void 0,
3085 __tempLocation: {
3086 ...nextHistory,
3087 search: nextHistory.searchStr,
3088 state: {
3089 ...nextHistory.state,
3090 __tempKey: void 0,
3091 __tempLocation: void 0,
3092 __TSR_key: void 0,
3093 key: void 0
3094 // TODO: Remove in v2 - use __TSR_key instead
3095 }
3096 }
3097 }
3098 };
3099 if (nextHistory.unmaskOnReload ?? this.options.unmaskOnReload ?? false) {
3100 nextHistory.state.__tempKey = this.tempLocationKey;
3101 }
3102 }
3103 nextHistory.state.__hashScrollIntoViewOptions = hashScrollIntoView ?? this.options.defaultHashScrollIntoView ?? true;
3104 this.shouldViewTransition = viewTransition;
3105 this.history[next.replace ? "replace" : "push"](
3106 nextHistory.publicHref,
3107 nextHistory.state,
3108 { ignoreBlocker }
3109 );
3110 }
3111 this.resetNextScroll = next.resetScroll ?? true;
3112 if (!this.history.subscribers.size) {
3113 this.load();
3114 }
3115 return this.commitLocationPromise;
3116 };
3117 this.buildAndCommitLocation = ({
3118 replace,
3119 resetScroll,
3120 hashScrollIntoView,
3121 viewTransition,
3122 ignoreBlocker,
3123 href,
3124 ...rest
3125 } = {}) => {
3126 if (href) {
3127 const currentIndex = this.history.location.state.__TSR_index;
3128 const parsed = parseHref(href, {
3129 __TSR_index: replace ? currentIndex : currentIndex + 1
3130 });
3131 rest.to = parsed.pathname;
3132 rest.search = this.options.parseSearch(parsed.search);
3133 rest.hash = parsed.hash.slice(1);
3134 }
3135 const location = this.buildLocation({
3136 ...rest,
3137 _includeValidateSearch: true
3138 });
3139 return this.commitLocation({
3140 ...location,
3141 viewTransition,
3142 replace,
3143 resetScroll,
3144 hashScrollIntoView,
3145 ignoreBlocker
3146 });
3147 };
3148 this.navigate = ({ to, reloadDocument, href, ...rest }) => {
3149 if (!reloadDocument && href) {
3150 try {
3151 new URL(`${href}`);
3152 reloadDocument = true;
3153 } catch {
3154 }
3155 }
3156 if (reloadDocument) {
3157 if (!href) {
3158 const location = this.buildLocation({ to, ...rest });
3159 href = location.url;
3160 }
3161 if (rest.replace) {
3162 window.location.replace(href);
3163 } else {
3164 window.location.href = href;
3165 }
3166 return Promise.resolve();
3167 }
3168 return this.buildAndCommitLocation({
3169 ...rest,
3170 href,
3171 to,
3172 _isNavigate: true
3173 });
3174 };
3175 this.beforeLoad = () => {
3176 this.cancelMatches();
3177 this.updateLatestLocation();
3178 if (this.isServer) {
3179 const nextLocation = this.buildLocation({
3180 to: this.latestLocation.pathname,
3181 search: true,
3182 params: true,
3183 hash: true,
3184 state: true,
3185 _includeValidateSearch: true
3186 });
3187 const normalizeUrl = (url) => {
3188 try {
3189 return encodeURI(decodeURI(url));
3190 } catch {
3191 return url;
3192 }
3193 };
3194 if (trimPath(normalizeUrl(this.latestLocation.href)) !== trimPath(normalizeUrl(nextLocation.href))) {
3195 let href = nextLocation.url;
3196 if (this.origin && href.startsWith(this.origin)) {
3197 href = href.replace(this.origin, "") || "/";
3198 }
3199 throw redirect({ href });
3200 }
3201 }
3202 const pendingMatches = this.matchRoutes(this.latestLocation);
3203 this.__store.setState((s) => ({
3204 ...s,
3205 status: "pending",
3206 statusCode: 200,
3207 isLoading: true,
3208 location: this.latestLocation,
3209 pendingMatches,
3210 // If a cached moved to pendingMatches, remove it from cachedMatches
3211 cachedMatches: s.cachedMatches.filter(
3212 (d) => !pendingMatches.some((e) => e.id === d.id)
3213 )
3214 }));
3215 };
3216 this.load = async (opts) => {
3217 let redirect2;
3218 let notFound2;
3219 let loadPromise;
3220 loadPromise = new Promise((resolve) => {
3221 this.startTransition(async () => {
3222 try {
3223 this.beforeLoad();
3224 const next = this.latestLocation;
3225 const prevLocation = this.state.resolvedLocation;
3226 if (!this.state.redirect) {
3227 this.emit({
3228 type: "onBeforeNavigate",
3229 ...getLocationChangeInfo({
3230 resolvedLocation: prevLocation,
3231 location: next
3232 })
3233 });
3234 }
3235 this.emit({
3236 type: "onBeforeLoad",
3237 ...getLocationChangeInfo({
3238 resolvedLocation: prevLocation,
3239 location: next
3240 })
3241 });
3242 await loadMatches({
3243 router: this,
3244 sync: opts?.sync,
3245 matches: this.state.pendingMatches,
3246 location: next,
3247 updateMatch: this.updateMatch,
3248 // eslint-disable-next-line @typescript-eslint/require-await
3249 onReady: async () => {
3250 this.startViewTransition(async () => {
3251 let exitingMatches;
3252 let enteringMatches;
3253 let stayingMatches;
3254 batch(() => {
3255 this.__store.setState((s) => {
3256 const previousMatches = s.matches;
3257 const newMatches = s.pendingMatches || s.matches;
3258 exitingMatches = previousMatches.filter(
3259 (match) => !newMatches.some((d) => d.id === match.id)
3260 );
3261 enteringMatches = newMatches.filter(
3262 (match) => !previousMatches.some((d) => d.id === match.id)
3263 );
3264 stayingMatches = previousMatches.filter(
3265 (match) => newMatches.some((d) => d.id === match.id)
3266 );
3267 return {
3268 ...s,
3269 isLoading: false,
3270 loadedAt: Date.now(),
3271 matches: newMatches,
3272 pendingMatches: void 0,
3273 cachedMatches: [
3274 ...s.cachedMatches,
3275 ...exitingMatches.filter((d) => d.status !== "error")
3276 ]
3277 };
3278 });
3279 this.clearExpiredCache();
3280 });
3281 [
3282 [exitingMatches, "onLeave"],
3283 [enteringMatches, "onEnter"],
3284 [stayingMatches, "onStay"]
3285 ].forEach(([matches, hook]) => {
3286 matches.forEach((match) => {
3287 this.looseRoutesById[match.routeId].options[hook]?.(match);
3288 });
3289 });
3290 });
3291 }
3292 });
3293 } catch (err) {
3294 if (isRedirect(err)) {
3295 redirect2 = err;
3296 if (!this.isServer) {
3297 this.navigate({
3298 ...redirect2.options,
3299 replace: true,
3300 ignoreBlocker: true
3301 });
3302 }
3303 } else if (isNotFound(err)) {
3304 notFound2 = err;
3305 }
3306 this.__store.setState((s) => ({
3307 ...s,
3308 statusCode: redirect2 ? redirect2.status : notFound2 ? 404 : s.matches.some((d) => d.status === "error") ? 500 : 200,
3309 redirect: redirect2
3310 }));
3311 }
3312 if (this.latestLoadPromise === loadPromise) {
3313 this.commitLocationPromise?.resolve();
3314 this.latestLoadPromise = void 0;
3315 this.commitLocationPromise = void 0;
3316 }
3317 resolve();
3318 });
3319 });
3320 this.latestLoadPromise = loadPromise;
3321 await loadPromise;
3322 while (this.latestLoadPromise && loadPromise !== this.latestLoadPromise) {
3323 await this.latestLoadPromise;
3324 }
3325 let newStatusCode = void 0;
3326 if (this.hasNotFoundMatch()) {
3327 newStatusCode = 404;
3328 } else if (this.__store.state.matches.some((d) => d.status === "error")) {
3329 newStatusCode = 500;
3330 }
3331 if (newStatusCode !== void 0) {
3332 this.__store.setState((s) => ({
3333 ...s,
3334 statusCode: newStatusCode
3335 }));
3336 }
3337 };
3338 this.startViewTransition = (fn) => {
3339 const shouldViewTransition = this.shouldViewTransition ?? this.options.defaultViewTransition;
3340 delete this.shouldViewTransition;
3341 if (shouldViewTransition && typeof document !== "undefined" && "startViewTransition" in document && typeof document.startViewTransition === "function") {
3342 let startViewTransitionParams;
3343 if (typeof shouldViewTransition === "object" && this.isViewTransitionTypesSupported) {
3344 const next = this.latestLocation;
3345 const prevLocation = this.state.resolvedLocation;
3346 const resolvedViewTransitionTypes = typeof shouldViewTransition.types === "function" ? shouldViewTransition.types(
3347 getLocationChangeInfo({
3348 resolvedLocation: prevLocation,
3349 location: next
3350 })
3351 ) : shouldViewTransition.types;
3352 if (resolvedViewTransitionTypes === false) {
3353 fn();
3354 return;
3355 }
3356 startViewTransitionParams = {
3357 update: fn,
3358 types: resolvedViewTransitionTypes
3359 };
3360 } else {
3361 startViewTransitionParams = fn;
3362 }
3363 document.startViewTransition(startViewTransitionParams);
3364 } else {
3365 fn();
3366 }
3367 };
3368 this.updateMatch = (id, updater) => {
3369 const matchesKey = this.state.pendingMatches?.some((d) => d.id === id) ? "pendingMatches" : this.state.matches.some((d) => d.id === id) ? "matches" : this.state.cachedMatches.some((d) => d.id === id) ? "cachedMatches" : "";
3370 if (matchesKey) {
3371 this.__store.setState((s) => ({
3372 ...s,
3373 [matchesKey]: s[matchesKey]?.map((d) => d.id === id ? updater(d) : d)
3374 }));
3375 }
3376 };
3377 this.getMatch = (matchId) => {
3378 const findFn = (d) => d.id === matchId;
3379 return this.state.cachedMatches.find(findFn) ?? this.state.pendingMatches?.find(findFn) ?? this.state.matches.find(findFn);
3380 };
3381 this.invalidate = (opts) => {
3382 const invalidate = (d) => {
3383 if (opts?.filter?.(d) ?? true) {
3384 return {
3385 ...d,
3386 invalid: true,
3387 ...opts?.forcePending || d.status === "error" ? { status: "pending", error: void 0 } : void 0
3388 };
3389 }
3390 return d;
3391 };
3392 this.__store.setState((s) => ({
3393 ...s,
3394 matches: s.matches.map(invalidate),
3395 cachedMatches: s.cachedMatches.map(invalidate),
3396 pendingMatches: s.pendingMatches?.map(invalidate)
3397 }));
3398 this.shouldViewTransition = false;
3399 return this.load({ sync: opts?.sync });
3400 };
3401 this.resolveRedirect = (redirect2) => {
3402 if (!redirect2.options.href) {
3403 const location = this.buildLocation(redirect2.options);
3404 let href = location.url;
3405 if (this.origin && href.startsWith(this.origin)) {
3406 href = href.replace(this.origin, "") || "/";
3407 }
3408 redirect2.options.href = location.href;
3409 redirect2.headers.set("Location", href);
3410 }
3411 if (!redirect2.headers.get("Location")) {
3412 redirect2.headers.set("Location", redirect2.options.href);
3413 }
3414 return redirect2;
3415 };
3416 this.clearCache = (opts) => {
3417 const filter = opts?.filter;
3418 if (filter !== void 0) {
3419 this.__store.setState((s) => {
3420 return {
3421 ...s,
3422 cachedMatches: s.cachedMatches.filter(
3423 (m) => !filter(m)
3424 )
3425 };
3426 });
3427 } else {
3428 this.__store.setState((s) => {
3429 return {
3430 ...s,
3431 cachedMatches: []
3432 };
3433 });
3434 }
3435 };
3436 this.clearExpiredCache = () => {
3437 const filter = (d) => {
3438 const route = this.looseRoutesById[d.routeId];
3439 if (!route.options.loader) {
3440 return true;
3441 }
3442 const gcTime = (d.preload ? route.options.preloadGcTime ?? this.options.defaultPreloadGcTime : route.options.gcTime ?? this.options.defaultGcTime) ?? 5 * 60 * 1e3;
3443 const isError = d.status === "error";
3444 if (isError) return true;
3445 const gcEligible = Date.now() - d.updatedAt >= gcTime;
3446 return gcEligible;
3447 };
3448 this.clearCache({ filter });
3449 };
3450 this.loadRouteChunk = loadRouteChunk;
3451 this.preloadRoute = async (opts) => {
3452 const next = this.buildLocation(opts);
3453 let matches = this.matchRoutes(next, {
3454 throwOnError: true,
3455 preload: true,
3456 dest: opts
3457 });
3458 const activeMatchIds = new Set(
3459 [...this.state.matches, ...this.state.pendingMatches ?? []].map(
3460 (d) => d.id
3461 )
3462 );
3463 const loadedMatchIds = /* @__PURE__ */ new Set([
3464 ...activeMatchIds,
3465 ...this.state.cachedMatches.map((d) => d.id)
3466 ]);
3467 batch(() => {
3468 matches.forEach((match) => {
3469 if (!loadedMatchIds.has(match.id)) {
3470 this.__store.setState((s) => ({
3471 ...s,
3472 cachedMatches: [...s.cachedMatches, match]
3473 }));
3474 }
3475 });
3476 });
3477 try {
3478 matches = await loadMatches({
3479 router: this,
3480 matches,
3481 location: next,
3482 preload: true,
3483 updateMatch: (id, updater) => {
3484 if (activeMatchIds.has(id)) {
3485 matches = matches.map((d) => d.id === id ? updater(d) : d);
3486 } else {
3487 this.updateMatch(id, updater);
3488 }
3489 }
3490 });
3491 return matches;
3492 } catch (err) {
3493 if (isRedirect(err)) {
3494 if (err.options.reloadDocument) {
3495 return void 0;
3496 }
3497 return await this.preloadRoute({
3498 ...err.options,
3499 _fromLocation: next
3500 });
3501 }
3502 if (!isNotFound(err)) {
3503 console.error(err);
3504 }
3505 return void 0;
3506 }
3507 };
3508 this.matchRoute = (location, opts) => {
3509 const matchLocation = {
3510 ...location,
3511 to: location.to ? this.resolvePathWithBase(
3512 location.from || "",
3513 location.to
3514 ) : void 0,
3515 params: location.params || {},
3516 leaveParams: true
3517 };
3518 const next = this.buildLocation(matchLocation);
3519 if (opts?.pending && this.state.status !== "pending") {
3520 return false;
3521 }
3522 const pending = opts?.pending === void 0 ? !this.state.isLoading : opts.pending;
3523 const baseLocation = pending ? this.latestLocation : this.state.resolvedLocation || this.state.location;
3524 const match = matchPathname(
3525 baseLocation.pathname,
3526 {
3527 ...opts,
3528 to: next.pathname
3529 },
3530 this.parsePathnameCache
3531 );
3532 if (!match) {
3533 return false;
3534 }
3535 if (location.params) {
3536 if (!deepEqual(match, location.params, { partial: true })) {
3537 return false;
3538 }
3539 }
3540 if (match && (opts?.includeSearch ?? true)) {
3541 return deepEqual(baseLocation.search, next.search, { partial: true }) ? match : false;
3542 }
3543 return match;
3544 };
3545 this.hasNotFoundMatch = () => {
3546 return this.__store.state.matches.some(
3547 (d) => d.status === "notFound" || d.globalNotFound
3548 );
3549 };
3550 this.update({
3551 defaultPreloadDelay: 50,
3552 defaultPendingMs: 1e3,
3553 defaultPendingMinMs: 500,
3554 context: void 0,
3555 ...options,
3556 caseSensitive: options.caseSensitive ?? false,
3557 notFoundMode: options.notFoundMode ?? "fuzzy",
3558 stringifySearch: options.stringifySearch ?? defaultStringifySearch,
3559 parseSearch: options.parseSearch ?? defaultParseSearch
3560 });
3561 if (typeof document !== "undefined") {
3562 self.__TSR_ROUTER__ = this;
3563 }
3564 }
3565 isShell() {
3566 return !!this.options.isShell;
3567 }
3568 isPrerendering() {
3569 return !!this.options.isPrerendering;
3570 }
3571 get state() {
3572 return this.__store.state;
3573 }
3574 get looseRoutesById() {
3575 return this.routesById;
3576 }
3577 matchRoutesInternal(next, opts) {
3578 const { foundRoute, matchedRoutes, routeParams } = this.getMatchedRoutes(
3579 next.pathname,
3580 opts?.dest?.to
3581 );
3582 let isGlobalNotFound = false;
3583 if (
3584 // If we found a route, and it's not an index route and we have left over path
3585 foundRoute ? foundRoute.path !== "/" && routeParams["**"] : (
3586 // Or if we didn't find a route and we have left over path
3587 trimPathRight(next.pathname)
3588 )
3589 ) {
3590 if (this.options.notFoundRoute) {
3591 matchedRoutes.push(this.options.notFoundRoute);
3592 } else {
3593 isGlobalNotFound = true;
3594 }
3595 }
3596 const globalNotFoundRouteId = (() => {
3597 if (!isGlobalNotFound) {
3598 return void 0;
3599 }
3600 if (this.options.notFoundMode !== "root") {
3601 for (let i = matchedRoutes.length - 1; i >= 0; i--) {
3602 const route = matchedRoutes[i];
3603 if (route.children) {
3604 return route.id;
3605 }
3606 }
3607 }
3608 return rootRouteId;
3609 })();
3610 const matches = [];
3611 const getParentContext = (parentMatch) => {
3612 const parentMatchId = parentMatch?.id;
3613 const parentContext = !parentMatchId ? this.options.context ?? void 0 : parentMatch.context ?? this.options.context ?? void 0;
3614 return parentContext;
3615 };
3616 matchedRoutes.forEach((route, index) => {
3617 const parentMatch = matches[index - 1];
3618 const [preMatchSearch, strictMatchSearch, searchError] = (() => {
3619 const parentSearch = parentMatch?.search ?? next.search;
3620 const parentStrictSearch = parentMatch?._strictSearch ?? void 0;
3621 try {
3622 const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? void 0;
3623 return [
3624 {
3625 ...parentSearch,
3626 ...strictSearch
3627 },
3628 { ...parentStrictSearch, ...strictSearch },
3629 void 0
3630 ];
3631 } catch (err) {
3632 let searchParamError = err;
3633 if (!(err instanceof SearchParamError)) {
3634 searchParamError = new SearchParamError(err.message, {
3635 cause: err
3636 });
3637 }
3638 if (opts?.throwOnError) {
3639 throw searchParamError;
3640 }
3641 return [parentSearch, {}, searchParamError];
3642 }
3643 })();
3644 const loaderDeps = route.options.loaderDeps?.({
3645 search: preMatchSearch
3646 }) ?? "";
3647 const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : "";
3648 const { interpolatedPath, usedParams } = interpolatePath({
3649 path: route.fullPath,
3650 params: routeParams,
3651 decodeCharMap: this.pathParamsDecodeCharMap
3652 });
3653 const matchId = interpolatePath({
3654 path: route.id,
3655 params: routeParams,
3656 leaveWildcards: true,
3657 decodeCharMap: this.pathParamsDecodeCharMap,
3658 parseCache: this.parsePathnameCache
3659 }).interpolatedPath + loaderDepsHash;
3660 const existingMatch = this.getMatch(matchId);
3661 const previousMatch = this.state.matches.find(
3662 (d) => d.routeId === route.id
3663 );
3664 const strictParams = existingMatch?._strictParams ?? usedParams;
3665 let paramsError = void 0;
3666 if (!existingMatch) {
3667 const strictParseParams = route.options.params?.parse ?? route.options.parseParams;
3668 if (strictParseParams) {
3669 try {
3670 Object.assign(
3671 strictParams,
3672 strictParseParams(strictParams)
3673 );
3674 } catch (err) {
3675 paramsError = new PathParamError(err.message, {
3676 cause: err
3677 });
3678 if (opts?.throwOnError) {
3679 throw paramsError;
3680 }
3681 }
3682 }
3683 }
3684 Object.assign(routeParams, strictParams);
3685 const cause = previousMatch ? "stay" : "enter";
3686 let match;
3687 if (existingMatch) {
3688 match = {
3689 ...existingMatch,
3690 cause,
3691 params: previousMatch ? replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
3692 _strictParams: strictParams,
3693 search: previousMatch ? replaceEqualDeep(previousMatch.search, preMatchSearch) : replaceEqualDeep(existingMatch.search, preMatchSearch),
3694 _strictSearch: strictMatchSearch
3695 };
3696 } else {
3697 const status = route.options.loader || route.options.beforeLoad || route.lazyFn || routeNeedsPreload(route) ? "pending" : "success";
3698 match = {
3699 id: matchId,
3700 index,
3701 routeId: route.id,
3702 params: previousMatch ? replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
3703 _strictParams: strictParams,
3704 pathname: interpolatedPath,
3705 updatedAt: Date.now(),
3706 search: previousMatch ? replaceEqualDeep(previousMatch.search, preMatchSearch) : preMatchSearch,
3707 _strictSearch: strictMatchSearch,
3708 searchError: void 0,
3709 status,
3710 isFetching: false,
3711 error: void 0,
3712 paramsError,
3713 __routeContext: void 0,
3714 _nonReactive: {
3715 loadPromise: createControlledPromise()
3716 },
3717 __beforeLoadContext: void 0,
3718 context: {},
3719 abortController: new AbortController(),
3720 fetchCount: 0,
3721 cause,
3722 loaderDeps: previousMatch ? replaceEqualDeep(previousMatch.loaderDeps, loaderDeps) : loaderDeps,
3723 invalid: false,
3724 preload: false,
3725 links: void 0,
3726 scripts: void 0,
3727 headScripts: void 0,
3728 meta: void 0,
3729 staticData: route.options.staticData || {},
3730 fullPath: route.fullPath
3731 };
3732 }
3733 if (!opts?.preload) {
3734 match.globalNotFound = globalNotFoundRouteId === route.id;
3735 }
3736 match.searchError = searchError;
3737 const parentContext = getParentContext(parentMatch);
3738 match.context = {
3739 ...parentContext,
3740 ...match.__routeContext,
3741 ...match.__beforeLoadContext
3742 };
3743 matches.push(match);
3744 });
3745 matches.forEach((match, index) => {
3746 const route = this.looseRoutesById[match.routeId];
3747 const existingMatch = this.getMatch(match.id);
3748 if (!existingMatch && opts?._buildLocation !== true) {
3749 const parentMatch = matches[index - 1];
3750 const parentContext = getParentContext(parentMatch);
3751 if (route.options.context) {
3752 const contextFnContext = {
3753 deps: match.loaderDeps,
3754 params: match.params,
3755 context: parentContext ?? {},
3756 location: next,
3757 navigate: (opts2) => this.navigate({ ...opts2, _fromLocation: next }),
3758 buildLocation: this.buildLocation,
3759 cause: match.cause,
3760 abortController: match.abortController,
3761 preload: !!match.preload,
3762 matches
3763 };
3764 match.__routeContext = route.options.context(contextFnContext) ?? void 0;
3765 }
3766 match.context = {
3767 ...parentContext,
3768 ...match.__routeContext,
3769 ...match.__beforeLoadContext
3770 };
3771 }
3772 });
3773 return matches;
3774 }
3775 };
3776 var SearchParamError = class extends Error {
3777 };
3778 var PathParamError = class extends Error {
3779 };
3780 var normalize = (str) => str.endsWith("/") && str.length > 1 ? str.slice(0, -1) : str;
3781 function comparePaths(a, b) {
3782 return normalize(a) === normalize(b);
3783 }
3784 function getInitialRouterState(location) {
3785 return {
3786 loadedAt: 0,
3787 isLoading: false,
3788 isTransitioning: false,
3789 status: "idle",
3790 resolvedLocation: void 0,
3791 location,
3792 matches: [],
3793 pendingMatches: [],
3794 cachedMatches: [],
3795 statusCode: 200
3796 };
3797 }
3798 function validateSearch(validateSearch2, input) {
3799 if (validateSearch2 == null) return {};
3800 if ("~standard" in validateSearch2) {
3801 const result = validateSearch2["~standard"].validate(input);
3802 if (result instanceof Promise)
3803 throw new SearchParamError("Async validation not supported");
3804 if (result.issues)
3805 throw new SearchParamError(JSON.stringify(result.issues, void 0, 2), {
3806 cause: result
3807 });
3808 return result.value;
3809 }
3810 if ("parse" in validateSearch2) {
3811 return validateSearch2.parse(input);
3812 }
3813 if (typeof validateSearch2 === "function") {
3814 return validateSearch2(input);
3815 }
3816 return {};
3817 }
3818 function getMatchedRoutes({
3819 pathname,
3820 routePathname,
3821 caseSensitive,
3822 routesByPath,
3823 routesById,
3824 flatRoutes,
3825 parseCache
3826 }) {
3827 let routeParams = {};
3828 const trimmedPath = trimPathRight(pathname);
3829 const getMatchedParams = (route) => {
3830 const result = matchPathname(
3831 trimmedPath,
3832 {
3833 to: route.fullPath,
3834 caseSensitive: route.options?.caseSensitive ?? caseSensitive,
3835 // we need fuzzy matching for `notFoundMode: 'fuzzy'`
3836 fuzzy: true
3837 },
3838 parseCache
3839 );
3840 return result;
3841 };
3842 let foundRoute = routePathname !== void 0 ? routesByPath[routePathname] : void 0;
3843 if (foundRoute) {
3844 routeParams = getMatchedParams(foundRoute);
3845 } else {
3846 let fuzzyMatch = void 0;
3847 for (const route of flatRoutes) {
3848 const matchedParams = getMatchedParams(route);
3849 if (matchedParams) {
3850 if (route.path !== "/" && matchedParams["**"]) {
3851 if (!fuzzyMatch) {
3852 fuzzyMatch = { foundRoute: route, routeParams: matchedParams };
3853 }
3854 } else {
3855 foundRoute = route;
3856 routeParams = matchedParams;
3857 break;
3858 }
3859 }
3860 }
3861 if (!foundRoute && fuzzyMatch) {
3862 foundRoute = fuzzyMatch.foundRoute;
3863 routeParams = fuzzyMatch.routeParams;
3864 }
3865 }
3866 let routeCursor = foundRoute || routesById[rootRouteId];
3867 const matchedRoutes = [routeCursor];
3868 while (routeCursor.parentRoute) {
3869 routeCursor = routeCursor.parentRoute;
3870 matchedRoutes.push(routeCursor);
3871 }
3872 matchedRoutes.reverse();
3873 return { matchedRoutes, routeParams, foundRoute };
3874 }
3875 function applySearchMiddleware({
3876 search,
3877 dest,
3878 destRoutes,
3879 _includeValidateSearch
3880 }) {
3881 const allMiddlewares = destRoutes.reduce(
3882 (acc, route) => {
3883 const middlewares = [];
3884 if ("search" in route.options) {
3885 if (route.options.search?.middlewares) {
3886 middlewares.push(...route.options.search.middlewares);
3887 }
3888 } else if (route.options.preSearchFilters || route.options.postSearchFilters) {
3889 const legacyMiddleware = ({
3890 search: search2,
3891 next
3892 }) => {
3893 let nextSearch = search2;
3894 if ("preSearchFilters" in route.options && route.options.preSearchFilters) {
3895 nextSearch = route.options.preSearchFilters.reduce(
3896 (prev, next2) => next2(prev),
3897 search2
3898 );
3899 }
3900 const result = next(nextSearch);
3901 if ("postSearchFilters" in route.options && route.options.postSearchFilters) {
3902 return route.options.postSearchFilters.reduce(
3903 (prev, next2) => next2(prev),
3904 result
3905 );
3906 }
3907 return result;
3908 };
3909 middlewares.push(legacyMiddleware);
3910 }
3911 if (_includeValidateSearch && route.options.validateSearch) {
3912 const validate = ({ search: search2, next }) => {
3913 const result = next(search2);
3914 try {
3915 const validatedSearch = {
3916 ...result,
3917 ...validateSearch(route.options.validateSearch, result) ?? void 0
3918 };
3919 return validatedSearch;
3920 } catch {
3921 return result;
3922 }
3923 };
3924 middlewares.push(validate);
3925 }
3926 return acc.concat(middlewares);
3927 },
3928 []
3929 ) ?? [];
3930 const final = ({ search: search2 }) => {
3931 if (!dest.search) {
3932 return {};
3933 }
3934 if (dest.search === true) {
3935 return search2;
3936 }
3937 return functionalUpdate(dest.search, search2);
3938 };
3939 allMiddlewares.push(final);
3940 const applyNext = (index, currentSearch) => {
3941 if (index >= allMiddlewares.length) {
3942 return currentSearch;
3943 }
3944 const middleware = allMiddlewares[index];
3945 const next = (newSearch) => {
3946 return applyNext(index + 1, newSearch);
3947 };
3948 return middleware({ search: currentSearch, next });
3949 };
3950 return applyNext(0, search);
3951 }
3952
3953 // node_modules/@tanstack/router-core/dist/esm/link.js
3954 var preloadWarning = "Error preloading route! \u261D\uFE0F";
3955
3956 // node_modules/@tanstack/router-core/dist/esm/route.js
3957 var BaseRoute = class {
3958 constructor(options) {
3959 this.init = (opts) => {
3960 this.originalIndex = opts.originalIndex;
3961 const options2 = this.options;
3962 const isRoot = !options2?.path && !options2?.id;
3963 this.parentRoute = this.options.getParentRoute?.();
3964 if (isRoot) {
3965 this._path = rootRouteId;
3966 } else if (!this.parentRoute) {
3967 invariant(
3968 false,
3969 `Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`
3970 );
3971 }
3972 let path = isRoot ? rootRouteId : options2?.path;
3973 if (path && path !== "/") {
3974 path = trimPathLeft(path);
3975 }
3976 const customId = options2?.id || path;
3977 let id = isRoot ? rootRouteId : joinPaths([
3978 this.parentRoute.id === rootRouteId ? "" : this.parentRoute.id,
3979 customId
3980 ]);
3981 if (path === rootRouteId) {
3982 path = "/";
3983 }
3984 if (id !== rootRouteId) {
3985 id = joinPaths(["/", id]);
3986 }
3987 const fullPath = id === rootRouteId ? "/" : joinPaths([this.parentRoute.fullPath, path]);
3988 this._path = path;
3989 this._id = id;
3990 this._fullPath = fullPath;
3991 this._to = fullPath;
3992 };
3993 this.clone = (other) => {
3994 this._path = other._path;
3995 this._id = other._id;
3996 this._fullPath = other._fullPath;
3997 this._to = other._to;
3998 this.options.getParentRoute = other.options.getParentRoute;
3999 this.children = other.children;
4000 };
4001 this.addChildren = (children) => {
4002 return this._addFileChildren(children);
4003 };
4004 this._addFileChildren = (children) => {
4005 if (Array.isArray(children)) {
4006 this.children = children;
4007 }
4008 if (typeof children === "object" && children !== null) {
4009 this.children = Object.values(children);
4010 }
4011 return this;
4012 };
4013 this._addFileTypes = () => {
4014 return this;
4015 };
4016 this.updateLoader = (options2) => {
4017 Object.assign(this.options, options2);
4018 return this;
4019 };
4020 this.update = (options2) => {
4021 Object.assign(this.options, options2);
4022 return this;
4023 };
4024 this.lazy = (lazyFn2) => {
4025 this.lazyFn = lazyFn2;
4026 return this;
4027 };
4028 this.options = options || {};
4029 this.isRoot = !options?.getParentRoute;
4030 if (options?.id && options?.path) {
4031 throw new Error(`Route cannot have both an 'id' and a 'path' option.`);
4032 }
4033 }
4034 get to() {
4035 return this._to;
4036 }
4037 get id() {
4038 return this._id;
4039 }
4040 get path() {
4041 return this._path;
4042 }
4043 get fullPath() {
4044 return this._fullPath;
4045 }
4046 };
4047 var BaseRootRoute = class extends BaseRoute {
4048 constructor(options) {
4049 super(options);
4050 }
4051 };
4052
4053 // node_modules/@tanstack/react-router/dist/esm/CatchBoundary.js
4054 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
4055 var React = __toESM(require_react(), 1);
4056 function CatchBoundary(props) {
4057 const errorComponent = props.errorComponent ?? ErrorComponent;
4058 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
4059 CatchBoundaryImpl,
4060 {
4061 getResetKey: props.getResetKey,
4062 onCatch: props.onCatch,
4063 children: ({ error, reset }) => {
4064 if (error) {
4065 return React.createElement(errorComponent, {
4066 error,
4067 reset
4068 });
4069 }
4070 return props.children;
4071 }
4072 }
4073 );
4074 }
4075 var CatchBoundaryImpl = class extends React.Component {
4076 constructor() {
4077 super(...arguments);
4078 this.state = { error: null };
4079 }
4080 static getDerivedStateFromProps(props) {
4081 return { resetKey: props.getResetKey() };
4082 }
4083 static getDerivedStateFromError(error) {
4084 return { error };
4085 }
4086 reset() {
4087 this.setState({ error: null });
4088 }
4089 componentDidUpdate(prevProps, prevState) {
4090 if (prevState.error && prevState.resetKey !== this.state.resetKey) {
4091 this.reset();
4092 }
4093 }
4094 componentDidCatch(error, errorInfo) {
4095 if (this.props.onCatch) {
4096 this.props.onCatch(error, errorInfo);
4097 }
4098 }
4099 render() {
4100 return this.props.children({
4101 error: this.state.resetKey !== this.props.getResetKey() ? null : this.state.error,
4102 reset: () => {
4103 this.reset();
4104 }
4105 });
4106 }
4107 };
4108 function ErrorComponent({ error }) {
4109 const [show, setShow] = React.useState(true);
4110 return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { padding: ".5rem", maxWidth: "100%" }, children: [
4111 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: ".5rem" }, children: [
4112 /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { style: { fontSize: "1rem" }, children: "Something went wrong!" }),
4113 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
4114 "button",
4115 {
4116 style: {
4117 appearance: "none",
4118 fontSize: ".6em",
4119 border: "1px solid currentColor",
4120 padding: ".1rem .2rem",
4121 fontWeight: "bold",
4122 borderRadius: ".25rem"
4123 },
4124 onClick: () => setShow((d) => !d),
4125 children: show ? "Hide Error" : "Show Error"
4126 }
4127 )
4128 ] }),
4129 /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { height: ".25rem" } }),
4130 show ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
4131 "pre",
4132 {
4133 style: {
4134 fontSize: ".7em",
4135 border: "1px solid red",
4136 borderRadius: ".25rem",
4137 padding: ".3rem",
4138 color: "red",
4139 overflow: "auto"
4140 },
4141 children: error.message ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: error.message }) : null
4142 }
4143 ) }) : null
4144 ] });
4145 }
4146
4147 // node_modules/@tanstack/react-router/dist/esm/ClientOnly.js
4148 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
4149 var import_react = __toESM(require_react(), 1);
4150 function ClientOnly({ children, fallback = null }) {
4151 return useHydrated() ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react.default.Fragment, { children }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react.default.Fragment, { children: fallback });
4152 }
4153 function useHydrated() {
4154 return import_react.default.useSyncExternalStore(
4155 subscribe,
4156 () => true,
4157 () => false
4158 );
4159 }
4160 function subscribe() {
4161 return () => {
4162 };
4163 }
4164
4165 // node_modules/tiny-warning/dist/tiny-warning.esm.js
4166 var isProduction2 = false;
4167 function warning(condition, message) {
4168 if (!isProduction2) {
4169 if (condition) {
4170 return;
4171 }
4172 var text = "Warning: " + message;
4173 if (typeof console !== "undefined") {
4174 console.warn(text);
4175 }
4176 try {
4177 throw Error(text);
4178 } catch (x) {
4179 }
4180 }
4181 }
4182 var tiny_warning_esm_default = warning;
4183
4184 // node_modules/@tanstack/react-router/dist/esm/route.js
4185 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
4186 var import_react3 = __toESM(require_react(), 1);
4187
4188 // node_modules/@tanstack/react-router/dist/esm/useMatch.js
4189 var React5 = __toESM(require_react(), 1);
4190
4191 // node_modules/@tanstack/react-store/dist/esm/index.js
4192 var import_with_selector = __toESM(require_with_selector(), 1);
4193 function useStore(store, selector = (d) => d, options = {}) {
4194 const equal = options.equal ?? shallow;
4195 const slice = (0, import_with_selector.useSyncExternalStoreWithSelector)(
4196 store.subscribe,
4197 () => store.state,
4198 () => store.state,
4199 selector,
4200 equal
4201 );
4202 return slice;
4203 }
4204 function shallow(objA, objB) {
4205 if (Object.is(objA, objB)) {
4206 return true;
4207 }
4208 if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
4209 return false;
4210 }
4211 if (objA instanceof Map && objB instanceof Map) {
4212 if (objA.size !== objB.size) return false;
4213 for (const [k, v] of objA) {
4214 if (!objB.has(k) || !Object.is(v, objB.get(k))) return false;
4215 }
4216 return true;
4217 }
4218 if (objA instanceof Set && objB instanceof Set) {
4219 if (objA.size !== objB.size) return false;
4220 for (const v of objA) {
4221 if (!objB.has(v)) return false;
4222 }
4223 return true;
4224 }
4225 if (objA instanceof Date && objB instanceof Date) {
4226 if (objA.getTime() !== objB.getTime()) return false;
4227 return true;
4228 }
4229 const keysA = getOwnKeys(objA);
4230 if (keysA.length !== getOwnKeys(objB).length) {
4231 return false;
4232 }
4233 for (let i = 0; i < keysA.length; i++) {
4234 if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
4235 return false;
4236 }
4237 }
4238 return true;
4239 }
4240 function getOwnKeys(obj) {
4241 return Object.keys(obj).concat(
4242 Object.getOwnPropertySymbols(obj)
4243 );
4244 }
4245
4246 // node_modules/@tanstack/react-router/dist/esm/useRouterState.js
4247 var import_react2 = __toESM(require_react(), 1);
4248
4249 // node_modules/@tanstack/react-router/dist/esm/useRouter.js
4250 var React3 = __toESM(require_react(), 1);
4251
4252 // node_modules/@tanstack/react-router/dist/esm/routerContext.js
4253 var React2 = __toESM(require_react(), 1);
4254 var routerContext = React2.createContext(null);
4255 function getRouterContext() {
4256 if (typeof document === "undefined") {
4257 return routerContext;
4258 }
4259 if (window.__TSR_ROUTER_CONTEXT__) {
4260 return window.__TSR_ROUTER_CONTEXT__;
4261 }
4262 window.__TSR_ROUTER_CONTEXT__ = routerContext;
4263 return routerContext;
4264 }
4265
4266 // node_modules/@tanstack/react-router/dist/esm/useRouter.js
4267 function useRouter(opts) {
4268 const value = React3.useContext(getRouterContext());
4269 tiny_warning_esm_default(
4270 !((opts?.warn ?? true) && !value),
4271 "useRouter must be used inside a <RouterProvider> component!"
4272 );
4273 return value;
4274 }
4275
4276 // node_modules/@tanstack/react-router/dist/esm/useRouterState.js
4277 function useRouterState(opts) {
4278 const contextRouter = useRouter({
4279 warn: opts?.router === void 0
4280 });
4281 const router = opts?.router || contextRouter;
4282 const previousResult = (0, import_react2.useRef)(void 0);
4283 return useStore(router.__store, (state) => {
4284 if (opts?.select) {
4285 if (opts.structuralSharing ?? router.options.defaultStructuralSharing) {
4286 const newSlice = replaceEqualDeep(
4287 previousResult.current,
4288 opts.select(state)
4289 );
4290 previousResult.current = newSlice;
4291 return newSlice;
4292 }
4293 return opts.select(state);
4294 }
4295 return state;
4296 });
4297 }
4298
4299 // node_modules/@tanstack/react-router/dist/esm/matchContext.js
4300 var React4 = __toESM(require_react(), 1);
4301 var matchContext = React4.createContext(void 0);
4302 var dummyMatchContext = React4.createContext(
4303 void 0
4304 );
4305
4306 // node_modules/@tanstack/react-router/dist/esm/useMatch.js
4307 function useMatch(opts) {
4308 const nearestMatchId = React5.useContext(
4309 opts.from ? dummyMatchContext : matchContext
4310 );
4311 const matchSelection = useRouterState({
4312 select: (state) => {
4313 const match = state.matches.find(
4314 (d) => opts.from ? opts.from === d.routeId : d.id === nearestMatchId
4315 );
4316 invariant(
4317 !((opts.shouldThrow ?? true) && !match),
4318 `Could not find ${opts.from ? `an active match from "${opts.from}"` : "a nearest match!"}`
4319 );
4320 if (match === void 0) {
4321 return void 0;
4322 }
4323 return opts.select ? opts.select(match) : match;
4324 },
4325 structuralSharing: opts.structuralSharing
4326 });
4327 return matchSelection;
4328 }
4329
4330 // node_modules/@tanstack/react-router/dist/esm/useLoaderData.js
4331 function useLoaderData(opts) {
4332 return useMatch({
4333 from: opts.from,
4334 strict: opts.strict,
4335 structuralSharing: opts.structuralSharing,
4336 select: (s) => {
4337 return opts.select ? opts.select(s.loaderData) : s.loaderData;
4338 }
4339 });
4340 }
4341
4342 // node_modules/@tanstack/react-router/dist/esm/useLoaderDeps.js
4343 function useLoaderDeps(opts) {
4344 const { select, ...rest } = opts;
4345 return useMatch({
4346 ...rest,
4347 select: (s) => {
4348 return select ? select(s.loaderDeps) : s.loaderDeps;
4349 }
4350 });
4351 }
4352
4353 // node_modules/@tanstack/react-router/dist/esm/useParams.js
4354 function useParams(opts) {
4355 return useMatch({
4356 from: opts.from,
4357 shouldThrow: opts.shouldThrow,
4358 structuralSharing: opts.structuralSharing,
4359 strict: opts.strict,
4360 select: (match) => {
4361 const params = opts.strict === false ? match.params : match._strictParams;
4362 return opts.select ? opts.select(params) : params;
4363 }
4364 });
4365 }
4366
4367 // node_modules/@tanstack/react-router/dist/esm/useSearch.js
4368 function useSearch(opts) {
4369 return useMatch({
4370 from: opts.from,
4371 strict: opts.strict,
4372 shouldThrow: opts.shouldThrow,
4373 structuralSharing: opts.structuralSharing,
4374 select: (match) => {
4375 return opts.select ? opts.select(match.search) : match.search;
4376 }
4377 });
4378 }
4379
4380 // node_modules/@tanstack/react-router/dist/esm/useNavigate.js
4381 var React6 = __toESM(require_react(), 1);
4382 function useNavigate(_defaultOpts) {
4383 const router = useRouter();
4384 return React6.useCallback(
4385 (options) => {
4386 return router.navigate({
4387 ...options,
4388 from: options.from ?? _defaultOpts?.from
4389 });
4390 },
4391 [_defaultOpts?.from, router]
4392 );
4393 }
4394
4395 // node_modules/@tanstack/react-router/dist/esm/link.js
4396 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
4397 var React8 = __toESM(require_react(), 1);
4398 var import_react_dom = __toESM(require_react_dom(), 1);
4399
4400 // node_modules/@tanstack/react-router/dist/esm/utils.js
4401 var React7 = __toESM(require_react(), 1);
4402 var useLayoutEffect2 = typeof window !== "undefined" ? React7.useLayoutEffect : React7.useEffect;
4403 function usePrevious(value) {
4404 const ref = React7.useRef({
4405 value,
4406 prev: null
4407 });
4408 const current = ref.current.value;
4409 if (value !== current) {
4410 ref.current = {
4411 value,
4412 prev: current
4413 };
4414 }
4415 return ref.current.prev;
4416 }
4417 function useIntersectionObserver(ref, callback, intersectionObserverOptions2 = {}, options = {}) {
4418 React7.useEffect(() => {
4419 if (!ref.current || options.disabled || typeof IntersectionObserver !== "function") {
4420 return;
4421 }
4422 const observer = new IntersectionObserver(([entry]) => {
4423 callback(entry);
4424 }, intersectionObserverOptions2);
4425 observer.observe(ref.current);
4426 return () => {
4427 observer.disconnect();
4428 };
4429 }, [callback, intersectionObserverOptions2, options.disabled, ref]);
4430 }
4431 function useForwardedRef(ref) {
4432 const innerRef = React7.useRef(null);
4433 React7.useImperativeHandle(ref, () => innerRef.current, []);
4434 return innerRef;
4435 }
4436
4437 // node_modules/@tanstack/react-router/dist/esm/link.js
4438 function useLinkProps(options, forwardedRef) {
4439 const router = useRouter();
4440 const [isTransitioning, setIsTransitioning] = React8.useState(false);
4441 const hasRenderFetched = React8.useRef(false);
4442 const innerRef = useForwardedRef(forwardedRef);
4443 const {
4444 // custom props
4445 activeProps,
4446 inactiveProps,
4447 activeOptions,
4448 to,
4449 preload: userPreload,
4450 preloadDelay: userPreloadDelay,
4451 hashScrollIntoView,
4452 replace,
4453 startTransition: startTransition2,
4454 resetScroll,
4455 viewTransition,
4456 // element props
4457 children,
4458 target,
4459 disabled,
4460 style,
4461 className,
4462 onClick,
4463 onFocus,
4464 onMouseEnter,
4465 onMouseLeave,
4466 onTouchStart,
4467 ignoreBlocker,
4468 // prevent these from being returned
4469 params: _params,
4470 search: _search,
4471 hash: _hash,
4472 state: _state,
4473 mask: _mask,
4474 reloadDocument: _reloadDocument,
4475 unsafeRelative: _unsafeRelative,
4476 from: _from,
4477 _fromLocation,
4478 ...propsSafeToSpread
4479 } = options;
4480 const currentSearch = useRouterState({
4481 select: (s) => s.location.search,
4482 structuralSharing: true
4483 });
4484 const from = options.from;
4485 const _options = React8.useMemo(
4486 () => {
4487 return { ...options, from };
4488 },
4489 // eslint-disable-next-line react-hooks/exhaustive-deps
4490 [
4491 router,
4492 currentSearch,
4493 from,
4494 options._fromLocation,
4495 options.hash,
4496 options.to,
4497 options.search,
4498 options.params,
4499 options.state,
4500 options.mask,
4501 options.unsafeRelative
4502 ]
4503 );
4504 const next = React8.useMemo(
4505 () => router.buildLocation({ ..._options }),
4506 [router, _options]
4507 );
4508 const hrefOption = React8.useMemo(() => {
4509 if (disabled) {
4510 return void 0;
4511 }
4512 let href = next.maskedLocation ? next.maskedLocation.url : next.url;
4513 let external = false;
4514 if (router.origin) {
4515 if (href.startsWith(router.origin)) {
4516 href = router.history.createHref(href.replace(router.origin, "")) || "/";
4517 } else {
4518 external = true;
4519 }
4520 }
4521 return { href, external };
4522 }, [disabled, next.maskedLocation, next.url, router.origin, router.history]);
4523 const externalLink = React8.useMemo(() => {
4524 if (hrefOption?.external) {
4525 return hrefOption.href;
4526 }
4527 try {
4528 new URL(to);
4529 return to;
4530 } catch {
4531 }
4532 return void 0;
4533 }, [to, hrefOption]);
4534 const preload = options.reloadDocument || externalLink ? false : userPreload ?? router.options.defaultPreload;
4535 const preloadDelay = userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0;
4536 const isActive = useRouterState({
4537 select: (s) => {
4538 if (externalLink) return false;
4539 if (activeOptions?.exact) {
4540 const testExact = exactPathTest(
4541 s.location.pathname,
4542 next.pathname,
4543 router.basepath
4544 );
4545 if (!testExact) {
4546 return false;
4547 }
4548 } else {
4549 const currentPathSplit = removeTrailingSlash(
4550 s.location.pathname,
4551 router.basepath
4552 );
4553 const nextPathSplit = removeTrailingSlash(
4554 next.pathname,
4555 router.basepath
4556 );
4557 const pathIsFuzzyEqual = currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/");
4558 if (!pathIsFuzzyEqual) {
4559 return false;
4560 }
4561 }
4562 if (activeOptions?.includeSearch ?? true) {
4563 const searchTest = deepEqual(s.location.search, next.search, {
4564 partial: !activeOptions?.exact,
4565 ignoreUndefined: !activeOptions?.explicitUndefined
4566 });
4567 if (!searchTest) {
4568 return false;
4569 }
4570 }
4571 if (activeOptions?.includeHash) {
4572 return s.location.hash === next.hash;
4573 }
4574 return true;
4575 }
4576 });
4577 const doPreload = React8.useCallback(() => {
4578 router.preloadRoute({ ..._options }).catch((err) => {
4579 console.warn(err);
4580 console.warn(preloadWarning);
4581 });
4582 }, [router, _options]);
4583 const preloadViewportIoCallback = React8.useCallback(
4584 (entry) => {
4585 if (entry?.isIntersecting) {
4586 doPreload();
4587 }
4588 },
4589 [doPreload]
4590 );
4591 useIntersectionObserver(
4592 innerRef,
4593 preloadViewportIoCallback,
4594 intersectionObserverOptions,
4595 { disabled: !!disabled || !(preload === "viewport") }
4596 );
4597 React8.useEffect(() => {
4598 if (hasRenderFetched.current) {
4599 return;
4600 }
4601 if (!disabled && preload === "render") {
4602 doPreload();
4603 hasRenderFetched.current = true;
4604 }
4605 }, [disabled, doPreload, preload]);
4606 const handleClick = (e) => {
4607 const elementTarget = e.currentTarget.getAttribute("target");
4608 const effectiveTarget = target !== void 0 ? target : elementTarget;
4609 if (!disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!effectiveTarget || effectiveTarget === "_self") && e.button === 0) {
4610 e.preventDefault();
4611 (0, import_react_dom.flushSync)(() => {
4612 setIsTransitioning(true);
4613 });
4614 const unsub = router.subscribe("onResolved", () => {
4615 unsub();
4616 setIsTransitioning(false);
4617 });
4618 router.navigate({
4619 ..._options,
4620 replace,
4621 resetScroll,
4622 hashScrollIntoView,
4623 startTransition: startTransition2,
4624 viewTransition,
4625 ignoreBlocker
4626 });
4627 }
4628 };
4629 if (externalLink) {
4630 return {
4631 ...propsSafeToSpread,
4632 ref: innerRef,
4633 href: externalLink,
4634 ...children && { children },
4635 ...target && { target },
4636 ...disabled && { disabled },
4637 ...style && { style },
4638 ...className && { className },
4639 ...onClick && { onClick },
4640 ...onFocus && { onFocus },
4641 ...onMouseEnter && { onMouseEnter },
4642 ...onMouseLeave && { onMouseLeave },
4643 ...onTouchStart && { onTouchStart }
4644 };
4645 }
4646 const handleFocus = (_) => {
4647 if (disabled) return;
4648 if (preload) {
4649 doPreload();
4650 }
4651 };
4652 const handleTouchStart = handleFocus;
4653 const handleEnter = (e) => {
4654 if (disabled || !preload) return;
4655 if (!preloadDelay) {
4656 doPreload();
4657 } else {
4658 const eventTarget = e.target;
4659 if (timeoutMap.has(eventTarget)) {
4660 return;
4661 }
4662 const id = setTimeout(() => {
4663 timeoutMap.delete(eventTarget);
4664 doPreload();
4665 }, preloadDelay);
4666 timeoutMap.set(eventTarget, id);
4667 }
4668 };
4669 const handleLeave = (e) => {
4670 if (disabled || !preload || !preloadDelay) return;
4671 const eventTarget = e.target;
4672 const id = timeoutMap.get(eventTarget);
4673 if (id) {
4674 clearTimeout(id);
4675 timeoutMap.delete(eventTarget);
4676 }
4677 };
4678 const resolvedActiveProps = isActive ? functionalUpdate(activeProps, {}) ?? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT;
4679 const resolvedInactiveProps = isActive ? STATIC_EMPTY_OBJECT : functionalUpdate(inactiveProps, {}) ?? STATIC_EMPTY_OBJECT;
4680 const resolvedClassName = [
4681 className,
4682 resolvedActiveProps.className,
4683 resolvedInactiveProps.className
4684 ].filter(Boolean).join(" ");
4685 const resolvedStyle = (style || resolvedActiveProps.style || resolvedInactiveProps.style) && {
4686 ...style,
4687 ...resolvedActiveProps.style,
4688 ...resolvedInactiveProps.style
4689 };
4690 return {
4691 ...propsSafeToSpread,
4692 ...resolvedActiveProps,
4693 ...resolvedInactiveProps,
4694 href: hrefOption?.href,
4695 ref: innerRef,
4696 onClick: composeHandlers([onClick, handleClick]),
4697 onFocus: composeHandlers([onFocus, handleFocus]),
4698 onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),
4699 onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
4700 onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),
4701 disabled: !!disabled,
4702 target,
4703 ...resolvedStyle && { style: resolvedStyle },
4704 ...resolvedClassName && { className: resolvedClassName },
4705 ...disabled && STATIC_DISABLED_PROPS,
4706 ...isActive && STATIC_ACTIVE_PROPS,
4707 ...isTransitioning && STATIC_TRANSITIONING_PROPS
4708 };
4709 }
4710 var STATIC_EMPTY_OBJECT = {};
4711 var STATIC_ACTIVE_OBJECT = { className: "active" };
4712 var STATIC_DISABLED_PROPS = { role: "link", "aria-disabled": true };
4713 var STATIC_ACTIVE_PROPS = { "data-status": "active", "aria-current": "page" };
4714 var STATIC_TRANSITIONING_PROPS = { "data-transitioning": "transitioning" };
4715 var timeoutMap = /* @__PURE__ */ new WeakMap();
4716 var intersectionObserverOptions = {
4717 rootMargin: "100px"
4718 };
4719 var composeHandlers = (handlers) => (e) => {
4720 for (const handler of handlers) {
4721 if (!handler) continue;
4722 if (e.defaultPrevented) return;
4723 handler(e);
4724 }
4725 };
4726 function createLink(Comp) {
4727 return React8.forwardRef(function CreatedLink(props, ref) {
4728 return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Link, { ...props, _asChild: Comp, ref });
4729 });
4730 }
4731 var Link = React8.forwardRef(
4732 (props, ref) => {
4733 const { _asChild, ...rest } = props;
4734 const {
4735 type: _type,
4736 ref: innerRef,
4737 ...linkProps
4738 } = useLinkProps(rest, ref);
4739 const children = typeof rest.children === "function" ? rest.children({
4740 isActive: linkProps["data-status"] === "active"
4741 }) : rest.children;
4742 if (_asChild === void 0) {
4743 delete linkProps.disabled;
4744 }
4745 return React8.createElement(
4746 _asChild ? _asChild : "a",
4747 {
4748 ...linkProps,
4749 ref: innerRef
4750 },
4751 children
4752 );
4753 }
4754 );
4755 function isCtrlEvent(e) {
4756 return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
4757 }
4758
4759 // node_modules/@tanstack/react-router/dist/esm/route.js
4760 var Route = class extends BaseRoute {
4761 /**
4762 * @deprecated Use the `createRoute` function instead.
4763 */
4764 constructor(options) {
4765 super(options);
4766 this.useMatch = (opts) => {
4767 return useMatch({
4768 select: opts?.select,
4769 from: this.id,
4770 structuralSharing: opts?.structuralSharing
4771 });
4772 };
4773 this.useRouteContext = (opts) => {
4774 return useMatch({
4775 ...opts,
4776 from: this.id,
4777 select: (d) => opts?.select ? opts.select(d.context) : d.context
4778 });
4779 };
4780 this.useSearch = (opts) => {
4781 return useSearch({
4782 select: opts?.select,
4783 structuralSharing: opts?.structuralSharing,
4784 from: this.id
4785 });
4786 };
4787 this.useParams = (opts) => {
4788 return useParams({
4789 select: opts?.select,
4790 structuralSharing: opts?.structuralSharing,
4791 from: this.id
4792 });
4793 };
4794 this.useLoaderDeps = (opts) => {
4795 return useLoaderDeps({ ...opts, from: this.id });
4796 };
4797 this.useLoaderData = (opts) => {
4798 return useLoaderData({ ...opts, from: this.id });
4799 };
4800 this.useNavigate = () => {
4801 return useNavigate({ from: this.fullPath });
4802 };
4803 this.Link = import_react3.default.forwardRef(
4804 (props, ref) => {
4805 return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Link, { ref, from: this.fullPath, ...props });
4806 }
4807 );
4808 this.$$typeof = /* @__PURE__ */ Symbol.for("react.memo");
4809 }
4810 };
4811 function createRoute(options) {
4812 return new Route(
4813 // TODO: Help us TypeChris, you're our only hope!
4814 options
4815 );
4816 }
4817 var RootRoute = class extends BaseRootRoute {
4818 /**
4819 * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
4820 */
4821 constructor(options) {
4822 super(options);
4823 this.useMatch = (opts) => {
4824 return useMatch({
4825 select: opts?.select,
4826 from: this.id,
4827 structuralSharing: opts?.structuralSharing
4828 });
4829 };
4830 this.useRouteContext = (opts) => {
4831 return useMatch({
4832 ...opts,
4833 from: this.id,
4834 select: (d) => opts?.select ? opts.select(d.context) : d.context
4835 });
4836 };
4837 this.useSearch = (opts) => {
4838 return useSearch({
4839 select: opts?.select,
4840 structuralSharing: opts?.structuralSharing,
4841 from: this.id
4842 });
4843 };
4844 this.useParams = (opts) => {
4845 return useParams({
4846 select: opts?.select,
4847 structuralSharing: opts?.structuralSharing,
4848 from: this.id
4849 });
4850 };
4851 this.useLoaderDeps = (opts) => {
4852 return useLoaderDeps({ ...opts, from: this.id });
4853 };
4854 this.useLoaderData = (opts) => {
4855 return useLoaderData({ ...opts, from: this.id });
4856 };
4857 this.useNavigate = () => {
4858 return useNavigate({ from: this.fullPath });
4859 };
4860 this.Link = import_react3.default.forwardRef(
4861 (props, ref) => {
4862 return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Link, { ref, from: this.fullPath, ...props });
4863 }
4864 );
4865 this.$$typeof = /* @__PURE__ */ Symbol.for("react.memo");
4866 }
4867 };
4868 function createRootRoute(options) {
4869 return new RootRoute(options);
4870 }
4871
4872 // node_modules/@tanstack/react-router/dist/esm/fileRoute.js
4873 function createFileRoute(path) {
4874 if (typeof path === "object") {
4875 return new FileRoute(path, {
4876 silent: true
4877 }).createRoute(path);
4878 }
4879 return new FileRoute(path, {
4880 silent: true
4881 }).createRoute;
4882 }
4883 var FileRoute = class {
4884 constructor(path, _opts) {
4885 this.path = path;
4886 this.createRoute = (options) => {
4887 tiny_warning_esm_default(
4888 this.silent,
4889 "FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead."
4890 );
4891 const route = createRoute(options);
4892 route.isRoot = false;
4893 return route;
4894 };
4895 this.silent = _opts?.silent;
4896 }
4897 };
4898 var LazyRoute = class {
4899 constructor(opts) {
4900 this.useMatch = (opts2) => {
4901 return useMatch({
4902 select: opts2?.select,
4903 from: this.options.id,
4904 structuralSharing: opts2?.structuralSharing
4905 });
4906 };
4907 this.useRouteContext = (opts2) => {
4908 return useMatch({
4909 from: this.options.id,
4910 select: (d) => opts2?.select ? opts2.select(d.context) : d.context
4911 });
4912 };
4913 this.useSearch = (opts2) => {
4914 return useSearch({
4915 select: opts2?.select,
4916 structuralSharing: opts2?.structuralSharing,
4917 from: this.options.id
4918 });
4919 };
4920 this.useParams = (opts2) => {
4921 return useParams({
4922 select: opts2?.select,
4923 structuralSharing: opts2?.structuralSharing,
4924 from: this.options.id
4925 });
4926 };
4927 this.useLoaderDeps = (opts2) => {
4928 return useLoaderDeps({ ...opts2, from: this.options.id });
4929 };
4930 this.useLoaderData = (opts2) => {
4931 return useLoaderData({ ...opts2, from: this.options.id });
4932 };
4933 this.useNavigate = () => {
4934 const router = useRouter();
4935 return useNavigate({ from: router.routesById[this.options.id].fullPath });
4936 };
4937 this.options = opts;
4938 this.$$typeof = /* @__PURE__ */ Symbol.for("react.memo");
4939 }
4940 };
4941 function createLazyRoute(id) {
4942 return (opts) => {
4943 return new LazyRoute({
4944 id,
4945 ...opts
4946 });
4947 };
4948 }
4949 function createLazyFileRoute(id) {
4950 if (typeof id === "object") {
4951 return new LazyRoute(id);
4952 }
4953 return (opts) => new LazyRoute({ id, ...opts });
4954 }
4955
4956 // node_modules/@tanstack/react-router/dist/esm/Matches.js
4957 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
4958 var React11 = __toESM(require_react(), 1);
4959
4960 // node_modules/@tanstack/react-router/dist/esm/Transitioner.js
4961 var React9 = __toESM(require_react(), 1);
4962 function Transitioner() {
4963 const router = useRouter();
4964 const mountLoadForRouter = React9.useRef({ router, mounted: false });
4965 const [isTransitioning, setIsTransitioning] = React9.useState(false);
4966 const { hasPendingMatches, isLoading } = useRouterState({
4967 select: (s) => ({
4968 isLoading: s.isLoading,
4969 hasPendingMatches: s.matches.some((d) => d.status === "pending")
4970 }),
4971 structuralSharing: true
4972 });
4973 const previousIsLoading = usePrevious(isLoading);
4974 const isAnyPending = isLoading || isTransitioning || hasPendingMatches;
4975 const previousIsAnyPending = usePrevious(isAnyPending);
4976 const isPagePending = isLoading || hasPendingMatches;
4977 const previousIsPagePending = usePrevious(isPagePending);
4978 router.startTransition = (fn) => {
4979 setIsTransitioning(true);
4980 React9.startTransition(() => {
4981 fn();
4982 setIsTransitioning(false);
4983 });
4984 };
4985 React9.useEffect(() => {
4986 const unsub = router.history.subscribe(router.load);
4987 const nextLocation = router.buildLocation({
4988 to: router.latestLocation.pathname,
4989 search: true,
4990 params: true,
4991 hash: true,
4992 state: true,
4993 _includeValidateSearch: true
4994 });
4995 if (trimPathRight(router.latestLocation.href) !== trimPathRight(nextLocation.href)) {
4996 router.commitLocation({ ...nextLocation, replace: true });
4997 }
4998 return () => {
4999 unsub();
5000 };
5001 }, [router, router.history]);
5002 useLayoutEffect2(() => {
5003 if (
5004 // if we are hydrating from SSR, loading is triggered in ssr-client
5005 typeof window !== "undefined" && router.ssr || mountLoadForRouter.current.router === router && mountLoadForRouter.current.mounted
5006 ) {
5007 return;
5008 }
5009 mountLoadForRouter.current = { router, mounted: true };
5010 const tryLoad = async () => {
5011 try {
5012 await router.load();
5013 } catch (err) {
5014 console.error(err);
5015 }
5016 };
5017 tryLoad();
5018 }, [router]);
5019 useLayoutEffect2(() => {
5020 if (previousIsLoading && !isLoading) {
5021 router.emit({
5022 type: "onLoad",
5023 // When the new URL has committed, when the new matches have been loaded into state.matches
5024 ...getLocationChangeInfo(router.state)
5025 });
5026 }
5027 }, [previousIsLoading, router, isLoading]);
5028 useLayoutEffect2(() => {
5029 if (previousIsPagePending && !isPagePending) {
5030 router.emit({
5031 type: "onBeforeRouteMount",
5032 ...getLocationChangeInfo(router.state)
5033 });
5034 }
5035 }, [isPagePending, previousIsPagePending, router]);
5036 useLayoutEffect2(() => {
5037 if (previousIsAnyPending && !isAnyPending) {
5038 router.emit({
5039 type: "onResolved",
5040 ...getLocationChangeInfo(router.state)
5041 });
5042 router.__store.setState((s) => ({
5043 ...s,
5044 status: "idle",
5045 resolvedLocation: s.location
5046 }));
5047 handleHashScroll(router);
5048 }
5049 }, [isAnyPending, previousIsAnyPending, router]);
5050 return null;
5051 }
5052
5053 // node_modules/@tanstack/react-router/dist/esm/Match.js
5054 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
5055 var React10 = __toESM(require_react(), 1);
5056
5057 // node_modules/@tanstack/react-router/dist/esm/not-found.js
5058 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
5059 function CatchNotFound(props) {
5060 const resetKey = useRouterState({
5061 select: (s) => `not-found-${s.location.pathname}-${s.status}`
5062 });
5063 return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
5064 CatchBoundary,
5065 {
5066 getResetKey: () => resetKey,
5067 onCatch: (error, errorInfo) => {
5068 if (isNotFound(error)) {
5069 props.onCatch?.(error, errorInfo);
5070 } else {
5071 throw error;
5072 }
5073 },
5074 errorComponent: ({ error }) => {
5075 if (isNotFound(error)) {
5076 return props.fallback?.(error);
5077 } else {
5078 throw error;
5079 }
5080 },
5081 children: props.children
5082 }
5083 );
5084 }
5085 function DefaultGlobalNotFound() {
5086 return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: "Not Found" });
5087 }
5088
5089 // node_modules/@tanstack/react-router/dist/esm/SafeFragment.js
5090 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
5091 function SafeFragment(props) {
5092 return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: props.children });
5093 }
5094
5095 // node_modules/@tanstack/react-router/dist/esm/renderRouteNotFound.js
5096 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
5097 function renderRouteNotFound(router, route, data) {
5098 if (!route.options.notFoundComponent) {
5099 if (router.options.defaultNotFoundComponent) {
5100 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(router.options.defaultNotFoundComponent, { data });
5101 }
5102 if (true) {
5103 tiny_warning_esm_default(
5104 route.options.notFoundComponent,
5105 `A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<div>Not Found<div>)`
5106 );
5107 }
5108 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DefaultGlobalNotFound, {});
5109 }
5110 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(route.options.notFoundComponent, { data });
5111 }
5112
5113 // node_modules/@tanstack/react-router/dist/esm/scroll-restoration.js
5114 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
5115
5116 // node_modules/@tanstack/react-router/dist/esm/ScriptOnce.js
5117 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
5118 function ScriptOnce({ children }) {
5119 const router = useRouter();
5120 if (!router.isServer) {
5121 return null;
5122 }
5123 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
5124 "script",
5125 {
5126 nonce: router.options.ssr?.nonce,
5127 className: "$tsr",
5128 dangerouslySetInnerHTML: {
5129 __html: [children].filter(Boolean).join("\n") + ";$_TSR.c()"
5130 }
5131 }
5132 );
5133 }
5134
5135 // node_modules/@tanstack/react-router/dist/esm/scroll-restoration.js
5136 function ScrollRestoration() {
5137 const router = useRouter();
5138 if (!router.isScrollRestoring || !router.isServer) {
5139 return null;
5140 }
5141 if (typeof router.options.scrollRestoration === "function") {
5142 const shouldRestore = router.options.scrollRestoration({
5143 location: router.latestLocation
5144 });
5145 if (!shouldRestore) {
5146 return null;
5147 }
5148 }
5149 const getKey = router.options.getScrollRestorationKey || defaultGetScrollRestorationKey;
5150 const userKey = getKey(router.latestLocation);
5151 const resolvedKey = userKey !== defaultGetScrollRestorationKey(router.latestLocation) ? userKey : void 0;
5152 const restoreScrollOptions = {
5153 storageKey,
5154 shouldScrollRestoration: true
5155 };
5156 if (resolvedKey) {
5157 restoreScrollOptions.key = resolvedKey;
5158 }
5159 return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
5160 ScriptOnce,
5161 {
5162 children: `(${restoreScroll.toString()})(${JSON.stringify(restoreScrollOptions)})`
5163 }
5164 );
5165 }
5166
5167 // node_modules/@tanstack/react-router/dist/esm/Match.js
5168 var Match = React10.memo(function MatchImpl({
5169 matchId
5170 }) {
5171 const router = useRouter();
5172 const matchState = useRouterState({
5173 select: (s) => {
5174 const match = s.matches.find((d) => d.id === matchId);
5175 invariant(
5176 match,
5177 `Could not find match for matchId "${matchId}". Please file an issue!`
5178 );
5179 return {
5180 routeId: match.routeId,
5181 ssr: match.ssr,
5182 _displayPending: match._displayPending
5183 };
5184 },
5185 structuralSharing: true
5186 });
5187 const route = router.routesById[matchState.routeId];
5188 const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent;
5189 const pendingElement = PendingComponent ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PendingComponent, {}) : null;
5190 const routeErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent;
5191 const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch;
5192 const routeNotFoundComponent = route.isRoot ? (
5193 // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component
5194 route.options.notFoundComponent ?? router.options.notFoundRoute?.options.component
5195 ) : route.options.notFoundComponent;
5196 const resolvedNoSsr = matchState.ssr === false || matchState.ssr === "data-only";
5197 const ResolvedSuspenseBoundary = (
5198 // If we're on the root route, allow forcefully wrapping in suspense
5199 (!route.isRoot || route.options.wrapInSuspense || resolvedNoSsr) && (route.options.wrapInSuspense ?? PendingComponent ?? (route.options.errorComponent?.preload || resolvedNoSsr)) ? React10.Suspense : SafeFragment
5200 );
5201 const ResolvedCatchBoundary = routeErrorComponent ? CatchBoundary : SafeFragment;
5202 const ResolvedNotFoundBoundary = routeNotFoundComponent ? CatchNotFound : SafeFragment;
5203 const resetKey = useRouterState({
5204 select: (s) => s.loadedAt
5205 });
5206 const parentRouteId = useRouterState({
5207 select: (s) => {
5208 const index = s.matches.findIndex((d) => d.id === matchId);
5209 return s.matches[index - 1]?.routeId;
5210 }
5211 });
5212 const ShellComponent = route.isRoot ? route.options.shellComponent ?? SafeFragment : SafeFragment;
5213 return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(ShellComponent, { children: [
5214 /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(matchContext.Provider, { value: matchId, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ResolvedSuspenseBoundary, { fallback: pendingElement, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
5215 ResolvedCatchBoundary,
5216 {
5217 getResetKey: () => resetKey,
5218 errorComponent: routeErrorComponent || ErrorComponent,
5219 onCatch: (error, errorInfo) => {
5220 if (isNotFound(error)) throw error;
5221 tiny_warning_esm_default(false, `Error in route match: ${matchId}`);
5222 routeOnCatch?.(error, errorInfo);
5223 },
5224 children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
5225 ResolvedNotFoundBoundary,
5226 {
5227 fallback: (error) => {
5228 if (!routeNotFoundComponent || error.routeId && error.routeId !== matchState.routeId || !error.routeId && !route.isRoot)
5229 throw error;
5230 return React10.createElement(routeNotFoundComponent, error);
5231 },
5232 children: resolvedNoSsr || matchState._displayPending ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ClientOnly, { fallback: pendingElement, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MatchInner, { matchId }) }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(MatchInner, { matchId })
5233 }
5234 )
5235 }
5236 ) }) }),
5237 parentRouteId === rootRouteId && router.options.scrollRestoration ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
5238 /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(OnRendered, {}),
5239 /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ScrollRestoration, {})
5240 ] }) : null
5241 ] });
5242 });
5243 function OnRendered() {
5244 const router = useRouter();
5245 const prevLocationRef = React10.useRef(
5246 void 0
5247 );
5248 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
5249 "script",
5250 {
5251 suppressHydrationWarning: true,
5252 ref: (el) => {
5253 if (el && (prevLocationRef.current === void 0 || prevLocationRef.current.href !== router.latestLocation.href)) {
5254 router.emit({
5255 type: "onRendered",
5256 ...getLocationChangeInfo(router.state)
5257 });
5258 prevLocationRef.current = router.latestLocation;
5259 }
5260 }
5261 },
5262 router.latestLocation.state.__TSR_key
5263 );
5264 }
5265 var MatchInner = React10.memo(function MatchInnerImpl({
5266 matchId
5267 }) {
5268 const router = useRouter();
5269 const { match, key, routeId } = useRouterState({
5270 select: (s) => {
5271 const match2 = s.matches.find((d) => d.id === matchId);
5272 const routeId2 = match2.routeId;
5273 const remountFn = router.routesById[routeId2].options.remountDeps ?? router.options.defaultRemountDeps;
5274 const remountDeps = remountFn?.({
5275 routeId: routeId2,
5276 loaderDeps: match2.loaderDeps,
5277 params: match2._strictParams,
5278 search: match2._strictSearch
5279 });
5280 const key2 = remountDeps ? JSON.stringify(remountDeps) : void 0;
5281 return {
5282 key: key2,
5283 routeId: routeId2,
5284 match: {
5285 id: match2.id,
5286 status: match2.status,
5287 error: match2.error,
5288 _forcePending: match2._forcePending,
5289 _displayPending: match2._displayPending
5290 }
5291 };
5292 },
5293 structuralSharing: true
5294 });
5295 const route = router.routesById[routeId];
5296 const out = React10.useMemo(() => {
5297 const Comp = route.options.component ?? router.options.defaultComponent;
5298 if (Comp) {
5299 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Comp, {}, key);
5300 }
5301 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Outlet, {});
5302 }, [key, route.options.component, router.options.defaultComponent]);
5303 if (match._displayPending) {
5304 throw router.getMatch(match.id)?._nonReactive.displayPendingPromise;
5305 }
5306 if (match._forcePending) {
5307 throw router.getMatch(match.id)?._nonReactive.minPendingPromise;
5308 }
5309 if (match.status === "pending") {
5310 const pendingMinMs = route.options.pendingMinMs ?? router.options.defaultPendingMinMs;
5311 if (pendingMinMs) {
5312 const routerMatch = router.getMatch(match.id);
5313 if (routerMatch && !routerMatch._nonReactive.minPendingPromise) {
5314 if (!router.isServer) {
5315 const minPendingPromise = createControlledPromise();
5316 routerMatch._nonReactive.minPendingPromise = minPendingPromise;
5317 setTimeout(() => {
5318 minPendingPromise.resolve();
5319 routerMatch._nonReactive.minPendingPromise = void 0;
5320 }, pendingMinMs);
5321 }
5322 }
5323 }
5324 throw router.getMatch(match.id)?._nonReactive.loadPromise;
5325 }
5326 if (match.status === "notFound") {
5327 invariant(isNotFound(match.error), "Expected a notFound error");
5328 return renderRouteNotFound(router, route, match.error);
5329 }
5330 if (match.status === "redirected") {
5331 invariant(isRedirect(match.error), "Expected a redirect error");
5332 throw router.getMatch(match.id)?._nonReactive.loadPromise;
5333 }
5334 if (match.status === "error") {
5335 if (router.isServer) {
5336 const RouteErrorComponent = (route.options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent;
5337 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
5338 RouteErrorComponent,
5339 {
5340 error: match.error,
5341 reset: void 0,
5342 info: {
5343 componentStack: ""
5344 }
5345 }
5346 );
5347 }
5348 throw match.error;
5349 }
5350 return out;
5351 });
5352 var Outlet = React10.memo(function OutletImpl() {
5353 const router = useRouter();
5354 const matchId = React10.useContext(matchContext);
5355 const routeId = useRouterState({
5356 select: (s) => s.matches.find((d) => d.id === matchId)?.routeId
5357 });
5358 const route = router.routesById[routeId];
5359 const parentGlobalNotFound = useRouterState({
5360 select: (s) => {
5361 const matches = s.matches;
5362 const parentMatch = matches.find((d) => d.id === matchId);
5363 invariant(
5364 parentMatch,
5365 `Could not find parent match for matchId "${matchId}"`
5366 );
5367 return parentMatch.globalNotFound;
5368 }
5369 });
5370 const childMatchId = useRouterState({
5371 select: (s) => {
5372 const matches = s.matches;
5373 const index = matches.findIndex((d) => d.id === matchId);
5374 return matches[index + 1]?.id;
5375 }
5376 });
5377 const pendingElement = router.options.defaultPendingComponent ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(router.options.defaultPendingComponent, {}) : null;
5378 if (parentGlobalNotFound) {
5379 return renderRouteNotFound(router, route, void 0);
5380 }
5381 if (!childMatchId) {
5382 return null;
5383 }
5384 const nextMatch = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Match, { matchId: childMatchId });
5385 if (matchId === rootRouteId) {
5386 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(React10.Suspense, { fallback: pendingElement, children: nextMatch });
5387 }
5388 return nextMatch;
5389 });
5390
5391 // node_modules/@tanstack/react-router/dist/esm/Matches.js
5392 function Matches() {
5393 const router = useRouter();
5394 const rootRoute = router.routesById[rootRouteId];
5395 const PendingComponent = rootRoute.options.pendingComponent ?? router.options.defaultPendingComponent;
5396 const pendingElement = PendingComponent ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PendingComponent, {}) : null;
5397 const ResolvedSuspense = router.isServer || typeof document !== "undefined" && router.ssr ? SafeFragment : React11.Suspense;
5398 const inner = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(ResolvedSuspense, { fallback: pendingElement, children: [
5399 !router.isServer && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Transitioner, {}),
5400 /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(MatchesInner, {})
5401 ] });
5402 return router.options.InnerWrap ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(router.options.InnerWrap, { children: inner }) : inner;
5403 }
5404 function MatchesInner() {
5405 const router = useRouter();
5406 const matchId = useRouterState({
5407 select: (s) => {
5408 return s.matches[0]?.id;
5409 }
5410 });
5411 const resetKey = useRouterState({
5412 select: (s) => s.loadedAt
5413 });
5414 const matchComponent = matchId ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Match, { matchId }) : null;
5415 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(matchContext.Provider, { value: matchId, children: router.options.disableGlobalCatchBoundary ? matchComponent : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
5416 CatchBoundary,
5417 {
5418 getResetKey: () => resetKey,
5419 errorComponent: ErrorComponent,
5420 onCatch: (error) => {
5421 tiny_warning_esm_default(
5422 false,
5423 `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`
5424 );
5425 tiny_warning_esm_default(false, error.message || error.toString());
5426 },
5427 children: matchComponent
5428 }
5429 ) });
5430 }
5431 function useMatches(opts) {
5432 return useRouterState({
5433 select: (state) => {
5434 const matches = state.matches;
5435 return opts?.select ? opts.select(matches) : matches;
5436 },
5437 structuralSharing: opts?.structuralSharing
5438 });
5439 }
5440
5441 // node_modules/@tanstack/react-router/dist/esm/router.js
5442 var createRouter = (options) => {
5443 return new Router(options);
5444 };
5445 var Router = class extends RouterCore {
5446 constructor(options) {
5447 super(options);
5448 }
5449 };
5450 if (typeof globalThis !== "undefined") {
5451 globalThis.createFileRoute = createFileRoute;
5452 globalThis.createLazyFileRoute = createLazyFileRoute;
5453 } else if (typeof window !== "undefined") {
5454 window.createFileRoute = createFileRoute;
5455 window.createLazyFileRoute = createLazyFileRoute;
5456 }
5457
5458 // node_modules/@tanstack/react-router/dist/esm/RouterProvider.js
5459 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
5460 function RouterContextProvider({
5461 router,
5462 children,
5463 ...rest
5464 }) {
5465 if (Object.keys(rest).length > 0) {
5466 router.update({
5467 ...router.options,
5468 ...rest,
5469 context: {
5470 ...router.options.context,
5471 ...rest.context
5472 }
5473 });
5474 }
5475 const routerContext2 = getRouterContext();
5476 const provider = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(routerContext2.Provider, { value: router, children });
5477 if (router.options.Wrap) {
5478 return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(router.options.Wrap, { children: provider });
5479 }
5480 return provider;
5481 }
5482 function RouterProvider({ router, ...rest }) {
5483 return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RouterContextProvider, { router, ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Matches, {}) });
5484 }
5485
5486 // node_modules/@tanstack/react-router/dist/esm/useLocation.js
5487 function useLocation(opts) {
5488 return useRouterState({
5489 select: (state) => opts?.select ? opts.select(state.location) : state.location
5490 });
5491 }
5492
5493 // node_modules/@tanstack/react-router/dist/esm/useCanGoBack.js
5494 function useCanGoBack() {
5495 return useRouterState({ select: (s) => s.location.state.__TSR_index !== 0 });
5496 }
5497
5498 // packages/route/build-module/lock-unlock.mjs
5499 var import_private_apis = __toESM(require_private_apis(), 1);
5500 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
5501 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
5502 "@wordpress/route"
5503 );
5504
5505 // packages/route/build-module/private-apis.mjs
5506 var privateApis = {};
5507 lock(privateApis, {
5508 // Router creation and setup
5509 createBrowserHistory,
5510 createLazyRoute,
5511 createRouter,
5512 createRootRoute,
5513 createRoute,
5514 Outlet,
5515 RouterProvider,
5516 // Internal routing utilities
5517 redirect,
5518 createLink,
5519 useCanGoBack,
5520 useLoaderData,
5521 useLocation,
5522 useMatches,
5523 useRouter,
5524 useRouterState,
5525 // History utilities
5526 parseHref
5527 });
5528
5529 // packages/route/build-module/index.mjs
5530 function useInvalidate() {
5531 const router = useRouter();
5532 return () => router.invalidate();
5533 }
5534 export {
5535 Link,
5536 notFound,
5537 privateApis,
5538 redirect,
5539 useInvalidate,
5540 useLinkProps,
5541 useNavigate,
5542 useParams,
5543 useSearch
5544 };
5545 /*! Bundled license information:
5546
5547 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
5548 (**
5549 * @license React
5550 * use-sync-external-store-shim.development.js
5551 *
5552 * Copyright (c) Meta Platforms, Inc. and affiliates.
5553 *
5554 * This source code is licensed under the MIT license found in the
5555 * LICENSE file in the root directory of this source tree.
5556 *)
5557
5558 use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
5559 (**
5560 * @license React
5561 * use-sync-external-store-shim/with-selector.development.js
5562 *
5563 * Copyright (c) Meta Platforms, Inc. and affiliates.
5564 *
5565 * This source code is licensed under the MIT license found in the
5566 * LICENSE file in the root directory of this source tree.
5567 *)
5568 */
5569 //# sourceMappingURL=index.js.map
5570