Socket
Socket
Sign inDemoInstall

@tanstack/router

Package Overview
Dependencies
Maintainers
2
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/router - npm Package Compare versions

Comparing version 0.0.1-beta.109 to 0.0.1-beta.110

8

build/cjs/react.js

@@ -347,4 +347,4 @@ /**

const router = useRouterContext();
return React__namespace.useCallback(getHtml => {
router.injectHtml(getHtml);
return React__namespace.useCallback(html => {
router.injectHtml(html);
}, []);

@@ -354,4 +354,4 @@ }

const router = useRouterContext();
return React__namespace.useCallback(function dehydrate(key, getData) {
return router.dehydrateData(key, getData);
return React__namespace.useCallback(function dehydrate(key, data) {
return router.dehydrateData(key, data);
}, []);

@@ -358,0 +358,0 @@ }

@@ -22,4 +22,2 @@ /**

abortController = new AbortController();
__promiseKeys = [];
__promisesByKey = {};
constructor(router, route, opts) {

@@ -203,40 +201,45 @@ Object.assign(this, {

if (latestPromise = checkLatest()) return await latestPromise;
Object.keys(loader ?? {}).forEach(key => {
const value = loader[key];
if (value instanceof Promise || value?.then) {
// if (this.__promisesByKey[key]) {
// return
// }
if (typeof document === 'undefined') {
this.__promisesByKey[key] = {
status: 'pending',
promise: value,
data: undefined,
resolve: () => {}
};
value.then(d => {
this.__promisesByKey[key].status = 'resolved';
this.__promisesByKey[key].data = d;
});
} else {
const promise = createPromise();
this.__promisesByKey[key] = {
status: 'pending',
promise,
data: undefined,
resolve: d => {
// @ts-ignore
promise.resolve();
this.__promisesByKey[key].status = 'resolved';
this.__promisesByKey[key].data = d;
}
};
if (!this.__promiseKeys.includes(key)) {
value.then(this.__promisesByKey[key].resolve);
}
}
loader[key] = this.__promisesByKey[key];
}
});
// Object.keys(loader ?? {}).forEach((key) => {
// const value = loader[key]
// if (value instanceof Promise || value?.then) {
// // if (this.__promisesByKey[key]) {
// // return
// // }
// if (typeof document === 'undefined') {
// this.__promisesByKey[key] = {
// status: 'pending',
// promise: value,
// data: undefined,
// resolve: () => {},
// }
// value.then((d: any) => {
// this.__promisesByKey[key]!.status = 'resolved'
// this.__promisesByKey[key]!.data = d
// })
// } else {
// const promise = createPromise()
// this.__promisesByKey[key] = {
// status: 'pending',
// promise,
// data: undefined,
// resolve: (d: any) => {
// // @ts-ignore
// promise.resolve()
// this.__promisesByKey[key]!.status = 'resolved'
// this.__promisesByKey[key]!.data = d
// },
// }
// if (!this.__promiseKeys.includes(key)) {
// value.then(this.__promisesByKey[key]!.resolve)
// }
// }
// loader[key] = this.__promisesByKey[key]
// }
// })
this.__store.setState(s => ({

@@ -289,14 +292,4 @@ ...s,

}
function createPromise() {
let resolve;
const promise = new Promise(r => {
resolve = r;
});
promise.resolve = d => {
resolve(d);
};
return promise;
}
exports.RouteMatch = RouteMatch;
//# sourceMappingURL=routeMatch.js.map

@@ -81,2 +81,5 @@ /**

}
if (typeof document !== 'undefined') {
this.hydrate();
}
}

@@ -636,10 +639,11 @@ reset = () => {

state: {
...utils.pick(this.state, ['location', 'status', 'lastUpdated']),
matches: this.state.matches.map(m => ({
id: m.id,
promiseKeys: Object.keys(m.__promisesByKey)
}))
...utils.pick(this.state, ['location', 'status', 'lastUpdated'])
// matches: this.state.matches.map((m) => ({
// id: m.id,
// promiseKeys: Object.keys(m.__promisesByKey),
// })),
}
};
};
hydrate = async __do_not_use_server_ctx => {

@@ -651,3 +655,3 @@ let _ctx = __do_not_use_server_ctx;

}
invariant__default["default"](_ctx, 'Expected to find a __TSR_DEHYDRATED__ property on window... but we did not. Did you forget to render <RouterScripts /> in your app?');
invariant__default["default"](_ctx, 'Expected to find a __TSR_DEHYDRATED__ property on window... but we did not. Did you forget to render <DehydrateRouter /> in your app?');
const ctx = _ctx;

@@ -664,10 +668,13 @@ this.options.hydrate?.(ctx.payload);

await this.load();
this.state.matches.forEach(m => {
m.__promiseKeys = ctx.router.state.matches.find(d => d.id === m.id)?.promiseKeys ?? [];
});
// this.state.matches.forEach((m) => {
// m.__promiseKeys =
// ctx.router.state.matches.find((d) => d.id === m.id)?.promiseKeys ?? []
// })
return;
};
injectedHtml = [];
injectHtml = async getHtml => {
this.injectedHtml.push(getHtml);
injectHtml = async html => {
this.injectedHtml.push(html);
};

@@ -678,3 +685,3 @@ dehydrateData = (key, getData) => {

this.injectHtml(async () => {
const data = await getData();
const data = typeof getData === 'function' ? await getData() : getData;
return `<script>window["__TSR__DEHYRATED__${escapeJSON(strKey)}"] = ${JSON.stringify(data)}</script>`;

@@ -693,5 +700,9 @@ });

};
resolveMatchPromise = (matchId, key, value) => {
this.state.matches.find(d => d.id === matchId)?.__promisesByKey[key]?.resolve(value);
};
// resolveMatchPromise = (matchId: string, key: string, value: any) => {
// this.state.matches
// .find((d) => d.id === matchId)
// ?.__promisesByKey[key]?.resolve(value)
// }
#buildRouteTree = routeTree => {

@@ -698,0 +709,0 @@ const recurseRoutes = (routes, parentRoute) => {

@@ -14,7 +14,7 @@ {

"name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"uid": "deaa-49"
"uid": "98e0-49"
},
{
"name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
"uid": "deaa-51"
"uid": "98e0-51"
}

@@ -30,39 +30,39 @@ ]

{
"uid": "deaa-53",
"uid": "98e0-53",
"name": "history.ts"
},
{
"uid": "deaa-55",
"uid": "98e0-55",
"name": "utils.ts"
},
{
"uid": "deaa-57",
"uid": "98e0-57",
"name": "path.ts"
},
{
"uid": "deaa-59",
"uid": "98e0-59",
"name": "qss.ts"
},
{
"uid": "deaa-67",
"uid": "98e0-67",
"name": "react.tsx"
},
{
"uid": "deaa-69",
"uid": "98e0-69",
"name": "route.ts"
},
{
"uid": "deaa-71",
"uid": "98e0-71",
"name": "searchParams.ts"
},
{
"uid": "deaa-73",
"uid": "98e0-73",
"name": "router.ts"
},
{
"uid": "deaa-75",
"uid": "98e0-75",
"name": "routeMatch.ts"
},
{
"uid": "deaa-77",
"uid": "98e0-77",
"name": "index.ts"

@@ -74,7 +74,7 @@ }

"name": "store/build/esm/index.js",
"uid": "deaa-63"
"uid": "98e0-63"
},
{
"name": "react-store/build/esm/index.js",
"uid": "deaa-65"
"uid": "98e0-65"
}

@@ -84,3 +84,3 @@ ]

{
"uid": "deaa-61",
"uid": "98e0-61",
"name": "\u0000rollupPluginBabelHelpers.js"

@@ -94,98 +94,98 @@ }

"nodeParts": {
"deaa-49": {
"98e0-49": {
"renderedLength": 199,
"gzipLength": 134,
"brotliLength": 0,
"mainUid": "deaa-48"
"mainUid": "98e0-48"
},
"deaa-51": {
"98e0-51": {
"renderedLength": 48,
"gzipLength": 65,
"brotliLength": 0,
"mainUid": "deaa-50"
"mainUid": "98e0-50"
},
"deaa-53": {
"98e0-53": {
"renderedLength": 5643,
"gzipLength": 1404,
"brotliLength": 0,
"mainUid": "deaa-52"
"mainUid": "98e0-52"
},
"deaa-55": {
"98e0-55": {
"renderedLength": 2821,
"gzipLength": 990,
"brotliLength": 0,
"mainUid": "deaa-54"
"mainUid": "98e0-54"
},
"deaa-57": {
"98e0-57": {
"renderedLength": 6028,
"gzipLength": 1423,
"brotliLength": 0,
"mainUid": "deaa-56"
"mainUid": "98e0-56"
},
"deaa-59": {
"98e0-59": {
"renderedLength": 1395,
"gzipLength": 558,
"brotliLength": 0,
"mainUid": "deaa-58"
"mainUid": "98e0-58"
},
"deaa-61": {
"98e0-61": {
"renderedLength": 457,
"gzipLength": 241,
"brotliLength": 0,
"mainUid": "deaa-60"
"mainUid": "98e0-60"
},
"deaa-63": {
"98e0-63": {
"renderedLength": 1459,
"gzipLength": 543,
"brotliLength": 0,
"mainUid": "deaa-62"
"mainUid": "98e0-62"
},
"deaa-65": {
"98e0-65": {
"renderedLength": 1066,
"gzipLength": 481,
"brotliLength": 0,
"mainUid": "deaa-64"
"mainUid": "98e0-64"
},
"deaa-67": {
"renderedLength": 14239,
"gzipLength": 3362,
"98e0-67": {
"renderedLength": 14227,
"gzipLength": 3360,
"brotliLength": 0,
"mainUid": "deaa-66"
"mainUid": "98e0-66"
},
"deaa-69": {
"98e0-69": {
"renderedLength": 3556,
"gzipLength": 903,
"brotliLength": 0,
"mainUid": "deaa-68"
"mainUid": "98e0-68"
},
"deaa-71": {
"98e0-71": {
"renderedLength": 1387,
"gzipLength": 483,
"brotliLength": 0,
"mainUid": "deaa-70"
"mainUid": "98e0-70"
},
"deaa-73": {
"renderedLength": 31040,
"gzipLength": 7666,
"98e0-73": {
"renderedLength": 31263,
"gzipLength": 7732,
"brotliLength": 0,
"mainUid": "deaa-72"
"mainUid": "98e0-72"
},
"deaa-75": {
"renderedLength": 8991,
"gzipLength": 1978,
"98e0-75": {
"renderedLength": 8853,
"gzipLength": 1927,
"brotliLength": 0,
"mainUid": "deaa-74"
"mainUid": "98e0-74"
},
"deaa-77": {
"98e0-77": {
"renderedLength": 0,
"gzipLength": 0,
"brotliLength": 0,
"mainUid": "deaa-76"
"mainUid": "98e0-76"
}
},
"nodeMetas": {
"deaa-48": {
"98e0-48": {
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"moduleParts": {
"index.production.js": "deaa-49"
"index.production.js": "98e0-49"
},

@@ -195,19 +195,19 @@ "imported": [],

{
"uid": "deaa-76"
"uid": "98e0-76"
},
{
"uid": "deaa-68"
"uid": "98e0-68"
},
{
"uid": "deaa-72"
"uid": "98e0-72"
},
{
"uid": "deaa-66"
"uid": "98e0-66"
}
]
},
"deaa-50": {
"98e0-50": {
"id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
"moduleParts": {
"index.production.js": "deaa-51"
"index.production.js": "98e0-51"
},

@@ -217,13 +217,13 @@ "imported": [],

{
"uid": "deaa-76"
"uid": "98e0-76"
},
{
"uid": "deaa-66"
"uid": "98e0-66"
}
]
},
"deaa-52": {
"98e0-52": {
"id": "/packages/router/src/history.ts",
"moduleParts": {
"index.production.js": "deaa-53"
"index.production.js": "98e0-53"
},

@@ -233,13 +233,13 @@ "imported": [],

{
"uid": "deaa-76"
"uid": "98e0-76"
},
{
"uid": "deaa-72"
"uid": "98e0-72"
}
]
},
"deaa-54": {
"98e0-54": {
"id": "/packages/router/src/utils.ts",
"moduleParts": {
"index.production.js": "deaa-55"
"index.production.js": "98e0-55"
},

@@ -249,26 +249,26 @@ "imported": [],

{
"uid": "deaa-76"
"uid": "98e0-76"
},
{
"uid": "deaa-56"
"uid": "98e0-56"
},
{
"uid": "deaa-74"
"uid": "98e0-74"
},
{
"uid": "deaa-72"
"uid": "98e0-72"
},
{
"uid": "deaa-66"
"uid": "98e0-66"
}
]
},
"deaa-56": {
"98e0-56": {
"id": "/packages/router/src/path.ts",
"moduleParts": {
"index.production.js": "deaa-57"
"index.production.js": "98e0-57"
},
"imported": [
{
"uid": "deaa-54"
"uid": "98e0-54"
}

@@ -278,16 +278,16 @@ ],

{
"uid": "deaa-76"
"uid": "98e0-76"
},
{
"uid": "deaa-68"
"uid": "98e0-68"
},
{
"uid": "deaa-72"
"uid": "98e0-72"
}
]
},
"deaa-58": {
"98e0-58": {
"id": "/packages/router/src/qss.ts",
"moduleParts": {
"index.production.js": "deaa-59"
"index.production.js": "98e0-59"
},

@@ -297,13 +297,13 @@ "imported": [],

{
"uid": "deaa-76"
"uid": "98e0-76"
},
{
"uid": "deaa-70"
"uid": "98e0-70"
}
]
},
"deaa-60": {
"98e0-60": {
"id": "\u0000rollupPluginBabelHelpers.js",
"moduleParts": {
"index.production.js": "deaa-61"
"index.production.js": "98e0-61"
},

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

{
"uid": "deaa-66"
"uid": "98e0-66"
}
]
},
"deaa-62": {
"98e0-62": {
"id": "/packages/store/build/esm/index.js",
"moduleParts": {
"index.production.js": "deaa-63"
"index.production.js": "98e0-63"
},

@@ -326,17 +326,17 @@ "imported": [],

{
"uid": "deaa-64"
"uid": "98e0-64"
}
]
},
"deaa-64": {
"98e0-64": {
"id": "/packages/react-store/build/esm/index.js",
"moduleParts": {
"index.production.js": "deaa-65"
"index.production.js": "98e0-65"
},
"imported": [
{
"uid": "deaa-81"
"uid": "98e0-81"
},
{
"uid": "deaa-62"
"uid": "98e0-62"
}

@@ -346,35 +346,35 @@ ],

{
"uid": "deaa-74"
"uid": "98e0-74"
},
{
"uid": "deaa-72"
"uid": "98e0-72"
},
{
"uid": "deaa-66"
"uid": "98e0-66"
}
]
},
"deaa-66": {
"98e0-66": {
"id": "/packages/router/src/react.tsx",
"moduleParts": {
"index.production.js": "deaa-67"
"index.production.js": "98e0-67"
},
"imported": [
{
"uid": "deaa-60"
"uid": "98e0-60"
},
{
"uid": "deaa-80"
"uid": "98e0-80"
},
{
"uid": "deaa-64"
"uid": "98e0-64"
},
{
"uid": "deaa-48"
"uid": "98e0-48"
},
{
"uid": "deaa-50"
"uid": "98e0-50"
},
{
"uid": "deaa-54"
"uid": "98e0-54"
}

@@ -384,23 +384,23 @@ ],

{
"uid": "deaa-76"
"uid": "98e0-76"
},
{
"uid": "deaa-68"
"uid": "98e0-68"
}
]
},
"deaa-68": {
"98e0-68": {
"id": "/packages/router/src/route.ts",
"moduleParts": {
"index.production.js": "deaa-69"
"index.production.js": "98e0-69"
},
"imported": [
{
"uid": "deaa-48"
"uid": "98e0-48"
},
{
"uid": "deaa-56"
"uid": "98e0-56"
},
{
"uid": "deaa-66"
"uid": "98e0-66"
}

@@ -410,14 +410,14 @@ ],

{
"uid": "deaa-76"
"uid": "98e0-76"
}
]
},
"deaa-70": {
"98e0-70": {
"id": "/packages/router/src/searchParams.ts",
"moduleParts": {
"index.production.js": "deaa-71"
"index.production.js": "98e0-71"
},
"imported": [
{
"uid": "deaa-58"
"uid": "98e0-58"
}

@@ -427,35 +427,35 @@ ],

{
"uid": "deaa-76"
"uid": "98e0-76"
},
{
"uid": "deaa-72"
"uid": "98e0-72"
}
]
},
"deaa-72": {
"98e0-72": {
"id": "/packages/router/src/router.ts",
"moduleParts": {
"index.production.js": "deaa-73"
"index.production.js": "98e0-73"
},
"imported": [
{
"uid": "deaa-64"
"uid": "98e0-64"
},
{
"uid": "deaa-48"
"uid": "98e0-48"
},
{
"uid": "deaa-56"
"uid": "98e0-56"
},
{
"uid": "deaa-74"
"uid": "98e0-74"
},
{
"uid": "deaa-70"
"uid": "98e0-70"
},
{
"uid": "deaa-54"
"uid": "98e0-54"
},
{
"uid": "deaa-52"
"uid": "98e0-52"
}

@@ -465,23 +465,23 @@ ],

{
"uid": "deaa-76"
"uid": "98e0-76"
},
{
"uid": "deaa-74"
"uid": "98e0-74"
}
]
},
"deaa-74": {
"98e0-74": {
"id": "/packages/router/src/routeMatch.ts",
"moduleParts": {
"index.production.js": "deaa-75"
"index.production.js": "98e0-75"
},
"imported": [
{
"uid": "deaa-64"
"uid": "98e0-64"
},
{
"uid": "deaa-72"
"uid": "98e0-72"
},
{
"uid": "deaa-54"
"uid": "98e0-54"
}

@@ -491,53 +491,53 @@ ],

{
"uid": "deaa-76"
"uid": "98e0-76"
},
{
"uid": "deaa-72"
"uid": "98e0-72"
}
]
},
"deaa-76": {
"98e0-76": {
"id": "/packages/router/src/index.ts",
"moduleParts": {
"index.production.js": "deaa-77"
"index.production.js": "98e0-77"
},
"imported": [
{
"uid": "deaa-48"
"uid": "98e0-48"
},
{
"uid": "deaa-50"
"uid": "98e0-50"
},
{
"uid": "deaa-52"
"uid": "98e0-52"
},
{
"uid": "deaa-78"
"uid": "98e0-78"
},
{
"uid": "deaa-56"
"uid": "98e0-56"
},
{
"uid": "deaa-58"
"uid": "98e0-58"
},
{
"uid": "deaa-68"
"uid": "98e0-68"
},
{
"uid": "deaa-79"
"uid": "98e0-79"
},
{
"uid": "deaa-74"
"uid": "98e0-74"
},
{
"uid": "deaa-72"
"uid": "98e0-72"
},
{
"uid": "deaa-70"
"uid": "98e0-70"
},
{
"uid": "deaa-54"
"uid": "98e0-54"
},
{
"uid": "deaa-66"
"uid": "98e0-66"
}

@@ -548,3 +548,3 @@ ],

},
"deaa-78": {
"98e0-78": {
"id": "/packages/router/src/link.ts",

@@ -555,7 +555,7 @@ "moduleParts": {},

{
"uid": "deaa-76"
"uid": "98e0-76"
}
]
},
"deaa-79": {
"98e0-79": {
"id": "/packages/router/src/routeInfo.ts",

@@ -566,7 +566,7 @@ "moduleParts": {},

{
"uid": "deaa-76"
"uid": "98e0-76"
}
]
},
"deaa-80": {
"98e0-80": {
"id": "react",

@@ -577,3 +577,3 @@ "moduleParts": {},

{
"uid": "deaa-66"
"uid": "98e0-66"
}

@@ -583,3 +583,3 @@ ],

},
"deaa-81": {
"98e0-81": {
"id": "use-sync-external-store/shim/with-selector",

@@ -590,3 +590,3 @@ "moduleParts": {},

{
"uid": "deaa-64"
"uid": "98e0-64"
}

@@ -593,0 +593,0 @@ ],

@@ -82,4 +82,4 @@ import * as React from 'react';

export declare function Outlet(): JSX.Element | null;
export declare function useInjectHtml(): (getHtml: () => Promise<string> | string) => void;
export declare function useDehydrate(): <T>(key: any, getData: () => T | Promise<T>) => () => T | undefined;
export declare function useInjectHtml(): (html: string | (() => Promise<string> | string)) => void;
export declare function useDehydrate(): <T>(key: any, data: T | (() => T | Promise<T>)) => () => T | undefined;
export declare function useHydrate(): <T = unknown>(key: any) => T;

@@ -86,0 +86,0 @@ export declare function ErrorComponent({ error }: {

@@ -144,5 +144,6 @@ import { ParsePathParams } from './link';

type MergeFromParent<T, U> = IsAny<T, U, T & U>;
export type UseLoaderResult<T> = {
[K in keyof T]: T[K] extends Promise<infer U> ? StreamedPromise<U> : T[K];
};
export type UseLoaderResult<T> = T extends Record<PropertyKey, infer U> ? {
[K in keyof T]: UseLoaderResultPromise<T[K]>;
} : UseLoaderResultPromise<T>;
export type UseLoaderResultPromise<T> = T extends Promise<infer U> ? StreamedPromise<U> : T;
export type StreamedPromise<T> = {

@@ -149,0 +150,0 @@ promise: Promise<T>;

import { Store } from '@tanstack/react-store';
import { RouteComponent } from './react';
import { AnyRoute, Route, StreamedPromise } from './route';
import { AnyRoute, Route } from './route';
import { AnyRoutesInfo, DefaultRoutesInfo } from './routeInfo';

@@ -49,4 +49,2 @@ import { AnyRouter, ParsedLocation, Router } from './router';

pendingInfo?: PendingRouteMatchInfo;
__promiseKeys: string[];
__promisesByKey: Record<string, StreamedPromise<any>>;
__loadPromise?: Promise<void>;

@@ -53,0 +51,0 @@ __loadPromiseResolve?: () => void;

@@ -125,3 +125,2 @@ /// <reference types="react" />

export interface DehydratedRouterState extends Pick<RouterState, 'status' | 'location' | 'lastUpdated'> {
matches: DehydratedRouteMatch[];
}

@@ -132,6 +131,2 @@ export interface DehydratedRouter {

export type MatchCache = Record<string, MatchCacheEntry>;
interface DehydratedRouteMatch {
id: string;
promiseKeys: string[];
}
export declare const defaultFetchServerDataFn: FetchServerDataFn;

@@ -187,7 +182,6 @@ export type RouterConstructorOptions<TRouteTree extends AnyRoute, TDehydrated extends Record<string, any>> = Omit<RouterOptions<TRouteTree, TDehydrated>, 'context'> & RouterContextOptions<TRouteTree>;

hydrate: (__do_not_use_server_ctx?: HydrationCtx) => Promise<void>;
injectedHtml: (() => Promise<string> | string)[];
injectHtml: (getHtml: () => Promise<string> | string) => Promise<void>;
dehydrateData: <T>(key: any, getData: () => T | Promise<T>) => () => T | undefined;
injectedHtml: (string | (() => Promise<string> | string))[];
injectHtml: (html: string | (() => Promise<string> | string)) => Promise<void>;
dehydrateData: <T>(key: any, getData: T | (() => T | Promise<T>)) => () => T | undefined;
hydrateData: <T = unknown>(key: any) => T | undefined;
resolveMatchPromise: (matchId: string, key: string, value: any) => void;
}

@@ -194,0 +188,0 @@ export type AnyRedirect = Redirect<any, any, any>;

@@ -11,3 +11,3 @@ /**

*/
!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).RouterCore={},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 a(t,e){if(!t)throw new Error("Invariant failed")}function n(t,e){}const i="popstate",c="beforeunload",h=t=>(t.preventDefault(),t.returnValue=""),u=()=>{removeEventListener(c,h,{capture:!0})};function l(t){let e=t.getLocation(),r=()=>{},o=new Set,s=[],a=[];const n=()=>{if(s.length)s[0]?.(n,(()=>{s=[],u()}));else{for(;a.length;)a.shift()?.();l()}},i=t=>{a.push(t),n()},l=()=>{e=t.getLocation(),o.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===o.size&&(r=t.listener(l)),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(c,h,{capture:!0}),()=>{s=s.filter((e=>e!==t)),s.length||u()})}}function d(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),r=t?.createHref??(t=>t);return l({getLocation:()=>f(e(),history.state),listener:t=>(window.addEventListener(i,t),()=>{window.removeEventListener(i,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:m()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:m()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t)})}function p(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,o={};return l({getLocation:()=>f(e[r],o),listener:()=>()=>{},pushState:(t,s)=>{o={...s,key:m()},e.push(t),r++},replaceState:(t,s)=>{o={...s,key:m()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function f(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 m(){return(Math.random()+1).toString(36).substring(7)}function y(t){return t[t.length-1]}function g(t,e){return"function"==typeof t?t(e):t}function v(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||w(t)&&w(r)){const e=o?t.length:Object.keys(t).length,s=o?r:Object.keys(r),a=s.length,n=o?[]:{};let i=0;for(let e=0;e<a;e++){const a=o?e:s[e];n[a]=_(t[a],r[a]),n[a]===t[a]&&i++}return e===a&&i===e?t:n}return r}function w(t){if(!b(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!b(r)&&!!r.hasOwnProperty("isPrototypeOf")}function b(t){return"[object Object]"===Object.prototype.toString.call(t)}function S(t,e){return t===e||typeof t==typeof e&&(w(t)&&w(e)?!Object.keys(e).some((r=>!S(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>S(t,e[r])))))}function E(t){return P(t.filter(Boolean).join("/"))}function P(t){return t.replace(/\/{2,}/g,"/")}function x(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function R(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function C(t){return R(x(t))}function k(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let o=L(e);const s=L(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&&"/"===y(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return P(E([t,...o.map((t=>t.value))]))}function L(t){if(!t)return[];const e=[];if("/"===(t=P(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 j(t,e,r=!1){return E(L(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 O(t,e,r){const o=D(t,e,r);if(!r.to||o)return o??{}}function D(t,e,r){e="/"!=t?e.substring(t.length):e;const o=`${r.to??"$"}`,s=L(e),a=L(o);e.startsWith("/")||s.unshift({type:"pathname",value:"/"}),o.startsWith("/")||a.unshift({type:"pathname",value:"/"});const n={};return(()=>{for(let t=0;t<Math.max(s.length,a.length);t++){const e=s[t],o=a[t],i=t>=s.length-1,c=t>=a.length-1;if(o){if("wildcard"===o.type)return!!e?.value&&(n["*"]=E(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)&&(n[o.value.substring(1)]=e.value)}}if(!i&&c)return!!r.fuzzy}return!0})()?n:void 0}function M(t,e){var r,o,s,a="";for(r in t)if(void 0!==(s=t[r]))if(Array.isArray(s))for(o=0;o<s.length;o++)a&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(s[o]);else a&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(s);return(e||"")+a}function A(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function T(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],A(e.shift())):o[r]=A(e.shift());return o}function $(){return $=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},$.apply(this,arguments)}
!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).RouterCore={},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(t,e){if(!t)throw new Error("Invariant failed")}function n(t,e){}const i="popstate",c="beforeunload",h=t=>(t.preventDefault(),t.returnValue=""),u=()=>{removeEventListener(c,h,{capture:!0})};function l(t){let e=t.getLocation(),r=()=>{},o=new Set,a=[],s=[];const n=()=>{if(a.length)a[0]?.(n,(()=>{a=[],u()}));else{for(;s.length;)s.shift()?.();l()}},i=t=>{s.push(t),n()},l=()=>{e=t.getLocation(),o.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===o.size&&(r=t.listener(l)),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(c,h,{capture:!0}),()=>{a=a.filter((e=>e!==t)),a.length||u()})}}function d(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),r=t?.createHref??(t=>t);return l({getLocation:()=>f(e(),history.state),listener:t=>(window.addEventListener(i,t),()=>{window.removeEventListener(i,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:m()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:m()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t)})}function p(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,o={};return l({getLocation:()=>f(e[r],o),listener:()=>()=>{},pushState:(t,a)=>{o={...a,key:m()},e.push(t),r++},replaceState:(t,a)=>{o={...a,key:m()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function f(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 m(){return(Math.random()+1).toString(36).substring(7)}function y(t){return t[t.length-1]}function g(t,e){return"function"==typeof t?t(e):t}function v(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||w(t)&&w(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 w(t){if(!S(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!S(r)&&!!r.hasOwnProperty("isPrototypeOf")}function S(t){return"[object Object]"===Object.prototype.toString.call(t)}function b(t,e){return t===e||typeof t==typeof e&&(w(t)&&w(e)?!Object.keys(e).some((r=>!b(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>b(t,e[r])))))}function E(t){return P(t.filter(Boolean).join("/"))}function P(t){return t.replace(/\/{2,}/g,"/")}function x(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function R(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function C(t){return R(x(t))}function L(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let o=k(e);const a=k(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&&"/"===y(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return P(E([t,...o.map((t=>t.value))]))}function k(t){if(!t)return[];const e=[];if("/"===(t=P(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 j(t,e,r=!1){return E(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 O(t,e,r){const o=D(t,e,r);if(!r.to||o)return o??{}}function D(t,e,r){e="/"!=t?e.substring(t.length):e;const o=`${r.to??"$"}`,a=k(e),s=k(o);e.startsWith("/")||a.unshift({type:"pathname",value:"/"}),o.startsWith("/")||s.unshift({type:"pathname",value:"/"});const n={};return(()=>{for(let t=0;t<Math.max(a.length,s.length);t++){const e=a[t],o=s[t],i=t>=a.length-1,c=t>=s.length-1;if(o){if("wildcard"===o.type)return!!e?.value&&(n["*"]=E(a.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)&&(n[o.value.substring(1)]=e.value)}}if(!i&&c)return!!r.fuzzy}return!0})()?n:void 0}function M(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 A(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function T(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],A(e.shift())):o[r]=A(e.shift());return o}function $(){return $=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},$.apply(this,arguments)}
/**

@@ -32,3 +32,3 @@ * @tanstack/store/src/index.ts

* @license MIT
*/function H(t,e=(t=>t)){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,N)}function N(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 B(t){const e=W(),{type:r,children:o,target:a,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:v,className:_,onClick:w,onFocus:b,onMouseEnter:S,onMouseLeave:E,onTouchStart:P,...x}=t,R=e.buildLink(t);if("external"===R.type){const{href:t}=R;return{href:t}}const{handleClick:C,handleFocus:k,handleEnter:L,handleLeave:j,handleTouchStart:O,isActive:D,next:M}=R,A=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},T=D?g(n,{})??{}:{},$=D?{}:g(i,{})??{};return{...T,...$,...x,href:h?void 0:M.href,onClick:A([w,t=>{s.startTransition?s.startTransition((()=>{C(t)})):C(t)}]),onFocus:A([b,k]),onMouseEnter:A([S,L]),onMouseLeave:A([E,j]),onTouchStart:A([P,O]),target:a,style:{...v,...T.style,...$.style},className:[_,T.className,$.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":D?"active":void 0}}const K=s.forwardRef(((t,e)=>{const r=B(t);return s.createElement("a",$({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))}));const F=s.createContext(null),U=s.createContext(null),z=s.useDeferredValue||(t=>t);function W(){const t=s.useContext(U);return H(t.router.__store),t.router}function J(t){const e=W();return H(e.__store,t),e}function q(){return s.useContext(F)}function V(t){const e=W(),r=q()[0],o=z(e.state.matches),s=t?.from?o.find((e=>e.route.id===t?.from)):r;return a(s,t?.from&&t.from),(t?.strict??1)&&a(r.route.id==s?.route.id,(s?.route.id,r.route.id,s?.route.id,s?.route.id)),H(s.__store,(e=>t?.track?.(s)??s)),s}function Y(t){const{track:e,...r}=t,o=V(r);return H(o.__store,(e=>t?.track?.(e.loader)??e.loader)),o.state.loader}function G(t){const{track:e,...r}=t??{},o=V(r);return H(o.__store,(e=>t?.track?.(e.search)??e.search)),o.state.search}function Q(t){const e=W();return H(e.__store,(e=>{const r=y(e.matches)?.params;return t?.track?.(r)??r})),y(e.state.matches)?.params}function X(){const t=W();return s.useCallback((e=>{const{pending:r,caseSensitive:o,...s}=e;return t.matchRoute(s,{pending:r,caseSensitive:o})}),[])}function Z(){const t=q().slice(1),e=t[0];return e?s.createElement(tt,{matches:t,match:e}):null}function tt({matches:t,match:e}){const r=W();H(e.__store,(t=>[t.status,t.error]));const o=s.useCallback((()=>null),[]),a=e.pendingComponent??r.options.defaultPendingComponent??o,n=e.errorComponent??r.options.defaultErrorComponent,i=e.route.options.wrapInSuspense??!e.route.isRoot?s.Suspense:rt,c=n?ot:rt;return s.createElement(F.Provider,{value:t},s.createElement(i,{fallback:s.createElement(a,null)},s.createElement(c,{key:e.route.id,errorComponent:n,onCatch:()=>{e.id}},s.createElement(et,{match:e}))))}function et(t){const e=W();if("error"===t.match.state.status)throw t.match.state.error;if("pending"===t.match.state.status)throw t.match.__loadPromise;if("success"===t.match.state.status)return s.createElement(t.match.component??e.options.defaultComponent??Z,{useLoader:t.match.route.useLoader,useMatch:t.match.route.useMatch,useContext:t.match.route.useContext,useSearch:t.match.route.useSearch,useParams:t.match.route.useParams});a(!1)}function rt(t){return s.createElement(s.Fragment,null,t.children)}class ot extends s.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 s.createElement(st,$({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function st(t){const[e,r]=s.useState(t.errorState),o=W(),a=t.errorComponent??at,n=s.useRef("");return s.useEffect((()=>{e&&(o.state.location.key,n.current),n.current=o.state.location.key}),[e,o.state.location.key]),s.useEffect((()=>{t.errorState.error}),[t.errorState.error]),t.errorState.error&&e.error?s.createElement(a,e):t.children}function at({error:t}){return s.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},s.createElement("strong",{style:{fontSize:"1.2rem"}},"Something went wrong!"),s.createElement("div",{style:{height:".5rem"}}),s.createElement("div",null,s.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".5rem",color:"red",overflow:"auto"}},t.message?s.createElement("code",null,t.message):null)))}function nt(t,e=!0){const r=J();s.useEffect((()=>{if(!e)return;let o=r.history.block(((e,r)=>{window.confirm(t)&&(o(),e())}));return o}))}const it="__root__";class ct{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=it:a(this.parentRoute);let o=r?it:e.path;o&&"/"!==o&&(o=C(o));const s=e?.id||o;let n=r?it:E([this.parentRoute.id===it?"":this.parentRoute.id,s]);o===it&&(o="/"),n!==it&&(n=E(["/",n]));const i=n===it?"/":E([this.parentRoute.fullPath,o]);this.path=o,this.id=n,this.fullPath=i,this.to=i};addChildren=t=>(this.children=t,this);useMatch=t=>V({...t,from:this.id});useLoader=t=>Y({...t,from:this.id});useContext=t=>V({...t,from:this.id}).context;useSearch=t=>G({...t,from:this.id});useParams=t=>Q({...t,from:this.id})}class ht extends ct{constructor(t){super(t)}static withRouterContext=()=>t=>new ht(t)}const ut=dt(JSON.parse),lt=pt(JSON.stringify);function dt(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=T(e);for(let e in r){const o=r[e];if("string"==typeof o)try{r[e]=t(o)}catch(t){}}return r}}function pt(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=M(e).toString();return r?`?${r}`:""}}const ft=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")};const mt="undefined"==typeof window||!window.document.createElement;function yt(){return{status:"idle",currentLocation:null,location:null,matches:[],lastUpdated:Date.now()}}function gt(t){return!!t?.isRedirect}const vt=["component","errorComponent","pendingComponent"];class _t{abortController=new AbortController;__promiseKeys=[];__promisesByKey={};constructor(t,e,r){Object.assign(this,{route:e,router:t,id:r.id,pathname:r.pathname,params:r.params,__store:new I({updatedAt:0,routeSearch:{},search:{},status:"pending",loader:void 0},{onUpdate:()=>{this.state=this.__store.state}})}),this.state=this.__store.state,vt.map((async t=>{const e=this.route.options[t];this[t]=e})),this.__loadPromise=new Promise((t=>{this.__loadPromiseResolve=t})),"pending"!==this.state.status||this.#t()||(this.__store.setState((t=>({...t,status:"success"}))),this.__loadPromiseResolve?.())}#t=()=>!(!this.route.options.loader&&!vt.some((t=>this.route.options[t]?.preload)));__commit=()=>{const{routeSearch:t,search:e,context:r,routeContext:o}=this.#e({location:this.router.state.location});this.context=r,this.routeContext=o,this.__store.setState((r=>({...r,routeSearch:_(r.routeSearch,t),search:_(r.search,e)})))};cancel=()=>{this.abortController?.abort()};#r=t=>{const e=this.parentMatch?this.parentMatch.#r(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(gt(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}};#e=t=>{const{search:e,routeSearch:r}=this.#r(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.#e(t)}catch(e){return gt(e)?void(t?.preload||this.router.navigate(e)):void this.__store.setState((t=>({...t,status:"error",error:e})))}const{routeSearch:r,search:o,context:s,routeContext:a}=e,n={params:this.params,routeSearch:r,search:o,signal:this.abortController.signal,preload:!!t?.preload,routeContext:a,context:s};return this.__loadPromise=Promise.resolve().then((async()=>{const e=""+Date.now()+Math.random();this.#o=e;const r=()=>e!==this.#o?this.__loadPromise:void 0;let o;const s=(async()=>{await Promise.all(vt.map((async t=>{const e=this.route.options[t];e?.preload&&await e.preload()})))})(),a=Promise.resolve().then((()=>{if(this.route.options.loader)return this.route.options.loader(n)}));try{const[t,e]=await Promise.all([s,a]);if(o=r())return await o;Object.keys(e??{}).forEach((t=>{const r=e[t];if(r instanceof Promise||r?.then){if("undefined"==typeof document)this.__promisesByKey[t]={status:"pending",promise:r,data:void 0,resolve:()=>{}},r.then((e=>{this.__promisesByKey[t].status="resolved",this.__promisesByKey[t].data=e}));else{const e=function(){let t;const e=new Promise((e=>{t=e}));return e.resolve=e=>{t(e)},e}();this.__promisesByKey[t]={status:"pending",promise:e,data:void 0,resolve:r=>{e.resolve(),this.__promisesByKey[t].status="resolved",this.__promisesByKey[t].data=r}},this.__promiseKeys.includes(t)||r.then(this.__promisesByKey[t].resolve)}e[t]=this.__promisesByKey[t]}})),this.__store.setState((t=>({...t,error:void 0,status:"success",updatedAt:Date.now(),loader:e})))}catch(e){if(gt(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 gt(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{this.__loadPromiseResolve?.(),delete this.__loadPromise}})),this.__loadPromise};#o=""}t.Block=function({message:t,condition:e,children:r}){return nt(t,e),r??null},t.ErrorComponent=at,t.Link=K,t.MatchRoute=function(t){const e=X()(t);return e?"function"==typeof t.children?t.children(e):e?t.children:null:null},t.Navigate=function(t){const e=W();return s.useLayoutEffect((()=>{e.navigate(t)}),[]),null},t.Outlet=Z,t.RootRoute=ht,t.Route=ct,t.RouteMatch=_t,t.Router=class{#s;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??lt,parseSearch:t?.parseSearch??ut,fetchServerDataFn:t?.fetchServerDataFn??ft},this.__store=new I(yt(),{onUpdate:()=>{this.state=this.__store.state}}),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.#a({...e,replace:!0})}reset=()=>{this.__store.setState((t=>Object.assign(t,yt())))};mount=()=>(mt||this.state.matches.length||this.safeLoad(),()=>{});update=t=>{if(Object.assign(this.options,t),this.context=this.options.context,!this.history||this.options.history&&this.options.history!==this.history){this.#s&&this.#s(),this.history=this.options.history??(mt?p():d());const t=this.#n();this.__store.setState((e=>({...e,currentLocation:t,location:t}))),this.#s=this.history.listen((()=>{this.safeLoad({next:this.#n(this.state.location)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${C(e??"")??""}`,r&&(this.routesById={},this.routeTree=this.#i(r)),this};buildNext=t=>{const e=this.#c(t),r=this.matchRoutes(e.pathname,e.search);return this.#c({...t,__matches:r})};cancelMatches=()=>{[...this.state.matches].forEach((t=>{t.cancel()}))};safeLoad=t=>{this.load(t).catch((t=>{console.warn(t),a(!1)}))};load=async t=>{this.#h();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,location:t.next}))),o=this.matchRoutes(this.state.location.pathname,this.state.location.search,{strictParseParams:!0,debug:!0}),this.__store.setState((t=>({...t,status:"pending",matches:o})))})),await this.loadMatches(o,this.state.location),this.startedLoadingAt!==r)return this.navigationPromise;const s=this.state.matches,a=[],n=[];s.forEach((t=>{o.find((e=>e.id===t.id))?n.push(t):a.push(t)}));const i=o.filter((t=>!s.find((e=>e.id===t.id))));e=Date.now(),a.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.location;this.__store.setState((t=>({...t,status:"idle",currentLocation:t.location,matches:o}))),o.forEach((t=>{t.__commit()})),c.href!==this.state.location.href&&this.options.onRouteChange?.(),this.resolveNavigation()};getRoute=t=>{const e=this.routesById[t];return a(e),e};loadRoute=async(t=this.state.location)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,e.search,{strictParseParams:!0});return await this.loadMatches(r,e),r};preloadRoute=async(t=this.state.location)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,e.search,{strictParseParams:!0});return await this.loadMatches(r,e,{preload:!0}),r};matchRoutes=(t,e,r)=>{if(!this.routeTree)return[];const o=[...this.state.matches];let s=[];const a=(e,o=[])=>{let n,i;if(e.some((e=>{const s=e.children;if(!e.path&&s?.length){const t=a(s,[...o,e]);return!!t&&(n=t,i=void 0,!0)}const c="/"!==e.path||!!s?.length,h=O(this.basepath,t,{to:e.fullPath,fuzzy:c,caseSensitive:e.options.caseSensitive??this.options.caseSensitive});if(h){let t;try{t=e.options.parseParams?.(h)??h}catch(t){if(r?.strictParseParams)throw t}return n=e,i=t,!0}return!1})),!n)return;s.push(...o.map((t=>({route:t}))),{route:n,params:i});const c=n.children;return c?.length?a(c):n};a([this.routeTree]);let n={};return s.map((({route:t,params:r})=>{Object.assign(n,r);const s=j(t.path,n),a=j(t.id,n,!0)+(t.options.getKey?.({params:n,search:e})??"");return o.find((t=>t.id===a))||new _t(this,t,{id:a,params:n,pathname:E([this.basepath,s])})})).filter(((t,e,r)=>r.findIndex((e=>e.id===t.id))===e))};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(gt(r))throw r;o=o??e;const s=t.route.options.onBeforeLoadError??t.route.options.onError;try{s?.(r)}catch(e){if(gt(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(gt(t))return void(r?.preload||this.navigate(t));throw t}const s=t.slice(0,o),a=s.map((async(t,o)=>{const a=s[o-1];t.__load({preload:r?.preload,location:e,parentMatch:a}),await t.__loadPromise,a&&await a.__loadPromise}));await Promise.all(a)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>k(this.basepath,t,P(e));navigate=async({from:t,to:e="",search:r,hash:o,replace:s,params:n})=>{const i=String(e),c=void 0===t?t:String(t);let h;try{new URL(`${i}`),h=!0}catch(t){}return a(!h),this.#a({from:c,to:i,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.currentLocation;if(!o)return!1;const s=O(this.basepath,o.pathname,{...e,to:r.pathname});return!!s&&(e?.includeSearch??1?!!S(o.search,r.search)&&s:s)};buildLink=({from:t,to:e=".",search:r,params:o,hash:s,target:a,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:s,replace:n},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)||S(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||a&&"_self"!==a||0!==t.button||(t.preventDefault(),this.#a(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:{...v(this.state,["location","status","lastUpdated"]),matches:this.state.matches.map((t=>({id:t.id,promiseKeys:Object.keys(t.__promisesByKey)})))}});hydrate=async t=>{let e=t;"undefined"!=typeof document&&(e=window.__TSR_DEHYDRATED__),a(e);const r=e;this.options.hydrate?.(r.payload),this.__store.setState((t=>({...t,...r.router.state,matches:t.matches,currentLocation:r.router.state.location}))),await this.load(),this.state.matches.forEach((t=>{t.__promiseKeys=r.router.state.matches.find((e=>e.id===t.id))?.promiseKeys??[]}))};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=await e();return`<script>window["__TSR__DEHYRATED__${o=r,o.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"')}"] = ${JSON.stringify(t)}<\/script>`;var o})),()=>this.hydrateData(t)}return()=>{}};hydrateData=t=>{if("undefined"!=typeof document){const e="string"==typeof t?t:JSON.stringify(t);return window[`__TSR__DEHYRATED__${e}`]}};resolveMatchPromise=(t,e,r)=>{this.state.matches.find((e=>e.id===t))?.__promisesByKey[e]?.resolve(r)};#i=t=>{const e=(t,r)=>{t.forEach(((t,r)=>{t.init({originalIndex:r,router:this});a(!this.routesById[t.id],String(t.id)),this.routesById[t.id]=t;const o=t.children;o?.length&&(e(o),o.length,t.children=o.map(((t,e)=>{const r=x(P(t.path??"/")),o=L(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,cleaned:r,parsed:o,index:e,score:s}})).sort(((t,e)=>{const r=Math.min(t.score.length,e.score.length);for(let o=0;o<r;o++)if(t.score[o]!==e.score[o])return e.score[o]-t.score[o];for(let o=0;o<r;o++)if(t.parsed[o].value!==e.parsed[o].value)return t.parsed[o].value>e.parsed[o].value?1:-1;return t.score.length!==e.score.length?e.score.length-t.score.length:t.cleaned!==e.cleaned?t.cleaned>e.cleaned?1:-1:t.index-e.index})).map((t=>t.child)))}))};e([t]);const r=(t,e)=>{t.forEach((t=>{t.isRoot?a(!e):a(!e||t.parentRoute===e,(t.path,t.parentRoute?.id,e?.id)),t.children&&r(t.children,t)}))};return r([t],void 0),t};#n=t=>{let{pathname:e,search:r,hash:o,state:s}=this.history.location;const a=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:_(t?.search,a),hash:o.split("#").reverse()[0]??"",href:`${e}${r}${o}`,state:s,key:s?.key||"__init__"}};#c=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.location.pathname:t.from??this.state.location.pathname;let r=k(this.basepath??"/",e,`${t.to??""}`);const o={...y(this.matchRoutes(this.state.location.pathname,this.state.location.search,{strictParseParams:!0}))?.params};let s=!0===(t.params??!0)?o:g(t.params,o);s&&t.__matches?.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{s={...s,...t(s)}})),r=j(r,s??{});const a=t.__matches?.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean)??[],n=t.__matches?.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean)??[],i=a?.length?a?.reduce(((t,e)=>e(t)),this.state.location.search):this.state.location.search,c=!0===t.search?i:t.search?g(t.search,i)??{}:a?.length?i:{},h=n?.length?n.reduce(((t,e)=>e(t)),c):c,u=_(this.state.location.search,h),l=this.options.stringifySearch(u),d=!0===t.hash?this.state.location.hash:g(t.hash,this.state.location.hash),p=d?`#${d}`:"";return{pathname:r,search:u,searchStr:l,state:!0===t.state?this.state.location.state:g(t.state,this.state.location.state),hash:d,href:this.history.createHref(`${r}${l}${p}`),key:t.key}};#a=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.#h()};#h=()=>{const t=this.resolveNavigation;return this.navigationPromise=new Promise((e=>{this.resolveNavigation=()=>{e(),t()}})),this.navigationPromise}},t.RouterProvider=function({router:t,...e}){t.update(e);const r=z(H(t.__store,(t=>t.matches)));return s.useEffect(t.mount,[t]),s.createElement(U.Provider,{value:{router:t}},s.createElement(F.Provider,{value:[void 0,...r]},s.createElement(ot,{errorComponent:at,onCatch:()=>{}},s.createElement(Z,null))))},t.cleanPath=P,t.createBrowserHistory=d,t.createHashHistory=function(){return d({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=p,t.decode=T,t.defaultFetchServerDataFn=ft,t.defaultParseSearch=ut,t.defaultStringifySearch=lt,t.encode=M,t.functionalUpdate=g,t.interpolatePath=j,t.invariant=a,t.isPlainObject=w,t.isRedirect=gt,t.joinPaths=E,t.last=y,t.lazy=function(t,e="default"){const r=s.lazy((async()=>({default:(await t())[e]})));return r.preload=async()=>{await t()},r},t.matchByPath=D,t.matchPathname=O,t.matchesContext=F,t.parsePathname=L,t.parseSearchWith=dt,t.partialDeepEqual=S,t.pick=v,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=_,t.resolvePath=k,t.rootRouteId=it,t.routerContext=U,t.stringifySearchWith=pt,t.trimPath=C,t.trimPathLeft=x,t.trimPathRight=R,t.useBlocker=nt,t.useDehydrate=function(){const t=W();return s.useCallback((function(e,r){return t.dehydrateData(e,r)}),[])},t.useHydrate=function(){const t=W();return function(e){return t.hydrateData(e)}},t.useInjectHtml=function(){const t=W();return s.useCallback((e=>{t.injectHtml(e)}),[])},t.useLinkProps=B,t.useLoader=Y,t.useMatch=V,t.useMatchRoute=X,t.useMatches=q,t.useNavigate=function(t){const e=W();return s.useCallback((r=>e.navigate({...t,...r})),[])},t.useParams=Q,t.useRouter=J,t.useRouterContext=W,t.useSearch=G,t.useStore=H,t.warning=n,Object.defineProperty(t,"__esModule",{value:!0})}));
*/function H(t,e=(t=>t)){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,N)}function N(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 B(t){const e=J(),{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:v,className:_,onClick:w,onFocus:S,onMouseEnter:b,onMouseLeave:E,onTouchStart:P,...x}=t,R=e.buildLink(t);if("external"===R.type){const{href:t}=R;return{href:t}}const{handleClick:C,handleFocus:L,handleEnter:k,handleLeave:j,handleTouchStart:O,isActive:D,next:M}=R,A=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},T=D?g(n,{})??{}:{},$=D?{}:g(i,{})??{};return{...T,...$,...x,href:h?void 0:M.href,onClick:A([w,t=>{a.startTransition?a.startTransition((()=>{C(t)})):C(t)}]),onFocus:A([S,L]),onMouseEnter:A([b,k]),onMouseLeave:A([E,j]),onTouchStart:A([P,O]),target:s,style:{...v,...T.style,...$.style},className:[_,T.className,$.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":D?"active":void 0}}const F=a.forwardRef(((t,e)=>{const r=B(t);return a.createElement("a",$({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))}));const U=a.createContext(null),z=a.createContext(null),W=a.useDeferredValue||(t=>t);function J(){const t=a.useContext(z);return H(t.router.__store),t.router}function K(t){const e=J();return H(e.__store,t),e}function q(){return a.useContext(U)}function V(t){const e=J(),r=q()[0],o=W(e.state.matches),a=t?.from?o.find((e=>e.route.id===t?.from)):r;return s(a,t?.from&&t.from),(t?.strict??1)&&s(r.route.id==a?.route.id,(a?.route.id,r.route.id,a?.route.id,a?.route.id)),H(a.__store,(e=>t?.track?.(a)??a)),a}function Y(t){const{track:e,...r}=t,o=V(r);return H(o.__store,(e=>t?.track?.(e.loader)??e.loader)),o.state.loader}function G(t){const{track:e,...r}=t??{},o=V(r);return H(o.__store,(e=>t?.track?.(e.search)??e.search)),o.state.search}function Q(t){const e=J();return H(e.__store,(e=>{const r=y(e.matches)?.params;return t?.track?.(r)??r})),y(e.state.matches)?.params}function X(){const t=J();return a.useCallback((e=>{const{pending:r,caseSensitive:o,...a}=e;return t.matchRoute(a,{pending:r,caseSensitive:o})}),[])}function Z(){const t=q().slice(1),e=t[0];return e?a.createElement(tt,{matches:t,match:e}):null}function tt({matches:t,match:e}){const r=J();H(e.__store,(t=>[t.status,t.error]));const o=a.useCallback((()=>null),[]),s=e.pendingComponent??r.options.defaultPendingComponent??o,n=e.errorComponent??r.options.defaultErrorComponent,i=e.route.options.wrapInSuspense??!e.route.isRoot?a.Suspense:rt,c=n?ot:rt;return a.createElement(U.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(et,{match:e}))))}function et(t){const e=J();if("error"===t.match.state.status)throw t.match.state.error;if("pending"===t.match.state.status)throw t.match.__loadPromise;if("success"===t.match.state.status)return a.createElement(t.match.component??e.options.defaultComponent??Z,{useLoader:t.match.route.useLoader,useMatch:t.match.route.useMatch,useContext:t.match.route.useContext,useSearch:t.match.route.useSearch,useParams:t.match.route.useParams});s(!1)}function rt(t){return a.createElement(a.Fragment,null,t.children)}class ot 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(at,$({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function at(t){const[e,r]=a.useState(t.errorState),o=J(),s=t.errorComponent??st,n=a.useRef("");return a.useEffect((()=>{e&&(o.state.location.key,n.current),n.current=o.state.location.key}),[e,o.state.location.key]),a.useEffect((()=>{t.errorState.error}),[t.errorState.error]),t.errorState.error&&e.error?a.createElement(s,e):t.children}function st({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 nt(t,e=!0){const r=K();a.useEffect((()=>{if(!e)return;let o=r.history.block(((e,r)=>{window.confirm(t)&&(o(),e())}));return o}))}const it="__root__";class ct{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=it:s(this.parentRoute);let o=r?it:e.path;o&&"/"!==o&&(o=C(o));const a=e?.id||o;let n=r?it:E([this.parentRoute.id===it?"":this.parentRoute.id,a]);o===it&&(o="/"),n!==it&&(n=E(["/",n]));const i=n===it?"/":E([this.parentRoute.fullPath,o]);this.path=o,this.id=n,this.fullPath=i,this.to=i};addChildren=t=>(this.children=t,this);useMatch=t=>V({...t,from:this.id});useLoader=t=>Y({...t,from:this.id});useContext=t=>V({...t,from:this.id}).context;useSearch=t=>G({...t,from:this.id});useParams=t=>Q({...t,from:this.id})}class ht extends ct{constructor(t){super(t)}static withRouterContext=()=>t=>new ht(t)}const ut=dt(JSON.parse),lt=pt(JSON.stringify);function dt(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=T(e);for(let e in r){const o=r[e];if("string"==typeof o)try{r[e]=t(o)}catch(t){}}return r}}function pt(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=M(e).toString();return r?`?${r}`:""}}const ft=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")};const mt="undefined"==typeof window||!window.document.createElement;function yt(){return{status:"idle",currentLocation:null,location:null,matches:[],lastUpdated:Date.now()}}function gt(t){return!!t?.isRedirect}const vt=["component","errorComponent","pendingComponent"];class _t{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 I({updatedAt:0,routeSearch:{},search:{},status:"pending",loader:void 0},{onUpdate:()=>{this.state=this.__store.state}})}),this.state=this.__store.state,vt.map((async t=>{const e=this.route.options[t];this[t]=e})),this.__loadPromise=new Promise((t=>{this.__loadPromiseResolve=t})),"pending"!==this.state.status||this.#t()||(this.__store.setState((t=>({...t,status:"success"}))),this.__loadPromiseResolve?.())}#t=()=>!(!this.route.options.loader&&!vt.some((t=>this.route.options[t]?.preload)));__commit=()=>{const{routeSearch:t,search:e,context:r,routeContext:o}=this.#e({location:this.router.state.location});this.context=r,this.routeContext=o,this.__store.setState((r=>({...r,routeSearch:_(r.routeSearch,t),search:_(r.search,e)})))};cancel=()=>{this.abortController?.abort()};#r=t=>{const e=this.parentMatch?this.parentMatch.#r(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(gt(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}};#e=t=>{const{search:e,routeSearch:r}=this.#r(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.#e(t)}catch(e){return gt(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,n={params:this.params,routeSearch:r,search:o,signal:this.abortController.signal,preload:!!t?.preload,routeContext:s,context:a};return this.__loadPromise=Promise.resolve().then((async()=>{const e=""+Date.now()+Math.random();this.#o=e;const r=()=>e!==this.#o?this.__loadPromise:void 0;let o;const a=(async()=>{await Promise.all(vt.map((async t=>{const e=this.route.options[t];e?.preload&&await e.preload()})))})(),s=Promise.resolve().then((()=>{if(this.route.options.loader)return this.route.options.loader(n)}));try{const[t,e]=await Promise.all([a,s]);if(o=r())return await o;this.__store.setState((t=>({...t,error:void 0,status:"success",updatedAt:Date.now(),loader:e})))}catch(e){if(gt(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 gt(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{this.__loadPromiseResolve?.(),delete this.__loadPromise}})),this.__loadPromise};#o=""}t.Block=function({message:t,condition:e,children:r}){return nt(t,e),r??null},t.ErrorComponent=st,t.Link=F,t.MatchRoute=function(t){const e=X()(t);return e?"function"==typeof t.children?t.children(e):e?t.children:null:null},t.Navigate=function(t){const e=J();return a.useLayoutEffect((()=>{e.navigate(t)}),[]),null},t.Outlet=Z,t.RootRoute=ht,t.Route=ct,t.RouteMatch=_t,t.Router=class{#a;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??lt,parseSearch:t?.parseSearch??ut,fetchServerDataFn:t?.fetchServerDataFn??ft},this.__store=new I(yt(),{onUpdate:()=>{this.state=this.__store.state}}),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.#s({...e,replace:!0}),"undefined"!=typeof document&&this.hydrate()}reset=()=>{this.__store.setState((t=>Object.assign(t,yt())))};mount=()=>(mt||this.state.matches.length||this.safeLoad(),()=>{});update=t=>{if(Object.assign(this.options,t),this.context=this.options.context,!this.history||this.options.history&&this.options.history!==this.history){this.#a&&this.#a(),this.history=this.options.history??(mt?p():d());const t=this.#n();this.__store.setState((e=>({...e,currentLocation:t,location:t}))),this.#a=this.history.listen((()=>{this.safeLoad({next:this.#n(this.state.location)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${C(e??"")??""}`,r&&(this.routesById={},this.routeTree=this.#i(r)),this};buildNext=t=>{const e=this.#c(t),r=this.matchRoutes(e.pathname,e.search);return this.#c({...t,__matches:r})};cancelMatches=()=>{[...this.state.matches].forEach((t=>{t.cancel()}))};safeLoad=t=>{this.load(t).catch((t=>{console.warn(t),s(!1)}))};load=async t=>{this.#h();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,location:t.next}))),o=this.matchRoutes(this.state.location.pathname,this.state.location.search,{strictParseParams:!0,debug:!0}),this.__store.setState((t=>({...t,status:"pending",matches:o})))})),await this.loadMatches(o,this.state.location),this.startedLoadingAt!==r)return this.navigationPromise;const a=this.state.matches,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.location;this.__store.setState((t=>({...t,status:"idle",currentLocation:t.location,matches:o}))),o.forEach((t=>{t.__commit()})),c.href!==this.state.location.href&&this.options.onRouteChange?.(),this.resolveNavigation()};getRoute=t=>{const e=this.routesById[t];return s(e),e};loadRoute=async(t=this.state.location)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,e.search,{strictParseParams:!0});return await this.loadMatches(r,e),r};preloadRoute=async(t=this.state.location)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,e.search,{strictParseParams:!0});return await this.loadMatches(r,e,{preload:!0}),r};matchRoutes=(t,e,r)=>{if(!this.routeTree)return[];const o=[...this.state.matches];let a=[];const s=(e,o=[])=>{let n,i;if(e.some((e=>{const a=e.children;if(!e.path&&a?.length){const t=s(a,[...o,e]);return!!t&&(n=t,i=void 0,!0)}const c="/"!==e.path||!!a?.length,h=O(this.basepath,t,{to:e.fullPath,fuzzy:c,caseSensitive:e.options.caseSensitive??this.options.caseSensitive});if(h){let t;try{t=e.options.parseParams?.(h)??h}catch(t){if(r?.strictParseParams)throw t}return n=e,i=t,!0}return!1})),!n)return;a.push(...o.map((t=>({route:t}))),{route:n,params:i});const c=n.children;return c?.length?s(c):n};s([this.routeTree]);let n={};return a.map((({route:t,params:r})=>{Object.assign(n,r);const a=j(t.path,n),s=j(t.id,n,!0)+(t.options.getKey?.({params:n,search:e})??"");return o.find((t=>t.id===s))||new _t(this,t,{id:s,params:n,pathname:E([this.basepath,a])})})).filter(((t,e,r)=>r.findIndex((e=>e.id===t.id))===e))};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(gt(r))throw r;o=o??e;const a=t.route.options.onBeforeLoadError??t.route.options.onError;try{a?.(r)}catch(e){if(gt(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(gt(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)=>L(this.basepath,t,P(e));navigate=async({from:t,to:e="",search:r,hash:o,replace:a,params:n})=>{const i=String(e),c=void 0===t?t:String(t);let h;try{new URL(`${i}`),h=!0}catch(t){}return s(!h),this.#s({from:c,to:i,search:r,hash:o,replace:a,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.currentLocation;if(!o)return!1;const a=O(this.basepath,o.pathname,{...e,to:r.pathname});return!!a&&(e?.includeSearch??1?!!b(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.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)||b(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||s&&"_self"!==s||0!==t.button||(t.preventDefault(),this.#s(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:{...v(this.state,["location","status","lastUpdated"])}});hydrate=async t=>{let e=t;"undefined"!=typeof document&&(e=window.__TSR_DEHYDRATED__),s(e);const r=e;this.options.hydrate?.(r.payload),this.__store.setState((t=>({...t,...r.router.state,matches:t.matches,currentLocation: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="function"==typeof e?await e():e;return`<script>window["__TSR__DEHYRATED__${o=r,o.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"')}"] = ${JSON.stringify(t)}<\/script>`;var o})),()=>this.hydrateData(t)}return()=>{}};hydrateData=t=>{if("undefined"!=typeof document){const e="string"==typeof t?t:JSON.stringify(t);return window[`__TSR__DEHYRATED__${e}`]}};#i=t=>{const e=(t,r)=>{t.forEach(((t,r)=>{t.init({originalIndex:r,router:this});s(!this.routesById[t.id],String(t.id)),this.routesById[t.id]=t;const o=t.children;o?.length&&(e(o),o.length,t.children=o.map(((t,e)=>{const r=x(P(t.path??"/")),o=k(r);for(;o.length>1&&"/"===o[0]?.value;)o.shift();const a=o.map((t=>"param"===t.type?.5:"wildcard"===t.type?.25:1));return{child:t,cleaned:r,parsed:o,index:e,score:a}})).sort(((t,e)=>{const r=Math.min(t.score.length,e.score.length);for(let o=0;o<r;o++)if(t.score[o]!==e.score[o])return e.score[o]-t.score[o];for(let o=0;o<r;o++)if(t.parsed[o].value!==e.parsed[o].value)return t.parsed[o].value>e.parsed[o].value?1:-1;return t.score.length!==e.score.length?e.score.length-t.score.length:t.cleaned!==e.cleaned?t.cleaned>e.cleaned?1:-1:t.index-e.index})).map((t=>t.child)))}))};e([t]);const r=(t,e)=>{t.forEach((t=>{t.isRoot?s(!e):s(!e||t.parentRoute===e,(t.path,t.parentRoute?.id,e?.id)),t.children&&r(t.children,t)}))};return r([t],void 0),t};#n=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__"}};#c=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.location.pathname:t.from??this.state.location.pathname;let r=L(this.basepath??"/",e,`${t.to??""}`);const o={...y(this.matchRoutes(this.state.location.pathname,this.state.location.search,{strictParseParams:!0}))?.params};let a=!0===(t.params??!0)?o:g(t.params,o);a&&t.__matches?.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{a={...a,...t(a)}})),r=j(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.location.search):this.state.location.search,c=!0===t.search?i:t.search?g(t.search,i)??{}:s?.length?i:{},h=n?.length?n.reduce(((t,e)=>e(t)),c):c,u=_(this.state.location.search,h),l=this.options.stringifySearch(u),d=!0===t.hash?this.state.location.hash:g(t.hash,this.state.location.hash),p=d?`#${d}`:"";return{pathname:r,search:u,searchStr:l,state:!0===t.state?this.state.location.state:g(t.state,this.state.location.state),hash:d,href:this.history.createHref(`${r}${l}${p}`),key:t.key}};#s=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 a=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===o?"push":"replace"](a,{id:r,...e.state}),this.#h()};#h=()=>{const t=this.resolveNavigation;return this.navigationPromise=new Promise((e=>{this.resolveNavigation=()=>{e(),t()}})),this.navigationPromise}},t.RouterProvider=function({router:t,...e}){t.update(e);const r=W(H(t.__store,(t=>t.matches)));return a.useEffect(t.mount,[t]),a.createElement(z.Provider,{value:{router:t}},a.createElement(U.Provider,{value:[void 0,...r]},a.createElement(ot,{errorComponent:st,onCatch:()=>{}},a.createElement(Z,null))))},t.cleanPath=P,t.createBrowserHistory=d,t.createHashHistory=function(){return d({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=p,t.decode=T,t.defaultFetchServerDataFn=ft,t.defaultParseSearch=ut,t.defaultStringifySearch=lt,t.encode=M,t.functionalUpdate=g,t.interpolatePath=j,t.invariant=s,t.isPlainObject=w,t.isRedirect=gt,t.joinPaths=E,t.last=y,t.lazy=function(t,e="default"){const r=a.lazy((async()=>({default:(await t())[e]})));return r.preload=async()=>{await t()},r},t.matchByPath=D,t.matchPathname=O,t.matchesContext=U,t.parsePathname=k,t.parseSearchWith=dt,t.partialDeepEqual=b,t.pick=v,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=_,t.resolvePath=L,t.rootRouteId=it,t.routerContext=z,t.stringifySearchWith=pt,t.trimPath=C,t.trimPathLeft=x,t.trimPathRight=R,t.useBlocker=nt,t.useDehydrate=function(){const t=J();return a.useCallback((function(e,r){return t.dehydrateData(e,r)}),[])},t.useHydrate=function(){const t=J();return function(e){return t.hydrateData(e)}},t.useInjectHtml=function(){const t=J();return a.useCallback((e=>{t.injectHtml(e)}),[])},t.useLinkProps=B,t.useLoader=Y,t.useMatch=V,t.useMatchRoute=X,t.useMatches=q,t.useNavigate=function(t){const e=J();return a.useCallback((r=>e.navigate({...t,...r})),[])},t.useParams=Q,t.useRouter=K,t.useRouterContext=J,t.useSearch=G,t.useStore=H,t.warning=n,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=index.production.js.map
{
"name": "@tanstack/router",
"author": "Tanner Linsley",
"version": "0.0.1-beta.109",
"version": "0.0.1-beta.110",
"license": "MIT",

@@ -45,2 +45,3 @@ "repository": "tanstack/router",

"tiny-warning": "^1.0.3",
"@gisatcz/cross-package-react-context": "^0.2.0",
"@tanstack/react-store": "0.0.1-beta.90"

@@ -47,0 +48,0 @@ },

@@ -474,6 +474,12 @@ import { ParsePathParams } from './link'

export type UseLoaderResult<T> = {
[K in keyof T]: T[K] extends Promise<infer U> ? StreamedPromise<U> : T[K]
}
export type UseLoaderResult<T> = T extends Record<PropertyKey, infer U>
? {
[K in keyof T]: UseLoaderResultPromise<T[K]>
}
: UseLoaderResultPromise<T>
export type UseLoaderResultPromise<T> = T extends Promise<infer U>
? StreamedPromise<U>
: T
export type StreamedPromise<T> = {

@@ -480,0 +486,0 @@ promise: Promise<T>

@@ -67,4 +67,4 @@ import { Store } from '@tanstack/react-store'

__promiseKeys: string[] = []
__promisesByKey: Record<string, StreamedPromise<any>> = {}
// __promiseKeys: string[] = []
// __promisesByKey: Record<string, StreamedPromise<any>> = {}
__loadPromise?: Promise<void>

@@ -307,43 +307,43 @@ __loadPromiseResolve?: () => void

Object.keys(loader ?? {}).forEach((key) => {
const value = loader[key]
if (value instanceof Promise || value?.then) {
// if (this.__promisesByKey[key]) {
// return
// }
// Object.keys(loader ?? {}).forEach((key) => {
// const value = loader[key]
// if (value instanceof Promise || value?.then) {
// // if (this.__promisesByKey[key]) {
// // return
// // }
if (typeof document === 'undefined') {
this.__promisesByKey[key] = {
status: 'pending',
promise: value,
data: undefined,
resolve: () => {},
}
// if (typeof document === 'undefined') {
// this.__promisesByKey[key] = {
// status: 'pending',
// promise: value,
// data: undefined,
// resolve: () => {},
// }
value.then((d: any) => {
this.__promisesByKey[key]!.status = 'resolved'
this.__promisesByKey[key]!.data = d
})
} else {
const promise = createPromise()
this.__promisesByKey[key] = {
status: 'pending',
promise,
data: undefined,
resolve: (d: any) => {
// @ts-ignore
promise.resolve()
this.__promisesByKey[key]!.status = 'resolved'
this.__promisesByKey[key]!.data = d
},
}
// value.then((d: any) => {
// this.__promisesByKey[key]!.status = 'resolved'
// this.__promisesByKey[key]!.data = d
// })
// } else {
// const promise = createPromise()
// this.__promisesByKey[key] = {
// status: 'pending',
// promise,
// data: undefined,
// resolve: (d: any) => {
// // @ts-ignore
// promise.resolve()
// this.__promisesByKey[key]!.status = 'resolved'
// this.__promisesByKey[key]!.data = d
// },
// }
if (!this.__promiseKeys.includes(key)) {
value.then(this.__promisesByKey[key]!.resolve)
}
}
// if (!this.__promiseKeys.includes(key)) {
// value.then(this.__promisesByKey[key]!.resolve)
// }
// }
loader[key] = this.__promisesByKey[key]
}
})
// loader[key] = this.__promisesByKey[key]
// }
// })

@@ -350,0 +350,0 @@ this.__store.setState((s) => ({

@@ -203,3 +203,3 @@ import { Store } from '@tanstack/react-store'

extends Pick<RouterState, 'status' | 'location' | 'lastUpdated'> {
matches: DehydratedRouteMatch[]
// matches: DehydratedRouteMatch[]
}

@@ -314,2 +314,6 @@

}
if (typeof document !== 'undefined') {
this.hydrate()
}
}

@@ -1019,6 +1023,6 @@

...pick(this.state, ['location', 'status', 'lastUpdated']),
matches: this.state.matches.map((m) => ({
id: m.id,
promiseKeys: Object.keys(m.__promisesByKey),
})),
// matches: this.state.matches.map((m) => ({
// id: m.id,
// promiseKeys: Object.keys(m.__promisesByKey),
// })),
},

@@ -1037,3 +1041,3 @@ }

_ctx,
'Expected to find a __TSR_DEHYDRATED__ property on window... but we did not. Did you forget to render <RouterScripts /> in your app?',
'Expected to find a __TSR_DEHYDRATED__ property on window... but we did not. Did you forget to render <DehydrateRouter /> in your app?',
)

@@ -1056,6 +1060,6 @@

this.state.matches.forEach((m) => {
m.__promiseKeys =
ctx.router.state.matches.find((d) => d.id === m.id)?.promiseKeys ?? []
})
// this.state.matches.forEach((m) => {
// m.__promiseKeys =
// ctx.router.state.matches.find((d) => d.id === m.id)?.promiseKeys ?? []
// })

@@ -1065,9 +1069,9 @@ return

injectedHtml: (() => Promise<string> | string)[] = []
injectedHtml: (string | (() => Promise<string> | string))[] = []
injectHtml = async (getHtml: () => Promise<string> | string) => {
this.injectedHtml.push(getHtml)
injectHtml = async (html: string | (() => Promise<string> | string)) => {
this.injectedHtml.push(html)
}
dehydrateData = <T>(key: any, getData: () => Promise<T> | T) => {
dehydrateData = <T>(key: any, getData: T | (() => Promise<T> | T)) => {
if (typeof document === 'undefined') {

@@ -1077,3 +1081,4 @@ const strKey = typeof key === 'string' ? key : JSON.stringify(key)

this.injectHtml(async () => {
const data = await getData()
const data =
typeof getData === 'function' ? await (getData as any)() : getData
return `<script>window["__TSR__DEHYRATED__${escapeJSON(

@@ -1100,7 +1105,7 @@ strKey,

resolveMatchPromise = (matchId: string, key: string, value: any) => {
this.state.matches
.find((d) => d.id === matchId)
?.__promisesByKey[key]?.resolve(value)
}
// resolveMatchPromise = (matchId: string, key: string, value: any) => {
// this.state.matches
// .find((d) => d.id === matchId)
// ?.__promisesByKey[key]?.resolve(value)
// }

@@ -1107,0 +1112,0 @@ #buildRouteTree = (routeTree: AnyRoute) => {

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 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 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