@tanstack/router-core 0.0.1-beta.19 → 0.0.1-beta.191
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/build/cjs/defer.js +39 -0
- package/build/cjs/defer.js.map +1 -0
- package/build/cjs/fileRoute.js +29 -0
- package/build/cjs/fileRoute.js.map +1 -0
- package/build/cjs/history.js +228 -0
- package/build/cjs/history.js.map +1 -0
- package/build/cjs/index.js +86 -0
- package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
- package/build/cjs/{packages/router-core/src/path.js → path.js} +45 -56
- package/build/cjs/path.js.map +1 -0
- package/build/cjs/{packages/router-core/src/qss.js → qss.js} +10 -16
- package/build/cjs/qss.js.map +1 -0
- package/build/cjs/route.js +114 -0
- package/build/cjs/route.js.map +1 -0
- package/build/cjs/router.js +1267 -0
- package/build/cjs/router.js.map +1 -0
- package/build/cjs/scroll-restoration.js +139 -0
- package/build/cjs/scroll-restoration.js.map +1 -0
- package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +32 -19
- package/build/cjs/searchParams.js.map +1 -0
- package/build/cjs/{packages/router-core/src/utils.js → utils.js} +69 -64
- package/build/cjs/utils.js.map +1 -0
- package/build/esm/index.js +1746 -2121
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +59 -49
- package/build/stats-react.json +197 -211
- package/build/types/defer.d.ts +19 -0
- package/build/types/fileRoute.d.ts +35 -0
- package/build/types/history.d.ts +36 -0
- package/build/types/index.d.ts +13 -609
- package/build/types/link.d.ts +96 -0
- package/build/types/path.d.ts +16 -0
- package/build/types/qss.d.ts +2 -0
- package/build/types/route.d.ts +251 -0
- package/build/types/routeInfo.d.ts +22 -0
- package/build/types/router.d.ts +260 -0
- package/build/types/scroll-restoration.d.ts +6 -0
- package/build/types/searchParams.d.ts +5 -0
- package/build/types/utils.d.ts +44 -0
- package/build/umd/index.development.js +1978 -2243
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +13 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +11 -7
- package/src/defer.ts +55 -0
- package/src/fileRoute.ts +161 -0
- package/src/history.ts +300 -0
- package/src/index.ts +5 -10
- package/src/link.ts +136 -125
- package/src/path.ts +37 -17
- package/src/qss.ts +1 -2
- package/src/route.ts +948 -218
- package/src/routeInfo.ts +45 -211
- package/src/router.ts +1778 -1075
- package/src/scroll-restoration.ts +179 -0
- package/src/searchParams.ts +31 -9
- package/src/utils.ts +84 -49
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
- package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
- package/build/cjs/node_modules/history/index.js +0 -815
- package/build/cjs/node_modules/history/index.js.map +0 -1
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
- package/build/cjs/packages/router-core/src/index.js +0 -58
- package/build/cjs/packages/router-core/src/path.js.map +0 -1
- package/build/cjs/packages/router-core/src/qss.js.map +0 -1
- package/build/cjs/packages/router-core/src/route.js +0 -147
- package/build/cjs/packages/router-core/src/route.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeConfig.js +0 -69
- package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
- package/build/cjs/packages/router-core/src/routeMatch.js +0 -220
- package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
- package/build/cjs/packages/router-core/src/router.js +0 -870
- package/build/cjs/packages/router-core/src/router.js.map +0 -1
- package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
- package/build/cjs/packages/router-core/src/utils.js.map +0 -1
- package/src/frameworks.ts +0 -11
- package/src/routeConfig.ts +0 -511
- package/src/routeMatch.ts +0 -312
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* router-core
|
|
2
|
+
* @tanstack/router-core/src/index.ts
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) TanStack
|
|
5
5
|
*
|
|
@@ -8,5 +8,16 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RouterCore={})}(this,(function(t){"use strict";function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},e.apply(this,arguments)}var a;!function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"}(a||(a={}));var n="beforeunload",o="popstate";function r(t){void 0===t&&(t={});var r=t.window,i=void 0===r?document.defaultView:r,s=i.history;function p(){var t=i.location,e=t.pathname,a=t.search,n=t.hash,o=s.state||{};return[o.idx,{pathname:e,search:a,hash:n,state:o.usr||null,key:o.key||"default"}]}var f=null;i.addEventListener(o,(function(){if(f)b.call(f),f=null;else{var t=a.Pop,e=p(),n=e[0],o=e[1];if(b.length){if(null!=n){var r=g-n;r&&(f={action:t,location:o,retry:function(){S(-1*r)}},S(r))}}else R(t)}}));var m=a.Pop,v=p(),g=v[0],y=v[1],_=c(),b=c();function P(t){return"string"==typeof t?t:h(t)}function w(t,a){return void 0===a&&(a=null),e({pathname:y.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function x(t,e){return[{usr:t.state,key:t.key,idx:e},P(t)]}function A(t,e,a){return!b.length||(b.call({action:t,location:e,retry:a}),!1)}function R(t){m=t;var e=p();g=e[0],y=e[1],_.call({action:m,location:y})}function S(t){s.go(t)}null==g&&(g=0,s.replaceState(e({},s.state,{idx:g}),""));var I={get action(){return m},get location(){return y},createHref:P,push:function t(e,n){var o=a.Push,r=w(e,n);if(A(o,r,(function(){t(e,n)}))){var l=x(r,g+1),c=l[0],u=l[1];try{s.pushState(c,"",u)}catch(t){i.location.assign(u)}R(o)}},replace:function t(e,n){var o=a.Replace,r=w(e,n);if(A(o,r,(function(){t(e,n)}))){var i=x(r,g),l=i[0],c=i[1];s.replaceState(l,"",c),R(o)}},go:S,back:function(){S(-1)},forward:function(){S(1)},listen:function(t){return _.push(t)},block:function(t){var e=b.push(t);return 1===b.length&&i.addEventListener(n,l),function(){e(),b.length||i.removeEventListener(n,l)}}};return I}function i(t){void 0===t&&(t={});var n=t,o=n.initialEntries,r=void 0===o?["/"]:o,i=n.initialIndex,l=r.map((function(t){return e({pathname:"/",search:"",hash:"",state:null,key:u()},"string"==typeof t?d(t):t)})),p=s(null==i?l.length-1:i,0,l.length-1),f=a.Pop,m=l[p],v=c(),g=c();function y(t,a){return void 0===a&&(a=null),e({pathname:m.pathname,search:"",hash:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function _(t,e,a){return!g.length||(g.call({action:t,location:e,retry:a}),!1)}function b(t,e){f=t,m=e,v.call({action:f,location:m})}function P(t){var e=s(p+t,0,l.length-1),n=a.Pop,o=l[e];_(n,o,(function(){P(t)}))&&(p=e,b(n,o))}var w={get index(){return p},get action(){return f},get location(){return m},createHref:function(t){return"string"==typeof t?t:h(t)},push:function t(e,n){var o=a.Push,r=y(e,n);_(o,r,(function(){t(e,n)}))&&(p+=1,l.splice(p,l.length,r),b(o,r))},replace:function t(e,n){var o=a.Replace,r=y(e,n);_(o,r,(function(){t(e,n)}))&&(l[p]=r,b(o,r))},go:P,back:function(){P(-1)},forward:function(){P(1)},listen:function(t){return v.push(t)},block:function(t){return g.push(t)}};return w}function s(t,e,a){return Math.min(Math.max(t,e),a)}function l(t){t.preventDefault(),t.returnValue=""}function c(){var t=[];return{get length(){return t.length},push:function(e){return t.push(e),function(){t=t.filter((function(t){return t!==e}))}},call:function(e){t.forEach((function(t){return t&&t(e)}))}}}function u(){return Math.random().toString(36).substr(2,8)}function h(t){var e=t.pathname,a=void 0===e?"/":e,n=t.search,o=void 0===n?"":n,r=t.hash,i=void 0===r?"":r;return o&&"?"!==o&&(a+="?"===o.charAt(0)?o:"?"+o),i&&"#"!==i&&(a+="#"===i.charAt(0)?i:"#"+i),a}function d(t){var e={};if(t){var a=t.indexOf("#");a>=0&&(e.hash=t.substr(a),t=t.substr(0,a));var n=t.indexOf("?");n>=0&&(e.search=t.substr(n),t=t.substr(0,n)),t&&(e.pathname=t)}return e}function p(t,e){if(!t)throw new Error("Invariant failed")}function f(t,e){if(t===e)return t;const a=Array.isArray(t)&&Array.isArray(e);if(a||m(t)&&m(e)){const n=a?t.length:Object.keys(t).length,o=a?e:Object.keys(e),r=o.length,i=a?[]:{};let s=0;for(let n=0;n<r;n++){const r=a?n:o[n];i[r]=f(t[r],e[r]),i[r]===t[r]&&s++}return n===r&&s===n?t:i}return e}function m(t){if(!v(t))return!1;const e=t.constructor;if(void 0===e)return!0;const a=e.prototype;return!!v(a)&&!!a.hasOwnProperty("isPrototypeOf")}function v(t){return"[object Object]"===Object.prototype.toString.call(t)}function g(t){return t[t.length-1]}function y(t,e){return"function"==typeof t?t(e):t}function _(t,e){return e.reduce(((e,a)=>(e[a]=t[a],e)),{})}function b(t){return P(t.filter(Boolean).join("/"))}function P(t){return t.replace(/\/{2,}/g,"/")}function w(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function x(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function A(t){return x(w(t))}function R(t,e,a){e=e.replace(new RegExp("^"+t),"/"),a=a.replace(new RegExp("^"+t),"/");let n=S(e);const o=S(a);o.forEach(((t,e)=>{if("/"===t.value)e?e===o.length-1&&n.push(t):n=[t];else if(".."===t.value){var a;n.length>1&&"/"===(null==(a=g(n))?void 0:a.value)&&n.pop(),n.pop()}else{if("."===t.value)return;n.push(t)}}));return P(b([t,...n.map((t=>t.value))]))}function S(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 a=t.split("/").filter(Boolean);return e.push(...a.map((t=>t.startsWith("*")?{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 I(t,e,a){return b(S(t).map((t=>{return"*"!==t.value||a?"param"===t.type?null!=(n=e[t.value.substring(1)])?n:"":t.value:"";var n})))}function L(t,e){const a=M(t,e);if(!e.to||a)return null!=a?a:{}}function M(t,e){var a;const n=S(t),o=S(""+(null!=(a=e.to)?a:"*")),r={};return(()=>{for(let t=0;t<Math.max(n.length,o.length);t++){const a=n[t],i=o[t],s=t===o.length-1,l=t===n.length-1;if(i){if("wildcard"===i.type)return!(null==a||!a.value)&&(r["*"]=b(n.slice(t).map((t=>t.value))),!0);if("pathname"===i.type){if("/"===i.value&&(null==a||!a.value))return!0;if(a)if(e.caseSensitive){if(i.value!==a.value)return!1}else if(i.value.toLowerCase()!==a.value.toLowerCase())return!1}if(!a)return!1;if("param"===i.type){if("/"===(null==a?void 0:a.value))return!1;a.value.startsWith(":")||(r[i.value.substring(1)]=a.value)}}if(s&&!l)return!!e.fuzzy}return!0})()?r:void 0}function E(t,e){var a,n,o,r="";for(a in t)if(void 0!==(o=t[a]))if(Array.isArray(o))for(n=0;n<o.length;n++)r&&(r+="&"),r+=encodeURIComponent(a)+"="+encodeURIComponent(o[n]);else r&&(r+="&"),r+=encodeURIComponent(a)+"="+encodeURIComponent(o);return(e||"")+r}function C(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function k(t){for(var e,a,n={},o=t.split("&");e=o.shift();)void 0!==n[a=(e=e.split("=")).shift()]?n[a]=[].concat(n[a],C(e.shift())):n[a]=C(e.shift());return n}function D(){return D=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},D.apply(this,arguments)}function O(t,e,a,n){const{id:o,routeId:r,path:i,fullPath:s}=t,l=n.state.actions[o]||(n.state.actions[o]={submissions:[],submit:async(t,e)=>{var a;if(!u)return;const o=null==(a=null==e?void 0:e.invalidate)||a;null!=e&&e.multi||(l.submissions=l.submissions.filter((t=>t.isMulti)));const r={submittedAt:Date.now(),status:"pending",submission:t,isMulti:!(null==e||!e.multi)};l.current=r,l.latest=r,l.submissions.push(r),n.notify();try{const e=await(null==u.options.action?void 0:u.options.action(t));return r.data=e,o&&(n.invalidateRoute({to:".",fromCurrent:!0}),await n.reload()),r.status="success",e}catch(t){console.error(t),r.error=t,r.status="error"}finally{n.notify()}}},n.state.actions[o]),c=n.state.loaders[o]||(n.state.loaders[o]={pending:[],fetch:async t=>{if(!u)return;const e={loadedAt:Date.now(),loaderContext:t};c.current=e,c.latest=e,c.pending.push(e),n.notify();try{return await(null==u.options.loader?void 0:u.options.loader(t))}finally{c.pending=c.pending.filter((t=>t!==e)),n.notify()}}},n.state.loaders[o]);let u={routeId:o,routeRouteId:r,routePath:i,fullPath:s,options:e,router:n,childRoutes:void 0,parentRoute:a,action:l,loader:c,buildLink:t=>n.buildLink(D({},t,{from:s})),navigate:t=>n.navigate(D({},t,{from:s})),matchRoute:(t,e)=>n.matchRoute(D({},t,{from:s}),e)};return null==n.options.createRoute||n.options.createRoute({router:n,route:u}),u}const F="__root__",j=["component","errorComponent","pendingComponent"];function T(t,e,a){const n=D({},e,a,{router:t,routeSearch:{},search:{},childMatches:[],status:"idle",routeLoaderData:{},loaderData:{},isFetching:!1,isInvalid:!1,invalidAt:1/0,getIsInvalid:()=>{const t=Date.now();return n.isInvalid||n.invalidAt<t},__:{abortController:new AbortController,latestId:"",resolve:()=>{},notify:()=>{n.__.resolve(),n.router.notify()},validate:()=>{var e,a;const o=null!=(e=null==(a=n.parentMatch)?void 0:a.search)?e:t.location.search;try{var r;const t=n.routeSearch,e="object"==typeof n.options.validateSearch?n.options.validateSearch.parse:n.options.validateSearch;let a=f(t,null!=(r=null==e?void 0:e(o))?r:{});t!==a&&(n.isInvalid=!0),n.routeSearch=a,n.search=f(o,D({},o,a)),j.map((async t=>{const e=n.options[t];"function"!=typeof n.__[t]&&(n.__[t]=e)}))}catch(t){console.error(t);const e=new Error("Invalid search params found",{cause:t});return e.code="INVALID_SEARCH_PARAMS",n.status="error",void(n.error=e)}}},cancel:()=>{var t;null==(t=n.__.abortController)||t.abort()},invalidate:()=>{n.isInvalid=!0},hasLoaders:()=>!(!e.options.loader&&!j.some((t=>{var a;return null==(a=e.options[t])?void 0:a.preload}))),load:async e=>{const a=Date.now(),o=null!=e&&e.preload?Math.max(null==e?void 0:e.maxAge,null==e?void 0:e.gcMaxAge):0;if(null!=e&&e.preload&&o>0){if(t.state.matches.find((t=>t.matchId===n.matchId)))return;t.matchCache[n.matchId]={gc:a+e.gcMaxAge,match:n}}if("success"===n.status&&n.getIsInvalid()||"error"===n.status||"idle"===n.status){const t=null!=e&&e.preload?null==e?void 0:e.maxAge:void 0;await n.fetch({maxAge:t})}},fetch:async e=>{const a=""+Date.now()+Math.random();n.__.latestId=a;const o=async()=>{if(a!==n.__.latestId)return new Promise((()=>{}))};"idle"===n.status&&(n.status="loading"),n.isInvalid=!1,n.__.loadPromise=new Promise((async a=>{n.isFetching=!0,n.__.resolve=a,n.__.componentsPromise=(async()=>{await Promise.all(j.map((async e=>{var a;const o=n.options[e];null!=(a=n.__[e])&&a.preload&&(n.__[e]=await t.options.loadComponent(o))})))})(),n.__.dataPromise=Promise.resolve().then((async()=>{try{var a,r,i;if(n.options.loader){const e=await t.loadMatchData(n);await o(),n.routeLoaderData=f(n.routeLoaderData,e)}return n.error=void 0,n.status="success",n.updatedAt=Date.now(),n.invalidAt=n.updatedAt+(null!=(a=null!=(r=null!=(i=null==e?void 0:e.maxAge)?i:n.options.loaderMaxAge)?r:t.options.defaultLoaderMaxAge)?a:0),n.routeLoaderData}catch(t){throw await o(),n.error=t,n.status="error",n.updatedAt=Date.now(),t}}));const r=async()=>{await o(),n.isFetching=!1,delete n.__.loadPromise,n.__.notify()};try{await Promise.all([n.__.componentsPromise,n.__.dataPromise.catch((()=>{}))]),r()}catch(t){r()}})),await n.__.loadPromise,await o()}});return n.hasLoaders()||(n.status="success"),n}const N=U(JSON.parse),B=H(JSON.stringify);function U(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let a=k(e);for(let e in a){const n=a[e];if("string"==typeof n)try{a[e]=t(n)}catch(t){}}return a}}function H(t){return e=>{(e=D({},e))&&Object.keys(e).forEach((a=>{const n=e[a];if(void 0===n||void 0===n)delete e[a];else if(n&&"object"==typeof n&&null!==n)try{e[a]=t(n)}catch(t){}}));const a=E(e).toString();return a?"?"+a:""}}var G;const z="undefined"==typeof window||!(null!=(G=window.document)&&G.createElement);function K(){return{status:"idle",location:null,matches:[],actions:{},loaders:{},lastUpdated:Date.now(),isFetching:!1,isPreloading:!1}}function V(t){t.forEach(((e,a)=>{const n=t[a-1];n&&(e.loaderData=f(e.loaderData,D({},n.loaderData,e.routeLoaderData)))}))}t.cleanPath=P,t.createBrowserHistory=r,t.createHashHistory=function(t){void 0===t&&(t={});var r=t.window,i=void 0===r?document.defaultView:r,s=i.history;function p(){var t=d(i.location.hash.substr(1)),e=t.pathname,a=void 0===e?"/":e,n=t.search,o=void 0===n?"":n,r=t.hash,l=void 0===r?"":r,c=s.state||{};return[c.idx,{pathname:a,search:o,hash:l,state:c.usr||null,key:c.key||"default"}]}var f=null;function m(){if(f)P.call(f),f=null;else{var t=a.Pop,e=p(),n=e[0],o=e[1];if(P.length){if(null!=n){var r=y-n;r&&(f={action:t,location:o,retry:function(){I(-1*r)}},I(r))}}else S(t)}}i.addEventListener(o,m),i.addEventListener("hashchange",(function(){h(p()[1])!==h(_)&&m()}));var v=a.Pop,g=p(),y=g[0],_=g[1],b=c(),P=c();function w(t){return function(){var t=document.querySelector("base"),e="";if(t&&t.getAttribute("href")){var a=i.location.href,n=a.indexOf("#");e=-1===n?a:a.slice(0,n)}return e}()+"#"+("string"==typeof t?t:h(t))}function x(t,a){return void 0===a&&(a=null),e({pathname:_.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function A(t,e){return[{usr:t.state,key:t.key,idx:e},w(t)]}function R(t,e,a){return!P.length||(P.call({action:t,location:e,retry:a}),!1)}function S(t){v=t;var e=p();y=e[0],_=e[1],b.call({action:v,location:_})}function I(t){s.go(t)}null==y&&(y=0,s.replaceState(e({},s.state,{idx:y}),""));var L={get action(){return v},get location(){return _},createHref:w,push:function t(e,n){var o=a.Push,r=x(e,n);if(R(o,r,(function(){t(e,n)}))){var l=A(r,y+1),c=l[0],u=l[1];try{s.pushState(c,"",u)}catch(t){i.location.assign(u)}S(o)}},replace:function t(e,n){var o=a.Replace,r=x(e,n);if(R(o,r,(function(){t(e,n)}))){var i=A(r,y),l=i[0],c=i[1];s.replaceState(l,"",c),S(o)}},go:I,back:function(){I(-1)},forward:function(){I(1)},listen:function(t){return b.push(t)},block:function(t){var e=P.push(t);return 1===P.length&&i.addEventListener(n,l),function(){e(),P.length||i.removeEventListener(n,l)}}};return L},t.createMemoryHistory=i,t.createRoute=O,t.createRouteConfig=function t(e,a,n,o,r){void 0===e&&(e={}),void 0===n&&(n=!0),n&&(e.path=F),o===F&&(o="");let i=n?F:e.path;i&&"/"!==i&&(i=A(i));const s=i||e.id;let l=b([o,s]);i===F&&(i="/"),l!==F&&(l=b(["/",l]));const c=l===F?"/":x(b([r,i]));return{id:l,routeId:s,path:i,fullPath:c,options:e,children:a,createChildren:a=>t(e,a((e=>t(e,void 0,!1,l,c))),!1,o,r),addChildren:a=>t(e,a,!1,o,r),createRoute:e=>t(e,void 0,!1,l,c)}},t.createRouteMatch=T,t.createRouter=function(t){var e,a;const n=(null==t?void 0:t.history)||(z?i():r()),o=D({defaultLoaderGcMaxAge:3e5,defaultLoaderMaxAge:0,defaultPreloadMaxAge:2e3,defaultPreloadDelay:50},t,{stringifySearch:null!=(e=null==t?void 0:t.stringifySearch)?e:B,parseSearch:null!=(a=null==t?void 0:t.parseSearch)?a:N});let s={types:void 0,history:n,options:o,listeners:[],basepath:"",routeTree:void 0,routesById:{},location:void 0,navigationPromise:Promise.resolve(),resolveNavigation:()=>{},matchCache:{},state:K(),reset:()=>{s.state=K(),s.notify()},startedLoadingAt:Date.now(),subscribe:t=>(s.listeners.push(t),()=>{s.listeners=s.listeners.filter((e=>e!==t))}),getRoute:t=>s.routesById[t],notify:()=>{const t="loading"===s.state.status||s.state.matches.some((t=>t.isFetching)),e=Object.values(s.matchCache).some((t=>t.match.isFetching&&!s.state.matches.find((e=>e.matchId===t.match.matchId))));s.state.isFetching===t&&s.state.isPreloading===e||(s.state=D({},s.state,{isFetching:t,isPreloading:e})),V(s.state.matches),s.listeners.forEach((t=>t(s)))},dehydrateState:()=>D({},_(s.state,["status","location","lastUpdated"]),{matches:s.state.matches.map((t=>_(t,["matchId","status","routeLoaderData","loaderData","isInvalid","invalidAt"])))}),hydrateState:t=>{const e=s.matchRoutes(s.location.pathname,{strictParseParams:!0});e.forEach(((e,a)=>{const n=t.matches[a];p(n),Object.assign(e,n)})),e.forEach((t=>t.__.validate())),s.state=D({},s.state,t,{matches:e})},mount:()=>{const t=s.__.buildLocation({to:".",search:!0,hash:!0});t.href!==s.location.href&&s.__.commitLocation(t,!0),s.state.matches.length||s.load();const e=s.history.listen((t=>{s.load(s.__.parseLocation(t.location,s.location))}));return!z&&window.addEventListener&&(window.addEventListener("visibilitychange",s.onFocus,!1),window.addEventListener("focus",s.onFocus,!1)),()=>{e(),!z&&window.removeEventListener&&(window.removeEventListener("visibilitychange",s.onFocus),window.removeEventListener("focus",s.onFocus))}},onFocus:()=>{s.load()},update:t=>{const e=(null==t?void 0:t.history)!==s.history;s.location&&!e||(null!=t&&t.history&&(s.history=t.history),s.location=s.__.parseLocation(s.history.location),s.state.location=s.location),Object.assign(s.options,t);const{basepath:a,routeConfig:n}=s.options;return s.basepath=P("/"+(null!=a?a:"")),n&&(s.routesById={},s.routeTree=s.__.buildRouteTree(n)),s},cancelMatches:()=>{var t,e;[...s.state.matches,...null!=(t=null==(e=s.state.pending)?void 0:e.matches)?t:[]].forEach((t=>{t.cancel()}))},load:async t=>{const e=Math.random();s.startedLoadingAt=e,t&&(s.location=t),s.cancelMatches();const a=s.matchRoutes(s.location.pathname,{strictParseParams:!0});if("undefined"!=typeof document?s.state=D({},s.state,{pending:{matches:a,location:s.location},status:"loading"}):s.state=D({},s.state,{matches:a,location:s.location,status:"loading"}),s.notify(),await s.loadMatches(a),s.startedLoadingAt!==e)return s.navigationPromise;const n=s.state.matches,o=[],r=[];n.forEach((t=>{a.find((e=>e.matchId===t.matchId))?r.push(t):o.push(t)}));const i=a.filter((t=>!n.find((e=>e.matchId===t.matchId)))),l=Date.now();o.forEach((t=>{var e,a,n,o;null==t.__.onExit||t.__.onExit({params:t.params,search:t.routeSearch}),"error"!==t.status||t.isFetching||(t.status="idle",t.error=void 0);const r=Math.max(null!=(e=null!=(a=t.options.loaderGcMaxAge)?a:s.options.defaultLoaderGcMaxAge)?e:0,null!=(n=null!=(o=t.options.loaderMaxAge)?o:s.options.defaultLoaderMaxAge)?n:0);r>0&&(s.matchCache[t.matchId]={gc:r==1/0?Number.MAX_SAFE_INTEGER:l+r,match:t})})),r.forEach((t=>{null==t.options.onTransition||t.options.onTransition({params:t.params,search:t.routeSearch})})),i.forEach((t=>{t.__.onExit=null==t.options.onMatch?void 0:t.options.onMatch({params:t.params,search:t.search}),delete s.matchCache[t.matchId]})),s.startedLoadingAt===e&&(a.forEach((t=>{t.action&&(t.action.current=void 0,t.action.submissions=[])})),s.state=D({},s.state,{location:s.location,matches:a,pending:void 0,status:"idle"}),s.notify(),s.resolveNavigation())},cleanMatchCache:()=>{const t=Date.now();Object.keys(s.matchCache).forEach((e=>{const a=s.matchCache[e];"loading"!==a.match.status&&(a.gc>0&&a.gc>t||delete s.matchCache[e])}))},loadRoute:async function(t){void 0===t&&(t=s.location);const e=s.buildNext(t),a=s.matchRoutes(e.pathname,{strictParseParams:!0});return await s.loadMatches(a),a},preloadRoute:async function(t,e){var a,n,o,r,i,l;void 0===t&&(t=s.location);const c=s.buildNext(t),u=s.matchRoutes(c.pathname,{strictParseParams:!0});return await s.loadMatches(u,{preload:!0,maxAge:null!=(a=null!=(n=null!=(o=e.maxAge)?o:s.options.defaultPreloadMaxAge)?n:s.options.defaultLoaderMaxAge)?a:0,gcMaxAge:null!=(r=null!=(i=null!=(l=e.gcMaxAge)?l:s.options.defaultPreloadGcMaxAge)?i:s.options.defaultLoaderGcMaxAge)?r:0}),u},matchRoutes:(t,e)=>{var a,n;s.cleanMatchCache();const o=[];if(!s.routeTree)return o;const r=[...s.state.matches,...null!=(a=null==(n=s.state.pending)?void 0:n.matches)?a:[]],i=async a=>{var n,l,c;const u=g(o);let h=null!=(n=null==u?void 0:u.params)?n:{};const d=null!=(l=null==s.options.filterRoutes?void 0:s.options.filterRoutes(a))?l:a;let p=[];const f=(a,n)=>(n.some((n=>{var o,r,i;if(!n.routePath&&null!=(o=n.childRoutes)&&o.length)return f([...p,n],n.childRoutes);const l=!!("/"!==n.routePath||null!=(r=n.childRoutes)&&r.length),c=L(t,{to:n.fullPath,fuzzy:l,caseSensitive:null!=(i=n.options.caseSensitive)?i:s.options.caseSensitive});if(c){let t;try{var u;t=null!=(u=null==n.options.parseParams?void 0:n.options.parseParams(c))?u:c}catch(t){if(null!=e&&e.strictParseParams)throw t}h=D({},h,t)}return c&&(p=[...a,n]),!!p.length})),!!p.length);if(f([],d),!p.length)return;p.forEach((e=>{var a;const n=I(e.routePath,h),i=I(e.routeId,h,!0),l=r.find((t=>t.matchId===i))||(null==(a=s.matchCache[i])?void 0:a.match)||T(s,e,{parentMatch:u,matchId:i,params:h,pathname:b([t,n])});o.push(l)}));const m=g(p);null!=(c=m.childRoutes)&&c.length&&i(m.childRoutes)};return i([s.routeTree]),V(o),o},loadMatches:async(t,e)=>{const a=t.map((async t=>{t.__.validate(),t.load(e);const a=t.search;a.__data&&a.__data.matchId!==t.matchId||t.__.loadPromise&&await t.__.loadPromise}));s.notify(),await Promise.all(a)},loadMatchData:async t=>{var e;if(z||!s.options.useServerData)return null!=(e=await(null==t.options.loader?void 0:t.options.loader({params:t.params,search:t.routeSearch,signal:t.__.abortController.signal})))?e:{};{const e=s.buildNext({to:".",search:e=>D({},null!=e?e:{},{__data:{matchId:t.matchId}})}),a=await fetch(e.href,{method:"GET"});if(a.ok)return a.json();throw new Error("Failed to fetch match data")}},invalidateRoute:t=>{var e,a;const n=s.buildNext(t),o=s.matchRoutes(n.pathname).map((t=>t.matchId));[...s.state.matches,...null!=(e=null==(a=s.state.pending)?void 0:a.matches)?e:[]].forEach((t=>{o.includes(t.matchId)&&t.invalidate()}))},reload:()=>s.__.navigate({fromCurrent:!0,replace:!0,search:!0}),resolvePath:(t,e)=>R(s.basepath,t,P(e)),matchRoute:(t,e)=>{var a;t=D({},t,{to:t.to?s.resolvePath(null!=(a=t.from)?a:"",t.to):void 0});const n=s.buildNext(t);var o;return null!=e&&e.pending?!(null==(o=s.state.pending)||!o.location)&&!!L(s.state.pending.location.pathname,D({},e,{to:n.pathname})):!!L(s.state.location.pathname,D({},e,{to:n.pathname}))},navigate:async t=>{let{from:e,to:a=".",search:n,hash:o,replace:r,params:i}=t;const l=String(a),c=String(e);let u;try{new URL(""+l),u=!0}catch(t){}return p(!u),s.__.navigate({from:c,to:l,search:n,hash:o,replace:r,params:i})},buildLink:t=>{var e,a;let{from:n,to:o=".",search:r,params:i,hash:l,target:c,replace:u,activeOptions:h,preload:d,preloadMaxAge:p,preloadGcMaxAge:f,preloadDelay:m,disabled:v}=t;try{return new URL(""+o),{type:"external",href:o}}catch(t){}const g={from:n,to:o,search:r,params:i,hash:l,replace:u},y=s.buildNext(g);d=null!=(e=d)?e:s.options.defaultPreload;const _=null!=(a=null!=m?m:s.options.defaultPreloadDelay)?a:0,b=s.state.location.pathname===y.pathname,P=s.state.location.pathname.split("/"),w=y.pathname.split("/").every(((t,e)=>t===P[e])),x=s.state.location.hash===y.hash,A=null!=h&&h.exact?b:w,R=null==h||!h.includeHash||x;return{type:"internal",next:y,handleFocus:t=>{d&&s.preloadRoute(g,{maxAge:p,gcMaxAge:f})},handleClick:t=>{v||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||c&&"_self"!==c||0!==t.button||(t.preventDefault(),!b||r||l||s.invalidateRoute(g),s.__.navigate(g))},handleEnter:t=>{const e=t.target||{};if(d){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,s.preloadRoute(g,{maxAge:p,gcMaxAge:f})}),_)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},isActive:A&&R,disabled:v}},buildNext:t=>{const e=s.__.buildLocation(t),a=s.matchRoutes(e.pathname),n=a.map((t=>{var e;return null!=(e=t.options.preSearchFilters)?e:[]})).flat().filter(Boolean),o=a.map((t=>{var e;return null!=(e=t.options.postSearchFilters)?e:[]})).flat().filter(Boolean);return s.__.buildLocation(D({},t,{__preSearchFilters:n,__postSearchFilters:o}))},__:{buildRouteTree:t=>{const e=(t,a)=>t.map((t=>{const n=O(t,t.options,a,s);if(s.routesById[n.routeId])throw new Error;s.routesById[n.routeId]=n;const o=t.children;return n.childRoutes=null!=o&&o.length?e(o,n):void 0,n}));return e([t])[0]},parseLocation:(t,e)=>{var a;const n=s.options.parseSearch(t.search);return{pathname:t.pathname,searchStr:t.search,search:f(null==e?void 0:e.search,n),hash:null!=(a=t.hash.split("#").reverse()[0])?a:"",href:""+t.pathname+t.search+t.hash,state:t.state,key:t.key}},navigate:t=>{const e=s.buildNext(t);return s.__.commitLocation(e,t.replace)},buildLocation:function(t){var e,a,n,o,r,i,l,c,u;void 0===t&&(t={});const h=t.fromCurrent?s.location.pathname:null!=(e=t.from)?e:s.location.pathname;let d=R(null!=(a=s.basepath)?a:"/",h,""+(null!=(n=t.to)?n:"."));const p=s.matchRoutes(s.location.pathname,{strictParseParams:!0}),m=s.matchRoutes(d),v=D({},null==(o=g(p))?void 0:o.params);let _=!0===(null==(r=t.params)||r)?v:y(t.params,v);_&&m.map((t=>t.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},_,t(_))})),d=I(d,null!=_?_:{});const b=null!=(i=t.__preSearchFilters)&&i.length?t.__preSearchFilters.reduce(((t,e)=>e(t)),s.location.search):s.location.search,P=!0===t.search?b:t.search?null!=(l=y(t.search,b))?l:{}:null!=(c=t.__preSearchFilters)&&c.length?b:{},w=null!=(u=t.__postSearchFilters)&&u.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),P):P,x=f(s.location.search,w),A=s.options.stringifySearch(x);let S=!0===t.hash?s.location.hash:y(t.hash,s.location.hash);return S=S?"#"+S:"",{pathname:d,search:x,searchStr:A,state:s.location.state,hash:S,href:""+d+A+S,key:t.key}},commitLocation:(t,e)=>{const a=""+Date.now()+Math.random();s.navigateTimeout&&clearTimeout(s.navigateTimeout);let o="replace";e||(o="push");return s.__.parseLocation(n.location).href===t.href&&!t.key&&(o="replace"),"replace"===o?n.replace({pathname:t.pathname,hash:t.hash,search:t.searchStr},D({id:a},t.state)):n.push({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:a}),s.navigationPromise=new Promise((t=>{const e=s.resolveNavigation;s.resolveNavigation=()=>{e(),t()}})),s.navigationPromise}}};return s.update(t),null==s.options.createRouter||s.options.createRouter(s),s},t.decode=k,t.defaultParseSearch=N,t.defaultStringifySearch=B,t.encode=E,t.functionalUpdate=y,t.interpolatePath=I,t.invariant=p,t.joinPaths=b,t.last=g,t.matchByPath=M,t.matchPathname=L,t.parsePathname=S,t.parseSearchWith=U,t.pick=_,t.replaceEqualDeep=f,t.resolvePath=R,t.rootRouteId=F,t.stringifySearchWith=H,t.trimPath=A,t.trimPathLeft=w,t.trimPathRight=x,t.warning=function(t,e){if(t){"undefined"!=typeof console&&console.warn(e);try{throw new Error(e)}catch(t){}}return!0},Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
11
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RouterCore={})}(this,(function(t){"use strict";function e(t,e){if(!t)throw new Error("Invariant failed")}const s="pushstate",o="popstate",r="beforeunload",a=t=>(t.preventDefault(),t.returnValue=""),n=()=>{removeEventListener(r,a,{capture:!0})};function i(t){let e=t.getLocation(),s=()=>{},o=new Set,i=[],h=[];const d=()=>{if(i.length)i[0]?.(d,(()=>{i=[],n()}));else{for(;h.length;)h.shift()?.();t.subscriber||u()}},l=t=>{h.push(t),d()},u=()=>{e=t.getLocation(),o.forEach((t=>t()))};return{get location(){return e},subscribe:e=>(0===o.size&&(s="function"==typeof t.subscriber?t.subscriber(u):()=>{}),o.add(e),()=>{o.delete(e),0===o.size&&s()}),push:(e,s)=>{c(s),l((()=>{t.pushState(e,s)}))},replace:(e,s)=>{c(s),l((()=>{t.replaceState(e,s)}))},go:e=>{l((()=>{t.go(e)}))},back:()=>{l((()=>{t.back()}))},forward:()=>{l((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(i.push(t),1===i.length&&addEventListener(r,a,{capture:!0}),()=>{i=i.filter((e=>e!==t)),i.length||n()})}}function c(t){t.key=u()}function h(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=t?.createHref??(t=>t);return i({getLocation:()=>l(e(),window.history.state),subscriber:t=>{window.addEventListener(s,t),window.addEventListener(o,t);var e=window.history.pushState;window.history.pushState=function(){let s=e.apply(history,arguments);return t(),s};var r=window.history.replaceState;return window.history.replaceState=function(){let e=r.apply(history,arguments);return t(),e},()=>{window.history.pushState=e,window.history.replaceState=r,window.removeEventListener(s,t),window.removeEventListener(o,t)}},pushState:(t,e)=>{window.history.pushState(e,"",r(t))},replaceState:(t,e)=>{window.history.replaceState(e,"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t)})}function d(t={initialEntries:["/"]}){const e=t.initialEntries;let s=t.initialIndex??e.length-1,o={key:u()};return i({getLocation:()=>l(e[s],o),subscriber:!1,pushState:(t,r)=>{o=r,e.push(t),s++},replaceState:(t,r)=>{o=r,e[s]=t},back:()=>{s--},forward:()=>{s=Math.min(s+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function l(t,e){let s=t.indexOf("#"),o=t.indexOf("?");return{href:t,pathname:t.substring(0,s>0?o>0?Math.min(s,o):s:o>0?o:t.length),hash:s>-1?t.substring(s):"",search:o>-1?t.slice(o,-1===s?void 0:s):"",state:e||{}}}function u(){return(Math.random()+1).toString(36).substring(7)}function p(t){return t[t.length-1]}function f(t,e){return"function"==typeof t?t(e):t}function m(t,e){return e.reduce(((e,s)=>(e[s]=t[s],e)),{})}function y(t,e){if(t===e)return t;const s=e,o=Array.isArray(t)&&Array.isArray(s);if(o||g(t)&&g(s)){const e=o?t.length:Object.keys(t).length,r=o?s:Object.keys(s),a=r.length,n=o?[]:{};let i=0;for(let e=0;e<a;e++){const a=o?e:r[e];n[a]=y(t[a],s[a]),n[a]===t[a]&&i++}return e===a&&i===e?t:n}return s}function g(t){if(!w(t))return!1;const e=t.constructor;if(void 0===e)return!0;const s=e.prototype;return!!w(s)&&!!s.hasOwnProperty("isPrototypeOf")}function w(t){return"[object Object]"===Object.prototype.toString.call(t)}function v(t,e){return t===e||typeof t==typeof e&&(g(t)&&g(e)?!Object.keys(e).some((s=>!v(t[s],e[s]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,s)=>v(t,e[s])))))}function _(t){return b(t.filter(Boolean).join("/"))}function b(t){return t.replace(/\/{2,}/g,"/")}function S(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function R(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function I(t){return R(S(t))}function M(t,e,s){e=e.replace(new RegExp(`^${t}`),"/"),s=s.replace(new RegExp(`^${t}`),"/");let o=x(e);const r=x(s);r.forEach(((t,e)=>{if("/"===t.value)e?e===r.length-1&&o.push(t):o=[t];else if(".."===t.value)o.length>1&&"/"===p(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return b(_([t,...o.map((t=>t.value))]))}function x(t){if(!t)return[];const e=[];if("/"===(t=b(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const s=t.split("/").filter(Boolean);return e.push(...s.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 E(t,e,s=!1){return _(x(t).map((t=>{if("wildcard"===t.type){const o=e[t.value];return s?`${t.value}${o??""}`:o}return"param"===t.type?e[t.value.substring(1)]??"":t.value})))}function L(t,e,s){const o=P(t,e,s);if(!s.to||o)return o??{}}function P(t,e,s){e="/"!=t?e.substring(t.length):e;const o=`${s.to??"$"}`,r=x(e),a=x(o);e.startsWith("/")||r.unshift({type:"pathname",value:"/"}),o.startsWith("/")||a.unshift({type:"pathname",value:"/"});const n={};return(()=>{for(let t=0;t<Math.max(r.length,a.length);t++){const e=r[t],o=a[t],i=t>=r.length-1,c=t>=a.length-1;if(o){if("wildcard"===o.type)return!!e?.value&&(n["*"]=_(r.slice(t).map((t=>t.value))),!0);if("pathname"===o.type){if("/"===o.value&&!e?.value)return!0;if(e)if(s.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!!s.fuzzy}return!0})()?n:void 0}function A(t,e){var s,o,r,a="";for(s in t)if(void 0!==(r=t[s]))if(Array.isArray(r))for(o=0;o<r.length;o++)a&&(a+="&"),a+=encodeURIComponent(s)+"="+encodeURIComponent(r[o]);else a&&(a+="&"),a+=encodeURIComponent(s)+"="+encodeURIComponent(r);return(e||"")+a}function O(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0&&+e+""===e?+e:e))}function D(t){for(var e,s,o={},r=t.split("&");e=r.shift();)void 0!==o[s=(e=e.split("=")).shift()]?o[s]=[].concat(o[s],O(e.shift())):o[s]=O(e.shift());return o}const B="__root__";class k{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute,k.__onInit(this)}init=t=>{this.originalIndex=t.originalIndex,this.router=t.router;const s=this.options,o=!s?.path&&!s?.id;this.parentRoute=this.options?.getParentRoute?.(),o?this.path=B:e(this.parentRoute);let r=o?B:s.path;r&&"/"!==r&&(r=I(r));const a=s?.id||r;let n=o?B:_([this.parentRoute.id===B?"":this.parentRoute.id,a]);r===B&&(r="/"),n!==B&&(n=_(["/",n]));const i=n===B?"/":_([this.parentRoute.fullPath,r]);this.path=r,this.id=n,this.fullPath=i,this.to=i};addChildren=t=>(this.children=t,this);update=t=>(Object.assign(this.options,t),this);static __onInit=t=>{}}class $ extends k{constructor(t){super(t)}}
|
|
12
|
+
/**
|
|
13
|
+
* @tanstack/store/src/index.ts
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) TanStack
|
|
16
|
+
*
|
|
17
|
+
* This source code is licensed under the MIT license found in the
|
|
18
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
19
|
+
*
|
|
20
|
+
* @license MIT
|
|
21
|
+
*/
|
|
22
|
+
class C{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 z(t){return!!t?.isRedirect}class X 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 k(t);return e.isRoot=!1,e}},t.PathParamError=q,t.RootRoute=$,t.Route=k,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 C(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?d():h());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 s=this.routesById[t];return e(s),s};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.key?t.options.key({params:o,search:e})??"":"",i=a?JSON.stringify(a):"",c=E(t.id,o,!0)+i,h=this.getRouteMatch(c);if(h)return{...h};const d=!(!t.options.loader&&!N.some((e=>t.options[e]?.preload)));return{id:c,key:i,routeId:t.id,params:o,pathname:_([this.basepath,r]),updatedAt:Date.now(),maxAge:-1,preloadMaxAge:-1,routeSearch:{},search:{},status:d?"pending":"success",isFetching:!1,invalid:!1,error:void 0,paramsError:n[s],searchError:void 0,loaderData:void 0,loadPromise:Promise.resolve(),routeContext:void 0,context:void 0,abortController:new AbortController,fetchedAt:0}}));return i.forEach(((t,o)=>{const 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 X(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,routeContext:t.routeContext,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,z(e))throw e;try{n.options.onError?.(e)}catch(t){if(e=t,z(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;try{const t=await(n.options.beforeLoad?.({...r,preload:!!e?.preload,parentContext:a?.routeContext??{},context:a?.context??this?.options.context??{}}))??{},s={...a?.context??this?.options.context,...t};this.setRouteMatch(r.id,(e=>({...e,context:s,routeContext:t})))}catch(t){i(t,"BEFORE_LOAD"),c=!0}if(c)break}}catch(t){if(z(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=>!!z(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?.({...t,preload:!!e?.preload,parentMatchPromise:o}),[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:s="",...o})=>{const r=String(s),a=void 0===t?t:String(t);let n;try{new URL(`${r}`),n=!0}catch(t){}return e(!n),this.#i({...o,from:a,to:r})};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 s=t;"undefined"!=typeof document&&(s=window.__TSR_DEHYDRATED__),e(s);const o=s;this.dehydratedData=o.payload,this.options.hydrate?.(o.payload);const r=o.router.state;let a=this.matchRoutes(this.state.location.pathname,this.state.location.search).map((t=>{const s=r.dehydratedMatches.find((e=>e.id===t.id));return e(s,t.id),s?{...t,...s}:t}));this.__store.setState((t=>({...t,matchIds:r.matchIds,matches:a,matchesById:this.#n(t.matchesById,a)})))};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 s=t=>{t.forEach(((t,o)=>{t.init({originalIndex:o,router:this});if(e(!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 r=t.children;r?.length&&s(r)}))};s([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={...p(this.matchRoutes(o,s.search))?.params};let n=!0===(t.params??!0)?a:f(t.params,a);n&&e?.map((t=>this.getRoute(t.routeId).options.stringifyParams)).filter(Boolean).forEach((t=>{n={...n,...t(n)}})),r=E(r,n??{});const i=e?.map((t=>this.getRoute(t.routeId).options.preSearchFilters??[])).flat().filter(Boolean)??[],c=e?.map((t=>this.getRoute(t.routeId).options.postSearchFilters??[])).flat().filter(Boolean)??[],h=i?.length?i?.reduce(((t,e)=>e(t)),s.search):s.search,d=!0===t.search?h:t.search?f(t.search,h)??{}:i?.length?h:{},l=c?.length?c.reduce(((t,e)=>e(t)),d):d,u=y(s.search,l),m=this.options.stringifySearch(u),g=!0===t.hash?s.hash:t.hash?f(t.hash,s.hash):s.hash,w=g?`#${g}`:"";let v=!0===t.state?s.state:t.state?f(t.state,s.state):s.state;return v=y(s.state,v),{pathname:r,search:u,searchStr:m,state:v,hash:g,href:this.history.createHref(`${r}${m}${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);let e="replace";t.replace||(e="push");this.state.location.href===t.href&&(e="replace");let{maskedLocation:s,...o}=t;return s&&(o={...s,state:{...s.state,__tempKey:void 0,__tempLocation:{...o,search:o.searchStr,state:{...o.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(o.unmaskOnReload??this.options.unmaskOnReload)&&(o.state.__tempKey=this.tempLocationKey)),this.history["push"===e?"push":"replace"](o.href,o.state),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=X,t.cleanPath=b,t.componentTypes=N,t.createBrowserHistory=h,t.createHashHistory=function(){return h({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=d,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=e,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=z,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})}));
|
|
12
23
|
//# sourceMappingURL=index.production.js.map
|