@tanstack/react-router 0.0.1-beta.227 → 0.0.1-beta.228
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/Matches.js +0 -4
- package/build/cjs/Matches.js.map +1 -1
- package/build/esm/index.js +0 -3
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +281 -287
- package/build/umd/index.development.js +0 -3
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/Matches.tsx +0 -4
|
@@ -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 n="pushstate",s="popstate",a="beforeunload",i=t=>(t.preventDefault(),t.returnValue=""),c=()=>{removeEventListener(a,i,{capture:!0})};function l(t){let e=t.getLocation(),o=new Set,r=[],n=[];const s=()=>{e=t.getLocation(),o.forEach((t=>t()))},l=()=>{if(r.length)r[0]?.(l,(()=>{r=[],c()}));else for(;n.length;)n.shift()?.()},h=t=>{n.push(t),l()};return{get location(){return e},subscribe:t=>(o.add(t),()=>{o.delete(t)}),push:(e,o)=>{o=u(o),h((()=>{t.pushState(e,o,s)}))},replace:(e,o)=>{o=u(o),h((()=>{t.replaceState(e,o,s)}))},go:e=>{h((()=>{t.go(e)}))},back:()=>{h((()=>{t.back()}))},forward:()=>{h((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(r.push(t),1===r.length&&addEventListener(a,i,{capture:!0}),()=>{r=r.filter((e=>e!==t)),r.length||c()}),flush:()=>t.flush?.(),destroy:()=>t.destroy?.(),notify:s}}function u(t){return t||(t={}),{...t,key:f()}}function h(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),o=t?.createHref??(t=>t);let r=d(e(),window.history.state);let a,i,c=!0;const u=()=>{c=!1,(()=>{a&&(window.history[a.isPush?"pushState":"replaceState"](a.state,"",a.href),a=void 0,i=void 0)})(),c=!0},h=(t,e,n,s)=>{const c=o(e);r=d(c,n),a={href:c,state:n,isPush:a?.isPush||"push"===t},s(),i||(i=Promise.resolve().then((()=>u())))},f=()=>{r=d(e(),window.history.state),y.notify()};var p=window.history.pushState,m=window.history.replaceState;const y=l({getLocation:()=>r,pushState:(t,e,o)=>h("push",t,e,o),replaceState:(t,e,o)=>h("replace",t,e,o),back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>o(t),flush:u,destroy:()=>{window.history.pushState=p,window.history.replaceState=m,window.removeEventListener(n,f),window.removeEventListener(s,f)}});return window.addEventListener(n,f),window.addEventListener(s,f),window.history.pushState=function(){let t=p.apply(window.history,arguments);return c&&y.notify(),t},window.history.replaceState=function(){let t=m.apply(window.history,arguments);return c&&y.notify(),t},y}function d(t,e){let o=t.indexOf("#"),r=t.indexOf("?");return{href:t,pathname:t.substring(0,o>0?r>0?Math.min(o,r):o:r>0?r:t.length),hash:o>-1?t.substring(o):"",search:r>-1?t.slice(r,-1===o?void 0:o):"",state:e||{}}}function f(){return(Math.random()+1).toString(36).substring(7)}var p="Invariant failed";function m(t,e){if(!t)throw new Error(p)}function y(t,e){}function g(t){const e=t.errorComponent??w;return r.createElement(v,{resetKey:t.resetKey,onCatch:t.onCatch,children:({error:o})=>o?r.createElement(e,{error:o}):t.children})}class v extends r.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t,e){e.error&&t.resetKey!==this.props.resetKey&&this.setState({error:null})}componentDidCatch(t){console.error(t),this.props.onCatch?.(t)}render(){return this.props.children(this.state)}}function w({error:t}){const[e,o]=r.useState(!1);return r.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},r.createElement("div",{style:{display:"flex",alignItems:"center",gap:".5rem"}},r.createElement("strong",{style:{fontSize:"1rem"}},"Something went wrong!"),r.createElement("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>o((t=>!t))},e?"Hide Error":"Show Error")),r.createElement("div",{style:{height:".25rem"}}),e?r.createElement("div",null,r.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"}},t.message?r.createElement("code",null,t.message):null)):null)}const S="undefined"==typeof document;function b(t){return t[t.length-1]}function R(t,e){return"function"==typeof t?t(e):t}function L(t,e){return e.reduce(((e,o)=>(e[o]=t[o],e)),{})}function E(t,e){if(t===e)return t;const o=e,r=Array.isArray(t)&&Array.isArray(o);if(r||P(t)&&P(o)){const e=r?t.length:Object.keys(t).length,n=r?o:Object.keys(o),s=n.length,a=r?[]:{};let i=0;for(let e=0;e<s;e++){const s=r?e:n[e];a[s]=E(t[s],o[s]),a[s]===t[s]&&i++}return e===s&&i===e?t:a}return o}function P(t){if(!_(t))return!1;const e=t.constructor;if(void 0===e)return!0;const o=e.prototype;return!!_(o)&&!!o.hasOwnProperty("isPrototypeOf")}function _(t){return"[object Object]"===Object.prototype.toString.call(t)}function C(t,e,o=!1){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(P(t)&&P(e)){const r=Object.keys(t),n=Object.keys(e);return!(!o&&r.length!==n.length)&&!n.some((r=>!(r in t)||!C(t[r],e[r],o)))}return!(!Array.isArray(t)||!Array.isArray(e))&&!t.some(((t,r)=>!C(t,e[r],o)))}const x="undefined"!=typeof window?r.useLayoutEffect:r.useEffect;function k(t){return t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"')}function O(t){return T(t.filter(Boolean).join("/"))}function T(t){return t.replace(/\/{2,}/g,"/")}function I(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function M(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function D(t){return M(I(t))}function j(t,e,o){e=e.replace(new RegExp(`^${t}`),"/"),o=o.replace(new RegExp(`^${t}`),"/");let r=B(e);const n=B(o);n.forEach(((t,e)=>{if("/"===t.value)e?e===n.length-1&&r.push(t):r=[t];else if(".."===t.value)r.length>1&&"/"===b(r)?.value&&r.pop(),r.pop();else{if("."===t.value)return;r.push(t)}}));return T(O([t,...r.map((t=>t.value))]))}function B(t){if(!t)return[];const e=[];if("/"===(t=T(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const o=t.split("/").filter(Boolean);return e.push(...o.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 $(t,e,o=!1){return O(B(t).map((t=>{if("wildcard"===t.type){const r=e[t.value];return o?`${t.value}${r??""}`:r}return"param"===t.type?e[t.value.substring(1)]??"":t.value})))}function A(t,e,o){const r=N(t,e,o);if(!o.to||r)return r??{}}function N(t,e,o){e="/"!=t?e.substring(t.length):e;const r=`${o.to??"$"}`,n=B(e),s=B(r);e.startsWith("/")||n.unshift({type:"pathname",value:"/"}),r.startsWith("/")||s.unshift({type:"pathname",value:"/"});const a={};return(()=>{for(let t=0;t<Math.max(n.length,s.length);t++){const e=n[t],r=s[t],i=t>=n.length-1,c=t>=s.length-1;if(r){if("wildcard"===r.type)return!!e?.value&&(a["*"]=O(n.slice(t).map((t=>t.value))),!0);if("pathname"===r.type){if("/"===r.value&&!e?.value)return!0;if(e)if(o.caseSensitive){if(r.value!==e.value)return!1}else if(r.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===r.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(a[r.value.substring(1)]=e.value)}}if(!i&&c)return!!o.fuzzy}return!0})()?a:void 0}function H(t){return st({select:e=>{const o=b(e.matches)?.params;return t?.select?t.select(o):o}})}function K(t){return G({...t,select:e=>t?.select?t.select(e.search):e.search})}const F="__root__";class W{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute,W.__onInit(this),this.$$typeof=Symbol.for("react.memo")}init=t=>{this.originalIndex=t.originalIndex;const e=this.options,o=!e?.path&&!e?.id;this.parentRoute=this.options?.getParentRoute?.(),o?this.path=F:m(this.parentRoute);let r=o?F:e.path;r&&"/"!==r&&(r=D(r));const n=e?.id||r;let s=o?F:O([this.parentRoute.id===F?"":this.parentRoute.id,n]);r===F&&(r="/"),s!==F&&(s=O(["/",s]));const a=s===F?"/":O([this.parentRoute.fullPath,r]);this.path=r,this.id=s,this.fullPath=a,this.to=a};addChildren=t=>(this.children=t,this);update=t=>(Object.assign(this.options,t),this);static __onInit=t=>{};useMatch=t=>G({...t,from:this.id});useRouteContext=t=>G({...t,from:this.id,select:e=>t?.select?t.select(e.context):e.context});useSearch=t=>K({...t,from:this.id});useParams=t=>H({...t,from:this.id});useLoaderData=t=>Z({...t,from:this.id})}class z extends W{constructor(t){super(t)}}function U(){const{routesById:t,state:e}=at(),{matches:o}=e,n=st().location.state.key,s=t[F],a=r.useCallback((t=>r.createElement(w,{...t,useMatch:s.useMatch,useRouteContext:s.useRouteContext,useSearch:s.useSearch,useParams:s.useParams})),[s]);return r.createElement(Q.Provider,{value:o},r.createElement(g,{resetKey:n,errorComponent:a,onCatch:()=>{}},o.length?r.createElement(Y,{matches:o}):null))}function J(t){return r.createElement(r.Fragment,null,t.children)}function Y({matches:t}){const{options:e,routesById:o}=at(),n=t[0],s=n?.routeId,a=o[s],i=st().location.state?.key,c=a.options.pendingComponent??e.defaultPendingComponent,l=a.options.errorComponent??e.defaultErrorComponent??w,u=a.options.wrapInSuspense??c?r.Suspense:J,h=l?r.useCallback((t=>r.createElement(l,{...t,useMatch:a.useMatch,useRouteContext:a.useRouteContext,useSearch:a.useSearch,useParams:a.useParams})),[a]):void 0,d=h?g:J;return r.createElement(Q.Provider,{value:t},r.createElement(u,{fallback:r.createElement(c,{useMatch:a.useMatch,useRouteContext:a.useRouteContext,useSearch:a.useSearch,useParams:a.useParams})},r.createElement(d,{resetKey:i,errorComponent:h,onCatch:()=>{n.id}},r.createElement(X,{match:n}))))}function X({match:t}){const{options:e,routesById:o}=at(),n=o[t.routeId];if(4===t.id.split("/").length&&console.log(t.id,L(t,["status","cause","isFetching"])),"error"===t.status)throw t.error;if("pending"===t.status)throw t.loadPromise;if("success"===t.status){let t=n.options.component??e.defaultComponent;return t?r.createElement(t,{useMatch:n.useMatch,useRouteContext:n.useRouteContext,useSearch:n.useSearch,useParams:n.useParams,useLoaderData:n.useLoaderData}):r.createElement(q,null)}m(!1)}function q(){const t=r.useContext(Q).slice(1);return t[0]?r.createElement(Y,{matches:t}):null}function V(){const{matchRoute:t}=at();return r.useCallback((e=>{const{pending:o,caseSensitive:r,...n}=e;return t(n,{pending:o,caseSensitive:r})}),[])}function G(t){const e=r.useContext(Q)[0],o=e?.routeId,n=st({select:o=>(t?.from?o.matches.find((e=>e.routeId===t?.from)):o.matches.find((t=>t.id===e.id))).routeId});(t?.strict??1)&&m(o==n);return st({select:o=>{const r=t?.from?o.matches.find((e=>e.routeId===t?.from)):o.matches.find((t=>t.id===e.id));return m(r,t?.from&&t.from),t?.select?t.select(r):r}})}const Q=r.createContext(null);function Z(t){const e=G({...t,select:void 0});return"function"==typeof t.select?t.select(e?.loaderData):e?.loaderData}const tt=r.createContext(null);"undefined"!=typeof document&&(window.__TSR_ROUTER_CONTEXT__=tt);class et extends Error{}class ot extends Error{}function rt(t){return{status:"idle",resolvedLocation:t,location:t,matches:[],pendingMatches:[],lastUpdated:Date.now()}}function nt(t,e){return[...t.pendingMatches,...t.matches].find((t=>t.id===e))}function st(t){const{state:e}=at();return t?.select?t.select(e):e}function at(){const t=window.__TSR_ROUTER_CONTEXT__||tt;return r.useContext(t)}function it(t){return"object"==typeof t&&null!==t&&!(t instanceof Promise)&&!t.then&&"__deferredState"in t}function ct({promise:t}){const e=at();let o=t.__deferredState;const r=`__TSR__DEFERRED__${o.uid}`;if(it(t)&&(o=e.hydrateData(r),(t=Promise.resolve(o.data)).__deferredState=o),"pending"===o.status)throw t;if("error"===o.status)throw o.error;return e.dehydrateData(r,o),[o.data]}function lt(){return lt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(t[r]=o[r])}return t},lt.apply(this,arguments)}function ut(t){const{buildLink:e}=at(),o=G({strict:!1}),{type:r,children:n,target:s,activeProps:a=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:l,hash:u,search:h,params:d,to:f,state:p,mask:m,preload:y,preloadDelay:g,replace:v,startTransition:w,resetScroll:S,style:b,className:L,onClick:E,onFocus:P,onMouseEnter:_,onMouseLeave:C,onTouchStart:x,...k}=t,O=e({from:t.to?o.pathname:void 0,...t});if("external"===O.type){const{href:t}=O;return{href:t}}const{handleClick:T,handleFocus:I,handleEnter:M,handleLeave:D,handleTouchStart:j,isActive:B,next:$}=O,A=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},N=B?R(a,{})??{}:{},H=B?{}:R(i,{})??{};return{...N,...H,...k,href:l?void 0:$.maskedLocation?$.maskedLocation.href:$.href,onClick:A([E,T]),onFocus:A([P,I]),onMouseEnter:A([_,M]),onMouseLeave:A([C,D]),onTouchStart:A([x,j]),target:s,style:{...b,...N.style,...H.style},className:[L,N.className,H.className].filter(Boolean).join(" ")||void 0,...l?{role:"link","aria-disabled":!0}:void 0,"data-status":B?"active":void 0}}const ht=r.forwardRef(((t,e)=>{const o=ut(t);return r.createElement("a",lt({ref:e},o,{children:"function"==typeof t.children?t.children({isActive:"active"===o["data-status"]}):t.children}))}));function dt(t,e){var o,r,n,s="";for(o in t)if(void 0!==(n=t[o]))if(Array.isArray(n))for(r=0;r<n.length;r++)s&&(s+="&"),s+=encodeURIComponent(o)+"="+encodeURIComponent(n[r]);else s&&(s+="&"),s+=encodeURIComponent(o)+"="+encodeURIComponent(n);return(e||"")+s}function ft(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0&&+e+""===e?+e:e))}function pt(t){for(var e,o,r={},n=t.split("&");e=n.shift();)void 0!==r[o=(e=e.split("=")).shift()]?r[o]=[].concat(r[o],ft(e.shift())):r[o]=ft(e.shift());return r}function mt(t){return!!t?.isRedirect}const yt=vt(JSON.parse),gt=wt(JSON.stringify,JSON.parse);function vt(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let o=pt(e);for(let e in o){const r=o[e];if("string"==typeof r)try{o[e]=t(r)}catch(t){}}return o}}function wt(t,e){return o=>{(o={...o})&&Object.keys(o).forEach((r=>{const n=o[r];void 0===n||void 0===n?delete o[r]:o[r]=function(o){if("object"==typeof o&&null!==o)try{return t(o)}catch(t){}else if("string"==typeof o&&"function"==typeof e)try{return e(o),t(o)}catch(t){}return o}(n)}));const r=dt(o).toString();return r?`?${r}`:""}}const St=["component","errorComponent","pendingComponent"],bt="Error preloading route! ☝️";const Rt="undefined"!=typeof window?r.useLayoutEffect:r.useEffect,Lt="window",Et="___";let Pt,_t=new WeakSet;const Ct="undefined"!=typeof window&&window.sessionStorage,xt=t=>t.state.key;function kt(t){const e=at();Rt((()=>{const o=t?.getKey||xt;Ct&&(Pt||(Pt=(()=>{const t="tsr-scroll-restoration-v2";return{state:JSON.parse(window.sessionStorage.getItem(t)||"null")||{cached:{},next:{}},set:e=>{Pt.state=R(e,Pt.state),window.sessionStorage.setItem(t,JSON.stringify(Pt.state))}}})()));const{history:r}=window;r.scrollRestoration&&(r.scrollRestoration="manual");const n=t=>{if(_t.has(t.target))return;_t.add(t.target);const e=t.target===document||t.target===window?Lt:s(t.target);Pt.state.next[e]||Pt.set((t=>({...t,next:{...t.next,[e]:{scrollX:NaN,scrollY:NaN}}})))},s=t=>{let e,o=[];for(;e=t.parentNode;)o.unshift(`${t.tagName}:nth-child(${[].indexOf.call(e.children,t)+1})`),t=e;return`${o.join(" > ")}`.toLowerCase()};"undefined"!=typeof document&&document.addEventListener("scroll",n,!0);const a=e.subscribe("onBeforeLoad",(t=>{if(t.pathChanged){const e=o(t.fromLocation);for(const t in Pt.state.next){const o=Pt.state.next[t];if(t===Lt)o.scrollX=window.scrollX||0,o.scrollY=window.scrollY||0;else if(t){const e=document.querySelector(t);o.scrollX=e?.scrollLeft||0,o.scrollY=e?.scrollTop||0}Pt.set((r=>{const n={...r.next};return delete n[t],{...r,next:n,cached:{...r.cached,[[e,t].join(Et)]:o}}}))}}})),i=e.subscribe("onResolved",(o=>{if(o.pathChanged){if(!e.resetNextScroll)return;e.resetNextScroll=!0;const r=(t?.getKey||xt)(o.toLocation);let n=!1;for(const t in Pt.state.cached){const e=Pt.state.cached[t],[o,s]=t.split(Et);if(o===r)if(s===Lt)n=!0,window.scrollTo(e.scrollX,e.scrollY);else if(s){const t=document.querySelector(s);t&&(t.scrollLeft=e.scrollX,t.scrollTop=e.scrollY)}}n||window.scrollTo(0,0),Pt.set((t=>({...t,next:{}}))),_t=new WeakSet}}));return()=>{document.removeEventListener("scroll",n),a(),i()}}),[])}function Ot(t,e=!0){const{history:o}=at();r.useEffect((()=>{if(!e)return;let r=o.block(((e,o)=>{window.confirm(t)&&(r(),e())}));return r}))}t.Await=function(t){const e=ct(t);return t.children(...e)},t.Block=function({message:t,condition:e,children:o}){return Ot(t,e),o??null},t.CatchBoundary=g,t.CatchBoundaryImpl=v,t.ErrorComponent=w,t.FileRoute=class{constructor(t){this.path=t}createRoute=t=>{const e=new W(t);return e.isRoot=!1,e}},t.Link=ht,t.Match=Y,t.MatchRoute=function(t){const e=V()(t);return"function"==typeof t.children?t.children(e):e?t.children:null},t.Matches=U,t.Navigate=function(t){const{navigate:e}=at(),o=G({strict:!1});return x((()=>{e({from:t.to?o.pathname:void 0,...t})}),[]),null},t.Outlet=q,t.PathParamError=ot,t.RootRoute=z,t.Route=W,t.Router=class{tempLocationKey=`${Math.round(1e7*Math.random())}`;resetNextScroll=!0;navigateTimeout=null;latestLoadPromise=Promise.resolve();subscribers=new Set;pendingMatches=[];injectedHtml=[];constructor(t){this.updateOptions({defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??gt,parseSearch:t?.parseSearch??yt})}startReactTransition=()=>{};setState=()=>{};updateOptions=t=>{this.options,this.options={...this.options,...t},this.basepath=`/${D(t.basepath??"")??""}`,(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history??h(),this.latestLocation=this.parseLocation()),this.options.routeTree!==this.routeTree&&(this.routeTree=this.options.routeTree,this.buildRouteTree()),this.state||(this.state=rt(this.latestLocation))};buildRouteTree=()=>{this.routesById={},this.routesByPath={};const t=e=>{e.forEach(((e,o)=>{e.init({originalIndex:o});if(m(!this.routesById[e.id],String(e.id)),this.routesById[e.id]=e,!e.isRoot&&e.path){const t=M(e.fullPath);this.routesByPath[t]&&!e.fullPath.endsWith("/")||(this.routesByPath[t]=e)}const r=e.children;r?.length&&t(r)}))};t([this.routeTree]),this.flatRoutes=Object.values(this.routesByPath).map(((t,e)=>{const o=D(t.fullPath),r=B(o);for(;r.length>1&&"/"===r[0]?.value;)r.shift();const n=r.map((t=>"param"===t.type?.5:"wildcard"===t.type?.25:1));return{child:t,trimmed:o,parsed:r,index:e,score:n}})).sort(((t,e)=>{let o="/"===t.trimmed?1:"/"===e.trimmed?-1:0;if(0!==o)return o;const r=Math.min(t.score.length,e.score.length);if(t.score.length!==e.score.length)return e.score.length-t.score.length;for(let o=0;o<r;o++)if(t.score[o]!==e.score[o])return e.score[o]-t.score[o];for(let o=0;o<r;o++)if(t.parsed[o].value!==e.parsed[o].value)return t.parsed[o].value>e.parsed[o].value?1:-1;return t.trimmed!==e.trimmed?t.trimmed>e.trimmed?1:-1:t.index-e.index})).map(((t,e)=>(t.child.rank=e,t.child)))};subscribe=(t,e)=>{const o={eventType:t,fn:e};return this.subscribers.add(o),()=>{this.subscribers.delete(o)}};emit=t=>{this.subscribers.forEach((e=>{e.eventType===t.type&&e.fn(t)}))};checkLatest=t=>this.latestLoadPromise!==t?this.latestLoadPromise:void 0;parseLocation=t=>{const e=({pathname:e,search:o,hash:r,state:n})=>{const s=this.options.parseSearch(o);return{pathname:e,searchStr:o,search:E(t?.search,s),hash:r.split("#").reverse()[0]??"",href:`${e}${o}${r}`,state:E(t?.state,n)}},o=e(this.history.location);let{__tempLocation:r,__tempKey:n}=o.state;if(r&&(!n||n===this.tempLocationKey)){const t=e(r);return t.state.key=o.state.key,delete t.state.__tempLocation,{...t,maskedLocation:o}}return o};resolvePathWithBase=(t,e)=>j(this.basepath,t,T(e));get looseRoutesById(){return this.routesById}matchRoutes=(t,e,o)=>{let r={},n=this.flatRoutes.find((e=>{const o=A(this.basepath,M(t),{to:e.fullPath,caseSensitive:e.options.caseSensitive??this.options.caseSensitive,fuzzy:!1});return!!o&&(r=o,!0)}))||this.routesById.__root__,s=[n];for(;n?.parentRoute;)n=n.parentRoute,n&&s.unshift(n);const a=s.map((t=>{let e;if(t.options.parseParams)try{const e=t.options.parseParams(r);Object.assign(r,e)}catch(t){if(e=new ot(t.message,{cause:t}),o?.throwOnError)throw e;return e}})),i=[];return s.forEach(((t,n)=>{const s=i[n-1],[c,l]=(()=>{const r=s?.search??e;try{const e="object"==typeof t.options.validateSearch?t.options.validateSearch.parse:t.options.validateSearch;let o=e?.(r)??{};return[{...r,...o},void 0]}catch(t){const e=new et(t.message,{cause:t});if(o?.throwOnError)throw e;return[r,e]}})(),u=$(t.path,r),h=$(t.id,r,!0)+(t.options.key?.({search:c,location:this.state.location})??""),d=nt(this.state,h),f=this.state.matches.find((t=>t.id===h))?"stay":"enter",p=!(!t.options.loader&&!St.some((e=>t.options[e]?.preload))),m=d?{...d,cause:f}:{id:h,routeId:t.id,params:r,pathname:O([this.basepath,u]),updatedAt:Date.now(),search:{},searchError:void 0,status:p?"pending":"success",isFetching:!1,invalid:!1,error:void 0,paramsError:a[n],loadPromise:Promise.resolve(),context:void 0,abortController:new AbortController,shouldReloadDeps:void 0,fetchedAt:0,cause:f};m.search=E(m.search,c),m.searchError=l,i.push(m)})),i};cancelMatch=t=>{nt(this.state,t)?.abortController?.abort()};cancelMatches=()=>{this.state.matches.forEach((t=>{this.cancelMatch(t.id)}))};buildLocation=t=>{const e=(t={},e)=>{const o=this.latestLocation,r=t.from??o.pathname;let n=this.resolvePathWithBase(r,`${t.to??""}`);const s=this.matchRoutes(r,o.search),a=e?.filter((t=>s?.find((e=>e.routeId===t.routeId)))),i={...b(s)?.params};let c=!0===(t.params??!0)?i:R(t.params,i);c&&e?.map((t=>this.looseRoutesById[t.routeId].options.stringifyParams)).filter(Boolean).forEach((t=>{c={...c,...t(c)}})),n=$(n,c??{});const l=a?.map((t=>this.looseRoutesById[t.routeId].options.preSearchFilters??[])).flat().filter(Boolean)??[],u=a?.map((t=>this.looseRoutesById[t.routeId].options.postSearchFilters??[])).flat().filter(Boolean)??[],h=l?.length?l?.reduce(((t,e)=>e(t)),o.search):o.search,d=!0===t.search?h:t.search?R(t.search,h)??{}:l?.length?h:{},f=u?.length?u.reduce(((t,e)=>e(t)),d):d,p=E(o.search,f),m=this.options.stringifySearch(p),y=!0===t.hash?o.hash:t.hash?R(t.hash,o.hash):o.hash,g=y?`#${y}`:"";let v=!0===t.state?o.state:t.state?R(t.state,o.state):o.state;return v=E(o.state,v),{pathname:n,search:p,searchStr:m,state:v,hash:y,href:this.history.createHref(`${n}${m}${g}`),unmaskOnReload:t.unmaskOnReload}},o=(t={},o)=>{let r=e(t),n=o?e(o):void 0;if(!n){let t={},s=this.options.routeMasks?.find((e=>{const o=A(this.basepath,r.pathname,{to:e.from,caseSensitive:!1,fuzzy:!1});return!!o&&(t=o,!0)}));s&&(s={...s,from:$(s.from,t)},n=e(o=s))}const s=this.matchRoutes(r.pathname,r.search),a=n?this.matchRoutes(n.pathname,n.search):void 0,i=n?e(o,a):void 0,c=e(t,s);return i&&(c.maskedLocation=i),c};return t.mask?o(t,{...L(t,["from"]),...t.mask}):o(t)};commitLocation=async({startTransition:t,...e})=>{this.navigateTimeout&&clearTimeout(this.navigateTimeout);if(!(this.latestLocation.href===e.href)||!e.replace){let{maskedLocation:o,...r}=e;o&&(r={...o,state:{...o.state,__tempKey:void 0,__tempLocation:{...r,search:r.searchStr,state:{...r.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(r.unmaskOnReload??this.options.unmaskOnReload)&&(r.state.__tempKey=this.tempLocationKey));const n=()=>{this.history[e.replace?"replace":"push"](r.href,r.state)};t??1?this.startReactTransition(n):n()}return this.resetNextScroll=e.resetScroll??!0,this.latestLoadPromise};buildAndCommitLocation=({replace:t,resetScroll:e,startTransition:o,...r}={})=>{const n=this.buildLocation(r);return this.commitLocation({...n,startTransition:o,replace:t,resetScroll:e})};navigate=({from:t,to:e="",...o})=>{const r=String(e),n=void 0===t?t:String(t);let s;try{new URL(`${r}`),s=!0}catch(t){}return m(!s),this.buildAndCommitLocation({...o,from:n,to:r})};loadMatches=async({checkLatest:t,matches:e,preload:o,invalidate:r})=>{let n,s;try{for(let[t,r]of e.entries()){const n=e[t-1],a=this.looseRoutesById[r.routeId],i=(o,n)=>{if(o.routerCode=n,s=s??t,mt(o))throw o;try{a.options.onError?.(o)}catch(t){if(o=t,mt(t))throw t}e[t]=r={...r,error:o,status:"error",updatedAt:Date.now()}};try{r.paramsError&&i(r.paramsError,"PARSE_PARAMS"),r.searchError&&i(r.searchError,"VALIDATE_SEARCH");const s=n?.context??this.options.context??{},c=await(a.options.beforeLoad?.({search:r.search,abortController:r.abortController,params:r.params,preload:!!o,context:s,location:this.state.location,navigate:t=>this.navigate({...t,from:r.pathname}),buildLocation:this.buildLocation,cause:r.cause}))??{},l={...s,...c};e[t]=r={...r,context:E(r.context,l)}}catch(t){i(t,"BEFORE_LOAD");break}}}catch(t){if(mt(t))return o||this.navigate(t),e;throw t}const a=e.slice(0,s),i=[];return a.forEach(((s,a)=>{i.push((async()=>{const c=i[a-1],l=this.looseRoutesById[s.routeId],u=t=>!!mt(t)&&(o||this.navigate(t),!0);let h;if(e[a]=s={...s,fetchedAt:Date.now(),invalid:!1},s.isFetching)h=nt(this.state,s.id)?.loadPromise;else{const t={params:s.params,search:s.search,preload:!!o,parentMatchPromise:c,abortController:s.abortController,context:s.context,location:this.state.location,navigate:t=>this.navigate({...t,from:s.pathname}),cause:s.cause};let n=!0,i="function"==typeof l.options.shouldReload?l.options.shouldReload?.(t):!!(l.options.shouldReload??1);if("enter"===s.cause||r?s.shouldReloadDeps=i:"stay"===s.cause&&("object"==typeof i?(n=!C(i,s.shouldReloadDeps),s.shouldReloadDeps=i):n=!!i),n){e[a]=s={...s,isFetching:!0};const o=Promise.all(St.map((async t=>{const e=l.options[t];e?.preload&&await e.preload()}))),r=l.options.loader?.(t);h=Promise.all([o,r]).then((t=>t[1]))}else h=Promise.resolve(s.loaderData)}e[a]=s={...s,loadPromise:h},o||this.setState((t=>({...t,matches:t.matches.map((t=>t.id===s.id?s:t))})));try{const o=await h;if(n=t())return await n;e[a]=s={...s,error:void 0,status:"success",isFetching:!1,updatedAt:Date.now(),loaderData:o,loadPromise:void 0}}catch(o){if(n=t())return await n;if(u(o))return;try{l.options.onError?.(o)}catch(t){if(o=t,u(t))return}e[a]=s={...s,error:o,status:"error",isFetching:!1,updatedAt:Date.now()}}o||this.setState((t=>({...t,matches:t.matches.map((t=>t.id===s.id?s:t))})))})())})),await Promise.all(i),e};invalidate=()=>this.load({invalidate:!0});load=async t=>{const e=new Promise((async(o,r)=>{const n=this.latestLocation,s=this.state.resolvedLocation,a=s.href!==n.href;let i;this.cancelMatches(),this.emit({type:"onBeforeLoad",fromLocation:s,toLocation:n,pathChanged:a});let c=this.matchRoutes(n.pathname,n.search,{debug:!0});this.pendingMatches=c;const l=this.state.matches;this.setState((t=>({...t,status:"pending",location:n,matches:c})));try{try{await this.loadMatches({matches:c,checkLatest:()=>this.checkLatest(e),invalidate:t?.invalidate})}catch(t){}if(i=this.checkLatest(e))return i;const r=l.filter((t=>!this.pendingMatches.includes(t))),u=this.pendingMatches.filter((t=>!l.includes(t)));[[r,"onLeave"],[u,"onEnter"],[l.filter((t=>this.pendingMatches.includes(t))),"onTransition"]].forEach((([t,e])=>{t.forEach((t=>{this.looseRoutesById[t.routeId].options[e]?.(t)}))})),this.emit({type:"onLoad",fromLocation:s,toLocation:n,pathChanged:a}),o()}catch(t){if(i=this.checkLatest(e))return i;r(t)}}));return this.latestLoadPromise=e,this.latestLoadPromise};preloadRoute=async(t=this.state.location)=>{let e=this.buildLocation(t),o=this.matchRoutes(e.pathname,e.search,{throwOnError:!0});return await this.loadMatches({matches:o,preload:!0,checkLatest:()=>{}}),[b(o),o]};buildLink=t=>{const{to:e,preload:o,preloadDelay:r,activeOptions:n,disabled:s,target:a,replace:i,resetScroll:c,startTransition:l}=t;try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const u=t,h=this.buildLocation(u),d=o??this.options.defaultPreload,f=r??this.options.defaultPreloadDelay??0,p=this.latestLocation.pathname.split("/"),m=h.pathname.split("/").every(((t,e)=>t===p[e])),y=n?.exact?this.latestLocation.pathname===h.pathname:m,g=!n?.includeHash||this.latestLocation.hash===h.hash,v=!(n?.includeSearch??1)||C(this.latestLocation.search,h.search,!0);return{type:"internal",next:h,handleFocus:t=>{d&&this.preloadRoute(u).catch((t=>{console.warn(t),console.warn(bt)}))},handleClick:t=>{s||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||a&&"_self"!==a||0!==t.button||(t.preventDefault(),this.commitLocation({...h,replace:i,resetScroll:c,startTransition:l}))},handleEnter:t=>{const e=t.target||{};if(d){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(u).catch((t=>{console.warn(t),console.warn(bt)}))}),f)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(u).catch((t=>{console.warn(t),console.warn(bt)}))},isActive:y&&g&&v,disabled:s}};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePathWithBase(t.from||"",t.to):void 0};const o=this.buildLocation(t);if(e?.pending&&"pending"!==this.state.status)return!1;const r=e?.pending?this.latestLocation:this.state.resolvedLocation;if(!r)return!1;const n=A(this.basepath,r.pathname,{...e,to:o.pathname});return!!n&&(n&&(e?.includeSearch??1)?!!C(r.search,o.search,!0)&&n:n)};injectHtml=async t=>{this.injectedHtml.push(t)};dehydrateData=(t,e)=>{if("undefined"==typeof document){const o="string"==typeof t?t:JSON.stringify(t);return this.injectHtml((async()=>{const t=`__TSR_DEHYDRATED__${o}`,r="function"==typeof e?await e():e;return`<script id='${t}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${k(o)}"] = ${JSON.stringify(r)}\n ;(() => {\n var el = document.getElementById('${t}')\n el.parentElement.removeChild(el)\n })()\n <\/script>`})),()=>this.hydrateData(t)}return()=>{}};hydrateData=t=>{if("undefined"!=typeof document){const e="string"==typeof t?t:JSON.stringify(t);return window[`__TSR_DEHYDRATED__${e}`]}}},t.RouterProvider=function({router:t,...e}){t.updateOptions({...t.options,...e,context:{...t.options.context,...e?.context}});const[o,n]=r.useState((()=>t.state)),[s,a]=r.useTransition(),i=r.useMemo((()=>({...o,status:s?"pending":"idle",location:s?t.latestLocation:o.location,pendingMatches:t.pendingMatches})),[o,s]);return t.setState=n,t.state=i,t.startReactTransition=a,r.useLayoutEffect((()=>{const e=t.history.subscribe((()=>{t.latestLocation=t.parseLocation(t.latestLocation),i.location!==t.latestLocation&&a((()=>{try{t.load()}catch(t){console.error(t)}}))})),o=t.buildLocation({search:!0,params:!0,hash:!0,state:!0});return i.location.href!==o.href&&t.commitLocation({...o,replace:!0}),()=>{e()}}),[t.history]),r.useLayoutEffect((()=>{s||i.resolvedLocation===i.location||(t.emit({type:"onResolved",fromLocation:i.resolvedLocation,toLocation:i.location,pathChanged:i.location.href!==i.resolvedLocation?.href}),t.pendingMatches=[],n((t=>({...t,resolvedLocation:t.location}))))})),r.useLayoutEffect((()=>{a((()=>{try{t.load()}catch(t){console.error(t)}}))}),[]),r.createElement(tt.Provider,{value:t},r.createElement(U,null))},t.ScrollRestoration=function(t){return kt(t),null},t.SearchParamError=et,t.cleanPath=T,t.componentTypes=St,t.createBrowserHistory=h,t.createHashHistory=function(){return h({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=function(t={initialEntries:["/"]}){const e=t.initialEntries;let o=t.initialIndex??e.length-1,r={key:f()};return l({getLocation:()=>d(e[o],r),pushState:(t,n)=>{r=n,e.push(t),o++},replaceState:(t,n)=>{r=n,e[o]=t},back:()=>{o--},forward:()=>{o=Math.min(o+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})},t.createRouteMask=function(t){return t},t.decode=pt,t.deepEqual=C,t.defaultParseSearch=yt,t.defaultStringifySearch=gt,t.defer=function(t){const e=t;if(!e.__deferredState){e.__deferredState={uid:Math.random().toString(36).slice(2),status:"pending"};const t=e.__deferredState;e.then((e=>{t.status="success",t.data=e})).catch((e=>{t.status="error",t.error=e}))}return e},t.encode=dt,t.escapeJSON=k,t.functionalUpdate=R,t.getInitialRouterState=rt,t.getRouteMatch=nt,t.interpolatePath=$,t.invariant=m,t.isDehydratedDeferred=it,t.isPlainObject=P,t.isRedirect=mt,t.isServer=S,t.joinPaths=O,t.last=b,t.lazyFn=function(t,e){return async(...o)=>(await t())[e||"default"](...o)},t.lazyRouteComponent=function(t,e){let o;const n=()=>(o||(o=t()),o),s=r.lazy((async()=>({default:(await n())[e??"default"]})));return s.preload=n,s},t.matchByPath=N,t.matchPathname=A,t.matchesContext=Q,t.parsePathname=B,t.parseSearchWith=vt,t.pick=L,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=E,t.resolvePath=j,t.rootRouteId=F,t.rootRouteWithContext=function(){return t=>new z(t)},t.routerContext=tt,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 o=Object.keys(t);if(o.length!==Object.keys(e).length)return!1;for(let r=0;r<o.length;r++)if(!Object.prototype.hasOwnProperty.call(e,o[r])||!Object.is(t[o[r]],e[o[r]]))return!1;return!0},t.stringifySearchWith=wt,t.trimPath=D,t.trimPathLeft=I,t.trimPathRight=M,t.typedNavigate=function(t){return t},t.useAwaited=ct,t.useBlocker=Ot,t.useLayoutEffect=x,t.useLinkProps=ut,t.useLoaderData=Z,t.useMatch=G,t.useMatchRoute=V,t.useMatches=function(t){const e=r.useContext(Q);return st({select:o=>{const r=o.matches.slice(o.matches.findIndex((t=>t.id===e[0]?.id)));return t?.select?t.select(r):r}})},t.useNavigate=function(t){const{navigate:e}=at(),o=G({strict:!1});return r.useCallback((r=>e({from:r?.to?o.pathname:void 0,...t,...r})),[])},t.useParams=H,t.useRouteContext=function(t){return G({...t,select:e=>t?.select?t.select(e.context):e.context})},t.useRouter=at,t.useRouterState=st,t.useScrollRestoration=kt,t.useSearch=K,t.useStableCallback=function(t){const e=r.useRef(t);return e.current=t,r.useRef(((...t)=>e.current(...t))).current},t.warning=y}));
|
|
21
|
+
*/const n="pushstate",s="popstate",a="beforeunload",i=t=>(t.preventDefault(),t.returnValue=""),c=()=>{removeEventListener(a,i,{capture:!0})};function l(t){let e=t.getLocation(),o=new Set,r=[],n=[];const s=()=>{e=t.getLocation(),o.forEach((t=>t()))},l=()=>{if(r.length)r[0]?.(l,(()=>{r=[],c()}));else for(;n.length;)n.shift()?.()},h=t=>{n.push(t),l()};return{get location(){return e},subscribe:t=>(o.add(t),()=>{o.delete(t)}),push:(e,o)=>{o=u(o),h((()=>{t.pushState(e,o,s)}))},replace:(e,o)=>{o=u(o),h((()=>{t.replaceState(e,o,s)}))},go:e=>{h((()=>{t.go(e)}))},back:()=>{h((()=>{t.back()}))},forward:()=>{h((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(r.push(t),1===r.length&&addEventListener(a,i,{capture:!0}),()=>{r=r.filter((e=>e!==t)),r.length||c()}),flush:()=>t.flush?.(),destroy:()=>t.destroy?.(),notify:s}}function u(t){return t||(t={}),{...t,key:f()}}function h(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),o=t?.createHref??(t=>t);let r=d(e(),window.history.state);let a,i,c=!0;const u=()=>{c=!1,(()=>{a&&(window.history[a.isPush?"pushState":"replaceState"](a.state,"",a.href),a=void 0,i=void 0)})(),c=!0},h=(t,e,n,s)=>{const c=o(e);r=d(c,n),a={href:c,state:n,isPush:a?.isPush||"push"===t},s(),i||(i=Promise.resolve().then((()=>u())))},f=()=>{r=d(e(),window.history.state),y.notify()};var p=window.history.pushState,m=window.history.replaceState;const y=l({getLocation:()=>r,pushState:(t,e,o)=>h("push",t,e,o),replaceState:(t,e,o)=>h("replace",t,e,o),back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>o(t),flush:u,destroy:()=>{window.history.pushState=p,window.history.replaceState=m,window.removeEventListener(n,f),window.removeEventListener(s,f)}});return window.addEventListener(n,f),window.addEventListener(s,f),window.history.pushState=function(){let t=p.apply(window.history,arguments);return c&&y.notify(),t},window.history.replaceState=function(){let t=m.apply(window.history,arguments);return c&&y.notify(),t},y}function d(t,e){let o=t.indexOf("#"),r=t.indexOf("?");return{href:t,pathname:t.substring(0,o>0?r>0?Math.min(o,r):o:r>0?r:t.length),hash:o>-1?t.substring(o):"",search:r>-1?t.slice(r,-1===o?void 0:o):"",state:e||{}}}function f(){return(Math.random()+1).toString(36).substring(7)}var p="Invariant failed";function m(t,e){if(!t)throw new Error(p)}function y(t,e){}function g(t){const e=t.errorComponent??w;return r.createElement(v,{resetKey:t.resetKey,onCatch:t.onCatch,children:({error:o})=>o?r.createElement(e,{error:o}):t.children})}class v extends r.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t,e){e.error&&t.resetKey!==this.props.resetKey&&this.setState({error:null})}componentDidCatch(t){console.error(t),this.props.onCatch?.(t)}render(){return this.props.children(this.state)}}function w({error:t}){const[e,o]=r.useState(!1);return r.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},r.createElement("div",{style:{display:"flex",alignItems:"center",gap:".5rem"}},r.createElement("strong",{style:{fontSize:"1rem"}},"Something went wrong!"),r.createElement("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>o((t=>!t))},e?"Hide Error":"Show Error")),r.createElement("div",{style:{height:".25rem"}}),e?r.createElement("div",null,r.createElement("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"}},t.message?r.createElement("code",null,t.message):null)):null)}const S="undefined"==typeof document;function b(t){return t[t.length-1]}function R(t,e){return"function"==typeof t?t(e):t}function L(t,e){return e.reduce(((e,o)=>(e[o]=t[o],e)),{})}function E(t,e){if(t===e)return t;const o=e,r=Array.isArray(t)&&Array.isArray(o);if(r||P(t)&&P(o)){const e=r?t.length:Object.keys(t).length,n=r?o:Object.keys(o),s=n.length,a=r?[]:{};let i=0;for(let e=0;e<s;e++){const s=r?e:n[e];a[s]=E(t[s],o[s]),a[s]===t[s]&&i++}return e===s&&i===e?t:a}return o}function P(t){if(!_(t))return!1;const e=t.constructor;if(void 0===e)return!0;const o=e.prototype;return!!_(o)&&!!o.hasOwnProperty("isPrototypeOf")}function _(t){return"[object Object]"===Object.prototype.toString.call(t)}function C(t,e,o=!1){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(P(t)&&P(e)){const r=Object.keys(t),n=Object.keys(e);return!(!o&&r.length!==n.length)&&!n.some((r=>!(r in t)||!C(t[r],e[r],o)))}return!(!Array.isArray(t)||!Array.isArray(e))&&!t.some(((t,r)=>!C(t,e[r],o)))}const x="undefined"!=typeof window?r.useLayoutEffect:r.useEffect;function k(t){return t.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"')}function O(t){return T(t.filter(Boolean).join("/"))}function T(t){return t.replace(/\/{2,}/g,"/")}function I(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function M(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function D(t){return M(I(t))}function j(t,e,o){e=e.replace(new RegExp(`^${t}`),"/"),o=o.replace(new RegExp(`^${t}`),"/");let r=B(e);const n=B(o);n.forEach(((t,e)=>{if("/"===t.value)e?e===n.length-1&&r.push(t):r=[t];else if(".."===t.value)r.length>1&&"/"===b(r)?.value&&r.pop(),r.pop();else{if("."===t.value)return;r.push(t)}}));return T(O([t,...r.map((t=>t.value))]))}function B(t){if(!t)return[];const e=[];if("/"===(t=T(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const o=t.split("/").filter(Boolean);return e.push(...o.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 $(t,e,o=!1){return O(B(t).map((t=>{if("wildcard"===t.type){const r=e[t.value];return o?`${t.value}${r??""}`:r}return"param"===t.type?e[t.value.substring(1)]??"":t.value})))}function A(t,e,o){const r=N(t,e,o);if(!o.to||r)return r??{}}function N(t,e,o){e="/"!=t?e.substring(t.length):e;const r=`${o.to??"$"}`,n=B(e),s=B(r);e.startsWith("/")||n.unshift({type:"pathname",value:"/"}),r.startsWith("/")||s.unshift({type:"pathname",value:"/"});const a={};return(()=>{for(let t=0;t<Math.max(n.length,s.length);t++){const e=n[t],r=s[t],i=t>=n.length-1,c=t>=s.length-1;if(r){if("wildcard"===r.type)return!!e?.value&&(a["*"]=O(n.slice(t).map((t=>t.value))),!0);if("pathname"===r.type){if("/"===r.value&&!e?.value)return!0;if(e)if(o.caseSensitive){if(r.value!==e.value)return!1}else if(r.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===r.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(a[r.value.substring(1)]=e.value)}}if(!i&&c)return!!o.fuzzy}return!0})()?a:void 0}function H(t){return st({select:e=>{const o=b(e.matches)?.params;return t?.select?t.select(o):o}})}function K(t){return G({...t,select:e=>t?.select?t.select(e.search):e.search})}const F="__root__";class W{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute,W.__onInit(this),this.$$typeof=Symbol.for("react.memo")}init=t=>{this.originalIndex=t.originalIndex;const e=this.options,o=!e?.path&&!e?.id;this.parentRoute=this.options?.getParentRoute?.(),o?this.path=F:m(this.parentRoute);let r=o?F:e.path;r&&"/"!==r&&(r=D(r));const n=e?.id||r;let s=o?F:O([this.parentRoute.id===F?"":this.parentRoute.id,n]);r===F&&(r="/"),s!==F&&(s=O(["/",s]));const a=s===F?"/":O([this.parentRoute.fullPath,r]);this.path=r,this.id=s,this.fullPath=a,this.to=a};addChildren=t=>(this.children=t,this);update=t=>(Object.assign(this.options,t),this);static __onInit=t=>{};useMatch=t=>G({...t,from:this.id});useRouteContext=t=>G({...t,from:this.id,select:e=>t?.select?t.select(e.context):e.context});useSearch=t=>K({...t,from:this.id});useParams=t=>H({...t,from:this.id});useLoaderData=t=>Z({...t,from:this.id})}class z extends W{constructor(t){super(t)}}function U(){const{routesById:t,state:e}=at(),{matches:o}=e,n=st().location.state.key,s=t[F],a=r.useCallback((t=>r.createElement(w,{...t,useMatch:s.useMatch,useRouteContext:s.useRouteContext,useSearch:s.useSearch,useParams:s.useParams})),[s]);return r.createElement(Q.Provider,{value:o},r.createElement(g,{resetKey:n,errorComponent:a,onCatch:()=>{}},o.length?r.createElement(Y,{matches:o}):null))}function J(t){return r.createElement(r.Fragment,null,t.children)}function Y({matches:t}){const{options:e,routesById:o}=at(),n=t[0],s=n?.routeId,a=o[s],i=st().location.state?.key,c=a.options.pendingComponent??e.defaultPendingComponent,l=a.options.errorComponent??e.defaultErrorComponent??w,u=a.options.wrapInSuspense??c?r.Suspense:J,h=l?r.useCallback((t=>r.createElement(l,{...t,useMatch:a.useMatch,useRouteContext:a.useRouteContext,useSearch:a.useSearch,useParams:a.useParams})),[a]):void 0,d=h?g:J;return r.createElement(Q.Provider,{value:t},r.createElement(u,{fallback:r.createElement(c,{useMatch:a.useMatch,useRouteContext:a.useRouteContext,useSearch:a.useSearch,useParams:a.useParams})},r.createElement(d,{resetKey:i,errorComponent:h,onCatch:()=>{n.id}},r.createElement(X,{match:n}))))}function X({match:t}){const{options:e,routesById:o}=at(),n=o[t.routeId];if("error"===t.status)throw t.error;if("pending"===t.status)throw t.loadPromise;if("success"===t.status){let t=n.options.component??e.defaultComponent;return t?r.createElement(t,{useMatch:n.useMatch,useRouteContext:n.useRouteContext,useSearch:n.useSearch,useParams:n.useParams,useLoaderData:n.useLoaderData}):r.createElement(q,null)}m(!1)}function q(){const t=r.useContext(Q).slice(1);return t[0]?r.createElement(Y,{matches:t}):null}function V(){const{matchRoute:t}=at();return r.useCallback((e=>{const{pending:o,caseSensitive:r,...n}=e;return t(n,{pending:o,caseSensitive:r})}),[])}function G(t){const e=r.useContext(Q)[0],o=e?.routeId,n=st({select:o=>(t?.from?o.matches.find((e=>e.routeId===t?.from)):o.matches.find((t=>t.id===e.id))).routeId});(t?.strict??1)&&m(o==n);return st({select:o=>{const r=t?.from?o.matches.find((e=>e.routeId===t?.from)):o.matches.find((t=>t.id===e.id));return m(r,t?.from&&t.from),t?.select?t.select(r):r}})}const Q=r.createContext(null);function Z(t){const e=G({...t,select:void 0});return"function"==typeof t.select?t.select(e?.loaderData):e?.loaderData}const tt=r.createContext(null);"undefined"!=typeof document&&(window.__TSR_ROUTER_CONTEXT__=tt);class et extends Error{}class ot extends Error{}function rt(t){return{status:"idle",resolvedLocation:t,location:t,matches:[],pendingMatches:[],lastUpdated:Date.now()}}function nt(t,e){return[...t.pendingMatches,...t.matches].find((t=>t.id===e))}function st(t){const{state:e}=at();return t?.select?t.select(e):e}function at(){const t=window.__TSR_ROUTER_CONTEXT__||tt;return r.useContext(t)}function it(t){return"object"==typeof t&&null!==t&&!(t instanceof Promise)&&!t.then&&"__deferredState"in t}function ct({promise:t}){const e=at();let o=t.__deferredState;const r=`__TSR__DEFERRED__${o.uid}`;if(it(t)&&(o=e.hydrateData(r),(t=Promise.resolve(o.data)).__deferredState=o),"pending"===o.status)throw t;if("error"===o.status)throw o.error;return e.dehydrateData(r,o),[o.data]}function lt(){return lt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(t[r]=o[r])}return t},lt.apply(this,arguments)}function ut(t){const{buildLink:e}=at(),o=G({strict:!1}),{type:r,children:n,target:s,activeProps:a=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:l,hash:u,search:h,params:d,to:f,state:p,mask:m,preload:y,preloadDelay:g,replace:v,startTransition:w,resetScroll:S,style:b,className:L,onClick:E,onFocus:P,onMouseEnter:_,onMouseLeave:C,onTouchStart:x,...k}=t,O=e({from:t.to?o.pathname:void 0,...t});if("external"===O.type){const{href:t}=O;return{href:t}}const{handleClick:T,handleFocus:I,handleEnter:M,handleLeave:D,handleTouchStart:j,isActive:B,next:$}=O,A=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},N=B?R(a,{})??{}:{},H=B?{}:R(i,{})??{};return{...N,...H,...k,href:l?void 0:$.maskedLocation?$.maskedLocation.href:$.href,onClick:A([E,T]),onFocus:A([P,I]),onMouseEnter:A([_,M]),onMouseLeave:A([C,D]),onTouchStart:A([x,j]),target:s,style:{...b,...N.style,...H.style},className:[L,N.className,H.className].filter(Boolean).join(" ")||void 0,...l?{role:"link","aria-disabled":!0}:void 0,"data-status":B?"active":void 0}}const ht=r.forwardRef(((t,e)=>{const o=ut(t);return r.createElement("a",lt({ref:e},o,{children:"function"==typeof t.children?t.children({isActive:"active"===o["data-status"]}):t.children}))}));function dt(t,e){var o,r,n,s="";for(o in t)if(void 0!==(n=t[o]))if(Array.isArray(n))for(r=0;r<n.length;r++)s&&(s+="&"),s+=encodeURIComponent(o)+"="+encodeURIComponent(n[r]);else s&&(s+="&"),s+=encodeURIComponent(o)+"="+encodeURIComponent(n);return(e||"")+s}function ft(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0&&+e+""===e?+e:e))}function pt(t){for(var e,o,r={},n=t.split("&");e=n.shift();)void 0!==r[o=(e=e.split("=")).shift()]?r[o]=[].concat(r[o],ft(e.shift())):r[o]=ft(e.shift());return r}function mt(t){return!!t?.isRedirect}const yt=vt(JSON.parse),gt=wt(JSON.stringify,JSON.parse);function vt(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let o=pt(e);for(let e in o){const r=o[e];if("string"==typeof r)try{o[e]=t(r)}catch(t){}}return o}}function wt(t,e){return o=>{(o={...o})&&Object.keys(o).forEach((r=>{const n=o[r];void 0===n||void 0===n?delete o[r]:o[r]=function(o){if("object"==typeof o&&null!==o)try{return t(o)}catch(t){}else if("string"==typeof o&&"function"==typeof e)try{return e(o),t(o)}catch(t){}return o}(n)}));const r=dt(o).toString();return r?`?${r}`:""}}const St=["component","errorComponent","pendingComponent"],bt="Error preloading route! ☝️";const Rt="undefined"!=typeof window?r.useLayoutEffect:r.useEffect,Lt="window",Et="___";let Pt,_t=new WeakSet;const Ct="undefined"!=typeof window&&window.sessionStorage,xt=t=>t.state.key;function kt(t){const e=at();Rt((()=>{const o=t?.getKey||xt;Ct&&(Pt||(Pt=(()=>{const t="tsr-scroll-restoration-v2";return{state:JSON.parse(window.sessionStorage.getItem(t)||"null")||{cached:{},next:{}},set:e=>{Pt.state=R(e,Pt.state),window.sessionStorage.setItem(t,JSON.stringify(Pt.state))}}})()));const{history:r}=window;r.scrollRestoration&&(r.scrollRestoration="manual");const n=t=>{if(_t.has(t.target))return;_t.add(t.target);const e=t.target===document||t.target===window?Lt:s(t.target);Pt.state.next[e]||Pt.set((t=>({...t,next:{...t.next,[e]:{scrollX:NaN,scrollY:NaN}}})))},s=t=>{let e,o=[];for(;e=t.parentNode;)o.unshift(`${t.tagName}:nth-child(${[].indexOf.call(e.children,t)+1})`),t=e;return`${o.join(" > ")}`.toLowerCase()};"undefined"!=typeof document&&document.addEventListener("scroll",n,!0);const a=e.subscribe("onBeforeLoad",(t=>{if(t.pathChanged){const e=o(t.fromLocation);for(const t in Pt.state.next){const o=Pt.state.next[t];if(t===Lt)o.scrollX=window.scrollX||0,o.scrollY=window.scrollY||0;else if(t){const e=document.querySelector(t);o.scrollX=e?.scrollLeft||0,o.scrollY=e?.scrollTop||0}Pt.set((r=>{const n={...r.next};return delete n[t],{...r,next:n,cached:{...r.cached,[[e,t].join(Et)]:o}}}))}}})),i=e.subscribe("onResolved",(o=>{if(o.pathChanged){if(!e.resetNextScroll)return;e.resetNextScroll=!0;const r=(t?.getKey||xt)(o.toLocation);let n=!1;for(const t in Pt.state.cached){const e=Pt.state.cached[t],[o,s]=t.split(Et);if(o===r)if(s===Lt)n=!0,window.scrollTo(e.scrollX,e.scrollY);else if(s){const t=document.querySelector(s);t&&(t.scrollLeft=e.scrollX,t.scrollTop=e.scrollY)}}n||window.scrollTo(0,0),Pt.set((t=>({...t,next:{}}))),_t=new WeakSet}}));return()=>{document.removeEventListener("scroll",n),a(),i()}}),[])}function Ot(t,e=!0){const{history:o}=at();r.useEffect((()=>{if(!e)return;let r=o.block(((e,o)=>{window.confirm(t)&&(r(),e())}));return r}))}t.Await=function(t){const e=ct(t);return t.children(...e)},t.Block=function({message:t,condition:e,children:o}){return Ot(t,e),o??null},t.CatchBoundary=g,t.CatchBoundaryImpl=v,t.ErrorComponent=w,t.FileRoute=class{constructor(t){this.path=t}createRoute=t=>{const e=new W(t);return e.isRoot=!1,e}},t.Link=ht,t.Match=Y,t.MatchRoute=function(t){const e=V()(t);return"function"==typeof t.children?t.children(e):e?t.children:null},t.Matches=U,t.Navigate=function(t){const{navigate:e}=at(),o=G({strict:!1});return x((()=>{e({from:t.to?o.pathname:void 0,...t})}),[]),null},t.Outlet=q,t.PathParamError=ot,t.RootRoute=z,t.Route=W,t.Router=class{tempLocationKey=`${Math.round(1e7*Math.random())}`;resetNextScroll=!0;navigateTimeout=null;latestLoadPromise=Promise.resolve();subscribers=new Set;pendingMatches=[];injectedHtml=[];constructor(t){this.updateOptions({defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??gt,parseSearch:t?.parseSearch??yt})}startReactTransition=()=>{};setState=()=>{};updateOptions=t=>{this.options,this.options={...this.options,...t},this.basepath=`/${D(t.basepath??"")??""}`,(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history??h(),this.latestLocation=this.parseLocation()),this.options.routeTree!==this.routeTree&&(this.routeTree=this.options.routeTree,this.buildRouteTree()),this.state||(this.state=rt(this.latestLocation))};buildRouteTree=()=>{this.routesById={},this.routesByPath={};const t=e=>{e.forEach(((e,o)=>{e.init({originalIndex:o});if(m(!this.routesById[e.id],String(e.id)),this.routesById[e.id]=e,!e.isRoot&&e.path){const t=M(e.fullPath);this.routesByPath[t]&&!e.fullPath.endsWith("/")||(this.routesByPath[t]=e)}const r=e.children;r?.length&&t(r)}))};t([this.routeTree]),this.flatRoutes=Object.values(this.routesByPath).map(((t,e)=>{const o=D(t.fullPath),r=B(o);for(;r.length>1&&"/"===r[0]?.value;)r.shift();const n=r.map((t=>"param"===t.type?.5:"wildcard"===t.type?.25:1));return{child:t,trimmed:o,parsed:r,index:e,score:n}})).sort(((t,e)=>{let o="/"===t.trimmed?1:"/"===e.trimmed?-1:0;if(0!==o)return o;const r=Math.min(t.score.length,e.score.length);if(t.score.length!==e.score.length)return e.score.length-t.score.length;for(let o=0;o<r;o++)if(t.score[o]!==e.score[o])return e.score[o]-t.score[o];for(let o=0;o<r;o++)if(t.parsed[o].value!==e.parsed[o].value)return t.parsed[o].value>e.parsed[o].value?1:-1;return t.trimmed!==e.trimmed?t.trimmed>e.trimmed?1:-1:t.index-e.index})).map(((t,e)=>(t.child.rank=e,t.child)))};subscribe=(t,e)=>{const o={eventType:t,fn:e};return this.subscribers.add(o),()=>{this.subscribers.delete(o)}};emit=t=>{this.subscribers.forEach((e=>{e.eventType===t.type&&e.fn(t)}))};checkLatest=t=>this.latestLoadPromise!==t?this.latestLoadPromise:void 0;parseLocation=t=>{const e=({pathname:e,search:o,hash:r,state:n})=>{const s=this.options.parseSearch(o);return{pathname:e,searchStr:o,search:E(t?.search,s),hash:r.split("#").reverse()[0]??"",href:`${e}${o}${r}`,state:E(t?.state,n)}},o=e(this.history.location);let{__tempLocation:r,__tempKey:n}=o.state;if(r&&(!n||n===this.tempLocationKey)){const t=e(r);return t.state.key=o.state.key,delete t.state.__tempLocation,{...t,maskedLocation:o}}return o};resolvePathWithBase=(t,e)=>j(this.basepath,t,T(e));get looseRoutesById(){return this.routesById}matchRoutes=(t,e,o)=>{let r={},n=this.flatRoutes.find((e=>{const o=A(this.basepath,M(t),{to:e.fullPath,caseSensitive:e.options.caseSensitive??this.options.caseSensitive,fuzzy:!1});return!!o&&(r=o,!0)}))||this.routesById.__root__,s=[n];for(;n?.parentRoute;)n=n.parentRoute,n&&s.unshift(n);const a=s.map((t=>{let e;if(t.options.parseParams)try{const e=t.options.parseParams(r);Object.assign(r,e)}catch(t){if(e=new ot(t.message,{cause:t}),o?.throwOnError)throw e;return e}})),i=[];return s.forEach(((t,n)=>{const s=i[n-1],[c,l]=(()=>{const r=s?.search??e;try{const e="object"==typeof t.options.validateSearch?t.options.validateSearch.parse:t.options.validateSearch;let o=e?.(r)??{};return[{...r,...o},void 0]}catch(t){const e=new et(t.message,{cause:t});if(o?.throwOnError)throw e;return[r,e]}})(),u=$(t.path,r),h=$(t.id,r,!0)+(t.options.key?.({search:c,location:this.state.location})??""),d=nt(this.state,h),f=this.state.matches.find((t=>t.id===h))?"stay":"enter",p=!(!t.options.loader&&!St.some((e=>t.options[e]?.preload))),m=d?{...d,cause:f}:{id:h,routeId:t.id,params:r,pathname:O([this.basepath,u]),updatedAt:Date.now(),search:{},searchError:void 0,status:p?"pending":"success",isFetching:!1,invalid:!1,error:void 0,paramsError:a[n],loadPromise:Promise.resolve(),context:void 0,abortController:new AbortController,shouldReloadDeps:void 0,fetchedAt:0,cause:f};m.search=E(m.search,c),m.searchError=l,i.push(m)})),i};cancelMatch=t=>{nt(this.state,t)?.abortController?.abort()};cancelMatches=()=>{this.state.matches.forEach((t=>{this.cancelMatch(t.id)}))};buildLocation=t=>{const e=(t={},e)=>{const o=this.latestLocation,r=t.from??o.pathname;let n=this.resolvePathWithBase(r,`${t.to??""}`);const s=this.matchRoutes(r,o.search),a=e?.filter((t=>s?.find((e=>e.routeId===t.routeId)))),i={...b(s)?.params};let c=!0===(t.params??!0)?i:R(t.params,i);c&&e?.map((t=>this.looseRoutesById[t.routeId].options.stringifyParams)).filter(Boolean).forEach((t=>{c={...c,...t(c)}})),n=$(n,c??{});const l=a?.map((t=>this.looseRoutesById[t.routeId].options.preSearchFilters??[])).flat().filter(Boolean)??[],u=a?.map((t=>this.looseRoutesById[t.routeId].options.postSearchFilters??[])).flat().filter(Boolean)??[],h=l?.length?l?.reduce(((t,e)=>e(t)),o.search):o.search,d=!0===t.search?h:t.search?R(t.search,h)??{}:l?.length?h:{},f=u?.length?u.reduce(((t,e)=>e(t)),d):d,p=E(o.search,f),m=this.options.stringifySearch(p),y=!0===t.hash?o.hash:t.hash?R(t.hash,o.hash):o.hash,g=y?`#${y}`:"";let v=!0===t.state?o.state:t.state?R(t.state,o.state):o.state;return v=E(o.state,v),{pathname:n,search:p,searchStr:m,state:v,hash:y,href:this.history.createHref(`${n}${m}${g}`),unmaskOnReload:t.unmaskOnReload}},o=(t={},o)=>{let r=e(t),n=o?e(o):void 0;if(!n){let t={},s=this.options.routeMasks?.find((e=>{const o=A(this.basepath,r.pathname,{to:e.from,caseSensitive:!1,fuzzy:!1});return!!o&&(t=o,!0)}));s&&(s={...s,from:$(s.from,t)},n=e(o=s))}const s=this.matchRoutes(r.pathname,r.search),a=n?this.matchRoutes(n.pathname,n.search):void 0,i=n?e(o,a):void 0,c=e(t,s);return i&&(c.maskedLocation=i),c};return t.mask?o(t,{...L(t,["from"]),...t.mask}):o(t)};commitLocation=async({startTransition:t,...e})=>{this.navigateTimeout&&clearTimeout(this.navigateTimeout);if(!(this.latestLocation.href===e.href)||!e.replace){let{maskedLocation:o,...r}=e;o&&(r={...o,state:{...o.state,__tempKey:void 0,__tempLocation:{...r,search:r.searchStr,state:{...r.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(r.unmaskOnReload??this.options.unmaskOnReload)&&(r.state.__tempKey=this.tempLocationKey));const n=()=>{this.history[e.replace?"replace":"push"](r.href,r.state)};t??1?this.startReactTransition(n):n()}return this.resetNextScroll=e.resetScroll??!0,this.latestLoadPromise};buildAndCommitLocation=({replace:t,resetScroll:e,startTransition:o,...r}={})=>{const n=this.buildLocation(r);return this.commitLocation({...n,startTransition:o,replace:t,resetScroll:e})};navigate=({from:t,to:e="",...o})=>{const r=String(e),n=void 0===t?t:String(t);let s;try{new URL(`${r}`),s=!0}catch(t){}return m(!s),this.buildAndCommitLocation({...o,from:n,to:r})};loadMatches=async({checkLatest:t,matches:e,preload:o,invalidate:r})=>{let n,s;try{for(let[t,r]of e.entries()){const n=e[t-1],a=this.looseRoutesById[r.routeId],i=(o,n)=>{if(o.routerCode=n,s=s??t,mt(o))throw o;try{a.options.onError?.(o)}catch(t){if(o=t,mt(t))throw t}e[t]=r={...r,error:o,status:"error",updatedAt:Date.now()}};try{r.paramsError&&i(r.paramsError,"PARSE_PARAMS"),r.searchError&&i(r.searchError,"VALIDATE_SEARCH");const s=n?.context??this.options.context??{},c=await(a.options.beforeLoad?.({search:r.search,abortController:r.abortController,params:r.params,preload:!!o,context:s,location:this.state.location,navigate:t=>this.navigate({...t,from:r.pathname}),buildLocation:this.buildLocation,cause:r.cause}))??{},l={...s,...c};e[t]=r={...r,context:E(r.context,l)}}catch(t){i(t,"BEFORE_LOAD");break}}}catch(t){if(mt(t))return o||this.navigate(t),e;throw t}const a=e.slice(0,s),i=[];return a.forEach(((s,a)=>{i.push((async()=>{const c=i[a-1],l=this.looseRoutesById[s.routeId],u=t=>!!mt(t)&&(o||this.navigate(t),!0);let h;if(e[a]=s={...s,fetchedAt:Date.now(),invalid:!1},s.isFetching)h=nt(this.state,s.id)?.loadPromise;else{const t={params:s.params,search:s.search,preload:!!o,parentMatchPromise:c,abortController:s.abortController,context:s.context,location:this.state.location,navigate:t=>this.navigate({...t,from:s.pathname}),cause:s.cause};let n=!0,i="function"==typeof l.options.shouldReload?l.options.shouldReload?.(t):!!(l.options.shouldReload??1);if("enter"===s.cause||r?s.shouldReloadDeps=i:"stay"===s.cause&&("object"==typeof i?(n=!C(i,s.shouldReloadDeps),s.shouldReloadDeps=i):n=!!i),n){e[a]=s={...s,isFetching:!0};const o=Promise.all(St.map((async t=>{const e=l.options[t];e?.preload&&await e.preload()}))),r=l.options.loader?.(t);h=Promise.all([o,r]).then((t=>t[1]))}else h=Promise.resolve(s.loaderData)}e[a]=s={...s,loadPromise:h},o||this.setState((t=>({...t,matches:t.matches.map((t=>t.id===s.id?s:t))})));try{const o=await h;if(n=t())return await n;e[a]=s={...s,error:void 0,status:"success",isFetching:!1,updatedAt:Date.now(),loaderData:o,loadPromise:void 0}}catch(o){if(n=t())return await n;if(u(o))return;try{l.options.onError?.(o)}catch(t){if(o=t,u(t))return}e[a]=s={...s,error:o,status:"error",isFetching:!1,updatedAt:Date.now()}}o||this.setState((t=>({...t,matches:t.matches.map((t=>t.id===s.id?s:t))})))})())})),await Promise.all(i),e};invalidate=()=>this.load({invalidate:!0});load=async t=>{const e=new Promise((async(o,r)=>{const n=this.latestLocation,s=this.state.resolvedLocation,a=s.href!==n.href;let i;this.cancelMatches(),this.emit({type:"onBeforeLoad",fromLocation:s,toLocation:n,pathChanged:a});let c=this.matchRoutes(n.pathname,n.search,{debug:!0});this.pendingMatches=c;const l=this.state.matches;this.setState((t=>({...t,status:"pending",location:n,matches:c})));try{try{await this.loadMatches({matches:c,checkLatest:()=>this.checkLatest(e),invalidate:t?.invalidate})}catch(t){}if(i=this.checkLatest(e))return i;const r=l.filter((t=>!this.pendingMatches.includes(t))),u=this.pendingMatches.filter((t=>!l.includes(t)));[[r,"onLeave"],[u,"onEnter"],[l.filter((t=>this.pendingMatches.includes(t))),"onTransition"]].forEach((([t,e])=>{t.forEach((t=>{this.looseRoutesById[t.routeId].options[e]?.(t)}))})),this.emit({type:"onLoad",fromLocation:s,toLocation:n,pathChanged:a}),o()}catch(t){if(i=this.checkLatest(e))return i;r(t)}}));return this.latestLoadPromise=e,this.latestLoadPromise};preloadRoute=async(t=this.state.location)=>{let e=this.buildLocation(t),o=this.matchRoutes(e.pathname,e.search,{throwOnError:!0});return await this.loadMatches({matches:o,preload:!0,checkLatest:()=>{}}),[b(o),o]};buildLink=t=>{const{to:e,preload:o,preloadDelay:r,activeOptions:n,disabled:s,target:a,replace:i,resetScroll:c,startTransition:l}=t;try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const u=t,h=this.buildLocation(u),d=o??this.options.defaultPreload,f=r??this.options.defaultPreloadDelay??0,p=this.latestLocation.pathname.split("/"),m=h.pathname.split("/").every(((t,e)=>t===p[e])),y=n?.exact?this.latestLocation.pathname===h.pathname:m,g=!n?.includeHash||this.latestLocation.hash===h.hash,v=!(n?.includeSearch??1)||C(this.latestLocation.search,h.search,!0);return{type:"internal",next:h,handleFocus:t=>{d&&this.preloadRoute(u).catch((t=>{console.warn(t),console.warn(bt)}))},handleClick:t=>{s||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||a&&"_self"!==a||0!==t.button||(t.preventDefault(),this.commitLocation({...h,replace:i,resetScroll:c,startTransition:l}))},handleEnter:t=>{const e=t.target||{};if(d){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(u).catch((t=>{console.warn(t),console.warn(bt)}))}),f)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(u).catch((t=>{console.warn(t),console.warn(bt)}))},isActive:y&&g&&v,disabled:s}};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePathWithBase(t.from||"",t.to):void 0};const o=this.buildLocation(t);if(e?.pending&&"pending"!==this.state.status)return!1;const r=e?.pending?this.latestLocation:this.state.resolvedLocation;if(!r)return!1;const n=A(this.basepath,r.pathname,{...e,to:o.pathname});return!!n&&(n&&(e?.includeSearch??1)?!!C(r.search,o.search,!0)&&n:n)};injectHtml=async t=>{this.injectedHtml.push(t)};dehydrateData=(t,e)=>{if("undefined"==typeof document){const o="string"==typeof t?t:JSON.stringify(t);return this.injectHtml((async()=>{const t=`__TSR_DEHYDRATED__${o}`,r="function"==typeof e?await e():e;return`<script id='${t}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${k(o)}"] = ${JSON.stringify(r)}\n ;(() => {\n var el = document.getElementById('${t}')\n el.parentElement.removeChild(el)\n })()\n <\/script>`})),()=>this.hydrateData(t)}return()=>{}};hydrateData=t=>{if("undefined"!=typeof document){const e="string"==typeof t?t:JSON.stringify(t);return window[`__TSR_DEHYDRATED__${e}`]}}},t.RouterProvider=function({router:t,...e}){t.updateOptions({...t.options,...e,context:{...t.options.context,...e?.context}});const[o,n]=r.useState((()=>t.state)),[s,a]=r.useTransition(),i=r.useMemo((()=>({...o,status:s?"pending":"idle",location:s?t.latestLocation:o.location,pendingMatches:t.pendingMatches})),[o,s]);return t.setState=n,t.state=i,t.startReactTransition=a,r.useLayoutEffect((()=>{const e=t.history.subscribe((()=>{t.latestLocation=t.parseLocation(t.latestLocation),i.location!==t.latestLocation&&a((()=>{try{t.load()}catch(t){console.error(t)}}))})),o=t.buildLocation({search:!0,params:!0,hash:!0,state:!0});return i.location.href!==o.href&&t.commitLocation({...o,replace:!0}),()=>{e()}}),[t.history]),r.useLayoutEffect((()=>{s||i.resolvedLocation===i.location||(t.emit({type:"onResolved",fromLocation:i.resolvedLocation,toLocation:i.location,pathChanged:i.location.href!==i.resolvedLocation?.href}),t.pendingMatches=[],n((t=>({...t,resolvedLocation:t.location}))))})),r.useLayoutEffect((()=>{a((()=>{try{t.load()}catch(t){console.error(t)}}))}),[]),r.createElement(tt.Provider,{value:t},r.createElement(U,null))},t.ScrollRestoration=function(t){return kt(t),null},t.SearchParamError=et,t.cleanPath=T,t.componentTypes=St,t.createBrowserHistory=h,t.createHashHistory=function(){return h({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=function(t={initialEntries:["/"]}){const e=t.initialEntries;let o=t.initialIndex??e.length-1,r={key:f()};return l({getLocation:()=>d(e[o],r),pushState:(t,n)=>{r=n,e.push(t),o++},replaceState:(t,n)=>{r=n,e[o]=t},back:()=>{o--},forward:()=>{o=Math.min(o+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})},t.createRouteMask=function(t){return t},t.decode=pt,t.deepEqual=C,t.defaultParseSearch=yt,t.defaultStringifySearch=gt,t.defer=function(t){const e=t;if(!e.__deferredState){e.__deferredState={uid:Math.random().toString(36).slice(2),status:"pending"};const t=e.__deferredState;e.then((e=>{t.status="success",t.data=e})).catch((e=>{t.status="error",t.error=e}))}return e},t.encode=dt,t.escapeJSON=k,t.functionalUpdate=R,t.getInitialRouterState=rt,t.getRouteMatch=nt,t.interpolatePath=$,t.invariant=m,t.isDehydratedDeferred=it,t.isPlainObject=P,t.isRedirect=mt,t.isServer=S,t.joinPaths=O,t.last=b,t.lazyFn=function(t,e){return async(...o)=>(await t())[e||"default"](...o)},t.lazyRouteComponent=function(t,e){let o;const n=()=>(o||(o=t()),o),s=r.lazy((async()=>({default:(await n())[e??"default"]})));return s.preload=n,s},t.matchByPath=N,t.matchPathname=A,t.matchesContext=Q,t.parsePathname=B,t.parseSearchWith=vt,t.pick=L,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=E,t.resolvePath=j,t.rootRouteId=F,t.rootRouteWithContext=function(){return t=>new z(t)},t.routerContext=tt,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 o=Object.keys(t);if(o.length!==Object.keys(e).length)return!1;for(let r=0;r<o.length;r++)if(!Object.prototype.hasOwnProperty.call(e,o[r])||!Object.is(t[o[r]],e[o[r]]))return!1;return!0},t.stringifySearchWith=wt,t.trimPath=D,t.trimPathLeft=I,t.trimPathRight=M,t.typedNavigate=function(t){return t},t.useAwaited=ct,t.useBlocker=Ot,t.useLayoutEffect=x,t.useLinkProps=ut,t.useLoaderData=Z,t.useMatch=G,t.useMatchRoute=V,t.useMatches=function(t){const e=r.useContext(Q);return st({select:o=>{const r=o.matches.slice(o.matches.findIndex((t=>t.id===e[0]?.id)));return t?.select?t.select(r):r}})},t.useNavigate=function(t){const{navigate:e}=at(),o=G({strict:!1});return r.useCallback((r=>e({from:r?.to?o.pathname:void 0,...t,...r})),[])},t.useParams=H,t.useRouteContext=function(t){return G({...t,select:e=>t?.select?t.select(e.context):e.context})},t.useRouter=at,t.useRouterState=st,t.useScrollRestoration=kt,t.useSearch=K,t.useStableCallback=function(t){const e=r.useRef(t);return e.current=t,r.useRef(((...t)=>e.current(...t))).current},t.warning=y}));
|
|
22
22
|
//# sourceMappingURL=index.production.js.map
|