6399 lines
214 KiB
JavaScript
6399 lines
214 KiB
JavaScript
import {
|
|
require_react_dom
|
|
} from "./chunk-65SL2JMO.js";
|
|
import {
|
|
require_jsx_runtime
|
|
} from "./chunk-CQKXKKJC.js";
|
|
import {
|
|
require_react
|
|
} from "./chunk-R7JHQV4C.js";
|
|
import {
|
|
__commonJS,
|
|
__toESM
|
|
} from "./chunk-PLDDJCW6.js";
|
|
|
|
// node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.1/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
|
|
var require_use_sync_external_store_shim_development = __commonJS({
|
|
"node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.1/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
|
|
"use strict";
|
|
(function() {
|
|
function is(x, y) {
|
|
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
}
|
|
function useSyncExternalStore$2(subscribe2, getSnapshot) {
|
|
didWarnOld18Alpha || void 0 === React17.startTransition || (didWarnOld18Alpha = true, console.error(
|
|
"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."
|
|
));
|
|
var value = getSnapshot();
|
|
if (!didWarnUncachedGetSnapshot) {
|
|
var cachedValue = getSnapshot();
|
|
objectIs(value, cachedValue) || (console.error(
|
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
), didWarnUncachedGetSnapshot = true);
|
|
}
|
|
cachedValue = useState5({
|
|
inst: { value, getSnapshot }
|
|
});
|
|
var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
|
|
useLayoutEffect3(
|
|
function() {
|
|
inst.value = value;
|
|
inst.getSnapshot = getSnapshot;
|
|
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
},
|
|
[subscribe2, value, getSnapshot]
|
|
);
|
|
useEffect7(
|
|
function() {
|
|
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
return subscribe2(function() {
|
|
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
});
|
|
},
|
|
[subscribe2]
|
|
);
|
|
useDebugValue(value);
|
|
return value;
|
|
}
|
|
function checkIfSnapshotChanged(inst) {
|
|
var latestGetSnapshot = inst.getSnapshot;
|
|
inst = inst.value;
|
|
try {
|
|
var nextValue = latestGetSnapshot();
|
|
return !objectIs(inst, nextValue);
|
|
} catch (error) {
|
|
return true;
|
|
}
|
|
}
|
|
function useSyncExternalStore$1(subscribe2, getSnapshot) {
|
|
return getSnapshot();
|
|
}
|
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
var React17 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState5 = React17.useState, useEffect7 = React17.useEffect, useLayoutEffect3 = React17.useLayoutEffect, useDebugValue = React17.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
|
|
exports.useSyncExternalStore = void 0 !== React17.useSyncExternalStore ? React17.useSyncExternalStore : shim;
|
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
})();
|
|
}
|
|
});
|
|
|
|
// node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.1/node_modules/use-sync-external-store/shim/index.js
|
|
var require_shim = __commonJS({
|
|
"node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.1/node_modules/use-sync-external-store/shim/index.js"(exports, module) {
|
|
"use strict";
|
|
if (false) {
|
|
module.exports = null;
|
|
} else {
|
|
module.exports = require_use_sync_external_store_shim_development();
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.1/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
|
|
var require_with_selector_development = __commonJS({
|
|
"node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.1/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
|
|
"use strict";
|
|
(function() {
|
|
function is(x, y) {
|
|
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
}
|
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
var React17 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore = shim.useSyncExternalStore, useRef7 = React17.useRef, useEffect7 = React17.useEffect, useMemo4 = React17.useMemo, useDebugValue = React17.useDebugValue;
|
|
exports.useSyncExternalStoreWithSelector = function(subscribe2, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
var instRef = useRef7(null);
|
|
if (null === instRef.current) {
|
|
var inst = { hasValue: false, value: null };
|
|
instRef.current = inst;
|
|
} else inst = instRef.current;
|
|
instRef = useMemo4(
|
|
function() {
|
|
function memoizedSelector(nextSnapshot) {
|
|
if (!hasMemo) {
|
|
hasMemo = true;
|
|
memoizedSnapshot = nextSnapshot;
|
|
nextSnapshot = selector(nextSnapshot);
|
|
if (void 0 !== isEqual && inst.hasValue) {
|
|
var currentSelection = inst.value;
|
|
if (isEqual(currentSelection, nextSnapshot))
|
|
return memoizedSelection = currentSelection;
|
|
}
|
|
return memoizedSelection = nextSnapshot;
|
|
}
|
|
currentSelection = memoizedSelection;
|
|
if (objectIs(memoizedSnapshot, nextSnapshot))
|
|
return currentSelection;
|
|
var nextSelection = selector(nextSnapshot);
|
|
if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
|
|
return memoizedSnapshot = nextSnapshot, currentSelection;
|
|
memoizedSnapshot = nextSnapshot;
|
|
return memoizedSelection = nextSelection;
|
|
}
|
|
var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
|
|
return [
|
|
function() {
|
|
return memoizedSelector(getSnapshot());
|
|
},
|
|
null === maybeGetServerSnapshot ? void 0 : function() {
|
|
return memoizedSelector(maybeGetServerSnapshot());
|
|
}
|
|
];
|
|
},
|
|
[getSnapshot, getServerSnapshot, selector, isEqual]
|
|
);
|
|
var value = useSyncExternalStore(subscribe2, instRef[0], instRef[1]);
|
|
useEffect7(
|
|
function() {
|
|
inst.hasValue = true;
|
|
inst.value = value;
|
|
},
|
|
[value]
|
|
);
|
|
useDebugValue(value);
|
|
return value;
|
|
};
|
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
})();
|
|
}
|
|
});
|
|
|
|
// node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.1/node_modules/use-sync-external-store/shim/with-selector.js
|
|
var require_with_selector = __commonJS({
|
|
"node_modules/.pnpm/use-sync-external-store@1.5.0_react@19.1.1/node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
|
|
"use strict";
|
|
if (false) {
|
|
module.exports = null;
|
|
} else {
|
|
module.exports = require_with_selector_development();
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
var isProduction = false;
|
|
var prefix = "Invariant failed";
|
|
function invariant(condition, message) {
|
|
if (condition) {
|
|
return;
|
|
}
|
|
if (isProduction) {
|
|
throw new Error(prefix);
|
|
}
|
|
var provided = typeof message === "function" ? message() : message;
|
|
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
throw new Error(value);
|
|
}
|
|
|
|
// node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js
|
|
var isProduction2 = false;
|
|
function warning(condition, message) {
|
|
if (!isProduction2) {
|
|
if (condition) {
|
|
return;
|
|
}
|
|
var text = "Warning: " + message;
|
|
if (typeof console !== "undefined") {
|
|
console.warn(text);
|
|
}
|
|
try {
|
|
throw Error(text);
|
|
} catch (x) {
|
|
}
|
|
}
|
|
}
|
|
var tiny_warning_esm_default = warning;
|
|
|
|
// node_modules/.pnpm/@tanstack+store@0.7.2/node_modules/@tanstack/store/dist/esm/scheduler.js
|
|
var __storeToDerived = /* @__PURE__ */ new WeakMap();
|
|
var __derivedToStore = /* @__PURE__ */ new WeakMap();
|
|
var __depsThatHaveWrittenThisTick = {
|
|
current: []
|
|
};
|
|
var __isFlushing = false;
|
|
var __batchDepth = 0;
|
|
var __pendingUpdates = /* @__PURE__ */ new Set();
|
|
var __initialBatchValues = /* @__PURE__ */ new Map();
|
|
function __flush_internals(relatedVals) {
|
|
const sorted = Array.from(relatedVals).sort((a, b) => {
|
|
if (a instanceof Derived && a.options.deps.includes(b)) return 1;
|
|
if (b instanceof Derived && b.options.deps.includes(a)) return -1;
|
|
return 0;
|
|
});
|
|
for (const derived of sorted) {
|
|
if (__depsThatHaveWrittenThisTick.current.includes(derived)) {
|
|
continue;
|
|
}
|
|
__depsThatHaveWrittenThisTick.current.push(derived);
|
|
derived.recompute();
|
|
const stores = __derivedToStore.get(derived);
|
|
if (stores) {
|
|
for (const store of stores) {
|
|
const relatedLinkedDerivedVals = __storeToDerived.get(store);
|
|
if (!relatedLinkedDerivedVals) continue;
|
|
__flush_internals(relatedLinkedDerivedVals);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function __notifyListeners(store) {
|
|
store.listeners.forEach(
|
|
(listener) => listener({
|
|
prevVal: store.prevState,
|
|
currentVal: store.state
|
|
})
|
|
);
|
|
}
|
|
function __notifyDerivedListeners(derived) {
|
|
derived.listeners.forEach(
|
|
(listener) => listener({
|
|
prevVal: derived.prevState,
|
|
currentVal: derived.state
|
|
})
|
|
);
|
|
}
|
|
function __flush(store) {
|
|
if (__batchDepth > 0 && !__initialBatchValues.has(store)) {
|
|
__initialBatchValues.set(store, store.prevState);
|
|
}
|
|
__pendingUpdates.add(store);
|
|
if (__batchDepth > 0) return;
|
|
if (__isFlushing) return;
|
|
try {
|
|
__isFlushing = true;
|
|
while (__pendingUpdates.size > 0) {
|
|
const stores = Array.from(__pendingUpdates);
|
|
__pendingUpdates.clear();
|
|
for (const store2 of stores) {
|
|
const prevState = __initialBatchValues.get(store2) ?? store2.prevState;
|
|
store2.prevState = prevState;
|
|
__notifyListeners(store2);
|
|
}
|
|
for (const store2 of stores) {
|
|
const derivedVals = __storeToDerived.get(store2);
|
|
if (!derivedVals) continue;
|
|
__depsThatHaveWrittenThisTick.current.push(store2);
|
|
__flush_internals(derivedVals);
|
|
}
|
|
for (const store2 of stores) {
|
|
const derivedVals = __storeToDerived.get(store2);
|
|
if (!derivedVals) continue;
|
|
for (const derived of derivedVals) {
|
|
__notifyDerivedListeners(derived);
|
|
}
|
|
}
|
|
}
|
|
} finally {
|
|
__isFlushing = false;
|
|
__depsThatHaveWrittenThisTick.current = [];
|
|
__initialBatchValues.clear();
|
|
}
|
|
}
|
|
function batch(fn) {
|
|
__batchDepth++;
|
|
try {
|
|
fn();
|
|
} finally {
|
|
__batchDepth--;
|
|
if (__batchDepth === 0) {
|
|
const pendingUpdateToFlush = Array.from(__pendingUpdates)[0];
|
|
if (pendingUpdateToFlush) {
|
|
__flush(pendingUpdateToFlush);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+store@0.7.2/node_modules/@tanstack/store/dist/esm/types.js
|
|
function isUpdaterFunction(updater) {
|
|
return typeof updater === "function";
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+store@0.7.2/node_modules/@tanstack/store/dist/esm/store.js
|
|
var Store = class {
|
|
constructor(initialState, options) {
|
|
this.listeners = /* @__PURE__ */ new Set();
|
|
this.subscribe = (listener) => {
|
|
var _a, _b;
|
|
this.listeners.add(listener);
|
|
const unsub = (_b = (_a = this.options) == null ? void 0 : _a.onSubscribe) == null ? void 0 : _b.call(_a, listener, this);
|
|
return () => {
|
|
this.listeners.delete(listener);
|
|
unsub == null ? void 0 : unsub();
|
|
};
|
|
};
|
|
this.prevState = initialState;
|
|
this.state = initialState;
|
|
this.options = options;
|
|
}
|
|
setState(updater) {
|
|
var _a, _b, _c;
|
|
this.prevState = this.state;
|
|
if ((_a = this.options) == null ? void 0 : _a.updateFn) {
|
|
this.state = this.options.updateFn(this.prevState)(updater);
|
|
} else {
|
|
if (isUpdaterFunction(updater)) {
|
|
this.state = updater(this.prevState);
|
|
} else {
|
|
this.state = updater;
|
|
}
|
|
}
|
|
(_c = (_b = this.options) == null ? void 0 : _b.onUpdate) == null ? void 0 : _c.call(_b);
|
|
__flush(this);
|
|
}
|
|
};
|
|
|
|
// node_modules/.pnpm/@tanstack+store@0.7.2/node_modules/@tanstack/store/dist/esm/derived.js
|
|
var Derived = class _Derived {
|
|
constructor(options) {
|
|
this.listeners = /* @__PURE__ */ new Set();
|
|
this._subscriptions = [];
|
|
this.lastSeenDepValues = [];
|
|
this.getDepVals = () => {
|
|
const prevDepVals = [];
|
|
const currDepVals = [];
|
|
for (const dep of this.options.deps) {
|
|
prevDepVals.push(dep.prevState);
|
|
currDepVals.push(dep.state);
|
|
}
|
|
this.lastSeenDepValues = currDepVals;
|
|
return {
|
|
prevDepVals,
|
|
currDepVals,
|
|
prevVal: this.prevState ?? void 0
|
|
};
|
|
};
|
|
this.recompute = () => {
|
|
var _a, _b;
|
|
this.prevState = this.state;
|
|
const { prevDepVals, currDepVals, prevVal } = this.getDepVals();
|
|
this.state = this.options.fn({
|
|
prevDepVals,
|
|
currDepVals,
|
|
prevVal
|
|
});
|
|
(_b = (_a = this.options).onUpdate) == null ? void 0 : _b.call(_a);
|
|
};
|
|
this.checkIfRecalculationNeededDeeply = () => {
|
|
for (const dep of this.options.deps) {
|
|
if (dep instanceof _Derived) {
|
|
dep.checkIfRecalculationNeededDeeply();
|
|
}
|
|
}
|
|
let shouldRecompute = false;
|
|
const lastSeenDepValues = this.lastSeenDepValues;
|
|
const { currDepVals } = this.getDepVals();
|
|
for (let i = 0; i < currDepVals.length; i++) {
|
|
if (currDepVals[i] !== lastSeenDepValues[i]) {
|
|
shouldRecompute = true;
|
|
break;
|
|
}
|
|
}
|
|
if (shouldRecompute) {
|
|
this.recompute();
|
|
}
|
|
};
|
|
this.mount = () => {
|
|
this.registerOnGraph();
|
|
this.checkIfRecalculationNeededDeeply();
|
|
return () => {
|
|
this.unregisterFromGraph();
|
|
for (const cleanup of this._subscriptions) {
|
|
cleanup();
|
|
}
|
|
};
|
|
};
|
|
this.subscribe = (listener) => {
|
|
var _a, _b;
|
|
this.listeners.add(listener);
|
|
const unsub = (_b = (_a = this.options).onSubscribe) == null ? void 0 : _b.call(_a, listener, this);
|
|
return () => {
|
|
this.listeners.delete(listener);
|
|
unsub == null ? void 0 : unsub();
|
|
};
|
|
};
|
|
this.options = options;
|
|
this.state = options.fn({
|
|
prevDepVals: void 0,
|
|
prevVal: void 0,
|
|
currDepVals: this.getDepVals().currDepVals
|
|
});
|
|
}
|
|
registerOnGraph(deps = this.options.deps) {
|
|
for (const dep of deps) {
|
|
if (dep instanceof _Derived) {
|
|
dep.registerOnGraph();
|
|
this.registerOnGraph(dep.options.deps);
|
|
} else if (dep instanceof Store) {
|
|
let relatedLinkedDerivedVals = __storeToDerived.get(dep);
|
|
if (!relatedLinkedDerivedVals) {
|
|
relatedLinkedDerivedVals = /* @__PURE__ */ new Set();
|
|
__storeToDerived.set(dep, relatedLinkedDerivedVals);
|
|
}
|
|
relatedLinkedDerivedVals.add(this);
|
|
let relatedStores = __derivedToStore.get(this);
|
|
if (!relatedStores) {
|
|
relatedStores = /* @__PURE__ */ new Set();
|
|
__derivedToStore.set(this, relatedStores);
|
|
}
|
|
relatedStores.add(dep);
|
|
}
|
|
}
|
|
}
|
|
unregisterFromGraph(deps = this.options.deps) {
|
|
for (const dep of deps) {
|
|
if (dep instanceof _Derived) {
|
|
this.unregisterFromGraph(dep.options.deps);
|
|
} else if (dep instanceof Store) {
|
|
const relatedLinkedDerivedVals = __storeToDerived.get(dep);
|
|
if (relatedLinkedDerivedVals) {
|
|
relatedLinkedDerivedVals.delete(this);
|
|
}
|
|
const relatedStores = __derivedToStore.get(this);
|
|
if (relatedStores) {
|
|
relatedStores.delete(dep);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
// node_modules/.pnpm/@tanstack+history@1.131.2/node_modules/@tanstack/history/dist/esm/index.js
|
|
var stateIndexKey = "__TSR_index";
|
|
var popStateEvent = "popstate";
|
|
var beforeUnloadEvent = "beforeunload";
|
|
function createHistory(opts) {
|
|
let location = opts.getLocation();
|
|
const subscribers = /* @__PURE__ */ new Set();
|
|
const notify = (action) => {
|
|
location = opts.getLocation();
|
|
subscribers.forEach((subscriber) => subscriber({ location, action }));
|
|
};
|
|
const handleIndexChange = (action) => {
|
|
if (opts.notifyOnIndexChange ?? true) notify(action);
|
|
else location = opts.getLocation();
|
|
};
|
|
const tryNavigation = async ({
|
|
task,
|
|
navigateOpts,
|
|
...actionInfo
|
|
}) => {
|
|
var _a, _b;
|
|
const ignoreBlocker = (navigateOpts == null ? void 0 : navigateOpts.ignoreBlocker) ?? false;
|
|
if (ignoreBlocker) {
|
|
task();
|
|
return;
|
|
}
|
|
const blockers = ((_a = opts.getBlockers) == null ? void 0 : _a.call(opts)) ?? [];
|
|
const isPushOrReplace = actionInfo.type === "PUSH" || actionInfo.type === "REPLACE";
|
|
if (typeof document !== "undefined" && blockers.length && isPushOrReplace) {
|
|
for (const blocker of blockers) {
|
|
const nextLocation = parseHref(actionInfo.path, actionInfo.state);
|
|
const isBlocked = await blocker.blockerFn({
|
|
currentLocation: location,
|
|
nextLocation,
|
|
action: actionInfo.type
|
|
});
|
|
if (isBlocked) {
|
|
(_b = opts.onBlocked) == null ? void 0 : _b.call(opts);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
task();
|
|
};
|
|
return {
|
|
get location() {
|
|
return location;
|
|
},
|
|
get length() {
|
|
return opts.getLength();
|
|
},
|
|
subscribers,
|
|
subscribe: (cb) => {
|
|
subscribers.add(cb);
|
|
return () => {
|
|
subscribers.delete(cb);
|
|
};
|
|
},
|
|
push: (path, state, navigateOpts) => {
|
|
const currentIndex = location.state[stateIndexKey];
|
|
state = assignKeyAndIndex(currentIndex + 1, state);
|
|
tryNavigation({
|
|
task: () => {
|
|
opts.pushState(path, state);
|
|
notify({ type: "PUSH" });
|
|
},
|
|
navigateOpts,
|
|
type: "PUSH",
|
|
path,
|
|
state
|
|
});
|
|
},
|
|
replace: (path, state, navigateOpts) => {
|
|
const currentIndex = location.state[stateIndexKey];
|
|
state = assignKeyAndIndex(currentIndex, state);
|
|
tryNavigation({
|
|
task: () => {
|
|
opts.replaceState(path, state);
|
|
notify({ type: "REPLACE" });
|
|
},
|
|
navigateOpts,
|
|
type: "REPLACE",
|
|
path,
|
|
state
|
|
});
|
|
},
|
|
go: (index, navigateOpts) => {
|
|
tryNavigation({
|
|
task: () => {
|
|
opts.go(index);
|
|
handleIndexChange({ type: "GO", index });
|
|
},
|
|
navigateOpts,
|
|
type: "GO"
|
|
});
|
|
},
|
|
back: (navigateOpts) => {
|
|
tryNavigation({
|
|
task: () => {
|
|
opts.back((navigateOpts == null ? void 0 : navigateOpts.ignoreBlocker) ?? false);
|
|
handleIndexChange({ type: "BACK" });
|
|
},
|
|
navigateOpts,
|
|
type: "BACK"
|
|
});
|
|
},
|
|
forward: (navigateOpts) => {
|
|
tryNavigation({
|
|
task: () => {
|
|
opts.forward((navigateOpts == null ? void 0 : navigateOpts.ignoreBlocker) ?? false);
|
|
handleIndexChange({ type: "FORWARD" });
|
|
},
|
|
navigateOpts,
|
|
type: "FORWARD"
|
|
});
|
|
},
|
|
canGoBack: () => location.state[stateIndexKey] !== 0,
|
|
createHref: (str) => opts.createHref(str),
|
|
block: (blocker) => {
|
|
var _a;
|
|
if (!opts.setBlockers) return () => {
|
|
};
|
|
const blockers = ((_a = opts.getBlockers) == null ? void 0 : _a.call(opts)) ?? [];
|
|
opts.setBlockers([...blockers, blocker]);
|
|
return () => {
|
|
var _a2, _b;
|
|
const blockers2 = ((_a2 = opts.getBlockers) == null ? void 0 : _a2.call(opts)) ?? [];
|
|
(_b = opts.setBlockers) == null ? void 0 : _b.call(opts, blockers2.filter((b) => b !== blocker));
|
|
};
|
|
},
|
|
flush: () => {
|
|
var _a;
|
|
return (_a = opts.flush) == null ? void 0 : _a.call(opts);
|
|
},
|
|
destroy: () => {
|
|
var _a;
|
|
return (_a = opts.destroy) == null ? void 0 : _a.call(opts);
|
|
},
|
|
notify
|
|
};
|
|
}
|
|
function assignKeyAndIndex(index, state) {
|
|
if (!state) {
|
|
state = {};
|
|
}
|
|
const key = createRandomKey();
|
|
return {
|
|
...state,
|
|
key,
|
|
// TODO: Remove in v2 - use __TSR_key instead
|
|
__TSR_key: key,
|
|
[stateIndexKey]: index
|
|
};
|
|
}
|
|
function createBrowserHistory(opts) {
|
|
var _a, _b;
|
|
const win = (opts == null ? void 0 : opts.window) ?? (typeof document !== "undefined" ? window : void 0);
|
|
const originalPushState = win.history.pushState;
|
|
const originalReplaceState = win.history.replaceState;
|
|
let blockers = [];
|
|
const _getBlockers = () => blockers;
|
|
const _setBlockers = (newBlockers) => blockers = newBlockers;
|
|
const createHref = (opts == null ? void 0 : opts.createHref) ?? ((path) => path);
|
|
const parseLocation = (opts == null ? void 0 : opts.parseLocation) ?? (() => parseHref(
|
|
`${win.location.pathname}${win.location.search}${win.location.hash}`,
|
|
win.history.state
|
|
));
|
|
if (!((_a = win.history.state) == null ? void 0 : _a.__TSR_key) && !((_b = win.history.state) == null ? void 0 : _b.key)) {
|
|
const addedKey = createRandomKey();
|
|
win.history.replaceState(
|
|
{
|
|
[stateIndexKey]: 0,
|
|
key: addedKey,
|
|
// TODO: Remove in v2 - use __TSR_key instead
|
|
__TSR_key: addedKey
|
|
},
|
|
""
|
|
);
|
|
}
|
|
let currentLocation = parseLocation();
|
|
let rollbackLocation;
|
|
let nextPopIsGo = false;
|
|
let ignoreNextPop = false;
|
|
let skipBlockerNextPop = false;
|
|
let ignoreNextBeforeUnload = false;
|
|
const getLocation = () => currentLocation;
|
|
let next;
|
|
let scheduled;
|
|
const flush = () => {
|
|
if (!next) {
|
|
return;
|
|
}
|
|
history._ignoreSubscribers = true;
|
|
(next.isPush ? win.history.pushState : win.history.replaceState)(
|
|
next.state,
|
|
"",
|
|
next.href
|
|
);
|
|
history._ignoreSubscribers = false;
|
|
next = void 0;
|
|
scheduled = void 0;
|
|
rollbackLocation = void 0;
|
|
};
|
|
const queueHistoryAction = (type, destHref, state) => {
|
|
const href = createHref(destHref);
|
|
if (!scheduled) {
|
|
rollbackLocation = currentLocation;
|
|
}
|
|
currentLocation = parseHref(destHref, state);
|
|
next = {
|
|
href,
|
|
state,
|
|
isPush: (next == null ? void 0 : next.isPush) || type === "push"
|
|
};
|
|
if (!scheduled) {
|
|
scheduled = Promise.resolve().then(() => flush());
|
|
}
|
|
};
|
|
const onPushPop = (type) => {
|
|
currentLocation = parseLocation();
|
|
history.notify({ type });
|
|
};
|
|
const onPushPopEvent = async () => {
|
|
if (ignoreNextPop) {
|
|
ignoreNextPop = false;
|
|
return;
|
|
}
|
|
const nextLocation = parseLocation();
|
|
const delta = nextLocation.state[stateIndexKey] - currentLocation.state[stateIndexKey];
|
|
const isForward = delta === 1;
|
|
const isBack = delta === -1;
|
|
const isGo = !isForward && !isBack || nextPopIsGo;
|
|
nextPopIsGo = false;
|
|
const action = isGo ? "GO" : isBack ? "BACK" : "FORWARD";
|
|
const notify = isGo ? {
|
|
type: "GO",
|
|
index: delta
|
|
} : {
|
|
type: isBack ? "BACK" : "FORWARD"
|
|
};
|
|
if (skipBlockerNextPop) {
|
|
skipBlockerNextPop = false;
|
|
} else {
|
|
const blockers2 = _getBlockers();
|
|
if (typeof document !== "undefined" && blockers2.length) {
|
|
for (const blocker of blockers2) {
|
|
const isBlocked = await blocker.blockerFn({
|
|
currentLocation,
|
|
nextLocation,
|
|
action
|
|
});
|
|
if (isBlocked) {
|
|
ignoreNextPop = true;
|
|
win.history.go(1);
|
|
history.notify(notify);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
currentLocation = parseLocation();
|
|
history.notify(notify);
|
|
};
|
|
const onBeforeUnload = (e) => {
|
|
if (ignoreNextBeforeUnload) {
|
|
ignoreNextBeforeUnload = false;
|
|
return;
|
|
}
|
|
let shouldBlock = false;
|
|
const blockers2 = _getBlockers();
|
|
if (typeof document !== "undefined" && blockers2.length) {
|
|
for (const blocker of blockers2) {
|
|
const shouldHaveBeforeUnload = blocker.enableBeforeUnload ?? true;
|
|
if (shouldHaveBeforeUnload === true) {
|
|
shouldBlock = true;
|
|
break;
|
|
}
|
|
if (typeof shouldHaveBeforeUnload === "function" && shouldHaveBeforeUnload() === true) {
|
|
shouldBlock = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (shouldBlock) {
|
|
e.preventDefault();
|
|
return e.returnValue = "";
|
|
}
|
|
return;
|
|
};
|
|
const history = createHistory({
|
|
getLocation,
|
|
getLength: () => win.history.length,
|
|
pushState: (href, state) => queueHistoryAction("push", href, state),
|
|
replaceState: (href, state) => queueHistoryAction("replace", href, state),
|
|
back: (ignoreBlocker) => {
|
|
if (ignoreBlocker) skipBlockerNextPop = true;
|
|
ignoreNextBeforeUnload = true;
|
|
return win.history.back();
|
|
},
|
|
forward: (ignoreBlocker) => {
|
|
if (ignoreBlocker) skipBlockerNextPop = true;
|
|
ignoreNextBeforeUnload = true;
|
|
win.history.forward();
|
|
},
|
|
go: (n) => {
|
|
nextPopIsGo = true;
|
|
win.history.go(n);
|
|
},
|
|
createHref: (href) => createHref(href),
|
|
flush,
|
|
destroy: () => {
|
|
win.history.pushState = originalPushState;
|
|
win.history.replaceState = originalReplaceState;
|
|
win.removeEventListener(beforeUnloadEvent, onBeforeUnload, {
|
|
capture: true
|
|
});
|
|
win.removeEventListener(popStateEvent, onPushPopEvent);
|
|
},
|
|
onBlocked: () => {
|
|
if (rollbackLocation && currentLocation !== rollbackLocation) {
|
|
currentLocation = rollbackLocation;
|
|
}
|
|
},
|
|
getBlockers: _getBlockers,
|
|
setBlockers: _setBlockers,
|
|
notifyOnIndexChange: false
|
|
});
|
|
win.addEventListener(beforeUnloadEvent, onBeforeUnload, { capture: true });
|
|
win.addEventListener(popStateEvent, onPushPopEvent);
|
|
win.history.pushState = function(...args) {
|
|
const res = originalPushState.apply(win.history, args);
|
|
if (!history._ignoreSubscribers) onPushPop("PUSH");
|
|
return res;
|
|
};
|
|
win.history.replaceState = function(...args) {
|
|
const res = originalReplaceState.apply(win.history, args);
|
|
if (!history._ignoreSubscribers) onPushPop("REPLACE");
|
|
return res;
|
|
};
|
|
return history;
|
|
}
|
|
function createHashHistory(opts) {
|
|
const win = (opts == null ? void 0 : opts.window) ?? (typeof document !== "undefined" ? window : void 0);
|
|
return createBrowserHistory({
|
|
window: win,
|
|
parseLocation: () => {
|
|
const hashSplit = win.location.hash.split("#").slice(1);
|
|
const pathPart = hashSplit[0] ?? "/";
|
|
const searchPart = win.location.search;
|
|
const hashEntries = hashSplit.slice(1);
|
|
const hashPart = hashEntries.length === 0 ? "" : `#${hashEntries.join("#")}`;
|
|
const hashHref = `${pathPart}${searchPart}${hashPart}`;
|
|
return parseHref(hashHref, win.history.state);
|
|
},
|
|
createHref: (href) => `${win.location.pathname}${win.location.search}#${href}`
|
|
});
|
|
}
|
|
function createMemoryHistory(opts = {
|
|
initialEntries: ["/"]
|
|
}) {
|
|
const entries = opts.initialEntries;
|
|
let index = opts.initialIndex ? Math.min(Math.max(opts.initialIndex, 0), entries.length - 1) : entries.length - 1;
|
|
const states = entries.map(
|
|
(_entry, index2) => assignKeyAndIndex(index2, void 0)
|
|
);
|
|
const getLocation = () => parseHref(entries[index], states[index]);
|
|
return createHistory({
|
|
getLocation,
|
|
getLength: () => entries.length,
|
|
pushState: (path, state) => {
|
|
if (index < entries.length - 1) {
|
|
entries.splice(index + 1);
|
|
states.splice(index + 1);
|
|
}
|
|
states.push(state);
|
|
entries.push(path);
|
|
index = Math.max(entries.length - 1, 0);
|
|
},
|
|
replaceState: (path, state) => {
|
|
states[index] = state;
|
|
entries[index] = path;
|
|
},
|
|
back: () => {
|
|
index = Math.max(index - 1, 0);
|
|
},
|
|
forward: () => {
|
|
index = Math.min(index + 1, entries.length - 1);
|
|
},
|
|
go: (n) => {
|
|
index = Math.min(Math.max(index + n, 0), entries.length - 1);
|
|
},
|
|
createHref: (path) => path
|
|
});
|
|
}
|
|
function parseHref(href, state) {
|
|
const hashIndex = href.indexOf("#");
|
|
const searchIndex = href.indexOf("?");
|
|
const addedKey = createRandomKey();
|
|
return {
|
|
href,
|
|
pathname: href.substring(
|
|
0,
|
|
hashIndex > 0 ? searchIndex > 0 ? Math.min(hashIndex, searchIndex) : hashIndex : searchIndex > 0 ? searchIndex : href.length
|
|
),
|
|
hash: hashIndex > -1 ? href.substring(hashIndex) : "",
|
|
search: searchIndex > -1 ? href.slice(searchIndex, hashIndex === -1 ? void 0 : hashIndex) : "",
|
|
state: state || { [stateIndexKey]: 0, key: addedKey, __TSR_key: addedKey }
|
|
};
|
|
}
|
|
function createRandomKey() {
|
|
return (Math.random() + 1).toString(36).substring(7);
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/utils.js
|
|
function last(arr) {
|
|
return arr[arr.length - 1];
|
|
}
|
|
function isFunction(d) {
|
|
return typeof d === "function";
|
|
}
|
|
function functionalUpdate(updater, previous) {
|
|
if (isFunction(updater)) {
|
|
return updater(previous);
|
|
}
|
|
return updater;
|
|
}
|
|
function pick(parent, keys) {
|
|
return keys.reduce((obj, key) => {
|
|
obj[key] = parent[key];
|
|
return obj;
|
|
}, {});
|
|
}
|
|
function replaceEqualDeep(prev, _next) {
|
|
if (prev === _next) {
|
|
return prev;
|
|
}
|
|
const next = _next;
|
|
const array = isPlainArray(prev) && isPlainArray(next);
|
|
if (array || isSimplePlainObject(prev) && isSimplePlainObject(next)) {
|
|
const prevItems = array ? prev : Object.keys(prev).concat(
|
|
Object.getOwnPropertySymbols(prev)
|
|
);
|
|
const prevSize = prevItems.length;
|
|
const nextItems = array ? next : Object.keys(next).concat(
|
|
Object.getOwnPropertySymbols(next)
|
|
);
|
|
const nextSize = nextItems.length;
|
|
const copy = array ? [] : {};
|
|
let equalItems = 0;
|
|
for (let i = 0; i < nextSize; i++) {
|
|
const key = array ? i : nextItems[i];
|
|
if ((!array && prevItems.includes(key) || array) && prev[key] === void 0 && next[key] === void 0) {
|
|
copy[key] = void 0;
|
|
equalItems++;
|
|
} else {
|
|
copy[key] = replaceEqualDeep(prev[key], next[key]);
|
|
if (copy[key] === prev[key] && prev[key] !== void 0) {
|
|
equalItems++;
|
|
}
|
|
}
|
|
}
|
|
return prevSize === nextSize && equalItems === prevSize ? prev : copy;
|
|
}
|
|
return next;
|
|
}
|
|
function isSimplePlainObject(o) {
|
|
return (
|
|
// all the checks from isPlainObject are more likely to hit so we perform them first
|
|
isPlainObject(o) && Object.getOwnPropertyNames(o).length === Object.keys(o).length
|
|
);
|
|
}
|
|
function isPlainObject(o) {
|
|
if (!hasObjectPrototype(o)) {
|
|
return false;
|
|
}
|
|
const ctor = o.constructor;
|
|
if (typeof ctor === "undefined") {
|
|
return true;
|
|
}
|
|
const prot = ctor.prototype;
|
|
if (!hasObjectPrototype(prot)) {
|
|
return false;
|
|
}
|
|
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
function hasObjectPrototype(o) {
|
|
return Object.prototype.toString.call(o) === "[object Object]";
|
|
}
|
|
function isPlainArray(value) {
|
|
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
}
|
|
function getObjectKeys(obj, ignoreUndefined) {
|
|
let keys = Object.keys(obj);
|
|
if (ignoreUndefined) {
|
|
keys = keys.filter((key) => obj[key] !== void 0);
|
|
}
|
|
return keys;
|
|
}
|
|
function deepEqual(a, b, opts) {
|
|
if (a === b) {
|
|
return true;
|
|
}
|
|
if (typeof a !== typeof b) {
|
|
return false;
|
|
}
|
|
if (isPlainObject(a) && isPlainObject(b)) {
|
|
const ignoreUndefined = (opts == null ? void 0 : opts.ignoreUndefined) ?? true;
|
|
const aKeys = getObjectKeys(a, ignoreUndefined);
|
|
const bKeys = getObjectKeys(b, ignoreUndefined);
|
|
if (!(opts == null ? void 0 : opts.partial) && aKeys.length !== bKeys.length) {
|
|
return false;
|
|
}
|
|
return bKeys.every((key) => deepEqual(a[key], b[key], opts));
|
|
}
|
|
if (Array.isArray(a) && Array.isArray(b)) {
|
|
if (a.length !== b.length) {
|
|
return false;
|
|
}
|
|
return !a.some((item, index) => !deepEqual(item, b[index], opts));
|
|
}
|
|
return false;
|
|
}
|
|
function createControlledPromise(onResolve) {
|
|
let resolveLoadPromise;
|
|
let rejectLoadPromise;
|
|
const controlledPromise = new Promise((resolve, reject) => {
|
|
resolveLoadPromise = resolve;
|
|
rejectLoadPromise = reject;
|
|
});
|
|
controlledPromise.status = "pending";
|
|
controlledPromise.resolve = (value) => {
|
|
controlledPromise.status = "resolved";
|
|
controlledPromise.value = value;
|
|
resolveLoadPromise(value);
|
|
onResolve == null ? void 0 : onResolve(value);
|
|
};
|
|
controlledPromise.reject = (e) => {
|
|
controlledPromise.status = "rejected";
|
|
rejectLoadPromise(e);
|
|
};
|
|
return controlledPromise;
|
|
}
|
|
function escapeJSON(jsonString) {
|
|
return jsonString.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/"/g, '\\"');
|
|
}
|
|
function shallow(objA, objB) {
|
|
if (Object.is(objA, objB)) {
|
|
return true;
|
|
}
|
|
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
return false;
|
|
}
|
|
const keysA = Object.keys(objA);
|
|
if (keysA.length !== Object.keys(objB).length) {
|
|
return false;
|
|
}
|
|
for (const item of keysA) {
|
|
if (!Object.prototype.hasOwnProperty.call(objB, item) || !Object.is(objA[item], objB[item])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function isModuleNotFoundError(error) {
|
|
if (typeof (error == null ? void 0 : error.message) !== "string") return false;
|
|
return error.message.startsWith("Failed to fetch dynamically imported module") || error.message.startsWith("error loading dynamically imported module") || error.message.startsWith("Importing a module script failed");
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/path.js
|
|
var SEGMENT_TYPE_PATHNAME = 0;
|
|
var SEGMENT_TYPE_PARAM = 1;
|
|
var SEGMENT_TYPE_WILDCARD = 2;
|
|
var SEGMENT_TYPE_OPTIONAL_PARAM = 3;
|
|
function joinPaths(paths) {
|
|
return cleanPath(
|
|
paths.filter((val) => {
|
|
return val !== void 0;
|
|
}).join("/")
|
|
);
|
|
}
|
|
function cleanPath(path) {
|
|
return path.replace(/\/{2,}/g, "/");
|
|
}
|
|
function trimPathLeft(path) {
|
|
return path === "/" ? path : path.replace(/^\/{1,}/, "");
|
|
}
|
|
function trimPathRight(path) {
|
|
return path === "/" ? path : path.replace(/\/{1,}$/, "");
|
|
}
|
|
function trimPath(path) {
|
|
return trimPathRight(trimPathLeft(path));
|
|
}
|
|
function removeTrailingSlash(value, basepath) {
|
|
if ((value == null ? void 0 : value.endsWith("/")) && value !== "/" && value !== `${basepath}/`) {
|
|
return value.slice(0, -1);
|
|
}
|
|
return value;
|
|
}
|
|
function exactPathTest(pathName1, pathName2, basepath) {
|
|
return removeTrailingSlash(pathName1, basepath) === removeTrailingSlash(pathName2, basepath);
|
|
}
|
|
function segmentToString(segment) {
|
|
const { type, value } = segment;
|
|
if (type === SEGMENT_TYPE_PATHNAME) {
|
|
return value;
|
|
}
|
|
const { prefixSegment, suffixSegment } = segment;
|
|
if (type === SEGMENT_TYPE_PARAM) {
|
|
const param = value.substring(1);
|
|
if (prefixSegment && suffixSegment) {
|
|
return `${prefixSegment}{$${param}}${suffixSegment}`;
|
|
} else if (prefixSegment) {
|
|
return `${prefixSegment}{$${param}}`;
|
|
} else if (suffixSegment) {
|
|
return `{$${param}}${suffixSegment}`;
|
|
}
|
|
}
|
|
if (type === SEGMENT_TYPE_OPTIONAL_PARAM) {
|
|
const param = value.substring(1);
|
|
if (prefixSegment && suffixSegment) {
|
|
return `${prefixSegment}{-$${param}}${suffixSegment}`;
|
|
} else if (prefixSegment) {
|
|
return `${prefixSegment}{-$${param}}`;
|
|
} else if (suffixSegment) {
|
|
return `{-$${param}}${suffixSegment}`;
|
|
}
|
|
return `{-$${param}}`;
|
|
}
|
|
if (type === SEGMENT_TYPE_WILDCARD) {
|
|
if (prefixSegment && suffixSegment) {
|
|
return `${prefixSegment}{$}${suffixSegment}`;
|
|
} else if (prefixSegment) {
|
|
return `${prefixSegment}{$}`;
|
|
} else if (suffixSegment) {
|
|
return `{$}${suffixSegment}`;
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
function resolvePath({
|
|
basepath,
|
|
base,
|
|
to,
|
|
trailingSlash = "never",
|
|
caseSensitive,
|
|
parseCache
|
|
}) {
|
|
var _a;
|
|
base = removeBasepath(basepath, base, caseSensitive);
|
|
to = removeBasepath(basepath, to, caseSensitive);
|
|
let baseSegments = parsePathname(base, parseCache).slice();
|
|
const toSegments = parsePathname(to, parseCache);
|
|
if (baseSegments.length > 1 && ((_a = last(baseSegments)) == null ? void 0 : _a.value) === "/") {
|
|
baseSegments.pop();
|
|
}
|
|
for (let index = 0, length = toSegments.length; index < length; index++) {
|
|
const toSegment = toSegments[index];
|
|
const value = toSegment.value;
|
|
if (value === "/") {
|
|
if (!index) {
|
|
baseSegments = [toSegment];
|
|
} else if (index === length - 1) {
|
|
baseSegments.push(toSegment);
|
|
} else ;
|
|
} else if (value === "..") {
|
|
baseSegments.pop();
|
|
} else if (value === ".") ;
|
|
else {
|
|
baseSegments.push(toSegment);
|
|
}
|
|
}
|
|
if (baseSegments.length > 1) {
|
|
if (last(baseSegments).value === "/") {
|
|
if (trailingSlash === "never") {
|
|
baseSegments.pop();
|
|
}
|
|
} else if (trailingSlash === "always") {
|
|
baseSegments.push({ type: SEGMENT_TYPE_PATHNAME, value: "/" });
|
|
}
|
|
}
|
|
const segmentValues = baseSegments.map(segmentToString);
|
|
const joined = joinPaths([basepath, ...segmentValues]);
|
|
return joined;
|
|
}
|
|
var parsePathname = (pathname, cache) => {
|
|
if (!pathname) return [];
|
|
const cached = cache == null ? void 0 : cache.get(pathname);
|
|
if (cached) return cached;
|
|
const parsed = baseParsePathname(pathname);
|
|
cache == null ? void 0 : cache.set(pathname, parsed);
|
|
return parsed;
|
|
};
|
|
var PARAM_RE = /^\$.{1,}$/;
|
|
var PARAM_W_CURLY_BRACES_RE = /^(.*?)\{(\$[a-zA-Z_$][a-zA-Z0-9_$]*)\}(.*)$/;
|
|
var OPTIONAL_PARAM_W_CURLY_BRACES_RE = /^(.*?)\{-(\$[a-zA-Z_$][a-zA-Z0-9_$]*)\}(.*)$/;
|
|
var WILDCARD_RE = /^\$$/;
|
|
var WILDCARD_W_CURLY_BRACES_RE = /^(.*?)\{\$\}(.*)$/;
|
|
function baseParsePathname(pathname) {
|
|
pathname = cleanPath(pathname);
|
|
const segments = [];
|
|
if (pathname.slice(0, 1) === "/") {
|
|
pathname = pathname.substring(1);
|
|
segments.push({
|
|
type: SEGMENT_TYPE_PATHNAME,
|
|
value: "/"
|
|
});
|
|
}
|
|
if (!pathname) {
|
|
return segments;
|
|
}
|
|
const split = pathname.split("/").filter(Boolean);
|
|
segments.push(
|
|
...split.map((part) => {
|
|
const wildcardBracesMatch = part.match(WILDCARD_W_CURLY_BRACES_RE);
|
|
if (wildcardBracesMatch) {
|
|
const prefix2 = wildcardBracesMatch[1];
|
|
const suffix = wildcardBracesMatch[2];
|
|
return {
|
|
type: SEGMENT_TYPE_WILDCARD,
|
|
value: "$",
|
|
prefixSegment: prefix2 || void 0,
|
|
suffixSegment: suffix || void 0
|
|
};
|
|
}
|
|
const optionalParamBracesMatch = part.match(
|
|
OPTIONAL_PARAM_W_CURLY_BRACES_RE
|
|
);
|
|
if (optionalParamBracesMatch) {
|
|
const prefix2 = optionalParamBracesMatch[1];
|
|
const paramName = optionalParamBracesMatch[2];
|
|
const suffix = optionalParamBracesMatch[3];
|
|
return {
|
|
type: SEGMENT_TYPE_OPTIONAL_PARAM,
|
|
value: paramName,
|
|
// Now just $paramName (no prefix)
|
|
prefixSegment: prefix2 || void 0,
|
|
suffixSegment: suffix || void 0
|
|
};
|
|
}
|
|
const paramBracesMatch = part.match(PARAM_W_CURLY_BRACES_RE);
|
|
if (paramBracesMatch) {
|
|
const prefix2 = paramBracesMatch[1];
|
|
const paramName = paramBracesMatch[2];
|
|
const suffix = paramBracesMatch[3];
|
|
return {
|
|
type: SEGMENT_TYPE_PARAM,
|
|
value: "" + paramName,
|
|
prefixSegment: prefix2 || void 0,
|
|
suffixSegment: suffix || void 0
|
|
};
|
|
}
|
|
if (PARAM_RE.test(part)) {
|
|
const paramName = part.substring(1);
|
|
return {
|
|
type: SEGMENT_TYPE_PARAM,
|
|
value: "$" + paramName,
|
|
prefixSegment: void 0,
|
|
suffixSegment: void 0
|
|
};
|
|
}
|
|
if (WILDCARD_RE.test(part)) {
|
|
return {
|
|
type: SEGMENT_TYPE_WILDCARD,
|
|
value: "$",
|
|
prefixSegment: void 0,
|
|
suffixSegment: void 0
|
|
};
|
|
}
|
|
return {
|
|
type: SEGMENT_TYPE_PATHNAME,
|
|
value: part.includes("%25") ? part.split("%25").map((segment) => decodeURI(segment)).join("%25") : decodeURI(part)
|
|
};
|
|
})
|
|
);
|
|
if (pathname.slice(-1) === "/") {
|
|
pathname = pathname.substring(1);
|
|
segments.push({
|
|
type: SEGMENT_TYPE_PATHNAME,
|
|
value: "/"
|
|
});
|
|
}
|
|
return segments;
|
|
}
|
|
function interpolatePath({
|
|
path,
|
|
params,
|
|
leaveWildcards,
|
|
leaveParams,
|
|
decodeCharMap,
|
|
parseCache
|
|
}) {
|
|
const interpolatedPathSegments = parsePathname(path, parseCache);
|
|
function encodeParam(key) {
|
|
const value = params[key];
|
|
const isValueString = typeof value === "string";
|
|
if (key === "*" || key === "_splat") {
|
|
return isValueString ? encodeURI(value) : value;
|
|
} else {
|
|
return isValueString ? encodePathParam(value, decodeCharMap) : value;
|
|
}
|
|
}
|
|
let isMissingParams = false;
|
|
const usedParams = {};
|
|
const interpolatedPath = joinPaths(
|
|
interpolatedPathSegments.map((segment) => {
|
|
if (segment.type === SEGMENT_TYPE_PATHNAME) {
|
|
return segment.value;
|
|
}
|
|
if (segment.type === SEGMENT_TYPE_WILDCARD) {
|
|
usedParams._splat = params._splat;
|
|
const segmentPrefix = segment.prefixSegment || "";
|
|
const segmentSuffix = segment.suffixSegment || "";
|
|
if (!("_splat" in params)) {
|
|
isMissingParams = true;
|
|
if (leaveWildcards) {
|
|
return `${segmentPrefix}${segment.value}${segmentSuffix}`;
|
|
}
|
|
if (segmentPrefix || segmentSuffix) {
|
|
return `${segmentPrefix}${segmentSuffix}`;
|
|
}
|
|
return void 0;
|
|
}
|
|
const value = encodeParam("_splat");
|
|
if (leaveWildcards) {
|
|
return `${segmentPrefix}${segment.value}${value ?? ""}${segmentSuffix}`;
|
|
}
|
|
return `${segmentPrefix}${value}${segmentSuffix}`;
|
|
}
|
|
if (segment.type === SEGMENT_TYPE_PARAM) {
|
|
const key = segment.value.substring(1);
|
|
if (!isMissingParams && !(key in params)) {
|
|
isMissingParams = true;
|
|
}
|
|
usedParams[key] = params[key];
|
|
const segmentPrefix = segment.prefixSegment || "";
|
|
const segmentSuffix = segment.suffixSegment || "";
|
|
if (leaveParams) {
|
|
const value = encodeParam(segment.value);
|
|
return `${segmentPrefix}${segment.value}${value ?? ""}${segmentSuffix}`;
|
|
}
|
|
return `${segmentPrefix}${encodeParam(key) ?? "undefined"}${segmentSuffix}`;
|
|
}
|
|
if (segment.type === SEGMENT_TYPE_OPTIONAL_PARAM) {
|
|
const key = segment.value.substring(1);
|
|
const segmentPrefix = segment.prefixSegment || "";
|
|
const segmentSuffix = segment.suffixSegment || "";
|
|
if (!(key in params) || params[key] == null) {
|
|
if (leaveWildcards) {
|
|
return `${segmentPrefix}${key}${segmentSuffix}`;
|
|
}
|
|
if (segmentPrefix || segmentSuffix) {
|
|
return `${segmentPrefix}${segmentSuffix}`;
|
|
}
|
|
return void 0;
|
|
}
|
|
usedParams[key] = params[key];
|
|
if (leaveParams) {
|
|
const value = encodeParam(segment.value);
|
|
return `${segmentPrefix}${segment.value}${value ?? ""}${segmentSuffix}`;
|
|
}
|
|
if (leaveWildcards) {
|
|
return `${segmentPrefix}${key}${encodeParam(key) ?? ""}${segmentSuffix}`;
|
|
}
|
|
return `${segmentPrefix}${encodeParam(key) ?? ""}${segmentSuffix}`;
|
|
}
|
|
return segment.value;
|
|
})
|
|
);
|
|
return { usedParams, interpolatedPath, isMissingParams };
|
|
}
|
|
function encodePathParam(value, decodeCharMap) {
|
|
let encoded = encodeURIComponent(value);
|
|
if (decodeCharMap) {
|
|
for (const [encodedChar, char] of decodeCharMap) {
|
|
encoded = encoded.replaceAll(encodedChar, char);
|
|
}
|
|
}
|
|
return encoded;
|
|
}
|
|
function matchPathname(basepath, currentPathname, matchLocation, parseCache) {
|
|
const pathParams = matchByPath(
|
|
basepath,
|
|
currentPathname,
|
|
matchLocation,
|
|
parseCache
|
|
);
|
|
if (matchLocation.to && !pathParams) {
|
|
return;
|
|
}
|
|
return pathParams ?? {};
|
|
}
|
|
function removeBasepath(basepath, pathname, caseSensitive = false) {
|
|
const normalizedBasepath = caseSensitive ? basepath : basepath.toLowerCase();
|
|
const normalizedPathname = caseSensitive ? pathname : pathname.toLowerCase();
|
|
switch (true) {
|
|
// default behaviour is to serve app from the root - pathname
|
|
// left untouched
|
|
case normalizedBasepath === "/":
|
|
return pathname;
|
|
// shortcut for removing the basepath if it matches the pathname
|
|
case normalizedPathname === normalizedBasepath:
|
|
return "";
|
|
// in case pathname is shorter than basepath - there is
|
|
// nothing to remove
|
|
case pathname.length < basepath.length:
|
|
return pathname;
|
|
// avoid matching partial segments - strict equality handled
|
|
// earlier, otherwise, basepath separated from pathname with
|
|
// separator, therefore lack of separator means partial
|
|
// segment match (`/app` should not match `/application`)
|
|
case normalizedPathname[normalizedBasepath.length] !== "/":
|
|
return pathname;
|
|
// remove the basepath from the pathname if it starts with it
|
|
case normalizedPathname.startsWith(normalizedBasepath):
|
|
return pathname.slice(basepath.length);
|
|
// otherwise, return the pathname as is
|
|
default:
|
|
return pathname;
|
|
}
|
|
}
|
|
function matchByPath(basepath, from, {
|
|
to,
|
|
fuzzy,
|
|
caseSensitive
|
|
}, parseCache) {
|
|
if (basepath !== "/" && !from.startsWith(basepath)) {
|
|
return void 0;
|
|
}
|
|
from = removeBasepath(basepath, from, caseSensitive);
|
|
to = removeBasepath(basepath, `${to ?? "$"}`, caseSensitive);
|
|
const baseSegments = parsePathname(
|
|
from.startsWith("/") ? from : `/${from}`,
|
|
parseCache
|
|
);
|
|
const routeSegments = parsePathname(
|
|
to.startsWith("/") ? to : `/${to}`,
|
|
parseCache
|
|
);
|
|
const params = {};
|
|
const result = isMatch(
|
|
baseSegments,
|
|
routeSegments,
|
|
params,
|
|
fuzzy,
|
|
caseSensitive
|
|
);
|
|
return result ? params : void 0;
|
|
}
|
|
function isMatch(baseSegments, routeSegments, params, fuzzy, caseSensitive) {
|
|
var _a, _b, _c;
|
|
let baseIndex = 0;
|
|
let routeIndex = 0;
|
|
while (baseIndex < baseSegments.length || routeIndex < routeSegments.length) {
|
|
const baseSegment = baseSegments[baseIndex];
|
|
const routeSegment = routeSegments[routeIndex];
|
|
if (routeSegment) {
|
|
if (routeSegment.type === SEGMENT_TYPE_WILDCARD) {
|
|
const remainingBaseSegments = baseSegments.slice(baseIndex);
|
|
let _splat;
|
|
if (routeSegment.prefixSegment || routeSegment.suffixSegment) {
|
|
if (!baseSegment) return false;
|
|
const prefix2 = routeSegment.prefixSegment || "";
|
|
const suffix = routeSegment.suffixSegment || "";
|
|
const baseValue = baseSegment.value;
|
|
if ("prefixSegment" in routeSegment) {
|
|
if (!baseValue.startsWith(prefix2)) {
|
|
return false;
|
|
}
|
|
}
|
|
if ("suffixSegment" in routeSegment) {
|
|
if (!((_a = baseSegments[baseSegments.length - 1]) == null ? void 0 : _a.value.endsWith(suffix))) {
|
|
return false;
|
|
}
|
|
}
|
|
let rejoinedSplat = decodeURI(
|
|
joinPaths(remainingBaseSegments.map((d) => d.value))
|
|
);
|
|
if (prefix2 && rejoinedSplat.startsWith(prefix2)) {
|
|
rejoinedSplat = rejoinedSplat.slice(prefix2.length);
|
|
}
|
|
if (suffix && rejoinedSplat.endsWith(suffix)) {
|
|
rejoinedSplat = rejoinedSplat.slice(
|
|
0,
|
|
rejoinedSplat.length - suffix.length
|
|
);
|
|
}
|
|
_splat = rejoinedSplat;
|
|
} else {
|
|
_splat = decodeURI(
|
|
joinPaths(remainingBaseSegments.map((d) => d.value))
|
|
);
|
|
}
|
|
params["*"] = _splat;
|
|
params["_splat"] = _splat;
|
|
return true;
|
|
}
|
|
if (routeSegment.type === SEGMENT_TYPE_PATHNAME) {
|
|
if (routeSegment.value === "/" && !(baseSegment == null ? void 0 : baseSegment.value)) {
|
|
routeIndex++;
|
|
continue;
|
|
}
|
|
if (baseSegment) {
|
|
if (caseSensitive) {
|
|
if (routeSegment.value !== baseSegment.value) {
|
|
return false;
|
|
}
|
|
} else if (routeSegment.value.toLowerCase() !== baseSegment.value.toLowerCase()) {
|
|
return false;
|
|
}
|
|
baseIndex++;
|
|
routeIndex++;
|
|
continue;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
if (routeSegment.type === SEGMENT_TYPE_PARAM) {
|
|
if (!baseSegment) {
|
|
return false;
|
|
}
|
|
if (baseSegment.value === "/") {
|
|
return false;
|
|
}
|
|
let _paramValue = "";
|
|
let matched = false;
|
|
if (routeSegment.prefixSegment || routeSegment.suffixSegment) {
|
|
const prefix2 = routeSegment.prefixSegment || "";
|
|
const suffix = routeSegment.suffixSegment || "";
|
|
const baseValue = baseSegment.value;
|
|
if (prefix2 && !baseValue.startsWith(prefix2)) {
|
|
return false;
|
|
}
|
|
if (suffix && !baseValue.endsWith(suffix)) {
|
|
return false;
|
|
}
|
|
let paramValue = baseValue;
|
|
if (prefix2 && paramValue.startsWith(prefix2)) {
|
|
paramValue = paramValue.slice(prefix2.length);
|
|
}
|
|
if (suffix && paramValue.endsWith(suffix)) {
|
|
paramValue = paramValue.slice(0, paramValue.length - suffix.length);
|
|
}
|
|
_paramValue = decodeURIComponent(paramValue);
|
|
matched = true;
|
|
} else {
|
|
_paramValue = decodeURIComponent(baseSegment.value);
|
|
matched = true;
|
|
}
|
|
if (matched) {
|
|
params[routeSegment.value.substring(1)] = _paramValue;
|
|
baseIndex++;
|
|
}
|
|
routeIndex++;
|
|
continue;
|
|
}
|
|
if (routeSegment.type === SEGMENT_TYPE_OPTIONAL_PARAM) {
|
|
if (!baseSegment) {
|
|
routeIndex++;
|
|
continue;
|
|
}
|
|
if (baseSegment.value === "/") {
|
|
routeIndex++;
|
|
continue;
|
|
}
|
|
let _paramValue = "";
|
|
let matched = false;
|
|
if (routeSegment.prefixSegment || routeSegment.suffixSegment) {
|
|
const prefix2 = routeSegment.prefixSegment || "";
|
|
const suffix = routeSegment.suffixSegment || "";
|
|
const baseValue = baseSegment.value;
|
|
if ((!prefix2 || baseValue.startsWith(prefix2)) && (!suffix || baseValue.endsWith(suffix))) {
|
|
let paramValue = baseValue;
|
|
if (prefix2 && paramValue.startsWith(prefix2)) {
|
|
paramValue = paramValue.slice(prefix2.length);
|
|
}
|
|
if (suffix && paramValue.endsWith(suffix)) {
|
|
paramValue = paramValue.slice(
|
|
0,
|
|
paramValue.length - suffix.length
|
|
);
|
|
}
|
|
_paramValue = decodeURIComponent(paramValue);
|
|
matched = true;
|
|
}
|
|
} else {
|
|
let shouldMatchOptional = true;
|
|
for (let lookAhead = routeIndex + 1; lookAhead < routeSegments.length; lookAhead++) {
|
|
const futureRouteSegment = routeSegments[lookAhead];
|
|
if ((futureRouteSegment == null ? void 0 : futureRouteSegment.type) === SEGMENT_TYPE_PATHNAME && futureRouteSegment.value === baseSegment.value) {
|
|
shouldMatchOptional = false;
|
|
break;
|
|
}
|
|
if ((futureRouteSegment == null ? void 0 : futureRouteSegment.type) === SEGMENT_TYPE_PARAM || (futureRouteSegment == null ? void 0 : futureRouteSegment.type) === SEGMENT_TYPE_WILDCARD) {
|
|
if (baseSegments.length < routeSegments.length) {
|
|
shouldMatchOptional = false;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
if (shouldMatchOptional) {
|
|
_paramValue = decodeURIComponent(baseSegment.value);
|
|
matched = true;
|
|
}
|
|
}
|
|
if (matched) {
|
|
params[routeSegment.value.substring(1)] = _paramValue;
|
|
baseIndex++;
|
|
}
|
|
routeIndex++;
|
|
continue;
|
|
}
|
|
}
|
|
if (baseIndex < baseSegments.length && routeIndex >= routeSegments.length) {
|
|
params["**"] = joinPaths(
|
|
baseSegments.slice(baseIndex).map((d) => d.value)
|
|
);
|
|
return !!fuzzy && ((_b = routeSegments[routeSegments.length - 1]) == null ? void 0 : _b.value) !== "/";
|
|
}
|
|
if (routeIndex < routeSegments.length && baseIndex >= baseSegments.length) {
|
|
for (let i = routeIndex; i < routeSegments.length; i++) {
|
|
if (((_c = routeSegments[i]) == null ? void 0 : _c.type) !== SEGMENT_TYPE_OPTIONAL_PARAM) {
|
|
return false;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/not-found.js
|
|
function notFound(options = {}) {
|
|
options.isNotFound = true;
|
|
if (options.throw) throw options;
|
|
return options;
|
|
}
|
|
function isNotFound(obj) {
|
|
return !!(obj == null ? void 0 : obj.isNotFound);
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/scroll-restoration.js
|
|
function getSafeSessionStorage() {
|
|
try {
|
|
if (typeof window !== "undefined" && typeof window.sessionStorage === "object") {
|
|
return window.sessionStorage;
|
|
}
|
|
} catch {
|
|
return void 0;
|
|
}
|
|
return void 0;
|
|
}
|
|
var storageKey = "tsr-scroll-restoration-v1_3";
|
|
var throttle = (fn, wait) => {
|
|
let timeout;
|
|
return (...args) => {
|
|
if (!timeout) {
|
|
timeout = setTimeout(() => {
|
|
fn(...args);
|
|
timeout = null;
|
|
}, wait);
|
|
}
|
|
};
|
|
};
|
|
function createScrollRestorationCache() {
|
|
const safeSessionStorage = getSafeSessionStorage();
|
|
if (!safeSessionStorage) {
|
|
return void 0;
|
|
}
|
|
const persistedState = safeSessionStorage.getItem(storageKey);
|
|
let state = persistedState ? JSON.parse(persistedState) : {};
|
|
return {
|
|
state,
|
|
// This setter is simply to make sure that we set the sessionStorage right
|
|
// after the state is updated. It doesn't necessarily need to be a functional
|
|
// update.
|
|
set: (updater) => (state = functionalUpdate(updater, state) || state, safeSessionStorage.setItem(storageKey, JSON.stringify(state)))
|
|
};
|
|
}
|
|
var scrollRestorationCache = createScrollRestorationCache();
|
|
var defaultGetScrollRestorationKey = (location) => {
|
|
return location.state.__TSR_key || location.href;
|
|
};
|
|
function getCssSelector(el) {
|
|
const path = [];
|
|
let parent;
|
|
while (parent = el.parentNode) {
|
|
path.unshift(
|
|
`${el.tagName}:nth-child(${[].indexOf.call(parent.children, el) + 1})`
|
|
);
|
|
el = parent;
|
|
}
|
|
return `${path.join(" > ")}`.toLowerCase();
|
|
}
|
|
var ignoreScroll = false;
|
|
function restoreScroll({
|
|
storageKey: storageKey2,
|
|
key,
|
|
behavior,
|
|
shouldScrollRestoration,
|
|
scrollToTopSelectors,
|
|
location
|
|
}) {
|
|
var _a;
|
|
let byKey;
|
|
try {
|
|
byKey = JSON.parse(sessionStorage.getItem(storageKey2) || "{}");
|
|
} catch (error) {
|
|
console.error(error);
|
|
return;
|
|
}
|
|
const resolvedKey = key || ((_a = window.history.state) == null ? void 0 : _a.key);
|
|
const elementEntries = byKey[resolvedKey];
|
|
ignoreScroll = true;
|
|
(() => {
|
|
if (shouldScrollRestoration && elementEntries && Object.keys(elementEntries).length > 0) {
|
|
for (const elementSelector in elementEntries) {
|
|
const entry = elementEntries[elementSelector];
|
|
if (elementSelector === "window") {
|
|
window.scrollTo({
|
|
top: entry.scrollY,
|
|
left: entry.scrollX,
|
|
behavior
|
|
});
|
|
} else if (elementSelector) {
|
|
const element = document.querySelector(elementSelector);
|
|
if (element) {
|
|
element.scrollLeft = entry.scrollX;
|
|
element.scrollTop = entry.scrollY;
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
const hash = (location ?? window.location).hash.split("#")[1];
|
|
if (hash) {
|
|
const hashScrollIntoViewOptions = (window.history.state || {}).__hashScrollIntoViewOptions ?? true;
|
|
if (hashScrollIntoViewOptions) {
|
|
const el = document.getElementById(hash);
|
|
if (el) {
|
|
el.scrollIntoView(hashScrollIntoViewOptions);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
[
|
|
"window",
|
|
...(scrollToTopSelectors == null ? void 0 : scrollToTopSelectors.filter((d) => d !== "window")) ?? []
|
|
].forEach((selector) => {
|
|
const element = selector === "window" ? window : typeof selector === "function" ? selector() : document.querySelector(selector);
|
|
if (element) {
|
|
element.scrollTo({
|
|
top: 0,
|
|
left: 0,
|
|
behavior
|
|
});
|
|
}
|
|
});
|
|
})();
|
|
ignoreScroll = false;
|
|
}
|
|
function setupScrollRestoration(router, force) {
|
|
if (scrollRestorationCache === void 0) {
|
|
return;
|
|
}
|
|
const shouldScrollRestoration = force ?? router.options.scrollRestoration ?? false;
|
|
if (shouldScrollRestoration) {
|
|
router.isScrollRestoring = true;
|
|
}
|
|
if (typeof document === "undefined" || router.isScrollRestorationSetup) {
|
|
return;
|
|
}
|
|
router.isScrollRestorationSetup = true;
|
|
ignoreScroll = false;
|
|
const getKey = router.options.getScrollRestorationKey || defaultGetScrollRestorationKey;
|
|
window.history.scrollRestoration = "manual";
|
|
const onScroll = (event) => {
|
|
if (ignoreScroll || !router.isScrollRestoring) {
|
|
return;
|
|
}
|
|
let elementSelector = "";
|
|
if (event.target === document || event.target === window) {
|
|
elementSelector = "window";
|
|
} else {
|
|
const attrId = event.target.getAttribute(
|
|
"data-scroll-restoration-id"
|
|
);
|
|
if (attrId) {
|
|
elementSelector = `[data-scroll-restoration-id="${attrId}"]`;
|
|
} else {
|
|
elementSelector = getCssSelector(event.target);
|
|
}
|
|
}
|
|
const restoreKey = getKey(router.state.location);
|
|
scrollRestorationCache.set((state) => {
|
|
const keyEntry = state[restoreKey] = state[restoreKey] || {};
|
|
const elementEntry = keyEntry[elementSelector] = keyEntry[elementSelector] || {};
|
|
if (elementSelector === "window") {
|
|
elementEntry.scrollX = window.scrollX || 0;
|
|
elementEntry.scrollY = window.scrollY || 0;
|
|
} else if (elementSelector) {
|
|
const element = document.querySelector(elementSelector);
|
|
if (element) {
|
|
elementEntry.scrollX = element.scrollLeft || 0;
|
|
elementEntry.scrollY = element.scrollTop || 0;
|
|
}
|
|
}
|
|
return state;
|
|
});
|
|
};
|
|
if (typeof document !== "undefined") {
|
|
document.addEventListener("scroll", throttle(onScroll, 100), true);
|
|
}
|
|
router.subscribe("onRendered", (event) => {
|
|
const cacheKey = getKey(event.toLocation);
|
|
if (!router.resetNextScroll) {
|
|
router.resetNextScroll = true;
|
|
return;
|
|
}
|
|
restoreScroll({
|
|
storageKey,
|
|
key: cacheKey,
|
|
behavior: router.options.scrollRestorationBehavior,
|
|
shouldScrollRestoration: router.isScrollRestoring,
|
|
scrollToTopSelectors: router.options.scrollToTopSelectors,
|
|
location: router.history.location
|
|
});
|
|
if (router.isScrollRestoring) {
|
|
scrollRestorationCache.set((state) => {
|
|
state[cacheKey] = state[cacheKey] || {};
|
|
return state;
|
|
});
|
|
}
|
|
});
|
|
}
|
|
function handleHashScroll(router) {
|
|
if (typeof document !== "undefined" && document.querySelector) {
|
|
const hashScrollIntoViewOptions = router.state.location.state.__hashScrollIntoViewOptions ?? true;
|
|
if (hashScrollIntoViewOptions && router.state.location.hash !== "") {
|
|
const el = document.getElementById(router.state.location.hash);
|
|
if (el) {
|
|
el.scrollIntoView(hashScrollIntoViewOptions);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/qss.js
|
|
function encode(obj, pfx) {
|
|
const normalizedObject = Object.entries(obj).flatMap(([key, value]) => {
|
|
if (Array.isArray(value)) {
|
|
return value.map((v) => [key, String(v)]);
|
|
} else {
|
|
return [[key, String(value)]];
|
|
}
|
|
});
|
|
const searchParams = new URLSearchParams(normalizedObject);
|
|
return (pfx || "") + searchParams.toString();
|
|
}
|
|
function toValue(str) {
|
|
if (!str) return "";
|
|
if (str === "false") return false;
|
|
if (str === "true") return true;
|
|
return +str * 0 === 0 && +str + "" === str ? +str : str;
|
|
}
|
|
function decode(str, pfx) {
|
|
const searchParamsPart = pfx ? str.slice(pfx.length) : str;
|
|
const searchParams = new URLSearchParams(searchParamsPart);
|
|
const entries = [...searchParams.entries()];
|
|
return entries.reduce((acc, [key, value]) => {
|
|
const previousValue = acc[key];
|
|
if (previousValue == null) {
|
|
acc[key] = toValue(value);
|
|
} else {
|
|
acc[key] = Array.isArray(previousValue) ? [...previousValue, toValue(value)] : [previousValue, toValue(value)];
|
|
}
|
|
return acc;
|
|
}, {});
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/searchParams.js
|
|
var defaultParseSearch = parseSearchWith(JSON.parse);
|
|
var defaultStringifySearch = stringifySearchWith(
|
|
JSON.stringify,
|
|
JSON.parse
|
|
);
|
|
function parseSearchWith(parser) {
|
|
return (searchStr) => {
|
|
if (searchStr.substring(0, 1) === "?") {
|
|
searchStr = searchStr.substring(1);
|
|
}
|
|
const query = decode(searchStr);
|
|
for (const key in query) {
|
|
const value = query[key];
|
|
if (typeof value === "string") {
|
|
try {
|
|
query[key] = parser(value);
|
|
} catch (err) {
|
|
}
|
|
}
|
|
}
|
|
return query;
|
|
};
|
|
}
|
|
function stringifySearchWith(stringify, parser) {
|
|
function stringifyValue(val) {
|
|
if (typeof val === "object" && val !== null) {
|
|
try {
|
|
return stringify(val);
|
|
} catch (err) {
|
|
}
|
|
} else if (typeof val === "string" && typeof parser === "function") {
|
|
try {
|
|
parser(val);
|
|
return stringify(val);
|
|
} catch (err) {
|
|
}
|
|
}
|
|
return val;
|
|
}
|
|
return (search) => {
|
|
search = { ...search };
|
|
Object.keys(search).forEach((key) => {
|
|
const val = search[key];
|
|
if (typeof val === "undefined" || val === void 0) {
|
|
delete search[key];
|
|
} else {
|
|
search[key] = stringifyValue(val);
|
|
}
|
|
});
|
|
const searchStr = encode(search).toString();
|
|
return searchStr ? `?${searchStr}` : "";
|
|
};
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/root.js
|
|
var rootRouteId = "__root__";
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/redirect.js
|
|
function redirect(opts) {
|
|
opts.statusCode = opts.statusCode || opts.code || 307;
|
|
if (!opts.reloadDocument) {
|
|
try {
|
|
new URL(`${opts.href}`);
|
|
opts.reloadDocument = true;
|
|
} catch {
|
|
}
|
|
}
|
|
const headers = new Headers(opts.headers || {});
|
|
if (opts.href && headers.get("Location") === null) {
|
|
headers.set("Location", opts.href);
|
|
}
|
|
const response = new Response(null, {
|
|
status: opts.statusCode,
|
|
headers
|
|
});
|
|
response.options = opts;
|
|
if (opts.throw) {
|
|
throw response;
|
|
}
|
|
return response;
|
|
}
|
|
function isRedirect(obj) {
|
|
return obj instanceof Response && !!obj.options;
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/lru-cache.js
|
|
function createLRUCache(max) {
|
|
const cache = /* @__PURE__ */ new Map();
|
|
let oldest;
|
|
let newest;
|
|
const touch = (entry) => {
|
|
if (!entry.next) return;
|
|
if (!entry.prev) {
|
|
entry.next.prev = void 0;
|
|
oldest = entry.next;
|
|
entry.next = void 0;
|
|
if (newest) {
|
|
entry.prev = newest;
|
|
newest.next = entry;
|
|
}
|
|
} else {
|
|
entry.prev.next = entry.next;
|
|
entry.next.prev = entry.prev;
|
|
entry.next = void 0;
|
|
if (newest) {
|
|
newest.next = entry;
|
|
entry.prev = newest;
|
|
}
|
|
}
|
|
newest = entry;
|
|
};
|
|
return {
|
|
get(key) {
|
|
const entry = cache.get(key);
|
|
if (!entry) return void 0;
|
|
touch(entry);
|
|
return entry.value;
|
|
},
|
|
set(key, value) {
|
|
if (cache.size >= max && oldest) {
|
|
const toDelete = oldest;
|
|
cache.delete(toDelete.key);
|
|
if (toDelete.next) {
|
|
oldest = toDelete.next;
|
|
toDelete.next.prev = void 0;
|
|
}
|
|
if (toDelete === newest) {
|
|
newest = void 0;
|
|
}
|
|
}
|
|
const existing = cache.get(key);
|
|
if (existing) {
|
|
existing.value = value;
|
|
touch(existing);
|
|
} else {
|
|
const entry = { key, value, prev: newest };
|
|
if (newest) newest.next = entry;
|
|
newest = entry;
|
|
if (!oldest) oldest = entry;
|
|
cache.set(key, entry);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/router.js
|
|
function defaultSerializeError(err) {
|
|
if (err instanceof Error) {
|
|
const obj = {
|
|
name: err.name,
|
|
message: err.message
|
|
};
|
|
if (true) {
|
|
obj.stack = err.stack;
|
|
}
|
|
return obj;
|
|
}
|
|
return {
|
|
data: err
|
|
};
|
|
}
|
|
function getLocationChangeInfo(routerState) {
|
|
const fromLocation = routerState.resolvedLocation;
|
|
const toLocation = routerState.location;
|
|
const pathChanged = (fromLocation == null ? void 0 : fromLocation.pathname) !== toLocation.pathname;
|
|
const hrefChanged = (fromLocation == null ? void 0 : fromLocation.href) !== toLocation.href;
|
|
const hashChanged = (fromLocation == null ? void 0 : fromLocation.hash) !== toLocation.hash;
|
|
return { fromLocation, toLocation, pathChanged, hrefChanged, hashChanged };
|
|
}
|
|
var RouterCore = class {
|
|
/**
|
|
* @deprecated Use the `createRouter` function instead
|
|
*/
|
|
constructor(options) {
|
|
this.tempLocationKey = `${Math.round(
|
|
Math.random() * 1e7
|
|
)}`;
|
|
this.resetNextScroll = true;
|
|
this.shouldViewTransition = void 0;
|
|
this.isViewTransitionTypesSupported = void 0;
|
|
this.subscribers = /* @__PURE__ */ new Set();
|
|
this.isScrollRestoring = false;
|
|
this.isScrollRestorationSetup = false;
|
|
this.startTransition = (fn) => fn();
|
|
this.update = (newOptions) => {
|
|
var _a;
|
|
if (newOptions.notFoundRoute) {
|
|
console.warn(
|
|
"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."
|
|
);
|
|
}
|
|
const previousOptions = this.options;
|
|
this.options = {
|
|
...this.options,
|
|
...newOptions
|
|
};
|
|
this.isServer = this.options.isServer ?? typeof document === "undefined";
|
|
this.pathParamsDecodeCharMap = this.options.pathParamsAllowedCharacters ? new Map(
|
|
this.options.pathParamsAllowedCharacters.map((char) => [
|
|
encodeURIComponent(char),
|
|
char
|
|
])
|
|
) : void 0;
|
|
if (!this.basepath || newOptions.basepath && newOptions.basepath !== previousOptions.basepath) {
|
|
if (newOptions.basepath === void 0 || newOptions.basepath === "" || newOptions.basepath === "/") {
|
|
this.basepath = "/";
|
|
} else {
|
|
this.basepath = `/${trimPath(newOptions.basepath)}`;
|
|
}
|
|
}
|
|
if (!this.history || this.options.history && this.options.history !== this.history) {
|
|
this.history = this.options.history ?? (this.isServer ? createMemoryHistory({
|
|
initialEntries: [this.basepath || "/"]
|
|
}) : createBrowserHistory());
|
|
this.updateLatestLocation();
|
|
}
|
|
if (this.options.routeTree !== this.routeTree) {
|
|
this.routeTree = this.options.routeTree;
|
|
this.buildRouteTree();
|
|
}
|
|
if (!this.__store) {
|
|
this.__store = new Store(getInitialRouterState(this.latestLocation), {
|
|
onUpdate: () => {
|
|
this.__store.state = {
|
|
...this.state,
|
|
cachedMatches: this.state.cachedMatches.filter(
|
|
(d) => !["redirected"].includes(d.status)
|
|
)
|
|
};
|
|
}
|
|
});
|
|
setupScrollRestoration(this);
|
|
}
|
|
if (typeof window !== "undefined" && "CSS" in window && typeof ((_a = window.CSS) == null ? void 0 : _a.supports) === "function") {
|
|
this.isViewTransitionTypesSupported = window.CSS.supports(
|
|
"selector(:active-view-transition-type(a)"
|
|
);
|
|
}
|
|
};
|
|
this.updateLatestLocation = () => {
|
|
this.latestLocation = this.parseLocation(
|
|
this.history.location,
|
|
this.latestLocation
|
|
);
|
|
};
|
|
this.buildRouteTree = () => {
|
|
const { routesById, routesByPath, flatRoutes } = processRouteTree({
|
|
routeTree: this.routeTree,
|
|
initRoute: (route, i) => {
|
|
route.init({
|
|
originalIndex: i
|
|
});
|
|
}
|
|
});
|
|
this.routesById = routesById;
|
|
this.routesByPath = routesByPath;
|
|
this.flatRoutes = flatRoutes;
|
|
const notFoundRoute = this.options.notFoundRoute;
|
|
if (notFoundRoute) {
|
|
notFoundRoute.init({
|
|
originalIndex: 99999999999
|
|
});
|
|
this.routesById[notFoundRoute.id] = notFoundRoute;
|
|
}
|
|
};
|
|
this.subscribe = (eventType, fn) => {
|
|
const listener = {
|
|
eventType,
|
|
fn
|
|
};
|
|
this.subscribers.add(listener);
|
|
return () => {
|
|
this.subscribers.delete(listener);
|
|
};
|
|
};
|
|
this.emit = (routerEvent) => {
|
|
this.subscribers.forEach((listener) => {
|
|
if (listener.eventType === routerEvent.type) {
|
|
listener.fn(routerEvent);
|
|
}
|
|
});
|
|
};
|
|
this.parseLocation = (locationToParse, previousLocation) => {
|
|
const parse = ({
|
|
pathname,
|
|
search,
|
|
hash,
|
|
state
|
|
}) => {
|
|
const parsedSearch = this.options.parseSearch(search);
|
|
const searchStr = this.options.stringifySearch(parsedSearch);
|
|
return {
|
|
pathname,
|
|
searchStr,
|
|
search: replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.search, parsedSearch),
|
|
hash: hash.split("#").reverse()[0] ?? "",
|
|
href: `${pathname}${searchStr}${hash}`,
|
|
state: replaceEqualDeep(previousLocation == null ? void 0 : previousLocation.state, state)
|
|
};
|
|
};
|
|
const location = parse(locationToParse);
|
|
const { __tempLocation, __tempKey } = location.state;
|
|
if (__tempLocation && (!__tempKey || __tempKey === this.tempLocationKey)) {
|
|
const parsedTempLocation = parse(__tempLocation);
|
|
parsedTempLocation.state.key = location.state.key;
|
|
parsedTempLocation.state.__TSR_key = location.state.__TSR_key;
|
|
delete parsedTempLocation.state.__tempLocation;
|
|
return {
|
|
...parsedTempLocation,
|
|
maskedLocation: location
|
|
};
|
|
}
|
|
return location;
|
|
};
|
|
this.resolvePathWithBase = (from, path) => {
|
|
const resolvedPath = resolvePath({
|
|
basepath: this.basepath,
|
|
base: from,
|
|
to: cleanPath(path),
|
|
trailingSlash: this.options.trailingSlash,
|
|
caseSensitive: this.options.caseSensitive,
|
|
parseCache: this.parsePathnameCache
|
|
});
|
|
return resolvedPath;
|
|
};
|
|
this.matchRoutes = (pathnameOrNext, locationSearchOrOpts, opts) => {
|
|
if (typeof pathnameOrNext === "string") {
|
|
return this.matchRoutesInternal(
|
|
{
|
|
pathname: pathnameOrNext,
|
|
search: locationSearchOrOpts
|
|
},
|
|
opts
|
|
);
|
|
}
|
|
return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts);
|
|
};
|
|
this.parsePathnameCache = createLRUCache(1e3);
|
|
this.getMatchedRoutes = (pathname, routePathname) => {
|
|
return getMatchedRoutes({
|
|
pathname,
|
|
routePathname,
|
|
basepath: this.basepath,
|
|
caseSensitive: this.options.caseSensitive,
|
|
routesByPath: this.routesByPath,
|
|
routesById: this.routesById,
|
|
flatRoutes: this.flatRoutes,
|
|
parseCache: this.parsePathnameCache
|
|
});
|
|
};
|
|
this.cancelMatch = (id) => {
|
|
const match = this.getMatch(id);
|
|
if (!match) return;
|
|
match.abortController.abort();
|
|
match._nonReactive.pendingTimeout = void 0;
|
|
clearTimeout(match._nonReactive.pendingTimeout);
|
|
};
|
|
this.cancelMatches = () => {
|
|
var _a;
|
|
(_a = this.state.pendingMatches) == null ? void 0 : _a.forEach((match) => {
|
|
this.cancelMatch(match.id);
|
|
});
|
|
};
|
|
this.buildLocation = (opts) => {
|
|
const build = (dest = {}) => {
|
|
var _a;
|
|
const currentLocation = dest._fromLocation || this.latestLocation;
|
|
const allCurrentLocationMatches = this.matchRoutes(currentLocation, {
|
|
_buildLocation: true
|
|
});
|
|
const lastMatch = last(allCurrentLocationMatches);
|
|
let fromPath = this.resolvePathWithBase(lastMatch.fullPath, ".");
|
|
const toPath = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
|
|
const routeIsChanging = !!dest.to && !comparePaths(dest.to.toString(), fromPath) && !comparePaths(toPath, fromPath);
|
|
if (dest.unsafeRelative === "path") {
|
|
fromPath = currentLocation.pathname;
|
|
} else if (routeIsChanging && dest.from) {
|
|
fromPath = dest.from;
|
|
if (dest._isNavigate) {
|
|
const allFromMatches = this.getMatchedRoutes(
|
|
dest.from,
|
|
void 0
|
|
).matchedRoutes;
|
|
const matchedFrom = [...allCurrentLocationMatches].reverse().find((d) => {
|
|
return comparePaths(d.fullPath, fromPath);
|
|
});
|
|
const matchedCurrent = [...allFromMatches].reverse().find((d) => {
|
|
return comparePaths(d.fullPath, currentLocation.pathname);
|
|
});
|
|
if (!matchedFrom && !matchedCurrent) {
|
|
console.warn(`Could not find match for from: ${fromPath}`);
|
|
}
|
|
}
|
|
}
|
|
fromPath = this.resolvePathWithBase(fromPath, ".");
|
|
const fromSearch = lastMatch.search;
|
|
const fromParams = { ...lastMatch.params };
|
|
const nextTo = dest.to ? this.resolvePathWithBase(fromPath, `${dest.to}`) : this.resolvePathWithBase(fromPath, ".");
|
|
let nextParams = dest.params === false || dest.params === null ? {} : (dest.params ?? true) === true ? fromParams : {
|
|
...fromParams,
|
|
...functionalUpdate(dest.params, fromParams)
|
|
};
|
|
const interpolatedNextTo = interpolatePath({
|
|
path: nextTo,
|
|
params: nextParams ?? {},
|
|
parseCache: this.parsePathnameCache
|
|
}).interpolatedPath;
|
|
const destRoutes = this.matchRoutes(interpolatedNextTo, void 0, {
|
|
_buildLocation: true
|
|
}).map((d) => this.looseRoutesById[d.routeId]);
|
|
if (Object.keys(nextParams).length > 0) {
|
|
destRoutes.map((route) => {
|
|
var _a2;
|
|
return ((_a2 = route.options.params) == null ? void 0 : _a2.stringify) ?? route.options.stringifyParams;
|
|
}).filter(Boolean).forEach((fn) => {
|
|
nextParams = { ...nextParams, ...fn(nextParams) };
|
|
});
|
|
}
|
|
const nextPathname = interpolatePath({
|
|
// Use the original template path for interpolation
|
|
// This preserves the original parameter syntax including optional parameters
|
|
path: nextTo,
|
|
params: nextParams ?? {},
|
|
leaveWildcards: false,
|
|
leaveParams: opts.leaveParams,
|
|
decodeCharMap: this.pathParamsDecodeCharMap,
|
|
parseCache: this.parsePathnameCache
|
|
}).interpolatedPath;
|
|
let nextSearch = fromSearch;
|
|
if (opts._includeValidateSearch && ((_a = this.options.search) == null ? void 0 : _a.strict)) {
|
|
let validatedSearch = {};
|
|
destRoutes.forEach((route) => {
|
|
try {
|
|
if (route.options.validateSearch) {
|
|
validatedSearch = {
|
|
...validatedSearch,
|
|
...validateSearch(route.options.validateSearch, {
|
|
...validatedSearch,
|
|
...nextSearch
|
|
}) ?? {}
|
|
};
|
|
}
|
|
} catch {
|
|
}
|
|
});
|
|
nextSearch = validatedSearch;
|
|
}
|
|
nextSearch = applySearchMiddleware({
|
|
search: nextSearch,
|
|
dest,
|
|
destRoutes,
|
|
_includeValidateSearch: opts._includeValidateSearch
|
|
});
|
|
nextSearch = replaceEqualDeep(fromSearch, nextSearch);
|
|
const searchStr = this.options.stringifySearch(nextSearch);
|
|
const hash = dest.hash === true ? currentLocation.hash : dest.hash ? functionalUpdate(dest.hash, currentLocation.hash) : void 0;
|
|
const hashStr = hash ? `#${hash}` : "";
|
|
let nextState = dest.state === true ? currentLocation.state : dest.state ? functionalUpdate(dest.state, currentLocation.state) : {};
|
|
nextState = replaceEqualDeep(currentLocation.state, nextState);
|
|
return {
|
|
pathname: nextPathname,
|
|
search: nextSearch,
|
|
searchStr,
|
|
state: nextState,
|
|
hash: hash ?? "",
|
|
href: `${nextPathname}${searchStr}${hashStr}`,
|
|
unmaskOnReload: dest.unmaskOnReload
|
|
};
|
|
};
|
|
const buildWithMatches = (dest = {}, maskedDest) => {
|
|
var _a;
|
|
const next = build(dest);
|
|
let maskedNext = maskedDest ? build(maskedDest) : void 0;
|
|
if (!maskedNext) {
|
|
let params = {};
|
|
const foundMask = (_a = this.options.routeMasks) == null ? void 0 : _a.find((d) => {
|
|
const match = matchPathname(
|
|
this.basepath,
|
|
next.pathname,
|
|
{
|
|
to: d.from,
|
|
caseSensitive: false,
|
|
fuzzy: false
|
|
},
|
|
this.parsePathnameCache
|
|
);
|
|
if (match) {
|
|
params = match;
|
|
return true;
|
|
}
|
|
return false;
|
|
});
|
|
if (foundMask) {
|
|
const { from: _from, ...maskProps } = foundMask;
|
|
maskedDest = {
|
|
...pick(opts, ["from"]),
|
|
...maskProps,
|
|
params
|
|
};
|
|
maskedNext = build(maskedDest);
|
|
}
|
|
}
|
|
if (maskedNext) {
|
|
const maskedFinal = build(maskedDest);
|
|
next.maskedLocation = maskedFinal;
|
|
}
|
|
return next;
|
|
};
|
|
if (opts.mask) {
|
|
return buildWithMatches(opts, {
|
|
...pick(opts, ["from"]),
|
|
...opts.mask
|
|
});
|
|
}
|
|
return buildWithMatches(opts);
|
|
};
|
|
this.commitLocation = ({
|
|
viewTransition,
|
|
ignoreBlocker,
|
|
...next
|
|
}) => {
|
|
const isSameState = () => {
|
|
const ignoredProps = [
|
|
"key",
|
|
// TODO: Remove in v2 - use __TSR_key instead
|
|
"__TSR_key",
|
|
"__TSR_index",
|
|
"__hashScrollIntoViewOptions"
|
|
];
|
|
ignoredProps.forEach((prop) => {
|
|
next.state[prop] = this.latestLocation.state[prop];
|
|
});
|
|
const isEqual = deepEqual(next.state, this.latestLocation.state);
|
|
ignoredProps.forEach((prop) => {
|
|
delete next.state[prop];
|
|
});
|
|
return isEqual;
|
|
};
|
|
const isSameUrl = this.latestLocation.href === next.href;
|
|
const previousCommitPromise = this.commitLocationPromise;
|
|
this.commitLocationPromise = createControlledPromise(() => {
|
|
previousCommitPromise == null ? void 0 : previousCommitPromise.resolve();
|
|
});
|
|
if (isSameUrl && isSameState()) {
|
|
this.load();
|
|
} else {
|
|
let { maskedLocation, hashScrollIntoView, ...nextHistory } = next;
|
|
if (maskedLocation) {
|
|
nextHistory = {
|
|
...maskedLocation,
|
|
state: {
|
|
...maskedLocation.state,
|
|
__tempKey: void 0,
|
|
__tempLocation: {
|
|
...nextHistory,
|
|
search: nextHistory.searchStr,
|
|
state: {
|
|
...nextHistory.state,
|
|
__tempKey: void 0,
|
|
__tempLocation: void 0,
|
|
__TSR_key: void 0,
|
|
key: void 0
|
|
// TODO: Remove in v2 - use __TSR_key instead
|
|
}
|
|
}
|
|
}
|
|
};
|
|
if (nextHistory.unmaskOnReload ?? this.options.unmaskOnReload ?? false) {
|
|
nextHistory.state.__tempKey = this.tempLocationKey;
|
|
}
|
|
}
|
|
nextHistory.state.__hashScrollIntoViewOptions = hashScrollIntoView ?? this.options.defaultHashScrollIntoView ?? true;
|
|
this.shouldViewTransition = viewTransition;
|
|
this.history[next.replace ? "replace" : "push"](
|
|
nextHistory.href,
|
|
nextHistory.state,
|
|
{ ignoreBlocker }
|
|
);
|
|
}
|
|
this.resetNextScroll = next.resetScroll ?? true;
|
|
if (!this.history.subscribers.size) {
|
|
this.load();
|
|
}
|
|
return this.commitLocationPromise;
|
|
};
|
|
this.buildAndCommitLocation = ({
|
|
replace,
|
|
resetScroll,
|
|
hashScrollIntoView,
|
|
viewTransition,
|
|
ignoreBlocker,
|
|
href,
|
|
...rest
|
|
} = {}) => {
|
|
if (href) {
|
|
const currentIndex = this.history.location.state.__TSR_index;
|
|
const parsed = parseHref(href, {
|
|
__TSR_index: replace ? currentIndex : currentIndex + 1
|
|
});
|
|
rest.to = parsed.pathname;
|
|
rest.search = this.options.parseSearch(parsed.search);
|
|
rest.hash = parsed.hash.slice(1);
|
|
}
|
|
const location = this.buildLocation({
|
|
...rest,
|
|
_includeValidateSearch: true
|
|
});
|
|
return this.commitLocation({
|
|
...location,
|
|
viewTransition,
|
|
replace,
|
|
resetScroll,
|
|
hashScrollIntoView,
|
|
ignoreBlocker
|
|
});
|
|
};
|
|
this.navigate = ({ to, reloadDocument, href, ...rest }) => {
|
|
if (!reloadDocument && href) {
|
|
try {
|
|
new URL(`${href}`);
|
|
reloadDocument = true;
|
|
} catch {
|
|
}
|
|
}
|
|
if (reloadDocument) {
|
|
if (!href) {
|
|
const location = this.buildLocation({ to, ...rest });
|
|
href = this.history.createHref(location.href);
|
|
}
|
|
if (rest.replace) {
|
|
window.location.replace(href);
|
|
} else {
|
|
window.location.href = href;
|
|
}
|
|
return Promise.resolve();
|
|
}
|
|
return this.buildAndCommitLocation({
|
|
...rest,
|
|
href,
|
|
to,
|
|
_isNavigate: true
|
|
});
|
|
};
|
|
this.beforeLoad = () => {
|
|
this.cancelMatches();
|
|
this.updateLatestLocation();
|
|
if (this.isServer) {
|
|
const nextLocation = this.buildLocation({
|
|
to: this.latestLocation.pathname,
|
|
search: true,
|
|
params: true,
|
|
hash: true,
|
|
state: true,
|
|
_includeValidateSearch: true
|
|
});
|
|
const normalizeUrl = (url) => {
|
|
try {
|
|
return encodeURI(decodeURI(url));
|
|
} catch {
|
|
return url;
|
|
}
|
|
};
|
|
if (trimPath(normalizeUrl(this.latestLocation.href)) !== trimPath(normalizeUrl(nextLocation.href))) {
|
|
throw redirect({ href: nextLocation.href });
|
|
}
|
|
}
|
|
const pendingMatches = this.matchRoutes(this.latestLocation);
|
|
this.__store.setState((s) => ({
|
|
...s,
|
|
status: "pending",
|
|
statusCode: 200,
|
|
isLoading: true,
|
|
location: this.latestLocation,
|
|
pendingMatches,
|
|
// If a cached moved to pendingMatches, remove it from cachedMatches
|
|
cachedMatches: s.cachedMatches.filter(
|
|
(d) => !pendingMatches.some((e) => e.id === d.id)
|
|
)
|
|
}));
|
|
};
|
|
this.load = async (opts) => {
|
|
let redirect2;
|
|
let notFound2;
|
|
let loadPromise;
|
|
loadPromise = new Promise((resolve) => {
|
|
this.startTransition(async () => {
|
|
var _a;
|
|
try {
|
|
this.beforeLoad();
|
|
const next = this.latestLocation;
|
|
const prevLocation = this.state.resolvedLocation;
|
|
if (!this.state.redirect) {
|
|
this.emit({
|
|
type: "onBeforeNavigate",
|
|
...getLocationChangeInfo({
|
|
resolvedLocation: prevLocation,
|
|
location: next
|
|
})
|
|
});
|
|
}
|
|
this.emit({
|
|
type: "onBeforeLoad",
|
|
...getLocationChangeInfo({
|
|
resolvedLocation: prevLocation,
|
|
location: next
|
|
})
|
|
});
|
|
await this.loadMatches({
|
|
sync: opts == null ? void 0 : opts.sync,
|
|
matches: this.state.pendingMatches,
|
|
location: next,
|
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
onReady: async () => {
|
|
this.startViewTransition(async () => {
|
|
let exitingMatches;
|
|
let enteringMatches;
|
|
let stayingMatches;
|
|
batch(() => {
|
|
this.__store.setState((s) => {
|
|
const previousMatches = s.matches;
|
|
const newMatches = s.pendingMatches || s.matches;
|
|
exitingMatches = previousMatches.filter(
|
|
(match) => !newMatches.some((d) => d.id === match.id)
|
|
);
|
|
enteringMatches = newMatches.filter(
|
|
(match) => !previousMatches.some((d) => d.id === match.id)
|
|
);
|
|
stayingMatches = previousMatches.filter(
|
|
(match) => newMatches.some((d) => d.id === match.id)
|
|
);
|
|
return {
|
|
...s,
|
|
isLoading: false,
|
|
loadedAt: Date.now(),
|
|
matches: newMatches,
|
|
pendingMatches: void 0,
|
|
cachedMatches: [
|
|
...s.cachedMatches,
|
|
...exitingMatches.filter((d) => d.status !== "error")
|
|
]
|
|
};
|
|
});
|
|
this.clearExpiredCache();
|
|
});
|
|
[
|
|
[exitingMatches, "onLeave"],
|
|
[enteringMatches, "onEnter"],
|
|
[stayingMatches, "onStay"]
|
|
].forEach(([matches, hook]) => {
|
|
matches.forEach((match) => {
|
|
var _a2, _b;
|
|
(_b = (_a2 = this.looseRoutesById[match.routeId].options)[hook]) == null ? void 0 : _b.call(_a2, match);
|
|
});
|
|
});
|
|
});
|
|
}
|
|
});
|
|
} catch (err) {
|
|
if (isRedirect(err)) {
|
|
redirect2 = err;
|
|
if (!this.isServer) {
|
|
this.navigate({
|
|
...redirect2.options,
|
|
replace: true,
|
|
ignoreBlocker: true
|
|
});
|
|
}
|
|
} else if (isNotFound(err)) {
|
|
notFound2 = err;
|
|
}
|
|
this.__store.setState((s) => ({
|
|
...s,
|
|
statusCode: redirect2 ? redirect2.status : notFound2 ? 404 : s.matches.some((d) => d.status === "error") ? 500 : 200,
|
|
redirect: redirect2
|
|
}));
|
|
}
|
|
if (this.latestLoadPromise === loadPromise) {
|
|
(_a = this.commitLocationPromise) == null ? void 0 : _a.resolve();
|
|
this.latestLoadPromise = void 0;
|
|
this.commitLocationPromise = void 0;
|
|
}
|
|
resolve();
|
|
});
|
|
});
|
|
this.latestLoadPromise = loadPromise;
|
|
await loadPromise;
|
|
while (this.latestLoadPromise && loadPromise !== this.latestLoadPromise) {
|
|
await this.latestLoadPromise;
|
|
}
|
|
if (this.hasNotFoundMatch()) {
|
|
this.__store.setState((s) => ({
|
|
...s,
|
|
statusCode: 404
|
|
}));
|
|
}
|
|
};
|
|
this.startViewTransition = (fn) => {
|
|
const shouldViewTransition = this.shouldViewTransition ?? this.options.defaultViewTransition;
|
|
delete this.shouldViewTransition;
|
|
if (shouldViewTransition && typeof document !== "undefined" && "startViewTransition" in document && typeof document.startViewTransition === "function") {
|
|
let startViewTransitionParams;
|
|
if (typeof shouldViewTransition === "object" && this.isViewTransitionTypesSupported) {
|
|
const next = this.latestLocation;
|
|
const prevLocation = this.state.resolvedLocation;
|
|
const resolvedViewTransitionTypes = typeof shouldViewTransition.types === "function" ? shouldViewTransition.types(
|
|
getLocationChangeInfo({
|
|
resolvedLocation: prevLocation,
|
|
location: next
|
|
})
|
|
) : shouldViewTransition.types;
|
|
startViewTransitionParams = {
|
|
update: fn,
|
|
types: resolvedViewTransitionTypes
|
|
};
|
|
} else {
|
|
startViewTransitionParams = fn;
|
|
}
|
|
document.startViewTransition(startViewTransitionParams);
|
|
} else {
|
|
fn();
|
|
}
|
|
};
|
|
this.updateMatch = (id, updater) => {
|
|
var _a;
|
|
const matchesKey = ((_a = this.state.pendingMatches) == null ? void 0 : _a.some((d) => d.id === id)) ? "pendingMatches" : this.state.matches.some((d) => d.id === id) ? "matches" : this.state.cachedMatches.some((d) => d.id === id) ? "cachedMatches" : "";
|
|
if (matchesKey) {
|
|
this.__store.setState((s) => {
|
|
var _a2;
|
|
return {
|
|
...s,
|
|
[matchesKey]: (_a2 = s[matchesKey]) == null ? void 0 : _a2.map((d) => d.id === id ? updater(d) : d)
|
|
};
|
|
});
|
|
}
|
|
};
|
|
this.getMatch = (matchId) => {
|
|
var _a;
|
|
const findFn = (d) => d.id === matchId;
|
|
return this.state.cachedMatches.find(findFn) ?? ((_a = this.state.pendingMatches) == null ? void 0 : _a.find(findFn)) ?? this.state.matches.find(findFn);
|
|
};
|
|
this.loadMatches = async ({
|
|
location,
|
|
matches,
|
|
preload: allPreload,
|
|
onReady,
|
|
updateMatch = this.updateMatch,
|
|
sync
|
|
}) => {
|
|
let firstBadMatchIndex;
|
|
let rendered = false;
|
|
const triggerOnReady = async () => {
|
|
if (!rendered) {
|
|
rendered = true;
|
|
await (onReady == null ? void 0 : onReady());
|
|
}
|
|
};
|
|
const resolvePreload = (matchId) => {
|
|
return !!(allPreload && !this.state.matches.some((d) => d.id === matchId));
|
|
};
|
|
if (!this.isServer && this.state.matches.some((d) => d._forcePending)) {
|
|
triggerOnReady();
|
|
}
|
|
const handleRedirectAndNotFound = (match, err) => {
|
|
var _a, _b, _c;
|
|
if (isRedirect(err) || isNotFound(err)) {
|
|
if (isRedirect(err)) {
|
|
if (err.redirectHandled) {
|
|
if (!err.options.reloadDocument) {
|
|
throw err;
|
|
}
|
|
}
|
|
}
|
|
(_a = match._nonReactive.beforeLoadPromise) == null ? void 0 : _a.resolve();
|
|
(_b = match._nonReactive.loaderPromise) == null ? void 0 : _b.resolve();
|
|
match._nonReactive.beforeLoadPromise = void 0;
|
|
match._nonReactive.loaderPromise = void 0;
|
|
updateMatch(match.id, (prev) => ({
|
|
...prev,
|
|
status: isRedirect(err) ? "redirected" : isNotFound(err) ? "notFound" : "error",
|
|
isFetching: false,
|
|
error: err
|
|
}));
|
|
if (!err.routeId) {
|
|
err.routeId = match.routeId;
|
|
}
|
|
(_c = match._nonReactive.loadPromise) == null ? void 0 : _c.resolve();
|
|
if (isRedirect(err)) {
|
|
rendered = true;
|
|
err.options._fromLocation = location;
|
|
err.redirectHandled = true;
|
|
err = this.resolveRedirect(err);
|
|
throw err;
|
|
} else if (isNotFound(err)) {
|
|
this._handleNotFound(matches, err, {
|
|
updateMatch
|
|
});
|
|
throw err;
|
|
}
|
|
}
|
|
};
|
|
const shouldSkipLoader = (matchId) => {
|
|
const match = this.getMatch(matchId);
|
|
if (!this.isServer && match._nonReactive.dehydrated) {
|
|
return true;
|
|
}
|
|
if (this.isServer) {
|
|
if (match.ssr === false) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
try {
|
|
await new Promise((resolveAll, rejectAll) => {
|
|
;
|
|
(async () => {
|
|
var _a, _b, _c, _d;
|
|
try {
|
|
const handleSerialError = (index, err, routerCode) => {
|
|
var _a2, _b2;
|
|
const { id: matchId, routeId } = matches[index];
|
|
const route = this.looseRoutesById[routeId];
|
|
if (err instanceof Promise) {
|
|
throw err;
|
|
}
|
|
err.routerCode = routerCode;
|
|
firstBadMatchIndex = firstBadMatchIndex ?? index;
|
|
handleRedirectAndNotFound(this.getMatch(matchId), err);
|
|
try {
|
|
(_b2 = (_a2 = route.options).onError) == null ? void 0 : _b2.call(_a2, err);
|
|
} catch (errorHandlerErr) {
|
|
err = errorHandlerErr;
|
|
handleRedirectAndNotFound(this.getMatch(matchId), err);
|
|
}
|
|
updateMatch(matchId, (prev) => {
|
|
var _a3, _b3;
|
|
(_a3 = prev._nonReactive.beforeLoadPromise) == null ? void 0 : _a3.resolve();
|
|
prev._nonReactive.beforeLoadPromise = void 0;
|
|
(_b3 = prev._nonReactive.loadPromise) == null ? void 0 : _b3.resolve();
|
|
return {
|
|
...prev,
|
|
error: err,
|
|
status: "error",
|
|
isFetching: false,
|
|
updatedAt: Date.now(),
|
|
abortController: new AbortController()
|
|
};
|
|
});
|
|
};
|
|
for (const [index, { id: matchId, routeId }] of matches.entries()) {
|
|
const existingMatch = this.getMatch(matchId);
|
|
const parentMatchId = (_a = matches[index - 1]) == null ? void 0 : _a.id;
|
|
const parentMatch = parentMatchId ? this.getMatch(parentMatchId) : void 0;
|
|
const route = this.looseRoutesById[routeId];
|
|
const pendingMs = route.options.pendingMs ?? this.options.defaultPendingMs;
|
|
if (this.isServer) {
|
|
let ssr;
|
|
if (this.isShell()) {
|
|
ssr = matchId === rootRouteId;
|
|
} else {
|
|
const defaultSsr = this.options.defaultSsr ?? true;
|
|
if ((parentMatch == null ? void 0 : parentMatch.ssr) === false) {
|
|
ssr = false;
|
|
} else {
|
|
let tempSsr;
|
|
if (route.options.ssr === void 0) {
|
|
tempSsr = defaultSsr;
|
|
} else if (typeof route.options.ssr === "function") {
|
|
let makeMaybe = function(value, error) {
|
|
if (error) {
|
|
return { status: "error", error };
|
|
}
|
|
return { status: "success", value };
|
|
};
|
|
const { search, params } = this.getMatch(matchId);
|
|
const ssrFnContext = {
|
|
search: makeMaybe(search, existingMatch.searchError),
|
|
params: makeMaybe(params, existingMatch.paramsError),
|
|
location,
|
|
matches: matches.map((match) => ({
|
|
index: match.index,
|
|
pathname: match.pathname,
|
|
fullPath: match.fullPath,
|
|
staticData: match.staticData,
|
|
id: match.id,
|
|
routeId: match.routeId,
|
|
search: makeMaybe(match.search, match.searchError),
|
|
params: makeMaybe(match.params, match.paramsError),
|
|
ssr: match.ssr
|
|
}))
|
|
};
|
|
tempSsr = await route.options.ssr(ssrFnContext) ?? defaultSsr;
|
|
} else {
|
|
tempSsr = route.options.ssr;
|
|
}
|
|
if (tempSsr === true && (parentMatch == null ? void 0 : parentMatch.ssr) === "data-only") {
|
|
ssr = "data-only";
|
|
} else {
|
|
ssr = tempSsr;
|
|
}
|
|
}
|
|
}
|
|
existingMatch.ssr = ssr;
|
|
}
|
|
if (shouldSkipLoader(matchId)) {
|
|
continue;
|
|
}
|
|
const shouldPending = !!(onReady && !this.isServer && !resolvePreload(matchId) && (route.options.loader || route.options.beforeLoad || routeNeedsPreload(route)) && typeof pendingMs === "number" && pendingMs !== Infinity && (route.options.pendingComponent ?? ((_b = this.options) == null ? void 0 : _b.defaultPendingComponent)));
|
|
let executeBeforeLoad = true;
|
|
const setupPendingTimeout = () => {
|
|
const match = this.getMatch(matchId);
|
|
if (shouldPending && match._nonReactive.pendingTimeout === void 0) {
|
|
const pendingTimeout = setTimeout(() => {
|
|
try {
|
|
triggerOnReady();
|
|
} catch {
|
|
}
|
|
}, pendingMs);
|
|
match._nonReactive.pendingTimeout = pendingTimeout;
|
|
}
|
|
};
|
|
if (
|
|
// If we are in the middle of a load, either of these will be present
|
|
// (not to be confused with `loadPromise`, which is always defined)
|
|
existingMatch._nonReactive.beforeLoadPromise || existingMatch._nonReactive.loaderPromise
|
|
) {
|
|
setupPendingTimeout();
|
|
await existingMatch._nonReactive.beforeLoadPromise;
|
|
const match = this.getMatch(matchId);
|
|
if (match.status === "error") {
|
|
executeBeforeLoad = true;
|
|
} else if (match.preload && (match.status === "redirected" || match.status === "notFound")) {
|
|
handleRedirectAndNotFound(match, match.error);
|
|
}
|
|
}
|
|
if (executeBeforeLoad) {
|
|
try {
|
|
const match = this.getMatch(matchId);
|
|
match._nonReactive.beforeLoadPromise = createControlledPromise();
|
|
const prevLoadPromise = match._nonReactive.loadPromise;
|
|
match._nonReactive.loadPromise = createControlledPromise(() => {
|
|
prevLoadPromise == null ? void 0 : prevLoadPromise.resolve();
|
|
});
|
|
const { paramsError, searchError } = this.getMatch(matchId);
|
|
if (paramsError) {
|
|
handleSerialError(index, paramsError, "PARSE_PARAMS");
|
|
}
|
|
if (searchError) {
|
|
handleSerialError(index, searchError, "VALIDATE_SEARCH");
|
|
}
|
|
setupPendingTimeout();
|
|
const abortController = new AbortController();
|
|
const parentMatchContext = (parentMatch == null ? void 0 : parentMatch.context) ?? this.options.context ?? void 0;
|
|
updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
isFetching: "beforeLoad",
|
|
fetchCount: prev.fetchCount + 1,
|
|
abortController,
|
|
context: {
|
|
...parentMatchContext,
|
|
...prev.__routeContext
|
|
}
|
|
}));
|
|
const { search, params, context, cause } = this.getMatch(matchId);
|
|
const preload = resolvePreload(matchId);
|
|
const beforeLoadFnContext = {
|
|
search,
|
|
abortController,
|
|
params,
|
|
preload,
|
|
context,
|
|
location,
|
|
navigate: (opts) => this.navigate({ ...opts, _fromLocation: location }),
|
|
buildLocation: this.buildLocation,
|
|
cause: preload ? "preload" : cause,
|
|
matches
|
|
};
|
|
const beforeLoadContext = await ((_d = (_c = route.options).beforeLoad) == null ? void 0 : _d.call(_c, beforeLoadFnContext));
|
|
if (isRedirect(beforeLoadContext) || isNotFound(beforeLoadContext)) {
|
|
handleSerialError(index, beforeLoadContext, "BEFORE_LOAD");
|
|
}
|
|
updateMatch(matchId, (prev) => {
|
|
return {
|
|
...prev,
|
|
__beforeLoadContext: beforeLoadContext,
|
|
context: {
|
|
...parentMatchContext,
|
|
...prev.__routeContext,
|
|
...beforeLoadContext
|
|
},
|
|
abortController
|
|
};
|
|
});
|
|
} catch (err) {
|
|
handleSerialError(index, err, "BEFORE_LOAD");
|
|
}
|
|
updateMatch(matchId, (prev) => {
|
|
var _a2;
|
|
(_a2 = prev._nonReactive.beforeLoadPromise) == null ? void 0 : _a2.resolve();
|
|
prev._nonReactive.beforeLoadPromise = void 0;
|
|
return {
|
|
...prev,
|
|
isFetching: false
|
|
};
|
|
});
|
|
}
|
|
}
|
|
const validResolvedMatches = matches.slice(0, firstBadMatchIndex);
|
|
const matchPromises = [];
|
|
validResolvedMatches.forEach(({ id: matchId, routeId }, index) => {
|
|
matchPromises.push(
|
|
(async () => {
|
|
var _a2, _b2;
|
|
let loaderShouldRunAsync = false;
|
|
let loaderIsRunningAsync = false;
|
|
const route = this.looseRoutesById[routeId];
|
|
const executeHead = async () => {
|
|
var _a3, _b3, _c2, _d2, _e, _f;
|
|
const match = this.getMatch(matchId);
|
|
if (!match) {
|
|
return;
|
|
}
|
|
const assetContext = {
|
|
matches,
|
|
match,
|
|
params: match.params,
|
|
loaderData: match.loaderData
|
|
};
|
|
const headFnContent = await ((_b3 = (_a3 = route.options).head) == null ? void 0 : _b3.call(_a3, assetContext));
|
|
const meta = headFnContent == null ? void 0 : headFnContent.meta;
|
|
const links = headFnContent == null ? void 0 : headFnContent.links;
|
|
const headScripts = headFnContent == null ? void 0 : headFnContent.scripts;
|
|
const styles = headFnContent == null ? void 0 : headFnContent.styles;
|
|
const scripts = await ((_d2 = (_c2 = route.options).scripts) == null ? void 0 : _d2.call(_c2, assetContext));
|
|
const headers = await ((_f = (_e = route.options).headers) == null ? void 0 : _f.call(_e, assetContext));
|
|
return {
|
|
meta,
|
|
links,
|
|
headScripts,
|
|
headers,
|
|
scripts,
|
|
styles
|
|
};
|
|
};
|
|
const potentialPendingMinPromise = async () => {
|
|
const latestMatch = this.getMatch(matchId);
|
|
if (latestMatch._nonReactive.minPendingPromise) {
|
|
await latestMatch._nonReactive.minPendingPromise;
|
|
}
|
|
};
|
|
const prevMatch = this.getMatch(matchId);
|
|
if (shouldSkipLoader(matchId)) {
|
|
if (this.isServer) {
|
|
const head = await executeHead();
|
|
updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
...head
|
|
}));
|
|
return this.getMatch(matchId);
|
|
}
|
|
} else if (prevMatch._nonReactive.loaderPromise) {
|
|
if (prevMatch.status === "success" && !sync && !prevMatch.preload) {
|
|
return this.getMatch(matchId);
|
|
}
|
|
await prevMatch._nonReactive.loaderPromise;
|
|
const match = this.getMatch(matchId);
|
|
if (match.error) {
|
|
handleRedirectAndNotFound(match, match.error);
|
|
}
|
|
} else {
|
|
const parentMatchPromise = matchPromises[index - 1];
|
|
const getLoaderContext = () => {
|
|
const {
|
|
params,
|
|
loaderDeps,
|
|
abortController,
|
|
context,
|
|
cause
|
|
} = this.getMatch(matchId);
|
|
const preload2 = resolvePreload(matchId);
|
|
return {
|
|
params,
|
|
deps: loaderDeps,
|
|
preload: !!preload2,
|
|
parentMatchPromise,
|
|
abortController,
|
|
context,
|
|
location,
|
|
navigate: (opts) => this.navigate({ ...opts, _fromLocation: location }),
|
|
cause: preload2 ? "preload" : cause,
|
|
route
|
|
};
|
|
};
|
|
const age = Date.now() - this.getMatch(matchId).updatedAt;
|
|
const preload = resolvePreload(matchId);
|
|
const staleAge = preload ? route.options.preloadStaleTime ?? this.options.defaultPreloadStaleTime ?? 3e4 : route.options.staleTime ?? this.options.defaultStaleTime ?? 0;
|
|
const shouldReloadOption = route.options.shouldReload;
|
|
const shouldReload = typeof shouldReloadOption === "function" ? shouldReloadOption(getLoaderContext()) : shouldReloadOption;
|
|
updateMatch(matchId, (prev) => {
|
|
prev._nonReactive.loaderPromise = createControlledPromise();
|
|
return {
|
|
...prev,
|
|
preload: !!preload && !this.state.matches.some((d) => d.id === matchId)
|
|
};
|
|
});
|
|
const runLoader = async () => {
|
|
var _a3, _b3, _c2, _d2;
|
|
try {
|
|
try {
|
|
if (!this.isServer || this.isServer && this.getMatch(matchId).ssr === true) {
|
|
this.loadRouteChunk(route);
|
|
}
|
|
updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
isFetching: "loader"
|
|
}));
|
|
const loaderData = await ((_b3 = (_a3 = route.options).loader) == null ? void 0 : _b3.call(_a3, getLoaderContext()));
|
|
handleRedirectAndNotFound(
|
|
this.getMatch(matchId),
|
|
loaderData
|
|
);
|
|
updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
loaderData
|
|
}));
|
|
await route._lazyPromise;
|
|
const head = await executeHead();
|
|
await potentialPendingMinPromise();
|
|
await route._componentsPromise;
|
|
updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
error: void 0,
|
|
status: "success",
|
|
isFetching: false,
|
|
updatedAt: Date.now(),
|
|
...head
|
|
}));
|
|
} catch (e) {
|
|
let error = e;
|
|
await potentialPendingMinPromise();
|
|
handleRedirectAndNotFound(this.getMatch(matchId), e);
|
|
try {
|
|
(_d2 = (_c2 = route.options).onError) == null ? void 0 : _d2.call(_c2, e);
|
|
} catch (onErrorError) {
|
|
error = onErrorError;
|
|
handleRedirectAndNotFound(
|
|
this.getMatch(matchId),
|
|
onErrorError
|
|
);
|
|
}
|
|
const head = await executeHead();
|
|
updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
error,
|
|
status: "error",
|
|
isFetching: false,
|
|
...head
|
|
}));
|
|
}
|
|
} catch (err) {
|
|
const head = await executeHead();
|
|
updateMatch(matchId, (prev) => {
|
|
prev._nonReactive.loaderPromise = void 0;
|
|
return {
|
|
...prev,
|
|
...head
|
|
};
|
|
});
|
|
handleRedirectAndNotFound(this.getMatch(matchId), err);
|
|
}
|
|
};
|
|
const { status, invalid } = this.getMatch(matchId);
|
|
loaderShouldRunAsync = status === "success" && (invalid || (shouldReload ?? age > staleAge));
|
|
if (preload && route.options.preload === false) {
|
|
} else if (loaderShouldRunAsync && !sync) {
|
|
loaderIsRunningAsync = true;
|
|
(async () => {
|
|
var _a3, _b3;
|
|
try {
|
|
await runLoader();
|
|
const match = this.getMatch(matchId);
|
|
(_a3 = match._nonReactive.loaderPromise) == null ? void 0 : _a3.resolve();
|
|
(_b3 = match._nonReactive.loadPromise) == null ? void 0 : _b3.resolve();
|
|
match._nonReactive.loaderPromise = void 0;
|
|
} catch (err) {
|
|
if (isRedirect(err)) {
|
|
await this.navigate(err.options);
|
|
}
|
|
}
|
|
})();
|
|
} else if (status !== "success" || loaderShouldRunAsync && sync) {
|
|
await runLoader();
|
|
} else {
|
|
const head = await executeHead();
|
|
updateMatch(matchId, (prev) => ({
|
|
...prev,
|
|
...head
|
|
}));
|
|
}
|
|
}
|
|
if (!loaderIsRunningAsync) {
|
|
const match = this.getMatch(matchId);
|
|
(_a2 = match._nonReactive.loaderPromise) == null ? void 0 : _a2.resolve();
|
|
(_b2 = match._nonReactive.loadPromise) == null ? void 0 : _b2.resolve();
|
|
}
|
|
updateMatch(matchId, (prev) => {
|
|
clearTimeout(prev._nonReactive.pendingTimeout);
|
|
prev._nonReactive.pendingTimeout = void 0;
|
|
if (!loaderIsRunningAsync)
|
|
prev._nonReactive.loaderPromise = void 0;
|
|
prev._nonReactive.dehydrated = void 0;
|
|
return {
|
|
...prev,
|
|
isFetching: loaderIsRunningAsync ? prev.isFetching : false,
|
|
invalid: false
|
|
};
|
|
});
|
|
return this.getMatch(matchId);
|
|
})()
|
|
);
|
|
});
|
|
await Promise.all(matchPromises);
|
|
resolveAll();
|
|
} catch (err) {
|
|
rejectAll(err);
|
|
}
|
|
})();
|
|
});
|
|
await triggerOnReady();
|
|
} catch (err) {
|
|
if (isRedirect(err) || isNotFound(err)) {
|
|
if (isNotFound(err) && !allPreload) {
|
|
await triggerOnReady();
|
|
}
|
|
throw err;
|
|
}
|
|
}
|
|
return matches;
|
|
};
|
|
this.invalidate = (opts) => {
|
|
const invalidate = (d) => {
|
|
var _a;
|
|
if (((_a = opts == null ? void 0 : opts.filter) == null ? void 0 : _a.call(opts, d)) ?? true) {
|
|
return {
|
|
...d,
|
|
invalid: true,
|
|
...(opts == null ? void 0 : opts.forcePending) || d.status === "error" ? { status: "pending", error: void 0 } : void 0
|
|
};
|
|
}
|
|
return d;
|
|
};
|
|
this.__store.setState((s) => {
|
|
var _a;
|
|
return {
|
|
...s,
|
|
matches: s.matches.map(invalidate),
|
|
cachedMatches: s.cachedMatches.map(invalidate),
|
|
pendingMatches: (_a = s.pendingMatches) == null ? void 0 : _a.map(invalidate)
|
|
};
|
|
});
|
|
this.shouldViewTransition = false;
|
|
return this.load({ sync: opts == null ? void 0 : opts.sync });
|
|
};
|
|
this.resolveRedirect = (redirect2) => {
|
|
if (!redirect2.options.href) {
|
|
redirect2.options.href = this.buildLocation(redirect2.options).href;
|
|
redirect2.headers.set("Location", redirect2.options.href);
|
|
}
|
|
if (!redirect2.headers.get("Location")) {
|
|
redirect2.headers.set("Location", redirect2.options.href);
|
|
}
|
|
return redirect2;
|
|
};
|
|
this.clearCache = (opts) => {
|
|
const filter = opts == null ? void 0 : opts.filter;
|
|
if (filter !== void 0) {
|
|
this.__store.setState((s) => {
|
|
return {
|
|
...s,
|
|
cachedMatches: s.cachedMatches.filter(
|
|
(m) => !filter(m)
|
|
)
|
|
};
|
|
});
|
|
} else {
|
|
this.__store.setState((s) => {
|
|
return {
|
|
...s,
|
|
cachedMatches: []
|
|
};
|
|
});
|
|
}
|
|
};
|
|
this.clearExpiredCache = () => {
|
|
const filter = (d) => {
|
|
const route = this.looseRoutesById[d.routeId];
|
|
if (!route.options.loader) {
|
|
return true;
|
|
}
|
|
const gcTime = (d.preload ? route.options.preloadGcTime ?? this.options.defaultPreloadGcTime : route.options.gcTime ?? this.options.defaultGcTime) ?? 5 * 60 * 1e3;
|
|
const isError = d.status === "error";
|
|
if (isError) return true;
|
|
const gcEligible = Date.now() - d.updatedAt >= gcTime;
|
|
return gcEligible;
|
|
};
|
|
this.clearCache({ filter });
|
|
};
|
|
this.loadRouteChunk = (route) => {
|
|
if (route._lazyPromise === void 0) {
|
|
if (route.lazyFn) {
|
|
route._lazyPromise = route.lazyFn().then((lazyRoute) => {
|
|
const { id: _id, ...options2 } = lazyRoute.options;
|
|
Object.assign(route.options, options2);
|
|
});
|
|
} else {
|
|
route._lazyPromise = Promise.resolve();
|
|
}
|
|
}
|
|
if (route._componentsPromise === void 0) {
|
|
route._componentsPromise = route._lazyPromise.then(
|
|
() => Promise.all(
|
|
componentTypes.map(async (type) => {
|
|
const component = route.options[type];
|
|
if (component == null ? void 0 : component.preload) {
|
|
await component.preload();
|
|
}
|
|
})
|
|
)
|
|
);
|
|
}
|
|
return route._componentsPromise;
|
|
};
|
|
this.preloadRoute = async (opts) => {
|
|
const next = this.buildLocation(opts);
|
|
let matches = this.matchRoutes(next, {
|
|
throwOnError: true,
|
|
preload: true,
|
|
dest: opts
|
|
});
|
|
const activeMatchIds = new Set(
|
|
[...this.state.matches, ...this.state.pendingMatches ?? []].map(
|
|
(d) => d.id
|
|
)
|
|
);
|
|
const loadedMatchIds = /* @__PURE__ */ new Set([
|
|
...activeMatchIds,
|
|
...this.state.cachedMatches.map((d) => d.id)
|
|
]);
|
|
batch(() => {
|
|
matches.forEach((match) => {
|
|
if (!loadedMatchIds.has(match.id)) {
|
|
this.__store.setState((s) => ({
|
|
...s,
|
|
cachedMatches: [...s.cachedMatches, match]
|
|
}));
|
|
}
|
|
});
|
|
});
|
|
try {
|
|
matches = await this.loadMatches({
|
|
matches,
|
|
location: next,
|
|
preload: true,
|
|
updateMatch: (id, updater) => {
|
|
if (activeMatchIds.has(id)) {
|
|
matches = matches.map((d) => d.id === id ? updater(d) : d);
|
|
} else {
|
|
this.updateMatch(id, updater);
|
|
}
|
|
}
|
|
});
|
|
return matches;
|
|
} catch (err) {
|
|
if (isRedirect(err)) {
|
|
if (err.options.reloadDocument) {
|
|
return void 0;
|
|
}
|
|
return await this.preloadRoute({
|
|
...err.options,
|
|
_fromLocation: next
|
|
});
|
|
}
|
|
if (!isNotFound(err)) {
|
|
console.error(err);
|
|
}
|
|
return void 0;
|
|
}
|
|
};
|
|
this.matchRoute = (location, opts) => {
|
|
const matchLocation = {
|
|
...location,
|
|
to: location.to ? this.resolvePathWithBase(
|
|
location.from || "",
|
|
location.to
|
|
) : void 0,
|
|
params: location.params || {},
|
|
leaveParams: true
|
|
};
|
|
const next = this.buildLocation(matchLocation);
|
|
if ((opts == null ? void 0 : opts.pending) && this.state.status !== "pending") {
|
|
return false;
|
|
}
|
|
const pending = (opts == null ? void 0 : opts.pending) === void 0 ? !this.state.isLoading : opts.pending;
|
|
const baseLocation = pending ? this.latestLocation : this.state.resolvedLocation || this.state.location;
|
|
const match = matchPathname(
|
|
this.basepath,
|
|
baseLocation.pathname,
|
|
{
|
|
...opts,
|
|
to: next.pathname
|
|
},
|
|
this.parsePathnameCache
|
|
);
|
|
if (!match) {
|
|
return false;
|
|
}
|
|
if (location.params) {
|
|
if (!deepEqual(match, location.params, { partial: true })) {
|
|
return false;
|
|
}
|
|
}
|
|
if (match && ((opts == null ? void 0 : opts.includeSearch) ?? true)) {
|
|
return deepEqual(baseLocation.search, next.search, { partial: true }) ? match : false;
|
|
}
|
|
return match;
|
|
};
|
|
this._handleNotFound = (matches, err, {
|
|
updateMatch = this.updateMatch
|
|
} = {}) => {
|
|
var _a;
|
|
const routeCursor = this.routesById[err.routeId ?? ""] ?? this.routeTree;
|
|
const matchesByRouteId = {};
|
|
for (const match of matches) {
|
|
matchesByRouteId[match.routeId] = match;
|
|
}
|
|
if (!routeCursor.options.notFoundComponent && ((_a = this.options) == null ? void 0 : _a.defaultNotFoundComponent)) {
|
|
routeCursor.options.notFoundComponent = this.options.defaultNotFoundComponent;
|
|
}
|
|
invariant(
|
|
routeCursor.options.notFoundComponent,
|
|
"No notFoundComponent found. Please set a notFoundComponent on your route or provide a defaultNotFoundComponent to the router."
|
|
);
|
|
const matchForRoute = matchesByRouteId[routeCursor.id];
|
|
invariant(
|
|
matchForRoute,
|
|
"Could not find match for route: " + routeCursor.id
|
|
);
|
|
updateMatch(matchForRoute.id, (prev) => ({
|
|
...prev,
|
|
status: "notFound",
|
|
error: err,
|
|
isFetching: false
|
|
}));
|
|
if (err.routerCode === "BEFORE_LOAD" && routeCursor.parentRoute) {
|
|
err.routeId = routeCursor.parentRoute.id;
|
|
this._handleNotFound(matches, err, {
|
|
updateMatch
|
|
});
|
|
}
|
|
};
|
|
this.hasNotFoundMatch = () => {
|
|
return this.__store.state.matches.some(
|
|
(d) => d.status === "notFound" || d.globalNotFound
|
|
);
|
|
};
|
|
this.update({
|
|
defaultPreloadDelay: 50,
|
|
defaultPendingMs: 1e3,
|
|
defaultPendingMinMs: 500,
|
|
context: void 0,
|
|
...options,
|
|
caseSensitive: options.caseSensitive ?? false,
|
|
notFoundMode: options.notFoundMode ?? "fuzzy",
|
|
stringifySearch: options.stringifySearch ?? defaultStringifySearch,
|
|
parseSearch: options.parseSearch ?? defaultParseSearch
|
|
});
|
|
if (typeof document !== "undefined") {
|
|
self.__TSR_ROUTER__ = this;
|
|
}
|
|
}
|
|
isShell() {
|
|
return !!this.options.isShell;
|
|
}
|
|
isPrerendering() {
|
|
return !!this.options.isPrerendering;
|
|
}
|
|
get state() {
|
|
return this.__store.state;
|
|
}
|
|
get looseRoutesById() {
|
|
return this.routesById;
|
|
}
|
|
matchRoutesInternal(next, opts) {
|
|
var _a;
|
|
const { foundRoute, matchedRoutes, routeParams } = this.getMatchedRoutes(
|
|
next.pathname,
|
|
(_a = opts == null ? void 0 : opts.dest) == null ? void 0 : _a.to
|
|
);
|
|
let isGlobalNotFound = false;
|
|
if (
|
|
// If we found a route, and it's not an index route and we have left over path
|
|
foundRoute ? foundRoute.path !== "/" && routeParams["**"] : (
|
|
// Or if we didn't find a route and we have left over path
|
|
trimPathRight(next.pathname)
|
|
)
|
|
) {
|
|
if (this.options.notFoundRoute) {
|
|
matchedRoutes.push(this.options.notFoundRoute);
|
|
} else {
|
|
isGlobalNotFound = true;
|
|
}
|
|
}
|
|
const globalNotFoundRouteId = (() => {
|
|
if (!isGlobalNotFound) {
|
|
return void 0;
|
|
}
|
|
if (this.options.notFoundMode !== "root") {
|
|
for (let i = matchedRoutes.length - 1; i >= 0; i--) {
|
|
const route = matchedRoutes[i];
|
|
if (route.children) {
|
|
return route.id;
|
|
}
|
|
}
|
|
}
|
|
return rootRouteId;
|
|
})();
|
|
const parseErrors = matchedRoutes.map((route) => {
|
|
var _a2;
|
|
let parsedParamsError;
|
|
const parseParams = ((_a2 = route.options.params) == null ? void 0 : _a2.parse) ?? route.options.parseParams;
|
|
if (parseParams) {
|
|
try {
|
|
const parsedParams = parseParams(routeParams);
|
|
Object.assign(routeParams, parsedParams);
|
|
} catch (err) {
|
|
parsedParamsError = new PathParamError(err.message, {
|
|
cause: err
|
|
});
|
|
if (opts == null ? void 0 : opts.throwOnError) {
|
|
throw parsedParamsError;
|
|
}
|
|
return parsedParamsError;
|
|
}
|
|
}
|
|
return;
|
|
});
|
|
const matches = [];
|
|
const getParentContext = (parentMatch) => {
|
|
const parentMatchId = parentMatch == null ? void 0 : parentMatch.id;
|
|
const parentContext = !parentMatchId ? this.options.context ?? void 0 : parentMatch.context ?? this.options.context ?? void 0;
|
|
return parentContext;
|
|
};
|
|
matchedRoutes.forEach((route, index) => {
|
|
var _a2, _b;
|
|
const parentMatch = matches[index - 1];
|
|
const [preMatchSearch, strictMatchSearch, searchError] = (() => {
|
|
const parentSearch = (parentMatch == null ? void 0 : parentMatch.search) ?? next.search;
|
|
const parentStrictSearch = (parentMatch == null ? void 0 : parentMatch._strictSearch) ?? void 0;
|
|
try {
|
|
const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? void 0;
|
|
return [
|
|
{
|
|
...parentSearch,
|
|
...strictSearch
|
|
},
|
|
{ ...parentStrictSearch, ...strictSearch },
|
|
void 0
|
|
];
|
|
} catch (err) {
|
|
let searchParamError = err;
|
|
if (!(err instanceof SearchParamError)) {
|
|
searchParamError = new SearchParamError(err.message, {
|
|
cause: err
|
|
});
|
|
}
|
|
if (opts == null ? void 0 : opts.throwOnError) {
|
|
throw searchParamError;
|
|
}
|
|
return [parentSearch, {}, searchParamError];
|
|
}
|
|
})();
|
|
const loaderDeps = ((_b = (_a2 = route.options).loaderDeps) == null ? void 0 : _b.call(_a2, {
|
|
search: preMatchSearch
|
|
})) ?? "";
|
|
const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : "";
|
|
const { usedParams, interpolatedPath } = interpolatePath({
|
|
path: route.fullPath,
|
|
params: routeParams,
|
|
decodeCharMap: this.pathParamsDecodeCharMap
|
|
});
|
|
const matchId = interpolatePath({
|
|
path: route.id,
|
|
params: routeParams,
|
|
leaveWildcards: true,
|
|
decodeCharMap: this.pathParamsDecodeCharMap,
|
|
parseCache: this.parsePathnameCache
|
|
}).interpolatedPath + loaderDepsHash;
|
|
const existingMatch = this.getMatch(matchId);
|
|
const previousMatch = this.state.matches.find(
|
|
(d) => d.routeId === route.id
|
|
);
|
|
const cause = previousMatch ? "stay" : "enter";
|
|
let match;
|
|
if (existingMatch) {
|
|
match = {
|
|
...existingMatch,
|
|
cause,
|
|
params: previousMatch ? replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
|
|
_strictParams: usedParams,
|
|
search: previousMatch ? replaceEqualDeep(previousMatch.search, preMatchSearch) : replaceEqualDeep(existingMatch.search, preMatchSearch),
|
|
_strictSearch: strictMatchSearch
|
|
};
|
|
} else {
|
|
const status = route.options.loader || route.options.beforeLoad || route.lazyFn || routeNeedsPreload(route) ? "pending" : "success";
|
|
match = {
|
|
id: matchId,
|
|
index,
|
|
routeId: route.id,
|
|
params: previousMatch ? replaceEqualDeep(previousMatch.params, routeParams) : routeParams,
|
|
_strictParams: usedParams,
|
|
pathname: joinPaths([this.basepath, interpolatedPath]),
|
|
updatedAt: Date.now(),
|
|
search: previousMatch ? replaceEqualDeep(previousMatch.search, preMatchSearch) : preMatchSearch,
|
|
_strictSearch: strictMatchSearch,
|
|
searchError: void 0,
|
|
status,
|
|
isFetching: false,
|
|
error: void 0,
|
|
paramsError: parseErrors[index],
|
|
__routeContext: void 0,
|
|
_nonReactive: {
|
|
loadPromise: createControlledPromise()
|
|
},
|
|
__beforeLoadContext: void 0,
|
|
context: {},
|
|
abortController: new AbortController(),
|
|
fetchCount: 0,
|
|
cause,
|
|
loaderDeps: previousMatch ? replaceEqualDeep(previousMatch.loaderDeps, loaderDeps) : loaderDeps,
|
|
invalid: false,
|
|
preload: false,
|
|
links: void 0,
|
|
scripts: void 0,
|
|
headScripts: void 0,
|
|
meta: void 0,
|
|
staticData: route.options.staticData || {},
|
|
fullPath: route.fullPath
|
|
};
|
|
}
|
|
if (!(opts == null ? void 0 : opts.preload)) {
|
|
match.globalNotFound = globalNotFoundRouteId === route.id;
|
|
}
|
|
match.searchError = searchError;
|
|
const parentContext = getParentContext(parentMatch);
|
|
match.context = {
|
|
...parentContext,
|
|
...match.__routeContext,
|
|
...match.__beforeLoadContext
|
|
};
|
|
matches.push(match);
|
|
});
|
|
matches.forEach((match, index) => {
|
|
const route = this.looseRoutesById[match.routeId];
|
|
const existingMatch = this.getMatch(match.id);
|
|
if (!existingMatch && (opts == null ? void 0 : opts._buildLocation) !== true) {
|
|
const parentMatch = matches[index - 1];
|
|
const parentContext = getParentContext(parentMatch);
|
|
if (route.options.context) {
|
|
const contextFnContext = {
|
|
deps: match.loaderDeps,
|
|
params: match.params,
|
|
context: parentContext ?? {},
|
|
location: next,
|
|
navigate: (opts2) => this.navigate({ ...opts2, _fromLocation: next }),
|
|
buildLocation: this.buildLocation,
|
|
cause: match.cause,
|
|
abortController: match.abortController,
|
|
preload: !!match.preload,
|
|
matches
|
|
};
|
|
match.__routeContext = route.options.context(contextFnContext) ?? void 0;
|
|
}
|
|
match.context = {
|
|
...parentContext,
|
|
...match.__routeContext,
|
|
...match.__beforeLoadContext
|
|
};
|
|
}
|
|
});
|
|
return matches;
|
|
}
|
|
};
|
|
var SearchParamError = class extends Error {
|
|
};
|
|
var PathParamError = class extends Error {
|
|
};
|
|
var normalize = (str) => str.endsWith("/") && str.length > 1 ? str.slice(0, -1) : str;
|
|
function comparePaths(a, b) {
|
|
return normalize(a) === normalize(b);
|
|
}
|
|
function lazyFn(fn, key) {
|
|
return async (...args) => {
|
|
const imported = await fn();
|
|
return imported[key || "default"](...args);
|
|
};
|
|
}
|
|
function getInitialRouterState(location) {
|
|
return {
|
|
loadedAt: 0,
|
|
isLoading: false,
|
|
isTransitioning: false,
|
|
status: "idle",
|
|
resolvedLocation: void 0,
|
|
location,
|
|
matches: [],
|
|
pendingMatches: [],
|
|
cachedMatches: [],
|
|
statusCode: 200
|
|
};
|
|
}
|
|
function validateSearch(validateSearch2, input) {
|
|
if (validateSearch2 == null) return {};
|
|
if ("~standard" in validateSearch2) {
|
|
const result = validateSearch2["~standard"].validate(input);
|
|
if (result instanceof Promise)
|
|
throw new SearchParamError("Async validation not supported");
|
|
if (result.issues)
|
|
throw new SearchParamError(JSON.stringify(result.issues, void 0, 2), {
|
|
cause: result
|
|
});
|
|
return result.value;
|
|
}
|
|
if ("parse" in validateSearch2) {
|
|
return validateSearch2.parse(input);
|
|
}
|
|
if (typeof validateSearch2 === "function") {
|
|
return validateSearch2(input);
|
|
}
|
|
return {};
|
|
}
|
|
var componentTypes = [
|
|
"component",
|
|
"errorComponent",
|
|
"pendingComponent",
|
|
"notFoundComponent"
|
|
];
|
|
function routeNeedsPreload(route) {
|
|
var _a;
|
|
for (const componentType of componentTypes) {
|
|
if ((_a = route.options[componentType]) == null ? void 0 : _a.preload) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
var REQUIRED_PARAM_BASE_SCORE = 0.5;
|
|
var OPTIONAL_PARAM_BASE_SCORE = 0.4;
|
|
var WILDCARD_PARAM_BASE_SCORE = 0.25;
|
|
var BOTH_PRESENCE_BASE_SCORE = 0.05;
|
|
var PREFIX_PRESENCE_BASE_SCORE = 0.02;
|
|
var SUFFIX_PRESENCE_BASE_SCORE = 0.01;
|
|
var PREFIX_LENGTH_SCORE_MULTIPLIER = 2e-4;
|
|
var SUFFIX_LENGTH_SCORE_MULTIPLIER = 1e-4;
|
|
function handleParam(segment, baseScore) {
|
|
if (segment.prefixSegment && segment.suffixSegment) {
|
|
return baseScore + BOTH_PRESENCE_BASE_SCORE + PREFIX_LENGTH_SCORE_MULTIPLIER * segment.prefixSegment.length + SUFFIX_LENGTH_SCORE_MULTIPLIER * segment.suffixSegment.length;
|
|
}
|
|
if (segment.prefixSegment) {
|
|
return baseScore + PREFIX_PRESENCE_BASE_SCORE + PREFIX_LENGTH_SCORE_MULTIPLIER * segment.prefixSegment.length;
|
|
}
|
|
if (segment.suffixSegment) {
|
|
return baseScore + SUFFIX_PRESENCE_BASE_SCORE + SUFFIX_LENGTH_SCORE_MULTIPLIER * segment.suffixSegment.length;
|
|
}
|
|
return baseScore;
|
|
}
|
|
function processRouteTree({
|
|
routeTree,
|
|
initRoute
|
|
}) {
|
|
const routesById = {};
|
|
const routesByPath = {};
|
|
const recurseRoutes = (childRoutes) => {
|
|
childRoutes.forEach((childRoute, i) => {
|
|
initRoute == null ? void 0 : initRoute(childRoute, i);
|
|
const existingRoute = routesById[childRoute.id];
|
|
invariant(
|
|
!existingRoute,
|
|
`Duplicate routes found with id: ${String(childRoute.id)}`
|
|
);
|
|
routesById[childRoute.id] = childRoute;
|
|
if (!childRoute.isRoot && childRoute.path) {
|
|
const trimmedFullPath = trimPathRight(childRoute.fullPath);
|
|
if (!routesByPath[trimmedFullPath] || childRoute.fullPath.endsWith("/")) {
|
|
routesByPath[trimmedFullPath] = childRoute;
|
|
}
|
|
}
|
|
const children = childRoute.children;
|
|
if (children == null ? void 0 : children.length) {
|
|
recurseRoutes(children);
|
|
}
|
|
});
|
|
};
|
|
recurseRoutes([routeTree]);
|
|
const scoredRoutes = [];
|
|
const routes = Object.values(routesById);
|
|
routes.forEach((d, i) => {
|
|
var _a;
|
|
if (d.isRoot || !d.path) {
|
|
return;
|
|
}
|
|
const trimmed = trimPathLeft(d.fullPath);
|
|
let parsed = parsePathname(trimmed);
|
|
let skip = 0;
|
|
while (parsed.length > skip + 1 && ((_a = parsed[skip]) == null ? void 0 : _a.value) === "/") {
|
|
skip++;
|
|
}
|
|
if (skip > 0) parsed = parsed.slice(skip);
|
|
let optionalParamCount = 0;
|
|
let hasStaticAfter = false;
|
|
const scores = parsed.map((segment, index) => {
|
|
if (segment.value === "/") {
|
|
return 0.75;
|
|
}
|
|
let baseScore = void 0;
|
|
if (segment.type === SEGMENT_TYPE_PARAM) {
|
|
baseScore = REQUIRED_PARAM_BASE_SCORE;
|
|
} else if (segment.type === SEGMENT_TYPE_OPTIONAL_PARAM) {
|
|
baseScore = OPTIONAL_PARAM_BASE_SCORE;
|
|
optionalParamCount++;
|
|
} else if (segment.type === SEGMENT_TYPE_WILDCARD) {
|
|
baseScore = WILDCARD_PARAM_BASE_SCORE;
|
|
}
|
|
if (baseScore) {
|
|
for (let i2 = index + 1; i2 < parsed.length; i2++) {
|
|
const nextSegment = parsed[i2];
|
|
if (nextSegment.type === SEGMENT_TYPE_PATHNAME && nextSegment.value !== "/") {
|
|
hasStaticAfter = true;
|
|
return handleParam(segment, baseScore + 0.2);
|
|
}
|
|
}
|
|
return handleParam(segment, baseScore);
|
|
}
|
|
return 1;
|
|
});
|
|
scoredRoutes.push({
|
|
child: d,
|
|
trimmed,
|
|
parsed,
|
|
index: i,
|
|
scores,
|
|
optionalParamCount,
|
|
hasStaticAfter
|
|
});
|
|
});
|
|
const flatRoutes = scoredRoutes.sort((a, b) => {
|
|
const minLength = Math.min(a.scores.length, b.scores.length);
|
|
for (let i = 0; i < minLength; i++) {
|
|
if (a.scores[i] !== b.scores[i]) {
|
|
return b.scores[i] - a.scores[i];
|
|
}
|
|
}
|
|
if (a.scores.length !== b.scores.length) {
|
|
if (a.optionalParamCount !== b.optionalParamCount) {
|
|
if (a.hasStaticAfter === b.hasStaticAfter) {
|
|
return a.optionalParamCount - b.optionalParamCount;
|
|
} else if (a.hasStaticAfter && !b.hasStaticAfter) {
|
|
return -1;
|
|
} else if (!a.hasStaticAfter && b.hasStaticAfter) {
|
|
return 1;
|
|
}
|
|
}
|
|
return b.scores.length - a.scores.length;
|
|
}
|
|
for (let i = 0; i < minLength; i++) {
|
|
if (a.parsed[i].value !== b.parsed[i].value) {
|
|
return a.parsed[i].value > b.parsed[i].value ? 1 : -1;
|
|
}
|
|
}
|
|
return a.index - b.index;
|
|
}).map((d, i) => {
|
|
d.child.rank = i;
|
|
return d.child;
|
|
});
|
|
return { routesById, routesByPath, flatRoutes };
|
|
}
|
|
function getMatchedRoutes({
|
|
pathname,
|
|
routePathname,
|
|
basepath,
|
|
caseSensitive,
|
|
routesByPath,
|
|
routesById,
|
|
flatRoutes,
|
|
parseCache
|
|
}) {
|
|
let routeParams = {};
|
|
const trimmedPath = trimPathRight(pathname);
|
|
const getMatchedParams = (route) => {
|
|
var _a;
|
|
const result = matchPathname(
|
|
basepath,
|
|
trimmedPath,
|
|
{
|
|
to: route.fullPath,
|
|
caseSensitive: ((_a = route.options) == null ? void 0 : _a.caseSensitive) ?? caseSensitive,
|
|
// we need fuzzy matching for `notFoundMode: 'fuzzy'`
|
|
fuzzy: true
|
|
},
|
|
parseCache
|
|
);
|
|
return result;
|
|
};
|
|
let foundRoute = routePathname !== void 0 ? routesByPath[routePathname] : void 0;
|
|
if (foundRoute) {
|
|
routeParams = getMatchedParams(foundRoute);
|
|
} else {
|
|
let fuzzyMatch = void 0;
|
|
for (const route of flatRoutes) {
|
|
const matchedParams = getMatchedParams(route);
|
|
if (matchedParams) {
|
|
if (route.path !== "/" && matchedParams["**"]) {
|
|
if (!fuzzyMatch) {
|
|
fuzzyMatch = { foundRoute: route, routeParams: matchedParams };
|
|
}
|
|
} else {
|
|
foundRoute = route;
|
|
routeParams = matchedParams;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (!foundRoute && fuzzyMatch) {
|
|
foundRoute = fuzzyMatch.foundRoute;
|
|
routeParams = fuzzyMatch.routeParams;
|
|
}
|
|
}
|
|
let routeCursor = foundRoute || routesById[rootRouteId];
|
|
const matchedRoutes = [routeCursor];
|
|
while (routeCursor.parentRoute) {
|
|
routeCursor = routeCursor.parentRoute;
|
|
matchedRoutes.push(routeCursor);
|
|
}
|
|
matchedRoutes.reverse();
|
|
return { matchedRoutes, routeParams, foundRoute };
|
|
}
|
|
function applySearchMiddleware({
|
|
search,
|
|
dest,
|
|
destRoutes,
|
|
_includeValidateSearch
|
|
}) {
|
|
const allMiddlewares = destRoutes.reduce(
|
|
(acc, route) => {
|
|
var _a;
|
|
const middlewares = [];
|
|
if ("search" in route.options) {
|
|
if ((_a = route.options.search) == null ? void 0 : _a.middlewares) {
|
|
middlewares.push(...route.options.search.middlewares);
|
|
}
|
|
} else if (route.options.preSearchFilters || route.options.postSearchFilters) {
|
|
const legacyMiddleware = ({
|
|
search: search2,
|
|
next
|
|
}) => {
|
|
let nextSearch = search2;
|
|
if ("preSearchFilters" in route.options && route.options.preSearchFilters) {
|
|
nextSearch = route.options.preSearchFilters.reduce(
|
|
(prev, next2) => next2(prev),
|
|
search2
|
|
);
|
|
}
|
|
const result = next(nextSearch);
|
|
if ("postSearchFilters" in route.options && route.options.postSearchFilters) {
|
|
return route.options.postSearchFilters.reduce(
|
|
(prev, next2) => next2(prev),
|
|
result
|
|
);
|
|
}
|
|
return result;
|
|
};
|
|
middlewares.push(legacyMiddleware);
|
|
}
|
|
if (_includeValidateSearch && route.options.validateSearch) {
|
|
const validate = ({ search: search2, next }) => {
|
|
const result = next(search2);
|
|
try {
|
|
const validatedSearch = {
|
|
...result,
|
|
...validateSearch(route.options.validateSearch, result) ?? void 0
|
|
};
|
|
return validatedSearch;
|
|
} catch {
|
|
return result;
|
|
}
|
|
};
|
|
middlewares.push(validate);
|
|
}
|
|
return acc.concat(middlewares);
|
|
},
|
|
[]
|
|
) ?? [];
|
|
const final = ({ search: search2 }) => {
|
|
if (!dest.search) {
|
|
return {};
|
|
}
|
|
if (dest.search === true) {
|
|
return search2;
|
|
}
|
|
return functionalUpdate(dest.search, search2);
|
|
};
|
|
allMiddlewares.push(final);
|
|
const applyNext = (index, currentSearch) => {
|
|
if (index >= allMiddlewares.length) {
|
|
return currentSearch;
|
|
}
|
|
const middleware = allMiddlewares[index];
|
|
const next = (newSearch) => {
|
|
return applyNext(index + 1, newSearch);
|
|
};
|
|
return middleware({ search: currentSearch, next });
|
|
};
|
|
return applyNext(0, search);
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/defer.js
|
|
var TSR_DEFERRED_PROMISE = Symbol.for("TSR_DEFERRED_PROMISE");
|
|
function defer(_promise, options) {
|
|
const promise = _promise;
|
|
if (promise[TSR_DEFERRED_PROMISE]) {
|
|
return promise;
|
|
}
|
|
promise[TSR_DEFERRED_PROMISE] = { status: "pending" };
|
|
promise.then((data) => {
|
|
promise[TSR_DEFERRED_PROMISE].status = "success";
|
|
promise[TSR_DEFERRED_PROMISE].data = data;
|
|
}).catch((error) => {
|
|
promise[TSR_DEFERRED_PROMISE].status = "error";
|
|
promise[TSR_DEFERRED_PROMISE].error = {
|
|
data: ((options == null ? void 0 : options.serializeError) ?? defaultSerializeError)(error),
|
|
__isServerError: true
|
|
};
|
|
});
|
|
return promise;
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/link.js
|
|
var preloadWarning = "Error preloading route! ☝️";
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/Matches.js
|
|
var isMatch2 = (match, path) => {
|
|
const parts = path.split(".");
|
|
let part;
|
|
let value = match;
|
|
while ((part = parts.shift()) != null && value != null) {
|
|
value = value[part];
|
|
}
|
|
return value != null;
|
|
};
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/route.js
|
|
var BaseRoute = class {
|
|
constructor(options) {
|
|
this.init = (opts) => {
|
|
var _a, _b;
|
|
this.originalIndex = opts.originalIndex;
|
|
const options2 = this.options;
|
|
const isRoot = !(options2 == null ? void 0 : options2.path) && !(options2 == null ? void 0 : options2.id);
|
|
this.parentRoute = (_b = (_a = this.options).getParentRoute) == null ? void 0 : _b.call(_a);
|
|
if (isRoot) {
|
|
this._path = rootRouteId;
|
|
} else if (!this.parentRoute) {
|
|
invariant(
|
|
false,
|
|
`Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance.`
|
|
);
|
|
}
|
|
let path = isRoot ? rootRouteId : options2 == null ? void 0 : options2.path;
|
|
if (path && path !== "/") {
|
|
path = trimPathLeft(path);
|
|
}
|
|
const customId = (options2 == null ? void 0 : options2.id) || path;
|
|
let id = isRoot ? rootRouteId : joinPaths([
|
|
this.parentRoute.id === rootRouteId ? "" : this.parentRoute.id,
|
|
customId
|
|
]);
|
|
if (path === rootRouteId) {
|
|
path = "/";
|
|
}
|
|
if (id !== rootRouteId) {
|
|
id = joinPaths(["/", id]);
|
|
}
|
|
const fullPath = id === rootRouteId ? "/" : joinPaths([this.parentRoute.fullPath, path]);
|
|
this._path = path;
|
|
this._id = id;
|
|
this._fullPath = fullPath;
|
|
this._to = fullPath;
|
|
};
|
|
this.clone = (other) => {
|
|
this._path = other._path;
|
|
this._id = other._id;
|
|
this._fullPath = other._fullPath;
|
|
this._to = other._to;
|
|
this.options.getParentRoute = other.options.getParentRoute;
|
|
this.children = other.children;
|
|
};
|
|
this.addChildren = (children) => {
|
|
return this._addFileChildren(children);
|
|
};
|
|
this._addFileChildren = (children) => {
|
|
if (Array.isArray(children)) {
|
|
this.children = children;
|
|
}
|
|
if (typeof children === "object" && children !== null) {
|
|
this.children = Object.values(children);
|
|
}
|
|
return this;
|
|
};
|
|
this._addFileTypes = () => {
|
|
return this;
|
|
};
|
|
this.updateLoader = (options2) => {
|
|
Object.assign(this.options, options2);
|
|
return this;
|
|
};
|
|
this.update = (options2) => {
|
|
Object.assign(this.options, options2);
|
|
return this;
|
|
};
|
|
this.lazy = (lazyFn2) => {
|
|
this.lazyFn = lazyFn2;
|
|
return this;
|
|
};
|
|
this.options = options || {};
|
|
this.isRoot = !(options == null ? void 0 : options.getParentRoute);
|
|
if ((options == null ? void 0 : options.id) && (options == null ? void 0 : options.path)) {
|
|
throw new Error(`Route cannot have both an 'id' and a 'path' option.`);
|
|
}
|
|
}
|
|
get to() {
|
|
return this._to;
|
|
}
|
|
get id() {
|
|
return this._id;
|
|
}
|
|
get path() {
|
|
return this._path;
|
|
}
|
|
get fullPath() {
|
|
return this._fullPath;
|
|
}
|
|
};
|
|
var BaseRouteApi = class {
|
|
constructor({ id }) {
|
|
this.notFound = (opts) => {
|
|
return notFound({ routeId: this.id, ...opts });
|
|
};
|
|
this.id = id;
|
|
}
|
|
};
|
|
var BaseRootRoute = class extends BaseRoute {
|
|
constructor(options) {
|
|
super(options);
|
|
}
|
|
};
|
|
|
|
// node_modules/.pnpm/@tanstack+router-core@1.131.7/node_modules/@tanstack/router-core/dist/esm/searchMiddleware.js
|
|
function retainSearchParams(keys) {
|
|
return ({ search, next }) => {
|
|
const result = next(search);
|
|
if (keys === true) {
|
|
return { ...search, ...result };
|
|
}
|
|
keys.forEach((key) => {
|
|
if (!(key in result)) {
|
|
result[key] = search[key];
|
|
}
|
|
});
|
|
return result;
|
|
};
|
|
}
|
|
function stripSearchParams(input) {
|
|
return ({ search, next }) => {
|
|
if (input === true) {
|
|
return {};
|
|
}
|
|
const result = next(search);
|
|
if (Array.isArray(input)) {
|
|
input.forEach((key) => {
|
|
delete result[key];
|
|
});
|
|
} else {
|
|
Object.entries(input).forEach(
|
|
([key, value]) => {
|
|
if (deepEqual(result[key], value)) {
|
|
delete result[key];
|
|
}
|
|
}
|
|
);
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/awaited.js
|
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
var React = __toESM(require_react(), 1);
|
|
function useAwaited({
|
|
promise: _promise
|
|
}) {
|
|
const promise = defer(_promise);
|
|
if (promise[TSR_DEFERRED_PROMISE].status === "pending") {
|
|
throw promise;
|
|
}
|
|
if (promise[TSR_DEFERRED_PROMISE].status === "error") {
|
|
throw promise[TSR_DEFERRED_PROMISE].error;
|
|
}
|
|
return [promise[TSR_DEFERRED_PROMISE].data, promise];
|
|
}
|
|
function Await(props) {
|
|
const inner = (0, import_jsx_runtime.jsx)(AwaitInner, { ...props });
|
|
if (props.fallback) {
|
|
return (0, import_jsx_runtime.jsx)(React.Suspense, { fallback: props.fallback, children: inner });
|
|
}
|
|
return inner;
|
|
}
|
|
function AwaitInner(props) {
|
|
const [data] = useAwaited(props);
|
|
return props.children(data);
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/CatchBoundary.js
|
|
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
|
|
var React2 = __toESM(require_react(), 1);
|
|
function CatchBoundary(props) {
|
|
const errorComponent = props.errorComponent ?? ErrorComponent;
|
|
return (0, import_jsx_runtime2.jsx)(
|
|
CatchBoundaryImpl,
|
|
{
|
|
getResetKey: props.getResetKey,
|
|
onCatch: props.onCatch,
|
|
children: ({ error, reset }) => {
|
|
if (error) {
|
|
return React2.createElement(errorComponent, {
|
|
error,
|
|
reset
|
|
});
|
|
}
|
|
return props.children;
|
|
}
|
|
}
|
|
);
|
|
}
|
|
var CatchBoundaryImpl = class extends React2.Component {
|
|
constructor() {
|
|
super(...arguments);
|
|
this.state = { error: null };
|
|
}
|
|
static getDerivedStateFromProps(props) {
|
|
return { resetKey: props.getResetKey() };
|
|
}
|
|
static getDerivedStateFromError(error) {
|
|
return { error };
|
|
}
|
|
reset() {
|
|
this.setState({ error: null });
|
|
}
|
|
componentDidUpdate(prevProps, prevState) {
|
|
if (prevState.error && prevState.resetKey !== this.state.resetKey) {
|
|
this.reset();
|
|
}
|
|
}
|
|
componentDidCatch(error, errorInfo) {
|
|
if (this.props.onCatch) {
|
|
this.props.onCatch(error, errorInfo);
|
|
}
|
|
}
|
|
render() {
|
|
return this.props.children({
|
|
error: this.state.resetKey !== this.props.getResetKey() ? null : this.state.error,
|
|
reset: () => {
|
|
this.reset();
|
|
}
|
|
});
|
|
}
|
|
};
|
|
function ErrorComponent({ error }) {
|
|
const [show, setShow] = React2.useState(true);
|
|
return (0, import_jsx_runtime2.jsxs)("div", { style: { padding: ".5rem", maxWidth: "100%" }, children: [
|
|
(0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: ".5rem" }, children: [
|
|
(0, import_jsx_runtime2.jsx)("strong", { style: { fontSize: "1rem" }, children: "Something went wrong!" }),
|
|
(0, import_jsx_runtime2.jsx)(
|
|
"button",
|
|
{
|
|
style: {
|
|
appearance: "none",
|
|
fontSize: ".6em",
|
|
border: "1px solid currentColor",
|
|
padding: ".1rem .2rem",
|
|
fontWeight: "bold",
|
|
borderRadius: ".25rem"
|
|
},
|
|
onClick: () => setShow((d) => !d),
|
|
children: show ? "Hide Error" : "Show Error"
|
|
}
|
|
)
|
|
] }),
|
|
(0, import_jsx_runtime2.jsx)("div", { style: { height: ".25rem" } }),
|
|
show ? (0, import_jsx_runtime2.jsx)("div", { children: (0, import_jsx_runtime2.jsx)(
|
|
"pre",
|
|
{
|
|
style: {
|
|
fontSize: ".7em",
|
|
border: "1px solid red",
|
|
borderRadius: ".25rem",
|
|
padding: ".3rem",
|
|
color: "red",
|
|
overflow: "auto"
|
|
},
|
|
children: error.message ? (0, import_jsx_runtime2.jsx)("code", { children: error.message }) : null
|
|
}
|
|
) }) : null
|
|
] });
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/ClientOnly.js
|
|
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
|
|
var import_react = __toESM(require_react(), 1);
|
|
function ClientOnly({ children, fallback = null }) {
|
|
return useHydrated() ? (0, import_jsx_runtime3.jsx)(import_react.default.Fragment, { children }) : (0, import_jsx_runtime3.jsx)(import_react.default.Fragment, { children: fallback });
|
|
}
|
|
function useHydrated() {
|
|
return import_react.default.useSyncExternalStore(
|
|
subscribe,
|
|
() => true,
|
|
() => false
|
|
);
|
|
}
|
|
function subscribe() {
|
|
return () => {
|
|
};
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/route.js
|
|
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
|
|
var import_react3 = __toESM(require_react(), 1);
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useMatch.js
|
|
var React6 = __toESM(require_react(), 1);
|
|
|
|
// node_modules/.pnpm/@tanstack+react-store@0.7.3_84c71f5e5d7c488cd20c24988c9cfd93/node_modules/@tanstack/react-store/dist/esm/index.js
|
|
var import_with_selector = __toESM(require_with_selector());
|
|
function useStore(store, selector = (d) => d) {
|
|
const slice = (0, import_with_selector.useSyncExternalStoreWithSelector)(
|
|
store.subscribe,
|
|
() => store.state,
|
|
() => store.state,
|
|
selector,
|
|
shallow2
|
|
);
|
|
return slice;
|
|
}
|
|
function shallow2(objA, objB) {
|
|
if (Object.is(objA, objB)) {
|
|
return true;
|
|
}
|
|
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
return false;
|
|
}
|
|
if (objA instanceof Map && objB instanceof Map) {
|
|
if (objA.size !== objB.size) return false;
|
|
for (const [k, v] of objA) {
|
|
if (!objB.has(k) || !Object.is(v, objB.get(k))) return false;
|
|
}
|
|
return true;
|
|
}
|
|
if (objA instanceof Set && objB instanceof Set) {
|
|
if (objA.size !== objB.size) return false;
|
|
for (const v of objA) {
|
|
if (!objB.has(v)) return false;
|
|
}
|
|
return true;
|
|
}
|
|
if (objA instanceof Date && objB instanceof Date) {
|
|
if (objA.getTime() !== objB.getTime()) return false;
|
|
return true;
|
|
}
|
|
const keysA = Object.keys(objA);
|
|
if (keysA.length !== Object.keys(objB).length) {
|
|
return false;
|
|
}
|
|
for (let i = 0; i < keysA.length; i++) {
|
|
if (!Object.prototype.hasOwnProperty.call(objB, keysA[i]) || !Object.is(objA[keysA[i]], objB[keysA[i]])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useRouterState.js
|
|
var import_react2 = __toESM(require_react(), 1);
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useRouter.js
|
|
var React4 = __toESM(require_react(), 1);
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/routerContext.js
|
|
var React3 = __toESM(require_react(), 1);
|
|
var routerContext = React3.createContext(null);
|
|
function getRouterContext() {
|
|
if (typeof document === "undefined") {
|
|
return routerContext;
|
|
}
|
|
if (window.__TSR_ROUTER_CONTEXT__) {
|
|
return window.__TSR_ROUTER_CONTEXT__;
|
|
}
|
|
window.__TSR_ROUTER_CONTEXT__ = routerContext;
|
|
return routerContext;
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useRouter.js
|
|
function useRouter(opts) {
|
|
const value = React4.useContext(getRouterContext());
|
|
tiny_warning_esm_default(
|
|
!(((opts == null ? void 0 : opts.warn) ?? true) && !value),
|
|
"useRouter must be used inside a <RouterProvider> component!"
|
|
);
|
|
return value;
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useRouterState.js
|
|
function useRouterState(opts) {
|
|
const contextRouter = useRouter({
|
|
warn: (opts == null ? void 0 : opts.router) === void 0
|
|
});
|
|
const router = (opts == null ? void 0 : opts.router) || contextRouter;
|
|
const previousResult = (0, import_react2.useRef)(void 0);
|
|
return useStore(router.__store, (state) => {
|
|
if (opts == null ? void 0 : opts.select) {
|
|
if (opts.structuralSharing ?? router.options.defaultStructuralSharing) {
|
|
const newSlice = replaceEqualDeep(
|
|
previousResult.current,
|
|
opts.select(state)
|
|
);
|
|
previousResult.current = newSlice;
|
|
return newSlice;
|
|
}
|
|
return opts.select(state);
|
|
}
|
|
return state;
|
|
});
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/matchContext.js
|
|
var React5 = __toESM(require_react(), 1);
|
|
var matchContext = React5.createContext(void 0);
|
|
var dummyMatchContext = React5.createContext(
|
|
void 0
|
|
);
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useMatch.js
|
|
function useMatch(opts) {
|
|
const nearestMatchId = React6.useContext(
|
|
opts.from ? dummyMatchContext : matchContext
|
|
);
|
|
const matchSelection = useRouterState({
|
|
select: (state) => {
|
|
const match = state.matches.find(
|
|
(d) => opts.from ? opts.from === d.routeId : d.id === nearestMatchId
|
|
);
|
|
invariant(
|
|
!((opts.shouldThrow ?? true) && !match),
|
|
`Could not find ${opts.from ? `an active match from "${opts.from}"` : "a nearest match!"}`
|
|
);
|
|
if (match === void 0) {
|
|
return void 0;
|
|
}
|
|
return opts.select ? opts.select(match) : match;
|
|
},
|
|
structuralSharing: opts.structuralSharing
|
|
});
|
|
return matchSelection;
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useLoaderData.js
|
|
function useLoaderData(opts) {
|
|
return useMatch({
|
|
from: opts.from,
|
|
strict: opts.strict,
|
|
structuralSharing: opts.structuralSharing,
|
|
select: (s) => {
|
|
return opts.select ? opts.select(s.loaderData) : s.loaderData;
|
|
}
|
|
});
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useLoaderDeps.js
|
|
function useLoaderDeps(opts) {
|
|
const { select, ...rest } = opts;
|
|
return useMatch({
|
|
...rest,
|
|
select: (s) => {
|
|
return select ? select(s.loaderDeps) : s.loaderDeps;
|
|
}
|
|
});
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useParams.js
|
|
function useParams(opts) {
|
|
return useMatch({
|
|
from: opts.from,
|
|
strict: opts.strict,
|
|
shouldThrow: opts.shouldThrow,
|
|
structuralSharing: opts.structuralSharing,
|
|
select: (match) => {
|
|
return opts.select ? opts.select(match.params) : match.params;
|
|
}
|
|
});
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useSearch.js
|
|
function useSearch(opts) {
|
|
return useMatch({
|
|
from: opts.from,
|
|
strict: opts.strict,
|
|
shouldThrow: opts.shouldThrow,
|
|
structuralSharing: opts.structuralSharing,
|
|
select: (match) => {
|
|
return opts.select ? opts.select(match.search) : match.search;
|
|
}
|
|
});
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useNavigate.js
|
|
var React7 = __toESM(require_react(), 1);
|
|
function useNavigate(_defaultOpts) {
|
|
const { navigate, state } = useRouter();
|
|
const matchIndex = useMatch({
|
|
strict: false,
|
|
select: (match) => match.index
|
|
});
|
|
return React7.useCallback(
|
|
(options) => {
|
|
const from = options.from ?? (_defaultOpts == null ? void 0 : _defaultOpts.from) ?? state.matches[matchIndex].fullPath;
|
|
return navigate({
|
|
...options,
|
|
from
|
|
});
|
|
},
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
[_defaultOpts == null ? void 0 : _defaultOpts.from, navigate]
|
|
);
|
|
}
|
|
function Navigate(props) {
|
|
const router = useRouter();
|
|
const navigate = useNavigate();
|
|
const previousPropsRef = React7.useRef(null);
|
|
React7.useEffect(() => {
|
|
if (previousPropsRef.current !== props) {
|
|
navigate(props);
|
|
previousPropsRef.current = props;
|
|
}
|
|
}, [router, props, navigate]);
|
|
return null;
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/link.js
|
|
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
|
|
var React9 = __toESM(require_react(), 1);
|
|
var import_react_dom = __toESM(require_react_dom(), 1);
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/utils.js
|
|
var React8 = __toESM(require_react(), 1);
|
|
function useStableCallback(fn) {
|
|
const fnRef = React8.useRef(fn);
|
|
fnRef.current = fn;
|
|
const ref = React8.useRef((...args) => fnRef.current(...args));
|
|
return ref.current;
|
|
}
|
|
var useLayoutEffect2 = typeof window !== "undefined" ? React8.useLayoutEffect : React8.useEffect;
|
|
function usePrevious(value) {
|
|
const ref = React8.useRef({
|
|
value,
|
|
prev: null
|
|
});
|
|
const current = ref.current.value;
|
|
if (value !== current) {
|
|
ref.current = {
|
|
value,
|
|
prev: current
|
|
};
|
|
}
|
|
return ref.current.prev;
|
|
}
|
|
function useIntersectionObserver(ref, callback, intersectionObserverOptions2 = {}, options = {}) {
|
|
React8.useEffect(() => {
|
|
if (!ref.current || options.disabled || typeof IntersectionObserver !== "function") {
|
|
return;
|
|
}
|
|
const observer = new IntersectionObserver(([entry]) => {
|
|
callback(entry);
|
|
}, intersectionObserverOptions2);
|
|
observer.observe(ref.current);
|
|
return () => {
|
|
observer.disconnect();
|
|
};
|
|
}, [callback, intersectionObserverOptions2, options.disabled, ref]);
|
|
}
|
|
function useForwardedRef(ref) {
|
|
const innerRef = React8.useRef(null);
|
|
React8.useImperativeHandle(ref, () => innerRef.current, []);
|
|
return innerRef;
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/link.js
|
|
function useLinkProps(options, forwardedRef) {
|
|
const router = useRouter();
|
|
const [isTransitioning, setIsTransitioning] = React9.useState(false);
|
|
const hasRenderFetched = React9.useRef(false);
|
|
const innerRef = useForwardedRef(forwardedRef);
|
|
const {
|
|
// custom props
|
|
activeProps,
|
|
inactiveProps,
|
|
activeOptions,
|
|
to,
|
|
preload: userPreload,
|
|
preloadDelay: userPreloadDelay,
|
|
hashScrollIntoView,
|
|
replace,
|
|
startTransition: startTransition2,
|
|
resetScroll,
|
|
viewTransition,
|
|
// element props
|
|
children,
|
|
target,
|
|
disabled,
|
|
style,
|
|
className,
|
|
onClick,
|
|
onFocus,
|
|
onMouseEnter,
|
|
onMouseLeave,
|
|
onTouchStart,
|
|
ignoreBlocker,
|
|
// prevent these from being returned
|
|
params: _params,
|
|
search: _search,
|
|
hash: _hash,
|
|
state: _state,
|
|
mask: _mask,
|
|
reloadDocument: _reloadDocument,
|
|
unsafeRelative: _unsafeRelative,
|
|
from: _from,
|
|
_fromLocation,
|
|
...propsSafeToSpread
|
|
} = options;
|
|
const type = React9.useMemo(() => {
|
|
try {
|
|
new URL(to);
|
|
return "external";
|
|
} catch {
|
|
}
|
|
return "internal";
|
|
}, [to]);
|
|
const currentSearch = useRouterState({
|
|
select: (s) => s.location.search,
|
|
structuralSharing: true
|
|
});
|
|
const from = useMatch({
|
|
strict: false,
|
|
select: (match) => options.from ?? match.fullPath
|
|
});
|
|
const next = React9.useMemo(
|
|
() => router.buildLocation({ ...options, from }),
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
[
|
|
router,
|
|
currentSearch,
|
|
options._fromLocation,
|
|
from,
|
|
options.hash,
|
|
options.to,
|
|
options.search,
|
|
options.params,
|
|
options.state,
|
|
options.mask,
|
|
options.unsafeRelative
|
|
]
|
|
);
|
|
const isExternal = type === "external";
|
|
const preload = options.reloadDocument || isExternal ? false : userPreload ?? router.options.defaultPreload;
|
|
const preloadDelay = userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0;
|
|
const isActive = useRouterState({
|
|
select: (s) => {
|
|
if (isExternal) return false;
|
|
if (activeOptions == null ? void 0 : activeOptions.exact) {
|
|
const testExact = exactPathTest(
|
|
s.location.pathname,
|
|
next.pathname,
|
|
router.basepath
|
|
);
|
|
if (!testExact) {
|
|
return false;
|
|
}
|
|
} else {
|
|
const currentPathSplit = removeTrailingSlash(
|
|
s.location.pathname,
|
|
router.basepath
|
|
);
|
|
const nextPathSplit = removeTrailingSlash(
|
|
next.pathname,
|
|
router.basepath
|
|
);
|
|
const pathIsFuzzyEqual = currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/");
|
|
if (!pathIsFuzzyEqual) {
|
|
return false;
|
|
}
|
|
}
|
|
if ((activeOptions == null ? void 0 : activeOptions.includeSearch) ?? true) {
|
|
const searchTest = deepEqual(s.location.search, next.search, {
|
|
partial: !(activeOptions == null ? void 0 : activeOptions.exact),
|
|
ignoreUndefined: !(activeOptions == null ? void 0 : activeOptions.explicitUndefined)
|
|
});
|
|
if (!searchTest) {
|
|
return false;
|
|
}
|
|
}
|
|
if (activeOptions == null ? void 0 : activeOptions.includeHash) {
|
|
return s.location.hash === next.hash;
|
|
}
|
|
return true;
|
|
}
|
|
});
|
|
const doPreload = React9.useCallback(
|
|
() => {
|
|
router.preloadRoute({ ...options, from }).catch((err) => {
|
|
console.warn(err);
|
|
console.warn(preloadWarning);
|
|
});
|
|
},
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
[
|
|
router,
|
|
options.to,
|
|
options._fromLocation,
|
|
from,
|
|
options.search,
|
|
options.hash,
|
|
options.params,
|
|
options.state,
|
|
options.mask,
|
|
options.unsafeRelative,
|
|
options.hashScrollIntoView,
|
|
options.href,
|
|
options.ignoreBlocker,
|
|
options.reloadDocument,
|
|
options.replace,
|
|
options.resetScroll,
|
|
options.viewTransition
|
|
]
|
|
);
|
|
const preloadViewportIoCallback = React9.useCallback(
|
|
(entry) => {
|
|
if (entry == null ? void 0 : entry.isIntersecting) {
|
|
doPreload();
|
|
}
|
|
},
|
|
[doPreload]
|
|
);
|
|
useIntersectionObserver(
|
|
innerRef,
|
|
preloadViewportIoCallback,
|
|
intersectionObserverOptions,
|
|
{ disabled: !!disabled || !(preload === "viewport") }
|
|
);
|
|
React9.useEffect(() => {
|
|
if (hasRenderFetched.current) {
|
|
return;
|
|
}
|
|
if (!disabled && preload === "render") {
|
|
doPreload();
|
|
hasRenderFetched.current = true;
|
|
}
|
|
}, [disabled, doPreload, preload]);
|
|
if (isExternal) {
|
|
return {
|
|
...propsSafeToSpread,
|
|
ref: innerRef,
|
|
type,
|
|
href: to,
|
|
...children && { children },
|
|
...target && { target },
|
|
...disabled && { disabled },
|
|
...style && { style },
|
|
...className && { className },
|
|
...onClick && { onClick },
|
|
...onFocus && { onFocus },
|
|
...onMouseEnter && { onMouseEnter },
|
|
...onMouseLeave && { onMouseLeave },
|
|
...onTouchStart && { onTouchStart }
|
|
};
|
|
}
|
|
const handleClick = (e) => {
|
|
if (!disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!target || target === "_self") && e.button === 0) {
|
|
e.preventDefault();
|
|
(0, import_react_dom.flushSync)(() => {
|
|
setIsTransitioning(true);
|
|
});
|
|
const unsub = router.subscribe("onResolved", () => {
|
|
unsub();
|
|
setIsTransitioning(false);
|
|
});
|
|
router.navigate({
|
|
...options,
|
|
from,
|
|
replace,
|
|
resetScroll,
|
|
hashScrollIntoView,
|
|
startTransition: startTransition2,
|
|
viewTransition,
|
|
ignoreBlocker
|
|
});
|
|
}
|
|
};
|
|
const handleFocus = (_) => {
|
|
if (disabled) return;
|
|
if (preload) {
|
|
doPreload();
|
|
}
|
|
};
|
|
const handleTouchStart = handleFocus;
|
|
const handleEnter = (e) => {
|
|
if (disabled || !preload) return;
|
|
if (!preloadDelay) {
|
|
doPreload();
|
|
} else {
|
|
const eventTarget = e.target;
|
|
if (timeoutMap.has(eventTarget)) {
|
|
return;
|
|
}
|
|
const id = setTimeout(() => {
|
|
timeoutMap.delete(eventTarget);
|
|
doPreload();
|
|
}, preloadDelay);
|
|
timeoutMap.set(eventTarget, id);
|
|
}
|
|
};
|
|
const handleLeave = (e) => {
|
|
if (disabled || !preload || !preloadDelay) return;
|
|
const eventTarget = e.target;
|
|
const id = timeoutMap.get(eventTarget);
|
|
if (id) {
|
|
clearTimeout(id);
|
|
timeoutMap.delete(eventTarget);
|
|
}
|
|
};
|
|
const resolvedActiveProps = isActive ? functionalUpdate(activeProps, {}) ?? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT;
|
|
const resolvedInactiveProps = isActive ? STATIC_EMPTY_OBJECT : functionalUpdate(inactiveProps, {}) ?? STATIC_EMPTY_OBJECT;
|
|
const resolvedClassName = [
|
|
className,
|
|
resolvedActiveProps.className,
|
|
resolvedInactiveProps.className
|
|
].filter(Boolean).join(" ");
|
|
const resolvedStyle = (style || resolvedActiveProps.style || resolvedInactiveProps.style) && {
|
|
...style,
|
|
...resolvedActiveProps.style,
|
|
...resolvedInactiveProps.style
|
|
};
|
|
return {
|
|
...propsSafeToSpread,
|
|
...resolvedActiveProps,
|
|
...resolvedInactiveProps,
|
|
href: disabled ? void 0 : next.maskedLocation ? router.history.createHref(next.maskedLocation.href) : router.history.createHref(next.href),
|
|
ref: innerRef,
|
|
onClick: composeHandlers([onClick, handleClick]),
|
|
onFocus: composeHandlers([onFocus, handleFocus]),
|
|
onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),
|
|
onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
|
|
onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),
|
|
disabled: !!disabled,
|
|
target,
|
|
...resolvedStyle && { style: resolvedStyle },
|
|
...resolvedClassName && { className: resolvedClassName },
|
|
...disabled && STATIC_DISABLED_PROPS,
|
|
...isActive && STATIC_ACTIVE_PROPS,
|
|
...isTransitioning && STATIC_TRANSITIONING_PROPS
|
|
};
|
|
}
|
|
var STATIC_EMPTY_OBJECT = {};
|
|
var STATIC_ACTIVE_OBJECT = { className: "active" };
|
|
var STATIC_DISABLED_PROPS = { role: "link", "aria-disabled": true };
|
|
var STATIC_ACTIVE_PROPS = { "data-status": "active", "aria-current": "page" };
|
|
var STATIC_TRANSITIONING_PROPS = { "data-transitioning": "transitioning" };
|
|
var timeoutMap = /* @__PURE__ */ new WeakMap();
|
|
var intersectionObserverOptions = {
|
|
rootMargin: "100px"
|
|
};
|
|
var composeHandlers = (handlers) => (e) => {
|
|
handlers.filter(Boolean).forEach((handler) => {
|
|
if (e.defaultPrevented) return;
|
|
handler(e);
|
|
});
|
|
};
|
|
function createLink(Comp) {
|
|
return React9.forwardRef(function CreatedLink(props, ref) {
|
|
return (0, import_jsx_runtime4.jsx)(Link, { ...props, _asChild: Comp, ref });
|
|
});
|
|
}
|
|
var Link = React9.forwardRef(
|
|
(props, ref) => {
|
|
const { _asChild, ...rest } = props;
|
|
const {
|
|
type: _type,
|
|
ref: innerRef,
|
|
...linkProps
|
|
} = useLinkProps(rest, ref);
|
|
const children = typeof rest.children === "function" ? rest.children({
|
|
isActive: linkProps["data-status"] === "active"
|
|
}) : rest.children;
|
|
if (_asChild === void 0) {
|
|
delete linkProps.disabled;
|
|
}
|
|
return React9.createElement(
|
|
_asChild ? _asChild : "a",
|
|
{
|
|
...linkProps,
|
|
ref: innerRef
|
|
},
|
|
children
|
|
);
|
|
}
|
|
);
|
|
function isCtrlEvent(e) {
|
|
return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
|
}
|
|
var linkOptions = (options) => {
|
|
return options;
|
|
};
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/route.js
|
|
function getRouteApi(id) {
|
|
return new RouteApi({ id });
|
|
}
|
|
var RouteApi = class extends BaseRouteApi {
|
|
/**
|
|
* @deprecated Use the `getRouteApi` function instead.
|
|
*/
|
|
constructor({ id }) {
|
|
super({ id });
|
|
this.useMatch = (opts) => {
|
|
return useMatch({
|
|
select: opts == null ? void 0 : opts.select,
|
|
from: this.id,
|
|
structuralSharing: opts == null ? void 0 : opts.structuralSharing
|
|
});
|
|
};
|
|
this.useRouteContext = (opts) => {
|
|
return useMatch({
|
|
from: this.id,
|
|
select: (d) => (opts == null ? void 0 : opts.select) ? opts.select(d.context) : d.context
|
|
});
|
|
};
|
|
this.useSearch = (opts) => {
|
|
return useSearch({
|
|
select: opts == null ? void 0 : opts.select,
|
|
structuralSharing: opts == null ? void 0 : opts.structuralSharing,
|
|
from: this.id
|
|
});
|
|
};
|
|
this.useParams = (opts) => {
|
|
return useParams({
|
|
select: opts == null ? void 0 : opts.select,
|
|
structuralSharing: opts == null ? void 0 : opts.structuralSharing,
|
|
from: this.id
|
|
});
|
|
};
|
|
this.useLoaderDeps = (opts) => {
|
|
return useLoaderDeps({ ...opts, from: this.id, strict: false });
|
|
};
|
|
this.useLoaderData = (opts) => {
|
|
return useLoaderData({ ...opts, from: this.id, strict: false });
|
|
};
|
|
this.useNavigate = () => {
|
|
const router = useRouter();
|
|
return useNavigate({ from: router.routesById[this.id].fullPath });
|
|
};
|
|
this.notFound = (opts) => {
|
|
return notFound({ routeId: this.id, ...opts });
|
|
};
|
|
this.Link = import_react3.default.forwardRef((props, ref) => {
|
|
const router = useRouter();
|
|
const fullPath = router.routesById[this.id].fullPath;
|
|
return (0, import_jsx_runtime5.jsx)(Link, { ref, from: fullPath, ...props });
|
|
});
|
|
}
|
|
};
|
|
var Route = class extends BaseRoute {
|
|
/**
|
|
* @deprecated Use the `createRoute` function instead.
|
|
*/
|
|
constructor(options) {
|
|
super(options);
|
|
this.useMatch = (opts) => {
|
|
return useMatch({
|
|
select: opts == null ? void 0 : opts.select,
|
|
from: this.id,
|
|
structuralSharing: opts == null ? void 0 : opts.structuralSharing
|
|
});
|
|
};
|
|
this.useRouteContext = (opts) => {
|
|
return useMatch({
|
|
...opts,
|
|
from: this.id,
|
|
select: (d) => (opts == null ? void 0 : opts.select) ? opts.select(d.context) : d.context
|
|
});
|
|
};
|
|
this.useSearch = (opts) => {
|
|
return useSearch({
|
|
select: opts == null ? void 0 : opts.select,
|
|
structuralSharing: opts == null ? void 0 : opts.structuralSharing,
|
|
from: this.id
|
|
});
|
|
};
|
|
this.useParams = (opts) => {
|
|
return useParams({
|
|
select: opts == null ? void 0 : opts.select,
|
|
structuralSharing: opts == null ? void 0 : opts.structuralSharing,
|
|
from: this.id
|
|
});
|
|
};
|
|
this.useLoaderDeps = (opts) => {
|
|
return useLoaderDeps({ ...opts, from: this.id });
|
|
};
|
|
this.useLoaderData = (opts) => {
|
|
return useLoaderData({ ...opts, from: this.id });
|
|
};
|
|
this.useNavigate = () => {
|
|
return useNavigate({ from: this.fullPath });
|
|
};
|
|
this.Link = import_react3.default.forwardRef(
|
|
(props, ref) => {
|
|
return (0, import_jsx_runtime5.jsx)(Link, { ref, from: this.fullPath, ...props });
|
|
}
|
|
);
|
|
this.$$typeof = Symbol.for("react.memo");
|
|
}
|
|
};
|
|
function createRoute(options) {
|
|
return new Route(options);
|
|
}
|
|
function createRootRouteWithContext() {
|
|
return (options) => {
|
|
return createRootRoute(options);
|
|
};
|
|
}
|
|
var rootRouteWithContext = createRootRouteWithContext;
|
|
var RootRoute = class extends BaseRootRoute {
|
|
/**
|
|
* @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
|
|
*/
|
|
constructor(options) {
|
|
super(options);
|
|
this.useMatch = (opts) => {
|
|
return useMatch({
|
|
select: opts == null ? void 0 : opts.select,
|
|
from: this.id,
|
|
structuralSharing: opts == null ? void 0 : opts.structuralSharing
|
|
});
|
|
};
|
|
this.useRouteContext = (opts) => {
|
|
return useMatch({
|
|
...opts,
|
|
from: this.id,
|
|
select: (d) => (opts == null ? void 0 : opts.select) ? opts.select(d.context) : d.context
|
|
});
|
|
};
|
|
this.useSearch = (opts) => {
|
|
return useSearch({
|
|
select: opts == null ? void 0 : opts.select,
|
|
structuralSharing: opts == null ? void 0 : opts.structuralSharing,
|
|
from: this.id
|
|
});
|
|
};
|
|
this.useParams = (opts) => {
|
|
return useParams({
|
|
select: opts == null ? void 0 : opts.select,
|
|
structuralSharing: opts == null ? void 0 : opts.structuralSharing,
|
|
from: this.id
|
|
});
|
|
};
|
|
this.useLoaderDeps = (opts) => {
|
|
return useLoaderDeps({ ...opts, from: this.id });
|
|
};
|
|
this.useLoaderData = (opts) => {
|
|
return useLoaderData({ ...opts, from: this.id });
|
|
};
|
|
this.useNavigate = () => {
|
|
return useNavigate({ from: this.fullPath });
|
|
};
|
|
this.Link = import_react3.default.forwardRef(
|
|
(props, ref) => {
|
|
return (0, import_jsx_runtime5.jsx)(Link, { ref, from: this.fullPath, ...props });
|
|
}
|
|
);
|
|
this.$$typeof = Symbol.for("react.memo");
|
|
}
|
|
};
|
|
function createRootRoute(options) {
|
|
return new RootRoute(options);
|
|
}
|
|
function createRouteMask(opts) {
|
|
return opts;
|
|
}
|
|
var NotFoundRoute = class extends Route {
|
|
constructor(options) {
|
|
super({
|
|
...options,
|
|
id: "404"
|
|
});
|
|
}
|
|
};
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/fileRoute.js
|
|
function createFileRoute(path) {
|
|
if (typeof path === "object") {
|
|
return new FileRoute(path, {
|
|
silent: true
|
|
}).createRoute(path);
|
|
}
|
|
return new FileRoute(path, {
|
|
silent: true
|
|
}).createRoute;
|
|
}
|
|
var FileRoute = class {
|
|
constructor(path, _opts) {
|
|
this.path = path;
|
|
this.createRoute = (options) => {
|
|
tiny_warning_esm_default(
|
|
this.silent,
|
|
"FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead."
|
|
);
|
|
const route = createRoute(options);
|
|
route.isRoot = false;
|
|
return route;
|
|
};
|
|
this.silent = _opts == null ? void 0 : _opts.silent;
|
|
}
|
|
};
|
|
function FileRouteLoader(_path) {
|
|
tiny_warning_esm_default(
|
|
false,
|
|
`FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \`createFileRoute('/path/to/file')(options)\` options`
|
|
);
|
|
return (loaderFn) => loaderFn;
|
|
}
|
|
var LazyRoute = class {
|
|
constructor(opts) {
|
|
this.useMatch = (opts2) => {
|
|
return useMatch({
|
|
select: opts2 == null ? void 0 : opts2.select,
|
|
from: this.options.id,
|
|
structuralSharing: opts2 == null ? void 0 : opts2.structuralSharing
|
|
});
|
|
};
|
|
this.useRouteContext = (opts2) => {
|
|
return useMatch({
|
|
from: this.options.id,
|
|
select: (d) => (opts2 == null ? void 0 : opts2.select) ? opts2.select(d.context) : d.context
|
|
});
|
|
};
|
|
this.useSearch = (opts2) => {
|
|
return useSearch({
|
|
select: opts2 == null ? void 0 : opts2.select,
|
|
structuralSharing: opts2 == null ? void 0 : opts2.structuralSharing,
|
|
from: this.options.id
|
|
});
|
|
};
|
|
this.useParams = (opts2) => {
|
|
return useParams({
|
|
select: opts2 == null ? void 0 : opts2.select,
|
|
structuralSharing: opts2 == null ? void 0 : opts2.structuralSharing,
|
|
from: this.options.id
|
|
});
|
|
};
|
|
this.useLoaderDeps = (opts2) => {
|
|
return useLoaderDeps({ ...opts2, from: this.options.id });
|
|
};
|
|
this.useLoaderData = (opts2) => {
|
|
return useLoaderData({ ...opts2, from: this.options.id });
|
|
};
|
|
this.useNavigate = () => {
|
|
const router = useRouter();
|
|
return useNavigate({ from: router.routesById[this.options.id].fullPath });
|
|
};
|
|
this.options = opts;
|
|
this.$$typeof = Symbol.for("react.memo");
|
|
}
|
|
};
|
|
function createLazyRoute(id) {
|
|
return (opts) => {
|
|
return new LazyRoute({
|
|
id,
|
|
...opts
|
|
});
|
|
};
|
|
}
|
|
function createLazyFileRoute(id) {
|
|
if (typeof id === "object") {
|
|
return new LazyRoute(id);
|
|
}
|
|
return (opts) => new LazyRoute({ id, ...opts });
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/lazyRouteComponent.js
|
|
var React10 = __toESM(require_react(), 1);
|
|
function lazyRouteComponent(importer, exportName) {
|
|
let loadPromise;
|
|
let comp;
|
|
let error;
|
|
let reload;
|
|
const load = () => {
|
|
if (!loadPromise) {
|
|
loadPromise = importer().then((res) => {
|
|
loadPromise = void 0;
|
|
comp = res[exportName ?? "default"];
|
|
}).catch((err) => {
|
|
error = err;
|
|
if (isModuleNotFoundError(error)) {
|
|
if (error instanceof Error && typeof window !== "undefined" && typeof sessionStorage !== "undefined") {
|
|
const storageKey2 = `tanstack_router_reload:${error.message}`;
|
|
if (!sessionStorage.getItem(storageKey2)) {
|
|
sessionStorage.setItem(storageKey2, "1");
|
|
reload = true;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return loadPromise;
|
|
};
|
|
const lazyComp = function Lazy(props) {
|
|
if (reload) {
|
|
window.location.reload();
|
|
throw new Promise(() => {
|
|
});
|
|
}
|
|
if (error) {
|
|
throw error;
|
|
}
|
|
if (!comp) {
|
|
throw load();
|
|
}
|
|
return React10.createElement(comp, props);
|
|
};
|
|
lazyComp.preload = load;
|
|
return lazyComp;
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/Matches.js
|
|
var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
|
|
var React13 = __toESM(require_react(), 1);
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/Transitioner.js
|
|
var React11 = __toESM(require_react(), 1);
|
|
function Transitioner() {
|
|
const router = useRouter();
|
|
const mountLoadForRouter = React11.useRef({ router, mounted: false });
|
|
const [isTransitioning, setIsTransitioning] = React11.useState(false);
|
|
const { hasPendingMatches, isLoading } = useRouterState({
|
|
select: (s) => ({
|
|
isLoading: s.isLoading,
|
|
hasPendingMatches: s.matches.some((d) => d.status === "pending")
|
|
}),
|
|
structuralSharing: true
|
|
});
|
|
const previousIsLoading = usePrevious(isLoading);
|
|
const isAnyPending = isLoading || isTransitioning || hasPendingMatches;
|
|
const previousIsAnyPending = usePrevious(isAnyPending);
|
|
const isPagePending = isLoading || hasPendingMatches;
|
|
const previousIsPagePending = usePrevious(isPagePending);
|
|
router.startTransition = (fn) => {
|
|
setIsTransitioning(true);
|
|
React11.startTransition(() => {
|
|
fn();
|
|
setIsTransitioning(false);
|
|
});
|
|
};
|
|
React11.useEffect(() => {
|
|
const unsub = router.history.subscribe(router.load);
|
|
const nextLocation = router.buildLocation({
|
|
to: router.latestLocation.pathname,
|
|
search: true,
|
|
params: true,
|
|
hash: true,
|
|
state: true,
|
|
_includeValidateSearch: true
|
|
});
|
|
if (trimPathRight(router.latestLocation.href) !== trimPathRight(nextLocation.href)) {
|
|
router.commitLocation({ ...nextLocation, replace: true });
|
|
}
|
|
return () => {
|
|
unsub();
|
|
};
|
|
}, [router, router.history]);
|
|
useLayoutEffect2(() => {
|
|
if (
|
|
// if we are hydrating from SSR, loading is triggered in ssr-client
|
|
typeof window !== "undefined" && router.ssr || mountLoadForRouter.current.router === router && mountLoadForRouter.current.mounted
|
|
) {
|
|
return;
|
|
}
|
|
mountLoadForRouter.current = { router, mounted: true };
|
|
const tryLoad = async () => {
|
|
try {
|
|
await router.load();
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
};
|
|
tryLoad();
|
|
}, [router]);
|
|
useLayoutEffect2(() => {
|
|
if (previousIsLoading && !isLoading) {
|
|
router.emit({
|
|
type: "onLoad",
|
|
// When the new URL has committed, when the new matches have been loaded into state.matches
|
|
...getLocationChangeInfo(router.state)
|
|
});
|
|
}
|
|
}, [previousIsLoading, router, isLoading]);
|
|
useLayoutEffect2(() => {
|
|
if (previousIsPagePending && !isPagePending) {
|
|
router.emit({
|
|
type: "onBeforeRouteMount",
|
|
...getLocationChangeInfo(router.state)
|
|
});
|
|
}
|
|
}, [isPagePending, previousIsPagePending, router]);
|
|
useLayoutEffect2(() => {
|
|
if (previousIsAnyPending && !isAnyPending) {
|
|
router.emit({
|
|
type: "onResolved",
|
|
...getLocationChangeInfo(router.state)
|
|
});
|
|
router.__store.setState((s) => ({
|
|
...s,
|
|
status: "idle",
|
|
resolvedLocation: s.location
|
|
}));
|
|
handleHashScroll(router);
|
|
}
|
|
}, [isAnyPending, previousIsAnyPending, router]);
|
|
return null;
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/Match.js
|
|
var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
|
|
var React12 = __toESM(require_react(), 1);
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/not-found.js
|
|
var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
|
|
function CatchNotFound(props) {
|
|
const resetKey = useRouterState({
|
|
select: (s) => `not-found-${s.location.pathname}-${s.status}`
|
|
});
|
|
return (0, import_jsx_runtime6.jsx)(
|
|
CatchBoundary,
|
|
{
|
|
getResetKey: () => resetKey,
|
|
onCatch: (error, errorInfo) => {
|
|
var _a;
|
|
if (isNotFound(error)) {
|
|
(_a = props.onCatch) == null ? void 0 : _a.call(props, error, errorInfo);
|
|
} else {
|
|
throw error;
|
|
}
|
|
},
|
|
errorComponent: ({ error }) => {
|
|
var _a;
|
|
if (isNotFound(error)) {
|
|
return (_a = props.fallback) == null ? void 0 : _a.call(props, error);
|
|
} else {
|
|
throw error;
|
|
}
|
|
},
|
|
children: props.children
|
|
}
|
|
);
|
|
}
|
|
function DefaultGlobalNotFound() {
|
|
return (0, import_jsx_runtime6.jsx)("p", { children: "Not Found" });
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/SafeFragment.js
|
|
var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
|
|
function SafeFragment(props) {
|
|
return (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: props.children });
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/renderRouteNotFound.js
|
|
var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
|
|
function renderRouteNotFound(router, route, data) {
|
|
if (!route.options.notFoundComponent) {
|
|
if (router.options.defaultNotFoundComponent) {
|
|
return (0, import_jsx_runtime8.jsx)(router.options.defaultNotFoundComponent, { data });
|
|
}
|
|
if (true) {
|
|
tiny_warning_esm_default(
|
|
route.options.notFoundComponent,
|
|
`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>)`
|
|
);
|
|
}
|
|
return (0, import_jsx_runtime8.jsx)(DefaultGlobalNotFound, {});
|
|
}
|
|
return (0, import_jsx_runtime8.jsx)(route.options.notFoundComponent, { data });
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/scroll-restoration.js
|
|
var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/ScriptOnce.js
|
|
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
|
|
function ScriptOnce({
|
|
children
|
|
}) {
|
|
if (typeof document !== "undefined") {
|
|
return null;
|
|
}
|
|
return (0, import_jsx_runtime9.jsx)(
|
|
"script",
|
|
{
|
|
className: "$tsr",
|
|
dangerouslySetInnerHTML: {
|
|
__html: [children].filter(Boolean).join("\n")
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/scroll-restoration.js
|
|
function ScrollRestoration() {
|
|
const router = useRouter();
|
|
const getKey = router.options.getScrollRestorationKey || defaultGetScrollRestorationKey;
|
|
const userKey = getKey(router.latestLocation);
|
|
const resolvedKey = userKey !== defaultGetScrollRestorationKey(router.latestLocation) ? userKey : void 0;
|
|
if (!router.isScrollRestoring || !router.isServer) {
|
|
return null;
|
|
}
|
|
const restoreScrollOptions = {
|
|
storageKey,
|
|
shouldScrollRestoration: true
|
|
};
|
|
if (resolvedKey) {
|
|
restoreScrollOptions.key = resolvedKey;
|
|
}
|
|
return (0, import_jsx_runtime10.jsx)(
|
|
ScriptOnce,
|
|
{
|
|
children: `(${restoreScroll.toString()})(${JSON.stringify(restoreScrollOptions)})`
|
|
}
|
|
);
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/Match.js
|
|
var Match = React12.memo(function MatchImpl({
|
|
matchId
|
|
}) {
|
|
var _a, _b;
|
|
const router = useRouter();
|
|
const matchState = useRouterState({
|
|
select: (s) => {
|
|
const match = s.matches.find((d) => d.id === matchId);
|
|
invariant(
|
|
match,
|
|
`Could not find match for matchId "${matchId}". Please file an issue!`
|
|
);
|
|
return {
|
|
routeId: match.routeId,
|
|
ssr: match.ssr,
|
|
_displayPending: match._displayPending
|
|
};
|
|
},
|
|
structuralSharing: true
|
|
});
|
|
const route = router.routesById[matchState.routeId];
|
|
const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
const pendingElement = PendingComponent ? (0, import_jsx_runtime11.jsx)(PendingComponent, {}) : null;
|
|
const routeErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent;
|
|
const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch;
|
|
const routeNotFoundComponent = route.isRoot ? (
|
|
// If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component
|
|
route.options.notFoundComponent ?? ((_a = router.options.notFoundRoute) == null ? void 0 : _a.options.component)
|
|
) : route.options.notFoundComponent;
|
|
const resolvedNoSsr = matchState.ssr === false || matchState.ssr === "data-only";
|
|
const ResolvedSuspenseBoundary = (
|
|
// If we're on the root route, allow forcefully wrapping in suspense
|
|
(!route.isRoot || route.options.wrapInSuspense || resolvedNoSsr) && (route.options.wrapInSuspense ?? PendingComponent ?? (((_b = route.options.errorComponent) == null ? void 0 : _b.preload) || resolvedNoSsr)) ? React12.Suspense : SafeFragment
|
|
);
|
|
const ResolvedCatchBoundary = routeErrorComponent ? CatchBoundary : SafeFragment;
|
|
const ResolvedNotFoundBoundary = routeNotFoundComponent ? CatchNotFound : SafeFragment;
|
|
const resetKey = useRouterState({
|
|
select: (s) => s.loadedAt
|
|
});
|
|
const parentRouteId = useRouterState({
|
|
select: (s) => {
|
|
var _a2;
|
|
const index = s.matches.findIndex((d) => d.id === matchId);
|
|
return (_a2 = s.matches[index - 1]) == null ? void 0 : _a2.routeId;
|
|
}
|
|
});
|
|
const ShellComponent = route.isRoot ? route.options.shellComponent ?? SafeFragment : SafeFragment;
|
|
return (0, import_jsx_runtime11.jsxs)(ShellComponent, { children: [
|
|
(0, import_jsx_runtime11.jsx)(matchContext.Provider, { value: matchId, children: (0, import_jsx_runtime11.jsx)(ResolvedSuspenseBoundary, { fallback: pendingElement, children: (0, import_jsx_runtime11.jsx)(
|
|
ResolvedCatchBoundary,
|
|
{
|
|
getResetKey: () => resetKey,
|
|
errorComponent: routeErrorComponent || ErrorComponent,
|
|
onCatch: (error, errorInfo) => {
|
|
if (isNotFound(error)) throw error;
|
|
tiny_warning_esm_default(false, `Error in route match: ${matchId}`);
|
|
routeOnCatch == null ? void 0 : routeOnCatch(error, errorInfo);
|
|
},
|
|
children: (0, import_jsx_runtime11.jsx)(
|
|
ResolvedNotFoundBoundary,
|
|
{
|
|
fallback: (error) => {
|
|
if (!routeNotFoundComponent || error.routeId && error.routeId !== matchState.routeId || !error.routeId && !route.isRoot)
|
|
throw error;
|
|
return React12.createElement(routeNotFoundComponent, error);
|
|
},
|
|
children: resolvedNoSsr || matchState._displayPending ? (0, import_jsx_runtime11.jsx)(ClientOnly, { fallback: pendingElement, children: (0, import_jsx_runtime11.jsx)(MatchInner, { matchId }) }) : (0, import_jsx_runtime11.jsx)(MatchInner, { matchId })
|
|
}
|
|
)
|
|
}
|
|
) }) }),
|
|
parentRouteId === rootRouteId && router.options.scrollRestoration ? (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
(0, import_jsx_runtime11.jsx)(OnRendered, {}),
|
|
(0, import_jsx_runtime11.jsx)(ScrollRestoration, {})
|
|
] }) : null
|
|
] });
|
|
});
|
|
function OnRendered() {
|
|
const router = useRouter();
|
|
const prevLocationRef = React12.useRef(
|
|
void 0
|
|
);
|
|
return (0, import_jsx_runtime11.jsx)(
|
|
"script",
|
|
{
|
|
suppressHydrationWarning: true,
|
|
ref: (el) => {
|
|
if (el && (prevLocationRef.current === void 0 || prevLocationRef.current.href !== router.latestLocation.href)) {
|
|
router.emit({
|
|
type: "onRendered",
|
|
...getLocationChangeInfo(router.state)
|
|
});
|
|
prevLocationRef.current = router.latestLocation;
|
|
}
|
|
}
|
|
},
|
|
router.latestLocation.state.__TSR_key
|
|
);
|
|
}
|
|
var MatchInner = React12.memo(function MatchInnerImpl({
|
|
matchId
|
|
}) {
|
|
var _a, _b, _c, _d;
|
|
const router = useRouter();
|
|
const { match, key, routeId } = useRouterState({
|
|
select: (s) => {
|
|
const match2 = s.matches.find((d) => d.id === matchId);
|
|
const routeId2 = match2.routeId;
|
|
const remountFn = router.routesById[routeId2].options.remountDeps ?? router.options.defaultRemountDeps;
|
|
const remountDeps = remountFn == null ? void 0 : remountFn({
|
|
routeId: routeId2,
|
|
loaderDeps: match2.loaderDeps,
|
|
params: match2._strictParams,
|
|
search: match2._strictSearch
|
|
});
|
|
const key2 = remountDeps ? JSON.stringify(remountDeps) : void 0;
|
|
return {
|
|
key: key2,
|
|
routeId: routeId2,
|
|
match: {
|
|
id: match2.id,
|
|
status: match2.status,
|
|
error: match2.error,
|
|
_forcePending: match2._forcePending,
|
|
_displayPending: match2._displayPending
|
|
}
|
|
};
|
|
},
|
|
structuralSharing: true
|
|
});
|
|
const route = router.routesById[routeId];
|
|
const out = React12.useMemo(() => {
|
|
const Comp = route.options.component ?? router.options.defaultComponent;
|
|
if (Comp) {
|
|
return (0, import_jsx_runtime11.jsx)(Comp, {}, key);
|
|
}
|
|
return (0, import_jsx_runtime11.jsx)(Outlet, {});
|
|
}, [key, route.options.component, router.options.defaultComponent]);
|
|
if (match._displayPending) {
|
|
throw (_a = router.getMatch(match.id)) == null ? void 0 : _a._nonReactive.displayPendingPromise;
|
|
}
|
|
if (match._forcePending) {
|
|
throw (_b = router.getMatch(match.id)) == null ? void 0 : _b._nonReactive.minPendingPromise;
|
|
}
|
|
if (match.status === "pending") {
|
|
const pendingMinMs = route.options.pendingMinMs ?? router.options.defaultPendingMinMs;
|
|
if (pendingMinMs) {
|
|
const routerMatch = router.getMatch(match.id);
|
|
if (routerMatch && !routerMatch._nonReactive.minPendingPromise) {
|
|
if (!router.isServer) {
|
|
const minPendingPromise = createControlledPromise();
|
|
Promise.resolve().then(() => {
|
|
routerMatch._nonReactive.minPendingPromise = minPendingPromise;
|
|
});
|
|
setTimeout(() => {
|
|
minPendingPromise.resolve();
|
|
routerMatch._nonReactive.minPendingPromise = void 0;
|
|
}, pendingMinMs);
|
|
}
|
|
}
|
|
}
|
|
throw (_c = router.getMatch(match.id)) == null ? void 0 : _c._nonReactive.loadPromise;
|
|
}
|
|
if (match.status === "notFound") {
|
|
invariant(isNotFound(match.error), "Expected a notFound error");
|
|
return renderRouteNotFound(router, route, match.error);
|
|
}
|
|
if (match.status === "redirected") {
|
|
invariant(isRedirect(match.error), "Expected a redirect error");
|
|
throw (_d = router.getMatch(match.id)) == null ? void 0 : _d._nonReactive.loadPromise;
|
|
}
|
|
if (match.status === "error") {
|
|
if (router.isServer) {
|
|
const RouteErrorComponent = (route.options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent;
|
|
return (0, import_jsx_runtime11.jsx)(
|
|
RouteErrorComponent,
|
|
{
|
|
error: match.error,
|
|
reset: void 0,
|
|
info: {
|
|
componentStack: ""
|
|
}
|
|
}
|
|
);
|
|
}
|
|
throw match.error;
|
|
}
|
|
return out;
|
|
});
|
|
var Outlet = React12.memo(function OutletImpl() {
|
|
const router = useRouter();
|
|
const matchId = React12.useContext(matchContext);
|
|
const routeId = useRouterState({
|
|
select: (s) => {
|
|
var _a;
|
|
return (_a = s.matches.find((d) => d.id === matchId)) == null ? void 0 : _a.routeId;
|
|
}
|
|
});
|
|
const route = router.routesById[routeId];
|
|
const parentGlobalNotFound = useRouterState({
|
|
select: (s) => {
|
|
const matches = s.matches;
|
|
const parentMatch = matches.find((d) => d.id === matchId);
|
|
invariant(
|
|
parentMatch,
|
|
`Could not find parent match for matchId "${matchId}"`
|
|
);
|
|
return parentMatch.globalNotFound;
|
|
}
|
|
});
|
|
const childMatchId = useRouterState({
|
|
select: (s) => {
|
|
var _a;
|
|
const matches = s.matches;
|
|
const index = matches.findIndex((d) => d.id === matchId);
|
|
return (_a = matches[index + 1]) == null ? void 0 : _a.id;
|
|
}
|
|
});
|
|
const pendingElement = router.options.defaultPendingComponent ? (0, import_jsx_runtime11.jsx)(router.options.defaultPendingComponent, {}) : null;
|
|
if (parentGlobalNotFound) {
|
|
return renderRouteNotFound(router, route, void 0);
|
|
}
|
|
if (!childMatchId) {
|
|
return null;
|
|
}
|
|
const nextMatch = (0, import_jsx_runtime11.jsx)(Match, { matchId: childMatchId });
|
|
if (matchId === rootRouteId) {
|
|
return (0, import_jsx_runtime11.jsx)(React12.Suspense, { fallback: pendingElement, children: nextMatch });
|
|
}
|
|
return nextMatch;
|
|
});
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/Matches.js
|
|
function Matches() {
|
|
const router = useRouter();
|
|
const pendingElement = router.options.defaultPendingComponent ? (0, import_jsx_runtime12.jsx)(router.options.defaultPendingComponent, {}) : null;
|
|
const ResolvedSuspense = router.isServer || typeof document !== "undefined" && router.ssr ? SafeFragment : React13.Suspense;
|
|
const inner = (0, import_jsx_runtime12.jsxs)(ResolvedSuspense, { fallback: pendingElement, children: [
|
|
!router.isServer && (0, import_jsx_runtime12.jsx)(Transitioner, {}),
|
|
(0, import_jsx_runtime12.jsx)(MatchesInner, {})
|
|
] });
|
|
return router.options.InnerWrap ? (0, import_jsx_runtime12.jsx)(router.options.InnerWrap, { children: inner }) : inner;
|
|
}
|
|
function MatchesInner() {
|
|
const router = useRouter();
|
|
const matchId = useRouterState({
|
|
select: (s) => {
|
|
var _a;
|
|
return (_a = s.matches[0]) == null ? void 0 : _a.id;
|
|
}
|
|
});
|
|
const resetKey = useRouterState({
|
|
select: (s) => s.loadedAt
|
|
});
|
|
const matchComponent = matchId ? (0, import_jsx_runtime12.jsx)(Match, { matchId }) : null;
|
|
return (0, import_jsx_runtime12.jsx)(matchContext.Provider, { value: matchId, children: router.options.disableGlobalCatchBoundary ? matchComponent : (0, import_jsx_runtime12.jsx)(
|
|
CatchBoundary,
|
|
{
|
|
getResetKey: () => resetKey,
|
|
errorComponent: ErrorComponent,
|
|
onCatch: (error) => {
|
|
tiny_warning_esm_default(
|
|
false,
|
|
`The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`
|
|
);
|
|
tiny_warning_esm_default(false, error.message || error.toString());
|
|
},
|
|
children: matchComponent
|
|
}
|
|
) });
|
|
}
|
|
function useMatchRoute() {
|
|
const router = useRouter();
|
|
useRouterState({
|
|
select: (s) => {
|
|
var _a;
|
|
return [s.location.href, (_a = s.resolvedLocation) == null ? void 0 : _a.href, s.status];
|
|
},
|
|
structuralSharing: true
|
|
});
|
|
return React13.useCallback(
|
|
(opts) => {
|
|
const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts;
|
|
return router.matchRoute(rest, {
|
|
pending,
|
|
caseSensitive,
|
|
fuzzy,
|
|
includeSearch
|
|
});
|
|
},
|
|
[router]
|
|
);
|
|
}
|
|
function MatchRoute(props) {
|
|
const matchRoute = useMatchRoute();
|
|
const params = matchRoute(props);
|
|
if (typeof props.children === "function") {
|
|
return props.children(params);
|
|
}
|
|
return params ? props.children : null;
|
|
}
|
|
function useMatches(opts) {
|
|
return useRouterState({
|
|
select: (state) => {
|
|
const matches = state.matches;
|
|
return (opts == null ? void 0 : opts.select) ? opts.select(matches) : matches;
|
|
},
|
|
structuralSharing: opts == null ? void 0 : opts.structuralSharing
|
|
});
|
|
}
|
|
function useParentMatches(opts) {
|
|
const contextMatchId = React13.useContext(matchContext);
|
|
return useMatches({
|
|
select: (matches) => {
|
|
matches = matches.slice(
|
|
0,
|
|
matches.findIndex((d) => d.id === contextMatchId)
|
|
);
|
|
return (opts == null ? void 0 : opts.select) ? opts.select(matches) : matches;
|
|
},
|
|
structuralSharing: opts == null ? void 0 : opts.structuralSharing
|
|
});
|
|
}
|
|
function useChildMatches(opts) {
|
|
const contextMatchId = React13.useContext(matchContext);
|
|
return useMatches({
|
|
select: (matches) => {
|
|
matches = matches.slice(
|
|
matches.findIndex((d) => d.id === contextMatchId) + 1
|
|
);
|
|
return (opts == null ? void 0 : opts.select) ? opts.select(matches) : matches;
|
|
},
|
|
structuralSharing: opts == null ? void 0 : opts.structuralSharing
|
|
});
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/router.js
|
|
var createRouter = (options) => {
|
|
return new Router(options);
|
|
};
|
|
var Router = class extends RouterCore {
|
|
constructor(options) {
|
|
super(options);
|
|
}
|
|
};
|
|
if (typeof globalThis !== "undefined") {
|
|
globalThis.createFileRoute = createFileRoute;
|
|
globalThis.createLazyFileRoute = createLazyFileRoute;
|
|
} else if (typeof window !== "undefined") {
|
|
window.createFileRoute = createFileRoute;
|
|
window.createFileRoute = createLazyFileRoute;
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/RouterProvider.js
|
|
var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
|
|
function RouterContextProvider({
|
|
router,
|
|
children,
|
|
...rest
|
|
}) {
|
|
if (Object.keys(rest).length > 0) {
|
|
router.update({
|
|
...router.options,
|
|
...rest,
|
|
context: {
|
|
...router.options.context,
|
|
...rest.context
|
|
}
|
|
});
|
|
}
|
|
const routerContext2 = getRouterContext();
|
|
const provider = (0, import_jsx_runtime13.jsx)(routerContext2.Provider, { value: router, children });
|
|
if (router.options.Wrap) {
|
|
return (0, import_jsx_runtime13.jsx)(router.options.Wrap, { children: provider });
|
|
}
|
|
return provider;
|
|
}
|
|
function RouterProvider({ router, ...rest }) {
|
|
return (0, import_jsx_runtime13.jsx)(RouterContextProvider, { router, ...rest, children: (0, import_jsx_runtime13.jsx)(Matches, {}) });
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/ScrollRestoration.js
|
|
function useScrollRestoration() {
|
|
const router = useRouter();
|
|
setupScrollRestoration(router, true);
|
|
}
|
|
function ScrollRestoration2(_props) {
|
|
useScrollRestoration();
|
|
if (true) {
|
|
console.warn(
|
|
"The ScrollRestoration component is deprecated. Use createRouter's `scrollRestoration` option instead."
|
|
);
|
|
}
|
|
return null;
|
|
}
|
|
function useElementScrollRestoration(options) {
|
|
var _a, _b;
|
|
useScrollRestoration();
|
|
const router = useRouter();
|
|
const getKey = options.getKey || defaultGetScrollRestorationKey;
|
|
let elementSelector = "";
|
|
if (options.id) {
|
|
elementSelector = `[data-scroll-restoration-id="${options.id}"]`;
|
|
} else {
|
|
const element = (_a = options.getElement) == null ? void 0 : _a.call(options);
|
|
if (!element) {
|
|
return;
|
|
}
|
|
elementSelector = element instanceof Window ? "window" : getCssSelector(element);
|
|
}
|
|
const restoreKey = getKey(router.latestLocation);
|
|
const byKey = (_b = scrollRestorationCache) == null ? void 0 : _b.state[restoreKey];
|
|
return byKey == null ? void 0 : byKey[elementSelector];
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useBlocker.js
|
|
var React14 = __toESM(require_react(), 1);
|
|
function _resolveBlockerOpts(opts, condition) {
|
|
if (opts === void 0) {
|
|
return {
|
|
shouldBlockFn: () => true,
|
|
withResolver: false
|
|
};
|
|
}
|
|
if ("shouldBlockFn" in opts) {
|
|
return opts;
|
|
}
|
|
if (typeof opts === "function") {
|
|
const shouldBlock2 = Boolean(condition ?? true);
|
|
const _customBlockerFn2 = async () => {
|
|
if (shouldBlock2) return await opts();
|
|
return false;
|
|
};
|
|
return {
|
|
shouldBlockFn: _customBlockerFn2,
|
|
enableBeforeUnload: shouldBlock2,
|
|
withResolver: false
|
|
};
|
|
}
|
|
const shouldBlock = Boolean(opts.condition ?? true);
|
|
const fn = opts.blockerFn;
|
|
const _customBlockerFn = async () => {
|
|
if (shouldBlock && fn !== void 0) {
|
|
return await fn();
|
|
}
|
|
return shouldBlock;
|
|
};
|
|
return {
|
|
shouldBlockFn: _customBlockerFn,
|
|
enableBeforeUnload: shouldBlock,
|
|
withResolver: fn === void 0
|
|
};
|
|
}
|
|
function useBlocker(opts, condition) {
|
|
const {
|
|
shouldBlockFn,
|
|
enableBeforeUnload = true,
|
|
disabled = false,
|
|
withResolver = false
|
|
} = _resolveBlockerOpts(opts, condition);
|
|
const router = useRouter();
|
|
const { history } = router;
|
|
const [resolver, setResolver] = React14.useState({
|
|
status: "idle",
|
|
current: void 0,
|
|
next: void 0,
|
|
action: void 0,
|
|
proceed: void 0,
|
|
reset: void 0
|
|
});
|
|
React14.useEffect(() => {
|
|
const blockerFnComposed = async (blockerFnArgs) => {
|
|
function getLocation(location) {
|
|
const parsedLocation = router.parseLocation(location);
|
|
const matchedRoutes = router.getMatchedRoutes(
|
|
parsedLocation.pathname,
|
|
void 0
|
|
);
|
|
if (matchedRoutes.foundRoute === void 0) {
|
|
throw new Error(`No route found for location ${location.href}`);
|
|
}
|
|
return {
|
|
routeId: matchedRoutes.foundRoute.id,
|
|
fullPath: matchedRoutes.foundRoute.fullPath,
|
|
pathname: parsedLocation.pathname,
|
|
params: matchedRoutes.routeParams,
|
|
search: parsedLocation.search
|
|
};
|
|
}
|
|
const current = getLocation(blockerFnArgs.currentLocation);
|
|
const next = getLocation(blockerFnArgs.nextLocation);
|
|
const shouldBlock = await shouldBlockFn({
|
|
action: blockerFnArgs.action,
|
|
current,
|
|
next
|
|
});
|
|
if (!withResolver) {
|
|
return shouldBlock;
|
|
}
|
|
if (!shouldBlock) {
|
|
return false;
|
|
}
|
|
const promise = new Promise((resolve) => {
|
|
setResolver({
|
|
status: "blocked",
|
|
current,
|
|
next,
|
|
action: blockerFnArgs.action,
|
|
proceed: () => resolve(false),
|
|
reset: () => resolve(true)
|
|
});
|
|
});
|
|
const canNavigateAsync = await promise;
|
|
setResolver({
|
|
status: "idle",
|
|
current: void 0,
|
|
next: void 0,
|
|
action: void 0,
|
|
proceed: void 0,
|
|
reset: void 0
|
|
});
|
|
return canNavigateAsync;
|
|
};
|
|
return disabled ? void 0 : history.block({ blockerFn: blockerFnComposed, enableBeforeUnload });
|
|
}, [
|
|
shouldBlockFn,
|
|
enableBeforeUnload,
|
|
disabled,
|
|
withResolver,
|
|
history,
|
|
router
|
|
]);
|
|
return resolver;
|
|
}
|
|
var _resolvePromptBlockerArgs = (props) => {
|
|
if ("shouldBlockFn" in props) {
|
|
return { ...props };
|
|
}
|
|
const shouldBlock = Boolean(props.condition ?? true);
|
|
const fn = props.blockerFn;
|
|
const _customBlockerFn = async () => {
|
|
if (shouldBlock && fn !== void 0) {
|
|
return await fn();
|
|
}
|
|
return shouldBlock;
|
|
};
|
|
return {
|
|
shouldBlockFn: _customBlockerFn,
|
|
enableBeforeUnload: shouldBlock,
|
|
withResolver: fn === void 0
|
|
};
|
|
};
|
|
function Block(opts) {
|
|
const { children, ...rest } = opts;
|
|
const args = _resolvePromptBlockerArgs(rest);
|
|
const resolver = useBlocker(args);
|
|
return children ? typeof children === "function" ? children(resolver) : children : null;
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useRouteContext.js
|
|
function useRouteContext(opts) {
|
|
return useMatch({
|
|
...opts,
|
|
select: (match) => opts.select ? opts.select(match.context) : match.context
|
|
});
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useLocation.js
|
|
function useLocation(opts) {
|
|
return useRouterState({
|
|
select: (state) => (opts == null ? void 0 : opts.select) ? opts.select(state.location) : state.location
|
|
});
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/useCanGoBack.js
|
|
function useCanGoBack() {
|
|
return useRouterState({ select: (s) => s.location.state.__TSR_index !== 0 });
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/Asset.js
|
|
var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
|
|
var React15 = __toESM(require_react(), 1);
|
|
function Asset({
|
|
tag,
|
|
attrs,
|
|
children
|
|
}) {
|
|
switch (tag) {
|
|
case "title":
|
|
return (0, import_jsx_runtime14.jsx)("title", { ...attrs, suppressHydrationWarning: true, children });
|
|
case "meta":
|
|
return (0, import_jsx_runtime14.jsx)("meta", { ...attrs, suppressHydrationWarning: true });
|
|
case "link":
|
|
return (0, import_jsx_runtime14.jsx)("link", { ...attrs, suppressHydrationWarning: true });
|
|
case "style":
|
|
return (0, import_jsx_runtime14.jsx)(
|
|
"style",
|
|
{
|
|
...attrs,
|
|
dangerouslySetInnerHTML: { __html: children }
|
|
}
|
|
);
|
|
case "script":
|
|
return (0, import_jsx_runtime14.jsx)(Script, { attrs, children });
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
function Script({
|
|
attrs,
|
|
children
|
|
}) {
|
|
React15.useEffect(() => {
|
|
if (attrs == null ? void 0 : attrs.src) {
|
|
const script = document.createElement("script");
|
|
for (const [key, value] of Object.entries(attrs)) {
|
|
if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) {
|
|
script.setAttribute(
|
|
key,
|
|
typeof value === "boolean" ? "" : String(value)
|
|
);
|
|
}
|
|
}
|
|
document.head.appendChild(script);
|
|
return () => {
|
|
if (script.parentNode) {
|
|
script.parentNode.removeChild(script);
|
|
}
|
|
};
|
|
}
|
|
if (typeof children === "string") {
|
|
const script = document.createElement("script");
|
|
script.textContent = children;
|
|
if (attrs) {
|
|
for (const [key, value] of Object.entries(attrs)) {
|
|
if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) {
|
|
script.setAttribute(
|
|
key,
|
|
typeof value === "boolean" ? "" : String(value)
|
|
);
|
|
}
|
|
}
|
|
}
|
|
document.head.appendChild(script);
|
|
return () => {
|
|
if (script.parentNode) {
|
|
script.parentNode.removeChild(script);
|
|
}
|
|
};
|
|
}
|
|
return void 0;
|
|
}, [attrs, children]);
|
|
if ((attrs == null ? void 0 : attrs.src) && typeof attrs.src === "string") {
|
|
return (0, import_jsx_runtime14.jsx)("script", { ...attrs, suppressHydrationWarning: true });
|
|
}
|
|
if (typeof children === "string") {
|
|
return (0, import_jsx_runtime14.jsx)(
|
|
"script",
|
|
{
|
|
...attrs,
|
|
dangerouslySetInnerHTML: { __html: children },
|
|
suppressHydrationWarning: true
|
|
}
|
|
);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/HeadContent.js
|
|
var React16 = __toESM(require_react(), 1);
|
|
var import_react4 = __toESM(require_react(), 1);
|
|
var useTags = () => {
|
|
const router = useRouter();
|
|
const routeMeta = useRouterState({
|
|
select: (state) => {
|
|
return state.matches.map((match) => match.meta).filter(Boolean);
|
|
}
|
|
});
|
|
const meta = React16.useMemo(() => {
|
|
const resultMeta = [];
|
|
const metaByAttribute = {};
|
|
let title;
|
|
[...routeMeta].reverse().forEach((metas) => {
|
|
[...metas].reverse().forEach((m) => {
|
|
if (!m) return;
|
|
if (m.title) {
|
|
if (!title) {
|
|
title = {
|
|
tag: "title",
|
|
children: m.title
|
|
};
|
|
}
|
|
} else {
|
|
const attribute = m.name ?? m.property;
|
|
if (attribute) {
|
|
if (metaByAttribute[attribute]) {
|
|
return;
|
|
} else {
|
|
metaByAttribute[attribute] = true;
|
|
}
|
|
}
|
|
resultMeta.push({
|
|
tag: "meta",
|
|
attrs: {
|
|
...m
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
if (title) {
|
|
resultMeta.push(title);
|
|
}
|
|
resultMeta.reverse();
|
|
return resultMeta;
|
|
}, [routeMeta]);
|
|
const links = useRouterState({
|
|
select: (state) => {
|
|
var _a;
|
|
const constructed = state.matches.map((match) => match.links).filter(Boolean).flat(1).map((link) => ({
|
|
tag: "link",
|
|
attrs: {
|
|
...link
|
|
}
|
|
}));
|
|
const manifest = (_a = router.ssr) == null ? void 0 : _a.manifest;
|
|
const assets = state.matches.map((match) => {
|
|
var _a2;
|
|
return ((_a2 = manifest == null ? void 0 : manifest.routes[match.routeId]) == null ? void 0 : _a2.assets) ?? [];
|
|
}).filter(Boolean).flat(1).filter((asset) => asset.tag === "link").map(
|
|
(asset) => ({
|
|
tag: "link",
|
|
attrs: {
|
|
...asset.attrs,
|
|
suppressHydrationWarning: true
|
|
}
|
|
})
|
|
);
|
|
return [...constructed, ...assets];
|
|
},
|
|
structuralSharing: true
|
|
});
|
|
const preloadMeta = useRouterState({
|
|
select: (state) => {
|
|
const preloadMeta2 = [];
|
|
state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
|
|
(route) => {
|
|
var _a, _b, _c, _d;
|
|
return (_d = (_c = (_b = (_a = router.ssr) == null ? void 0 : _a.manifest) == null ? void 0 : _b.routes[route.id]) == null ? void 0 : _c.preloads) == null ? void 0 : _d.filter(Boolean).forEach((preload) => {
|
|
preloadMeta2.push({
|
|
tag: "link",
|
|
attrs: {
|
|
rel: "modulepreload",
|
|
href: preload
|
|
}
|
|
});
|
|
});
|
|
}
|
|
);
|
|
return preloadMeta2;
|
|
},
|
|
structuralSharing: true
|
|
});
|
|
const styles = useRouterState({
|
|
select: (state) => state.matches.map((match) => match.styles).flat(1).filter(Boolean).map(({ children, ...attrs }) => ({
|
|
tag: "style",
|
|
attrs,
|
|
children
|
|
})),
|
|
structuralSharing: true
|
|
});
|
|
const headScripts = useRouterState({
|
|
select: (state) => state.matches.map((match) => match.headScripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
|
|
tag: "script",
|
|
attrs: {
|
|
...script
|
|
},
|
|
children
|
|
})),
|
|
structuralSharing: true
|
|
});
|
|
return uniqBy(
|
|
[
|
|
...meta,
|
|
...preloadMeta,
|
|
...links,
|
|
...styles,
|
|
...headScripts
|
|
],
|
|
(d) => {
|
|
return JSON.stringify(d);
|
|
}
|
|
);
|
|
};
|
|
function HeadContent() {
|
|
const tags = useTags();
|
|
return tags.map((tag) => (0, import_react4.createElement)(Asset, { ...tag, key: `tsr-meta-${JSON.stringify(tag)}` }));
|
|
}
|
|
function uniqBy(arr, fn) {
|
|
const seen = /* @__PURE__ */ new Set();
|
|
return arr.filter((item) => {
|
|
const key = fn(item);
|
|
if (seen.has(key)) {
|
|
return false;
|
|
}
|
|
seen.add(key);
|
|
return true;
|
|
});
|
|
}
|
|
|
|
// node_modules/.pnpm/@tanstack+react-router@1.13_fa2ecf64975fde76e8218d35a2f1565b/node_modules/@tanstack/react-router/dist/esm/Scripts.js
|
|
var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
|
|
var import_react5 = __toESM(require_react(), 1);
|
|
var Scripts = () => {
|
|
const router = useRouter();
|
|
const assetScripts = useRouterState({
|
|
select: (state) => {
|
|
var _a;
|
|
const assetScripts2 = [];
|
|
const manifest = (_a = router.ssr) == null ? void 0 : _a.manifest;
|
|
if (!manifest) {
|
|
return [];
|
|
}
|
|
state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
|
|
(route) => {
|
|
var _a2, _b;
|
|
return (_b = (_a2 = manifest.routes[route.id]) == null ? void 0 : _a2.assets) == null ? void 0 : _b.filter((d) => d.tag === "script").forEach((asset) => {
|
|
assetScripts2.push({
|
|
tag: "script",
|
|
attrs: asset.attrs,
|
|
children: asset.children
|
|
});
|
|
});
|
|
}
|
|
);
|
|
return assetScripts2;
|
|
},
|
|
structuralSharing: true
|
|
});
|
|
const { scripts } = useRouterState({
|
|
select: (state) => ({
|
|
scripts: state.matches.map((match) => match.scripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
|
|
tag: "script",
|
|
attrs: {
|
|
...script,
|
|
suppressHydrationWarning: true
|
|
},
|
|
children
|
|
}))
|
|
}),
|
|
structuralSharing: true
|
|
});
|
|
const allScripts = [...scripts, ...assetScripts];
|
|
return (0, import_jsx_runtime15.jsx)(import_jsx_runtime15.Fragment, { children: allScripts.map((asset, i) => (0, import_react5.createElement)(Asset, { ...asset, key: `tsr-scripts-${asset.tag}-${i}` })) });
|
|
};
|
|
export {
|
|
Asset,
|
|
Await,
|
|
Block,
|
|
CatchBoundary,
|
|
CatchNotFound,
|
|
ClientOnly,
|
|
DefaultGlobalNotFound,
|
|
ErrorComponent,
|
|
FileRoute,
|
|
FileRouteLoader,
|
|
HeadContent,
|
|
LazyRoute,
|
|
Link,
|
|
Match,
|
|
MatchRoute,
|
|
Matches,
|
|
Navigate,
|
|
NotFoundRoute,
|
|
Outlet,
|
|
PathParamError,
|
|
RootRoute,
|
|
Route,
|
|
RouteApi,
|
|
Router,
|
|
RouterContextProvider,
|
|
RouterProvider,
|
|
ScriptOnce,
|
|
Scripts,
|
|
ScrollRestoration2 as ScrollRestoration,
|
|
SearchParamError,
|
|
TSR_DEFERRED_PROMISE,
|
|
cleanPath,
|
|
componentTypes,
|
|
createBrowserHistory,
|
|
createControlledPromise,
|
|
createFileRoute,
|
|
createHashHistory,
|
|
createHistory,
|
|
createLazyFileRoute,
|
|
createLazyRoute,
|
|
createLink,
|
|
createMemoryHistory,
|
|
createRootRoute,
|
|
createRootRouteWithContext,
|
|
createRoute,
|
|
createRouteMask,
|
|
createRouter,
|
|
decode,
|
|
deepEqual,
|
|
defaultParseSearch,
|
|
defaultSerializeError,
|
|
defaultStringifySearch,
|
|
defer,
|
|
encode,
|
|
escapeJSON,
|
|
functionalUpdate,
|
|
getInitialRouterState,
|
|
getRouteApi,
|
|
getRouterContext,
|
|
interpolatePath,
|
|
invariant,
|
|
isMatch2 as isMatch,
|
|
isNotFound,
|
|
isPlainArray,
|
|
isPlainObject,
|
|
isRedirect,
|
|
joinPaths,
|
|
lazyFn,
|
|
lazyRouteComponent,
|
|
linkOptions,
|
|
matchByPath,
|
|
matchContext,
|
|
matchPathname,
|
|
notFound,
|
|
parsePathname,
|
|
parseSearchWith,
|
|
pick,
|
|
redirect,
|
|
removeBasepath,
|
|
replaceEqualDeep,
|
|
resolvePath,
|
|
retainSearchParams,
|
|
rootRouteId,
|
|
rootRouteWithContext,
|
|
shallow,
|
|
stringifySearchWith,
|
|
stripSearchParams,
|
|
trimPath,
|
|
trimPathLeft,
|
|
trimPathRight,
|
|
useAwaited,
|
|
useBlocker,
|
|
useCanGoBack,
|
|
useChildMatches,
|
|
useElementScrollRestoration,
|
|
useLayoutEffect2 as useLayoutEffect,
|
|
useLinkProps,
|
|
useLoaderData,
|
|
useLoaderDeps,
|
|
useLocation,
|
|
useMatch,
|
|
useMatchRoute,
|
|
useMatches,
|
|
useNavigate,
|
|
useParams,
|
|
useParentMatches,
|
|
useRouteContext,
|
|
useRouter,
|
|
useRouterState,
|
|
useSearch,
|
|
useStableCallback,
|
|
tiny_warning_esm_default as warning
|
|
};
|
|
/*! Bundled license information:
|
|
|
|
use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
|
|
(**
|
|
* @license React
|
|
* use-sync-external-store-shim.development.js
|
|
*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*)
|
|
|
|
use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
|
|
(**
|
|
* @license React
|
|
* use-sync-external-store-shim/with-selector.development.js
|
|
*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*)
|
|
*/
|
|
//# sourceMappingURL=@tanstack_react-router.js.map
|