@tanstack/react-router
Advanced tools
Comparing version 0.0.1-beta.145 to 0.0.1-beta.146
@@ -10,3 +10,3 @@ { | ||
{ | ||
"uid": "1efb-163", | ||
"uid": "2b8f-167", | ||
"name": "\u0000rollupPluginBabelHelpers.js" | ||
@@ -19,15 +19,15 @@ }, | ||
"name": "store/build/esm/index.js", | ||
"uid": "1efb-165" | ||
"uid": "2b8f-169" | ||
}, | ||
{ | ||
"name": "react-store/build/esm/index.js", | ||
"uid": "1efb-167" | ||
"uid": "2b8f-171" | ||
}, | ||
{ | ||
"name": "router-core/build/esm/index.js", | ||
"uid": "1efb-173" | ||
"uid": "2b8f-177" | ||
}, | ||
{ | ||
"name": "react-router/src/index.tsx", | ||
"uid": "1efb-175" | ||
"uid": "2b8f-179" | ||
} | ||
@@ -41,7 +41,7 @@ ] | ||
"name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js", | ||
"uid": "1efb-169" | ||
"uid": "2b8f-173" | ||
}, | ||
{ | ||
"name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js", | ||
"uid": "1efb-171" | ||
"uid": "2b8f-175" | ||
} | ||
@@ -56,50 +56,50 @@ ] | ||
"nodeParts": { | ||
"1efb-163": { | ||
"2b8f-167": { | ||
"renderedLength": 429, | ||
"gzipLength": 238, | ||
"brotliLength": 0, | ||
"mainUid": "1efb-162" | ||
"mainUid": "2b8f-166" | ||
}, | ||
"1efb-165": { | ||
"2b8f-169": { | ||
"renderedLength": 1843, | ||
"gzipLength": 644, | ||
"brotliLength": 0, | ||
"mainUid": "1efb-164" | ||
"mainUid": "2b8f-168" | ||
}, | ||
"1efb-167": { | ||
"2b8f-171": { | ||
"renderedLength": 1006, | ||
"gzipLength": 479, | ||
"brotliLength": 0, | ||
"mainUid": "1efb-166" | ||
"mainUid": "2b8f-170" | ||
}, | ||
"1efb-169": { | ||
"2b8f-173": { | ||
"renderedLength": 181, | ||
"gzipLength": 129, | ||
"brotliLength": 0, | ||
"mainUid": "1efb-168" | ||
"mainUid": "2b8f-172" | ||
}, | ||
"1efb-171": { | ||
"2b8f-175": { | ||
"renderedLength": 44, | ||
"gzipLength": 62, | ||
"brotliLength": 0, | ||
"mainUid": "1efb-170" | ||
"mainUid": "2b8f-174" | ||
}, | ||
"1efb-173": { | ||
"renderedLength": 56600, | ||
"gzipLength": 13389, | ||
"2b8f-177": { | ||
"renderedLength": 55753, | ||
"gzipLength": 13207, | ||
"brotliLength": 0, | ||
"mainUid": "1efb-172" | ||
"mainUid": "2b8f-176" | ||
}, | ||
"1efb-175": { | ||
"2b8f-179": { | ||
"renderedLength": 17095, | ||
"gzipLength": 3814, | ||
"brotliLength": 0, | ||
"mainUid": "1efb-174" | ||
"mainUid": "2b8f-178" | ||
} | ||
}, | ||
"nodeMetas": { | ||
"1efb-162": { | ||
"2b8f-166": { | ||
"id": "\u0000rollupPluginBabelHelpers.js", | ||
"moduleParts": { | ||
"index.production.js": "1efb-163" | ||
"index.production.js": "2b8f-167" | ||
}, | ||
@@ -109,10 +109,10 @@ "imported": [], | ||
{ | ||
"uid": "1efb-174" | ||
"uid": "2b8f-178" | ||
} | ||
] | ||
}, | ||
"1efb-164": { | ||
"2b8f-168": { | ||
"id": "/packages/store/build/esm/index.js", | ||
"moduleParts": { | ||
"index.production.js": "1efb-165" | ||
"index.production.js": "2b8f-169" | ||
}, | ||
@@ -122,17 +122,17 @@ "imported": [], | ||
{ | ||
"uid": "1efb-166" | ||
"uid": "2b8f-170" | ||
} | ||
] | ||
}, | ||
"1efb-166": { | ||
"2b8f-170": { | ||
"id": "/packages/react-store/build/esm/index.js", | ||
"moduleParts": { | ||
"index.production.js": "1efb-167" | ||
"index.production.js": "2b8f-171" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "1efb-177" | ||
"uid": "2b8f-181" | ||
}, | ||
{ | ||
"uid": "1efb-164" | ||
"uid": "2b8f-168" | ||
} | ||
@@ -142,13 +142,13 @@ ], | ||
{ | ||
"uid": "1efb-174" | ||
"uid": "2b8f-178" | ||
}, | ||
{ | ||
"uid": "1efb-172" | ||
"uid": "2b8f-176" | ||
} | ||
] | ||
}, | ||
"1efb-168": { | ||
"2b8f-172": { | ||
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js", | ||
"moduleParts": { | ||
"index.production.js": "1efb-169" | ||
"index.production.js": "2b8f-173" | ||
}, | ||
@@ -158,13 +158,13 @@ "imported": [], | ||
{ | ||
"uid": "1efb-174" | ||
"uid": "2b8f-178" | ||
}, | ||
{ | ||
"uid": "1efb-172" | ||
"uid": "2b8f-176" | ||
} | ||
] | ||
}, | ||
"1efb-170": { | ||
"2b8f-174": { | ||
"id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js", | ||
"moduleParts": { | ||
"index.production.js": "1efb-171" | ||
"index.production.js": "2b8f-175" | ||
}, | ||
@@ -174,23 +174,23 @@ "imported": [], | ||
{ | ||
"uid": "1efb-174" | ||
"uid": "2b8f-178" | ||
}, | ||
{ | ||
"uid": "1efb-172" | ||
"uid": "2b8f-176" | ||
} | ||
] | ||
}, | ||
"1efb-172": { | ||
"2b8f-176": { | ||
"id": "/packages/router-core/build/esm/index.js", | ||
"moduleParts": { | ||
"index.production.js": "1efb-173" | ||
"index.production.js": "2b8f-177" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "1efb-168" | ||
"uid": "2b8f-172" | ||
}, | ||
{ | ||
"uid": "1efb-170" | ||
"uid": "2b8f-174" | ||
}, | ||
{ | ||
"uid": "1efb-166" | ||
"uid": "2b8f-170" | ||
} | ||
@@ -200,29 +200,29 @@ ], | ||
{ | ||
"uid": "1efb-174" | ||
"uid": "2b8f-178" | ||
} | ||
] | ||
}, | ||
"1efb-174": { | ||
"2b8f-178": { | ||
"id": "/packages/react-router/src/index.tsx", | ||
"moduleParts": { | ||
"index.production.js": "1efb-175" | ||
"index.production.js": "2b8f-179" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "1efb-162" | ||
"uid": "2b8f-166" | ||
}, | ||
{ | ||
"uid": "1efb-176" | ||
"uid": "2b8f-180" | ||
}, | ||
{ | ||
"uid": "1efb-166" | ||
"uid": "2b8f-170" | ||
}, | ||
{ | ||
"uid": "1efb-168" | ||
"uid": "2b8f-172" | ||
}, | ||
{ | ||
"uid": "1efb-170" | ||
"uid": "2b8f-174" | ||
}, | ||
{ | ||
"uid": "1efb-172" | ||
"uid": "2b8f-176" | ||
} | ||
@@ -233,3 +233,3 @@ ], | ||
}, | ||
"1efb-176": { | ||
"2b8f-180": { | ||
"id": "react", | ||
@@ -240,3 +240,3 @@ "moduleParts": {}, | ||
{ | ||
"uid": "1efb-174" | ||
"uid": "2b8f-178" | ||
} | ||
@@ -246,3 +246,3 @@ ], | ||
}, | ||
"1efb-177": { | ||
"2b8f-181": { | ||
"id": "use-sync-external-store/shim/with-selector", | ||
@@ -253,3 +253,3 @@ "moduleParts": {}, | ||
{ | ||
"uid": "1efb-166" | ||
"uid": "2b8f-170" | ||
} | ||
@@ -256,0 +256,0 @@ ], |
@@ -23,3 +23,3 @@ /** | ||
interface RegisterRouteErrorComponent<TProps extends Record<string, any>> { | ||
RouteComponent: RouteComponent<TProps>; | ||
RouteErrorComponent: RouteComponent<TProps>; | ||
} | ||
@@ -26,0 +26,0 @@ interface Route<TParentRoute extends AnyRoute = AnyRoute, TPath extends string = '/', TFullPath extends ResolveFullPath<TParentRoute, TPath> = ResolveFullPath<TParentRoute, TPath>, TCustomId extends string = string, TId extends ResolveId<TParentRoute, TCustomId, TPath> = ResolveId<TParentRoute, TCustomId, TPath>, TLoader = unknown, TSearchSchema extends AnySearchSchema = {}, TFullSearchSchema extends AnySearchSchema = ResolveFullSearchSchema<TParentRoute, TSearchSchema>, TParams extends Record<ParsePathParams<TPath>, any> = Record<ParsePathParams<TPath>, string>, TAllParams extends MergeParamsFromParent<TParentRoute['__types']['allParams'], TParams> = MergeParamsFromParent<TParentRoute['__types']['allParams'], TParams>, TParentContext extends TParentRoute['__types']['routeContext'] = TParentRoute['__types']['routeContext'], TAllParentContext extends TParentRoute['__types']['context'] = TParentRoute['__types']['context'], TRouteContext extends RouteContext = RouteContext, TContext extends MergeParamsFromParent<TParentRoute['__types']['context'], TRouteContext> = MergeParamsFromParent<TParentRoute['__types']['context'], TRouteContext>, TRouterContext extends AnyContext = AnyContext, TChildren extends unknown = unknown, TRoutesInfo extends DefaultRoutesInfo = DefaultRoutesInfo> { |
@@ -42,3 +42,3 @@ /** | ||
*/ | ||
const u="pushstate",l="popstate",d="beforeunload",p=t=>(t.preventDefault(),t.returnValue=""),f=()=>{removeEventListener(d,p,{capture:!0})};function m(t){let e=t.getLocation(),r=()=>{},o=new Set,s=[],n=[];const a=()=>{if(s.length)s[0]?.(a,(()=>{s=[],f()}));else{for(;n.length;)n.shift()?.();t.listener||c()}},i=t=>{n.push(t),a()},c=()=>{e=t.getLocation(),o.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===o.size&&(r="function"==typeof t.listener?t.listener(c):()=>{}),o.add(e),()=>{o.delete(e),0===o.size&&r()}),push:(e,r)=>{i((()=>{t.pushState(e,r)}))},replace:(e,r)=>{i((()=>{t.replaceState(e,r)}))},go:e=>{i((()=>{t.go(e)}))},back:()=>{i((()=>{t.back()}))},forward:()=>{i((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(s.push(t),1===s.length&&addEventListener(d,p,{capture:!0}),()=>{s=s.filter((e=>e!==t)),s.length||f()})}}function y(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=t?.createHref??(t=>t);return m({getLocation:()=>v(e(),history.state),listener:t=>{window.addEventListener(u,t),window.addEventListener(l,t);var e=window.history.pushState;window.history.pushState=function(){let r=e.apply(history,arguments);return t(),r};var r=window.history.replaceState;return window.history.replaceState=function(){let e=r.apply(history,arguments);return t(),e},()=>{window.history.pushState=e,window.history.replaceState=r,window.removeEventListener(u,t),window.removeEventListener(l,t)}},pushState:(t,e)=>{window.history.pushState({...e,key:w()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:w()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t)})}function g(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,o={};return m({getLocation:()=>v(e[r],o),listener:!1,pushState:(t,s)=>{o={...s,key:w()},e.push(t),r++},replaceState:(t,s)=>{o={...s,key:w()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function v(t,e){let r=t.indexOf("#"),o=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?o>0?Math.min(r,o):r:o>0?o:t.length),hash:r>-1?t.substring(r):"",search:o>-1?t.slice(o,-1===r?void 0:r):"",state:e}}function w(){return(Math.random()+1).toString(36).substring(7)}function b(t){return t[t.length-1]}function S(t,e){return"function"==typeof t?t(e):t}function x(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function E(t,e){if(t===e)return t;const r=e,o=Array.isArray(t)&&Array.isArray(r);if(o||R(t)&&R(r)){const e=o?t.length:Object.keys(t).length,s=o?r:Object.keys(r),n=s.length,a=o?[]:{};let i=0;for(let e=0;e<n;e++){const n=o?e:s[e];a[n]=E(t[n],r[n]),a[n]===t[n]&&i++}return e===n&&i===e?t:a}return r}function R(t){if(!I(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!I(r)&&!!r.hasOwnProperty("isPrototypeOf")}function I(t){return"[object Object]"===Object.prototype.toString.call(t)}function _(t,e){return t===e||typeof t==typeof e&&(R(t)&&R(e)?!Object.keys(e).some((r=>!_(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>_(t,e[r])))))}function P(t){return C(t.filter(Boolean).join("/"))}function C(t){return t.replace(/\/{2,}/g,"/")}function M(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function L(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function O(t){return L(M(t))}function j(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let o=k(e);const s=k(r);s.forEach(((t,e)=>{if("/"===t.value)e?e===s.length-1&&o.push(t):o=[t];else if(".."===t.value)o.length>1&&"/"===b(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return C(P([t,...o.map((t=>t.value))]))}function k(t){if(!t)return[];const e=[];if("/"===(t=C(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const r=t.split("/").filter(Boolean);return e.push(...r.map((t=>"$"===t||"*"===t?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function A(t,e,r=!1){return P(k(t).map((t=>{if("wildcard"===t.type){const o=e[t.value];return r?`${t.value}${o??""}`:o}return"param"===t.type?e[t.value.substring(1)]??"":t.value})))}function D(t,e,r){const o=B(t,e,r);if(!r.to||o)return o??{}}function B(t,e,r){e="/"!=t?e.substring(t.length):e;const o=`${r.to??"$"}`,s=k(e),n=k(o);e.startsWith("/")||s.unshift({type:"pathname",value:"/"}),o.startsWith("/")||n.unshift({type:"pathname",value:"/"});const a={};return(()=>{for(let t=0;t<Math.max(s.length,n.length);t++){const e=s[t],o=n[t],i=t>=s.length-1,c=t>=n.length-1;if(o){if("wildcard"===o.type)return!!e?.value&&(a["*"]=P(s.slice(t).map((t=>t.value))),!0);if("pathname"===o.type){if("/"===o.value&&!e?.value)return!0;if(e)if(r.caseSensitive){if(o.value!==e.value)return!1}else if(o.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===o.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(a[o.value.substring(1)]=e.value)}}if(!i&&c)return!!r.fuzzy}return!0})()?a:void 0}function $(t,e){var r,o,s,n="";for(r in t)if(void 0!==(s=t[r]))if(Array.isArray(s))for(o=0;o<s.length;o++)n&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(s[o]);else n&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(s);return(e||"")+n}function T(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0&&+e+""===e?+e:e))}function H(t){for(var e,r,o={},s=t.split("&");e=s.shift();)void 0!==o[r=(e=e.split("=")).shift()]?o[r]=[].concat(o[r],T(e.shift())):o[r]=T(e.shift());return o}const F="__root__";class N{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute,N.__onInit(this)}init=t=>{this.originalIndex=t.originalIndex,this.router=t.router;const e=this.options,r=!e?.path&&!e?.id;this.parentRoute=this.options?.getParentRoute?.(),r?this.path=F:h(this.parentRoute);let o=r?F:e.path;o&&"/"!==o&&(o=O(o));const s=e?.id||o;let n=r?F:P([this.parentRoute.id===F?"":this.parentRoute.id,s]);o===F&&(o="/"),n!==F&&(n=P(["/",n]));const a=n===F?"/":P([this.parentRoute.fullPath,o]);this.path=o,this.id=n,this.fullPath=a,this.to=a};addChildren=t=>(this.children=t,this);update=t=>(Object.assign(this.options,t),this);static __onInit=t=>{}}class U extends N{constructor(t){super(t)}}const z=J(JSON.parse),W=q(JSON.stringify);function J(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=H(e);for(let e in r){const o=r[e];if("string"==typeof o)try{r[e]=t(o)}catch(t){}}return r}}function q(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const o=e[r];if(void 0===o||void 0===o)delete e[r];else if(o&&"object"==typeof o&&null!==o)try{e[r]=t(o)}catch(t){}}));const r=$(e).toString();return r?`?${r}`:""}}const K=["component","errorComponent","pendingComponent"];const Y="undefined"==typeof window||!window.document.createElement;function V(){return{status:"idle",isFetching:!1,resolvedLocation:null,location:null,matchesById:{},matchIds:[],pendingMatchIds:[],matches:[],pendingMatches:[],lastUpdated:Date.now()}}function G(t){return!!t?.isRedirect}class Q extends Error{}class X extends Error{}function Z(t){const e=nt(),{type:r,children:o,target:n,activeProps:a=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:h,hash:u,search:l,params:d,to:p=".",preload:f,preloadDelay:m,replace:y,style:g,className:v,onClick:w,onFocus:b,onMouseEnter:x,onMouseLeave:E,onTouchStart:R,...I}=t,_=e.buildLink(t);if("external"===_.type){const{href:t}=_;return{href:t}}const{handleClick:P,handleFocus:C,handleEnter:M,handleLeave:L,handleTouchStart:O,isActive:j,next:k}=_,A=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},D=j?S(a,{})??{}:{},B=j?{}:S(i,{})??{};return{...D,...B,...I,href:h?void 0:k.href,onClick:A([w,e=>{(t.startTransition??1)&&(s.startTransition||(t=>t))((()=>{P(e)}))}]),onFocus:A([b,C]),onMouseEnter:A([x,M]),onMouseLeave:A([E,L]),onTouchStart:A([R,O]),target:n,style:{...g,...D.style,...B.style},className:[v,D.className,B.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":j?"active":void 0}}N.__onInit=t=>{Object.assign(t,{useMatch:(e={})=>at({...e,from:t.id}),useLoader:(e={})=>it({...e,from:t.id}),useContext:(e={})=>at({...e,from:t.id,select:t=>e?.select?.(t.context)??t.context}),useRouteContext:(e={})=>at({...e,from:t.id,select:t=>e?.select?.(t.routeContext)??t.routeContext}),useSearch:(e={})=>ct({...e,from:t.id}),useParams:(e={})=>ht({...e,from:t.id})})};const tt=s.forwardRef(((t,e)=>{const r=Z(t);return s.createElement("a",n({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))}));const et=s.createContext(null),rt=s.createContext(null);function ot(t){return i(nt().__store,t?.select)}function st(){const t=nt(),e=ot({select:e=>e.pendingMatches.some((e=>!!t.getRoute(e.routeId)?.options.pendingComponent))?(console.log("hasPending"),e.pendingMatchIds):e.matchIds});return s.createElement(et.Provider,{value:[void 0,...e]},s.createElement(yt,{errorComponent:vt,onCatch:()=>{}},s.createElement(lt,null)))}function nt(){return s.useContext(rt)}function at(t){const e=nt(),r=s.useContext(et)[0],o=e.getRouteMatch(r)?.routeId,n=ot({select:e=>{const o=e.matches;return(t?.from?o.find((e=>e.routeId===t?.from)):o.find((t=>t.id===r))).routeId}});(t?.strict??1)&&h(o==n);return ot({select:e=>{const o=e.matches,s=t?.from?o.find((e=>e.routeId===t?.from)):o.find((t=>t.id===r));return h(s,t?.from&&t.from),t?.select?.(s)??s}})}function it(t){return at({...t,select:e=>t?.select?.(e.loaderData)??e.loaderData})}function ct(t){return at({...t,select:e=>t?.select?.(e.search)??e.search})}function ht(t){return ot({select:e=>{const r=b(e.matches)?.params;return t?.select?.(r)??r}})}function ut(){const t=nt();return s.useCallback((e=>{const{pending:r,caseSensitive:o,...s}=e;return t.matchRoute(s,{pending:r,caseSensitive:o})}),[])}function lt(){const t=s.useContext(et).slice(1);return t[0]?s.createElement(pt,{matchIds:t}):null}const dt=()=>null;function pt({matchIds:t}){const e=nt(),r=t[0],o=e.getRouteMatch(r).routeId,n=e.getRoute(o),a=n.options.pendingComponent??e.options.defaultPendingComponent??dt,i=n.options.errorComponent??e.options.defaultErrorComponent??vt,c=n.options.wrapInSuspense??!n.isRoot?s.Suspense:mt,h=i?yt:mt;return s.createElement(et.Provider,{value:t},s.createElement(c,{fallback:s.createElement(a,{useLoader:n.useLoader,useMatch:n.useMatch,useContext:n.useContext,useRouteContext:n.useRouteContext,useSearch:n.useSearch,useParams:n.useParams})},s.createElement(h,{key:n.id,errorComponent:i,onCatch:()=>{}},s.createElement(ft,{matchId:r,PendingComponent:a}))))}function ft({matchId:t,PendingComponent:e}){const r=nt(),o=ot({select:e=>x(e.matchesById[t],["status","loadPromise","routeId","error"])}),n=r.getRoute(o.routeId);if("error"===o.status)throw o.error;if("pending"===o.status)return s.createElement(e,{useLoader:n.useLoader,useMatch:n.useMatch,useContext:n.useContext,useRouteContext:n.useRouteContext,useSearch:n.useSearch,useParams:n.useParams});if("success"===o.status){let t=n.options.component??r.options.defaultComponent;return t?s.createElement(t,{useLoader:n.useLoader,useMatch:n.useMatch,useContext:n.useContext,useRouteContext:n.useRouteContext,useSearch:n.useSearch,useParams:n.useParams}):s.createElement(lt,null)}h(!1)}function mt(t){return s.createElement(s.Fragment,null,t.children)}class yt extends s.Component{state={error:!1,info:void 0};componentDidCatch(t,e){this.props.onCatch(t,e),this.setState({error:t,info:e})}render(){return s.createElement(gt,n({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function gt(t){const e=ot({select:t=>t.resolvedLocation.key}),[r,o]=s.useState(t.errorState),n=t.errorComponent??vt,a=s.useRef("");return s.useEffect((()=>{r&&e!==a.current&&o({}),a.current=e}),[r,e]),s.useEffect((()=>{t.errorState.error&&o(t.errorState)}),[t.errorState.error]),t.errorState.error&&r.error?s.createElement(n,r):t.children}function vt({error:t}){const[e,r]=s.useState(!1);return s.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},s.createElement("div",{style:{display:"flex",alignItems:"center",gap:".5rem"}},s.createElement("strong",{style:{fontSize:"1rem"}},"Something went wrong!"),s.createElement("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>r((t=>!t))},e?"Hide Error":"Show Error")),s.createElement("div",{style:{height:".25rem"}}),e?s.createElement("div",null,s.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"}},t.message?s.createElement("code",null,t.message):null)):null)}function wt(t,e=!0){const r=nt();s.useEffect((()=>{if(!e)return;let o=r.history.block(((e,r)=>{window.confirm(t)&&(o(),e())}));return o}))}t.Block=function({message:t,condition:e,children:r}){return wt(t,e),r??null},t.ErrorComponent=vt,t.Link=tt,t.MatchRoute=function(t){const e=ut()(t);return"function"==typeof t.children?t.children(e):e?t.children:null},t.Navigate=function(t){const e=nt();return s.useLayoutEffect((()=>{e.navigate(t)}),[]),null},t.Outlet=lt,t.PathParamError=X,t.RootRoute=U,t.Route=N,t.Router=class{#t;constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??W,parseSearch:t?.parseSearch??z},this.__store=new a(V(),{onUpdate:()=>{const t=this.state;this.state=this.__store.state;const e=t.matchesById!==this.state.matchesById;let r,o;e||(r=t.matchIds.length!==this.state.matchIds.length||t.matchIds.some(((t,e)=>t!==this.state.matchIds[e])),o=t.pendingMatchIds.length!==this.state.pendingMatchIds.length||t.pendingMatchIds.some(((t,e)=>t!==this.state.pendingMatchIds[e]))),(e||r)&&(this.state.matches=this.state.matchIds.map((t=>this.state.matchesById[t]))),(e||o)&&(this.state.pendingMatches=this.state.pendingMatchIds.map((t=>this.state.matchesById[t]))),this.state.isFetching=[...this.state.matches,...this.state.pendingMatches].some((t=>t.isFetching))},defaultPriority:"low"}),this.state=this.__store.state,this.update(t);const e=this.buildNext({hash:!0,fromCurrent:!0,search:!0,state:!0});this.state.location.href!==e.href&&this.#e({...e,replace:!0})}reset=()=>{this.__store.setState((t=>Object.assign(t,V())))};mount=()=>{this.safeLoad()};update=t=>{if(this.options={...this.options,...t,context:{...this.options.context,...t?.context}},!this.history||this.options.history&&this.options.history!==this.history){this.#t&&this.#t(),this.history=this.options.history??(Y?g():y());const t=this.#r();this.__store.setState((e=>({...e,resolvedLocation:t,location:t}))),this.#t=this.history.listen((()=>{this.safeLoad({next:this.#r(this.state.location)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${O(e??"")??""}`,r&&r!==this.routeTree&&this.#o(r),this};buildNext=t=>{const e=this.#s(t),r=this.matchRoutes(e.pathname,e.search);return this.#s({...t,__matches:r})};cancelMatches=()=>{this.state.matches.forEach((t=>{this.cancelMatch(t.id)}))};cancelMatch=t=>{this.getRouteMatch(t)?.abortController?.abort()};safeLoad=t=>this.load(t).catch((t=>{}));latestLoadPromise=Promise.resolve();load=async t=>{const e=new Promise((async(r,o)=>{let s;const n=()=>this.latestLoadPromise!==e?this.latestLoadPromise:void 0;let a;this.__store.batch((()=>{t?.next&&this.__store.setState((e=>({...e,location:t.next}))),a=this.matchRoutes(this.state.location.pathname,this.state.location.search,{throwOnError:t?.throwOnError,debug:!0}),this.__store.setState((t=>({...t,status:"pending",pendingMatchIds:a.map((t=>t.id)),matchesById:this.#n(t.matchesById,a)})))}));try{if(await this.loadMatches(a),s=n())return await s;const t=this.state.resolvedLocation;this.__store.setState((t=>({...t,status:"idle",resolvedLocation:t.location,matchIds:t.pendingMatchIds,pendingMatchIds:[]}))),t.href!==this.state.location.href&&this.options.onRouteChange?.(),r()}catch(t){if(s=n())return await s;o(t)}}));return this.latestLoadPromise=e,this.latestLoadPromise};#n=(t,e)=>{const r={...t};let o=!1;return e.forEach((t=>{r[t.id]||(o=!0,r[t.id]=t)})),o?r:t};getRoute=t=>{const e=this.routesById[t];return h(e),e};preloadRoute=async(t=this.state.location)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,e.search,{throwOnError:!0});return this.__store.setState((t=>({...t,matchesById:this.#n(t.matchesById,r)}))),await this.loadMatches(r,{preload:!0,maxAge:t.maxAge}),r};cleanMatches=()=>{const t=Date.now(),e=Object.values(this.state.matchesById).filter((e=>{const r=this.getRoute(e.routeId);return!this.state.matchIds.includes(e.id)&&!this.state.pendingMatchIds.includes(e.id)&&e.preloadInvalidAt<t&&(!r.options.gcMaxAge||e.updatedAt+r.options.gcMaxAge<t)})).map((t=>t.id));e.length&&this.__store.setState((t=>{const r={...t.matchesById};return e.forEach((t=>{delete r[t]})),{...t,matchesById:r}}))};matchRoutes=(t,e,r)=>{let o={},s=this.flatRoutes.find((e=>{const r=D(this.basepath,t,{to:e.fullPath,caseSensitive:e.options.caseSensitive??this.options.caseSensitive});return!!r&&(o=r,!0)}))||this.routesById.__root__,n=[s];for(;s?.parentRoute;)s=s.parentRoute,s&&n.unshift(s);let a={};const i=n.map((t=>{let s,n;try{s=t.options.parseParams?.(o)??o}catch(t){if(n=new X(t.message,{cause:t}),r?.throwOnError)throw n}Object.assign(a,s);const i=A(t.path,a),c=t.options.key?t.options.key({params:a,search:e})??"":"",h=c?JSON.stringify(c):"",u=A(t.id,a,!0)+h,l=this.getRouteMatch(u);if(l)return{...l};const d=!(!t.options.loader&&!K.some((e=>t.options[e]?.preload)));return{id:u,key:h,routeId:t.id,params:a,pathname:P([this.basepath,i]),updatedAt:Date.now(),invalidAt:1/0,preloadInvalidAt:1/0,routeSearch:{},search:{},status:d?"idle":"success",isFetching:!1,invalid:!1,error:void 0,paramsError:n,searchError:void 0,loaderData:void 0,loadPromise:Promise.resolve(),routeContext:void 0,context:void 0,abortController:new AbortController,fetchedAt:0}}));return i.forEach(((t,o)=>{const s=i[o-1],n=this.getRoute(t.routeId),a=(()=>{const o={search:s?.search??e,routeSearch:s?.routeSearch??e};try{const e=("object"==typeof n.options.validateSearch?n.options.validateSearch.parse:n.options.validateSearch)?.(o.search)??{},r={...o.search,...e};return{routeSearch:E(t.routeSearch,e),search:E(t.search,r)}}catch(e){if(t.searchError=new Q(e.message,{cause:e}),r?.throwOnError)throw t.searchError;return o}})(),c=(()=>{try{const e=n.options.getContext?.({parentContext:s?.routeContext??{},context:s?.context??this?.options.context??{},params:t.params,search:t.search})||{};return{context:{...s?.context??this?.options.context,...e},routeContext:e}}catch(t){throw n.options.onError?.(t),t}})();Object.assign(t,{...a,...c})})),i};loadMatches=async(t,e)=>{let r;this.cleanMatches();try{await Promise.all(t.map((async(t,o)=>{const s=this.getRoute(t.routeId);e?.preload||this.setRouteMatch(t.id,(e=>({...e,routeSearch:t.routeSearch,search:t.search,routeContext:t.routeContext,context:t.context,error:t.error,paramsError:t.paramsError,searchError:t.searchError,params:t.params})));const n=(e,n)=>{if(r=r??o,n=n||s.options.onError,G(e))throw e;try{n?.(e)}catch(t){if(e=t,G(t))throw t}this.setRouteMatch(t.id,(t=>({...t,error:e,status:"error",updatedAt:Date.now()})))};t.paramsError&&n(t.paramsError,s.options.onParseParamsError),t.searchError&&n(t.searchError,s.options.onValidateSearchError);try{await(s.options.beforeLoad?.({...t,preload:!!e?.preload}))}catch(t){n(t,s.options.onBeforeLoadError)}})))}catch(t){throw e?.preload||this.navigate(t),t}const o=t.slice(0,r),s=[];o.forEach(((t,r)=>{s.push((async()=>{const o=s[r-1],n=this.getRoute(t.routeId);if(t.isFetching||"success"===t.status&&!this.getIsInvalid({matchId:t.id,preload:e?.preload}))return this.getRouteMatch(t.id)?.loadPromise;const a=Date.now(),i=()=>{const e=this.getRouteMatch(t.id);return e&&e.fetchedAt!==a?e.loadPromise:void 0},c=(async()=>{let r;const s=Promise.all(K.map((async t=>{const e=n.options[t];e?.preload&&await e.preload()}))),a=n.options.loader?.({...t,preload:!!e?.preload,parentMatchPromise:o}),c=t=>!!G(t)&&(e?.preload||this.navigate(t),!0);try{const[o,n]=await Promise.all([s,a]);if(r=i())return await r;this.setRouteMatchData(t.id,(()=>n),e)}catch(e){if(r=i())return await r;if(c(e))return;const o=n.options.onLoadError??n.options.onError;let s=e;try{o?.(e)}catch(t){if(s=t,c(t))return}this.setRouteMatch(t.id,(t=>({...t,error:s,status:"error",isFetching:!1,updatedAt:Date.now()})))}})();this.setRouteMatch(t.id,(t=>({...t,status:"success"!==t.status?"pending":t.status,isFetching:!0,loadPromise:c,fetchedAt:a,invalid:!1}))),await c})())})),await Promise.all(s)};reload=()=>this.navigate({fromCurrent:!0,replace:!0,search:!0});resolvePath=(t,e)=>j(this.basepath,t,C(e));navigate=async({from:t,to:e="",search:r,hash:o,replace:s,params:n})=>{const a=String(e),i=void 0===t?t:String(t);let c;try{new URL(`${a}`),c=!0}catch(t){}return h(!c),this.#e({from:i,to:a,search:r,hash:o,replace:s,params:n})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t);if(e?.pending&&"pending"!==this.state.status)return!1;const o=e?.pending?this.state.location:this.state.resolvedLocation;if(!o)return!1;const s=D(this.basepath,o.pathname,{...e,to:r.pathname});return!!s&&(e?.includeSearch??1?!!_(o.search,r.search)&&s:s)};buildLink=({from:t,to:e=".",search:r,params:o,hash:s,target:n,replace:a,activeOptions:i,preload:c,preloadDelay:h,disabled:u})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const l={from:t,to:e,search:r,params:o,hash:s,replace:a},d=this.buildNext(l);c=c??this.options.defaultPreload;const p=h??this.options.defaultPreloadDelay??0,f=this.state.location.pathname.split("/"),m=d.pathname.split("/").every(((t,e)=>t===f[e])),y=i?.exact?this.state.location.pathname===d.pathname:m,g=!i?.includeHash||this.state.location.hash===d.hash,v=!(i?.includeSearch??1)||_(this.state.location.search,d.search);return{type:"internal",next:d,handleFocus:t=>{c&&this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{u||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||n&&"_self"!==n||0!==t.button||(t.preventDefault(),this.#e(l))},handleEnter:t=>{const e=t.target||{};if(c){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),p)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},isActive:y&&g&&v,disabled:u}};dehydrate=()=>({state:x(this.state,["location","status","lastUpdated"])});hydrate=async t=>{let e=t;"undefined"!=typeof document&&(e=window.__TSR_DEHYDRATED__),h(e);const r=e;this.dehydratedData=r.payload,this.options.hydrate?.(r.payload),this.__store.setState((t=>({...t,...r.router.state,resolvedLocation:r.router.state.location}))),await this.load()};injectedHtml=[];injectHtml=async t=>{this.injectedHtml.push(t)};dehydrateData=(t,e)=>{if("undefined"==typeof document){const r="string"==typeof t?t:JSON.stringify(t);return this.injectHtml((async()=>{const t=`__TSR_DEHYDRATED__${r}`,o="function"==typeof e?await e():e;return`<script id='${t}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${s=r,s.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"')}"] = ${JSON.stringify(o)}\n ;(() => {\n var el = document.getElementById('${t}')\n el.parentElement.removeChild(el)\n })()\n <\/script>`;var s})),()=>this.hydrateData(t)}return()=>{}};hydrateData=t=>{if("undefined"!=typeof document){const e="string"==typeof t?t:JSON.stringify(t);return window[`__TSR_DEHYDRATED__${e}`]}};#o=t=>{this.routeTree=t,this.routesById={},this.routesByPath={},this.flatRoutes=[];const e=t=>{t.forEach(((t,r)=>{t.init({originalIndex:r,router:this});if(h(!this.routesById[t.id],String(t.id)),this.routesById[t.id]=t,!t.isRoot&&t.path){const e=L(t.fullPath);this.routesByPath[e]&&!t.fullPath.endsWith("/")||(this.routesByPath[e]=t)}const o=t.children;o?.length&&e(o)}))};e([t]),this.flatRoutes=Object.values(this.routesByPath).map(((t,e)=>{const r=O(t.fullPath),o=k(r);for(;o.length>1&&"/"===o[0]?.value;)o.shift();const s=o.map((t=>"param"===t.type?.5:"wildcard"===t.type?.25:1));return{child:t,trimmed:r,parsed:o,index:e,score:s}})).sort(((t,e)=>{let r="/"===t.trimmed?1:"/"===e.trimmed?-1:0;if(0!==r)return r;const o=Math.min(t.score.length,e.score.length);if(t.score.length!==e.score.length)return e.score.length-t.score.length;for(let r=0;r<o;r++)if(t.score[r]!==e.score[r])return e.score[r]-t.score[r];for(let r=0;r<o;r++)if(t.parsed[r].value!==e.parsed[r].value)return t.parsed[r].value>e.parsed[r].value?1:-1;return t.trimmed!==e.trimmed?t.trimmed>e.trimmed?1:-1:t.index-e.index})).map(((t,e)=>(t.child.rank=e,t.child)))};#r=t=>{let{pathname:e,search:r,hash:o,state:s}=this.history.location;const n=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:E(t?.search,n),hash:o.split("#").reverse()[0]??"",href:`${e}${r}${o}`,state:s,key:s?.key||"__init__"}};#s=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.location.pathname:t.from??this.state.location.pathname;let r=j(this.basepath??"/",e,`${t.to??""}`);const o={...b(this.matchRoutes(this.state.location.pathname,this.state.location.search))?.params};let s=!0===(t.params??!0)?o:S(t.params,o);s&&t.__matches?.map((t=>this.getRoute(t.routeId).options.stringifyParams)).filter(Boolean).forEach((t=>{s={...s,...t(s)}})),r=A(r,s??{});const n=t.__matches?.map((t=>this.getRoute(t.routeId).options.preSearchFilters??[])).flat().filter(Boolean)??[],a=t.__matches?.map((t=>this.getRoute(t.routeId).options.postSearchFilters??[])).flat().filter(Boolean)??[],i=n?.length?n?.reduce(((t,e)=>e(t)),this.state.location.search):this.state.location.search,c=!0===t.search?i:t.search?S(t.search,i)??{}:n?.length?i:{},h=a?.length?a.reduce(((t,e)=>e(t)),c):c,u=E(this.state.location.search,h),l=this.options.stringifySearch(u),d=!0===t.hash?this.state.location.hash:S(t.hash,this.state.location.hash),p=d?`#${d}`:"";return{pathname:r,search:u,searchStr:l,state:!0===t.state?this.state.location.state:S(t.state,this.state.location.state),hash:d,href:this.history.createHref(`${r}${l}${p}`),key:t.key}};#e=async t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let o="replace";t.replace||(o="push");this.state.location.href===e.href&&!e.key&&(o="replace");const s=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===o?"push":"replace"](s,{id:r,...e.state}),this.latestLoadPromise};getRouteMatch=t=>this.state.matchesById[t];setRouteMatch=(t,e)=>{this.__store.setState((r=>({...r,matchesById:{...r.matchesById,[t]:e(r.matchesById[t])}})))};setRouteMatchData=(t,e,r)=>{const o=this.getRouteMatch(t);if(!o)return;const s=this.getRoute(o.routeId),n=r?.updatedAt??Date.now(),a=n+(r?.maxAge??s.options.preloadMaxAge??this.options.defaultPreloadMaxAge??5e3),i=n+(r?.maxAge??s.options.maxAge??this.options.defaultMaxAge??1/0);this.setRouteMatch(t,(t=>({...t,error:void 0,status:"success",isFetching:!1,updatedAt:Date.now(),loaderData:S(e,t.loaderData),preloadInvalidAt:a,invalidAt:i}))),this.state.matches.find((e=>e.id===t))};invalidate=async t=>{if(t?.matchId){this.setRouteMatch(t.matchId,(t=>({...t,invalid:!0})));const e=this.state.matches.findIndex((e=>e.id===t.matchId)),r=this.state.matches[e+1];if(r)return this.invalidate({matchId:r.id,reload:!1})}else this.__store.batch((()=>{Object.values(this.state.matchesById).forEach((t=>{this.setRouteMatch(t.id,(t=>({...t,invalid:!0})))}))}));if(t?.reload??1)return this.reload()};getIsInvalid=t=>{if(!t?.matchId)return!!this.state.matches.find((e=>this.getIsInvalid({matchId:e.id,preload:t?.preload})));const e=this.getRouteMatch(t?.matchId);if(!e)return!1;const r=Date.now();return e.invalid||(t?.preload?e.preloadInvalidAt:e.invalidAt)<r}},t.RouterContext=class{constructor(){}createRootRoute=t=>new U(t)},t.RouterProvider=function({router:t,...e}){t.update(e),s.useEffect((()=>{let e;return s.startTransition((()=>{e=t.mount()})),e}),[t]);const r=t.options.Wrap||s.Fragment;return s.createElement(s.Suspense,{fallback:null},s.createElement(r,null,s.createElement(rt.Provider,{value:t},s.createElement(st,null))))},t.SearchParamError=Q,t.cleanPath=C,t.componentTypes=K,t.createBrowserHistory=y,t.createHashHistory=function(){return y({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=g,t.decode=H,t.defaultParseSearch=z,t.defaultStringifySearch=W,t.encode=$,t.functionalUpdate=S,t.interpolatePath=A,t.invariant=h,t.isPlainObject=R,t.isRedirect=G,t.joinPaths=P,t.last=b,t.lazyFn=function(t,e){return async(...r)=>(await t())[e||"default"](...r)},t.lazyRouteComponent=function(t,e){let r;const o=()=>(r||(r=t()),r),n=s.lazy((async()=>({default:(await o())[e??"default"]})));return n.preload=o,n},t.matchByPath=B,t.matchIdsContext=et,t.matchPathname=D,t.parsePathname=k,t.parseSearchWith=J,t.partialDeepEqual=_,t.pick=x,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=E,t.resolvePath=j,t.rootRouteId=F,t.routerContext=rt,t.shallow=function(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(e,r[o])||!Object.is(t[r[o]],e[r[o]]))return!1;return!0},t.stringifySearchWith=q,t.trimPath=O,t.trimPathLeft=M,t.trimPathRight=L,t.useBlocker=wt,t.useDehydrate=function(){const t=nt();return s.useCallback((function(e,r){return t.dehydrateData(e,r)}),[])},t.useHydrate=function(){const t=nt();return function(e){return t.hydrateData(e)}},t.useInjectHtml=function(){const t=nt();return s.useCallback((e=>{t.injectHtml(e)}),[])},t.useLinkProps=Z,t.useLoader=it,t.useMatch=at,t.useMatchRoute=ut,t.useMatches=function(t){const e=s.useContext(et);return ot({select:r=>{const o=r.matches.slice(r.matches.findIndex((t=>t.id===e[0])));return t?.select?.(o)??o}})},t.useNavigate=function(t){const e=nt();return s.useCallback((r=>e.navigate({...t,...r})),[])},t.useParams=ht,t.useRouteContext=function(t){return at({...t,select:e=>t?.select?.(e.routeContext)??e.routeContext})},t.useRouter=nt,t.useRouterContext=function(t){return at({...t,select:e=>t?.select?.(e.context)??e.context})},t.useRouterState=ot,t.useSearch=ct,t.useStore=i,t.warning=function(t,e){},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
const u="pushstate",l="popstate",d="beforeunload",p=t=>(t.preventDefault(),t.returnValue=""),f=()=>{removeEventListener(d,p,{capture:!0})};function m(t){let e=t.getLocation(),r=()=>{},o=new Set,s=[],n=[];const a=()=>{if(s.length)s[0]?.(a,(()=>{s=[],f()}));else{for(;n.length;)n.shift()?.();t.listener||c()}},i=t=>{n.push(t),a()},c=()=>{e=t.getLocation(),o.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===o.size&&(r="function"==typeof t.listener?t.listener(c):()=>{}),o.add(e),()=>{o.delete(e),0===o.size&&r()}),push:(e,r)=>{i((()=>{t.pushState(e,r)}))},replace:(e,r)=>{i((()=>{t.replaceState(e,r)}))},go:e=>{i((()=>{t.go(e)}))},back:()=>{i((()=>{t.back()}))},forward:()=>{i((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(s.push(t),1===s.length&&addEventListener(d,p,{capture:!0}),()=>{s=s.filter((e=>e!==t)),s.length||f()})}}function y(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=t?.createHref??(t=>t);return m({getLocation:()=>v(e(),history.state),listener:t=>{window.addEventListener(u,t),window.addEventListener(l,t);var e=window.history.pushState;window.history.pushState=function(){let r=e.apply(history,arguments);return t(),r};var r=window.history.replaceState;return window.history.replaceState=function(){let e=r.apply(history,arguments);return t(),e},()=>{window.history.pushState=e,window.history.replaceState=r,window.removeEventListener(u,t),window.removeEventListener(l,t)}},pushState:(t,e)=>{window.history.pushState({...e,key:w()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:w()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t)})}function g(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,o={};return m({getLocation:()=>v(e[r],o),listener:!1,pushState:(t,s)=>{o={...s,key:w()},e.push(t),r++},replaceState:(t,s)=>{o={...s,key:w()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function v(t,e){let r=t.indexOf("#"),o=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?o>0?Math.min(r,o):r:o>0?o:t.length),hash:r>-1?t.substring(r):"",search:o>-1?t.slice(o,-1===r?void 0:r):"",state:e}}function w(){return(Math.random()+1).toString(36).substring(7)}function b(t){return t[t.length-1]}function S(t,e){return"function"==typeof t?t(e):t}function R(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function x(t,e){if(t===e)return t;const r=e,o=Array.isArray(t)&&Array.isArray(r);if(o||E(t)&&E(r)){const e=o?t.length:Object.keys(t).length,s=o?r:Object.keys(r),n=s.length,a=o?[]:{};let i=0;for(let e=0;e<n;e++){const n=o?e:s[e];a[n]=x(t[n],r[n]),a[n]===t[n]&&i++}return e===n&&i===e?t:a}return r}function E(t){if(!I(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!I(r)&&!!r.hasOwnProperty("isPrototypeOf")}function I(t){return"[object Object]"===Object.prototype.toString.call(t)}function _(t,e){return t===e||typeof t==typeof e&&(E(t)&&E(e)?!Object.keys(e).some((r=>!_(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>_(t,e[r])))))}function P(t){return C(t.filter(Boolean).join("/"))}function C(t){return t.replace(/\/{2,}/g,"/")}function M(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function L(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function O(t){return L(M(t))}function j(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let o=k(e);const s=k(r);s.forEach(((t,e)=>{if("/"===t.value)e?e===s.length-1&&o.push(t):o=[t];else if(".."===t.value)o.length>1&&"/"===b(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return C(P([t,...o.map((t=>t.value))]))}function k(t){if(!t)return[];const e=[];if("/"===(t=C(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const r=t.split("/").filter(Boolean);return e.push(...r.map((t=>"$"===t||"*"===t?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function A(t,e,r=!1){return P(k(t).map((t=>{if("wildcard"===t.type){const o=e[t.value];return r?`${t.value}${o??""}`:o}return"param"===t.type?e[t.value.substring(1)]??"":t.value})))}function D(t,e,r){const o=B(t,e,r);if(!r.to||o)return o??{}}function B(t,e,r){e="/"!=t?e.substring(t.length):e;const o=`${r.to??"$"}`,s=k(e),n=k(o);e.startsWith("/")||s.unshift({type:"pathname",value:"/"}),o.startsWith("/")||n.unshift({type:"pathname",value:"/"});const a={};return(()=>{for(let t=0;t<Math.max(s.length,n.length);t++){const e=s[t],o=n[t],i=t>=s.length-1,c=t>=n.length-1;if(o){if("wildcard"===o.type)return!!e?.value&&(a["*"]=P(s.slice(t).map((t=>t.value))),!0);if("pathname"===o.type){if("/"===o.value&&!e?.value)return!0;if(e)if(r.caseSensitive){if(o.value!==e.value)return!1}else if(o.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===o.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(a[o.value.substring(1)]=e.value)}}if(!i&&c)return!!r.fuzzy}return!0})()?a:void 0}function $(t,e){var r,o,s,n="";for(r in t)if(void 0!==(s=t[r]))if(Array.isArray(s))for(o=0;o<s.length;o++)n&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(s[o]);else n&&(n+="&"),n+=encodeURIComponent(r)+"="+encodeURIComponent(s);return(e||"")+n}function T(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0&&+e+""===e?+e:e))}function H(t){for(var e,r,o={},s=t.split("&");e=s.shift();)void 0!==o[r=(e=e.split("=")).shift()]?o[r]=[].concat(o[r],T(e.shift())):o[r]=T(e.shift());return o}const F="__root__";class N{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute,N.__onInit(this)}init=t=>{this.originalIndex=t.originalIndex,this.router=t.router;const e=this.options,r=!e?.path&&!e?.id;this.parentRoute=this.options?.getParentRoute?.(),r?this.path=F:h(this.parentRoute);let o=r?F:e.path;o&&"/"!==o&&(o=O(o));const s=e?.id||o;let n=r?F:P([this.parentRoute.id===F?"":this.parentRoute.id,s]);o===F&&(o="/"),n!==F&&(n=P(["/",n]));const a=n===F?"/":P([this.parentRoute.fullPath,o]);this.path=o,this.id=n,this.fullPath=a,this.to=a};addChildren=t=>(this.children=t,this);update=t=>(Object.assign(this.options,t),this);static __onInit=t=>{}}class U extends N{constructor(t){super(t)}}const z=J(JSON.parse),W=q(JSON.stringify);function J(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=H(e);for(let e in r){const o=r[e];if("string"==typeof o)try{r[e]=t(o)}catch(t){}}return r}}function q(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const o=e[r];if(void 0===o||void 0===o)delete e[r];else if(o&&"object"==typeof o&&null!==o)try{e[r]=t(o)}catch(t){}}));const r=$(e).toString();return r?`?${r}`:""}}const K=["component","errorComponent","pendingComponent"];const Y="undefined"==typeof window||!window.document.createElement;function V(){return{status:"idle",isFetching:!1,resolvedLocation:null,location:null,matchesById:{},matchIds:[],pendingMatchIds:[],matches:[],pendingMatches:[],lastUpdated:Date.now()}}function G(t){return!!t?.isRedirect}class Q extends Error{}class X extends Error{}function Z(t){const e=nt(),{type:r,children:o,target:n,activeProps:a=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:h,hash:u,search:l,params:d,to:p=".",preload:f,preloadDelay:m,replace:y,style:g,className:v,onClick:w,onFocus:b,onMouseEnter:R,onMouseLeave:x,onTouchStart:E,...I}=t,_=e.buildLink(t);if("external"===_.type){const{href:t}=_;return{href:t}}const{handleClick:P,handleFocus:C,handleEnter:M,handleLeave:L,handleTouchStart:O,isActive:j,next:k}=_,A=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},D=j?S(a,{})??{}:{},B=j?{}:S(i,{})??{};return{...D,...B,...I,href:h?void 0:k.href,onClick:A([w,e=>{(t.startTransition??1)&&(s.startTransition||(t=>t))((()=>{P(e)}))}]),onFocus:A([b,C]),onMouseEnter:A([R,M]),onMouseLeave:A([x,L]),onTouchStart:A([E,O]),target:n,style:{...g,...D.style,...B.style},className:[v,D.className,B.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":j?"active":void 0}}N.__onInit=t=>{Object.assign(t,{useMatch:(e={})=>at({...e,from:t.id}),useLoader:(e={})=>it({...e,from:t.id}),useContext:(e={})=>at({...e,from:t.id,select:t=>e?.select?.(t.context)??t.context}),useRouteContext:(e={})=>at({...e,from:t.id,select:t=>e?.select?.(t.routeContext)??t.routeContext}),useSearch:(e={})=>ct({...e,from:t.id}),useParams:(e={})=>ht({...e,from:t.id})})};const tt=s.forwardRef(((t,e)=>{const r=Z(t);return s.createElement("a",n({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))}));const et=s.createContext(null),rt=s.createContext(null);function ot(t){return i(nt().__store,t?.select)}function st(){const t=nt(),e=ot({select:e=>e.pendingMatches.some((e=>!!t.getRoute(e.routeId)?.options.pendingComponent))?(console.log("hasPending"),e.pendingMatchIds):e.matchIds});return s.createElement(et.Provider,{value:[void 0,...e]},s.createElement(yt,{errorComponent:vt,onCatch:()=>{}},s.createElement(lt,null)))}function nt(){return s.useContext(rt)}function at(t){const e=nt(),r=s.useContext(et)[0],o=e.getRouteMatch(r)?.routeId,n=ot({select:e=>{const o=e.matches;return(t?.from?o.find((e=>e.routeId===t?.from)):o.find((t=>t.id===r))).routeId}});(t?.strict??1)&&h(o==n);return ot({select:e=>{const o=e.matches,s=t?.from?o.find((e=>e.routeId===t?.from)):o.find((t=>t.id===r));return h(s,t?.from&&t.from),t?.select?.(s)??s}})}function it(t){return at({...t,select:e=>t?.select?.(e.loaderData)??e.loaderData})}function ct(t){return at({...t,select:e=>t?.select?.(e.search)??e.search})}function ht(t){return ot({select:e=>{const r=b(e.matches)?.params;return t?.select?.(r)??r}})}function ut(){const t=nt();return s.useCallback((e=>{const{pending:r,caseSensitive:o,...s}=e;return t.matchRoute(s,{pending:r,caseSensitive:o})}),[])}function lt(){const t=s.useContext(et).slice(1);return t[0]?s.createElement(pt,{matchIds:t}):null}const dt=()=>null;function pt({matchIds:t}){const e=nt(),r=t[0],o=e.getRouteMatch(r).routeId,n=e.getRoute(o),a=n.options.pendingComponent??e.options.defaultPendingComponent??dt,i=n.options.errorComponent??e.options.defaultErrorComponent??vt,c=n.options.wrapInSuspense??!n.isRoot?s.Suspense:mt,h=i?yt:mt;return s.createElement(et.Provider,{value:t},s.createElement(c,{fallback:s.createElement(a,{useLoader:n.useLoader,useMatch:n.useMatch,useContext:n.useContext,useRouteContext:n.useRouteContext,useSearch:n.useSearch,useParams:n.useParams})},s.createElement(h,{key:n.id,errorComponent:i,onCatch:()=>{}},s.createElement(ft,{matchId:r,PendingComponent:a}))))}function ft({matchId:t,PendingComponent:e}){const r=nt(),o=ot({select:e=>R(e.matchesById[t],["status","loadPromise","routeId","error"])}),n=r.getRoute(o.routeId);if("error"===o.status)throw o.error;if("pending"===o.status)return s.createElement(e,{useLoader:n.useLoader,useMatch:n.useMatch,useContext:n.useContext,useRouteContext:n.useRouteContext,useSearch:n.useSearch,useParams:n.useParams});if("success"===o.status){let t=n.options.component??r.options.defaultComponent;return t?s.createElement(t,{useLoader:n.useLoader,useMatch:n.useMatch,useContext:n.useContext,useRouteContext:n.useRouteContext,useSearch:n.useSearch,useParams:n.useParams}):s.createElement(lt,null)}h(!1)}function mt(t){return s.createElement(s.Fragment,null,t.children)}class yt extends s.Component{state={error:!1,info:void 0};componentDidCatch(t,e){this.props.onCatch(t,e),this.setState({error:t,info:e})}render(){return s.createElement(gt,n({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function gt(t){const e=ot({select:t=>t.resolvedLocation.key}),[r,o]=s.useState(t.errorState),n=t.errorComponent??vt,a=s.useRef("");return s.useEffect((()=>{r&&e!==a.current&&o({}),a.current=e}),[r,e]),s.useEffect((()=>{t.errorState.error&&o(t.errorState)}),[t.errorState.error]),t.errorState.error&&r.error?s.createElement(n,r):t.children}function vt({error:t}){const[e,r]=s.useState(!1);return s.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},s.createElement("div",{style:{display:"flex",alignItems:"center",gap:".5rem"}},s.createElement("strong",{style:{fontSize:"1rem"}},"Something went wrong!"),s.createElement("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>r((t=>!t))},e?"Hide Error":"Show Error")),s.createElement("div",{style:{height:".25rem"}}),e?s.createElement("div",null,s.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"}},t.message?s.createElement("code",null,t.message):null)):null)}function wt(t,e=!0){const r=nt();s.useEffect((()=>{if(!e)return;let o=r.history.block(((e,r)=>{window.confirm(t)&&(o(),e())}));return o}))}t.Block=function({message:t,condition:e,children:r}){return wt(t,e),r??null},t.ErrorComponent=vt,t.FileRoute=class{constructor(t){this.path=t}createRoute=t=>{const e=new N(t);return e.isRoot=!1,e}},t.Link=tt,t.MatchRoute=function(t){const e=ut()(t);return"function"==typeof t.children?t.children(e):e?t.children:null},t.Navigate=function(t){const e=nt();return s.useLayoutEffect((()=>{e.navigate(t)}),[]),null},t.Outlet=lt,t.PathParamError=X,t.RootRoute=U,t.Route=N,t.Router=class{#t;constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??W,parseSearch:t?.parseSearch??z},this.__store=new a(V(),{onUpdate:()=>{const t=this.state;this.state=this.__store.state;const e=t.matchesById!==this.state.matchesById;let r,o;e||(r=t.matchIds.length!==this.state.matchIds.length||t.matchIds.some(((t,e)=>t!==this.state.matchIds[e])),o=t.pendingMatchIds.length!==this.state.pendingMatchIds.length||t.pendingMatchIds.some(((t,e)=>t!==this.state.pendingMatchIds[e]))),(e||r)&&(this.state.matches=this.state.matchIds.map((t=>this.state.matchesById[t]))),(e||o)&&(this.state.pendingMatches=this.state.pendingMatchIds.map((t=>this.state.matchesById[t]))),this.state.isFetching=[...this.state.matches,...this.state.pendingMatches].some((t=>t.isFetching))},defaultPriority:"low"}),this.state=this.__store.state,this.update(t);const e=this.buildNext({hash:!0,fromCurrent:!0,search:!0,state:!0});this.state.location.href!==e.href&&this.#e({...e,replace:!0})}reset=()=>{this.__store.setState((t=>Object.assign(t,V())))};mount=()=>{this.safeLoad()};update=t=>{if(this.options={...this.options,...t,context:{...this.options.context,...t?.context}},!this.history||this.options.history&&this.options.history!==this.history){this.#t&&this.#t(),this.history=this.options.history??(Y?g():y());const t=this.#r();this.__store.setState((e=>({...e,resolvedLocation:t,location:t}))),this.#t=this.history.listen((()=>{this.safeLoad({next:this.#r(this.state.location)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${O(e??"")??""}`,r&&r!==this.routeTree&&this.#o(r),this};buildNext=t=>{const e=this.#s(t),r=this.matchRoutes(e.pathname,e.search);return this.#s({...t,__matches:r})};cancelMatches=()=>{this.state.matches.forEach((t=>{this.cancelMatch(t.id)}))};cancelMatch=t=>{this.getRouteMatch(t)?.abortController?.abort()};safeLoad=t=>this.load(t).catch((t=>{}));latestLoadPromise=Promise.resolve();load=async t=>{const e=new Promise((async(r,o)=>{let s;const n=()=>this.latestLoadPromise!==e?this.latestLoadPromise:void 0;let a;this.__store.batch((()=>{t?.next&&this.__store.setState((e=>({...e,location:t.next}))),a=this.matchRoutes(this.state.location.pathname,this.state.location.search,{throwOnError:t?.throwOnError,debug:!0}),this.__store.setState((t=>({...t,status:"pending",pendingMatchIds:a.map((t=>t.id)),matchesById:this.#n(t.matchesById,a)})))}));try{if(await this.loadMatches(a),s=n())return await s;const t=this.state.resolvedLocation;this.__store.setState((t=>({...t,status:"idle",resolvedLocation:t.location,matchIds:t.pendingMatchIds,pendingMatchIds:[]}))),t.href!==this.state.location.href&&this.options.onRouteChange?.(),r()}catch(t){if(s=n())return await s;o(t)}}));return this.latestLoadPromise=e,this.latestLoadPromise};#n=(t,e)=>{const r={...t};let o=!1;return e.forEach((t=>{r[t.id]||(o=!0,r[t.id]=t)})),o?r:t};getRoute=t=>{const e=this.routesById[t];return h(e),e};preloadRoute=async(t=this.state.location)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,e.search,{throwOnError:!0});return this.__store.setState((t=>({...t,matchesById:this.#n(t.matchesById,r)}))),await this.loadMatches(r,{preload:!0,maxAge:t.maxAge}),r};cleanMatches=()=>{const t=Date.now(),e=Object.values(this.state.matchesById).filter((e=>{const r=this.getRoute(e.routeId);return!this.state.matchIds.includes(e.id)&&!this.state.pendingMatchIds.includes(e.id)&&e.preloadInvalidAt<t&&(!r.options.gcMaxAge||e.updatedAt+r.options.gcMaxAge<t)})).map((t=>t.id));e.length&&this.__store.setState((t=>{const r={...t.matchesById};return e.forEach((t=>{delete r[t]})),{...t,matchesById:r}}))};matchRoutes=(t,e,r)=>{let o={},s=this.flatRoutes.find((e=>{const r=D(this.basepath,t,{to:e.fullPath,caseSensitive:e.options.caseSensitive??this.options.caseSensitive});return!!r&&(o=r,!0)}))||this.routesById.__root__,n=[s];for(;s?.parentRoute;)s=s.parentRoute,s&&n.unshift(s);let a={};const i=n.map((t=>{let s,n;try{s=t.options.parseParams?.(o)??o}catch(t){if(n=new X(t.message,{cause:t}),r?.throwOnError)throw n}Object.assign(a,s);const i=A(t.path,a),c=t.options.key?t.options.key({params:a,search:e})??"":"",h=c?JSON.stringify(c):"",u=A(t.id,a,!0)+h,l=this.getRouteMatch(u);if(l)return{...l};const d=!(!t.options.loader&&!K.some((e=>t.options[e]?.preload)));return{id:u,key:h,routeId:t.id,params:a,pathname:P([this.basepath,i]),updatedAt:Date.now(),invalidAt:1/0,preloadInvalidAt:1/0,routeSearch:{},search:{},status:d?"idle":"success",isFetching:!1,invalid:!1,error:void 0,paramsError:n,searchError:void 0,loaderData:void 0,loadPromise:Promise.resolve(),routeContext:void 0,context:void 0,abortController:new AbortController,fetchedAt:0}}));return i.forEach(((t,o)=>{const s=i[o-1],n=this.getRoute(t.routeId),a=(()=>{const o={search:s?.search??e,routeSearch:s?.routeSearch??e};try{const e=("object"==typeof n.options.validateSearch?n.options.validateSearch.parse:n.options.validateSearch)?.(o.search)??{},r={...o.search,...e};return{routeSearch:x(t.routeSearch,e),search:x(t.search,r)}}catch(e){if(t.searchError=new Q(e.message,{cause:e}),r?.throwOnError)throw t.searchError;return o}})(),c=(()=>{try{const e=n.options.getContext?.({parentContext:s?.routeContext??{},context:s?.context??this?.options.context??{},params:t.params,search:t.search})||{};return{context:{...s?.context??this?.options.context,...e},routeContext:e}}catch(t){throw n.options.onError?.(t),t}})();Object.assign(t,{...a,...c})})),i};loadMatches=async(t,e)=>{let r;this.cleanMatches();try{await Promise.all(t.map((async(t,o)=>{const s=this.getRoute(t.routeId);e?.preload||this.setRouteMatch(t.id,(e=>({...e,routeSearch:t.routeSearch,search:t.search,routeContext:t.routeContext,context:t.context,error:t.error,paramsError:t.paramsError,searchError:t.searchError,params:t.params})));const n=(e,n)=>{if(r=r??o,n=n||s.options.onError,G(e))throw e;try{n?.(e)}catch(t){if(e=t,G(t))throw t}this.setRouteMatch(t.id,(t=>({...t,error:e,status:"error",updatedAt:Date.now()})))};t.paramsError&&n(t.paramsError,s.options.onParseParamsError),t.searchError&&n(t.searchError,s.options.onValidateSearchError);try{await(s.options.beforeLoad?.({...t,preload:!!e?.preload}))}catch(t){n(t,s.options.onBeforeLoadError)}})))}catch(t){throw e?.preload||this.navigate(t),t}const o=t.slice(0,r),s=[];o.forEach(((t,r)=>{s.push((async()=>{const o=s[r-1],n=this.getRoute(t.routeId);if(t.isFetching||"success"===t.status&&!this.getIsInvalid({matchId:t.id,preload:e?.preload}))return this.getRouteMatch(t.id)?.loadPromise;const a=Date.now(),i=()=>{const e=this.getRouteMatch(t.id);return e&&e.fetchedAt!==a?e.loadPromise:void 0},c=(async()=>{let r;const s=Promise.all(K.map((async t=>{const e=n.options[t];e?.preload&&await e.preload()}))),a=n.options.loader?.({...t,preload:!!e?.preload,parentMatchPromise:o}),c=t=>!!G(t)&&(e?.preload||this.navigate(t),!0);try{const[o,n]=await Promise.all([s,a]);if(r=i())return await r;this.setRouteMatchData(t.id,(()=>n),e)}catch(e){if(r=i())return await r;if(c(e))return;const o=n.options.onLoadError??n.options.onError;let s=e;try{o?.(e)}catch(t){if(s=t,c(t))return}this.setRouteMatch(t.id,(t=>({...t,error:s,status:"error",isFetching:!1,updatedAt:Date.now()})))}})();this.setRouteMatch(t.id,(t=>({...t,status:"success"!==t.status?"pending":t.status,isFetching:!0,loadPromise:c,fetchedAt:a,invalid:!1}))),await c})())})),await Promise.all(s)};reload=()=>this.navigate({fromCurrent:!0,replace:!0,search:!0});resolvePath=(t,e)=>j(this.basepath,t,C(e));navigate=async({from:t,to:e="",search:r,hash:o,replace:s,params:n})=>{const a=String(e),i=void 0===t?t:String(t);let c;try{new URL(`${a}`),c=!0}catch(t){}return h(!c),this.#e({from:i,to:a,search:r,hash:o,replace:s,params:n})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t);if(e?.pending&&"pending"!==this.state.status)return!1;const o=e?.pending?this.state.location:this.state.resolvedLocation;if(!o)return!1;const s=D(this.basepath,o.pathname,{...e,to:r.pathname});return!!s&&(e?.includeSearch??1?!!_(o.search,r.search)&&s:s)};buildLink=({from:t,to:e=".",search:r,params:o,hash:s,target:n,replace:a,activeOptions:i,preload:c,preloadDelay:h,disabled:u})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const l={from:t,to:e,search:r,params:o,hash:s,replace:a},d=this.buildNext(l);c=c??this.options.defaultPreload;const p=h??this.options.defaultPreloadDelay??0,f=this.state.location.pathname.split("/"),m=d.pathname.split("/").every(((t,e)=>t===f[e])),y=i?.exact?this.state.location.pathname===d.pathname:m,g=!i?.includeHash||this.state.location.hash===d.hash,v=!(i?.includeSearch??1)||_(this.state.location.search,d.search);return{type:"internal",next:d,handleFocus:t=>{c&&this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{u||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||n&&"_self"!==n||0!==t.button||(t.preventDefault(),this.#e(l))},handleEnter:t=>{const e=t.target||{};if(c){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),p)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},isActive:y&&g&&v,disabled:u}};dehydrate=()=>({state:R(this.state,["location","status","lastUpdated"])});hydrate=async t=>{let e=t;"undefined"!=typeof document&&(e=window.__TSR_DEHYDRATED__),h(e);const r=e;this.dehydratedData=r.payload,this.options.hydrate?.(r.payload),this.__store.setState((t=>({...t,...r.router.state,resolvedLocation:r.router.state.location}))),await this.load()};injectedHtml=[];injectHtml=async t=>{this.injectedHtml.push(t)};dehydrateData=(t,e)=>{if("undefined"==typeof document){const r="string"==typeof t?t:JSON.stringify(t);return this.injectHtml((async()=>{const t=`__TSR_DEHYDRATED__${r}`,o="function"==typeof e?await e():e;return`<script id='${t}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${s=r,s.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"')}"] = ${JSON.stringify(o)}\n ;(() => {\n var el = document.getElementById('${t}')\n el.parentElement.removeChild(el)\n })()\n <\/script>`;var s})),()=>this.hydrateData(t)}return()=>{}};hydrateData=t=>{if("undefined"!=typeof document){const e="string"==typeof t?t:JSON.stringify(t);return window[`__TSR_DEHYDRATED__${e}`]}};#o=t=>{this.routeTree=t,this.routesById={},this.routesByPath={},this.flatRoutes=[];const e=t=>{t.forEach(((t,r)=>{t.init({originalIndex:r,router:this});if(h(!this.routesById[t.id],String(t.id)),this.routesById[t.id]=t,!t.isRoot&&t.path){const e=L(t.fullPath);this.routesByPath[e]&&!t.fullPath.endsWith("/")||(this.routesByPath[e]=t)}const o=t.children;o?.length&&e(o)}))};e([t]),this.flatRoutes=Object.values(this.routesByPath).map(((t,e)=>{const r=O(t.fullPath),o=k(r);for(;o.length>1&&"/"===o[0]?.value;)o.shift();const s=o.map((t=>"param"===t.type?.5:"wildcard"===t.type?.25:1));return{child:t,trimmed:r,parsed:o,index:e,score:s}})).sort(((t,e)=>{let r="/"===t.trimmed?1:"/"===e.trimmed?-1:0;if(0!==r)return r;const o=Math.min(t.score.length,e.score.length);if(t.score.length!==e.score.length)return e.score.length-t.score.length;for(let r=0;r<o;r++)if(t.score[r]!==e.score[r])return e.score[r]-t.score[r];for(let r=0;r<o;r++)if(t.parsed[r].value!==e.parsed[r].value)return t.parsed[r].value>e.parsed[r].value?1:-1;return t.trimmed!==e.trimmed?t.trimmed>e.trimmed?1:-1:t.index-e.index})).map(((t,e)=>(t.child.rank=e,t.child)))};#r=t=>{let{pathname:e,search:r,hash:o,state:s}=this.history.location;const n=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:x(t?.search,n),hash:o.split("#").reverse()[0]??"",href:`${e}${r}${o}`,state:s,key:s?.key||"__init__"}};#s=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.location.pathname:t.from??this.state.location.pathname;let r=j(this.basepath??"/",e,`${t.to??""}`);const o={...b(this.matchRoutes(this.state.location.pathname,this.state.location.search))?.params};let s=!0===(t.params??!0)?o:S(t.params,o);s&&t.__matches?.map((t=>this.getRoute(t.routeId).options.stringifyParams)).filter(Boolean).forEach((t=>{s={...s,...t(s)}})),r=A(r,s??{});const n=t.__matches?.map((t=>this.getRoute(t.routeId).options.preSearchFilters??[])).flat().filter(Boolean)??[],a=t.__matches?.map((t=>this.getRoute(t.routeId).options.postSearchFilters??[])).flat().filter(Boolean)??[],i=n?.length?n?.reduce(((t,e)=>e(t)),this.state.location.search):this.state.location.search,c=!0===t.search?i:t.search?S(t.search,i)??{}:n?.length?i:{},h=a?.length?a.reduce(((t,e)=>e(t)),c):c,u=x(this.state.location.search,h),l=this.options.stringifySearch(u),d=!0===t.hash?this.state.location.hash:S(t.hash,this.state.location.hash),p=d?`#${d}`:"";return{pathname:r,search:u,searchStr:l,state:!0===t.state?this.state.location.state:S(t.state,this.state.location.state),hash:d,href:this.history.createHref(`${r}${l}${p}`),key:t.key}};#e=async t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let o="replace";t.replace||(o="push");this.state.location.href===e.href&&!e.key&&(o="replace");const s=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===o?"push":"replace"](s,{id:r,...e.state}),this.latestLoadPromise};getRouteMatch=t=>this.state.matchesById[t];setRouteMatch=(t,e)=>{this.__store.setState((r=>({...r,matchesById:{...r.matchesById,[t]:e(r.matchesById[t])}})))};setRouteMatchData=(t,e,r)=>{const o=this.getRouteMatch(t);if(!o)return;const s=this.getRoute(o.routeId),n=r?.updatedAt??Date.now(),a=n+(r?.maxAge??s.options.preloadMaxAge??this.options.defaultPreloadMaxAge??5e3),i=n+(r?.maxAge??s.options.maxAge??this.options.defaultMaxAge??1/0);this.setRouteMatch(t,(t=>({...t,error:void 0,status:"success",isFetching:!1,updatedAt:Date.now(),loaderData:S(e,t.loaderData),preloadInvalidAt:a,invalidAt:i}))),this.state.matches.find((e=>e.id===t))};invalidate=async t=>{if(t?.matchId){this.setRouteMatch(t.matchId,(t=>({...t,invalid:!0})));const e=this.state.matches.findIndex((e=>e.id===t.matchId)),r=this.state.matches[e+1];if(r)return this.invalidate({matchId:r.id,reload:!1})}else this.__store.batch((()=>{Object.values(this.state.matchesById).forEach((t=>{this.setRouteMatch(t.id,(t=>({...t,invalid:!0})))}))}));if(t?.reload??1)return this.reload()};getIsInvalid=t=>{if(!t?.matchId)return!!this.state.matches.find((e=>this.getIsInvalid({matchId:e.id,preload:t?.preload})));const e=this.getRouteMatch(t?.matchId);if(!e)return!1;const r=Date.now();return e.invalid||(t?.preload?e.preloadInvalidAt:e.invalidAt)<r}},t.RouterContext=class{constructor(){}createRootRoute=t=>new U(t)},t.RouterProvider=function({router:t,...e}){t.update(e),s.useEffect((()=>{let e;return s.startTransition((()=>{e=t.mount()})),e}),[t]);const r=t.options.Wrap||s.Fragment;return s.createElement(s.Suspense,{fallback:null},s.createElement(r,null,s.createElement(rt.Provider,{value:t},s.createElement(st,null))))},t.SearchParamError=Q,t.cleanPath=C,t.componentTypes=K,t.createBrowserHistory=y,t.createHashHistory=function(){return y({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=g,t.decode=H,t.defaultParseSearch=z,t.defaultStringifySearch=W,t.encode=$,t.functionalUpdate=S,t.interpolatePath=A,t.invariant=h,t.isPlainObject=E,t.isRedirect=G,t.joinPaths=P,t.last=b,t.lazyFn=function(t,e){return async(...r)=>(await t())[e||"default"](...r)},t.lazyRouteComponent=function(t,e){let r;const o=()=>(r||(r=t()),r),n=s.lazy((async()=>({default:(await o())[e??"default"]})));return n.preload=o,n},t.matchByPath=B,t.matchIdsContext=et,t.matchPathname=D,t.parsePathname=k,t.parseSearchWith=J,t.partialDeepEqual=_,t.pick=R,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=x,t.resolvePath=j,t.rootRouteId=F,t.routerContext=rt,t.shallow=function(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(e,r[o])||!Object.is(t[r[o]],e[r[o]]))return!1;return!0},t.stringifySearchWith=q,t.trimPath=O,t.trimPathLeft=M,t.trimPathRight=L,t.useBlocker=wt,t.useDehydrate=function(){const t=nt();return s.useCallback((function(e,r){return t.dehydrateData(e,r)}),[])},t.useHydrate=function(){const t=nt();return function(e){return t.hydrateData(e)}},t.useInjectHtml=function(){const t=nt();return s.useCallback((e=>{t.injectHtml(e)}),[])},t.useLinkProps=Z,t.useLoader=it,t.useMatch=at,t.useMatchRoute=ut,t.useMatches=function(t){const e=s.useContext(et);return ot({select:r=>{const o=r.matches.slice(r.matches.findIndex((t=>t.id===e[0])));return t?.select?.(o)??o}})},t.useNavigate=function(t){const e=nt();return s.useCallback((r=>e.navigate({...t,...r})),[])},t.useParams=ht,t.useRouteContext=function(t){return at({...t,select:e=>t?.select?.(e.routeContext)??e.routeContext})},t.useRouter=nt,t.useRouterContext=function(t){return at({...t,select:e=>t?.select?.(e.context)??e.context})},t.useRouterState=ot,t.useSearch=ct,t.useStore=i,t.warning=function(t,e){},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.production.js.map |
{ | ||
"name": "@tanstack/react-router", | ||
"author": "Tanner Linsley", | ||
"version": "0.0.1-beta.145", | ||
"version": "0.0.1-beta.146", | ||
"license": "MIT", | ||
@@ -46,3 +46,3 @@ "repository": "tanstack/router", | ||
"@gisatcz/cross-package-react-context": "^0.2.0", | ||
"@tanstack/router-core": "0.0.1-beta.145", | ||
"@tanstack/router-core": "0.0.1-beta.146", | ||
"@tanstack/react-store": "0.0.1-beta.134" | ||
@@ -49,0 +49,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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
759002
5250
+ Added@tanstack/router-core@0.0.1-beta.146(transitive)
- Removed@tanstack/router-core@0.0.1-beta.145(transitive)