@tanstack/react-router 0.0.1-beta.206 → 0.0.1-beta.208

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.
@@ -18,5 +18,5 @@
18
18
  * LICENSE.md file in the root directory of this source tree.
19
19
  *
20
20
  * @license MIT
21
- */const o="pushstate",a="popstate",s="beforeunload",c=e=>(e.preventDefault(),e.returnValue=""),i=()=>{removeEventListener(s,c,{capture:!0})};function u(e){let t=e.getLocation(),r=new Set,n=[],o=[];const a=()=>{t=e.getLocation(),r.forEach((e=>e()))},u=()=>{if(n.length)n[0]?.(u,(()=>{n=[],i()}));else for(;o.length;)o.shift()?.()},h=e=>{o.push(e),u()};return{get location(){return t},subscribe:e=>(r.add(e),()=>{r.delete(e)}),push:(t,r)=>{r=l(r),h((()=>{e.pushState(t,r,a)}))},replace:(t,r)=>{r=l(r),h((()=>{e.replaceState(t,r,a)}))},go:t=>{h((()=>{e.go(t)}))},back:()=>{h((()=>{e.back()}))},forward:()=>{h((()=>{e.forward()}))},createHref:t=>e.createHref(t),block:e=>(n.push(e),1===n.length&&addEventListener(s,c,{capture:!0}),()=>{n=n.filter((t=>t!==e)),n.length||i()}),flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:a}}function l(e){return e||(e={}),e.key=f(),e}function h(e){const t=e?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=e?.createHref??(e=>e);let n=d(t(),window.history.state);let s,c,i=!0;const l=()=>{i=!1,(()=>{s&&(window.history[s.isPush?"pushState":"replaceState"](s.state,"",s.href),s=void 0,c=void 0)})(),i=!0},h=(e,t,o,a)=>{const i=r(t);n=d(i,o),s={href:i,state:o,isPush:s?.isPush||"push"===e},a(),c||(c=Promise.resolve().then((()=>l())))},f=()=>{n=d(t(),window.history.state),y.notify()};var p=window.history.pushState,m=window.history.replaceState;const y=u({getLocation:()=>n,pushState:(e,t,r)=>h("push",e,t,r),replaceState:(e,t,r)=>h("replace",e,t,r),back:()=>window.history.back(),forward:()=>window.history.forward(),go:e=>window.history.go(e),createHref:e=>r(e),flush:l,destroy:()=>{window.history.pushState=p,window.history.replaceState=m,window.removeEventListener(o,f),window.removeEventListener(a,f)}});return window.addEventListener(o,f),window.addEventListener(a,f),window.history.pushState=function(){let e=p.apply(window.history,arguments);return i&&y.notify(),e},window.history.replaceState=function(){let e=m.apply(window.history,arguments);return i&&y.notify(),e},y}function d(e,t){let r=e.indexOf("#"),n=e.indexOf("?");return{href:e,pathname:e.substring(0,r>0?n>0?Math.min(r,n):r:n>0?n:e.length),hash:r>-1?e.substring(r):"",search:n>-1?e.slice(n,-1===r?void 0:r):"",state:t||{}}}function f(){return(Math.random()+1).toString(36).substring(7)}function p(e,t){if(!e)throw new Error("Invariant failed")}function m(e,t){}const y="undefined"==typeof document;function v(e){return e[e.length-1]}function g(e,t){return"function"==typeof e?e(t):e}function w(e,t){return t.reduce(((t,r)=>(t[r]=e[r],t)),{})}function b(e,t){if(e===t)return e;const r=t,n=Array.isArray(e)&&Array.isArray(r);if(n||S(e)&&S(r)){const t=n?e.length:Object.keys(e).length,o=n?r:Object.keys(r),a=o.length,s=n?[]:{};let c=0;for(let t=0;t<a;t++){const a=n?t:o[t];s[a]=b(e[a],r[a]),s[a]===e[a]&&c++}return t===a&&c===t?e:s}return r}function S(e){if(!E(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!!E(r)&&!!r.hasOwnProperty("isPrototypeOf")}function E(e){return"[object Object]"===Object.prototype.toString.call(e)}function R(e,t){return e===t||typeof e==typeof t&&(S(e)&&S(t)?!Object.keys(t).some((r=>!R(e[r],t[r]))):!(!Array.isArray(e)||!Array.isArray(t))&&(e.length===t.length&&e.every(((e,r)=>R(e,t[r])))))}function P(e){const t=n.useRef(e);t.current=e;return n.useRef(((...e)=>t.current(...e))).current}function C(e){return k(e.filter(Boolean).join("/"))}function k(e){return e.replace(/\/{2,}/g,"/")}function M(e){return"/"===e?e:e.replace(/^\/{1,}/,"")}function O(e){return"/"===e?e:e.replace(/\/{1,}$/,"")}function L(e){return O(M(e))}function x(e,t,r){t=t.replace(new RegExp(`^${e}`),"/"),r=r.replace(new RegExp(`^${e}`),"/");let n=I(t);const o=I(r);o.forEach(((e,t)=>{if("/"===e.value)t?t===o.length-1&&n.push(e):n=[e];else if(".."===e.value)n.length>1&&"/"===v(n)?.value&&n.pop(),n.pop();else{if("."===e.value)return;n.push(e)}}));return k(C([e,...n.map((e=>e.value))]))}function I(e){if(!e)return[];const t=[];if("/"===(e=k(e)).slice(0,1)&&(e=e.substring(1),t.push({type:"pathname",value:"/"})),!e)return t;const r=e.split("/").filter(Boolean);return t.push(...r.map((e=>"$"===e||"*"===e?{type:"wildcard",value:e}:"$"===e.charAt(0)?{type:"param",value:e}:{type:"pathname",value:e}))),"/"===e.slice(-1)&&(e=e.substring(1),t.push({type:"pathname",value:"/"})),t}function _(e,t,r=!1){return C(I(e).map((e=>{if("wildcard"===e.type){const n=t[e.value];return r?`${e.value}${n??""}`:n}return"param"===e.type?t[e.value.substring(1)]??"":e.value})))}function j(e,t,r){const n=A(e,t,r);if(!r.to||n)return n??{}}function A(e,t,r){t="/"!=e?t.substring(e.length):t;const n=`${r.to??"$"}`,o=I(t),a=I(n);t.startsWith("/")||o.unshift({type:"pathname",value:"/"}),n.startsWith("/")||a.unshift({type:"pathname",value:"/"});const s={};return(()=>{for(let e=0;e<Math.max(o.length,a.length);e++){const t=o[e],n=a[e],c=e>=o.length-1,i=e>=a.length-1;if(n){if("wildcard"===n.type)return!!t?.value&&(s["*"]=C(o.slice(e).map((e=>e.value))),!0);if("pathname"===n.type){if("/"===n.value&&!t?.value)return!0;if(t)if(r.caseSensitive){if(n.value!==t.value)return!1}else if(n.value.toLowerCase()!==t.value.toLowerCase())return!1}if(!t)return!1;if("param"===n.type){if("/"===t?.value)return!1;"$"!==t.value.charAt(0)&&(s[n.value.substring(1)]=t.value)}}if(!c&&i)return!!r.fuzzy}return!0})()?s:void 0}function T(e,t){var r,n,o,a="";for(r in e)if(void 0!==(o=e[r]))if(Array.isArray(o))for(n=0;n<o.length;n++)a&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(o[n]);else a&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(o);return(t||"")+a}function $(e){if(!e)return"";var t=decodeURIComponent(e);return"false"!==t&&("true"===t||(0*+t==0&&+t+""===t?+t:t))}function D(e){for(var t,r,n={},o=e.split("&");t=o.shift();)void 0!==n[r=(t=t.split("=")).shift()]?n[r]=[].concat(n[r],$(t.shift())):n[r]=$(t.shift());return n}function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},B.apply(this,arguments)}const F=K(JSON.parse),H=z(JSON.stringify,JSON.parse);function K(e){return t=>{"?"===t.substring(0,1)&&(t=t.substring(1));let r=D(t);for(let t in r){const n=r[t];if("string"==typeof n)try{r[t]=e(n)}catch(e){}}return r}}function z(e,t){return r=>{(r={...r})&&Object.keys(r).forEach((n=>{const o=r[n];void 0===o||void 0===o?delete r[n]:r[n]=function(r){if("object"==typeof r&&null!==r)try{return e(r)}catch(e){}else if("string"==typeof r&&"function"==typeof t)try{return t(r),e(r)}catch(e){}return r}(o)}));const n=T(r).toString();return n?`?${n}`:""}}const N=["component","errorComponent","pendingComponent"];function U(e){return!!e?.isRedirect}const W="Error preloading route! ☝️",q=n.createContext(null);function J(e){return{status:"idle",isFetching:!1,resolvedLocation:e,location:e,matches:[],pendingMatches:[],lastUpdated:Date.now()}}class V extends Error{}class G extends Error{}function Q(e,t){return[...e.pendingMatches,...e.matches].find((e=>e.id===t))}const X="undefined"!=typeof window?n.useLayoutEffect:n.useEffect;function Y(e){const{buildLink:t,state:r}=te(),o=ne({strict:!1}),{type:a,children:s,target:c,activeProps:i=(()=>({className:"active"})),inactiveProps:u=(()=>({})),activeOptions:l,disabled:h,hash:d,search:f,params:p,to:m,state:y,mask:v,preload:w,preloadDelay:b,replace:S,style:E,className:R,onClick:P,onFocus:C,onMouseEnter:k,onMouseLeave:M,onTouchStart:O,...L}=e,x=t(r,{from:e.to?o.pathname:void 0,...e});if("external"===x.type){const{href:e}=x;return{href:e}}const{handleClick:I,handleFocus:_,handleEnter:j,handleLeave:A,handleTouchStart:T,isActive:$,next:D}=x,B=e=>t=>{t.persist&&t.persist(),e.filter(Boolean).forEach((e=>{t.defaultPrevented||e(t)}))},F=$?g(i,{})??{}:{},H=$?{}:g(u,{})??{};return{...F,...H,...L,href:h?void 0:D.maskedLocation?D.maskedLocation.href:D.href,onClick:B([P,t=>{(e.startTransition??1)&&(n.startTransition||(e=>e))((()=>{I(t)}))}]),onFocus:B([C,_]),onMouseEnter:B([k,j]),onMouseLeave:B([M,A]),onTouchStart:B([O,T]),target:c,style:{...E,...F.style,...H.style},className:[R,F.className,H.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":$?"active":void 0}}const Z=n.forwardRef(((e,t)=>{const r=Y(e);return n.createElement("a",B({ref:t},r,{children:"function"==typeof e.children?e.children({isActive:"active"===r["data-status"]}):e.children}))}));const ee=n.createContext(null);function te(){return n.useContext(q)}function re(e){const{state:t}=te();return e?.select?e.select(t):t}function ne(e){const t=n.useContext(ee)[0],r=t?.routeId,o=re({select:r=>(e?.from?r.matches.find((t=>t.routeId===e?.from)):r.matches.find((e=>e.id===t.id))).routeId});(e?.strict??1)&&p(r==o);return re({select:r=>{const n=e?.from?r.matches.find((t=>t.routeId===e?.from)):r.matches.find((e=>e.id===t.id));return p(n,e?.from&&e.from),e?.select?e.select(n):n}})}function oe(e){return ne({...e,select:t=>e?.select?e.select(t.search):t.search})}function ae(e){return re({select:t=>{const r=v(t.matches)?.params;return e?.select?e.select(r):r}})}function se(){const{state:e,matchRoute:t}=te();return n.useCallback((r=>{const{pending:n,caseSensitive:o,...a}=r;return t(e,a,{pending:n,caseSensitive:o})}),[])}function ce(){const{routesById:e,state:t}=te(),{matches:r}=t,o=re({select:e=>e.resolvedLocation.state?.key}),a=e[ve],s=n.useCallback((e=>n.createElement(me,{...e,useMatch:a.useMatch,useRouteMeta:a.useRouteMeta,useSearch:a.useSearch,useParams:a.useParams})),[a]);return n.createElement(ee.Provider,{value:r},n.createElement(fe,{resetKey:o,errorComponent:s,onCatch:()=>{}},r.length?n.createElement(le,{matches:r}):null))}function ie(){const e=n.useContext(ee).slice(1);return e[0]?n.createElement(le,{matches:e}):null}const ue=()=>null;function le({matches:e}){const{options:t,routesById:r}=te(),o=e[0],a=o?.routeId,s=r[a],c=re({select:e=>e.resolvedLocation.state?.key}),i=s.options.pendingComponent??t.defaultPendingComponent??ue,u=s.options.errorComponent??t.defaultErrorComponent??me,l=s.options.wrapInSuspense??!s.isRoot?n.Suspense:de,h=u?fe:de,d=n.useCallback((e=>n.createElement(u,{...e,useMatch:s.useMatch,useRouteMeta:s.useRouteMeta,useSearch:s.useSearch,useParams:s.useParams})),[s]);return n.createElement(ee.Provider,{value:e},n.createElement(l,{fallback:n.createElement(i,{useMatch:s.useMatch,useRouteMeta:s.useRouteMeta,useSearch:s.useSearch,useParams:s.useParams})},n.createElement(h,{resetKey:c,errorComponent:d,onCatch:()=>{o.id}},n.createElement(he,{match:o}))))}function he({match:e}){const{options:t,routesById:r}=te(),o=r[e.routeId];if("error"===e.status)throw e.error;if("pending"===e.status)throw e.loadPromise;if("success"===e.status){let e=o.options.component??t.defaultComponent;return e?n.createElement(e,{useMatch:o.useMatch,useRouteMeta:o.useRouteMeta,useSearch:o.useSearch,useParams:o.useParams}):n.createElement(ie,null)}p(!1)}function de(e){return n.createElement(n.Fragment,null,e.children)}function fe(e){const t=e.errorComponent??me;return n.createElement(pe,{resetKey:e.resetKey,onCatch:e.onCatch,children:({error:r})=>r?n.createElement(t,{error:r}):e.children})}class pe extends n.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidUpdate(e,t){t.error&&e.resetKey!==this.props.resetKey&&this.setState({error:null})}componentDidCatch(e){this.props.onCatch?.(e)}render(){return this.props.children(this.state)}}function me({error:e}){const[t,r]=n.useState(!1);return n.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},n.createElement("div",{style:{display:"flex",alignItems:"center",gap:".5rem"}},n.createElement("strong",{style:{fontSize:"1rem"}},"Something went wrong!"),n.createElement("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>r((e=>!e))},t?"Hide Error":"Show Error")),n.createElement("div",{style:{height:".25rem"}}),t?n.createElement("div",null,n.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"}},e.message?n.createElement("code",null,e.message):null)):null)}function ye(e,t=!0){const{history:r}=te();n.useEffect((()=>{if(!t)return;let n=r.block(((t,r)=>{window.confirm(e)&&(n(),t())}));return n}))}const ve="__root__";class ge{constructor(e){this.options=e||{},this.isRoot=!e?.getParentRoute,ge.__onInit(this)}init=e=>{this.originalIndex=e.originalIndex;const t=this.options,r=!t?.path&&!t?.id;this.parentRoute=this.options?.getParentRoute?.(),r?this.path=ve:p(this.parentRoute);let n=r?ve:t.path;n&&"/"!==n&&(n=L(n));const o=t?.id||n;let a=r?ve:C([this.parentRoute.id===ve?"":this.parentRoute.id,o]);n===ve&&(n="/"),a!==ve&&(a=C(["/",a]));const s=a===ve?"/":C([this.parentRoute.fullPath,n]);this.path=n,this.id=a,this.fullPath=s,this.to=s};addChildren=e=>(this.children=e,this);update=e=>(Object.assign(this.options,e),this);static __onInit=e=>{};useMatch=e=>ne({...e,from:this.id});useRouteMeta=e=>ne({...e,from:this.id,select:t=>e?.select?e.select(t.meta):t.meta});useSearch=e=>oe({...e,from:this.id});useParams=e=>ae({...e,from:this.id})}class we extends ge{constructor(e){super(e)}}e.Block=function({message:e,condition:t,children:r}){return ye(e,t),r??null},e.CatchBoundary=fe,e.CatchBoundaryImpl=pe,e.ErrorComponent=me,e.FileRoute=class{constructor(e){this.path=e}createRoute=e=>{const t=new ge(e);return t.isRoot=!1,t}},e.Link=Z,e.MatchRoute=function(e){const t=se()(e);return"function"==typeof e.children?e.children(t):t?e.children:null},e.Matches=ce,e.Navigate=function(e){const{navigate:t}=te(),r=ne({strict:!1});return X((()=>{t({from:e.to?r.pathname:void 0,...e})}),[]),null},e.Outlet=ie,e.PathParamError=G,e.RootRoute=we,e.Route=ge,e.Router=class{constructor(e){this.options={defaultPreloadDelay:50,meta:void 0,...e,stringifySearch:e?.stringifySearch??H,parseSearch:e?.parseSearch??F},this.routeTree=this.options.routeTree}subscribers=new Set;subscribe=(e,t)=>{const r={eventType:e,fn:t};return this.subscribers.add(r),()=>{this.subscribers.delete(r)}};emit=e=>{this.subscribers.forEach((t=>{t.eventType===e.type&&t.fn(e)}))}},e.RouterMeta=class{constructor(){}createRootRoute=e=>new we(e)},e.RouterProvider=function({router:e,...t}){const r={...e.options,...t,meta:{...e.options.meta,...t?.meta}},o=n.useState((()=>r.history??h()))[0],a=n.useRef(`${Math.round(1e7*Math.random())}`),s=n.useRef(!1),c=n.useRef(null),i=P((e=>{const t=({pathname:t,search:n,hash:o,state:a})=>{const s=r.parseSearch(n);return{pathname:t,searchStr:n,search:b(e?.search,s),hash:o.split("#").reverse()[0]??"",href:`${t}${n}${o}`,state:b(e?.state,a)}},n=t(o.location);let{__tempLocation:s,__tempKey:c}=n.state;if(s&&(!c||c===a.current)){const e=t(s);return e.state.key=n.state.key,delete e.state.__tempLocation,{...e,maskedLocation:n}}return n})),[u,l]=n.useState((()=>J(i()))),d=`/${L(r.basepath??"")??""}`,f=P(((e,t)=>x(d,e,k(t)))),[m,y]=n.useMemo((()=>{const t={},r={},n=e=>{e.forEach(((e,o)=>{e.init({originalIndex:o});if(p(!t[e.id],String(e.id)),t[e.id]=e,!e.isRoot&&e.path){const t=O(e.fullPath);r[t]&&!e.fullPath.endsWith("/")||(r[t]=e)}const a=e.children;a?.length&&n(a)}))};return n([e.routeTree]),[t,r]}),[]),S=m,E=n.useMemo((()=>Object.values(y).map(((e,t)=>{const r=L(e.fullPath),n=I(r);for(;n.length>1&&"/"===n[0]?.value;)n.shift();const o=n.map((e=>"param"===e.type?.5:"wildcard"===e.type?.25:1));return{child:e,trimmed:r,parsed:n,index:t,score:o}})).sort(((e,t)=>{let r="/"===e.trimmed?1:"/"===t.trimmed?-1:0;if(0!==r)return r;const n=Math.min(e.score.length,t.score.length);if(e.score.length!==t.score.length)return t.score.length-e.score.length;for(let r=0;r<n;r++)if(e.score[r]!==t.score[r])return t.score[r]-e.score[r];for(let r=0;r<n;r++)if(e.parsed[r].value!==t.parsed[r].value)return e.parsed[r].value>t.parsed[r].value?1:-1;return e.trimmed!==t.trimmed?e.trimmed>t.trimmed?1:-1:e.index-t.index})).map(((e,t)=>(e.child.rank=t,e.child)))),[y]),M=n.useRef(Promise.resolve()),A=P(((e,t,n)=>{let o={},a=E.find((t=>{const n=j(d,O(e),{to:t.fullPath,caseSensitive:t.options.caseSensitive??r.caseSensitive,fuzzy:!1});return!!n&&(o=n,!0)}))||m.__root__,s=[a];for(;a?.parentRoute;)a=a.parentRoute,a&&s.unshift(a);const c=s.map((e=>{let t;if(e.options.parseParams)try{const t=e.options.parseParams(o);Object.assign(o,t)}catch(e){if(t=new G(e.message,{cause:e}),n?.throwOnError)throw t;return t}})),i=s.map(((e,t)=>{const r=_(e.path,o),n=_(e.id,o,!0),a=Q(u,n);if(a)return{...a};const s=!(!e.options.load&&!N.some((t=>e.options[t]?.preload)));return{id:n,routeId:e.id,params:o,pathname:C([d,r]),updatedAt:Date.now(),routeSearch:{},search:{},status:s?"pending":"success",isFetching:!1,invalid:!1,error:void 0,paramsError:c[t],searchError:void 0,loadPromise:Promise.resolve(),meta:void 0,abortController:new AbortController,fetchedAt:0}}));return i.forEach(((e,r)=>{const o=i[r-1],a=S[e.routeId],s=(()=>{const r={search:o?.search??t,routeSearch:o?.routeSearch??t};try{let t=("object"==typeof a.options.validateSearch?a.options.validateSearch.parse:a.options.validateSearch)?.(r.search)??{},n={...r.search,...t};return t=b(e.routeSearch,t),n=b(e.search,n),{routeSearch:t,search:n,searchDidChange:e.routeSearch!==t}}catch(t){if(e.searchError=new V(t.message,{cause:t}),n?.throwOnError)throw e.searchError;return r}})();Object.assign(e,s)})),i})),T=P((e=>{Q(u,e)?.abortController?.abort()})),$=P((e=>{e.matches.forEach((e=>{T(e.id)}))})),D=P(((e={})=>{const t=(e={},t)=>{const n=ee.current,a=e.from??n.pathname;let s=f(a,`${e.to??""}`);const c=A(a,n.search),i=t?.filter((e=>c?.find((t=>t.routeId===e.routeId)))),u={...v(c)?.params};let l=!0===(e.params??!0)?u:g(e.params,u);l&&t?.map((e=>S[e.routeId].options.stringifyParams)).filter(Boolean).forEach((e=>{l={...l,...e(l)}})),s=_(s,l??{});const h=i?.map((e=>S[e.routeId].options.preSearchFilters??[])).flat().filter(Boolean)??[],d=i?.map((e=>S[e.routeId].options.postSearchFilters??[])).flat().filter(Boolean)??[],p=h?.length?h?.reduce(((e,t)=>t(e)),n.search):n.search,m=!0===e.search?p:e.search?g(e.search,p)??{}:h?.length?p:{},y=d?.length?d.reduce(((e,t)=>t(e)),m):m,w=b(n.search,y),E=r.stringifySearch(w),R=!0===e.hash?n.hash:e.hash?g(e.hash,n.hash):n.hash,P=R?`#${R}`:"";let C=!0===e.state?n.state:e.state?g(e.state,n.state):n.state;return C=b(n.state,C),{pathname:s,search:w,searchStr:E,state:C,hash:R,href:o.createHref(`${s}${E}${P}`),unmaskOnReload:e.unmaskOnReload}},n=(e={},n)=>{let o=t(e),a=n?t(n):void 0;if(!a){let e={},s=r.routeMasks?.find((t=>{const r=j(d,o.pathname,{to:t.from,caseSensitive:!1,fuzzy:!1});return!!r&&(e=r,!0)}));s&&(s={...s,from:_(s.from,e)},a=t(n=s))}const s=A(o.pathname,o.search),c=a?A(a.pathname,a.search):void 0,i=a?t(n,c):void 0,u=t(e,s);return i&&(u.maskedLocation=i),u};return e.mask?n(e,{...w(e,["from"]),...e.mask}):n(e)})),B=P((async e=>{c.current&&clearTimeout(c.current);if(!(ee.current.href===e.href)||!e.replace){let{maskedLocation:t,...n}=e;t&&(n={...t,state:{...t.state,__tempKey:void 0,__tempLocation:{...n,search:n.searchStr,state:{...n.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(n.unmaskOnReload??r.unmaskOnReload)&&(n.state.__tempKey=a.current)),o[e.replace?"replace":"push"](n.href,n.state)}return s.current=e.resetScroll??!0,M.current})),F=P((({replace:e,resetScroll:t,...r}={})=>{const n=D(r);return B({...n,replace:e,resetScroll:t})})),H=P((({from:e,to:t="",...r})=>{const n=String(t),o=void 0===e?e:String(e);let a;try{new URL(`${n}`),a=!0}catch(e){}return p(!a),F({...r,from:o,to:n})})),K=P((async({matches:e,preload:t})=>{let n;try{for(let[o,a]of e.entries()){const s=e[o-1],c=S[a.routeId],i=(t,r)=>{if(t.routerCode=r,n=n??o,U(t))throw t;try{c.options.onError?.(t)}catch(e){if(t=e,U(e))throw e}e[o]=a={...a,error:t,status:"error",updatedAt:Date.now()}};try{a.paramsError&&i(a.paramsError,"PARSE_PARAMS"),a.searchError&&i(a.searchError,"VALIDATE_SEARCH");const n=s?.meta??r.meta??{},l=await(c.options.beforeLoad?.({search:a.search,abortController:a.abortController,params:a.params,preload:!!t,meta:n,location:u.location}))??{},h={...n,...l};e[o]=a={...a,meta:b(a.meta,h)}}catch(e){i(e,"BEFORE_LOAD");break}}}catch(e){if(U(e))return void(t||H(e));throw e}const o=e.slice(0,n),a=[];o.forEach(((r,n)=>{a.push((async()=>{const o=a[n-1],s=S[r.routeId];if(r.isFetching)return Q(u,r.id)?.loadPromise;const c=Date.now(),i=()=>{const e=Q(u,r.id);return e&&e.fetchedAt!==c?e.loadPromise:void 0},l=e=>!!U(e)&&(t||H(e),!0);let h;e[n]=r={...r,isFetching:!0,fetchedAt:c,invalid:!1},h=(async()=>{let a;try{const c=Promise.all(N.map((async e=>{const t=s.options[e];t?.preload&&await t.preload()}))),u=s.options.load?.({params:r.params,search:r.search,preload:!!t,parentMatchPromise:o,abortController:r.abortController,meta:r.meta});if(await Promise.all([c,u]),a=i())return await a;e[n]=r={...r,error:void 0,status:"success",isFetching:!1,updatedAt:Date.now()}}catch(t){if(a=i())return await a;if(l(t))return;try{s.options.onError?.(t)}catch(e){if(t=e,l(e))return}e[n]=r={...r,error:t,status:"error",isFetching:!1,updatedAt:Date.now()}}})(),e[n]=r={...r,loadPromise:h},await h})())})),await Promise.all(a)})),z=P((async t=>{const r=new Promise((async(n,o)=>{const a=u.resolvedLocation,s=!(!t?.next||a.href===t.next.href);let c;const i=()=>M.current!==r?M.current:void 0;$(u),e.emit({type:"onBeforeLoad",from:a,to:t?.next??u.location,pathChanged:s}),t?.next&&l((e=>({...e,location:t.next})));const h=A(u.location.pathname,u.location.search,{throwOnError:t?.throwOnError,debug:!0});l((e=>({...e,status:"pending",matches:h})));try{try{await K({matches:h})}catch(e){}if(c=i())return c;l((e=>({...e,status:"idle",resolvedLocation:e.location}))),e.emit({type:"onLoad",from:a,to:u.location,pathChanged:s}),n()}catch(e){if(c=i())return c;o(e)}}));return M.current=r,M.current})),X=n.useCallback((async()=>{try{return z()}catch(e){}}),[]),Y=P((async(e=u.location)=>{let t=D(e),r=A(t.pathname,t.search,{throwOnError:!0});return await K({matches:r,preload:!0}),[v(r),r]})),Z=P(((e,t)=>{const{to:n,preload:o,preloadDelay:a,activeOptions:s,disabled:c,target:i,replace:u,resetScroll:l}=t;try{return new URL(`${n}`),{type:"external",href:n}}catch(e){}const h=t,d=D(h),f=o??r.defaultPreload,p=a??r.defaultPreloadDelay??0,m=ee.current.pathname.split("/"),y=d.pathname.split("/").every(((e,t)=>e===m[t])),v=s?.exact?ee.current.pathname===d.pathname:y,g=!s?.includeHash||ee.current.hash===d.hash,w=!(s?.includeSearch??1)||R(ee.current.search,d.search);return{type:"internal",next:d,handleFocus:e=>{f&&Y(h).catch((e=>{console.warn(e),console.warn(W)}))},handleClick:e=>{c||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)||e.defaultPrevented||i&&"_self"!==i||0!==e.button||(e.preventDefault(),B({...d,replace:u,resetScroll:l}))},handleEnter:e=>{const t=e.target||{};if(f){if(t.preloadTimeout)return;t.preloadTimeout=setTimeout((()=>{t.preloadTimeout=null,Y(h).catch((e=>{console.warn(e),console.warn(W)}))}),p)}},handleLeave:e=>{const t=e.target||{};t.preloadTimeout&&(clearTimeout(t.preloadTimeout),t.preloadTimeout=null)},handleTouchStart:e=>{Y(h).catch((e=>{console.warn(e),console.warn(W)}))},isActive:v&&g&&w,disabled:c}})),ee=n.useRef(u.location);n.useLayoutEffect((()=>{const e=o.subscribe((()=>{ee.current=i(ee.current),n.startTransition((()=>{l((e=>({...e,location:ee.current})))}))})),t=D({search:!0,params:!0,hash:!0,state:!0});return u.location.href!==t.href&&B({...t,replace:!0}),()=>{e()}}),[o]);const te=n.useRef(!0);te.current&&(te.current=!1,X()),n.useLayoutEffect((()=>{u.resolvedLocation!==u.location&&X()}),[u.location]),n.useMemo((()=>[...u.matches,...u.pendingMatches].some((e=>e.isFetching))),[u.matches,u.pendingMatches]);const re=P(((e,t,r)=>{t={...t,to:t.to?f(t.from||"",t.to):void 0};const n=D(t);if(r?.pending&&"pending"!==e.status)return!1;const o=r?.pending?ee.current:e.resolvedLocation;if(!o)return!1;const a=j(d,o.pathname,{...r,to:n.pathname});return!!a&&(r?.includeSearch??1?!!R(o.search,n.search)&&a:a)})),ne={routeTree:e.routeTree,navigate:H,buildLink:Z,state:u,matchRoute:re,routesById:m,options:r,history:o,load:z};return n.createElement(q.Provider,{value:ne},n.createElement(ce,null))},e.SearchParamError=V,e.cleanPath=k,e.componentTypes=N,e.createBrowserHistory=h,e.createHashHistory=function(){return h({getHref:()=>window.location.hash.substring(1),createHref:e=>`#${e}`})},e.createMemoryHistory=function(e={initialEntries:["/"]}){const t=e.initialEntries;let r=e.initialIndex??t.length-1,n={key:f()};return u({getLocation:()=>d(t[r],n),pushState:(e,o)=>{n=o,t.push(e),r++},replaceState:(e,o)=>{n=o,t[r]=e},back:()=>{r--},forward:()=>{r=Math.min(r+1,t.length-1)},go:e=>window.history.go(e),createHref:e=>e})},e.createRouteMask=function(e){return e},e.decode=D,e.defaultParseSearch=F,e.defaultStringifySearch=H,e.encode=T,e.functionalUpdate=g,e.getInitialRouterState=J,e.getRouteMatch=Q,e.interpolatePath=_,e.invariant=p,e.isPlainObject=S,e.isRedirect=U,e.isServer=y,e.joinPaths=C,e.last=v,e.lazyFn=function(e,t){return async(...r)=>(await e())[t||"default"](...r)},e.lazyRouteComponent=function(e,t){let r;const o=()=>(r||(r=e()),r),a=n.lazy((async()=>({default:(await o())[t??"default"]})));return a.preload=o,a},e.matchByPath=A,e.matchPathname=j,e.matchesContext=ee,e.parsePathname=I,e.parseSearchWith=K,e.partialDeepEqual=R,e.pick=w,e.redirect=function(e){return e.isRedirect=!0,e},e.replaceEqualDeep=b,e.resolvePath=x,e.rootRouteId=ve,e.routerContext=q,e.shallow=function(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let n=0;n<r.length;n++)if(!Object.prototype.hasOwnProperty.call(t,r[n])||!Object.is(e[r[n]],t[r[n]]))return!1;return!0},e.stringifySearchWith=z,e.trimPath=L,e.trimPathLeft=M,e.trimPathRight=O,e.useBlocker=ye,e.useLinkProps=Y,e.useMatch=ne,e.useMatchRoute=se,e.useMatches=function(e){const t=n.useContext(ee);return re({select:r=>{const n=r.matches.slice(r.matches.findIndex((e=>e.id===t[0]?.id)));return e?.select?e.select(n):n}})},e.useNavigate=function(e){const{navigate:t}=te(),r=ne({strict:!1});return n.useCallback((n=>t({from:n?.to?r.pathname:void 0,...e,...n})),[])},e.useParams=ae,e.useRouteMeta=function(e){return ne({...e,select:t=>e?.select?e.select(t.meta):t.meta})},e.useRouter=te,e.useRouterState=re,e.useSearch=oe,e.useStableCallback=P,e.warning=m,Object.defineProperty(e,"__esModule",{value:!0})}));
21
+ */const o="pushstate",a="popstate",s="beforeunload",c=e=>(e.preventDefault(),e.returnValue=""),i=()=>{removeEventListener(s,c,{capture:!0})};function u(e){let t=e.getLocation(),r=new Set,n=[],o=[];const a=()=>{t=e.getLocation(),r.forEach((e=>e()))},u=()=>{if(n.length)n[0]?.(u,(()=>{n=[],i()}));else for(;o.length;)o.shift()?.()},h=e=>{o.push(e),u()};return{get location(){return t},subscribe:e=>(r.add(e),()=>{r.delete(e)}),push:(t,r)=>{r=l(r),h((()=>{e.pushState(t,r,a)}))},replace:(t,r)=>{r=l(r),h((()=>{e.replaceState(t,r,a)}))},go:t=>{h((()=>{e.go(t)}))},back:()=>{h((()=>{e.back()}))},forward:()=>{h((()=>{e.forward()}))},createHref:t=>e.createHref(t),block:e=>(n.push(e),1===n.length&&addEventListener(s,c,{capture:!0}),()=>{n=n.filter((t=>t!==e)),n.length||i()}),flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:a}}function l(e){return e||(e={}),e.key=f(),e}function h(e){const t=e?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=e?.createHref??(e=>e);let n=d(t(),window.history.state);let s,c,i=!0;const l=()=>{i=!1,(()=>{s&&(window.history[s.isPush?"pushState":"replaceState"](s.state,"",s.href),s=void 0,c=void 0)})(),i=!0},h=(e,t,o,a)=>{const i=r(t);n=d(i,o),s={href:i,state:o,isPush:s?.isPush||"push"===e},a(),c||(c=Promise.resolve().then((()=>l())))},f=()=>{n=d(t(),window.history.state),y.notify()};var p=window.history.pushState,m=window.history.replaceState;const y=u({getLocation:()=>n,pushState:(e,t,r)=>h("push",e,t,r),replaceState:(e,t,r)=>h("replace",e,t,r),back:()=>window.history.back(),forward:()=>window.history.forward(),go:e=>window.history.go(e),createHref:e=>r(e),flush:l,destroy:()=>{window.history.pushState=p,window.history.replaceState=m,window.removeEventListener(o,f),window.removeEventListener(a,f)}});return window.addEventListener(o,f),window.addEventListener(a,f),window.history.pushState=function(){let e=p.apply(window.history,arguments);return i&&y.notify(),e},window.history.replaceState=function(){let e=m.apply(window.history,arguments);return i&&y.notify(),e},y}function d(e,t){let r=e.indexOf("#"),n=e.indexOf("?");return{href:e,pathname:e.substring(0,r>0?n>0?Math.min(r,n):r:n>0?n:e.length),hash:r>-1?e.substring(r):"",search:n>-1?e.slice(n,-1===r?void 0:r):"",state:t||{}}}function f(){return(Math.random()+1).toString(36).substring(7)}function p(e,t){if(!e)throw new Error("Invariant failed")}function m(e,t){}const y="undefined"==typeof document;function g(e){return e[e.length-1]}function v(e,t){return"function"==typeof e?e(t):e}function w(e,t){return t.reduce(((t,r)=>(t[r]=e[r],t)),{})}function b(e,t){if(e===t)return e;const r=t,n=Array.isArray(e)&&Array.isArray(r);if(n||S(e)&&S(r)){const t=n?e.length:Object.keys(e).length,o=n?r:Object.keys(r),a=o.length,s=n?[]:{};let c=0;for(let t=0;t<a;t++){const a=n?t:o[t];s[a]=b(e[a],r[a]),s[a]===e[a]&&c++}return t===a&&c===t?e:s}return r}function S(e){if(!E(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!!E(r)&&!!r.hasOwnProperty("isPrototypeOf")}function E(e){return"[object Object]"===Object.prototype.toString.call(e)}function R(e,t){return e===t||typeof e==typeof t&&(S(e)&&S(t)?!Object.keys(t).some((r=>!R(e[r],t[r]))):!(!Array.isArray(e)||!Array.isArray(t))&&(e.length===t.length&&e.every(((e,r)=>R(e,t[r])))))}function P(e){const t=n.useRef(e);t.current=e;return n.useRef(((...e)=>t.current(...e))).current}function C(e){return k(e.filter(Boolean).join("/"))}function k(e){return e.replace(/\/{2,}/g,"/")}function M(e){return"/"===e?e:e.replace(/^\/{1,}/,"")}function O(e){return"/"===e?e:e.replace(/\/{1,}$/,"")}function L(e){return O(M(e))}function _(e,t,r){t=t.replace(new RegExp(`^${e}`),"/"),r=r.replace(new RegExp(`^${e}`),"/");let n=I(t);const o=I(r);o.forEach(((e,t)=>{if("/"===e.value)t?t===o.length-1&&n.push(e):n=[e];else if(".."===e.value)n.length>1&&"/"===g(n)?.value&&n.pop(),n.pop();else{if("."===e.value)return;n.push(e)}}));return k(C([e,...n.map((e=>e.value))]))}function I(e){if(!e)return[];const t=[];if("/"===(e=k(e)).slice(0,1)&&(e=e.substring(1),t.push({type:"pathname",value:"/"})),!e)return t;const r=e.split("/").filter(Boolean);return t.push(...r.map((e=>"$"===e||"*"===e?{type:"wildcard",value:e}:"$"===e.charAt(0)?{type:"param",value:e}:{type:"pathname",value:e}))),"/"===e.slice(-1)&&(e=e.substring(1),t.push({type:"pathname",value:"/"})),t}function x(e,t,r=!1){return C(I(e).map((e=>{if("wildcard"===e.type){const n=t[e.value];return r?`${e.value}${n??""}`:n}return"param"===e.type?t[e.value.substring(1)]??"":e.value})))}function T(e,t,r){const n=j(e,t,r);if(!r.to||n)return n??{}}function j(e,t,r){t="/"!=e?t.substring(e.length):t;const n=`${r.to??"$"}`,o=I(t),a=I(n);t.startsWith("/")||o.unshift({type:"pathname",value:"/"}),n.startsWith("/")||a.unshift({type:"pathname",value:"/"});const s={};return(()=>{for(let e=0;e<Math.max(o.length,a.length);e++){const t=o[e],n=a[e],c=e>=o.length-1,i=e>=a.length-1;if(n){if("wildcard"===n.type)return!!t?.value&&(s["*"]=C(o.slice(e).map((e=>e.value))),!0);if("pathname"===n.type){if("/"===n.value&&!t?.value)return!0;if(t)if(r.caseSensitive){if(n.value!==t.value)return!1}else if(n.value.toLowerCase()!==t.value.toLowerCase())return!1}if(!t)return!1;if("param"===n.type){if("/"===t?.value)return!1;"$"!==t.value.charAt(0)&&(s[n.value.substring(1)]=t.value)}}if(!c&&i)return!!r.fuzzy}return!0})()?s:void 0}function A(e,t){var r,n,o,a="";for(r in e)if(void 0!==(o=e[r]))if(Array.isArray(o))for(n=0;n<o.length;n++)a&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(o[n]);else a&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(o);return(t||"")+a}function $(e){if(!e)return"";var t=decodeURIComponent(e);return"false"!==t&&("true"===t||(0*+t==0&&+t+""===t?+t:t))}function D(e){for(var t,r,n={},o=e.split("&");t=o.shift();)void 0!==n[r=(t=t.split("=")).shift()]?n[r]=[].concat(n[r],$(t.shift())):n[r]=$(t.shift());return n}function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},B.apply(this,arguments)}const F=K(JSON.parse),H=z(JSON.stringify,JSON.parse);function K(e){return t=>{"?"===t.substring(0,1)&&(t=t.substring(1));let r=D(t);for(let t in r){const n=r[t];if("string"==typeof n)try{r[t]=e(n)}catch(e){}}return r}}function z(e,t){return r=>{(r={...r})&&Object.keys(r).forEach((n=>{const o=r[n];void 0===o||void 0===o?delete r[n]:r[n]=function(r){if("object"==typeof r&&null!==r)try{return e(r)}catch(e){}else if("string"==typeof r&&"function"==typeof t)try{return t(r),e(r)}catch(e){}return r}(o)}));const n=A(r).toString();return n?`?${n}`:""}}const N=["component","errorComponent","pendingComponent"];function U(e){return!!e?.isRedirect}const W="Error preloading route! ☝️",q=n.createContext(null);function J(e){return{status:"idle",isFetching:!1,resolvedLocation:e,location:e,matches:[],pendingMatches:[],lastUpdated:Date.now()}}"undefined"!=typeof document&&(window.__TSR_ROUTER_CONTEXT__=q);class V extends Error{}class X extends Error{}function G(e,t){return[...e.pendingMatches,...e.matches].find((e=>e.id===t))}const Q="undefined"!=typeof window?n.useLayoutEffect:n.useEffect;function Y(e){const{buildLink:t,state:r}=te(),o=ne({strict:!1}),{type:a,children:s,target:c,activeProps:i=(()=>({className:"active"})),inactiveProps:u=(()=>({})),activeOptions:l,disabled:h,hash:d,search:f,params:p,to:m,state:y,mask:g,preload:w,preloadDelay:b,replace:S,style:E,className:R,onClick:P,onFocus:C,onMouseEnter:k,onMouseLeave:M,onTouchStart:O,...L}=e,_=t(r,{from:e.to?o.pathname:void 0,...e});if("external"===_.type){const{href:e}=_;return{href:e}}const{handleClick:I,handleFocus:x,handleEnter:T,handleLeave:j,handleTouchStart:A,isActive:$,next:D}=_,B=e=>t=>{t.persist&&t.persist(),e.filter(Boolean).forEach((e=>{t.defaultPrevented||e(t)}))},F=$?v(i,{})??{}:{},H=$?{}:v(u,{})??{};return{...F,...H,...L,href:h?void 0:D.maskedLocation?D.maskedLocation.href:D.href,onClick:B([P,t=>{(e.startTransition??1)&&(n.startTransition||(e=>e))((()=>{I(t)}))}]),onFocus:B([C,x]),onMouseEnter:B([k,T]),onMouseLeave:B([M,j]),onTouchStart:B([O,A]),target:c,style:{...E,...F.style,...H.style},className:[R,F.className,H.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":$?"active":void 0}}const Z=n.forwardRef(((e,t)=>{const r=Y(e);return n.createElement("a",B({ref:t},r,{children:"function"==typeof e.children?e.children({isActive:"active"===r["data-status"]}):e.children}))}));const ee=n.createContext(null);function te(){const e=window.__TSR_ROUTER_CONTEXT__||q;return n.useContext(e)}function re(e){const{state:t}=te();return e?.select?e.select(t):t}function ne(e){const t=n.useContext(ee)[0],r=t?.routeId,o=re({select:r=>(e?.from?r.matches.find((t=>t.routeId===e?.from)):r.matches.find((e=>e.id===t.id))).routeId});(e?.strict??1)&&p(r==o);return re({select:r=>{const n=e?.from?r.matches.find((t=>t.routeId===e?.from)):r.matches.find((e=>e.id===t.id));return p(n,e?.from&&e.from),e?.select?e.select(n):n}})}function oe(e){return ne({...e,select:t=>e?.select?e.select(t.search):t.search})}function ae(e){return re({select:t=>{const r=g(t.matches)?.params;return e?.select?e.select(r):r}})}function se(){const{state:e,matchRoute:t}=te();return n.useCallback((r=>{const{pending:n,caseSensitive:o,...a}=r;return t(e,a,{pending:n,caseSensitive:o})}),[])}function ce(){const{routesById:e,state:t}=te(),{matches:r}=t,o=re({select:e=>e.resolvedLocation.state?.key}),a=e[ge],s=n.useCallback((e=>n.createElement(me,{...e,useMatch:a.useMatch,useRouteMeta:a.useRouteMeta,useSearch:a.useSearch,useParams:a.useParams})),[a]);return n.createElement(ee.Provider,{value:r},n.createElement(fe,{resetKey:o,errorComponent:s,onCatch:()=>{}},r.length?n.createElement(le,{matches:r}):null))}function ie(){const e=n.useContext(ee).slice(1);return e[0]?n.createElement(le,{matches:e}):null}const ue=()=>null;function le({matches:e}){const{options:t,routesById:r}=te(),o=e[0],a=o?.routeId,s=r[a],c=re({select:e=>e.resolvedLocation.state?.key}),i=s.options.pendingComponent??t.defaultPendingComponent??ue,u=s.options.errorComponent??t.defaultErrorComponent??me,l=s.options.wrapInSuspense??!s.isRoot?n.Suspense:de,h=u?fe:de,d=n.useCallback((e=>n.createElement(u,{...e,useMatch:s.useMatch,useRouteMeta:s.useRouteMeta,useSearch:s.useSearch,useParams:s.useParams})),[s]);return n.createElement(ee.Provider,{value:e},n.createElement(l,{fallback:n.createElement(i,{useMatch:s.useMatch,useRouteMeta:s.useRouteMeta,useSearch:s.useSearch,useParams:s.useParams})},n.createElement(h,{resetKey:c,errorComponent:d,onCatch:()=>{o.id}},n.createElement(he,{match:o}))))}function he({match:e}){const{options:t,routesById:r}=te(),o=r[e.routeId];if("error"===e.status)throw e.error;if("pending"===e.status)throw e.loadPromise;if("success"===e.status){let e=o.options.component??t.defaultComponent;return e?n.createElement(e,{useMatch:o.useMatch,useRouteMeta:o.useRouteMeta,useSearch:o.useSearch,useParams:o.useParams}):n.createElement(ie,null)}p(!1)}function de(e){return n.createElement(n.Fragment,null,e.children)}function fe(e){const t=e.errorComponent??me;return n.createElement(pe,{resetKey:e.resetKey,onCatch:e.onCatch,children:({error:r})=>r?n.createElement(t,{error:r}):e.children})}class pe extends n.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidUpdate(e,t){t.error&&e.resetKey!==this.props.resetKey&&this.setState({error:null})}componentDidCatch(e){this.props.onCatch?.(e)}render(){return this.props.children(this.state)}}function me({error:e}){const[t,r]=n.useState(!1);return n.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},n.createElement("div",{style:{display:"flex",alignItems:"center",gap:".5rem"}},n.createElement("strong",{style:{fontSize:"1rem"}},"Something went wrong!"),n.createElement("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>r((e=>!e))},t?"Hide Error":"Show Error")),n.createElement("div",{style:{height:".25rem"}}),t?n.createElement("div",null,n.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"}},e.message?n.createElement("code",null,e.message):null)):null)}function ye(e,t=!0){const{history:r}=te();n.useEffect((()=>{if(!t)return;let n=r.block(((t,r)=>{window.confirm(e)&&(n(),t())}));return n}))}const ge="__root__";class ve{constructor(e){this.options=e||{},this.isRoot=!e?.getParentRoute,ve.__onInit(this)}init=e=>{this.originalIndex=e.originalIndex;const t=this.options,r=!t?.path&&!t?.id;this.parentRoute=this.options?.getParentRoute?.(),r?this.path=ge:p(this.parentRoute);let n=r?ge:t.path;n&&"/"!==n&&(n=L(n));const o=t?.id||n;let a=r?ge:C([this.parentRoute.id===ge?"":this.parentRoute.id,o]);n===ge&&(n="/"),a!==ge&&(a=C(["/",a]));const s=a===ge?"/":C([this.parentRoute.fullPath,n]);this.path=n,this.id=a,this.fullPath=s,this.to=s};addChildren=e=>(this.children=e,this);update=e=>(Object.assign(this.options,e),this);static __onInit=e=>{};useMatch=e=>ne({...e,from:this.id});useRouteMeta=e=>ne({...e,from:this.id,select:t=>e?.select?e.select(t.meta):t.meta});useSearch=e=>oe({...e,from:this.id});useParams=e=>ae({...e,from:this.id})}class we extends ve{constructor(e){super(e)}}e.Block=function({message:e,condition:t,children:r}){return ye(e,t),r??null},e.CatchBoundary=fe,e.CatchBoundaryImpl=pe,e.ErrorComponent=me,e.FileRoute=class{constructor(e){this.path=e}createRoute=e=>{const t=new ve(e);return t.isRoot=!1,t}},e.Link=Z,e.MatchRoute=function(e){const t=se()(e);return"function"==typeof e.children?e.children(t):t?e.children:null},e.Matches=ce,e.Navigate=function(e){const{navigate:t}=te(),r=ne({strict:!1});return Q((()=>{t({from:e.to?r.pathname:void 0,...e})}),[]),null},e.Outlet=ie,e.PathParamError=X,e.RootRoute=we,e.Route=ve,e.Router=class{constructor(e){this.options={defaultPreloadDelay:50,meta:void 0,...e,stringifySearch:e?.stringifySearch??H,parseSearch:e?.parseSearch??F},this.routeTree=this.options.routeTree}subscribers=new Set;subscribe=(e,t)=>{const r={eventType:e,fn:t};return this.subscribers.add(r),()=>{this.subscribers.delete(r)}};emit=e=>{this.subscribers.forEach((t=>{t.eventType===e.type&&t.fn(e)}))}},e.RouterMeta=class{constructor(){}createRootRoute=e=>new we(e)},e.RouterProvider=function({router:e,...t}){const r={...e.options,...t,meta:{...e.options.meta,...t?.meta}},o=n.useState((()=>r.history??h()))[0],a=n.useRef(`${Math.round(1e7*Math.random())}`),s=n.useRef(!1),c=n.useRef(null),i=n.useRef(Promise.resolve()),u=e=>i.current!==e?i.current:void 0,l=P((e=>{const t=({pathname:t,search:n,hash:o,state:a})=>{const s=r.parseSearch(n);return{pathname:t,searchStr:n,search:b(e?.search,s),hash:o.split("#").reverse()[0]??"",href:`${t}${n}${o}`,state:b(e?.state,a)}},n=t(o.location);let{__tempLocation:s,__tempKey:c}=n.state;if(s&&(!c||c===a.current)){const e=t(s);return e.state.key=n.state.key,delete e.state.__tempLocation,{...e,maskedLocation:n}}return n})),[d,f]=n.useState((()=>J(l()))),m=`/${L(r.basepath??"")??""}`,y=P(((e,t)=>_(m,e,k(t)))),[S,E]=n.useMemo((()=>{const t={},r={},n=e=>{e.forEach(((e,o)=>{e.init({originalIndex:o});if(p(!t[e.id],String(e.id)),t[e.id]=e,!e.isRoot&&e.path){const t=O(e.fullPath);r[t]&&!e.fullPath.endsWith("/")||(r[t]=e)}const a=e.children;a?.length&&n(a)}))};return n([e.routeTree]),[t,r]}),[]),M=S,j=n.useMemo((()=>Object.values(E).map(((e,t)=>{const r=L(e.fullPath),n=I(r);for(;n.length>1&&"/"===n[0]?.value;)n.shift();const o=n.map((e=>"param"===e.type?.5:"wildcard"===e.type?.25:1));return{child:e,trimmed:r,parsed:n,index:t,score:o}})).sort(((e,t)=>{let r="/"===e.trimmed?1:"/"===t.trimmed?-1:0;if(0!==r)return r;const n=Math.min(e.score.length,t.score.length);if(e.score.length!==t.score.length)return t.score.length-e.score.length;for(let r=0;r<n;r++)if(e.score[r]!==t.score[r])return t.score[r]-e.score[r];for(let r=0;r<n;r++)if(e.parsed[r].value!==t.parsed[r].value)return e.parsed[r].value>t.parsed[r].value?1:-1;return e.trimmed!==t.trimmed?e.trimmed>t.trimmed?1:-1:e.index-t.index})).map(((e,t)=>(e.child.rank=t,e.child)))),[E]),A=P(((e,t,n)=>{let o={},a=j.find((t=>{const n=T(m,O(e),{to:t.fullPath,caseSensitive:t.options.caseSensitive??r.caseSensitive,fuzzy:!1});return!!n&&(o=n,!0)}))||S.__root__,s=[a];for(;a?.parentRoute;)a=a.parentRoute,a&&s.unshift(a);const c=s.map((e=>{let t;if(e.options.parseParams)try{const t=e.options.parseParams(o);Object.assign(o,t)}catch(e){if(t=new X(e.message,{cause:e}),n?.throwOnError)throw t;return t}})),i=s.map(((e,t)=>{const r=x(e.path,o),n=x(e.id,o,!0),a=G(d,n);if(a)return{...a};const s=!(!e.options.load&&!N.some((t=>e.options[t]?.preload)));return{id:n,routeId:e.id,params:o,pathname:C([m,r]),updatedAt:Date.now(),routeSearch:{},search:{},status:s?"pending":"success",isFetching:!1,invalid:!1,error:void 0,paramsError:c[t],searchError:void 0,loadPromise:Promise.resolve(),meta:void 0,abortController:new AbortController,fetchedAt:0}}));return i.forEach(((e,r)=>{const o=i[r-1],a=M[e.routeId],s=(()=>{const r={search:o?.search??t,routeSearch:o?.routeSearch??t};try{let t=("object"==typeof a.options.validateSearch?a.options.validateSearch.parse:a.options.validateSearch)?.(r.search)??{},n={...r.search,...t};return t=b(e.routeSearch,t),n=b(e.search,n),{routeSearch:t,search:n,searchDidChange:e.routeSearch!==t}}catch(t){if(e.searchError=new V(t.message,{cause:t}),n?.throwOnError)throw e.searchError;return r}})();Object.assign(e,s)})),i})),$=P((e=>{G(d,e)?.abortController?.abort()})),D=P((e=>{e.matches.forEach((e=>{$(e.id)}))})),B=P(((e={})=>{const t=(e={},t)=>{const n=ee.current,a=e.from??n.pathname;let s=y(a,`${e.to??""}`);const c=A(a,n.search),i=t?.filter((e=>c?.find((t=>t.routeId===e.routeId)))),u={...g(c)?.params};let l=!0===(e.params??!0)?u:v(e.params,u);l&&t?.map((e=>M[e.routeId].options.stringifyParams)).filter(Boolean).forEach((e=>{l={...l,...e(l)}})),s=x(s,l??{});const h=i?.map((e=>M[e.routeId].options.preSearchFilters??[])).flat().filter(Boolean)??[],d=i?.map((e=>M[e.routeId].options.postSearchFilters??[])).flat().filter(Boolean)??[],f=h?.length?h?.reduce(((e,t)=>t(e)),n.search):n.search,p=!0===e.search?f:e.search?v(e.search,f)??{}:h?.length?f:{},m=d?.length?d.reduce(((e,t)=>t(e)),p):p,w=b(n.search,m),S=r.stringifySearch(w),E=!0===e.hash?n.hash:e.hash?v(e.hash,n.hash):n.hash,R=E?`#${E}`:"";let P=!0===e.state?n.state:e.state?v(e.state,n.state):n.state;return P=b(n.state,P),{pathname:s,search:w,searchStr:S,state:P,hash:E,href:o.createHref(`${s}${S}${R}`),unmaskOnReload:e.unmaskOnReload}},n=(e={},n)=>{let o=t(e),a=n?t(n):void 0;if(!a){let e={},s=r.routeMasks?.find((t=>{const r=T(m,o.pathname,{to:t.from,caseSensitive:!1,fuzzy:!1});return!!r&&(e=r,!0)}));s&&(s={...s,from:x(s.from,e)},a=t(n=s))}const s=A(o.pathname,o.search),c=a?A(a.pathname,a.search):void 0,i=a?t(n,c):void 0,u=t(e,s);return i&&(u.maskedLocation=i),u};return e.mask?n(e,{...w(e,["from"]),...e.mask}):n(e)})),F=P((async e=>{c.current&&clearTimeout(c.current);if(!(ee.current.href===e.href)||!e.replace){let{maskedLocation:t,...n}=e;t&&(n={...t,state:{...t.state,__tempKey:void 0,__tempLocation:{...n,search:n.searchStr,state:{...n.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(n.unmaskOnReload??r.unmaskOnReload)&&(n.state.__tempKey=a.current)),o[e.replace?"replace":"push"](n.href,n.state)}return s.current=e.resetScroll??!0,i.current})),H=P((({replace:e,resetScroll:t,...r}={})=>{const n=B(r);return F({...n,replace:e,resetScroll:t})})),K=P((({from:e,to:t="",...r})=>{const n=String(t),o=void 0===e?e:String(e);let a;try{new URL(`${n}`),a=!0}catch(e){}return p(!a),H({...r,from:o,to:n})})),z=P((async({checkLatest:e,matches:t,preload:n})=>{let o,a;try{for(let[e,o]of t.entries()){const s=t[e-1],c=M[o.routeId],i=(r,n)=>{if(r.routerCode=n,a=a??e,U(r))throw r;try{c.options.onError?.(r)}catch(e){if(r=e,U(e))throw e}t[e]=o={...o,error:r,status:"error",updatedAt:Date.now()}};try{o.paramsError&&i(o.paramsError,"PARSE_PARAMS"),o.searchError&&i(o.searchError,"VALIDATE_SEARCH");const a=s?.meta??r.meta??{},u=await(c.options.beforeLoad?.({search:o.search,abortController:o.abortController,params:o.params,preload:!!n,meta:a,location:d.location,navigate:e=>K({...e,from:o.pathname})}))??{},l={...a,...u};t[e]=o={...o,meta:b(o.meta,l)}}catch(e){i(e,"BEFORE_LOAD");break}}}catch(e){if(U(e))return n||K(e),t;throw e}const s=t.slice(0,a),c=[];return s.forEach(((r,a)=>{c.push((async()=>{const s=c[a-1],i=M[r.routeId];if(r.isFetching)return G(d,r.id)?.loadPromise;const u=e=>!!U(e)&&(n||K(e),!0);let l;t[a]=r={...r,isFetching:!0,fetchedAt:Date.now(),invalid:!1},l=(async()=>{try{const c=Promise.all(N.map((async e=>{const t=i.options[e];t?.preload&&await t.preload()}))),u=i.options.load?.({params:r.params,search:r.search,preload:!!n,parentMatchPromise:s,abortController:r.abortController,meta:r.meta,location:d.location,navigate:e=>K({...e,from:r.pathname})});if(await Promise.all([c,u]),o=e())return await o;t[a]=r={...r,error:void 0,status:"success",isFetching:!1,updatedAt:Date.now()}}catch(n){if(o=e())return await o;if(u(n))return;try{i.options.onError?.(n)}catch(e){if(n=e,u(e))return}t[a]=r={...r,error:n,status:"error",isFetching:!1,updatedAt:Date.now()}}n||f((e=>({...e,matches:e.matches.map((e=>e.id===r.id?r:e))})))})(),t[a]=r={...r,loadPromise:l},await l})())})),await Promise.all(c),t})),Q=P((async()=>{const t=new Promise((async(r,n)=>{const o=ee.current,a=d.resolvedLocation,s=!(!o||a.href===o.href);let c;D(d),e.emit({type:"onBeforeLoad",from:a,to:o??d.location,pathChanged:s}),f((e=>({...e,location:o})));let i=A(o.pathname,o.search,{debug:!0});f((e=>({...e,status:"pending",matches:i})));try{try{await z({matches:i,checkLatest:()=>u(t)})}catch(e){}if(c=u(t))return c;f((e=>({...e,status:"idle",resolvedLocation:e.location}))),e.emit({type:"onLoad",from:a,to:o,pathChanged:s}),r()}catch(e){if(c=u(t))return c;n(e)}}));return i.current=t,i.current})),Y=P((async(e=d.location)=>{let t=B(e),r=A(t.pathname,t.search,{throwOnError:!0});return await z({matches:r,preload:!0,checkLatest:()=>{}}),[g(r),r]})),Z=P(((e,t)=>{const{to:n,preload:o,preloadDelay:a,activeOptions:s,disabled:c,target:i,replace:u,resetScroll:l}=t;try{return new URL(`${n}`),{type:"external",href:n}}catch(e){}const h=t,d=B(h),f=o??r.defaultPreload,p=a??r.defaultPreloadDelay??0,m=ee.current.pathname.split("/"),y=d.pathname.split("/").every(((e,t)=>e===m[t])),g=s?.exact?ee.current.pathname===d.pathname:y,v=!s?.includeHash||ee.current.hash===d.hash,w=!(s?.includeSearch??1)||R(ee.current.search,d.search);return{type:"internal",next:d,handleFocus:e=>{f&&Y(h).catch((e=>{console.warn(e),console.warn(W)}))},handleClick:e=>{c||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)||e.defaultPrevented||i&&"_self"!==i||0!==e.button||(e.preventDefault(),F({...d,replace:u,resetScroll:l}))},handleEnter:e=>{const t=e.target||{};if(f){if(t.preloadTimeout)return;t.preloadTimeout=setTimeout((()=>{t.preloadTimeout=null,Y(h).catch((e=>{console.warn(e),console.warn(W)}))}),p)}},handleLeave:e=>{const t=e.target||{};t.preloadTimeout&&(clearTimeout(t.preloadTimeout),t.preloadTimeout=null)},handleTouchStart:e=>{Y(h).catch((e=>{console.warn(e),console.warn(W)}))},isActive:g&&v&&w,disabled:c}})),ee=n.useRef(d.location);n.useLayoutEffect((()=>{const e=o.subscribe((()=>{ee.current=l(ee.current),n.startTransition((()=>{if(d.location!==ee.current)try{Q()}catch(e){console.error(e)}}))})),t=B({search:!0,params:!0,hash:!0,state:!0});return d.location.href!==t.href&&F({...t,replace:!0}),()=>{e()}}),[o]);const te=n.useRef(!0);if(te.current){te.current=!1;try{Q()}catch(e){console.error(e)}}n.useMemo((()=>[...d.matches,...d.pendingMatches].some((e=>e.isFetching))),[d.matches,d.pendingMatches]);const re=P(((e,t,r)=>{t={...t,to:t.to?y(t.from||"",t.to):void 0};const n=B(t);if(r?.pending&&"pending"!==e.status)return!1;const o=r?.pending?ee.current:e.resolvedLocation;if(!o)return!1;const a=T(m,o.pathname,{...r,to:n.pathname});return!!a&&(r?.includeSearch??1?!!R(o.search,n.search)&&a:a)})),ne={routeTree:e.routeTree,navigate:K,buildLink:Z,state:d,matchRoute:re,routesById:S,options:r,history:o,load:Q};return n.createElement(q.Provider,{value:ne},n.createElement(ce,null))},e.SearchParamError=V,e.cleanPath=k,e.componentTypes=N,e.createBrowserHistory=h,e.createHashHistory=function(){return h({getHref:()=>window.location.hash.substring(1),createHref:e=>`#${e}`})},e.createMemoryHistory=function(e={initialEntries:["/"]}){const t=e.initialEntries;let r=e.initialIndex??t.length-1,n={key:f()};return u({getLocation:()=>d(t[r],n),pushState:(e,o)=>{n=o,t.push(e),r++},replaceState:(e,o)=>{n=o,t[r]=e},back:()=>{r--},forward:()=>{r=Math.min(r+1,t.length-1)},go:e=>window.history.go(e),createHref:e=>e})},e.createRouteMask=function(e){return e},e.decode=D,e.defaultParseSearch=F,e.defaultStringifySearch=H,e.encode=A,e.functionalUpdate=v,e.getInitialRouterState=J,e.getRouteMatch=G,e.interpolatePath=x,e.invariant=p,e.isPlainObject=S,e.isRedirect=U,e.isServer=y,e.joinPaths=C,e.last=g,e.lazyFn=function(e,t){return async(...r)=>(await e())[t||"default"](...r)},e.lazyRouteComponent=function(e,t){let r;const o=()=>(r||(r=e()),r),a=n.lazy((async()=>({default:(await o())[t??"default"]})));return a.preload=o,a},e.matchByPath=j,e.matchPathname=T,e.matchesContext=ee,e.parsePathname=I,e.parseSearchWith=K,e.partialDeepEqual=R,e.pick=w,e.redirect=function(e){return e.isRedirect=!0,e},e.replaceEqualDeep=b,e.resolvePath=_,e.rootRouteId=ge,e.routerContext=q,e.shallow=function(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let n=0;n<r.length;n++)if(!Object.prototype.hasOwnProperty.call(t,r[n])||!Object.is(e[r[n]],t[r[n]]))return!1;return!0},e.stringifySearchWith=z,e.trimPath=L,e.trimPathLeft=M,e.trimPathRight=O,e.typedNavigate=function(e){return e},e.useBlocker=ye,e.useLinkProps=Y,e.useMatch=ne,e.useMatchRoute=se,e.useMatches=function(e){const t=n.useContext(ee);return re({select:r=>{const n=r.matches.slice(r.matches.findIndex((e=>e.id===t[0]?.id)));return e?.select?e.select(n):n}})},e.useNavigate=function(e){const{navigate:t}=te(),r=ne({strict:!1});return n.useCallback((n=>t({from:n?.to?r.pathname:void 0,...e,...n})),[])},e.useParams=ae,e.useRouteMeta=function(e){return ne({...e,select:t=>e?.select?e.select(t.meta):t.meta})},e.useRouter=te,e.useRouterState=re,e.useSearch=oe,e.useStableCallback=P,e.warning=m,Object.defineProperty(e,"__esModule",{value:!0})}));
22
22
  //# sourceMappingURL=index.production.js.map