Socket
Socket
Sign inDemoInstall

@tanstack/router-core

Package Overview
Dependencies
Maintainers
2
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/router-core - npm Package Compare versions

Comparing version 0.0.1-beta.203 to 0.0.1-beta.204

2

build/cjs/router.js

@@ -1111,3 +1111,3 @@ /**

// do nothing
if (!isSameUrl || next.replace) {
if (!isSameUrl || !next.replace) {
let {

@@ -1114,0 +1114,0 @@ maskedLocation,

@@ -1606,3 +1606,3 @@ /**

// do nothing
if (!isSameUrl || next.replace) {
if (!isSameUrl || !next.replace) {
let {

@@ -1609,0 +1609,0 @@ maskedLocation,

@@ -14,3 +14,3 @@ {

"name": "history/build/esm/index.js",
"uid": "8721-35"
"uid": "8e4c-35"
},

@@ -21,39 +21,39 @@ {

{
"uid": "8721-41",
"uid": "8e4c-41",
"name": "utils.ts"
},
{
"uid": "8721-43",
"uid": "8e4c-43",
"name": "path.ts"
},
{
"uid": "8721-45",
"uid": "8e4c-45",
"name": "qss.ts"
},
{
"uid": "8721-47",
"uid": "8e4c-47",
"name": "route.ts"
},
{
"uid": "8721-49",
"uid": "8e4c-49",
"name": "fileRoute.ts"
},
{
"uid": "8721-53",
"uid": "8e4c-53",
"name": "searchParams.ts"
},
{
"uid": "8721-55",
"uid": "8e4c-55",
"name": "router.ts"
},
{
"uid": "8721-57",
"uid": "8e4c-57",
"name": "scroll-restoration.ts"
},
{
"uid": "8721-59",
"uid": "8e4c-59",
"name": "defer.ts"
},
{
"uid": "8721-61",
"uid": "8e4c-61",
"name": "index.ts"

@@ -70,11 +70,11 @@ }

"name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"uid": "8721-37"
"uid": "8e4c-37"
},
{
"name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
"uid": "8721-39"
"uid": "8e4c-39"
},
{
"name": "@tanstack+store@0.0.1/node_modules/@tanstack/store/build/esm/index.js",
"uid": "8721-51"
"uid": "8e4c-51"
}

@@ -89,92 +89,92 @@ ]

"nodeParts": {
"8721-35": {
"8e4c-35": {
"renderedLength": 9148,
"gzipLength": 2726,
"brotliLength": 0,
"mainUid": "8721-34"
"mainUid": "8e4c-34"
},
"8721-37": {
"8e4c-37": {
"renderedLength": 181,
"gzipLength": 129,
"brotliLength": 0,
"mainUid": "8721-36"
"mainUid": "8e4c-36"
},
"8721-39": {
"8e4c-39": {
"renderedLength": 44,
"gzipLength": 62,
"brotliLength": 0,
"mainUid": "8721-38"
"mainUid": "8e4c-38"
},
"8721-41": {
"8e4c-41": {
"renderedLength": 3068,
"gzipLength": 1129,
"brotliLength": 0,
"mainUid": "8721-40"
"mainUid": "8e4c-40"
},
"8721-43": {
"8e4c-43": {
"renderedLength": 5666,
"gzipLength": 1414,
"brotliLength": 0,
"mainUid": "8721-42"
"mainUid": "8e4c-42"
},
"8721-45": {
"8e4c-45": {
"renderedLength": 1281,
"gzipLength": 547,
"brotliLength": 0,
"mainUid": "8721-44"
"mainUid": "8e4c-44"
},
"8721-47": {
"8e4c-47": {
"renderedLength": 2442,
"gzipLength": 908,
"brotliLength": 0,
"mainUid": "8721-46"
"mainUid": "8e4c-46"
},
"8721-49": {
"8e4c-49": {
"renderedLength": 203,
"gzipLength": 140,
"brotliLength": 0,
"mainUid": "8721-48"
"mainUid": "8e4c-48"
},
"8721-51": {
"8e4c-51": {
"renderedLength": 1843,
"gzipLength": 644,
"brotliLength": 0,
"mainUid": "8721-50"
"mainUid": "8e4c-50"
},
"8721-53": {
"8e4c-53": {
"renderedLength": 1706,
"gzipLength": 575,
"brotliLength": 0,
"mainUid": "8721-52"
"mainUid": "8e4c-52"
},
"8721-55": {
"renderedLength": 43166,
"gzipLength": 10022,
"8e4c-55": {
"renderedLength": 43167,
"gzipLength": 10023,
"brotliLength": 0,
"mainUid": "8721-54"
"mainUid": "8e4c-54"
},
"8721-57": {
"8e4c-57": {
"renderedLength": 4194,
"gzipLength": 1183,
"brotliLength": 0,
"mainUid": "8721-56"
"mainUid": "8e4c-56"
},
"8721-59": {
"8e4c-59": {
"renderedLength": 640,
"gzipLength": 309,
"brotliLength": 0,
"mainUid": "8721-58"
"mainUid": "8e4c-58"
},
"8721-61": {
"8e4c-61": {
"renderedLength": 0,
"gzipLength": 0,
"brotliLength": 0,
"mainUid": "8721-60"
"mainUid": "8e4c-60"
}
},
"nodeMetas": {
"8721-34": {
"8e4c-34": {
"id": "/packages/history/build/esm/index.js",
"moduleParts": {
"index.production.js": "8721-35"
"index.production.js": "8e4c-35"
},

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

{
"uid": "8721-60"
"uid": "8e4c-60"
},
{
"uid": "8721-54"
"uid": "8e4c-54"
}
]
},
"8721-36": {
"8e4c-36": {
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
"moduleParts": {
"index.production.js": "8721-37"
"index.production.js": "8e4c-37"
},

@@ -200,16 +200,16 @@ "imported": [],

{
"uid": "8721-60"
"uid": "8e4c-60"
},
{
"uid": "8721-46"
"uid": "8e4c-46"
},
{
"uid": "8721-54"
"uid": "8e4c-54"
}
]
},
"8721-38": {
"8e4c-38": {
"id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
"moduleParts": {
"index.production.js": "8721-39"
"index.production.js": "8e4c-39"
},

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

{
"uid": "8721-60"
"uid": "8e4c-60"
}
]
},
"8721-40": {
"8e4c-40": {
"id": "/packages/router-core/src/utils.ts",
"moduleParts": {
"index.production.js": "8721-41"
"index.production.js": "8e4c-41"
},

@@ -232,20 +232,20 @@ "imported": [],

{
"uid": "8721-60"
"uid": "8e4c-60"
},
{
"uid": "8721-42"
"uid": "8e4c-42"
},
{
"uid": "8721-54"
"uid": "8e4c-54"
}
]
},
"8721-42": {
"8e4c-42": {
"id": "/packages/router-core/src/path.ts",
"moduleParts": {
"index.production.js": "8721-43"
"index.production.js": "8e4c-43"
},
"imported": [
{
"uid": "8721-40"
"uid": "8e4c-40"
}

@@ -255,16 +255,16 @@ ],

{
"uid": "8721-60"
"uid": "8e4c-60"
},
{
"uid": "8721-46"
"uid": "8e4c-46"
},
{
"uid": "8721-54"
"uid": "8e4c-54"
}
]
},
"8721-44": {
"8e4c-44": {
"id": "/packages/router-core/src/qss.ts",
"moduleParts": {
"index.production.js": "8721-45"
"index.production.js": "8e4c-45"
},

@@ -274,20 +274,20 @@ "imported": [],

{
"uid": "8721-60"
"uid": "8e4c-60"
},
{
"uid": "8721-52"
"uid": "8e4c-52"
}
]
},
"8721-46": {
"8e4c-46": {
"id": "/packages/router-core/src/route.ts",
"moduleParts": {
"index.production.js": "8721-47"
"index.production.js": "8e4c-47"
},
"imported": [
{
"uid": "8721-36"
"uid": "8e4c-36"
},
{
"uid": "8721-42"
"uid": "8e4c-42"
}

@@ -297,17 +297,17 @@ ],

{
"uid": "8721-60"
"uid": "8e4c-60"
},
{
"uid": "8721-48"
"uid": "8e4c-48"
}
]
},
"8721-48": {
"8e4c-48": {
"id": "/packages/router-core/src/fileRoute.ts",
"moduleParts": {
"index.production.js": "8721-49"
"index.production.js": "8e4c-49"
},
"imported": [
{
"uid": "8721-46"
"uid": "8e4c-46"
}

@@ -317,10 +317,10 @@ ],

{
"uid": "8721-60"
"uid": "8e4c-60"
}
]
},
"8721-50": {
"8e4c-50": {
"id": "/node_modules/.pnpm/@tanstack+store@0.0.1/node_modules/@tanstack/store/build/esm/index.js",
"moduleParts": {
"index.production.js": "8721-51"
"index.production.js": "8e4c-51"
},

@@ -330,14 +330,14 @@ "imported": [],

{
"uid": "8721-54"
"uid": "8e4c-54"
}
]
},
"8721-52": {
"8e4c-52": {
"id": "/packages/router-core/src/searchParams.ts",
"moduleParts": {
"index.production.js": "8721-53"
"index.production.js": "8e4c-53"
},
"imported": [
{
"uid": "8721-44"
"uid": "8e4c-44"
}

@@ -347,32 +347,32 @@ ],

{
"uid": "8721-60"
"uid": "8e4c-60"
},
{
"uid": "8721-54"
"uid": "8e4c-54"
}
]
},
"8721-54": {
"8e4c-54": {
"id": "/packages/router-core/src/router.ts",
"moduleParts": {
"index.production.js": "8721-55"
"index.production.js": "8e4c-55"
},
"imported": [
{
"uid": "8721-50"
"uid": "8e4c-50"
},
{
"uid": "8721-36"
"uid": "8e4c-36"
},
{
"uid": "8721-34"
"uid": "8e4c-34"
},
{
"uid": "8721-42"
"uid": "8e4c-42"
},
{
"uid": "8721-52"
"uid": "8e4c-52"
},
{
"uid": "8721-40"
"uid": "8e4c-40"
}

@@ -382,10 +382,10 @@ ],

{
"uid": "8721-60"
"uid": "8e4c-60"
}
]
},
"8721-56": {
"8e4c-56": {
"id": "/packages/router-core/src/scroll-restoration.ts",
"moduleParts": {
"index.production.js": "8721-57"
"index.production.js": "8e4c-57"
},

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

{
"uid": "8721-60"
"uid": "8e4c-60"
}
]
},
"8721-58": {
"8e4c-58": {
"id": "/packages/router-core/src/defer.ts",
"moduleParts": {
"index.production.js": "8721-59"
"index.production.js": "8e4c-59"
},

@@ -408,53 +408,53 @@ "imported": [],

{
"uid": "8721-60"
"uid": "8e4c-60"
}
]
},
"8721-60": {
"8e4c-60": {
"id": "/packages/router-core/src/index.ts",
"moduleParts": {
"index.production.js": "8721-61"
"index.production.js": "8e4c-61"
},
"imported": [
{
"uid": "8721-34"
"uid": "8e4c-34"
},
{
"uid": "8721-36"
"uid": "8e4c-36"
},
{
"uid": "8721-38"
"uid": "8e4c-38"
},
{
"uid": "8721-62"
"uid": "8e4c-62"
},
{
"uid": "8721-42"
"uid": "8e4c-42"
},
{
"uid": "8721-44"
"uid": "8e4c-44"
},
{
"uid": "8721-46"
"uid": "8e4c-46"
},
{
"uid": "8721-48"
"uid": "8e4c-48"
},
{
"uid": "8721-63"
"uid": "8e4c-63"
},
{
"uid": "8721-54"
"uid": "8e4c-54"
},
{
"uid": "8721-52"
"uid": "8e4c-52"
},
{
"uid": "8721-40"
"uid": "8e4c-40"
},
{
"uid": "8721-56"
"uid": "8e4c-56"
},
{
"uid": "8721-58"
"uid": "8e4c-58"
}

@@ -465,3 +465,3 @@ ],

},
"8721-62": {
"8e4c-62": {
"id": "/packages/router-core/src/link.ts",

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

{
"uid": "8721-60"
"uid": "8e4c-60"
}
]
},
"8721-63": {
"8e4c-63": {
"id": "/packages/router-core/src/routeInfo.ts",

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

{
"uid": "8721-60"
"uid": "8e4c-60"
}

@@ -486,0 +486,0 @@ ]

@@ -32,3 +32,3 @@ /**

*/
class k{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 s=this.state;this.state=this.options?.updateFn?this.options.updateFn(s)(t):t(s);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()}}const T=H(JSON.parse),j=F(JSON.stringify,JSON.parse);function H(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let s=D(e);for(let e in s){const o=s[e];if("string"==typeof o)try{s[e]=t(o)}catch(t){}}return s}}function F(t,e){return s=>{(s={...s})&&Object.keys(s).forEach((o=>{const r=s[o];void 0===r||void 0===r?delete s[o]:s[o]=function(s){if("object"==typeof s&&null!==s)try{return t(s)}catch(t){}else if("string"==typeof s&&"function"==typeof e)try{return e(s),t(s)}catch(t){}return s}(r)}));const o=A(s).toString();return o?`?${o}`:""}}const N=["component","errorComponent","pendingComponent"],K="visibilitychange",U="focus",Y="Error preloading route! ☝️";const J="undefined"==typeof window||!window.document.createElement;function W(){return{status:"idle",isFetching:!1,resolvedLocation:null,location:null,matchesById:{},matchIds:[],pendingMatchIds:[],matches:[],pendingMatches:[],renderedMatchIds:[],renderedMatches:[],lastUpdated:Date.now()}}function X(t){return!!t?.isRedirect}class z extends Error{}class q extends Error{}function V(t,e){const s=Date.now();return!!t.invalid||(e?.preload?!(t.preloadMaxAge<0)&&t.updatedAt+t.preloadMaxAge<s:!(t.maxAge<0)&&t.updatedAt+t.maxAge<s)}const G="window",Q="___";let Z,tt={},et=!1;const st="undefined"!=typeof window&&window.sessionStorage,ot=t=>t.state.key;t.FileRoute=class{constructor(t){this.path=t}createRoute=t=>{const e=new C(t);return e.isRoot=!1,e}},t.PathParamError=q,t.RootRoute=$,t.Route=C,t.Router=class{#t;resetNextScroll=!1;tempLocationKey=`${Math.round(1e7*Math.random())}`;constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??j,parseSearch:t?.parseSearch??T},this.__store=new k(W(),{onUpdate:()=>{const t=this.state,e=this.__store.state,s=t.matchesById!==e.matchesById;let o,r;if(s||(o=t.matchIds.length!==e.matchIds.length||t.matchIds.some(((t,s)=>t!==e.matchIds[s])),r=t.pendingMatchIds.length!==e.pendingMatchIds.length||t.pendingMatchIds.some(((t,s)=>t!==e.pendingMatchIds[s]))),(s||o)&&(e.matches=e.matchIds.map((t=>e.matchesById[t]))),(s||r)&&(e.pendingMatches=e.pendingMatchIds.map((t=>e.matchesById[t]))),s||o||r){const t=e.pendingMatches.some((t=>!!this.getRoute(t.routeId)?.options.pendingComponent));e.renderedMatchIds=t?e.pendingMatchIds:e.matchIds,e.renderedMatches=e.renderedMatchIds.map((t=>e.matchesById[t]))}e.isFetching=[...e.matches,...e.pendingMatches].some((t=>t.isFetching)),this.state=e},defaultPriority:"low"}),this.state=this.__store.state,this.update(t);const e=this.buildLocation({search:!0,params:!0,hash:!0,state:!0});this.state.location.href!==e.href&&this.#e({...e,replace:!0})}subscribers=new Set;subscribe=(t,e)=>{const s={eventType:t,fn:e};return this.subscribers.add(s),()=>{this.subscribers.delete(s)}};#s=t=>{this.subscribers.forEach((e=>{e.eventType===t.type&&e.fn(t)}))};reset=()=>{this.__store.setState((t=>Object.assign(t,W())))};mount=()=>("undefined"!=typeof window&&window.addEventListener&&(window.addEventListener(K,this.#o,!1),window.addEventListener(U,this.#o,!1)),this.safeLoad(),()=>{"undefined"!=typeof window&&window.removeEventListener&&(window.removeEventListener(K,this.#o),window.removeEventListener(U,this.#o))});#o=()=>{(this.options.reloadOnWindowFocus??1)&&this.invalidate({__fromFocus:!0})};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??(J?h():c());const t=this.#r();this.__store.setState((e=>({...e,resolvedLocation:t,location:t}))),this.#t=this.history.subscribe((()=>{this.safeLoad({next:this.#r(this.state.location)})}))}const{basepath:e,routeTree:s}=this.options;return this.basepath=`/${I(e??"")??""}`,s&&s!==this.routeTree&&this.#a(s),this};cancelMatches=()=>{this.state.matches.forEach((t=>{this.cancelMatch(t.id)}))};cancelMatch=t=>{this.getRouteMatch(t)?.abortController?.abort()};safeLoad=async t=>{try{return this.load(t)}catch(t){}};latestLoadPromise=Promise.resolve();load=async t=>{const e=new Promise((async(s,o)=>{const r=this.state.resolvedLocation,a=!(!t?.next||r.href===t.next.href);let n;const i=()=>this.latestLoadPromise!==e?this.latestLoadPromise:void 0;let c;this.#s({type:"onBeforeLoad",from:r,to:t?.next??this.state.location,pathChanged:a}),this.__store.batch((()=>{t?.next&&this.__store.setState((e=>({...e,location:t.next}))),c=this.matchRoutes(this.state.location.pathname,this.state.location.search,{throwOnError:t?.throwOnError,debug:!0}),this.__store.setState((t=>({...t,status:"pending",pendingMatchIds:c.map((t=>t.id)),matchesById:this.#n(t.matchesById,c)})))}));try{try{await this.loadMatches(c.map((t=>t.id)))}catch(t){}if(n=i())return n;const t=this.state.matchIds.filter((t=>!this.state.pendingMatchIds.includes(t))),e=this.state.pendingMatchIds.filter((t=>!this.state.matchIds.includes(t))),o=this.state.matchIds.filter((t=>this.state.pendingMatchIds.includes(t)));this.__store.setState((t=>({...t,status:"idle",resolvedLocation:t.location,matchIds:t.pendingMatchIds,pendingMatchIds:[]}))),[[t,"onLeave"],[e,"onEnter"],[o,"onTransition"]].forEach((([t,e])=>{t.forEach((t=>{const s=this.getRouteMatch(t);this.getRoute(s.routeId).options[e]?.(s)}))})),this.#s({type:"onLoad",from:r,to:this.state.location,pathChanged:a}),s()}catch(t){if(n=i())return n;o(t)}}));return this.latestLoadPromise=e,this.latestLoadPromise.then((()=>{this.cleanMatches()})),this.latestLoadPromise};#n=(t,e)=>{let s={...t};return e.forEach((t=>{s[t.id]||(s[t.id]=t),s[t.id]={...s[t.id],...t}})),s};getRoute=t=>{const e=this.routesById[t];return u(e),e};preloadRoute=async(t=this.state.location)=>{let e=this.buildLocation(t);const s=this.matchRoutes(e.pathname,e.search,{throwOnError:!0});return this.__store.setState((t=>({...t,matchesById:this.#n(t.matchesById,s)}))),await this.loadMatches(s.map((t=>t.id)),{preload:!0,maxAge:t.maxAge}),[p(s),s]};cleanMatches=()=>{const t=Date.now(),e=Object.values(this.state.matchesById).filter((e=>{const s=this.getRoute(e.routeId);return!(this.state.matchIds.includes(e.id)||this.state.pendingMatchIds.includes(e.id)||e.preloadMaxAge>-1&&!(e.updatedAt+e.preloadMaxAge<t)||s.options.gcMaxAge&&!(e.updatedAt+s.options.gcMaxAge<t))})).map((t=>t.id));e.length&&this.__store.setState((t=>{const s={...t.matchesById};return e.forEach((t=>{delete s[t]})),{...t,matchesById:s}}))};matchRoutes=(t,e,s)=>{let o={},r=this.flatRoutes.find((e=>{const s=L(this.basepath,R(t),{to:e.fullPath,caseSensitive:e.options.caseSensitive??this.options.caseSensitive});return!!s&&(o=s,!0)}))||this.routesById.__root__,a=[r];for(;r?.parentRoute;)r=r.parentRoute,r&&a.unshift(r);const n=a.map((t=>{let e;if(t.options.parseParams)try{const e=t.options.parseParams(o);Object.assign(o,e)}catch(t){if(e=new q(t.message,{cause:t}),s?.throwOnError)throw e;return e}})),i=a.map(((t,s)=>{const r=E(t.path,o),a=t.options.loaderContext?t.options.loaderContext({search:e}):void 0,i=JSON.stringify([E(t.id,o,!0),a].filter((t=>void 0!==t)),((e,s)=>("function"==typeof s&&(console.info(t),u(!1)),"object"==typeof s&&null!==s?Object.fromEntries(Object.keys(s).sort().map((t=>[t,s[t]]))):s))),c=this.getRouteMatch(i);if(c)return{...c};const h=!(!t.options.loader&&!N.some((e=>t.options[e]?.preload)));return{id:i,loaderContext:a,routeId:t.id,params:o,pathname:_([this.basepath,r]),updatedAt:Date.now(),maxAge:-1,preloadMaxAge:-1,routeSearch:{},search:{},status:h?"pending":"success",isFetching:!1,invalid:!1,error:void 0,paramsError:n[s],searchError:void 0,loaderData:void 0,loadPromise:Promise.resolve(),context:void 0,abortController:new AbortController,fetchedAt:0}}));return i.forEach(((t,o)=>{const r=i[o-1],a=this.getRoute(t.routeId),n=(()=>{const o={search:r?.search??e,routeSearch:r?.routeSearch??e};try{let e=("object"==typeof a.options.validateSearch?a.options.validateSearch.parse:a.options.validateSearch)?.(o.search)??{},s={...o.search,...e};return e=y(t.routeSearch,e),s=y(t.search,s),{routeSearch:e,search:s,searchDidChange:t.routeSearch!==e}}catch(e){if(t.searchError=new z(e.message,{cause:e}),s?.throwOnError)throw t.searchError;return o}})();Object.assign(t,n)})),i};loadMatches=async(t,e)=>{const s=()=>t.map((t=>this.getRouteMatch(t)));let o;e?.preload||s().forEach((t=>{this.setRouteMatch(t.id,(e=>({...e,routeSearch:t.routeSearch,search:t.search,context:t.context,error:t.error,paramsError:t.paramsError,searchError:t.searchError,params:t.params,preloadMaxAge:0})))}));try{for(const[t,r]of s().entries()){const a=s()[t-1],n=this.getRoute(r.routeId),i=(e,s)=>{if(e.routerCode=s,o=o??t,X(e))throw e;try{n.options.onError?.(e)}catch(t){if(e=t,X(t))throw t}this.setRouteMatch(r.id,(t=>({...t,error:e,status:"error",updatedAt:Date.now()})))};r.paramsError&&i(r.paramsError,"PARSE_PARAMS"),r.searchError&&i(r.searchError,"VALIDATE_SEARCH");let c=!1;const h=a?.context??this?.options.context??{};try{const t=await(n.options.beforeLoad?.({abortController:r.abortController,params:r.params,preload:!!e?.preload,context:{...h,...r.loaderContext}}))??{},s={...h,...r.loaderContext,...t};this.setRouteMatch(r.id,(t=>({...t,context:y(t.context,s)})))}catch(t){i(t,"BEFORE_LOAD"),c=!0}if(c)break}}catch(t){if(X(t))return void(e?.preload||this.navigate(t));throw t}const r=s().slice(0,o),a=[];r.forEach(((t,s)=>{a.push((async()=>{const o=a[s-1],r=this.getRoute(t.routeId);if(t.isFetching||"success"===t.status&&!V(t,{preload:e?.preload}))return this.getRouteMatch(t.id)?.loadPromise;const n=Date.now(),i=()=>{const e=this.getRouteMatch(t.id);return e&&e.fetchedAt!==n?e.loadPromise:void 0},c=t=>!!X(t)&&(e?.preload||this.navigate(t),!0),h=async()=>{let s;try{const a=Promise.all(N.map((async t=>{const e=r.options[t];e?.preload&&await e.preload()}))),n=r.options.loader?.({params:t.params,preload:!!e?.preload,parentMatchPromise:o,abortController:t.abortController,context:t.context}),[c,h]=await Promise.all([a,n]);if(s=i())return await s;this.setRouteMatchData(t.id,(()=>h),e)}catch(e){if(s=i())return await s;if(c(e))return;try{r.options.onError?.(e)}catch(t){if(e=t,c(t))return}this.setRouteMatch(t.id,(t=>({...t,error:e,status:"error",isFetching:!1,updatedAt:Date.now()})))}};let d;this.__store.batch((()=>{this.setRouteMatch(t.id,(t=>({...t,isFetching:!0,fetchedAt:n,invalid:!1}))),d=h(),this.setRouteMatch(t.id,(t=>({...t,loadPromise:d})))})),await d})())})),await Promise.all(a)};resolvePath=(t,e)=>M(this.basepath,t,b(e));navigate=async({from:t,to:e="",...s})=>{const o=String(e),r=void 0===t?t:String(t);let a;try{new URL(`${o}`),a=!0}catch(t){}return u(!a),this.#i({...s,from:r,to:o})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const s=this.buildLocation(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 r=L(this.basepath,o.pathname,{...e,to:s.pathname});return!!r&&(e?.includeSearch??1?!!v(o.search,s.search)&&r:r)};buildLink=t=>{const{to:e,preload:s,preloadDelay:o,activeOptions:r,disabled:a,target:n,replace:i,resetScroll:c}=t;try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const h=t,d=this.buildLocation(h),l=s??this.options.defaultPreload,u=o??this.options.defaultPreloadDelay??0,p=this.state.location.pathname.split("/"),f=d.pathname.split("/").every(((t,e)=>t===p[e])),m=r?.exact?this.state.location.pathname===d.pathname:f,y=!r?.includeHash||this.state.location.hash===d.hash,g=!(r?.includeSearch??1)||v(this.state.location.search,d.search);return{type:"internal",next:d,handleFocus:t=>{l&&this.preloadRoute(h).catch((t=>{console.warn(t),console.warn(Y)}))},handleClick:t=>{a||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||n&&"_self"!==n||0!==t.button||(t.preventDefault(),this.#e({...d,replace:i,resetScroll:c}))},handleEnter:t=>{const e=t.target||{};if(l){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(h).catch((t=>{console.warn(t),console.warn(Y)}))}),u)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(h).catch((t=>{console.warn(t),console.warn(Y)}))},isActive:m&&y&&g,disabled:a}};dehydrate=()=>({state:{matchIds:this.state.matchIds,dehydratedMatches:this.state.matches.map((t=>m(t,["fetchedAt","invalid","preloadMaxAge","maxAge","id","loaderData","status","updatedAt"])))}});hydrate=async t=>{let e=t;"undefined"!=typeof document&&(e=window.__TSR_DEHYDRATED__),u(e);const s=e;this.dehydratedData=s.payload,this.options.hydrate?.(s.payload);const o=s.router.state;let r=this.matchRoutes(this.state.location.pathname,this.state.location.search).map((t=>{const e=o.dehydratedMatches.find((e=>e.id===t.id));return u(e,t.id),e?{...t,...e}:t}));this.__store.setState((t=>({...t,matchIds:o.matchIds,matches:r,matchesById:this.#n(t.matchesById,r)})))};injectedHtml=[];injectHtml=async t=>{this.injectedHtml.push(t)};dehydrateData=(t,e)=>{if("undefined"==typeof document){const s="string"==typeof t?t:JSON.stringify(t);return this.injectHtml((async()=>{const t=`__TSR_DEHYDRATED__${s}`,o="function"==typeof e?await e():e;return`<script id='${t}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${r=s,r.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 r})),()=>this.hydrateData(t)}return()=>{}};hydrateData=t=>{if("undefined"!=typeof document){const e="string"==typeof t?t:JSON.stringify(t);return window[`__TSR_DEHYDRATED__${e}`]}};#a=t=>{this.routeTree=t,this.routesById={},this.routesByPath={},this.flatRoutes=[];const e=t=>{t.forEach(((t,s)=>{t.init({originalIndex:s,router:this});if(u(!this.routesById[t.id],String(t.id)),this.routesById[t.id]=t,!t.isRoot&&t.path){const e=R(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 s=I(t.fullPath),o=x(s);for(;o.length>1&&"/"===o[0]?.value;)o.shift();const r=o.map((t=>"param"===t.type?.5:"wildcard"===t.type?.25:1));return{child:t,trimmed:s,parsed:o,index:e,score:r}})).sort(((t,e)=>{let s="/"===t.trimmed?1:"/"===e.trimmed?-1:0;if(0!==s)return s;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 s=0;s<o;s++)if(t.score[s]!==e.score[s])return e.score[s]-t.score[s];for(let s=0;s<o;s++)if(t.parsed[s].value!==e.parsed[s].value)return t.parsed[s].value>e.parsed[s].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=>{const e=({pathname:e,search:s,hash:o,state:r})=>{const a=this.options.parseSearch(s);return{pathname:e,searchStr:s,search:y(t?.search,a),hash:o.split("#").reverse()[0]??"",href:`${e}${s}${o}`,state:y(t?.state,r)}},s=e(this.history.location);let{__tempLocation:o,__tempKey:r}=s.state;if(o&&(!r||r===this.tempLocationKey)){const t=e(o);return t.state.key=s.state.key,delete t.state.__tempLocation,{...t,maskedLocation:s}}return s};buildLocation=(t={})=>{const e=(t={},e)=>{const s=this.state.location,o=t.from??s.pathname;let r=M(this.basepath??"/",o,`${t.to??""}`);const a=this.matchRoutes(o,s.search),n=e?.filter((t=>a?.find((e=>e.routeId===t.routeId)))),i={...p(a)?.params};let c=!0===(t.params??!0)?i:f(t.params,i);c&&e?.map((t=>this.getRoute(t.routeId).options.stringifyParams)).filter(Boolean).forEach((t=>{c={...c,...t(c)}})),r=E(r,c??{});const h=n?.map((t=>this.getRoute(t.routeId).options.preSearchFilters??[])).flat().filter(Boolean)??[],d=n?.map((t=>this.getRoute(t.routeId).options.postSearchFilters??[])).flat().filter(Boolean)??[],l=h?.length?h?.reduce(((t,e)=>e(t)),s.search):s.search,u=!0===t.search?l:t.search?f(t.search,l)??{}:h?.length?l:{},m=d?.length?d.reduce(((t,e)=>e(t)),u):u,g=y(s.search,m),w=this.options.stringifySearch(g),v=!0===t.hash?s.hash:t.hash?f(t.hash,s.hash):s.hash,_=v?`#${v}`:"";let b=!0===t.state?s.state:t.state?f(t.state,s.state):s.state;return b=y(s.state,b),{pathname:r,search:g,searchStr:w,state:b,hash:v,href:this.history.createHref(`${r}${w}${_}`),unmaskOnReload:t.unmaskOnReload}},s=(t={},s)=>{let o=e(t),r=s?e(s):void 0;if(!r){let t={},a=this.options.routeMasks?.find((e=>{const s=L(this.basepath,o.pathname,{to:e.from,fuzzy:!1});return!!s&&(t=s,!0)}));a&&(a={...a,from:E(a.from,t)},r=e(s=a))}const a=this.matchRoutes(o.pathname,o.search),n=r?this.matchRoutes(r.pathname,r.search):void 0,i=r?e(s,n):void 0,c=e(t,a);return i&&(c.maskedLocation=i),c};return t.mask?s(t,{...m(t,["from"]),...t.mask}):s(t)};#i=({replace:t,resetScroll:e,...s}={})=>{const o=this.buildLocation(s);return this.#e({...o,replace:t,resetScroll:e})};#e=async t=>{this.navigateTimeout&&clearTimeout(this.navigateTimeout);if(!(this.state.location.href===t.href)||t.replace){let{maskedLocation:e,...s}=t;e&&(s={...e,state:{...e.state,__tempKey:void 0,__tempLocation:{...s,search:s.searchStr,state:{...s.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(s.unmaskOnReload??this.options.unmaskOnReload)&&(s.state.__tempKey=this.tempLocationKey)),this.history[t.replace?"replace":"push"](s.href,s.state)}return this.resetNextScroll=t.resetScroll??!0,this.latestLoadPromise};getRouteMatch=t=>this.state.matchesById[t];setRouteMatch=(t,e)=>{this.__store.setState((s=>s.matchesById[t]?{...s,matchesById:{...s.matchesById,[t]:e(s.matchesById[t])}}:s))};setRouteMatchData=(t,e,s)=>{const o=this.getRouteMatch(t);if(!o)return;const r=this.getRoute(o.routeId),a=s?.updatedAt??Date.now(),n=s?.maxAge??r.options.preloadMaxAge??this.options.defaultPreloadMaxAge??5e3,i=s?.maxAge??r.options.maxAge??this.options.defaultMaxAge??-1;this.setRouteMatch(t,(t=>({...t,error:void 0,status:"success",isFetching:!1,updatedAt:a,loaderData:f(e,t.loaderData),preloadMaxAge:n,maxAge:i})))};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)),s=this.state.matches[e+1];if(s)return this.invalidate({matchId:s.id,reload:!1,__fromFocus:t.__fromFocus})}else this.__store.batch((()=>{Object.values(this.state.matchesById).forEach((e=>{const s=this.getRoute(e.routeId);(!t?.__fromFocus||(s.options.reloadOnWindowFocus??!0))&&this.setRouteMatch(e.id,(t=>({...t,invalid:!0})))}))}));if(t?.reload??1)return this.load()}},t.RouterContext=class{constructor(){}createRootRoute=t=>new $(t)},t.SearchParamError=z,t.cleanPath=b,t.componentTypes=N,t.createBrowserHistory=c,t.createHashHistory=function(){return c({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=h,t.createRouteMask=function(t){return t},t.decode=D,t.defaultParseSearch=T,t.defaultStringifySearch=j,t.defer=function(t){const e=t;if(!e.__deferredState){e.__deferredState={uid:Math.random().toString(36).slice(2),status:"pending"};const t=e.__deferredState;e.then((e=>{t.status="success",t.data=e})).catch((e=>{t.status="error",t.error=e}))}return e},t.encode=A,t.functionalUpdate=f,t.interpolatePath=E,t.invariant=u,t.isDehydratedDeferred=function(t){return"object"==typeof t&&null!==t&&!(t instanceof Promise)&&!t.then&&"__deferredState"in t},t.isMatchInvalid=V,t.isPlainObject=g,t.isRedirect=X,t.joinPaths=_,t.last=p,t.lazyFn=function(t,e){return async(...s)=>(await t())[e||"default"](...s)},t.matchByPath=P,t.matchPathname=L,t.parsePathname=x,t.parseSearchWith=H,t.partialDeepEqual=v,t.pick=m,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=y,t.resolvePath=M,t.restoreScrollPositions=function(t,e){if(et){if(!t.resetNextScroll)return;et=!1;const s=(e?.getKey||ot)(t.state.location);let o=!1;for(const t in Z.current){const e=Z.current[t],[r,a]=t.split(Q);if(r===s)if(a===G)o=!0,window.scrollTo(e.scrollX,e.scrollY);else if(a){const t=document.querySelector(a);t&&(t.scrollLeft=e.scrollX,t.scrollTop=e.scrollY)}}o||window.scrollTo(0,0)}},t.rootRouteId=B,t.stringifySearchWith=F,t.trimPath=I,t.trimPathLeft=S,t.trimPathRight=R,t.warning=function(t,e){},t.watchScrollPositions=function(t,e){const s=e?.getKey||ot;st&&(Z||(Z=(()=>{const t="tsr-scroll-restoration-v1",e=JSON.parse(window.sessionStorage.getItem(t)||"{}");return{current:e,set:(s,o)=>{e[s]=o,window.sessionStorage.setItem(t,JSON.stringify(Z))}}})()));const{history:o}=window;o.scrollRestoration&&(o.scrollRestoration="manual");const r=e=>{const o=s(t.state.resolvedLocation);tt[o]||(tt[o]=new WeakSet);const r=tt[o];if(r.has(e.target))return;r.add(e.target);const n=[o,e.target===document||e.target===window?G:a(e.target)].join(Q);Z.current[n]||Z.set(n,{scrollX:NaN,scrollY:NaN})},a=t=>{let e,s=[];for(;e=t.parentNode;)s.unshift(`${t.tagName}:nth-child(${[].indexOf.call(e.children,t)+1})`),t=e;return`${s.join(" > ")}`.toLowerCase()};"undefined"!=typeof document&&document.addEventListener("scroll",r,!0);const n=t.subscribe("onBeforeLoad",(t=>{t.pathChanged&&(t=>{const e=s(t);for(const t in Z.current){const s=Z.current[t],[o,r]=t.split(Q);if(e===o){if(r===G)s.scrollX=window.scrollX||0,s.scrollY=window.scrollY||0;else if(r){const t=document.querySelector(r);s.scrollX=t?.scrollLeft||0,s.scrollY=t?.scrollTop||0}Z.set(t,s)}}})(t.from)})),i=t.subscribe("onLoad",(t=>{t.pathChanged&&(et=!0)}));return()=>{document.removeEventListener("scroll",r),n(),i()}},Object.defineProperty(t,"__esModule",{value:!0})}));
class k{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 s=this.state;this.state=this.options?.updateFn?this.options.updateFn(s)(t):t(s);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()}}const T=H(JSON.parse),j=F(JSON.stringify,JSON.parse);function H(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let s=D(e);for(let e in s){const o=s[e];if("string"==typeof o)try{s[e]=t(o)}catch(t){}}return s}}function F(t,e){return s=>{(s={...s})&&Object.keys(s).forEach((o=>{const r=s[o];void 0===r||void 0===r?delete s[o]:s[o]=function(s){if("object"==typeof s&&null!==s)try{return t(s)}catch(t){}else if("string"==typeof s&&"function"==typeof e)try{return e(s),t(s)}catch(t){}return s}(r)}));const o=A(s).toString();return o?`?${o}`:""}}const N=["component","errorComponent","pendingComponent"],K="visibilitychange",U="focus",Y="Error preloading route! ☝️";const J="undefined"==typeof window||!window.document.createElement;function W(){return{status:"idle",isFetching:!1,resolvedLocation:null,location:null,matchesById:{},matchIds:[],pendingMatchIds:[],matches:[],pendingMatches:[],renderedMatchIds:[],renderedMatches:[],lastUpdated:Date.now()}}function X(t){return!!t?.isRedirect}class z extends Error{}class q extends Error{}function V(t,e){const s=Date.now();return!!t.invalid||(e?.preload?!(t.preloadMaxAge<0)&&t.updatedAt+t.preloadMaxAge<s:!(t.maxAge<0)&&t.updatedAt+t.maxAge<s)}const G="window",Q="___";let Z,tt={},et=!1;const st="undefined"!=typeof window&&window.sessionStorage,ot=t=>t.state.key;t.FileRoute=class{constructor(t){this.path=t}createRoute=t=>{const e=new C(t);return e.isRoot=!1,e}},t.PathParamError=q,t.RootRoute=$,t.Route=C,t.Router=class{#t;resetNextScroll=!1;tempLocationKey=`${Math.round(1e7*Math.random())}`;constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??j,parseSearch:t?.parseSearch??T},this.__store=new k(W(),{onUpdate:()=>{const t=this.state,e=this.__store.state,s=t.matchesById!==e.matchesById;let o,r;if(s||(o=t.matchIds.length!==e.matchIds.length||t.matchIds.some(((t,s)=>t!==e.matchIds[s])),r=t.pendingMatchIds.length!==e.pendingMatchIds.length||t.pendingMatchIds.some(((t,s)=>t!==e.pendingMatchIds[s]))),(s||o)&&(e.matches=e.matchIds.map((t=>e.matchesById[t]))),(s||r)&&(e.pendingMatches=e.pendingMatchIds.map((t=>e.matchesById[t]))),s||o||r){const t=e.pendingMatches.some((t=>!!this.getRoute(t.routeId)?.options.pendingComponent));e.renderedMatchIds=t?e.pendingMatchIds:e.matchIds,e.renderedMatches=e.renderedMatchIds.map((t=>e.matchesById[t]))}e.isFetching=[...e.matches,...e.pendingMatches].some((t=>t.isFetching)),this.state=e},defaultPriority:"low"}),this.state=this.__store.state,this.update(t);const e=this.buildLocation({search:!0,params:!0,hash:!0,state:!0});this.state.location.href!==e.href&&this.#e({...e,replace:!0})}subscribers=new Set;subscribe=(t,e)=>{const s={eventType:t,fn:e};return this.subscribers.add(s),()=>{this.subscribers.delete(s)}};#s=t=>{this.subscribers.forEach((e=>{e.eventType===t.type&&e.fn(t)}))};reset=()=>{this.__store.setState((t=>Object.assign(t,W())))};mount=()=>("undefined"!=typeof window&&window.addEventListener&&(window.addEventListener(K,this.#o,!1),window.addEventListener(U,this.#o,!1)),this.safeLoad(),()=>{"undefined"!=typeof window&&window.removeEventListener&&(window.removeEventListener(K,this.#o),window.removeEventListener(U,this.#o))});#o=()=>{(this.options.reloadOnWindowFocus??1)&&this.invalidate({__fromFocus:!0})};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??(J?h():c());const t=this.#r();this.__store.setState((e=>({...e,resolvedLocation:t,location:t}))),this.#t=this.history.subscribe((()=>{this.safeLoad({next:this.#r(this.state.location)})}))}const{basepath:e,routeTree:s}=this.options;return this.basepath=`/${I(e??"")??""}`,s&&s!==this.routeTree&&this.#a(s),this};cancelMatches=()=>{this.state.matches.forEach((t=>{this.cancelMatch(t.id)}))};cancelMatch=t=>{this.getRouteMatch(t)?.abortController?.abort()};safeLoad=async t=>{try{return this.load(t)}catch(t){}};latestLoadPromise=Promise.resolve();load=async t=>{const e=new Promise((async(s,o)=>{const r=this.state.resolvedLocation,a=!(!t?.next||r.href===t.next.href);let n;const i=()=>this.latestLoadPromise!==e?this.latestLoadPromise:void 0;let c;this.#s({type:"onBeforeLoad",from:r,to:t?.next??this.state.location,pathChanged:a}),this.__store.batch((()=>{t?.next&&this.__store.setState((e=>({...e,location:t.next}))),c=this.matchRoutes(this.state.location.pathname,this.state.location.search,{throwOnError:t?.throwOnError,debug:!0}),this.__store.setState((t=>({...t,status:"pending",pendingMatchIds:c.map((t=>t.id)),matchesById:this.#n(t.matchesById,c)})))}));try{try{await this.loadMatches(c.map((t=>t.id)))}catch(t){}if(n=i())return n;const t=this.state.matchIds.filter((t=>!this.state.pendingMatchIds.includes(t))),e=this.state.pendingMatchIds.filter((t=>!this.state.matchIds.includes(t))),o=this.state.matchIds.filter((t=>this.state.pendingMatchIds.includes(t)));this.__store.setState((t=>({...t,status:"idle",resolvedLocation:t.location,matchIds:t.pendingMatchIds,pendingMatchIds:[]}))),[[t,"onLeave"],[e,"onEnter"],[o,"onTransition"]].forEach((([t,e])=>{t.forEach((t=>{const s=this.getRouteMatch(t);this.getRoute(s.routeId).options[e]?.(s)}))})),this.#s({type:"onLoad",from:r,to:this.state.location,pathChanged:a}),s()}catch(t){if(n=i())return n;o(t)}}));return this.latestLoadPromise=e,this.latestLoadPromise.then((()=>{this.cleanMatches()})),this.latestLoadPromise};#n=(t,e)=>{let s={...t};return e.forEach((t=>{s[t.id]||(s[t.id]=t),s[t.id]={...s[t.id],...t}})),s};getRoute=t=>{const e=this.routesById[t];return u(e),e};preloadRoute=async(t=this.state.location)=>{let e=this.buildLocation(t);const s=this.matchRoutes(e.pathname,e.search,{throwOnError:!0});return this.__store.setState((t=>({...t,matchesById:this.#n(t.matchesById,s)}))),await this.loadMatches(s.map((t=>t.id)),{preload:!0,maxAge:t.maxAge}),[p(s),s]};cleanMatches=()=>{const t=Date.now(),e=Object.values(this.state.matchesById).filter((e=>{const s=this.getRoute(e.routeId);return!(this.state.matchIds.includes(e.id)||this.state.pendingMatchIds.includes(e.id)||e.preloadMaxAge>-1&&!(e.updatedAt+e.preloadMaxAge<t)||s.options.gcMaxAge&&!(e.updatedAt+s.options.gcMaxAge<t))})).map((t=>t.id));e.length&&this.__store.setState((t=>{const s={...t.matchesById};return e.forEach((t=>{delete s[t]})),{...t,matchesById:s}}))};matchRoutes=(t,e,s)=>{let o={},r=this.flatRoutes.find((e=>{const s=L(this.basepath,R(t),{to:e.fullPath,caseSensitive:e.options.caseSensitive??this.options.caseSensitive});return!!s&&(o=s,!0)}))||this.routesById.__root__,a=[r];for(;r?.parentRoute;)r=r.parentRoute,r&&a.unshift(r);const n=a.map((t=>{let e;if(t.options.parseParams)try{const e=t.options.parseParams(o);Object.assign(o,e)}catch(t){if(e=new q(t.message,{cause:t}),s?.throwOnError)throw e;return e}})),i=a.map(((t,s)=>{const r=E(t.path,o),a=t.options.loaderContext?t.options.loaderContext({search:e}):void 0,i=JSON.stringify([E(t.id,o,!0),a].filter((t=>void 0!==t)),((e,s)=>("function"==typeof s&&(console.info(t),u(!1)),"object"==typeof s&&null!==s?Object.fromEntries(Object.keys(s).sort().map((t=>[t,s[t]]))):s))),c=this.getRouteMatch(i);if(c)return{...c};const h=!(!t.options.loader&&!N.some((e=>t.options[e]?.preload)));return{id:i,loaderContext:a,routeId:t.id,params:o,pathname:_([this.basepath,r]),updatedAt:Date.now(),maxAge:-1,preloadMaxAge:-1,routeSearch:{},search:{},status:h?"pending":"success",isFetching:!1,invalid:!1,error:void 0,paramsError:n[s],searchError:void 0,loaderData:void 0,loadPromise:Promise.resolve(),context:void 0,abortController:new AbortController,fetchedAt:0}}));return i.forEach(((t,o)=>{const r=i[o-1],a=this.getRoute(t.routeId),n=(()=>{const o={search:r?.search??e,routeSearch:r?.routeSearch??e};try{let e=("object"==typeof a.options.validateSearch?a.options.validateSearch.parse:a.options.validateSearch)?.(o.search)??{},s={...o.search,...e};return e=y(t.routeSearch,e),s=y(t.search,s),{routeSearch:e,search:s,searchDidChange:t.routeSearch!==e}}catch(e){if(t.searchError=new z(e.message,{cause:e}),s?.throwOnError)throw t.searchError;return o}})();Object.assign(t,n)})),i};loadMatches=async(t,e)=>{const s=()=>t.map((t=>this.getRouteMatch(t)));let o;e?.preload||s().forEach((t=>{this.setRouteMatch(t.id,(e=>({...e,routeSearch:t.routeSearch,search:t.search,context:t.context,error:t.error,paramsError:t.paramsError,searchError:t.searchError,params:t.params,preloadMaxAge:0})))}));try{for(const[t,r]of s().entries()){const a=s()[t-1],n=this.getRoute(r.routeId),i=(e,s)=>{if(e.routerCode=s,o=o??t,X(e))throw e;try{n.options.onError?.(e)}catch(t){if(e=t,X(t))throw t}this.setRouteMatch(r.id,(t=>({...t,error:e,status:"error",updatedAt:Date.now()})))};r.paramsError&&i(r.paramsError,"PARSE_PARAMS"),r.searchError&&i(r.searchError,"VALIDATE_SEARCH");let c=!1;const h=a?.context??this?.options.context??{};try{const t=await(n.options.beforeLoad?.({abortController:r.abortController,params:r.params,preload:!!e?.preload,context:{...h,...r.loaderContext}}))??{},s={...h,...r.loaderContext,...t};this.setRouteMatch(r.id,(t=>({...t,context:y(t.context,s)})))}catch(t){i(t,"BEFORE_LOAD"),c=!0}if(c)break}}catch(t){if(X(t))return void(e?.preload||this.navigate(t));throw t}const r=s().slice(0,o),a=[];r.forEach(((t,s)=>{a.push((async()=>{const o=a[s-1],r=this.getRoute(t.routeId);if(t.isFetching||"success"===t.status&&!V(t,{preload:e?.preload}))return this.getRouteMatch(t.id)?.loadPromise;const n=Date.now(),i=()=>{const e=this.getRouteMatch(t.id);return e&&e.fetchedAt!==n?e.loadPromise:void 0},c=t=>!!X(t)&&(e?.preload||this.navigate(t),!0),h=async()=>{let s;try{const a=Promise.all(N.map((async t=>{const e=r.options[t];e?.preload&&await e.preload()}))),n=r.options.loader?.({params:t.params,preload:!!e?.preload,parentMatchPromise:o,abortController:t.abortController,context:t.context}),[c,h]=await Promise.all([a,n]);if(s=i())return await s;this.setRouteMatchData(t.id,(()=>h),e)}catch(e){if(s=i())return await s;if(c(e))return;try{r.options.onError?.(e)}catch(t){if(e=t,c(t))return}this.setRouteMatch(t.id,(t=>({...t,error:e,status:"error",isFetching:!1,updatedAt:Date.now()})))}};let d;this.__store.batch((()=>{this.setRouteMatch(t.id,(t=>({...t,isFetching:!0,fetchedAt:n,invalid:!1}))),d=h(),this.setRouteMatch(t.id,(t=>({...t,loadPromise:d})))})),await d})())})),await Promise.all(a)};resolvePath=(t,e)=>M(this.basepath,t,b(e));navigate=async({from:t,to:e="",...s})=>{const o=String(e),r=void 0===t?t:String(t);let a;try{new URL(`${o}`),a=!0}catch(t){}return u(!a),this.#i({...s,from:r,to:o})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const s=this.buildLocation(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 r=L(this.basepath,o.pathname,{...e,to:s.pathname});return!!r&&(e?.includeSearch??1?!!v(o.search,s.search)&&r:r)};buildLink=t=>{const{to:e,preload:s,preloadDelay:o,activeOptions:r,disabled:a,target:n,replace:i,resetScroll:c}=t;try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const h=t,d=this.buildLocation(h),l=s??this.options.defaultPreload,u=o??this.options.defaultPreloadDelay??0,p=this.state.location.pathname.split("/"),f=d.pathname.split("/").every(((t,e)=>t===p[e])),m=r?.exact?this.state.location.pathname===d.pathname:f,y=!r?.includeHash||this.state.location.hash===d.hash,g=!(r?.includeSearch??1)||v(this.state.location.search,d.search);return{type:"internal",next:d,handleFocus:t=>{l&&this.preloadRoute(h).catch((t=>{console.warn(t),console.warn(Y)}))},handleClick:t=>{a||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||n&&"_self"!==n||0!==t.button||(t.preventDefault(),this.#e({...d,replace:i,resetScroll:c}))},handleEnter:t=>{const e=t.target||{};if(l){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(h).catch((t=>{console.warn(t),console.warn(Y)}))}),u)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(h).catch((t=>{console.warn(t),console.warn(Y)}))},isActive:m&&y&&g,disabled:a}};dehydrate=()=>({state:{matchIds:this.state.matchIds,dehydratedMatches:this.state.matches.map((t=>m(t,["fetchedAt","invalid","preloadMaxAge","maxAge","id","loaderData","status","updatedAt"])))}});hydrate=async t=>{let e=t;"undefined"!=typeof document&&(e=window.__TSR_DEHYDRATED__),u(e);const s=e;this.dehydratedData=s.payload,this.options.hydrate?.(s.payload);const o=s.router.state;let r=this.matchRoutes(this.state.location.pathname,this.state.location.search).map((t=>{const e=o.dehydratedMatches.find((e=>e.id===t.id));return u(e,t.id),e?{...t,...e}:t}));this.__store.setState((t=>({...t,matchIds:o.matchIds,matches:r,matchesById:this.#n(t.matchesById,r)})))};injectedHtml=[];injectHtml=async t=>{this.injectedHtml.push(t)};dehydrateData=(t,e)=>{if("undefined"==typeof document){const s="string"==typeof t?t:JSON.stringify(t);return this.injectHtml((async()=>{const t=`__TSR_DEHYDRATED__${s}`,o="function"==typeof e?await e():e;return`<script id='${t}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${r=s,r.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 r})),()=>this.hydrateData(t)}return()=>{}};hydrateData=t=>{if("undefined"!=typeof document){const e="string"==typeof t?t:JSON.stringify(t);return window[`__TSR_DEHYDRATED__${e}`]}};#a=t=>{this.routeTree=t,this.routesById={},this.routesByPath={},this.flatRoutes=[];const e=t=>{t.forEach(((t,s)=>{t.init({originalIndex:s,router:this});if(u(!this.routesById[t.id],String(t.id)),this.routesById[t.id]=t,!t.isRoot&&t.path){const e=R(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 s=I(t.fullPath),o=x(s);for(;o.length>1&&"/"===o[0]?.value;)o.shift();const r=o.map((t=>"param"===t.type?.5:"wildcard"===t.type?.25:1));return{child:t,trimmed:s,parsed:o,index:e,score:r}})).sort(((t,e)=>{let s="/"===t.trimmed?1:"/"===e.trimmed?-1:0;if(0!==s)return s;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 s=0;s<o;s++)if(t.score[s]!==e.score[s])return e.score[s]-t.score[s];for(let s=0;s<o;s++)if(t.parsed[s].value!==e.parsed[s].value)return t.parsed[s].value>e.parsed[s].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=>{const e=({pathname:e,search:s,hash:o,state:r})=>{const a=this.options.parseSearch(s);return{pathname:e,searchStr:s,search:y(t?.search,a),hash:o.split("#").reverse()[0]??"",href:`${e}${s}${o}`,state:y(t?.state,r)}},s=e(this.history.location);let{__tempLocation:o,__tempKey:r}=s.state;if(o&&(!r||r===this.tempLocationKey)){const t=e(o);return t.state.key=s.state.key,delete t.state.__tempLocation,{...t,maskedLocation:s}}return s};buildLocation=(t={})=>{const e=(t={},e)=>{const s=this.state.location,o=t.from??s.pathname;let r=M(this.basepath??"/",o,`${t.to??""}`);const a=this.matchRoutes(o,s.search),n=e?.filter((t=>a?.find((e=>e.routeId===t.routeId)))),i={...p(a)?.params};let c=!0===(t.params??!0)?i:f(t.params,i);c&&e?.map((t=>this.getRoute(t.routeId).options.stringifyParams)).filter(Boolean).forEach((t=>{c={...c,...t(c)}})),r=E(r,c??{});const h=n?.map((t=>this.getRoute(t.routeId).options.preSearchFilters??[])).flat().filter(Boolean)??[],d=n?.map((t=>this.getRoute(t.routeId).options.postSearchFilters??[])).flat().filter(Boolean)??[],l=h?.length?h?.reduce(((t,e)=>e(t)),s.search):s.search,u=!0===t.search?l:t.search?f(t.search,l)??{}:h?.length?l:{},m=d?.length?d.reduce(((t,e)=>e(t)),u):u,g=y(s.search,m),w=this.options.stringifySearch(g),v=!0===t.hash?s.hash:t.hash?f(t.hash,s.hash):s.hash,_=v?`#${v}`:"";let b=!0===t.state?s.state:t.state?f(t.state,s.state):s.state;return b=y(s.state,b),{pathname:r,search:g,searchStr:w,state:b,hash:v,href:this.history.createHref(`${r}${w}${_}`),unmaskOnReload:t.unmaskOnReload}},s=(t={},s)=>{let o=e(t),r=s?e(s):void 0;if(!r){let t={},a=this.options.routeMasks?.find((e=>{const s=L(this.basepath,o.pathname,{to:e.from,fuzzy:!1});return!!s&&(t=s,!0)}));a&&(a={...a,from:E(a.from,t)},r=e(s=a))}const a=this.matchRoutes(o.pathname,o.search),n=r?this.matchRoutes(r.pathname,r.search):void 0,i=r?e(s,n):void 0,c=e(t,a);return i&&(c.maskedLocation=i),c};return t.mask?s(t,{...m(t,["from"]),...t.mask}):s(t)};#i=({replace:t,resetScroll:e,...s}={})=>{const o=this.buildLocation(s);return this.#e({...o,replace:t,resetScroll:e})};#e=async t=>{this.navigateTimeout&&clearTimeout(this.navigateTimeout);if(!(this.state.location.href===t.href)||!t.replace){let{maskedLocation:e,...s}=t;e&&(s={...e,state:{...e.state,__tempKey:void 0,__tempLocation:{...s,search:s.searchStr,state:{...s.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(s.unmaskOnReload??this.options.unmaskOnReload)&&(s.state.__tempKey=this.tempLocationKey)),this.history[t.replace?"replace":"push"](s.href,s.state)}return this.resetNextScroll=t.resetScroll??!0,this.latestLoadPromise};getRouteMatch=t=>this.state.matchesById[t];setRouteMatch=(t,e)=>{this.__store.setState((s=>s.matchesById[t]?{...s,matchesById:{...s.matchesById,[t]:e(s.matchesById[t])}}:s))};setRouteMatchData=(t,e,s)=>{const o=this.getRouteMatch(t);if(!o)return;const r=this.getRoute(o.routeId),a=s?.updatedAt??Date.now(),n=s?.maxAge??r.options.preloadMaxAge??this.options.defaultPreloadMaxAge??5e3,i=s?.maxAge??r.options.maxAge??this.options.defaultMaxAge??-1;this.setRouteMatch(t,(t=>({...t,error:void 0,status:"success",isFetching:!1,updatedAt:a,loaderData:f(e,t.loaderData),preloadMaxAge:n,maxAge:i})))};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)),s=this.state.matches[e+1];if(s)return this.invalidate({matchId:s.id,reload:!1,__fromFocus:t.__fromFocus})}else this.__store.batch((()=>{Object.values(this.state.matchesById).forEach((e=>{const s=this.getRoute(e.routeId);(!t?.__fromFocus||(s.options.reloadOnWindowFocus??!0))&&this.setRouteMatch(e.id,(t=>({...t,invalid:!0})))}))}));if(t?.reload??1)return this.load()}},t.RouterContext=class{constructor(){}createRootRoute=t=>new $(t)},t.SearchParamError=z,t.cleanPath=b,t.componentTypes=N,t.createBrowserHistory=c,t.createHashHistory=function(){return c({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=h,t.createRouteMask=function(t){return t},t.decode=D,t.defaultParseSearch=T,t.defaultStringifySearch=j,t.defer=function(t){const e=t;if(!e.__deferredState){e.__deferredState={uid:Math.random().toString(36).slice(2),status:"pending"};const t=e.__deferredState;e.then((e=>{t.status="success",t.data=e})).catch((e=>{t.status="error",t.error=e}))}return e},t.encode=A,t.functionalUpdate=f,t.interpolatePath=E,t.invariant=u,t.isDehydratedDeferred=function(t){return"object"==typeof t&&null!==t&&!(t instanceof Promise)&&!t.then&&"__deferredState"in t},t.isMatchInvalid=V,t.isPlainObject=g,t.isRedirect=X,t.joinPaths=_,t.last=p,t.lazyFn=function(t,e){return async(...s)=>(await t())[e||"default"](...s)},t.matchByPath=P,t.matchPathname=L,t.parsePathname=x,t.parseSearchWith=H,t.partialDeepEqual=v,t.pick=m,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=y,t.resolvePath=M,t.restoreScrollPositions=function(t,e){if(et){if(!t.resetNextScroll)return;et=!1;const s=(e?.getKey||ot)(t.state.location);let o=!1;for(const t in Z.current){const e=Z.current[t],[r,a]=t.split(Q);if(r===s)if(a===G)o=!0,window.scrollTo(e.scrollX,e.scrollY);else if(a){const t=document.querySelector(a);t&&(t.scrollLeft=e.scrollX,t.scrollTop=e.scrollY)}}o||window.scrollTo(0,0)}},t.rootRouteId=B,t.stringifySearchWith=F,t.trimPath=I,t.trimPathLeft=S,t.trimPathRight=R,t.warning=function(t,e){},t.watchScrollPositions=function(t,e){const s=e?.getKey||ot;st&&(Z||(Z=(()=>{const t="tsr-scroll-restoration-v1",e=JSON.parse(window.sessionStorage.getItem(t)||"{}");return{current:e,set:(s,o)=>{e[s]=o,window.sessionStorage.setItem(t,JSON.stringify(Z))}}})()));const{history:o}=window;o.scrollRestoration&&(o.scrollRestoration="manual");const r=e=>{const o=s(t.state.resolvedLocation);tt[o]||(tt[o]=new WeakSet);const r=tt[o];if(r.has(e.target))return;r.add(e.target);const n=[o,e.target===document||e.target===window?G:a(e.target)].join(Q);Z.current[n]||Z.set(n,{scrollX:NaN,scrollY:NaN})},a=t=>{let e,s=[];for(;e=t.parentNode;)s.unshift(`${t.tagName}:nth-child(${[].indexOf.call(e.children,t)+1})`),t=e;return`${s.join(" > ")}`.toLowerCase()};"undefined"!=typeof document&&document.addEventListener("scroll",r,!0);const n=t.subscribe("onBeforeLoad",(t=>{t.pathChanged&&(t=>{const e=s(t);for(const t in Z.current){const s=Z.current[t],[o,r]=t.split(Q);if(e===o){if(r===G)s.scrollX=window.scrollX||0,s.scrollY=window.scrollY||0;else if(r){const t=document.querySelector(r);s.scrollX=t?.scrollLeft||0,s.scrollY=t?.scrollTop||0}Z.set(t,s)}}})(t.from)})),i=t.subscribe("onLoad",(t=>{t.pathChanged&&(et=!0)}));return()=>{document.removeEventListener("scroll",r),n(),i()}},Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=index.production.js.map
{
"name": "@tanstack/router-core",
"author": "Tanner Linsley",
"version": "0.0.1-beta.203",
"version": "0.0.1-beta.204",
"license": "MIT",

@@ -47,3 +47,3 @@ "repository": "tanstack/router",

"@gisatcz/cross-package-react-context": "^0.2.0",
"@tanstack/history": "0.0.1-beta.203"
"@tanstack/history": "0.0.1-beta.204"
},

@@ -50,0 +50,0 @@ "scripts": {

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

// do nothing
if (!isSameUrl || next.replace) {
if (!isSameUrl || !next.replace) {
let { maskedLocation, ...nextHistory } = next

@@ -1865,0 +1865,0 @@

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

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