Socket
Socket
Sign inDemoInstall

@tanstack/react-router

Package Overview
Dependencies
Maintainers
2
Versions
582
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/react-router - npm Package Compare versions

Comparing version 0.0.1-beta.83 to 0.0.1-beta.145

2

build/cjs/_virtual/_rollupPluginBabelHelpers.js
/**
* react-router
* @tanstack/react-router/src/index.tsx
*

@@ -4,0 +4,0 @@ * Copyright (c) TanStack

/**
* react-router
* @tanstack/react-router/src/index.tsx
*

@@ -17,5 +17,9 @@ * Copyright (c) TanStack

var React = require('react');
var router = require('@tanstack/router');
var reactStore = require('@tanstack/react-store');
var invariant = require('tiny-invariant');
var warning = require('tiny-warning');
var routerCore = require('@tanstack/router-core');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
function _interopNamespace(e) {

@@ -40,14 +44,67 @@ if (e && e.__esModule) return e;

var React__namespace = /*#__PURE__*/_interopNamespace(React);
var invariant__default = /*#__PURE__*/_interopDefaultLegacy(invariant);
var warning__default = /*#__PURE__*/_interopDefaultLegacy(warning);
routerCore.Route.__onInit = route => {
Object.assign(route, {
useMatch: (opts = {}) => {
return useMatch({
...opts,
from: route.id
});
},
useLoader: (opts = {}) => {
return useLoader({
...opts,
from: route.id
});
},
useContext: (opts = {}) => {
return useMatch({
...opts,
from: route.id,
select: d => opts?.select?.(d.context) ?? d.context
});
},
useRouteContext: (opts = {}) => {
return useMatch({
...opts,
from: route.id,
select: d => opts?.select?.(d.routeContext) ?? d.routeContext
});
},
useSearch: (opts = {}) => {
return useSearch({
...opts,
from: route.id
});
},
useParams: (opts = {}) => {
return useParams({
...opts,
from: route.id
});
}
});
};
//
function lazy(importer) {
const lazyComp = /*#__PURE__*/React__namespace.lazy(importer);
const finalComp = lazyComp;
finalComp.preload = async () => {
{
await importer();
function lazyRouteComponent(importer, exportName) {
let loadPromise;
const load = () => {
if (!loadPromise) {
loadPromise = importer();
}
return loadPromise;
};
return finalComp;
const lazyComp = /*#__PURE__*/React__namespace.lazy(async () => {
const moduleExports = await load();
const comp = moduleExports[exportName ?? 'default'];
return {
default: comp
};
});
lazyComp.preload = load;
return lazyComp;
}

@@ -57,3 +114,3 @@ //

function useLinkProps(options) {
const router$1 = useRouterContext();
const router = useRouter();
const {

@@ -88,3 +145,3 @@ // custom props

} = options;
const linkInfo = router$1.buildLink(options);
const linkInfo = router.buildLink(options);
if (linkInfo.type === 'external') {

@@ -107,10 +164,7 @@ const {

} = linkInfo;
const reactHandleClick = e => {
if (React__namespace.startTransition) {
// This is a hack for react < 18
React__namespace.startTransition(() => {
const handleReactClick = e => {
if (options.startTransition ?? true) {
(React__namespace.startTransition || (d => d))(() => {
handleClick(e);
});
} else {
handleClick(e);
}

@@ -127,6 +181,6 @@ };

// Get the active props
const resolvedActiveProps = isActive ? router.functionalUpdate(activeProps, {}) ?? {} : {};
const resolvedActiveProps = isActive ? routerCore.functionalUpdate(activeProps, {}) ?? {} : {};
// Get the inactive props
const resolvedInactiveProps = isActive ? {} : router.functionalUpdate(inactiveProps, {}) ?? {};
const resolvedInactiveProps = isActive ? {} : routerCore.functionalUpdate(inactiveProps, {}) ?? {};
return {

@@ -137,3 +191,3 @@ ...resolvedActiveProps,

href: disabled ? undefined : next.href,
onClick: composeHandlers([onClick, reactHandleClick]),
onClick: composeHandlers([onClick, handleReactClick]),
onFocus: composeHandlers([onFocus, handleFocus]),

@@ -168,3 +222,3 @@ onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),

function Navigate(props) {
const router = useRouterContext();
const router = useRouter();
React__namespace.useLayoutEffect(() => {

@@ -175,87 +229,125 @@ router.navigate(props);

}
const matchesContext = /*#__PURE__*/React__namespace.createContext(null);
const matchIdsContext = /*#__PURE__*/React__namespace.createContext(null);
const routerContext = /*#__PURE__*/React__namespace.createContext(null);
class ReactRouter extends router.Router {
constructor(opts) {
super({
...opts,
loadComponent: async component => {
if (component.preload) {
await component.preload();
}
return component;
}
});
}
function useRouterState(opts) {
const router = useRouter();
return reactStore.useStore(router.__store, opts?.select);
}
function RouterProvider({
router: router$1,
router,
...rest
}) {
router$1.update(rest);
const currentMatches = reactStore.useStore(router$1.__store, s => s.currentMatches);
React__namespace.useEffect(router$1.mount, [router$1]);
return /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
value: {
router: router$1
router.update(rest);
React__namespace.useEffect(() => {
let unsub;
React__namespace.startTransition(() => {
unsub = router.mount();
});
return unsub;
}, [router]);
const Wrap = router.options.Wrap || React__namespace.Fragment;
return /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
fallback: null
}, /*#__PURE__*/React__namespace.createElement(Wrap, null, /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
value: router
}, /*#__PURE__*/React__namespace.createElement(Matches, null))));
}
function Matches() {
const router = useRouter();
const matchIds = useRouterState({
select: state => {
const hasPendingComponent = state.pendingMatches.some(d => {
const route = router.getRoute(d.routeId);
return !!route?.options.pendingComponent;
});
if (hasPendingComponent) {
console.log('hasPending');
return state.pendingMatchIds;
}
return state.matchIds;
}
}, /*#__PURE__*/React__namespace.createElement(matchesContext.Provider, {
value: [undefined, ...currentMatches]
});
return /*#__PURE__*/React__namespace.createElement(matchIdsContext.Provider, {
value: [undefined, ...matchIds]
}, /*#__PURE__*/React__namespace.createElement(CatchBoundary, {
errorComponent: ErrorComponent,
onCatch: () => {
router.warning(false, `Error in router! Consider setting an 'errorComponent' in your RootRoute! 👍`);
warning__default["default"](false, `Error in router! Consider setting an 'errorComponent' in your RootRoute! 👍`);
}
}, /*#__PURE__*/React__namespace.createElement(Outlet, null))));
}, /*#__PURE__*/React__namespace.createElement(Outlet, null)));
}
function useRouterContext() {
function useRouter() {
const value = React__namespace.useContext(routerContext);
router.warning(value, 'useRouter must be used inside a <Router> component!');
reactStore.useStore(value.router.__store);
return value.router;
warning__default["default"](value, 'useRouter must be used inside a <Router> component!');
return value;
}
function useRouter(track, shallow) {
const router = useRouterContext();
reactStore.useStore(router.__store, track, shallow);
return router;
function useMatches(opts) {
const matchIds = React__namespace.useContext(matchIdsContext);
return useRouterState({
select: state => {
const matches = state.matches.slice(state.matches.findIndex(d => d.id === matchIds[0]));
return opts?.select?.(matches) ?? matches;
}
});
}
function useMatches() {
return React__namespace.useContext(matchesContext);
}
function useMatch(opts) {
const router$1 = useRouterContext();
const nearestMatch = useMatches()[0];
const match = opts?.from ? router$1.state.currentMatches.find(d => d.route.id === opts?.from) : nearestMatch;
router.invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
const router = useRouter();
const nearestMatchId = React__namespace.useContext(matchIdsContext)[0];
const nearestMatchRouteId = router.getRouteMatch(nearestMatchId)?.routeId;
const matchRouteId = useRouterState({
select: state => {
const matches = state.matches;
const match = opts?.from ? matches.find(d => d.routeId === opts?.from) : matches.find(d => d.id === nearestMatchId);
return match.routeId;
}
});
if (opts?.strict ?? true) {
router.invariant(nearestMatch.route.id == match?.route.id, `useMatch("${match?.route.id}") is being called in a component that is meant to render the '${nearestMatch.route.id}' route. Did you mean to 'useMatch("${match?.route.id}", { strict: false })' or 'useRoute("${match?.route.id}")' instead?`);
invariant__default["default"](nearestMatchRouteId == matchRouteId, `useMatch("${matchRouteId}") is being called in a component that is meant to render the '${nearestMatchRouteId}' route. Did you mean to 'useMatch("${matchRouteId}", { strict: false })' or 'useRoute("${matchRouteId}")' instead?`);
}
reactStore.useStore(match.__store, d => opts?.track?.(match) ?? match, opts?.shallow);
const match = useRouterState({
select: state => {
const matches = state.matches;
const match = opts?.from ? matches.find(d => d.routeId === opts?.from) : matches.find(d => d.id === nearestMatchId);
invariant__default["default"](match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
return opts?.select?.(match) ?? match;
}
});
return match;
}
function useRoute(routeId) {
const router$1 = useRouterContext();
const resolvedRoute = router$1.getRoute(routeId);
router.invariant(resolvedRoute, `Could not find a route for route "${routeId}"! Did you forget to add it to your route?`);
return resolvedRoute;
function useLoader(opts) {
return useMatch({
...opts,
select: match => opts?.select?.(match.loaderData) ?? match.loaderData
});
}
function useRouterContext(opts) {
return useMatch({
...opts,
select: match => opts?.select?.(match.context) ?? match.context
});
}
function useRouteContext(opts) {
return useMatch({
...opts,
select: match => opts?.select?.(match.routeContext) ?? match.routeContext
});
}
function useSearch(opts) {
const {
track,
...matchOpts
} = opts;
const match = useMatch(matchOpts);
reactStore.useStore(match.__store, d => opts?.track?.(d.search) ?? d.search, true);
return match.state.search;
return useMatch({
...opts,
select: match => {
return opts?.select?.(match.search) ?? match.search;
}
});
}
function useParams(opts) {
const router$1 = useRouterContext();
reactStore.useStore(router$1.__store, d => {
const params = router.last(d.currentMatches)?.params;
return opts?.track?.(params) ?? params;
}, true);
return router.last(router$1.state.currentMatches)?.params;
return useRouterState({
select: state => {
const params = routerCore.last(state.matches)?.params;
return opts?.select?.(params) ?? params;
}
});
}
function useNavigate(defaultOpts) {
const router = useRouterContext();
const router = useRouter();
return React__namespace.useCallback(opts => {

@@ -269,3 +361,3 @@ return router.navigate({

function useMatchRoute() {
const router = useRouterContext();
const router = useRouter();
return React__namespace.useCallback(opts => {

@@ -286,58 +378,90 @@ const {

const params = matchRoute(props);
if (!params) {
return null;
}
if (typeof props.children === 'function') {
return props.children(params);
}
return params ? props.children : null;
return !!params ? props.children : null;
}
function Outlet() {
const matches = useMatches().slice(1);
const match = matches[0];
if (!match) {
const matchIds = React__namespace.useContext(matchIdsContext).slice(1);
if (!matchIds[0]) {
return null;
}
return /*#__PURE__*/React__namespace.createElement(SubOutlet, {
matches: matches,
match: match
return /*#__PURE__*/React__namespace.createElement(Match, {
matchIds: matchIds
});
}
function SubOutlet({
matches,
match
const defaultPending = () => null;
function Match({
matchIds
}) {
const router$1 = useRouterContext();
reactStore.useStore(match.__store, store => [store.status, store.error], true);
const defaultPending = React__namespace.useCallback(() => null, []);
const PendingComponent = match.pendingComponent ?? router$1.options.defaultPendingComponent ?? defaultPending;
const errorComponent = match.errorComponent ?? router$1.options.defaultErrorComponent;
const ResolvedSuspenseBoundary = match.route.options.wrapInSuspense ?? true ? React__namespace.Suspense : SafeFragment;
const ResolvedCatchBoundary = errorComponent ? CatchBoundary : SafeFragment;
return /*#__PURE__*/React__namespace.createElement(matchesContext.Provider, {
value: matches
const router = useRouter();
const matchId = matchIds[0];
const routeId = router.getRouteMatch(matchId).routeId;
const route = router.getRoute(routeId);
const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent ?? defaultPending;
const errorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent ?? ErrorComponent;
const ResolvedSuspenseBoundary = route.options.wrapInSuspense ?? !route.isRoot ? React__namespace.Suspense : SafeFragment;
const ResolvedCatchBoundary = !!errorComponent ? CatchBoundary : SafeFragment;
return /*#__PURE__*/React__namespace.createElement(matchIdsContext.Provider, {
value: matchIds
}, /*#__PURE__*/React__namespace.createElement(ResolvedSuspenseBoundary, {
fallback: /*#__PURE__*/React__namespace.createElement(PendingComponent, null)
fallback: /*#__PURE__*/React__namespace.createElement(PendingComponent, {
useLoader: route.useLoader,
useMatch: route.useMatch,
useContext: route.useContext,
useRouteContext: route.useRouteContext,
useSearch: route.useSearch,
useParams: route.useParams
})
}, /*#__PURE__*/React__namespace.createElement(ResolvedCatchBoundary, {
key: match.route.id,
key: route.id,
errorComponent: errorComponent,
onCatch: () => {
router.warning(false, `Error in route match: ${match.id}`);
warning__default["default"](false, `Error in route match: ${matchId}`);
}
}, /*#__PURE__*/React__namespace.createElement(Inner, {
match: match
}, /*#__PURE__*/React__namespace.createElement(MatchInner, {
matchId: matchId,
PendingComponent: PendingComponent
}))));
}
function Inner(props) {
const router$1 = useRouterContext();
if (props.match.state.status === 'error') {
throw props.match.state.error;
function MatchInner({
matchId,
PendingComponent
}) {
const router = useRouter();
const match = useRouterState({
select: d => {
const match = d.matchesById[matchId];
return routerCore.pick(match, ['status', 'loadPromise', 'routeId', 'error']);
}
});
const route = router.getRoute(match.routeId);
if (match.status === 'error') {
throw match.error;
}
if (props.match.state.status === 'success') {
return /*#__PURE__*/React__namespace.createElement(props.match.component ?? router$1.options.defaultComponent ?? Outlet);
if (match.status === 'pending') {
return /*#__PURE__*/React__namespace.createElement(PendingComponent, {
useLoader: route.useLoader,
useMatch: route.useMatch,
useContext: route.useContext,
useRouteContext: route.useRouteContext,
useSearch: route.useSearch,
useParams: route.useParams
});
}
if (props.match.state.status === 'pending') {
throw props.match.__loadPromise;
if (match.status === 'success') {
let comp = route.options.component ?? router.options.defaultComponent;
if (comp) {
return /*#__PURE__*/React__namespace.createElement(comp, {
useLoader: route.useLoader,
useMatch: route.useMatch,
useContext: route.useContext,
useRouteContext: route.useRouteContext,
useSearch: route.useSearch,
useParams: route.useParams
});
}
return /*#__PURE__*/React__namespace.createElement(Outlet, null);
}
router.invariant(false, 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!');
invariant__default["default"](false, 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!');
}

@@ -347,2 +471,20 @@ function SafeFragment(props) {

}
function useInjectHtml() {
const router = useRouter();
return React__namespace.useCallback(html => {
router.injectHtml(html);
}, []);
}
function useDehydrate() {
const router = useRouter();
return React__namespace.useCallback(function dehydrate(key, data) {
return router.dehydrateData(key, data);
}, []);
}
function useHydrate() {
const router = useRouter();
return function hydrate(key) {
return router.hydrateData(key);
};
}

@@ -360,3 +502,2 @@ // This is the messiest thing ever... I'm either seriously tired (likely) or

this.props.onCatch(error, info);
console.error(error);
this.setState({

@@ -375,4 +516,6 @@ error,

function CatchBoundaryInner(props) {
const locationKey = useRouterState({
select: d => d.resolvedLocation.key
});
const [activeErrorState, setActiveErrorState] = React__namespace.useState(props.errorState);
const router = useRouterContext();
const errorComponent = props.errorComponent ?? ErrorComponent;

@@ -382,8 +525,8 @@ const prevKeyRef = React__namespace.useRef('');

if (activeErrorState) {
if (router.state.currentLocation.key !== prevKeyRef.current) {
if (locationKey !== prevKeyRef.current) {
setActiveErrorState({});
}
}
prevKeyRef.current = router.state.currentLocation.key;
}, [activeErrorState, router.state.currentLocation.key]);
prevKeyRef.current = locationKey;
}, [activeErrorState, locationKey]);
React__namespace.useEffect(() => {

@@ -403,2 +546,3 @@ if (props.errorState.error) {

}) {
const [show, setShow] = React__namespace.useState(process.env.NODE_ENV !== 'production');
return /*#__PURE__*/React__namespace.createElement("div", {

@@ -409,11 +553,27 @@ style: {

}
}, /*#__PURE__*/React__namespace.createElement("div", {
style: {
display: 'flex',
alignItems: 'center',
gap: '.5rem'
}
}, /*#__PURE__*/React__namespace.createElement("strong", {
style: {
fontSize: '1.2rem'
fontSize: '1rem'
}
}, "Something went wrong!"), /*#__PURE__*/React__namespace.createElement("div", {
}, "Something went wrong!"), /*#__PURE__*/React__namespace.createElement("button", {
style: {
height: '.5rem'
appearance: 'none',
fontSize: '.6em',
border: '1px solid currentColor',
padding: '.1rem .2rem',
fontWeight: 'bold',
borderRadius: '.25rem'
},
onClick: () => setShow(d => !d)
}, show ? 'Hide Error' : 'Show Error')), /*#__PURE__*/React__namespace.createElement("div", {
style: {
height: '.25rem'
}
}), /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("pre", {
}), show ? /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("pre", {
style: {

@@ -423,7 +583,7 @@ fontSize: '.7em',

borderRadius: '.25rem',
padding: '.5rem',
padding: '.3rem',
color: 'red',
overflow: 'auto'
}
}, error.message ? /*#__PURE__*/React__namespace.createElement("code", null, error.message) : null)));
}, error.message ? /*#__PURE__*/React__namespace.createElement("code", null, error.message) : null)) : null);
}

@@ -438,4 +598,2 @@ function useBlocker(message, condition = true) {

retry();
} else {
cancel();
}

@@ -454,2 +612,20 @@ });

}
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 (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;
}

@@ -466,9 +642,13 @@ Object.defineProperty(exports, 'useStore', {

exports.Outlet = Outlet;
exports.ReactRouter = ReactRouter;
exports.RouterProvider = RouterProvider;
exports.lazy = lazy;
exports.matchesContext = matchesContext;
exports.lazyRouteComponent = lazyRouteComponent;
exports.matchIdsContext = matchIdsContext;
exports.routerContext = routerContext;
exports.shallow = shallow;
exports.useBlocker = useBlocker;
exports.useDehydrate = useDehydrate;
exports.useHydrate = useHydrate;
exports.useInjectHtml = useInjectHtml;
exports.useLinkProps = useLinkProps;
exports.useLoader = useLoader;
exports.useMatch = useMatch;

@@ -479,12 +659,13 @@ exports.useMatchRoute = useMatchRoute;

exports.useParams = useParams;
exports.useRoute = useRoute;
exports.useRouteContext = useRouteContext;
exports.useRouter = useRouter;
exports.useRouterContext = useRouterContext;
exports.useRouterState = useRouterState;
exports.useSearch = useSearch;
Object.keys(router).forEach(function (k) {
Object.keys(routerCore).forEach(function (k) {
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
enumerable: true,
get: function () { return router[k]; }
get: function () { return routerCore[k]; }
});
});
//# sourceMappingURL=index.js.map
/**
* react-router
* @tanstack/react-router/src/index.tsx
*

@@ -12,6 +12,8 @@ * Copyright (c) TanStack

import * as React from 'react';
import { functionalUpdate, Router, warning, invariant, last } from '@tanstack/router';
export * from '@tanstack/router';
import { useStore } from '@tanstack/react-store';
export { useStore } from '@tanstack/react-store';
import invariant from 'tiny-invariant';
import warning from 'tiny-warning';
import { Route, functionalUpdate, last, pick } from '@tanstack/router-core';
export * from '@tanstack/router-core';

@@ -33,13 +35,64 @@ function _extends() {

Route.__onInit = route => {
Object.assign(route, {
useMatch: (opts = {}) => {
return useMatch({
...opts,
from: route.id
});
},
useLoader: (opts = {}) => {
return useLoader({
...opts,
from: route.id
});
},
useContext: (opts = {}) => {
return useMatch({
...opts,
from: route.id,
select: d => opts?.select?.(d.context) ?? d.context
});
},
useRouteContext: (opts = {}) => {
return useMatch({
...opts,
from: route.id,
select: d => opts?.select?.(d.routeContext) ?? d.routeContext
});
},
useSearch: (opts = {}) => {
return useSearch({
...opts,
from: route.id
});
},
useParams: (opts = {}) => {
return useParams({
...opts,
from: route.id
});
}
});
};
//
function lazy(importer) {
const lazyComp = /*#__PURE__*/React.lazy(importer);
const finalComp = lazyComp;
finalComp.preload = async () => {
{
await importer();
function lazyRouteComponent(importer, exportName) {
let loadPromise;
const load = () => {
if (!loadPromise) {
loadPromise = importer();
}
return loadPromise;
};
return finalComp;
const lazyComp = /*#__PURE__*/React.lazy(async () => {
const moduleExports = await load();
const comp = moduleExports[exportName ?? 'default'];
return {
default: comp
};
});
lazyComp.preload = load;
return lazyComp;
}

@@ -49,3 +102,3 @@ //

function useLinkProps(options) {
const router = useRouterContext();
const router = useRouter();
const {

@@ -98,10 +151,7 @@ // custom props

} = linkInfo;
const reactHandleClick = e => {
if (React.startTransition) {
// This is a hack for react < 18
React.startTransition(() => {
const handleReactClick = e => {
if (options.startTransition ?? true) {
(React.startTransition || (d => d))(() => {
handleClick(e);
});
} else {
handleClick(e);
}

@@ -127,3 +177,3 @@ };

href: disabled ? undefined : next.href,
onClick: composeHandlers([onClick, reactHandleClick]),
onClick: composeHandlers([onClick, handleReactClick]),
onFocus: composeHandlers([onFocus, handleFocus]),

@@ -158,3 +208,3 @@ onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),

function Navigate(props) {
const router = useRouterContext();
const router = useRouter();
React.useLayoutEffect(() => {

@@ -165,16 +215,7 @@ router.navigate(props);

}
const matchesContext = /*#__PURE__*/React.createContext(null);
const matchIdsContext = /*#__PURE__*/React.createContext(null);
const routerContext = /*#__PURE__*/React.createContext(null);
class ReactRouter extends Router {
constructor(opts) {
super({
...opts,
loadComponent: async component => {
if (component.preload) {
await component.preload();
}
return component;
}
});
}
function useRouterState(opts) {
const router = useRouter();
return useStore(router.__store, opts?.select);
}

@@ -186,10 +227,33 @@ function RouterProvider({

router.update(rest);
const currentMatches = useStore(router.__store, s => s.currentMatches);
React.useEffect(router.mount, [router]);
return /*#__PURE__*/React.createElement(routerContext.Provider, {
value: {
router: router
React.useEffect(() => {
let unsub;
React.startTransition(() => {
unsub = router.mount();
});
return unsub;
}, [router]);
const Wrap = router.options.Wrap || React.Fragment;
return /*#__PURE__*/React.createElement(React.Suspense, {
fallback: null
}, /*#__PURE__*/React.createElement(Wrap, null, /*#__PURE__*/React.createElement(routerContext.Provider, {
value: router
}, /*#__PURE__*/React.createElement(Matches, null))));
}
function Matches() {
const router = useRouter();
const matchIds = useRouterState({
select: state => {
const hasPendingComponent = state.pendingMatches.some(d => {
const route = router.getRoute(d.routeId);
return !!route?.options.pendingComponent;
});
if (hasPendingComponent) {
console.log('hasPending');
return state.pendingMatchIds;
}
return state.matchIds;
}
}, /*#__PURE__*/React.createElement(matchesContext.Provider, {
value: [undefined, ...currentMatches]
});
return /*#__PURE__*/React.createElement(matchIdsContext.Provider, {
value: [undefined, ...matchIds]
}, /*#__PURE__*/React.createElement(CatchBoundary, {

@@ -200,54 +264,78 @@ errorComponent: ErrorComponent,

}
}, /*#__PURE__*/React.createElement(Outlet, null))));
}, /*#__PURE__*/React.createElement(Outlet, null)));
}
function useRouterContext() {
function useRouter() {
const value = React.useContext(routerContext);
warning(value, 'useRouter must be used inside a <Router> component!');
useStore(value.router.__store);
return value.router;
return value;
}
function useRouter(track, shallow) {
const router = useRouterContext();
useStore(router.__store, track, shallow);
return router;
function useMatches(opts) {
const matchIds = React.useContext(matchIdsContext);
return useRouterState({
select: state => {
const matches = state.matches.slice(state.matches.findIndex(d => d.id === matchIds[0]));
return opts?.select?.(matches) ?? matches;
}
});
}
function useMatches() {
return React.useContext(matchesContext);
}
function useMatch(opts) {
const router = useRouterContext();
const nearestMatch = useMatches()[0];
const match = opts?.from ? router.state.currentMatches.find(d => d.route.id === opts?.from) : nearestMatch;
invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
const router = useRouter();
const nearestMatchId = React.useContext(matchIdsContext)[0];
const nearestMatchRouteId = router.getRouteMatch(nearestMatchId)?.routeId;
const matchRouteId = useRouterState({
select: state => {
const matches = state.matches;
const match = opts?.from ? matches.find(d => d.routeId === opts?.from) : matches.find(d => d.id === nearestMatchId);
return match.routeId;
}
});
if (opts?.strict ?? true) {
invariant(nearestMatch.route.id == match?.route.id, `useMatch("${match?.route.id}") is being called in a component that is meant to render the '${nearestMatch.route.id}' route. Did you mean to 'useMatch("${match?.route.id}", { strict: false })' or 'useRoute("${match?.route.id}")' instead?`);
invariant(nearestMatchRouteId == matchRouteId, `useMatch("${matchRouteId}") is being called in a component that is meant to render the '${nearestMatchRouteId}' route. Did you mean to 'useMatch("${matchRouteId}", { strict: false })' or 'useRoute("${matchRouteId}")' instead?`);
}
useStore(match.__store, d => opts?.track?.(match) ?? match, opts?.shallow);
const match = useRouterState({
select: state => {
const matches = state.matches;
const match = opts?.from ? matches.find(d => d.routeId === opts?.from) : matches.find(d => d.id === nearestMatchId);
invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
return opts?.select?.(match) ?? match;
}
});
return match;
}
function useRoute(routeId) {
const router = useRouterContext();
const resolvedRoute = router.getRoute(routeId);
invariant(resolvedRoute, `Could not find a route for route "${routeId}"! Did you forget to add it to your route?`);
return resolvedRoute;
function useLoader(opts) {
return useMatch({
...opts,
select: match => opts?.select?.(match.loaderData) ?? match.loaderData
});
}
function useRouterContext(opts) {
return useMatch({
...opts,
select: match => opts?.select?.(match.context) ?? match.context
});
}
function useRouteContext(opts) {
return useMatch({
...opts,
select: match => opts?.select?.(match.routeContext) ?? match.routeContext
});
}
function useSearch(opts) {
const {
track,
...matchOpts
} = opts;
const match = useMatch(matchOpts);
useStore(match.__store, d => opts?.track?.(d.search) ?? d.search, true);
return match.state.search;
return useMatch({
...opts,
select: match => {
return opts?.select?.(match.search) ?? match.search;
}
});
}
function useParams(opts) {
const router = useRouterContext();
useStore(router.__store, d => {
const params = last(d.currentMatches)?.params;
return opts?.track?.(params) ?? params;
}, true);
return last(router.state.currentMatches)?.params;
return useRouterState({
select: state => {
const params = last(state.matches)?.params;
return opts?.select?.(params) ?? params;
}
});
}
function useNavigate(defaultOpts) {
const router = useRouterContext();
const router = useRouter();
return React.useCallback(opts => {

@@ -261,3 +349,3 @@ return router.navigate({

function useMatchRoute() {
const router = useRouterContext();
const router = useRouter();
return React.useCallback(opts => {

@@ -278,56 +366,88 @@ const {

const params = matchRoute(props);
if (!params) {
return null;
}
if (typeof props.children === 'function') {
return props.children(params);
}
return params ? props.children : null;
return !!params ? props.children : null;
}
function Outlet() {
const matches = useMatches().slice(1);
const match = matches[0];
if (!match) {
const matchIds = React.useContext(matchIdsContext).slice(1);
if (!matchIds[0]) {
return null;
}
return /*#__PURE__*/React.createElement(SubOutlet, {
matches: matches,
match: match
return /*#__PURE__*/React.createElement(Match, {
matchIds: matchIds
});
}
function SubOutlet({
matches,
match
const defaultPending = () => null;
function Match({
matchIds
}) {
const router = useRouterContext();
useStore(match.__store, store => [store.status, store.error], true);
const defaultPending = React.useCallback(() => null, []);
const PendingComponent = match.pendingComponent ?? router.options.defaultPendingComponent ?? defaultPending;
const errorComponent = match.errorComponent ?? router.options.defaultErrorComponent;
const ResolvedSuspenseBoundary = match.route.options.wrapInSuspense ?? true ? React.Suspense : SafeFragment;
const ResolvedCatchBoundary = errorComponent ? CatchBoundary : SafeFragment;
return /*#__PURE__*/React.createElement(matchesContext.Provider, {
value: matches
const router = useRouter();
const matchId = matchIds[0];
const routeId = router.getRouteMatch(matchId).routeId;
const route = router.getRoute(routeId);
const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent ?? defaultPending;
const errorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent ?? ErrorComponent;
const ResolvedSuspenseBoundary = route.options.wrapInSuspense ?? !route.isRoot ? React.Suspense : SafeFragment;
const ResolvedCatchBoundary = !!errorComponent ? CatchBoundary : SafeFragment;
return /*#__PURE__*/React.createElement(matchIdsContext.Provider, {
value: matchIds
}, /*#__PURE__*/React.createElement(ResolvedSuspenseBoundary, {
fallback: /*#__PURE__*/React.createElement(PendingComponent, null)
fallback: /*#__PURE__*/React.createElement(PendingComponent, {
useLoader: route.useLoader,
useMatch: route.useMatch,
useContext: route.useContext,
useRouteContext: route.useRouteContext,
useSearch: route.useSearch,
useParams: route.useParams
})
}, /*#__PURE__*/React.createElement(ResolvedCatchBoundary, {
key: match.route.id,
key: route.id,
errorComponent: errorComponent,
onCatch: () => {
warning(false, `Error in route match: ${match.id}`);
warning(false, `Error in route match: ${matchId}`);
}
}, /*#__PURE__*/React.createElement(Inner, {
match: match
}, /*#__PURE__*/React.createElement(MatchInner, {
matchId: matchId,
PendingComponent: PendingComponent
}))));
}
function Inner(props) {
const router = useRouterContext();
if (props.match.state.status === 'error') {
throw props.match.state.error;
function MatchInner({
matchId,
PendingComponent
}) {
const router = useRouter();
const match = useRouterState({
select: d => {
const match = d.matchesById[matchId];
return pick(match, ['status', 'loadPromise', 'routeId', 'error']);
}
});
const route = router.getRoute(match.routeId);
if (match.status === 'error') {
throw match.error;
}
if (props.match.state.status === 'success') {
return /*#__PURE__*/React.createElement(props.match.component ?? router.options.defaultComponent ?? Outlet);
if (match.status === 'pending') {
return /*#__PURE__*/React.createElement(PendingComponent, {
useLoader: route.useLoader,
useMatch: route.useMatch,
useContext: route.useContext,
useRouteContext: route.useRouteContext,
useSearch: route.useSearch,
useParams: route.useParams
});
}
if (props.match.state.status === 'pending') {
throw props.match.__loadPromise;
if (match.status === 'success') {
let comp = route.options.component ?? router.options.defaultComponent;
if (comp) {
return /*#__PURE__*/React.createElement(comp, {
useLoader: route.useLoader,
useMatch: route.useMatch,
useContext: route.useContext,
useRouteContext: route.useRouteContext,
useSearch: route.useSearch,
useParams: route.useParams
});
}
return /*#__PURE__*/React.createElement(Outlet, null);
}

@@ -339,2 +459,20 @@ invariant(false, 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!');

}
function useInjectHtml() {
const router = useRouter();
return React.useCallback(html => {
router.injectHtml(html);
}, []);
}
function useDehydrate() {
const router = useRouter();
return React.useCallback(function dehydrate(key, data) {
return router.dehydrateData(key, data);
}, []);
}
function useHydrate() {
const router = useRouter();
return function hydrate(key) {
return router.hydrateData(key);
};
}

@@ -352,3 +490,2 @@ // This is the messiest thing ever... I'm either seriously tired (likely) or

this.props.onCatch(error, info);
console.error(error);
this.setState({

@@ -367,4 +504,6 @@ error,

function CatchBoundaryInner(props) {
const locationKey = useRouterState({
select: d => d.resolvedLocation.key
});
const [activeErrorState, setActiveErrorState] = React.useState(props.errorState);
const router = useRouterContext();
const errorComponent = props.errorComponent ?? ErrorComponent;

@@ -374,8 +513,8 @@ const prevKeyRef = React.useRef('');

if (activeErrorState) {
if (router.state.currentLocation.key !== prevKeyRef.current) {
if (locationKey !== prevKeyRef.current) {
setActiveErrorState({});
}
}
prevKeyRef.current = router.state.currentLocation.key;
}, [activeErrorState, router.state.currentLocation.key]);
prevKeyRef.current = locationKey;
}, [activeErrorState, locationKey]);
React.useEffect(() => {

@@ -395,2 +534,3 @@ if (props.errorState.error) {

}) {
const [show, setShow] = React.useState(process.env.NODE_ENV !== 'production');
return /*#__PURE__*/React.createElement("div", {

@@ -401,11 +541,27 @@ style: {

}
}, /*#__PURE__*/React.createElement("div", {
style: {
display: 'flex',
alignItems: 'center',
gap: '.5rem'
}
}, /*#__PURE__*/React.createElement("strong", {
style: {
fontSize: '1.2rem'
fontSize: '1rem'
}
}, "Something went wrong!"), /*#__PURE__*/React.createElement("div", {
}, "Something went wrong!"), /*#__PURE__*/React.createElement("button", {
style: {
height: '.5rem'
appearance: 'none',
fontSize: '.6em',
border: '1px solid currentColor',
padding: '.1rem .2rem',
fontWeight: 'bold',
borderRadius: '.25rem'
},
onClick: () => setShow(d => !d)
}, show ? 'Hide Error' : 'Show Error')), /*#__PURE__*/React.createElement("div", {
style: {
height: '.25rem'
}
}), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("pre", {
}), show ? /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("pre", {
style: {

@@ -415,7 +571,7 @@ fontSize: '.7em',

borderRadius: '.25rem',
padding: '.5rem',
padding: '.3rem',
color: 'red',
overflow: 'auto'
}
}, error.message ? /*#__PURE__*/React.createElement("code", null, error.message) : null)));
}, error.message ? /*#__PURE__*/React.createElement("code", null, error.message) : null)) : null);
}

@@ -430,4 +586,2 @@ function useBlocker(message, condition = true) {

retry();
} else {
cancel();
}

@@ -446,4 +600,22 @@ });

}
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 (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;
}
export { Block, ErrorComponent, Link, MatchRoute, Navigate, Outlet, ReactRouter, RouterProvider, lazy, matchesContext, routerContext, useBlocker, useLinkProps, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRoute, useRouter, useRouterContext, useSearch };
export { Block, ErrorComponent, Link, MatchRoute, Navigate, Outlet, RouterProvider, lazyRouteComponent, matchIdsContext, routerContext, shallow, useBlocker, useDehydrate, useHydrate, useInjectHtml, useLinkProps, useLoader, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRouteContext, useRouter, useRouterContext, useRouterState, useSearch };
//# sourceMappingURL=index.js.map

@@ -10,15 +10,23 @@ {

{
"uid": "3f93-161",
"uid": "1efb-163",
"name": "\u0000rollupPluginBabelHelpers.js"
},
{
"name": "node_modules/.pnpm",
"name": "packages",
"children": [
{
"name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"uid": "3f93-163"
"name": "store/build/esm/index.js",
"uid": "1efb-165"
},
{
"name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
"uid": "3f93-165"
"name": "react-store/build/esm/index.js",
"uid": "1efb-167"
},
{
"name": "router-core/build/esm/index.js",
"uid": "1efb-173"
},
{
"name": "react-router/src/index.tsx",
"uid": "1efb-175"
}

@@ -28,19 +36,11 @@ ]

{
"name": "packages",
"name": "node_modules/.pnpm",
"children": [
{
"name": "store/build/esm/index.js",
"uid": "3f93-167"
"name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"uid": "1efb-169"
},
{
"name": "router/build/esm/index.js",
"uid": "3f93-169"
},
{
"name": "react-store/build/esm/index.js",
"uid": "3f93-171"
},
{
"name": "react-router/src/index.tsx",
"uid": "3f93-173"
"name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
"uid": "1efb-171"
}

@@ -55,50 +55,50 @@ ]

"nodeParts": {
"3f93-161": {
"1efb-163": {
"renderedLength": 429,
"gzipLength": 238,
"brotliLength": 0,
"mainUid": "3f93-160"
"mainUid": "1efb-162"
},
"3f93-163": {
"1efb-165": {
"renderedLength": 1843,
"gzipLength": 644,
"brotliLength": 0,
"mainUid": "1efb-164"
},
"1efb-167": {
"renderedLength": 1006,
"gzipLength": 479,
"brotliLength": 0,
"mainUid": "1efb-166"
},
"1efb-169": {
"renderedLength": 181,
"gzipLength": 129,
"brotliLength": 0,
"mainUid": "3f93-162"
"mainUid": "1efb-168"
},
"3f93-165": {
"1efb-171": {
"renderedLength": 44,
"gzipLength": 62,
"brotliLength": 0,
"mainUid": "3f93-164"
"mainUid": "1efb-170"
},
"3f93-167": {
"renderedLength": 2382,
"gzipLength": 809,
"1efb-173": {
"renderedLength": 56600,
"gzipLength": 13389,
"brotliLength": 0,
"mainUid": "3f93-166"
"mainUid": "1efb-172"
},
"3f93-169": {
"renderedLength": 51236,
"gzipLength": 11955,
"1efb-175": {
"renderedLength": 17095,
"gzipLength": 3814,
"brotliLength": 0,
"mainUid": "3f93-168"
},
"3f93-171": {
"renderedLength": 477,
"gzipLength": 284,
"brotliLength": 0,
"mainUid": "3f93-170"
},
"3f93-173": {
"renderedLength": 12276,
"gzipLength": 3105,
"brotliLength": 0,
"mainUid": "3f93-172"
"mainUid": "1efb-174"
}
},
"nodeMetas": {
"3f93-160": {
"1efb-162": {
"id": "\u0000rollupPluginBabelHelpers.js",
"moduleParts": {
"index.production.js": "3f93-161"
"index.production.js": "1efb-163"
},

@@ -108,10 +108,10 @@ "imported": [],

{
"uid": "3f93-172"
"uid": "1efb-174"
}
]
},
"3f93-162": {
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"1efb-164": {
"id": "/packages/store/build/esm/index.js",
"moduleParts": {
"index.production.js": "3f93-163"
"index.production.js": "1efb-165"
},

@@ -121,22 +121,32 @@ "imported": [],

{
"uid": "3f93-168"
"uid": "1efb-166"
}
]
},
"3f93-164": {
"id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
"1efb-166": {
"id": "/packages/react-store/build/esm/index.js",
"moduleParts": {
"index.production.js": "3f93-165"
"index.production.js": "1efb-167"
},
"imported": [],
"imported": [
{
"uid": "1efb-177"
},
{
"uid": "1efb-164"
}
],
"importedBy": [
{
"uid": "3f93-168"
"uid": "1efb-174"
},
{
"uid": "1efb-172"
}
]
},
"3f93-166": {
"id": "/packages/store/build/esm/index.js",
"1efb-168": {
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"moduleParts": {
"index.production.js": "3f93-167"
"index.production.js": "1efb-169"
},

@@ -146,42 +156,38 @@ "imported": [],

{
"uid": "3f93-168"
"uid": "1efb-174"
},
{
"uid": "3f93-170"
"uid": "1efb-172"
}
]
},
"3f93-168": {
"id": "/packages/router/build/esm/index.js",
"1efb-170": {
"id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
"moduleParts": {
"index.production.js": "3f93-169"
"index.production.js": "1efb-171"
},
"imported": [
"imported": [],
"importedBy": [
{
"uid": "3f93-162"
"uid": "1efb-174"
},
{
"uid": "3f93-164"
},
{
"uid": "3f93-166"
"uid": "1efb-172"
}
],
"importedBy": [
{
"uid": "3f93-172"
}
]
},
"3f93-170": {
"id": "/packages/react-store/build/esm/index.js",
"1efb-172": {
"id": "/packages/router-core/build/esm/index.js",
"moduleParts": {
"index.production.js": "3f93-171"
"index.production.js": "1efb-173"
},
"imported": [
{
"uid": "3f93-166"
"uid": "1efb-168"
},
{
"uid": "3f93-175"
"uid": "1efb-170"
},
{
"uid": "1efb-166"
}

@@ -191,23 +197,29 @@ ],

{
"uid": "3f93-172"
"uid": "1efb-174"
}
]
},
"3f93-172": {
"1efb-174": {
"id": "/packages/react-router/src/index.tsx",
"moduleParts": {
"index.production.js": "3f93-173"
"index.production.js": "1efb-175"
},
"imported": [
{
"uid": "3f93-160"
"uid": "1efb-162"
},
{
"uid": "3f93-174"
"uid": "1efb-176"
},
{
"uid": "3f93-168"
"uid": "1efb-166"
},
{
"uid": "3f93-170"
"uid": "1efb-168"
},
{
"uid": "1efb-170"
},
{
"uid": "1efb-172"
}

@@ -218,3 +230,3 @@ ],

},
"3f93-174": {
"1efb-176": {
"id": "react",

@@ -225,3 +237,3 @@ "moduleParts": {},

{
"uid": "3f93-172"
"uid": "1efb-174"
}

@@ -231,3 +243,3 @@ ],

},
"3f93-175": {
"1efb-177": {
"id": "use-sync-external-store/shim/with-selector",

@@ -238,3 +250,3 @@ "moduleParts": {},

{
"uid": "3f93-170"
"uid": "1efb-166"
}

@@ -241,0 +253,0 @@ ],

/**
* react-router
* @tanstack/react-router/src/index.tsx
*

@@ -11,45 +11,73 @@ * Copyright (c) TanStack

*/
import * as _tanstack_router_core from '@tanstack/router-core';
import { AnyRoute, ResolveFullPath, ResolveId, AnySearchSchema, ResolveFullSearchSchema, ParsePathParams, MergeParamsFromParent, RouteContext, AnyContext, DefaultRoutesInfo, UseLoaderResult, AnyRouteProps, RegisteredRoutesInfo, LinkOptions, ToOptions, MatchRouteOptions, RouteByPath, ResolveRelativePath, NavigateOptions, Router, AnyRoutesInfo, RouterOptions, RegisteredRouter, RouteMatch } from '@tanstack/router-core';
export * from '@tanstack/router-core';
import * as React from 'react';
import { RegisteredRoutesInfo, LinkOptions, ToOptions, MatchRouteOptions, RouteByPath, ResolveRelativePath, NoInfer, ValidFromPath, NavigateOptions, RegisteredRouter, AnyRootRoute, RootRoute, AnyRoutesInfo, RoutesInfo, Router, RouterConstructorOptions, DefaultRoutesInfo, RouterOptions, RouterStore, RouteMatch, AnyRouteMatch } from '@tanstack/router';
export * from '@tanstack/router';
import { NoInfer } from '@tanstack/react-store';
export { useStore } from '@tanstack/react-store';
declare module '@tanstack/router-core' {
interface RegisterRouteComponent<TProps extends Record<string, any>> {
RouteComponent: RouteComponent<TProps>;
}
interface RegisterRouteErrorComponent<TProps extends Record<string, any>> {
RouteComponent: RouteComponent<TProps>;
}
interface Route<TParentRoute extends AnyRoute = AnyRoute, TPath extends string = '/', TFullPath extends ResolveFullPath<TParentRoute, TPath> = ResolveFullPath<TParentRoute, TPath>, TCustomId extends string = string, TId extends ResolveId<TParentRoute, TCustomId, TPath> = ResolveId<TParentRoute, TCustomId, TPath>, TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<ParsePathParams<TPath>, any> = Record<ParsePathParams<TPath>, string>, TAllParams extends MergeParamsFromParent<TParentRoute['__types']['allParams'], TParams> = MergeParamsFromParent<TParentRoute['__types']['allParams'], TParams>, TParentContext extends TParentRoute['__types']['routeContext'] = TParentRoute['__types']['routeContext'], TAllParentContext extends TParentRoute['__types']['context'] = TParentRoute['__types']['context'], TRouteContext extends RouteContext = RouteContext, TContext extends MergeParamsFromParent<TParentRoute['__types']['context'], TRouteContext> = MergeParamsFromParent<TParentRoute['__types']['context'], TRouteContext>, TRouterContext extends AnyContext = AnyContext, TChildren extends unknown = unknown, TRoutesInfo extends DefaultRoutesInfo = DefaultRoutesInfo> {
useMatch: <TStrict extends boolean = true, TSelected = TContext>(opts?: {
strict?: TStrict;
select?: (search: TContext) => TSelected;
}) => TStrict extends true ? TSelected : TSelected | undefined;
useLoader: <TStrict extends boolean = true, TSelected = TLoader>(opts?: {
strict?: TStrict;
select?: (search: TLoader) => TSelected;
}) => TStrict extends true ? UseLoaderResult<TSelected> : UseLoaderResult<TSelected> | undefined;
useContext: <TStrict extends boolean = true, TSelected = TContext>(opts?: {
strict?: TStrict;
select?: (search: TContext) => TSelected;
}) => TStrict extends true ? TSelected : TSelected | undefined;
useRouteContext: <TStrict extends boolean = true, TSelected = TRouteContext>(opts?: {
strict?: TStrict;
select?: (search: TRouteContext) => TSelected;
}) => TStrict extends true ? TSelected : TSelected | undefined;
useSearch: <TStrict extends boolean = true, TSelected = TFullSearchSchema>(opts?: {
strict?: TStrict;
select?: (search: TFullSearchSchema) => TSelected;
}) => TStrict extends true ? TSelected : TSelected | undefined;
useParams: <TStrict extends boolean = true, TSelected = TAllParams>(opts?: {
strict?: TStrict;
select?: (search: TAllParams) => TSelected;
}) => TStrict extends true ? TSelected : TSelected | undefined;
}
}
type ReactNode = any;
type SyncRouteComponent<TProps = {}> = (props: TProps) => ReactNode;
type RouteComponent<TProps = {}> = SyncRouteComponent<TProps> & {
type SyncRouteComponent<TProps> = ((props: TProps) => ReactNode) | React.LazyExoticComponent<(props: TProps) => ReactNode>;
type AsyncRouteComponent<TProps> = SyncRouteComponent<TProps> & {
preload?: () => Promise<void>;
};
declare function lazy(importer: () => Promise<{
default: SyncRouteComponent;
}>): RouteComponent;
type RouteErrorComponent = AsyncRouteComponent<RouteErrorComponentProps>;
type RouteErrorComponentProps = {
error: Error;
info: {
componentStack: string;
};
};
type AnyRouteComponent = RouteComponent<AnyRouteProps>;
type RouteComponent<TProps> = AsyncRouteComponent<TProps>;
declare function lazyRouteComponent<T extends Record<string, any>, TKey extends keyof T = 'default'>(importer: () => Promise<T>, exportName?: TKey): T[TKey] extends (props: infer TProps) => any ? AsyncRouteComponent<TProps> : never;
type LinkPropsOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''> = LinkOptions<RegisteredRoutesInfo, TFrom, TTo> & {
activeProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
inactiveProps?: React.AnchorHTMLAttributes<HTMLAnchorElement> | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>);
startTransition?: boolean;
};
type MakeUseMatchRouteOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''> = ToOptions<RegisteredRoutesInfo, TFrom, TTo> & MatchRouteOptions;
type MakeMatchRouteOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''> = ToOptions<RegisteredRoutesInfo, TFrom, TTo> & MatchRouteOptions & {
children?: ReactNode | ((params: RouteByPath<RegisteredRoutesInfo, ResolveRelativePath<TFrom, NoInfer<TTo>>>['__types']['allParams']) => ReactNode);
children?: ((params?: RouteByPath<RegisteredRoutesInfo, ResolveRelativePath<TFrom, NoInfer<TTo>>>['__types']['allParams']) => ReactNode) | React.ReactNode;
};
type MakeLinkPropsOptions<TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/', TTo extends string = ''> = LinkPropsOptions<TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>;
type MakeLinkOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''> = LinkPropsOptions<TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement> & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
children?: ReactNode | ((state: {
type MakeLinkPropsOptions<TFrom extends string = '/', TTo extends string = ''> = LinkPropsOptions<TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>;
type MakeLinkOptions<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''> = LinkPropsOptions<TFrom, TTo> & Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {
children?: React.ReactNode | ((state: {
isActive: boolean;
}) => ReactNode);
}) => React.ReactNode);
};
declare module '@tanstack/router' {
interface FrameworkGenerics {
Component: RouteComponent;
ErrorComponent: RouteComponent<{
error: Error;
info: {
componentStack: string;
};
}>;
}
interface RouterOptions<TRouteTree> {
}
interface FrameworkRouteOptions {
wrapInSuspense?: boolean;
}
}
type PromptProps = {

@@ -60,3 +88,3 @@ message: string;

};
declare function useLinkProps<TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/', TTo extends string = ''>(options: MakeLinkPropsOptions<TFrom, TTo>): React.AnchorHTMLAttributes<HTMLAnchorElement>;
declare function useLinkProps<TFrom extends string = '/', TTo extends string = ''>(options: MakeLinkPropsOptions<TFrom, TTo>): React.AnchorHTMLAttributes<HTMLAnchorElement>;
interface LinkFn<TDefaultFrom extends RegisteredRoutesInfo['routePaths'] = '/', TDefaultTo extends string = ''> {

@@ -67,43 +95,55 @@ <TFrom extends RegisteredRoutesInfo['routePaths'] = TDefaultFrom, TTo extends string = TDefaultTo>(props: MakeLinkOptions<TFrom, TTo> & React.RefAttributes<HTMLAnchorElement>): ReactNode;

declare function Navigate<TFrom extends RegisteredRoutesInfo['routePaths'] = '/', TTo extends string = ''>(props: NavigateOptions<RegisteredRoutesInfo, TFrom, TTo>): null;
type MatchesContextValue = AnyRouteMatch[];
declare const matchesContext: React.Context<MatchesContextValue>;
declare const routerContext: React.Context<{
router: RegisteredRouter;
}>;
type MatchesProviderProps = {
value: MatchesContextValue;
children: ReactNode;
};
declare class ReactRouter<TRouteConfig extends AnyRootRoute = RootRoute, TRoutesInfo extends AnyRoutesInfo = RoutesInfo<TRouteConfig>> extends Router<TRouteConfig, TRoutesInfo> {
constructor(opts: RouterConstructorOptions<TRouteConfig>);
}
type RouterProps<TRouteConfig extends AnyRootRoute = RootRoute, TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo> = RouterOptions<TRouteConfig> & {
declare const matchIdsContext: React.Context<string[]>;
declare const routerContext: React.Context<Router<AnyRoute, _tanstack_router_core.RoutesInfo<AnyRoute>, Record<string, any>>>;
type RouterProps<TRouteConfig extends AnyRoute = AnyRoute, TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TDehydrated extends Record<string, any> = Record<string, any>> = Omit<RouterOptions<TRouteConfig, TDehydrated>, 'context'> & {
router: Router<TRouteConfig, TRoutesInfo>;
context?: Partial<RouterOptions<TRouteConfig, TDehydrated>['context']>;
};
declare function RouterProvider<TRouteConfig extends AnyRootRoute = RootRoute, TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo>({ router, ...rest }: RouterProps<TRouteConfig, TRoutesInfo>): JSX.Element;
declare function useRouterContext(): RegisteredRouter;
declare function useRouter<T = RouterStore>(track?: (state: Router['__store']) => T, shallow?: boolean): RegisteredRouter;
declare function useMatches(): RouteMatch[];
declare function useMatch<TFrom extends keyof RegisteredRoutesInfo['routesById'], TStrict extends boolean = true, TRouteMatch = RouteMatch<RegisteredRoutesInfo, RegisteredRoutesInfo['routesById'][TFrom]>>(opts?: {
declare function useRouterState<TSelected = RegisteredRouter['state']>(opts?: {
select: (state: RegisteredRouter['state']) => TSelected;
}): TSelected;
declare function RouterProvider<TRouteConfig extends AnyRoute = AnyRoute, TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo, TDehydrated extends Record<string, any> = Record<string, any>>({ router, ...rest }: RouterProps<TRouteConfig, TRoutesInfo, TDehydrated>): JSX.Element;
declare function useRouter(): RegisteredRouter;
declare function useMatches<T = RouteMatch[]>(opts?: {
select?: (matches: RouteMatch[]) => T;
}): T;
declare function useMatch<TFrom extends keyof RegisteredRoutesInfo['routesById'], TStrict extends boolean = true, TRouteMatchState = RouteMatch<RegisteredRoutesInfo, RegisteredRoutesInfo['routesById'][TFrom]>, TSelected = TRouteMatchState>(opts?: {
from: TFrom;
strict?: TStrict;
track?: (match: TRouteMatch) => any;
shallow?: boolean;
}): TStrict extends true ? TRouteMatch : TRouteMatch | undefined;
declare function useRoute<TId extends keyof RegisteredRoutesInfo['routesById'] = '/'>(routeId: TId): RegisteredRoutesInfo['routesById'][TId];
select?: (match: TRouteMatchState) => TSelected;
}): TStrict extends true ? TRouteMatchState : TRouteMatchState | undefined;
type RouteFromIdOrRoute<T> = T extends RegisteredRoutesInfo['routeUnion'] ? T : T extends keyof RegisteredRoutesInfo['routesById'] ? RegisteredRoutesInfo['routesById'][T] : T extends string ? keyof RegisteredRoutesInfo['routesById'] : never;
declare function useLoader<TFrom extends keyof RegisteredRoutesInfo['routesById'], TStrict extends boolean = true, TLoader = RegisteredRoutesInfo['routesById'][TFrom]['__types']['loader'], TSelected = TLoader>(opts?: {
from: TFrom;
strict?: TStrict;
select?: (search: TLoader) => TSelected;
}): TStrict extends true ? TSelected : TSelected | undefined;
declare function useRouterContext<TFrom extends keyof RegisteredRoutesInfo['routesById'], TStrict extends boolean = true, TContext = RegisteredRoutesInfo['routesById'][TFrom]['__types']['context'], TSelected = TContext>(opts?: {
from: TFrom;
strict?: TStrict;
select?: (search: TContext) => TSelected;
}): TStrict extends true ? TSelected : TSelected | undefined;
declare function useRouteContext<TFrom extends keyof RegisteredRoutesInfo['routesById'], TStrict extends boolean = true, TRouteContext = RegisteredRoutesInfo['routesById'][TFrom]['__types']['routeContext'], TSelected = TRouteContext>(opts?: {
from: TFrom;
strict?: TStrict;
select?: (search: TRouteContext) => TSelected;
}): TStrict extends true ? TSelected : TSelected | undefined;
declare function useSearch<TFrom extends keyof RegisteredRoutesInfo['routesById'], TStrict extends boolean = true, TSearch = RegisteredRoutesInfo['routesById'][TFrom]['__types']['fullSearchSchema'], TSelected = TSearch>(opts?: {
from: TFrom;
strict?: TStrict;
track?: (search: TSearch) => TSelected;
select?: (search: TSearch) => TSelected;
}): TStrict extends true ? TSelected : TSelected | undefined;
declare function useParams<TFrom extends keyof RegisteredRoutesInfo['routesById'] = '/', TDefaultSelected = RegisteredRoutesInfo['allParams'] & RegisteredRoutesInfo['routesById'][TFrom]['__types']['allParams'], TSelected = TDefaultSelected>(opts?: {
from: TFrom;
track?: (search: TDefaultSelected) => TSelected;
select?: (search: TDefaultSelected) => TSelected;
}): TSelected;
declare function useNavigate<TDefaultFrom extends keyof RegisteredRoutesInfo['routesById'] = '/'>(defaultOpts?: {
declare function useNavigate<TDefaultFrom extends RegisteredRoutesInfo['routePaths'] = '/'>(defaultOpts?: {
from?: TDefaultFrom;
}): <TFrom extends string = TDefaultFrom, TTo extends string = "">(opts?: MakeLinkOptions<TFrom, TTo> | undefined) => Promise<void>;
declare function useMatchRoute(): <TFrom extends ValidFromPath<AnyRoutesInfo> = "/", TTo extends string = "">(opts: MakeUseMatchRouteOptions<TFrom, TTo>) => false | {};
declare function MatchRoute<TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/', TTo extends string = ''>(props: MakeMatchRouteOptions<TFrom, TTo>): any;
}): <TFrom extends unknown = TDefaultFrom, TTo extends string = "">(opts?: NavigateOptions<AnyRoutesInfo, TFrom, TTo> | undefined) => Promise<void>;
declare function useMatchRoute(): <TFrom extends string = "/", TTo extends string = "">(opts: MakeUseMatchRouteOptions<TFrom, TTo>) => any;
declare function MatchRoute<TFrom extends string = '/', TTo extends string = ''>(props: MakeMatchRouteOptions<TFrom, TTo>): any;
declare function Outlet(): JSX.Element | null;
declare function useInjectHtml(): (html: string | (() => Promise<string> | string)) => void;
declare function useDehydrate(): <T>(key: any, data: T | (() => T | Promise<T>)) => () => T | undefined;
declare function useHydrate(): <T = unknown>(key: any) => T;
declare function ErrorComponent({ error }: {

@@ -114,3 +154,4 @@ error: any;

declare function Block({ message, condition, children }: PromptProps): any;
declare function shallow<T>(objA: T, objB: T): boolean;
export { Block, ErrorComponent, Link, LinkFn, LinkPropsOptions, MakeLinkOptions, MakeLinkPropsOptions, MakeMatchRouteOptions, MakeUseMatchRouteOptions, MatchRoute, MatchesProviderProps, Navigate, Outlet, PromptProps, ReactRouter, RouteComponent, RouterProps, RouterProvider, SyncRouteComponent, lazy, matchesContext, routerContext, useBlocker, useLinkProps, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRoute, useRouter, useRouterContext, useSearch };
export { AnyRouteComponent, AsyncRouteComponent, Block, ErrorComponent, Link, LinkFn, LinkPropsOptions, MakeLinkOptions, MakeLinkPropsOptions, MakeMatchRouteOptions, MakeUseMatchRouteOptions, MatchRoute, Navigate, Outlet, PromptProps, RouteComponent, RouteErrorComponent, RouteErrorComponentProps, RouteFromIdOrRoute, RouterProps, RouterProvider, SyncRouteComponent, lazyRouteComponent, matchIdsContext, routerContext, shallow, useBlocker, useDehydrate, useHydrate, useInjectHtml, useLinkProps, useLoader, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRouteContext, useRouter, useRouterContext, useRouterState, useSearch };
/**
* react-router
* @tanstack/react-router/src/index.tsx
*

@@ -11,5 +11,5 @@ * Copyright (c) TanStack

*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("use-sync-external-store/shim/with-selector")):"function"==typeof define&&define.amd?define(["exports","react","use-sync-external-store/shim/with-selector"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReactRouter={},t.React,t.withSelector)}(this,(function(t,e,r){"use strict";function o(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var a=o(e);function s(){return s=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},s.apply(this,arguments)}function n(t,e){if(!t)throw new Error("Invariant failed")}function i(t,e){}
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("use-sync-external-store/shim/with-selector")):"function"==typeof define&&define.amd?define(["exports","react","use-sync-external-store/shim/with-selector"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReactRouter={},t.React,t.withSelector)}(this,(function(t,e,r){"use strict";function o(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var s=o(e);function n(){return n=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},n.apply(this,arguments)}
/**
* store
* @tanstack/store/src/index.ts
*

@@ -22,5 +22,5 @@ * Copyright (c) TanStack

* @license MIT
*/class c{listeners=new Set;batching=!1;queue=[];constructor(t,e){this.state=t,this.options=e}subscribe=t=>{this.listeners.add(t);const e=this.options?.onSubscribe?.(t,this);return()=>{this.listeners.delete(t),e?.()}};setState=t=>{const e=this.state;this.state=this.options?.updateFn?this.options.updateFn(e)(t):t(e),this.state!==e&&(this.options?.onUpdate?.(this.state,e),this.queue.push((()=>{this.listeners.forEach((t=>t(this.state,e)))})),this.#t())};#t=()=>{this.batching||(this.queue.forEach((t=>t())),this.queue=[])};batch=t=>{this.batching=!0,t(),this.batching=!1,this.#t()}}function h(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(e,r[o])||!Object.is(t[r[o]],e[r[o]]))return!1;return!0}
*/class a{listeners=new Set;_batching=!1;_flushing=0;_nextPriority=null;constructor(t,e){this.state=t,this.options=e}subscribe=t=>{this.listeners.add(t);const e=this.options?.onSubscribe?.(t,this);return()=>{this.listeners.delete(t),e?.()}};setState=(t,e)=>{const r=this.state;this.state=this.options?.updateFn?this.options.updateFn(r)(t):t(r);const o=e?.priority??this.options?.defaultPriority??"high";null===this._nextPriority||"high"===this._nextPriority?this._nextPriority=o:this._nextPriority=this.options?.defaultPriority??"high",this.options?.onUpdate?.({priority:this._nextPriority}),this._flush()};_flush=()=>{if(this._batching)return;const t=++this._flushing;this.listeners.forEach((e=>{this._flushing===t&&e({priority:this._nextPriority??"high"})}))};batch=t=>{if(this._batching)return t();this._batching=!0,t(),this._batching=!1,this._flush()}}
/**
* router
* @tanstack/react-store/src/index.tsx
*

@@ -33,5 +33,5 @@ * Copyright (c) TanStack

* @license MIT
*/const u="popstate",l="beforeunload",d=t=>(t.preventDefault(),t.returnValue=""),p=()=>{removeEventListener(l,d,{capture:!0})};function f(t){let e=t.getLocation(),r=()=>{},o=new Set,a=[],s=[];const n=()=>{if(a.length)a[0]?.(n,(()=>{a=[],p()}));else{for(;s.length;)s.shift()?.();c()}},i=t=>{s.push(t),n()},c=()=>{e=t.getLocation(),o.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===o.size&&(r=t.listener(c)),o.add(e),()=>{o.delete(e),0===o.size&&r()}),push:(e,r)=>{i((()=>{t.pushState(e,r)}))},replace:(e,r)=>{i((()=>{t.replaceState(e,r)}))},go:e=>{i((()=>{t.go(e)}))},back:()=>{i((()=>{t.back()}))},forward:()=>{i((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(a.push(t),1===a.length&&addEventListener(l,d,{capture:!0}),()=>{a=a.filter((e=>e!==t)),a.length||p()})}}function m(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),r=t?.createHref??(t=>t);return f({getLocation:()=>g(e(),history.state),listener:t=>(window.addEventListener(u,t),()=>{window.removeEventListener(u,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:v()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:v()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t)})}function y(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,o={};return f({getLocation:()=>g(e[r],o),listener:()=>()=>{},pushState:(t,a)=>{o={...a,key:v()},e.push(t),r++},replaceState:(t,a)=>{o={...a,key:v()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function g(t,e){let r=t.indexOf("#"),o=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?o>0?Math.min(r,o):r:o>0?o:t.length),hash:r>-1?t.substring(r,o):"",search:o>-1?t.substring(o):"",state:e}}function v(){return(Math.random()+1).toString(36).substring(7)}function w(t){return t[t.length-1]}function b(t,e){return"function"==typeof t?t(e):t}function S(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function _(t,e){if(t===e)return t;const r=e,o=Array.isArray(t)&&Array.isArray(r);if(o||L(t)&&L(r)){const e=o?t.length:Object.keys(t).length,a=o?r:Object.keys(r),s=a.length,n=o?[]:{};let i=0;for(let e=0;e<s;e++){const s=o?e:a[e];n[s]=_(t[s],r[s]),n[s]===t[s]&&i++}return e===s&&i===e?t:n}return r}function L(t){if(!E(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!E(r)&&!!r.hasOwnProperty("isPrototypeOf")}function E(t){return"[object Object]"===Object.prototype.toString.call(t)}function P(t,e){return t===e||typeof t==typeof e&&(L(t)&&L(e)?!Object.keys(e).some((r=>!P(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>P(t,e[r])))))}function x(t){return R(t.filter(Boolean).join("/"))}function R(t){return t.replace(/\/{2,}/g,"/")}function C(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function M(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function k(t){return M(C(t))}function O(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let o=j(e);const a=j(r);a.forEach(((t,e)=>{if("/"===t.value)e?e===a.length-1&&o.push(t):o=[t];else if(".."===t.value)o.length>1&&"/"===w(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return R(x([t,...o.map((t=>t.value))]))}function j(t){if(!t)return[];const e=[];if("/"===(t=R(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const r=t.split("/").filter(Boolean);return e.push(...r.map((t=>"$"===t||"*"===t?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function A(t,e,r){return x(j(t).map((t=>["$","*"].includes(t.value)&&!r?"":"param"===t.type?e[t.value.substring(1)]??"":t.value)))}function I(t,e,r){const o=$(t,e,r);if(!r.to||o)return o??{}}function $(t,e,r){if(!e.startsWith(t))return;const o=j(e="/"!=t?e.substring(t.length):e),a=j(`${r.to??"$"}`);"/"===w(o)?.value&&o.pop();const s={};return(()=>{for(let t=0;t<Math.max(o.length,a.length);t++){const e=o[t],n=a[t],i=t===a.length-1,c=t===o.length-1;if(n){if("wildcard"===n.type)return!!e?.value&&(s["*"]=x(o.slice(t).map((t=>t.value))),!0);if("pathname"===n.type){if("/"===n.value&&!e?.value)return!0;if(e)if(r.caseSensitive){if(n.value!==e.value)return!1}else if(n.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===n.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(s[n.value.substring(1)]=e.value)}}if(i&&!c)return!!r.fuzzy}return!0})()?s:void 0}function T(t,e){var r,o,a,s="";for(r in t)if(void 0!==(a=t[r]))if(Array.isArray(a))for(o=0;o<a.length;o++)s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(a[o]);else s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(a);return(e||"")+s}function D(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function N(t){for(var e,r,o={},a=t.split("&");e=a.shift();)void 0!==o[r=(e=e.split("=")).shift()]?o[r]=[].concat(o[r],D(e.shift())):o[r]=D(e.shift());return o}const H="__root__";class B{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute}init=t=>{this.originalIndex=t.originalIndex,this.router=t.router;const e=this.options,r=!e?.path&&!e?.id;this.parentRoute=this.options?.getParentRoute?.(),r?this.path=H:n(this.parentRoute);let o=r?H:e.path;o&&"/"!==o&&(o=k(o));const a=e?.id||o;let s=r?H:x([this.parentRoute.id===H?"":this.parentRoute.id,a]);o===H&&(o="/"),s!==H&&(s=x(["/",s]));const i=s===H?"/":M(x([this.parentRoute.fullPath,o]));this.path=o,this.id=s,this.fullPath=i};addChildren=t=>(this.children=t,this)}class F extends B{constructor(t){super(t)}static withRouterContext=()=>t=>new F(t)}const U=q(JSON.parse),z=W(JSON.stringify);function q(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=N(e);for(let e in r){const o=r[e];if("string"==typeof o)try{r[e]=t(o)}catch(t){}}return r}}function W(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const o=e[r];if(void 0===o||void 0===o)delete e[r];else if(o&&"object"==typeof o&&null!==o)try{e[r]=t(o)}catch(t){}}));const r=T(e).toString();return r?`?${r}`:""}}const K=async({router:t,routeMatch:e})=>{const r=t.buildNext({to:".",search:t=>({...t??{},__data:{matchId:e.id}})}),o=await fetch(r.href,{method:"GET",signal:e.abortController.signal});if(o.ok)return o.json();throw new Error("Failed to fetch match data")};class V{#e;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??z,parseSearch:t?.parseSearch??U,fetchServerDataFn:t?.fetchServerDataFn??K},this.__store=new c(G(),{onUpdate:t=>{this.state=t}}),this.state=this.__store.state,this.basepath="",this.update(t),this.options.Router?.(this);const e=this.buildNext({hash:!0,fromCurrent:!0,search:!0,state:!0});this.state.latestLocation.href!==e.href&&this.#r({...e,replace:!0})}reset=()=>{this.__store.setState((t=>Object.assign(t,G())))};mount=()=>(J||this.state.currentMatches.length||this.safeLoad(),()=>{});update=t=>{if(Object.assign(this.options,t),!this.history||this.options.history&&this.options.history!==this.history){this.#e&&this.#e(),this.history=this.options.history??(J?y():m());const t=this.#o();this.__store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#e=this.history.listen((()=>{this.safeLoad({next:this.#o(this.state.latestLocation)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${k(e??"")??""}`,r&&(this.routesById={},this.routeTree=this.#a(r)),this};buildNext=t=>{const e=this.#s(t),r=this.matchRoutes(e.pathname);return this.#s({...t,__matches:r})};cancelMatches=()=>{[...this.state.currentMatches,...this.state.pendingMatches||[]].forEach((t=>{t.cancel()}))};safeLoad=t=>{this.load(t).catch((t=>{console.warn(t),n(!1)}))};load=async t=>{let e=Date.now();const r=e;let o;if(this.startedLoadingAt=r,this.cancelMatches(),this.__store.batch((()=>{t?.next&&this.__store.setState((e=>({...e,latestLocation:t.next}))),o=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),this.__store.setState((t=>({...t,status:"pending",pendingMatches:o,pendingLocation:this.state.latestLocation})))})),await this.loadMatches(o,this.state.pendingLocation),this.startedLoadingAt!==r)return this.navigationPromise;const a=this.state.currentMatches,s=[],n=[];a.forEach((t=>{o.find((e=>e.id===t.id))?n.push(t):s.push(t)}));const i=o.filter((t=>!a.find((e=>e.id===t.id))));e=Date.now(),s.forEach((t=>{t.__onExit?.({params:t.params,search:t.state.routeSearch}),"error"===t.state.status&&this.__store.setState((t=>({...t,status:"idle",error:void 0})))})),n.forEach((t=>{t.route.options.onTransition?.({params:t.params,search:t.state.routeSearch})})),i.forEach((t=>{t.__onExit=t.route.options.onLoaded?.({params:t.params,search:t.state.search})}));const c=this.state.currentLocation;this.__store.setState((t=>({...t,status:"idle",currentLocation:this.state.latestLocation,currentMatches:o,pendingLocation:void 0,pendingMatches:void 0}))),o.forEach((t=>{t.__commit()})),c.href!==this.state.currentLocation.href&&this.options.onRouteChange?.(),this.resolveNavigation()};getRoute=t=>{const e=this.routesById[t];return n(e),e};loadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r,e),r};preloadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r,e,{preload:!0}),r};matchRoutes=(t,e)=>{const r=[];if(!this.routeTree)return r;const o=[...this.state.currentMatches,...this.state.pendingMatches??[]],a=async s=>{let n=w(r)?.params??{};const i=this.options.filterRoutes?.(s)??s;let c=[];const h=(r,o)=>(o.some((o=>{const a=o.children;if(!o.path&&a?.length)return h([...c,o],a);const s=!("/"===o.path&&!a?.length),i=I(this.basepath,t,{to:o.fullPath,fuzzy:s,caseSensitive:o.options.caseSensitive??this.options.caseSensitive});if(i){let t;try{t=o.options.parseParams?.(i)??i}catch(t){if(e?.strictParseParams)throw t}n={...n,...t}}return i&&(c=[...r,o]),!!c.length})),!!c.length);if(h([],i),!c.length)return;c.forEach((t=>{const e=A(t.path,n),a=A(t.id,n,!0),s=o.find((t=>t.id===a))||new Y(this,t,{id:a,params:n,pathname:x([this.basepath,e])});r.push(s)}));const u=w(c).children;u?.length&&a(u)};return a([this.routeTree]),r};loadMatches=async(t,e,r)=>{let o;try{await Promise.all(t.map((async(t,e)=>{try{await(t.route.options.beforeLoad?.({router:this,match:t}))}catch(r){if(Q(r))throw r;o=o??e;const a=t.route.options.onBeforeLoadError??t.route.options.onError;try{a?.(r)}catch(e){if(Q(e))throw e;return void t.__store.setState((t=>({...t,error:e,status:"error",updatedAt:Date.now()})))}t.__store.setState((t=>({...t,error:r,status:"error",updatedAt:Date.now()})))}})))}catch(t){if(Q(t))return void(r?.preload||this.navigate(t));throw t}const a=t.slice(0,o),s=a.map((async(t,o)=>{const s=a[o-1];t.__load({preload:r?.preload,location:e,parentMatch:s}),await t.__loadPromise,s&&await s.__loadPromise}));await Promise.all(s)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>O(this.basepath,t,R(e));navigate=async({from:t,to:e="",search:r,hash:o,replace:a,params:s})=>{const i=String(e),c=void 0===t?t:String(t);let h;try{new URL(`${i}`),h=!0}catch(t){}return n(!h),this.#r({from:c,to:i,search:r,hash:o,replace:a,params:s})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t),o=e?.pending?this.state.pendingLocation:this.state.currentLocation;if(!o)return!1;const a=I(this.basepath,o.pathname,{...e,to:r.pathname});return!!a&&(e?.includeSearch??1?!!P(o.search,r.search)&&a:a)};buildLink=({from:t,to:e=".",search:r,params:o,hash:a,target:s,replace:n,activeOptions:i,preload:c,preloadDelay:h,disabled:u})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const l={from:t,to:e,search:r,params:o,hash:a,replace:n},d=this.buildNext(l);c=c??this.options.defaultPreload;const p=h??this.options.defaultPreloadDelay??0,f=this.state.currentLocation.pathname.split("/"),m=d.pathname.split("/").every(((t,e)=>t===f[e])),y=i?.exact?this.state.currentLocation.pathname===d.pathname:m,g=!i?.includeHash||this.state.currentLocation.hash===d.hash,v=!(i?.includeSearch??1)||P(this.state.currentLocation.search,d.search);return{type:"internal",next:d,handleFocus:t=>{c&&this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{u||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||s&&"_self"!==s||0!==t.button||(t.preventDefault(),this.#r(l))},handleEnter:t=>{const e=t.target||{};if(c){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),p)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},isActive:y&&g&&v,disabled:u}};dehydrate=()=>({state:{...S(this.state,["latestLocation","currentLocation","status","lastUpdated"]),currentMatches:this.state.currentMatches.map((t=>({id:t.id,state:{status:t.state.status}})))}});hydrate=t=>{this.__store.setState((e=>{const r=this.matchRoutes(t.state.latestLocation.pathname,{strictParseParams:!0});return r.forEach(((e,r)=>{const o=t.state.currentMatches[r];n(o&&o.id===e.id),e.__store.setState((t=>({...t,...o.state})))})),{...e,...t.state,currentMatches:r}}))};#a=t=>{const e=(t,r)=>{t.forEach(((t,r)=>{t.init({originalIndex:r,router:this});n(!this.routesById[t.id],String(t.id)),this.routesById[t.id]=t;const o=t.children;o?.length&&(e(o),t.children=o.map(((t,e)=>{const r=j(C(R(t.path??"/")));for(;r.length>1&&"/"===r[0]?.value;)r.shift();let o=0;return r.forEach(((t,e)=>{let r=1;for(;e--;)r*=.001;"pathname"===t.type&&"/"!==t.value?o+=1*r:"param"===t.type?o+=2*r:"wildcard"===t.type&&(o+=3*r)})),{child:t,parsed:r,index:e,score:o}})).sort(((t,e)=>t.score!==e.score?t.score-e.score:t.index-e.index)).map((t=>t.child)))}))};e([t]);const r=(t,e)=>{t.forEach((t=>{t.isRoot?n(!e):n(!e||t.parentRoute===e,(t.path,t.parentRoute?.id,e?.id)),t.children&&r(t.children,t)}))};return r([t],void 0),t};#o=t=>{let{pathname:e,search:r,hash:o,state:a}=this.history.location;const s=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:_(t?.search,s),hash:o.split("#").reverse()[0]??"",href:`${e}${r}${o}`,state:a,key:a?.key||"__init__"}};#s=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.latestLocation.pathname:t.from??this.state.latestLocation.pathname;let r=O(this.basepath??"/",e,`${t.to??""}`);const o={...w(this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}))?.params};let a=!0===(t.params??!0)?o:b(t.params,o);a&&t.__matches?.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{a={...a,...t(a)}})),r=A(r,a??{});const s=t.__matches?.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean)??[],n=t.__matches?.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean)??[],i=s?.length?s?.reduce(((t,e)=>e(t)),this.state.latestLocation.search):this.state.latestLocation.search,c=!0===t.search?i:t.search?b(t.search,i)??{}:s?.length?i:{},h=n?.length?n.reduce(((t,e)=>e(t)),c):c,u=_(this.state.latestLocation.search,h),l=this.options.stringifySearch(u);let d=!0===t.hash?this.state.latestLocation.hash:b(t.hash,this.state.latestLocation.hash);d=d?`#${d}`:"";return{pathname:r,search:u,searchStr:l,state:!0===t.state?this.state.latestLocation.state:b(t.state,this.state.latestLocation.state),hash:d,href:this.history.createHref(`${r}${l}${d}`),key:t.key}};#r=async t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let o="replace";t.replace||(o="push");this.state.latestLocation.href===e.href&&!e.key&&(o="replace");const a=`${e.pathname}${e.searchStr}${e.hash?`${e.hash}`:""}`;return this.history["push"===o?"push":"replace"](a,{id:r,...e.state}),this.navigationPromise=new Promise((t=>{const e=this.resolveNavigation;this.resolveNavigation=()=>{e(),t()}}))}}const J="undefined"==typeof window||!window.document.createElement;function G(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],lastUpdated:Date.now()}}function Q(t){return!!t?.isRedirect}const X=["component","errorComponent","pendingComponent"];class Y{abortController=new AbortController;constructor(t,e,r){Object.assign(this,{route:e,router:t,id:r.id,pathname:r.pathname,params:r.params,__store:new c({updatedAt:0,routeSearch:{},search:{},status:"idle"},{onUpdate:t=>{this.state=t}})}),this.state=this.__store.state,X.map((async t=>{const e=this.route.options[t];"function"!=typeof this[t]&&(this[t]=e)})),"idle"!==this.state.status||this.#n()||this.__store.setState((t=>({...t,status:"success"})))}#n=()=>!(!this.route.options.onLoad&&!X.some((t=>this.route.options[t]?.preload)));__commit=()=>{const{routeSearch:t,search:e,context:r,routeContext:o}=this.#i({location:this.router.state.currentLocation});this.context=r,this.routeContext=o,this.__store.setState((r=>({...r,routeSearch:_(r.routeSearch,t),search:_(r.search,e)})))};cancel=()=>{this.abortController?.abort()};#c=t=>{const e=this.parentMatch?this.parentMatch.#c(t):{search:t.location.search,routeSearch:t.location.search};try{const t=("object"==typeof this.route.options.validateSearch?this.route.options.validateSearch.parse:this.route.options.validateSearch)?.(e.search)??{};return{routeSearch:t,search:{...e.search,...t}}}catch(t){if(Q(t))throw t;(this.route.options.onValidateSearchError??this.route.options.onError)?.(t);const e=new Error("Invalid search params found",{cause:t});throw e.code="INVALID_SEARCH_PARAMS",e}};#i=t=>{const{search:e,routeSearch:r}=this.#c(t);try{const t=this.route.options.getContext?.({parentContext:this.parentMatch?.routeContext??{},context:this.parentMatch?.context??this.router?.options.context??{},params:this.params,search:e})||{};return{routeSearch:r,search:e,context:{...this.parentMatch?.context??this.router?.options.context,...t},routeContext:t}}catch(t){throw this.route.options.onError?.(t),t}};__load=async t=>{let e;this.parentMatch=t.parentMatch;try{e=this.#i(t)}catch(e){return Q(e)?void(t?.preload||this.router.navigate(e)):void this.__store.setState((t=>({...t,status:"error",error:e})))}const{routeSearch:r,search:o,context:a,routeContext:s}=e;if("pending"!==this.state.status)return this.__loadPromise=Promise.resolve().then((async()=>{const e=""+Date.now()+Math.random();this.#h=e;const n=()=>e!==this.#h?this.__loadPromise:void 0;let i;"idle"===this.state.status&&this.__store.setState((t=>({...t,status:"pending"})));const c=(async()=>{await Promise.all(X.map((async t=>{const e=this.route.options[t];this[t]?.preload&&(this[t]=await this.router.options.loadComponent(e))})))})(),h=Promise.resolve().then((()=>{if(this.route.options.onLoad)return this.route.options.onLoad({params:this.params,routeSearch:r,search:o,signal:this.abortController.signal,preload:!!t?.preload,routeContext:s,context:a})}));try{if(await Promise.all([c,h]),i=n())return await i;this.__store.setState((t=>({...t,error:void 0,status:"success",updatedAt:Date.now()})))}catch(e){if(Q(e))return void(t?.preload||this.router.navigate(e));const r=this.route.options.onLoadError??this.route.options.onError;try{r?.(e)}catch(e){return Q(e)?void(t?.preload||this.router.navigate(e)):void this.__store.setState((t=>({...t,error:e,status:"error",updatedAt:Date.now()})))}this.__store.setState((t=>({...t,error:e,status:"error",updatedAt:Date.now()})))}finally{delete this.__loadPromise}})),this.__loadPromise};#h=""}
*/function i(t,e=(t=>t)){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,c)}function c(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(e,r[o])||!Object.is(t[r[o]],e[r[o]]))return!1;return!0}function h(t,e){if(!t)throw new Error("Invariant failed")}
/**
* react-store
* @tanstack/router-core/src/index.ts
*

@@ -44,3 +44,4 @@ * Copyright (c) TanStack

* @license MIT
*/function Z(t,e=(t=>t),o){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,o?h:void 0)}function tt(t){const e=at(),{type:r,children:o,target:s,activeProps:n=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:h,hash:u,search:l,params:d,to:p=".",preload:f,preloadDelay:m,replace:y,style:g,className:v,onClick:w,onFocus:S,onMouseEnter:_,onMouseLeave:L,onTouchStart:E,...P}=t,x=e.buildLink(t);if("external"===x.type){const{href:t}=x;return{href:t}}const{handleClick:R,handleFocus:C,handleEnter:M,handleLeave:k,handleTouchStart:O,isActive:j,next:A}=x,I=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},$=j?b(n,{})??{}:{},T=j?{}:b(i,{})??{};return{...$,...T,...P,href:h?void 0:A.href,onClick:I([w,t=>{a.startTransition?a.startTransition((()=>{R(t)})):R(t)}]),onFocus:I([S,C]),onMouseEnter:I([_,M]),onMouseLeave:I([L,k]),onTouchStart:I([E,O]),target:s,style:{...g,...$.style,...T.style},className:[v,$.className,T.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":j?"active":void 0}}const et=a.forwardRef(((t,e)=>{const r=tt(t);return a.createElement("a",s({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))}));const rt=a.createContext(null),ot=a.createContext(null);function at(){const t=a.useContext(ot);return Z(t.router.__store),t.router}function st(t,e){const r=at();return Z(r.__store,t,e),r}function nt(){return a.useContext(rt)}function it(t){const e=at(),r=nt()[0],o=t?.from?e.state.currentMatches.find((e=>e.route.id===t?.from)):r;return n(o,t?.from&&t.from),(t?.strict??1)&&n(r.route.id==o?.route.id,(o?.route.id,r.route.id,o?.route.id,o?.route.id)),Z(o.__store,(e=>t?.track?.(o)??o),t?.shallow),o}function ct(){const t=at();return a.useCallback((e=>{const{pending:r,caseSensitive:o,...a}=e;return t.matchRoute(a,{pending:r,caseSensitive:o})}),[])}function ht(){const t=nt().slice(1),e=t[0];return e?a.createElement(ut,{matches:t,match:e}):null}function ut({matches:t,match:e}){const r=at();Z(e.__store,(t=>[t.status,t.error]),!0);const o=a.useCallback((()=>null),[]),s=e.pendingComponent??r.options.defaultPendingComponent??o,n=e.errorComponent??r.options.defaultErrorComponent,i=e.route.options.wrapInSuspense??1?a.Suspense:dt,c=n?pt:dt;return a.createElement(rt.Provider,{value:t},a.createElement(i,{fallback:a.createElement(s,null)},a.createElement(c,{key:e.route.id,errorComponent:n,onCatch:()=>{e.id}},a.createElement(lt,{match:e}))))}function lt(t){const e=at();if("error"===t.match.state.status)throw t.match.state.error;if("success"===t.match.state.status)return a.createElement(t.match.component??e.options.defaultComponent??ht);if("pending"===t.match.state.status)throw t.match.__loadPromise;n(!1)}function dt(t){return a.createElement(a.Fragment,null,t.children)}class pt extends a.Component{state={error:!1,info:void 0};componentDidCatch(t,e){this.props.onCatch(t,e),console.error(t),this.setState({error:t,info:e})}render(){return a.createElement(ft,s({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function ft(t){const[e,r]=a.useState(t.errorState),o=at(),s=t.errorComponent??mt,n=a.useRef("");return a.useEffect((()=>{e&&o.state.currentLocation.key!==n.current&&r({}),n.current=o.state.currentLocation.key}),[e,o.state.currentLocation.key]),a.useEffect((()=>{t.errorState.error&&r(t.errorState)}),[t.errorState.error]),t.errorState.error&&e.error?a.createElement(s,e):t.children}function mt({error:t}){return a.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},a.createElement("strong",{style:{fontSize:"1.2rem"}},"Something went wrong!"),a.createElement("div",{style:{height:".5rem"}}),a.createElement("div",null,a.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".5rem",color:"red",overflow:"auto"}},t.message?a.createElement("code",null,t.message):null)))}function yt(t,e=!0){const r=st();a.useEffect((()=>{if(!e)return;let o=r.history.block(((e,r)=>{window.confirm(t)?(o(),e()):r()}));return o}))}t.Block=function({message:t,condition:e,children:r}){return yt(t,e),r??null},t.ErrorComponent=mt,t.Link=et,t.MatchRoute=function(t){const e=ct()(t);return e?"function"==typeof t.children?t.children(e):e?t.children:null:null},t.Navigate=function(t){const e=at();return a.useLayoutEffect((()=>{e.navigate(t)}),[]),null},t.Outlet=ht,t.ReactRouter=class extends V{constructor(t){super({...t,loadComponent:async t=>(t.preload&&await t.preload(),t)})}},t.RootRoute=F,t.Route=B,t.RouteMatch=Y,t.Router=V,t.RouterProvider=function({router:t,...e}){t.update(e);const r=Z(t.__store,(t=>t.currentMatches));return a.useEffect(t.mount,[t]),a.createElement(ot.Provider,{value:{router:t}},a.createElement(rt.Provider,{value:[void 0,...r]},a.createElement(pt,{errorComponent:mt,onCatch:()=>{}},a.createElement(ht,null))))},t.cleanPath=R,t.createBrowserHistory=m,t.createHashHistory=function(){return m({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=y,t.decode=N,t.defaultFetchServerDataFn=K,t.defaultParseSearch=U,t.defaultStringifySearch=z,t.encode=T,t.functionalUpdate=b,t.interpolatePath=A,t.invariant=n,t.isPlainObject=L,t.isRedirect=Q,t.joinPaths=x,t.last=w,t.lazy=function(t){const e=a.lazy(t);return e.preload=async()=>{await t()},e},t.matchByPath=$,t.matchPathname=I,t.matchesContext=rt,t.parsePathname=j,t.parseSearchWith=q,t.partialDeepEqual=P,t.pick=S,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=_,t.resolvePath=O,t.rootRouteId=H,t.routerContext=ot,t.stringifySearchWith=W,t.trimPath=k,t.trimPathLeft=C,t.trimPathRight=M,t.useBlocker=yt,t.useLinkProps=tt,t.useMatch=it,t.useMatchRoute=ct,t.useMatches=nt,t.useNavigate=function(t){const e=at();return a.useCallback((r=>e.navigate({...t,...r})),[])},t.useParams=function(t){const e=at();return Z(e.__store,(e=>{const r=w(e.currentMatches)?.params;return t?.track?.(r)??r}),!0),w(e.state.currentMatches)?.params},t.useRoute=function(t){const e=at().getRoute(t);return n(e),e},t.useRouter=st,t.useRouterContext=at,t.useSearch=function(t){const{track:e,...r}=t,o=it(r);return Z(o.__store,(e=>t?.track?.(e.search)??e.search),!0),o.state.search},t.useStore=Z,t.warning=i,Object.defineProperty(t,"__esModule",{value:!0})}));
*/
const u="pushstate",l="popstate",d="beforeunload",p=t=>(t.preventDefault(),t.returnValue=""),f=()=>{removeEventListener(d,p,{capture:!0})};function m(t){let e=t.getLocation(),r=()=>{},o=new Set,s=[],n=[];const a=()=>{if(s.length)s[0]?.(a,(()=>{s=[],f()}));else{for(;n.length;)n.shift()?.();t.listener||c()}},i=t=>{n.push(t),a()},c=()=>{e=t.getLocation(),o.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===o.size&&(r="function"==typeof t.listener?t.listener(c):()=>{}),o.add(e),()=>{o.delete(e),0===o.size&&r()}),push:(e,r)=>{i((()=>{t.pushState(e,r)}))},replace:(e,r)=>{i((()=>{t.replaceState(e,r)}))},go:e=>{i((()=>{t.go(e)}))},back:()=>{i((()=>{t.back()}))},forward:()=>{i((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(s.push(t),1===s.length&&addEventListener(d,p,{capture:!0}),()=>{s=s.filter((e=>e!==t)),s.length||f()})}}function y(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=t?.createHref??(t=>t);return m({getLocation:()=>v(e(),history.state),listener:t=>{window.addEventListener(u,t),window.addEventListener(l,t);var e=window.history.pushState;window.history.pushState=function(){let r=e.apply(history,arguments);return t(),r};var r=window.history.replaceState;return window.history.replaceState=function(){let e=r.apply(history,arguments);return t(),e},()=>{window.history.pushState=e,window.history.replaceState=r,window.removeEventListener(u,t),window.removeEventListener(l,t)}},pushState:(t,e)=>{window.history.pushState({...e,key:w()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:w()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t)})}function g(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,o={};return m({getLocation:()=>v(e[r],o),listener:!1,pushState:(t,s)=>{o={...s,key:w()},e.push(t),r++},replaceState:(t,s)=>{o={...s,key:w()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function v(t,e){let r=t.indexOf("#"),o=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?o>0?Math.min(r,o):r:o>0?o:t.length),hash:r>-1?t.substring(r):"",search:o>-1?t.slice(o,-1===r?void 0:r):"",state:e}}function w(){return(Math.random()+1).toString(36).substring(7)}function b(t){return t[t.length-1]}function S(t,e){return"function"==typeof t?t(e):t}function x(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function E(t,e){if(t===e)return t;const r=e,o=Array.isArray(t)&&Array.isArray(r);if(o||R(t)&&R(r)){const e=o?t.length:Object.keys(t).length,s=o?r:Object.keys(r),n=s.length,a=o?[]:{};let i=0;for(let e=0;e<n;e++){const n=o?e:s[e];a[n]=E(t[n],r[n]),a[n]===t[n]&&i++}return e===n&&i===e?t:a}return r}function R(t){if(!I(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!I(r)&&!!r.hasOwnProperty("isPrototypeOf")}function I(t){return"[object Object]"===Object.prototype.toString.call(t)}function _(t,e){return t===e||typeof t==typeof e&&(R(t)&&R(e)?!Object.keys(e).some((r=>!_(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>_(t,e[r])))))}function P(t){return C(t.filter(Boolean).join("/"))}function C(t){return t.replace(/\/{2,}/g,"/")}function M(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function L(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function O(t){return L(M(t))}function j(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let o=k(e);const s=k(r);s.forEach(((t,e)=>{if("/"===t.value)e?e===s.length-1&&o.push(t):o=[t];else if(".."===t.value)o.length>1&&"/"===b(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return C(P([t,...o.map((t=>t.value))]))}function k(t){if(!t)return[];const e=[];if("/"===(t=C(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const r=t.split("/").filter(Boolean);return e.push(...r.map((t=>"$"===t||"*"===t?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function A(t,e,r=!1){return P(k(t).map((t=>{if("wildcard"===t.type){const o=e[t.value];return r?`${t.value}${o??""}`:o}return"param"===t.type?e[t.value.substring(1)]??"":t.value})))}function D(t,e,r){const o=B(t,e,r);if(!r.to||o)return o??{}}function B(t,e,r){e="/"!=t?e.substring(t.length):e;const o=`${r.to??"$"}`,s=k(e),n=k(o);e.startsWith("/")||s.unshift({type:"pathname",value:"/"}),o.startsWith("/")||n.unshift({type:"pathname",value:"/"});const a={};return(()=>{for(let t=0;t<Math.max(s.length,n.length);t++){const e=s[t],o=n[t],i=t>=s.length-1,c=t>=n.length-1;if(o){if("wildcard"===o.type)return!!e?.value&&(a["*"]=P(s.slice(t).map((t=>t.value))),!0);if("pathname"===o.type){if("/"===o.value&&!e?.value)return!0;if(e)if(r.caseSensitive){if(o.value!==e.value)return!1}else if(o.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===o.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(a[o.value.substring(1)]=e.value)}}if(!i&&c)return!!r.fuzzy}return!0})()?a:void 0}function $(t,e){var r,o,s,n="";for(r in t)if(void 0!==(s=t[r]))if(Array.isArray(s))for(o=0;o<s.length;o++)n&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(s[o]);else n&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(s);return(e||"")+n}function T(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0&&+e+""===e?+e:e))}function H(t){for(var e,r,o={},s=t.split("&");e=s.shift();)void 0!==o[r=(e=e.split("=")).shift()]?o[r]=[].concat(o[r],T(e.shift())):o[r]=T(e.shift());return o}const F="__root__";class N{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute,N.__onInit(this)}init=t=>{this.originalIndex=t.originalIndex,this.router=t.router;const e=this.options,r=!e?.path&&!e?.id;this.parentRoute=this.options?.getParentRoute?.(),r?this.path=F:h(this.parentRoute);let o=r?F:e.path;o&&"/"!==o&&(o=O(o));const s=e?.id||o;let n=r?F:P([this.parentRoute.id===F?"":this.parentRoute.id,s]);o===F&&(o="/"),n!==F&&(n=P(["/",n]));const a=n===F?"/":P([this.parentRoute.fullPath,o]);this.path=o,this.id=n,this.fullPath=a,this.to=a};addChildren=t=>(this.children=t,this);update=t=>(Object.assign(this.options,t),this);static __onInit=t=>{}}class U extends N{constructor(t){super(t)}}const z=J(JSON.parse),W=q(JSON.stringify);function J(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=H(e);for(let e in r){const o=r[e];if("string"==typeof o)try{r[e]=t(o)}catch(t){}}return r}}function q(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const o=e[r];if(void 0===o||void 0===o)delete e[r];else if(o&&"object"==typeof o&&null!==o)try{e[r]=t(o)}catch(t){}}));const r=$(e).toString();return r?`?${r}`:""}}const K=["component","errorComponent","pendingComponent"];const Y="undefined"==typeof window||!window.document.createElement;function V(){return{status:"idle",isFetching:!1,resolvedLocation:null,location:null,matchesById:{},matchIds:[],pendingMatchIds:[],matches:[],pendingMatches:[],lastUpdated:Date.now()}}function G(t){return!!t?.isRedirect}class Q extends Error{}class X extends Error{}function Z(t){const e=nt(),{type:r,children:o,target:n,activeProps:a=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:h,hash:u,search:l,params:d,to:p=".",preload:f,preloadDelay:m,replace:y,style:g,className:v,onClick:w,onFocus:b,onMouseEnter:x,onMouseLeave:E,onTouchStart:R,...I}=t,_=e.buildLink(t);if("external"===_.type){const{href:t}=_;return{href:t}}const{handleClick:P,handleFocus:C,handleEnter:M,handleLeave:L,handleTouchStart:O,isActive:j,next:k}=_,A=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},D=j?S(a,{})??{}:{},B=j?{}:S(i,{})??{};return{...D,...B,...I,href:h?void 0:k.href,onClick:A([w,e=>{(t.startTransition??1)&&(s.startTransition||(t=>t))((()=>{P(e)}))}]),onFocus:A([b,C]),onMouseEnter:A([x,M]),onMouseLeave:A([E,L]),onTouchStart:A([R,O]),target:n,style:{...g,...D.style,...B.style},className:[v,D.className,B.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":j?"active":void 0}}N.__onInit=t=>{Object.assign(t,{useMatch:(e={})=>at({...e,from:t.id}),useLoader:(e={})=>it({...e,from:t.id}),useContext:(e={})=>at({...e,from:t.id,select:t=>e?.select?.(t.context)??t.context}),useRouteContext:(e={})=>at({...e,from:t.id,select:t=>e?.select?.(t.routeContext)??t.routeContext}),useSearch:(e={})=>ct({...e,from:t.id}),useParams:(e={})=>ht({...e,from:t.id})})};const tt=s.forwardRef(((t,e)=>{const r=Z(t);return s.createElement("a",n({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))}));const et=s.createContext(null),rt=s.createContext(null);function ot(t){return i(nt().__store,t?.select)}function st(){const t=nt(),e=ot({select:e=>e.pendingMatches.some((e=>!!t.getRoute(e.routeId)?.options.pendingComponent))?(console.log("hasPending"),e.pendingMatchIds):e.matchIds});return s.createElement(et.Provider,{value:[void 0,...e]},s.createElement(yt,{errorComponent:vt,onCatch:()=>{}},s.createElement(lt,null)))}function nt(){return s.useContext(rt)}function at(t){const e=nt(),r=s.useContext(et)[0],o=e.getRouteMatch(r)?.routeId,n=ot({select:e=>{const o=e.matches;return(t?.from?o.find((e=>e.routeId===t?.from)):o.find((t=>t.id===r))).routeId}});(t?.strict??1)&&h(o==n);return ot({select:e=>{const o=e.matches,s=t?.from?o.find((e=>e.routeId===t?.from)):o.find((t=>t.id===r));return h(s,t?.from&&t.from),t?.select?.(s)??s}})}function it(t){return at({...t,select:e=>t?.select?.(e.loaderData)??e.loaderData})}function ct(t){return at({...t,select:e=>t?.select?.(e.search)??e.search})}function ht(t){return ot({select:e=>{const r=b(e.matches)?.params;return t?.select?.(r)??r}})}function ut(){const t=nt();return s.useCallback((e=>{const{pending:r,caseSensitive:o,...s}=e;return t.matchRoute(s,{pending:r,caseSensitive:o})}),[])}function lt(){const t=s.useContext(et).slice(1);return t[0]?s.createElement(pt,{matchIds:t}):null}const dt=()=>null;function pt({matchIds:t}){const e=nt(),r=t[0],o=e.getRouteMatch(r).routeId,n=e.getRoute(o),a=n.options.pendingComponent??e.options.defaultPendingComponent??dt,i=n.options.errorComponent??e.options.defaultErrorComponent??vt,c=n.options.wrapInSuspense??!n.isRoot?s.Suspense:mt,h=i?yt:mt;return s.createElement(et.Provider,{value:t},s.createElement(c,{fallback:s.createElement(a,{useLoader:n.useLoader,useMatch:n.useMatch,useContext:n.useContext,useRouteContext:n.useRouteContext,useSearch:n.useSearch,useParams:n.useParams})},s.createElement(h,{key:n.id,errorComponent:i,onCatch:()=>{}},s.createElement(ft,{matchId:r,PendingComponent:a}))))}function ft({matchId:t,PendingComponent:e}){const r=nt(),o=ot({select:e=>x(e.matchesById[t],["status","loadPromise","routeId","error"])}),n=r.getRoute(o.routeId);if("error"===o.status)throw o.error;if("pending"===o.status)return s.createElement(e,{useLoader:n.useLoader,useMatch:n.useMatch,useContext:n.useContext,useRouteContext:n.useRouteContext,useSearch:n.useSearch,useParams:n.useParams});if("success"===o.status){let t=n.options.component??r.options.defaultComponent;return t?s.createElement(t,{useLoader:n.useLoader,useMatch:n.useMatch,useContext:n.useContext,useRouteContext:n.useRouteContext,useSearch:n.useSearch,useParams:n.useParams}):s.createElement(lt,null)}h(!1)}function mt(t){return s.createElement(s.Fragment,null,t.children)}class yt extends s.Component{state={error:!1,info:void 0};componentDidCatch(t,e){this.props.onCatch(t,e),this.setState({error:t,info:e})}render(){return s.createElement(gt,n({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function gt(t){const e=ot({select:t=>t.resolvedLocation.key}),[r,o]=s.useState(t.errorState),n=t.errorComponent??vt,a=s.useRef("");return s.useEffect((()=>{r&&e!==a.current&&o({}),a.current=e}),[r,e]),s.useEffect((()=>{t.errorState.error&&o(t.errorState)}),[t.errorState.error]),t.errorState.error&&r.error?s.createElement(n,r):t.children}function vt({error:t}){const[e,r]=s.useState(!1);return s.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},s.createElement("div",{style:{display:"flex",alignItems:"center",gap:".5rem"}},s.createElement("strong",{style:{fontSize:"1rem"}},"Something went wrong!"),s.createElement("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>r((t=>!t))},e?"Hide Error":"Show Error")),s.createElement("div",{style:{height:".25rem"}}),e?s.createElement("div",null,s.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"}},t.message?s.createElement("code",null,t.message):null)):null)}function wt(t,e=!0){const r=nt();s.useEffect((()=>{if(!e)return;let o=r.history.block(((e,r)=>{window.confirm(t)&&(o(),e())}));return o}))}t.Block=function({message:t,condition:e,children:r}){return wt(t,e),r??null},t.ErrorComponent=vt,t.Link=tt,t.MatchRoute=function(t){const e=ut()(t);return"function"==typeof t.children?t.children(e):e?t.children:null},t.Navigate=function(t){const e=nt();return s.useLayoutEffect((()=>{e.navigate(t)}),[]),null},t.Outlet=lt,t.PathParamError=X,t.RootRoute=U,t.Route=N,t.Router=class{#t;constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??W,parseSearch:t?.parseSearch??z},this.__store=new a(V(),{onUpdate:()=>{const t=this.state;this.state=this.__store.state;const e=t.matchesById!==this.state.matchesById;let r,o;e||(r=t.matchIds.length!==this.state.matchIds.length||t.matchIds.some(((t,e)=>t!==this.state.matchIds[e])),o=t.pendingMatchIds.length!==this.state.pendingMatchIds.length||t.pendingMatchIds.some(((t,e)=>t!==this.state.pendingMatchIds[e]))),(e||r)&&(this.state.matches=this.state.matchIds.map((t=>this.state.matchesById[t]))),(e||o)&&(this.state.pendingMatches=this.state.pendingMatchIds.map((t=>this.state.matchesById[t]))),this.state.isFetching=[...this.state.matches,...this.state.pendingMatches].some((t=>t.isFetching))},defaultPriority:"low"}),this.state=this.__store.state,this.update(t);const e=this.buildNext({hash:!0,fromCurrent:!0,search:!0,state:!0});this.state.location.href!==e.href&&this.#e({...e,replace:!0})}reset=()=>{this.__store.setState((t=>Object.assign(t,V())))};mount=()=>{this.safeLoad()};update=t=>{if(this.options={...this.options,...t,context:{...this.options.context,...t?.context}},!this.history||this.options.history&&this.options.history!==this.history){this.#t&&this.#t(),this.history=this.options.history??(Y?g():y());const t=this.#r();this.__store.setState((e=>({...e,resolvedLocation:t,location:t}))),this.#t=this.history.listen((()=>{this.safeLoad({next:this.#r(this.state.location)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${O(e??"")??""}`,r&&r!==this.routeTree&&this.#o(r),this};buildNext=t=>{const e=this.#s(t),r=this.matchRoutes(e.pathname,e.search);return this.#s({...t,__matches:r})};cancelMatches=()=>{this.state.matches.forEach((t=>{this.cancelMatch(t.id)}))};cancelMatch=t=>{this.getRouteMatch(t)?.abortController?.abort()};safeLoad=t=>this.load(t).catch((t=>{}));latestLoadPromise=Promise.resolve();load=async t=>{const e=new Promise((async(r,o)=>{let s;const n=()=>this.latestLoadPromise!==e?this.latestLoadPromise:void 0;let a;this.__store.batch((()=>{t?.next&&this.__store.setState((e=>({...e,location:t.next}))),a=this.matchRoutes(this.state.location.pathname,this.state.location.search,{throwOnError:t?.throwOnError,debug:!0}),this.__store.setState((t=>({...t,status:"pending",pendingMatchIds:a.map((t=>t.id)),matchesById:this.#n(t.matchesById,a)})))}));try{if(await this.loadMatches(a),s=n())return await s;const t=this.state.resolvedLocation;this.__store.setState((t=>({...t,status:"idle",resolvedLocation:t.location,matchIds:t.pendingMatchIds,pendingMatchIds:[]}))),t.href!==this.state.location.href&&this.options.onRouteChange?.(),r()}catch(t){if(s=n())return await s;o(t)}}));return this.latestLoadPromise=e,this.latestLoadPromise};#n=(t,e)=>{const r={...t};let o=!1;return e.forEach((t=>{r[t.id]||(o=!0,r[t.id]=t)})),o?r:t};getRoute=t=>{const e=this.routesById[t];return h(e),e};preloadRoute=async(t=this.state.location)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,e.search,{throwOnError:!0});return this.__store.setState((t=>({...t,matchesById:this.#n(t.matchesById,r)}))),await this.loadMatches(r,{preload:!0,maxAge:t.maxAge}),r};cleanMatches=()=>{const t=Date.now(),e=Object.values(this.state.matchesById).filter((e=>{const r=this.getRoute(e.routeId);return!this.state.matchIds.includes(e.id)&&!this.state.pendingMatchIds.includes(e.id)&&e.preloadInvalidAt<t&&(!r.options.gcMaxAge||e.updatedAt+r.options.gcMaxAge<t)})).map((t=>t.id));e.length&&this.__store.setState((t=>{const r={...t.matchesById};return e.forEach((t=>{delete r[t]})),{...t,matchesById:r}}))};matchRoutes=(t,e,r)=>{let o={},s=this.flatRoutes.find((e=>{const r=D(this.basepath,t,{to:e.fullPath,caseSensitive:e.options.caseSensitive??this.options.caseSensitive});return!!r&&(o=r,!0)}))||this.routesById.__root__,n=[s];for(;s?.parentRoute;)s=s.parentRoute,s&&n.unshift(s);let a={};const i=n.map((t=>{let s,n;try{s=t.options.parseParams?.(o)??o}catch(t){if(n=new X(t.message,{cause:t}),r?.throwOnError)throw n}Object.assign(a,s);const i=A(t.path,a),c=t.options.key?t.options.key({params:a,search:e})??"":"",h=c?JSON.stringify(c):"",u=A(t.id,a,!0)+h,l=this.getRouteMatch(u);if(l)return{...l};const d=!(!t.options.loader&&!K.some((e=>t.options[e]?.preload)));return{id:u,key:h,routeId:t.id,params:a,pathname:P([this.basepath,i]),updatedAt:Date.now(),invalidAt:1/0,preloadInvalidAt:1/0,routeSearch:{},search:{},status:d?"idle":"success",isFetching:!1,invalid:!1,error:void 0,paramsError:n,searchError:void 0,loaderData:void 0,loadPromise:Promise.resolve(),routeContext:void 0,context:void 0,abortController:new AbortController,fetchedAt:0}}));return i.forEach(((t,o)=>{const s=i[o-1],n=this.getRoute(t.routeId),a=(()=>{const o={search:s?.search??e,routeSearch:s?.routeSearch??e};try{const e=("object"==typeof n.options.validateSearch?n.options.validateSearch.parse:n.options.validateSearch)?.(o.search)??{},r={...o.search,...e};return{routeSearch:E(t.routeSearch,e),search:E(t.search,r)}}catch(e){if(t.searchError=new Q(e.message,{cause:e}),r?.throwOnError)throw t.searchError;return o}})(),c=(()=>{try{const e=n.options.getContext?.({parentContext:s?.routeContext??{},context:s?.context??this?.options.context??{},params:t.params,search:t.search})||{};return{context:{...s?.context??this?.options.context,...e},routeContext:e}}catch(t){throw n.options.onError?.(t),t}})();Object.assign(t,{...a,...c})})),i};loadMatches=async(t,e)=>{let r;this.cleanMatches();try{await Promise.all(t.map((async(t,o)=>{const s=this.getRoute(t.routeId);e?.preload||this.setRouteMatch(t.id,(e=>({...e,routeSearch:t.routeSearch,search:t.search,routeContext:t.routeContext,context:t.context,error:t.error,paramsError:t.paramsError,searchError:t.searchError,params:t.params})));const n=(e,n)=>{if(r=r??o,n=n||s.options.onError,G(e))throw e;try{n?.(e)}catch(t){if(e=t,G(t))throw t}this.setRouteMatch(t.id,(t=>({...t,error:e,status:"error",updatedAt:Date.now()})))};t.paramsError&&n(t.paramsError,s.options.onParseParamsError),t.searchError&&n(t.searchError,s.options.onValidateSearchError);try{await(s.options.beforeLoad?.({...t,preload:!!e?.preload}))}catch(t){n(t,s.options.onBeforeLoadError)}})))}catch(t){throw e?.preload||this.navigate(t),t}const o=t.slice(0,r),s=[];o.forEach(((t,r)=>{s.push((async()=>{const o=s[r-1],n=this.getRoute(t.routeId);if(t.isFetching||"success"===t.status&&!this.getIsInvalid({matchId:t.id,preload:e?.preload}))return this.getRouteMatch(t.id)?.loadPromise;const a=Date.now(),i=()=>{const e=this.getRouteMatch(t.id);return e&&e.fetchedAt!==a?e.loadPromise:void 0},c=(async()=>{let r;const s=Promise.all(K.map((async t=>{const e=n.options[t];e?.preload&&await e.preload()}))),a=n.options.loader?.({...t,preload:!!e?.preload,parentMatchPromise:o}),c=t=>!!G(t)&&(e?.preload||this.navigate(t),!0);try{const[o,n]=await Promise.all([s,a]);if(r=i())return await r;this.setRouteMatchData(t.id,(()=>n),e)}catch(e){if(r=i())return await r;if(c(e))return;const o=n.options.onLoadError??n.options.onError;let s=e;try{o?.(e)}catch(t){if(s=t,c(t))return}this.setRouteMatch(t.id,(t=>({...t,error:s,status:"error",isFetching:!1,updatedAt:Date.now()})))}})();this.setRouteMatch(t.id,(t=>({...t,status:"success"!==t.status?"pending":t.status,isFetching:!0,loadPromise:c,fetchedAt:a,invalid:!1}))),await c})())})),await Promise.all(s)};reload=()=>this.navigate({fromCurrent:!0,replace:!0,search:!0});resolvePath=(t,e)=>j(this.basepath,t,C(e));navigate=async({from:t,to:e="",search:r,hash:o,replace:s,params:n})=>{const a=String(e),i=void 0===t?t:String(t);let c;try{new URL(`${a}`),c=!0}catch(t){}return h(!c),this.#e({from:i,to:a,search:r,hash:o,replace:s,params:n})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t);if(e?.pending&&"pending"!==this.state.status)return!1;const o=e?.pending?this.state.location:this.state.resolvedLocation;if(!o)return!1;const s=D(this.basepath,o.pathname,{...e,to:r.pathname});return!!s&&(e?.includeSearch??1?!!_(o.search,r.search)&&s:s)};buildLink=({from:t,to:e=".",search:r,params:o,hash:s,target:n,replace:a,activeOptions:i,preload:c,preloadDelay:h,disabled:u})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const l={from:t,to:e,search:r,params:o,hash:s,replace:a},d=this.buildNext(l);c=c??this.options.defaultPreload;const p=h??this.options.defaultPreloadDelay??0,f=this.state.location.pathname.split("/"),m=d.pathname.split("/").every(((t,e)=>t===f[e])),y=i?.exact?this.state.location.pathname===d.pathname:m,g=!i?.includeHash||this.state.location.hash===d.hash,v=!(i?.includeSearch??1)||_(this.state.location.search,d.search);return{type:"internal",next:d,handleFocus:t=>{c&&this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{u||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||n&&"_self"!==n||0!==t.button||(t.preventDefault(),this.#e(l))},handleEnter:t=>{const e=t.target||{};if(c){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),p)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},isActive:y&&g&&v,disabled:u}};dehydrate=()=>({state:x(this.state,["location","status","lastUpdated"])});hydrate=async t=>{let e=t;"undefined"!=typeof document&&(e=window.__TSR_DEHYDRATED__),h(e);const r=e;this.dehydratedData=r.payload,this.options.hydrate?.(r.payload),this.__store.setState((t=>({...t,...r.router.state,resolvedLocation:r.router.state.location}))),await this.load()};injectedHtml=[];injectHtml=async t=>{this.injectedHtml.push(t)};dehydrateData=(t,e)=>{if("undefined"==typeof document){const r="string"==typeof t?t:JSON.stringify(t);return this.injectHtml((async()=>{const t=`__TSR_DEHYDRATED__${r}`,o="function"==typeof e?await e():e;return`<script id='${t}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${s=r,s.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"')}"] = ${JSON.stringify(o)}\n ;(() => {\n var el = document.getElementById('${t}')\n el.parentElement.removeChild(el)\n })()\n <\/script>`;var s})),()=>this.hydrateData(t)}return()=>{}};hydrateData=t=>{if("undefined"!=typeof document){const e="string"==typeof t?t:JSON.stringify(t);return window[`__TSR_DEHYDRATED__${e}`]}};#o=t=>{this.routeTree=t,this.routesById={},this.routesByPath={},this.flatRoutes=[];const e=t=>{t.forEach(((t,r)=>{t.init({originalIndex:r,router:this});if(h(!this.routesById[t.id],String(t.id)),this.routesById[t.id]=t,!t.isRoot&&t.path){const e=L(t.fullPath);this.routesByPath[e]&&!t.fullPath.endsWith("/")||(this.routesByPath[e]=t)}const o=t.children;o?.length&&e(o)}))};e([t]),this.flatRoutes=Object.values(this.routesByPath).map(((t,e)=>{const r=O(t.fullPath),o=k(r);for(;o.length>1&&"/"===o[0]?.value;)o.shift();const s=o.map((t=>"param"===t.type?.5:"wildcard"===t.type?.25:1));return{child:t,trimmed:r,parsed:o,index:e,score:s}})).sort(((t,e)=>{let r="/"===t.trimmed?1:"/"===e.trimmed?-1:0;if(0!==r)return r;const o=Math.min(t.score.length,e.score.length);if(t.score.length!==e.score.length)return e.score.length-t.score.length;for(let r=0;r<o;r++)if(t.score[r]!==e.score[r])return e.score[r]-t.score[r];for(let r=0;r<o;r++)if(t.parsed[r].value!==e.parsed[r].value)return t.parsed[r].value>e.parsed[r].value?1:-1;return t.trimmed!==e.trimmed?t.trimmed>e.trimmed?1:-1:t.index-e.index})).map(((t,e)=>(t.child.rank=e,t.child)))};#r=t=>{let{pathname:e,search:r,hash:o,state:s}=this.history.location;const n=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:E(t?.search,n),hash:o.split("#").reverse()[0]??"",href:`${e}${r}${o}`,state:s,key:s?.key||"__init__"}};#s=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.location.pathname:t.from??this.state.location.pathname;let r=j(this.basepath??"/",e,`${t.to??""}`);const o={...b(this.matchRoutes(this.state.location.pathname,this.state.location.search))?.params};let s=!0===(t.params??!0)?o:S(t.params,o);s&&t.__matches?.map((t=>this.getRoute(t.routeId).options.stringifyParams)).filter(Boolean).forEach((t=>{s={...s,...t(s)}})),r=A(r,s??{});const n=t.__matches?.map((t=>this.getRoute(t.routeId).options.preSearchFilters??[])).flat().filter(Boolean)??[],a=t.__matches?.map((t=>this.getRoute(t.routeId).options.postSearchFilters??[])).flat().filter(Boolean)??[],i=n?.length?n?.reduce(((t,e)=>e(t)),this.state.location.search):this.state.location.search,c=!0===t.search?i:t.search?S(t.search,i)??{}:n?.length?i:{},h=a?.length?a.reduce(((t,e)=>e(t)),c):c,u=E(this.state.location.search,h),l=this.options.stringifySearch(u),d=!0===t.hash?this.state.location.hash:S(t.hash,this.state.location.hash),p=d?`#${d}`:"";return{pathname:r,search:u,searchStr:l,state:!0===t.state?this.state.location.state:S(t.state,this.state.location.state),hash:d,href:this.history.createHref(`${r}${l}${p}`),key:t.key}};#e=async t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let o="replace";t.replace||(o="push");this.state.location.href===e.href&&!e.key&&(o="replace");const s=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===o?"push":"replace"](s,{id:r,...e.state}),this.latestLoadPromise};getRouteMatch=t=>this.state.matchesById[t];setRouteMatch=(t,e)=>{this.__store.setState((r=>({...r,matchesById:{...r.matchesById,[t]:e(r.matchesById[t])}})))};setRouteMatchData=(t,e,r)=>{const o=this.getRouteMatch(t);if(!o)return;const s=this.getRoute(o.routeId),n=r?.updatedAt??Date.now(),a=n+(r?.maxAge??s.options.preloadMaxAge??this.options.defaultPreloadMaxAge??5e3),i=n+(r?.maxAge??s.options.maxAge??this.options.defaultMaxAge??1/0);this.setRouteMatch(t,(t=>({...t,error:void 0,status:"success",isFetching:!1,updatedAt:Date.now(),loaderData:S(e,t.loaderData),preloadInvalidAt:a,invalidAt:i}))),this.state.matches.find((e=>e.id===t))};invalidate=async t=>{if(t?.matchId){this.setRouteMatch(t.matchId,(t=>({...t,invalid:!0})));const e=this.state.matches.findIndex((e=>e.id===t.matchId)),r=this.state.matches[e+1];if(r)return this.invalidate({matchId:r.id,reload:!1})}else this.__store.batch((()=>{Object.values(this.state.matchesById).forEach((t=>{this.setRouteMatch(t.id,(t=>({...t,invalid:!0})))}))}));if(t?.reload??1)return this.reload()};getIsInvalid=t=>{if(!t?.matchId)return!!this.state.matches.find((e=>this.getIsInvalid({matchId:e.id,preload:t?.preload})));const e=this.getRouteMatch(t?.matchId);if(!e)return!1;const r=Date.now();return e.invalid||(t?.preload?e.preloadInvalidAt:e.invalidAt)<r}},t.RouterContext=class{constructor(){}createRootRoute=t=>new U(t)},t.RouterProvider=function({router:t,...e}){t.update(e),s.useEffect((()=>{let e;return s.startTransition((()=>{e=t.mount()})),e}),[t]);const r=t.options.Wrap||s.Fragment;return s.createElement(s.Suspense,{fallback:null},s.createElement(r,null,s.createElement(rt.Provider,{value:t},s.createElement(st,null))))},t.SearchParamError=Q,t.cleanPath=C,t.componentTypes=K,t.createBrowserHistory=y,t.createHashHistory=function(){return y({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=g,t.decode=H,t.defaultParseSearch=z,t.defaultStringifySearch=W,t.encode=$,t.functionalUpdate=S,t.interpolatePath=A,t.invariant=h,t.isPlainObject=R,t.isRedirect=G,t.joinPaths=P,t.last=b,t.lazyFn=function(t,e){return async(...r)=>(await t())[e||"default"](...r)},t.lazyRouteComponent=function(t,e){let r;const o=()=>(r||(r=t()),r),n=s.lazy((async()=>({default:(await o())[e??"default"]})));return n.preload=o,n},t.matchByPath=B,t.matchIdsContext=et,t.matchPathname=D,t.parsePathname=k,t.parseSearchWith=J,t.partialDeepEqual=_,t.pick=x,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=E,t.resolvePath=j,t.rootRouteId=F,t.routerContext=rt,t.shallow=function(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(e,r[o])||!Object.is(t[r[o]],e[r[o]]))return!1;return!0},t.stringifySearchWith=q,t.trimPath=O,t.trimPathLeft=M,t.trimPathRight=L,t.useBlocker=wt,t.useDehydrate=function(){const t=nt();return s.useCallback((function(e,r){return t.dehydrateData(e,r)}),[])},t.useHydrate=function(){const t=nt();return function(e){return t.hydrateData(e)}},t.useInjectHtml=function(){const t=nt();return s.useCallback((e=>{t.injectHtml(e)}),[])},t.useLinkProps=Z,t.useLoader=it,t.useMatch=at,t.useMatchRoute=ut,t.useMatches=function(t){const e=s.useContext(et);return ot({select:r=>{const o=r.matches.slice(r.matches.findIndex((t=>t.id===e[0])));return t?.select?.(o)??o}})},t.useNavigate=function(t){const e=nt();return s.useCallback((r=>e.navigate({...t,...r})),[])},t.useParams=ht,t.useRouteContext=function(t){return at({...t,select:e=>t?.select?.(e.routeContext)??e.routeContext})},t.useRouter=nt,t.useRouterContext=function(t){return at({...t,select:e=>t?.select?.(e.context)??e.context})},t.useRouterState=ot,t.useSearch=ct,t.useStore=i,t.warning=function(t,e){},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=index.production.js.map
{
"name": "@tanstack/react-router",
"author": "Tanner Linsley",
"version": "0.0.1-beta.83",
"version": "0.0.1-beta.145",
"license": "MIT",
"repository": "tanstack/router",
"homepage": "https://tanstack.com/router/",
"homepage": "https://tanstack.com/router",
"description": "",

@@ -15,3 +15,2 @@ "publishConfig": {

"location",
"@tanstack/react-router",
"router",

@@ -45,8 +44,11 @@ "routing",

"@babel/runtime": "^7.16.7",
"@tanstack/router": "0.0.1-beta.83",
"@tanstack/react-store": "0.0.1-beta.81"
"tiny-invariant": "^1.3.1",
"tiny-warning": "^1.0.3",
"@gisatcz/cross-package-react-context": "^0.2.0",
"@tanstack/router-core": "0.0.1-beta.145",
"@tanstack/react-store": "0.0.1-beta.134"
},
"devDependencies": {
"babel-plugin-transform-async-to-promises": "^0.8.18"
"scripts": {
"build": "rollup --config rollup.config.js"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc