@tanstack/react-router 0.0.1-beta.69 → 0.0.1-beta.70

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.
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("use-sync-external-store/shim/with-selector")):"function"==typeof define&&define.amd?define(["exports","react","use-sync-external-store/shim/with-selector"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReactRouter={},t.React,t.withSelector)}(this,(function(t,e,r){"use strict";function o(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var a=o(e);function s(){return s=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},s.apply(this,arguments)}function n(t,e){if(!t)throw new Error("Invariant failed")}
11
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("use-sync-external-store/shim/with-selector")):"function"==typeof define&&define.amd?define(["exports","react","use-sync-external-store/shim/with-selector"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReactRouter={},t.React,t.withSelector)}(this,(function(t,e,r){"use strict";function o(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var s=o(e);function a(){return a=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},a.apply(this,arguments)}function n(t,e){if(!t)throw new Error("Invariant failed")}function i(t,e){}
12
12
  /**
13
13
  * store
14
14
  *
@@ -18,7 +18,7 @@
18
18
  * LICENSE.md file in the root directory of this source tree.
19
19
  *
20
20
  * @license MIT
21
- */class i{listeners=new Set;batching=!1;queue=[];constructor(t,e){this.state=t,this.options=e}subscribe=t=>{this.listeners.add(t);const e=this.options?.onSubscribe?.(t,this);return()=>{this.listeners.delete(t),e?.()}};setState=t=>{const e=this.state;this.state=this.options?.updateFn?this.options.updateFn(e)(t):t(e),this.state!==e&&(this.options?.onUpdate?.(this.state,e),this.queue.push((()=>{this.listeners.forEach((t=>t(this.state,e)))})),this.#t())};#t=()=>{this.batching||(this.queue.forEach((t=>t())),this.queue=[])};batch=t=>{this.batching=!0,t(),this.batching=!1,this.#t()}}
21
+ */class c{listeners=new Set;batching=!1;queue=[];constructor(t,e){this.state=t,this.options=e}subscribe=t=>{this.listeners.add(t);const e=this.options?.onSubscribe?.(t,this);return()=>{this.listeners.delete(t),e?.()}};setState=t=>{const e=this.state;this.state=this.options?.updateFn?this.options.updateFn(e)(t):t(e),this.state!==e&&(this.options?.onUpdate?.(this.state,e),this.queue.push((()=>{this.listeners.forEach((t=>t(this.state,e)))})),this.#t())};#t=()=>{this.batching||(this.queue.forEach((t=>t())),this.queue=[])};batch=t=>{this.batching=!0,t(),this.batching=!1,this.#t()}}
22
22
  /**
23
23
  * router
24
24
  *
@@ -28,7 +28,7 @@
28
28
  * LICENSE.md file in the root directory of this source tree.
29
29
  *
30
30
  * @license MIT
31
- */const c="popstate";function h(t){let e=t.getLocation(),r=()=>{},o=new Set;const a=()=>{e=t.getLocation(),o.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===o.size&&(r=t.listener(a)),o.add(e),()=>{o.delete(e),0===o.size&&r()}),push:(e,r)=>{t.pushState(e,r),a()},replace:(e,r)=>{t.replaceState(e,r),a()},go:e=>{t.go(e),a()},back:()=>{t.back(),a()},forward:()=>{t.forward(),a()}}}function u(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),r=t?.createHref??(t=>t);return h({getLocation:()=>d(e(),history.state),listener:t=>(window.addEventListener(c,t),()=>{window.removeEventListener(c,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:p()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:p()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t)})}function l(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,o={};return h({getLocation:()=>d(e[r],o),listener:()=>()=>{},pushState:(t,a)=>{o={...a,key:p()},e.push(t),r++},replaceState:(t,a)=>{o={...a,key:p()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t)})}function d(t,e){let r=t.indexOf("#"),o=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?o>0?Math.min(r,o):r:o>0?o:t.length),hash:r>-1?t.substring(r,o):"",search:o>-1?t.substring(o):"",state:e}}function p(){return(Math.random()+1).toString(36).substring(7)}function f(t){return t[t.length-1]}function m(t,e){if(t){"undefined"!=typeof console&&console.warn(e);try{throw new Error(e)}catch{}}return!0}function y(t,e){return"function"==typeof t?t(e):t}function g(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function v(t,e){if(t===e)return t;const r=e,o=Array.isArray(t)&&Array.isArray(r);if(o||w(t)&&w(r)){const e=o?t.length:Object.keys(t).length,a=o?r:Object.keys(r),s=a.length,n=o?[]:{};let i=0;for(let e=0;e<s;e++){const s=o?e:a[e];n[s]=v(t[s],r[s]),n[s]===t[s]&&i++}return e===s&&i===e?t:n}return r}function w(t){if(!S(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!S(r)&&!!r.hasOwnProperty("isPrototypeOf")}function S(t){return"[object Object]"===Object.prototype.toString.call(t)}function b(t,e){return t===e||typeof t==typeof e&&(w(t)&&w(e)?!Object.keys(e).some((r=>!b(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>b(t,e[r])))))}function L(t){return E(t.filter(Boolean).join("/"))}function E(t){return t.replace(/\/{2,}/g,"/")}function P(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function x(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function R(t){return x(P(t))}function C(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let o=_(e);const a=_(r);a.forEach(((t,e)=>{if("/"===t.value)e?e===a.length-1&&o.push(t):o=[t];else if(".."===t.value)o.length>1&&"/"===f(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return E(L([t,...o.map((t=>t.value))]))}function _(t){if(!t)return[];const e=[];if("/"===(t=E(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const r=t.split("/").filter(Boolean);return e.push(...r.map((t=>"$"===t?{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 M(t,e,r){return L(_(t).map((t=>"$"!==t.value||r?"param"===t.type?e[t.value.substring(1)]??"":t.value:"")))}function k(t,e,r){const o=O(t,e,r);if(!r.to||o)return o??{}}function O(t,e,r){if(!e.startsWith(t))return;const o=_(e="/"!=t?e.substring(t.length):e),a=_(`${r.to??"$"}`),s={};return(()=>{for(let t=0;t<Math.max(o.length,a.length);t++){const e=o[t],n=a[t],i=t===a.length-1,c=t===o.length-1;if(n){if("wildcard"===n.type)return!!e?.value&&(s.$=L(o.slice(t).map((t=>t.value))),!0);if("pathname"===n.type){if("/"===n.value&&!e?.value)return!0;if(e)if(r.caseSensitive){if(n.value!==e.value)return!1}else if(n.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===n.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(s[n.value.substring(1)]=e.value)}}if(i&&!c)return!!r.fuzzy}return!0})()?s:void 0}function j(t,e){var r,o,a,s="";for(r in t)if(void 0!==(a=t[r]))if(Array.isArray(a))for(o=0;o<a.length;o++)s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(a[o]);else s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(a);return(e||"")+s}function $(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function I(t){for(var e,r,o={},a=t.split("&");e=a.shift();)void 0!==o[r=(e=e.split("=")).shift()]?o[r]=[].concat(o[r],$(e.shift())):o[r]=$(e.shift());return o}const A="__root__";class T{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute}init=t=>{this.originalIndex=t.originalIndex,this.router=t.router;const e=this.options,r=!e?.path&&!e?.id,o=this.options?.getParentRoute?.();r?this.path=A:n(o);let a=r?A:e.path;a&&"/"!==a&&(a=R(a));const s=e?.id||a;let i=r?A:L([o.id===A?"":o.id,s]);a===A&&(a="/"),i!==A&&(i=L(["/",i]));const c=i===A?"/":x(L([o.fullPath,a]));this.path=a,this.id=i,this.fullPath=c};addChildren=t=>(this.children=t,this);generate=t=>{n(!1)}}class F extends T{constructor(t){super(t)}static withRouterContext=()=>t=>new F(t)}const D=["component","errorComponent","pendingComponent"];class N{abortController=new AbortController;onLoaderDataListeners=new Set;constructor(t,e,r){Object.assign(this,{route:e,router:t,id:r.id,pathname:r.pathname,params:r.params,store:new i({updatedAt:0,routeSearch:{},search:{},status:"idle"},{onUpdate:t=>{this.state=t}})}),this.state=this.store.state,D.map((async t=>{const e=this.route.options[t];"function"!=typeof this[t]&&(this[t]=e)})),"idle"!==this.state.status||this.#e()||this.store.setState((t=>({...t,status:"success"})))}#e=()=>!(!this.route.options.onLoad&&!D.some((t=>this.route.options[t]?.preload)));__commit=()=>{const{routeSearch:t,search:e,context:r,routeContext:o}=this.#r({location:this.router.state.currentLocation});this.context=r,this.routeContext=o,this.store.setState((r=>({...r,routeSearch:v(r.routeSearch,t),search:v(r.search,e)})))};cancel=()=>{this.abortController?.abort()};#o=t=>{const e=this.parentMatch?this.parentMatch.#o(t):{search:t.location.search,routeSearch:t.location.search};try{const t=("object"==typeof this.route.options.validateSearch?this.route.options.validateSearch.parse:this.route.options.validateSearch)?.(e.search)??{};return{routeSearch:t,search:{...e.search,...t}}}catch(t){this.route.options.onValidateSearchError?.(t);const e=new Error("Invalid search params found",{cause:t});throw e.code="INVALID_SEARCH_PARAMS",e}};#r=t=>{const{search:e,routeSearch:r}=this.#o(t),o=this.route.options.getContext?.({parentContext:this.parentMatch?.routeContext??{},context:this.parentMatch?.context??this.router?.options.context??{},params:this.params,search:e})||{};return{routeSearch:r,search:e,context:{...this.parentMatch?.context??this.router?.options.context,...o},routeContext:o}};__load=async t=>{let e;this.parentMatch=t.parentMatch;try{e=this.#r(t)}catch(t){return this.route.options.onError?.(t),void this.store.setState((e=>({...e,status:"error",error:t})))}const{routeSearch:r,search:o,context:a,routeContext:s}=e;if("pending"!==this.state.status)return this.__loadPromise=Promise.resolve().then((async()=>{const e=""+Date.now()+Math.random();this.#a=e;const n=()=>e!==this.#a?this.__loadPromise:void 0;let i;"idle"===this.state.status&&this.store.setState((t=>({...t,status:"pending"})));const c=(async()=>{await Promise.all(D.map((async t=>{const e=this.route.options[t];this[t]?.preload&&(this[t]=await this.router.options.loadComponent(e))})))})(),h=Promise.resolve().then((()=>{if(this.route.options.onLoad)return this.route.options.onLoad({params:this.params,routeSearch:r,search:o,signal:this.abortController.signal,preload:!!t?.preload,routeContext:s,context:a})}));try{if(await Promise.all([c,h]),i=n())return await i;this.store.setState((t=>({...t,error:void 0,status:"success",updatedAt:Date.now()})))}catch(t){this.route.options.onLoadError?.(t),this.route.options.onError?.(t),this.store.setState((e=>({...e,error:t,status:"error",updatedAt:Date.now()})))}finally{delete this.__loadPromise}})),this.__loadPromise};#a=""}const B=U(JSON.parse),H=z(JSON.stringify);function U(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=I(e);for(let e in r){const o=r[e];if("string"==typeof o)try{r[e]=t(o)}catch(t){}}return r}}function z(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const o=e[r];if(void 0===o||void 0===o)delete e[r];else if(o&&"object"==typeof o&&null!==o)try{e[r]=t(o)}catch(t){}}));const r=j(e).toString();return r?`?${r}`:""}}const q=async({router:t,routeMatch:e})=>{const r=t.buildNext({to:".",search:t=>({...t??{},__data:{matchId:e.id}})}),o=await fetch(r.href,{method:"GET",signal:e.abortController.signal});if(o.ok)return o.json();throw new Error("Failed to fetch match data")};class W{#s;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??H,parseSearch:t?.parseSearch??B,fetchServerDataFn:t?.fetchServerDataFn??q},this.store=new i(J(),{onUpdate:t=>{this.state=t}}),this.state=this.store.state,this.basepath="",this.update(t),this.options.Router?.(this)}reset=()=>{this.store.setState((t=>Object.assign(t,J())))};mount=()=>{if(!K){this.state.currentMatches.length||this.load();const t="visibilitychange",e="focus";return window.addEventListener&&(window.addEventListener(t,this.#n,!1),window.addEventListener(e,this.#n,!1)),()=>{window.removeEventListener&&(window.removeEventListener(t,this.#n),window.removeEventListener(e,this.#n))}}return()=>{}};update=t=>{if(Object.assign(this.options,t),!this.history||this.options.history&&this.options.history!==this.history){this.#s&&this.#s(),this.history=this.options.history??(K?l():u());const t=this.#i();this.store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#s=this.history.listen((()=>{this.load({next:this.#i(this.state.latestLocation)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${R(e??"")??""}`,r&&(this.routesById={},this.routeTree=this.#c(r)),this};buildNext=t=>{const e=this.#h(t),r=this.matchRoutes(e.pathname),o=r.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean),a=r.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean);return this.#h({...t,__preSearchFilters:o,__postSearchFilters:a})};cancelMatches=()=>{[...this.state.currentMatches,...this.state.pendingMatches||[]].forEach((t=>{t.cancel()}))};load=async t=>{let e=Date.now();const r=e;let o;this.startedLoadingAt=r,this.cancelMatches(),this.store.batch((()=>{t?.next&&this.store.setState((e=>({...e,latestLocation:t.next}))),o=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),this.store.setState((t=>({...t,status:"pending",pendingMatches:o,pendingLocation:this.state.latestLocation})))}));try{await this.loadMatches(o,this.state.pendingLocation)}catch(t){console.warn(t),n(!1)}if(this.startedLoadingAt!==r)return this.navigationPromise;const a=this.state.currentMatches,s=[],i=[];a.forEach((t=>{o.find((e=>e.id===t.id))?i.push(t):s.push(t)}));const c=o.filter((t=>!a.find((e=>e.id===t.id))));e=Date.now(),s.forEach((t=>{t.__onExit?.({params:t.params,search:t.state.routeSearch}),"error"===t.state.status&&this.store.setState((t=>({...t,status:"idle",error:void 0})))})),i.forEach((t=>{t.route.options.onTransition?.({params:t.params,search:t.state.routeSearch})})),c.forEach((t=>{t.__onExit=t.route.options.onLoaded?.({params:t.params,search:t.state.search})}));const h=this.state.currentLocation;this.store.setState((t=>({...t,status:"idle",currentLocation:this.state.latestLocation,currentMatches:o,pendingLocation:void 0,pendingMatches:void 0}))),o.forEach((t=>{t.__commit()})),h.href!==this.state.currentLocation.href&&this.options.onRouteChange?.(),this.resolveNavigation()};getRoute=t=>{const e=this.routesById[t];return n(e),e};loadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r,e),r};preloadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r,e,{preload:!0}),r};matchRoutes=(t,e)=>{const r=[];if(!this.routeTree)return r;const o=[...this.state.currentMatches,...this.state.pendingMatches??[]],a=async s=>{let n=f(r)?.params??{};const i=this.options.filterRoutes?.(s)??s;let c=[];const h=(r,o)=>(o.some((o=>{const a=o.children;if(!o.path&&a?.length)return h([...c,o],a);const s=!("/"===o.path&&!a?.length),i=k(this.basepath,t,{to:o.fullPath,fuzzy:s,caseSensitive:o.options.caseSensitive??this.options.caseSensitive});if(i){let t;try{t=o.options.parseParams?.(i)??i}catch(t){if(e?.strictParseParams)throw t}n={...n,...t}}return i&&(c=[...r,o]),!!c.length})),!!c.length);if(h([],i),!c.length)return;c.forEach((t=>{const e=M(t.path,n),a=M(t.id,n,!0),s=o.find((t=>t.id===a))||new N(this,t,{id:a,params:n,pathname:L([this.basepath,e])});r.push(s)}));const u=f(c).children;u?.length&&a(u)};return a([this.routeTree]),r};loadMatches=async(t,e,r)=>{await Promise.all(t.map((async t=>{try{await(t.route.options.beforeLoad?.({router:this,match:t}))}catch(e){throw r?.preload||t.route.options.onBeforeLoadError?.(e),t.route.options.onError?.(e),e}})));const o=t.map((async(o,a)=>{const s=t[a-1];o.__load({preload:r?.preload,location:e,parentMatch:s}),await o.__loadPromise,s&&await s.__loadPromise}));await Promise.all(o)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>C(this.basepath,t,E(e));navigate=async({from:t,to:e="",search:r,hash:o,replace:a,params:s})=>{const i=String(e),c=void 0===t?t:String(t);let h;try{new URL(`${i}`),h=!0}catch(t){}return n(!h),this.#u({from:c,to:i,search:r,hash:o,replace:a,params:s})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t),o=e?.pending?this.state.pendingLocation:this.state.currentLocation;if(!o)return!1;const a=k(this.basepath,o.pathname,{...e,to:r.pathname});return!!a&&(e?.includeSearch??1?!!b(o.search,r.search)&&a:a)};buildLink=({from:t,to:e=".",search:r,params:o,hash:a,target:s,replace:n,activeOptions:i,preload:c,preloadDelay:h,disabled:u})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const l={from:t,to:e,search:r,params:o,hash:a,replace:n},d=this.buildNext(l);c=c??this.options.defaultPreload;const p=h??this.options.defaultPreloadDelay??0,f=this.state.currentLocation.pathname.split("/"),m=d.pathname.split("/").every(((t,e)=>t===f[e])),y=i?.exact?this.state.currentLocation.pathname===d.pathname:m,g=!i?.includeHash||this.state.currentLocation.hash===d.hash,v=!(i?.includeSearch??1)||b(this.state.currentLocation.search,d.search);return{type:"internal",next:d,handleFocus:t=>{c&&this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{u||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}
31
+ */const h="popstate";function u(t){let e=t.getLocation(),r=()=>{},o=new Set;const s=()=>{e=t.getLocation(),o.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===o.size&&(r=t.listener(s)),o.add(e),()=>{o.delete(e),0===o.size&&r()}),push:(e,r)=>{t.pushState(e,r),s()},replace:(e,r)=>{t.replaceState(e,r),s()},go:e=>{t.go(e),s()},back:()=>{t.back(),s()},forward:()=>{t.forward(),s()}}}function l(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),r=t?.createHref??(t=>t);return u({getLocation:()=>p(e(),history.state),listener:t=>(window.addEventListener(h,t),()=>{window.removeEventListener(h,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:f()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:f()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t)})}function d(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,o={};return u({getLocation:()=>p(e[r],o),listener:()=>()=>{},pushState:(t,s)=>{o={...s,key:f()},e.push(t),r++},replaceState:(t,s)=>{o={...s,key:f()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t)})}function p(t,e){let r=t.indexOf("#"),o=t.indexOf("?");return{href:t,pathname:t.substring(0,r>0?o>0?Math.min(r,o):r:o>0?o:t.length),hash:r>-1?t.substring(r,o):"",search:o>-1?t.substring(o):"",state:e}}function f(){return(Math.random()+1).toString(36).substring(7)}function m(t){return t[t.length-1]}function y(t,e){return"function"==typeof t?t(e):t}function g(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function v(t,e){if(t===e)return t;const r=e,o=Array.isArray(t)&&Array.isArray(r);if(o||w(t)&&w(r)){const e=o?t.length:Object.keys(t).length,s=o?r:Object.keys(r),a=s.length,n=o?[]:{};let i=0;for(let e=0;e<a;e++){const a=o?e:s[e];n[a]=v(t[a],r[a]),n[a]===t[a]&&i++}return e===a&&i===e?t:n}return r}function w(t){if(!S(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!S(r)&&!!r.hasOwnProperty("isPrototypeOf")}function S(t){return"[object Object]"===Object.prototype.toString.call(t)}function b(t,e){return t===e||typeof t==typeof e&&(w(t)&&w(e)?!Object.keys(e).some((r=>!b(t[r],e[r]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,r)=>b(t,e[r])))))}function L(t){return E(t.filter(Boolean).join("/"))}function E(t){return t.replace(/\/{2,}/g,"/")}function P(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function x(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function C(t){return x(P(t))}function R(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let o=_(e);const s=_(r);s.forEach(((t,e)=>{if("/"===t.value)e?e===s.length-1&&o.push(t):o=[t];else if(".."===t.value)o.length>1&&"/"===m(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return E(L([t,...o.map((t=>t.value))]))}function _(t){if(!t)return[];const e=[];if("/"===(t=E(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const r=t.split("/").filter(Boolean);return e.push(...r.map((t=>"$"===t?{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 M(t,e,r){return L(_(t).map((t=>"$"!==t.value||r?"param"===t.type?e[t.value.substring(1)]??"":t.value:"")))}function k(t,e,r){const o=O(t,e,r);if(!r.to||o)return o??{}}function O(t,e,r){if(!e.startsWith(t))return;const o=_(e="/"!=t?e.substring(t.length):e),s=_(`${r.to??"$"}`);"/"===m(o)?.value&&o.pop();const a={};return(()=>{for(let t=0;t<Math.max(o.length,s.length);t++){const e=o[t],n=s[t],i=t===s.length-1,c=t===o.length-1;if(n){if("wildcard"===n.type)return!!e?.value&&(a.$=L(o.slice(t).map((t=>t.value))),!0);if("pathname"===n.type){if("/"===n.value&&!e?.value)return!0;if(e)if(r.caseSensitive){if(n.value!==e.value)return!1}else if(n.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===n.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(a[n.value.substring(1)]=e.value)}}if(i&&!c)return!!r.fuzzy}return!0})()?a:void 0}function j(t,e){var r,o,s,a="";for(r in t)if(void 0!==(s=t[r]))if(Array.isArray(s))for(o=0;o<s.length;o++)a&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(s[o]);else a&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(s);return(e||"")+a}function $(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function I(t){for(var e,r,o={},s=t.split("&");e=s.shift();)void 0!==o[r=(e=e.split("=")).shift()]?o[r]=[].concat(o[r],$(e.shift())):o[r]=$(e.shift());return o}const A="__root__";class T{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute}init=t=>{this.originalIndex=t.originalIndex,this.router=t.router;const e=this.options,r=!e?.path&&!e?.id,o=this.options?.getParentRoute?.();r?this.path=A:n(o);let s=r?A:e.path;s&&"/"!==s&&(s=C(s));const a=e?.id||s;let i=r?A:L([o.id===A?"":o.id,a]);s===A&&(s="/"),i!==A&&(i=L(["/",i]));const c=i===A?"/":x(L([o.fullPath,s]));this.path=s,this.id=i,this.fullPath=c};addChildren=t=>(this.children=t,this);generate=t=>{n(!1)}}class F extends T{constructor(t){super(t)}static withRouterContext=()=>t=>new F(t)}const D=B(JSON.parse),N=H(JSON.stringify);function B(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=I(e);for(let e in r){const o=r[e];if("string"==typeof o)try{r[e]=t(o)}catch(t){}}return r}}function H(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const o=e[r];if(void 0===o||void 0===o)delete e[r];else if(o&&"object"==typeof o&&null!==o)try{e[r]=t(o)}catch(t){}}));const r=j(e).toString();return r?`?${r}`:""}}const U=async({router:t,routeMatch:e})=>{const r=t.buildNext({to:".",search:t=>({...t??{},__data:{matchId:e.id}})}),o=await fetch(r.href,{method:"GET",signal:e.abortController.signal});if(o.ok)return o.json();throw new Error("Failed to fetch match data")};class z{#e;startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??N,parseSearch:t?.parseSearch??D,fetchServerDataFn:t?.fetchServerDataFn??U},this.store=new c(W(),{onUpdate:t=>{this.state=t}}),this.state=this.store.state,this.basepath="",this.update(t),this.options.Router?.(this)}reset=()=>{this.store.setState((t=>Object.assign(t,W())))};mount=()=>{if(!q){this.state.currentMatches.length||this.safeLoad();const t="visibilitychange",e="focus";return window.addEventListener&&(window.addEventListener(t,this.#r,!1),window.addEventListener(e,this.#r,!1)),()=>{window.removeEventListener&&(window.removeEventListener(t,this.#r),window.removeEventListener(e,this.#r))}}return()=>{}};update=t=>{if(Object.assign(this.options,t),!this.history||this.options.history&&this.options.history!==this.history){this.#e&&this.#e(),this.history=this.options.history??(q?d():l());const t=this.#o();this.store.setState((e=>({...e,latestLocation:t,currentLocation:t}))),this.#e=this.history.listen((()=>{this.safeLoad({next:this.#o(this.state.latestLocation)})}))}const{basepath:e,routeTree:r}=this.options;return this.basepath=`/${C(e??"")??""}`,r&&(this.routesById={},this.routeTree=this.#s(r)),this};buildNext=t=>{const e=this.#a(t),r=this.matchRoutes(e.pathname),o=r.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean),s=r.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean);return this.#a({...t,__preSearchFilters:o,__postSearchFilters:s})};cancelMatches=()=>{[...this.state.currentMatches,...this.state.pendingMatches||[]].forEach((t=>{t.cancel()}))};safeLoad=t=>{this.load(t).catch((t=>{console.warn(t),n(!1)}))};load=async t=>{let e=Date.now();const r=e;let o;if(this.startedLoadingAt=r,this.cancelMatches(),this.store.batch((()=>{t?.next&&this.store.setState((e=>({...e,latestLocation:t.next}))),o=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),this.store.setState((t=>({...t,status:"pending",pendingMatches:o,pendingLocation:this.state.latestLocation})))})),await this.loadMatches(o,this.state.pendingLocation),this.startedLoadingAt!==r)return this.navigationPromise;const s=this.state.currentMatches,a=[],n=[];s.forEach((t=>{o.find((e=>e.id===t.id))?n.push(t):a.push(t)}));const i=o.filter((t=>!s.find((e=>e.id===t.id))));e=Date.now(),a.forEach((t=>{t.__onExit?.({params:t.params,search:t.state.routeSearch}),"error"===t.state.status&&this.store.setState((t=>({...t,status:"idle",error:void 0})))})),n.forEach((t=>{t.route.options.onTransition?.({params:t.params,search:t.state.routeSearch})})),i.forEach((t=>{t.__onExit=t.route.options.onLoaded?.({params:t.params,search:t.state.search})}));const c=this.state.currentLocation;this.store.setState((t=>({...t,status:"idle",currentLocation:this.state.latestLocation,currentMatches:o,pendingLocation:void 0,pendingMatches:void 0}))),o.forEach((t=>{t.__commit()})),c.href!==this.state.currentLocation.href&&this.options.onRouteChange?.(),this.resolveNavigation()};getRoute=t=>{const e=this.routesById[t];return n(e),e};loadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r,e),r};preloadRoute=async(t=this.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r,e,{preload:!0}),r};matchRoutes=(t,e)=>{const r=[];if(!this.routeTree)return r;const o=[...this.state.currentMatches,...this.state.pendingMatches??[]],s=async a=>{let n=m(r)?.params??{};const i=this.options.filterRoutes?.(a)??a;let c=[];const h=(r,o)=>(o.some((o=>{const s=o.children;if(!o.path&&s?.length)return h([...c,o],s);const a=!("/"===o.path&&!s?.length),i=k(this.basepath,t,{to:o.fullPath,fuzzy:a,caseSensitive:o.options.caseSensitive??this.options.caseSensitive});if(i){let t;try{t=o.options.parseParams?.(i)??i}catch(t){if(e?.strictParseParams)throw t}n={...n,...t}}return i&&(c=[...r,o]),!!c.length})),!!c.length);if(h([],i),!c.length)return;c.forEach((t=>{const e=M(t.path,n),s=M(t.id,n,!0),a=o.find((t=>t.id===s))||new V(this,t,{id:s,params:n,pathname:L([this.basepath,e])});r.push(a)}));const u=m(c).children;u?.length&&s(u)};return s([this.routeTree]),r};loadMatches=async(t,e,r)=>{await Promise.all(t.map((async t=>{try{await(t.route.options.beforeLoad?.({router:this,match:t}))}catch(e){throw r?.preload||t.route.options.onBeforeLoadError?.(e),t.route.options.onError?.(e),e}})));const o=t.map((async(o,s)=>{const a=t[s-1];o.__load({preload:r?.preload,location:e,parentMatch:a}),await o.__loadPromise,a&&await a.__loadPromise}));await Promise.all(o)};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>R(this.basepath,t,E(e));navigate=async({from:t,to:e="",search:r,hash:o,replace:s,params:a})=>{const i=String(e),c=void 0===t?t:String(t);let h;try{new URL(`${i}`),h=!0}catch(t){}return n(!h),this.#n({from:c,to:i,search:r,hash:o,replace:s,params:a})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t),o=e?.pending?this.state.pendingLocation:this.state.currentLocation;if(!o)return!1;const s=k(this.basepath,o.pathname,{...e,to:r.pathname});return!!s&&(e?.includeSearch??1?!!b(o.search,r.search)&&s:s)};buildLink=({from:t,to:e=".",search:r,params:o,hash:s,target:a,replace:n,activeOptions:i,preload:c,preloadDelay:h,disabled:u})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const l={from:t,to:e,search:r,params:o,hash:s,replace:n},d=this.buildNext(l);c=c??this.options.defaultPreload;const p=h??this.options.defaultPreloadDelay??0,f=this.state.currentLocation.pathname.split("/"),m=d.pathname.split("/").every(((t,e)=>t===f[e])),y=i?.exact?this.state.currentLocation.pathname===d.pathname:m,g=!i?.includeHash||this.state.currentLocation.hash===d.hash,v=!(i?.includeSearch??1)||b(this.state.currentLocation.search,d.search);return{type:"internal",next:d,handleFocus:t=>{c&&this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{u||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||a&&"_self"!==a||0!==t.button||(t.preventDefault(),this.#n(l))},handleEnter:t=>{const e=t.target||{};if(c){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),p)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},isActive:y&&g&&v,disabled:u}};dehydrate=()=>({state:{...g(this.state,["latestLocation","currentLocation","status","lastUpdated"]),currentMatches:this.state.currentMatches.map((t=>({id:t.id,state:{status:t.state.status}})))}});hydrate=t=>{this.store.setState((e=>{const r=this.matchRoutes(t.state.latestLocation.pathname,{strictParseParams:!0});return r.forEach(((e,r)=>{const o=t.state.currentMatches[r];n(o&&o.id===e.id),e.store.setState((t=>({...t,...o.state})))})),{...e,...t.state,currentMatches:r}}))};#s=t=>{const e=t=>{t.forEach(((t,r)=>{t.init({originalIndex:r,router:this});if(this.routesById[t.id])throw new Error;this.routesById[t.id]=t;const o=t.children;o?.length&&e(o)}))};return e([t]),t};#o=t=>{let{pathname:e,search:r,hash:o,state:s}=this.history.location;const a=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:v(t?.search,a),hash:o.split("#").reverse()[0]??"",href:`${e}${r}${o}`,state:s,key:s?.key||"__init__"}};#r=()=>{this.safeLoad()};#a=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.latestLocation.pathname:t.from??this.state.latestLocation.pathname;let r=R(this.basepath??"/",e,`${t.to??""}`);const o=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),s=this.matchRoutes(r),a={...m(o)?.params};let n=!0===(t.params??!0)?a:y(t.params,a);n&&s.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},n,t(n))})),r=M(r,n??{});const i=t.__preSearchFilters?.length?t.__preSearchFilters?.reduce(((t,e)=>e(t)),this.state.latestLocation.search):this.state.latestLocation.search,c=!0===t.search?i:t.search?y(t.search,i)??{}:t.__preSearchFilters?.length?i:{},h=t.__postSearchFilters?.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),c):c,u=v(this.state.latestLocation.search,h),l=this.options.stringifySearch(u);let d=!0===t.hash?this.state.latestLocation.hash:y(t.hash,this.state.latestLocation.hash);return d=d?`#${d}`:"",{pathname:r,search:u,searchStr:l,state:this.state.latestLocation.state,hash:d,href:`${r}${l}${d}`,key:t.key}};#n=async t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let o="replace";t.replace||(o="push");this.state.latestLocation.href===e.href&&!e.key&&(o="replace");const s=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===o?"push":"replace"](s,{id:r,...e.state}),this.navigationPromise=new Promise((t=>{const e=this.resolveNavigation;this.resolveNavigation=()=>{e(),t()}}))}}const q="undefined"==typeof window||!window.document.createElement;function W(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],lastUpdated:Date.now()}}function K(t){return!!t?.isRedirect}const J=["component","errorComponent","pendingComponent"];class V{abortController=new AbortController;onLoaderDataListeners=new Set;constructor(t,e,r){Object.assign(this,{route:e,router:t,id:r.id,pathname:r.pathname,params:r.params,store:new c({updatedAt:0,routeSearch:{},search:{},status:"idle"},{onUpdate:t=>{this.state=t}})}),this.state=this.store.state,J.map((async t=>{const e=this.route.options[t];"function"!=typeof this[t]&&(this[t]=e)})),"idle"!==this.state.status||this.#i()||this.store.setState((t=>({...t,status:"success"})))}#i=()=>!(!this.route.options.onLoad&&!J.some((t=>this.route.options[t]?.preload)));__commit=()=>{const{routeSearch:t,search:e,context:r,routeContext:o}=this.#c({location:this.router.state.currentLocation});this.context=r,this.routeContext=o,this.store.setState((r=>({...r,routeSearch:v(r.routeSearch,t),search:v(r.search,e)})))};cancel=()=>{this.abortController?.abort()};#h=t=>{const e=this.parentMatch?this.parentMatch.#h(t):{search:t.location.search,routeSearch:t.location.search};try{const t=("object"==typeof this.route.options.validateSearch?this.route.options.validateSearch.parse:this.route.options.validateSearch)?.(e.search)??{};return{routeSearch:t,search:{...e.search,...t}}}catch(t){if(K(t))throw t;this.route.options.onValidateSearchError?.(t);const e=new Error("Invalid search params found",{cause:t});throw e.code="INVALID_SEARCH_PARAMS",e}};#c=t=>{const{search:e,routeSearch:r}=this.#h(t),o=this.route.options.getContext?.({parentContext:this.parentMatch?.routeContext??{},context:this.parentMatch?.context??this.router?.options.context??{},params:this.params,search:e})||{};return{routeSearch:r,search:e,context:{...this.parentMatch?.context??this.router?.options.context,...o},routeContext:o}};__load=async t=>{let e;this.parentMatch=t.parentMatch;try{e=this.#c(t)}catch(t){return K(t)?void this.router.navigate(t):(this.route.options.onError?.(t),void this.store.setState((e=>({...e,status:"error",error:t}))))}const{routeSearch:r,search:o,context:s,routeContext:a}=e;if("pending"!==this.state.status)return this.__loadPromise=Promise.resolve().then((async()=>{const e=""+Date.now()+Math.random();this.#u=e;const n=()=>e!==this.#u?this.__loadPromise:void 0;let i;"idle"===this.state.status&&this.store.setState((t=>({...t,status:"pending"})));const c=(async()=>{await Promise.all(J.map((async t=>{const e=this.route.options[t];this[t]?.preload&&(this[t]=await this.router.options.loadComponent(e))})))})(),h=Promise.resolve().then((()=>{if(this.route.options.onLoad)return this.route.options.onLoad({params:this.params,routeSearch:r,search:o,signal:this.abortController.signal,preload:!!t?.preload,routeContext:a,context:s})}));try{if(await Promise.all([c,h]),i=n())return await i;this.store.setState((t=>({...t,error:void 0,status:"success",updatedAt:Date.now()})))}catch(t){if(K(t))return void this.router.navigate(t);this.route.options.onLoadError?.(t),this.route.options.onError?.(t),this.store.setState((e=>({...e,error:t,status:"error",updatedAt:Date.now()})))}finally{delete this.__loadPromise}})),this.__loadPromise};#u=""}
32
32
  /**
33
33
  * react-store
34
34
  *
@@ -38,5 +38,5 @@
38
38
  * LICENSE.md file in the root directory of this source tree.
39
39
  *
40
40
  * @license MIT
41
- */(t)||t.defaultPrevented||s&&"_self"!==s||0!==t.button||(t.preventDefault(),this.#u(l))},handleEnter:t=>{const e=t.target||{};if(c){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),p)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(l).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},isActive:y&&g&&v,disabled:u}};dehydrate=()=>({state:{...g(this.state,["latestLocation","currentLocation","status","lastUpdated"]),currentMatches:this.state.currentMatches.map((t=>({id:t.id,state:{status:t.state.status}})))}});hydrate=t=>{this.store.setState((e=>{const r=this.matchRoutes(t.state.latestLocation.pathname,{strictParseParams:!0});return r.forEach(((e,r)=>{const o=t.state.currentMatches[r];n(o&&o.id===e.id),e.store.setState((t=>({...t,...o.state})))})),{...e,...t.state,currentMatches:r}}))};#c=t=>{const e=t=>{t.forEach(((t,r)=>{t.init({originalIndex:r,router:this});if(this.routesById[t.id])throw new Error;this.routesById[t.id]=t;const o=t.children;o?.length&&e(o)}))};return e([t]),t};#i=t=>{let{pathname:e,search:r,hash:o,state:a}=this.history.location;const s=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:v(t?.search,s),hash:o.split("#").reverse()[0]??"",href:`${e}${r}${o}`,state:a,key:a?.key||"__init__"}};#n=()=>{this.load()};#h=(t={})=>{t.fromCurrent=t.fromCurrent??""===t.to;const e=t.fromCurrent?this.state.latestLocation.pathname:t.from??this.state.latestLocation.pathname;let r=C(this.basepath??"/",e,`${t.to??""}`);const o=this.matchRoutes(this.state.latestLocation.pathname,{strictParseParams:!0}),a=this.matchRoutes(r),s={...f(o)?.params};let n=!0===(t.params??!0)?s:y(t.params,s);n&&a.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},n,t(n))})),r=M(r,n??{});const i=t.__preSearchFilters?.length?t.__preSearchFilters?.reduce(((t,e)=>e(t)),this.state.latestLocation.search):this.state.latestLocation.search,c=!0===t.search?i:t.search?y(t.search,i)??{}:t.__preSearchFilters?.length?i:{},h=t.__postSearchFilters?.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),c):c,u=v(this.state.latestLocation.search,h),l=this.options.stringifySearch(u);let d=!0===t.hash?this.state.latestLocation.hash:y(t.hash,this.state.latestLocation.hash);return d=d?`#${d}`:"",{pathname:r,search:u,searchStr:l,state:this.state.latestLocation.state,hash:d,href:`${r}${l}${d}`,key:t.key}};#u=async t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let o="replace";t.replace||(o="push");this.state.latestLocation.href===e.href&&!e.key&&(o="replace");const a=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===o?"push":"replace"](a,{id:r,...e.state}),this.navigationPromise=new Promise((t=>{const e=this.resolveNavigation;this.resolveNavigation=()=>{e(),t()}}))}}const K="undefined"==typeof window||!window.document.createElement;function J(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],lastUpdated:Date.now()}}function V(t,e=(t=>t),o){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,o?G:void 0)}function G(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(e,r[o])||!Object.is(t[r[o]],e[r[o]]))return!1;return!0}function Q(t){const e=tt(),{type:r,children:o,target:s,activeProps:n=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:h,hash:u,search:l,params:d,to:p=".",preload:f,preloadDelay:m,replace:g,style:v,className:w,onClick:S,onFocus:b,onMouseEnter:L,onMouseLeave:E,onTouchStart:P,...x}=t,R=e.buildLink(t);if("external"===R.type){const{href:t}=R;return{href:t}}const{handleClick:C,handleFocus:_,handleEnter:M,handleLeave:k,handleTouchStart:O,isActive:j,next:$}=R,I=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},A=j?y(n,{})??{}:{},T=j?{}:y(i,{})??{};return{...A,...T,...x,href:h?void 0:$.href,onClick:I([S,t=>{a.startTransition?a.startTransition((()=>{C(t)})):C(t)}]),onFocus:I([b,_]),onMouseEnter:I([L,M]),onMouseLeave:I([E,k]),onTouchStart:I([P,O]),target:s,style:{...v,...A.style,...T.style},className:[w,A.className,T.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":j?"active":void 0}}const X=a.forwardRef(((t,e)=>{const r=Q(t);return a.createElement("a",s({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))}));const Y=a.createContext(null),Z=a.createContext(null);function tt(){const t=a.useContext(Z);return m(!t,"useRouter must be used inside a <Router> component!"),V(t.router.store),t.router}function et(){return a.useContext(Y)}function rt(t){const e=tt(),r=et()[0],o=t?.from?e.state.currentMatches.find((e=>e.route.id===t?.from)):r;return n(o,t?.from&&t.from),(t?.strict??1)&&n(r.route.id==o?.route.id,(o?.route.id,r.route.id,o?.route.id,o?.route.id)),V(o.store,(e=>t?.track?.(o)??o),t?.shallow),o}function ot(){const t=tt();return a.useCallback((e=>{const{pending:r,caseSensitive:o,...a}=e;return t.matchRoute(a,{pending:r,caseSensitive:o})}),[])}function at(){const t=et().slice(1),e=t[0];return e?a.createElement(st,{matches:t,match:e}):null}function st({matches:t,match:e}){const r=tt();V(e.store,(t=>[t.status,t.error]),!0);const o=a.useCallback((()=>null),[]),s=a.useCallback((t=>{if("error"===t.match.state.status)throw t.match.state.error;if("success"===t.match.state.status)return a.createElement(t.match.component??r.options.defaultComponent??at);if("pending"===t.match.state.status)throw t.match.__loadPromise;n(!1)}),[]),i=e.pendingComponent??r.options.defaultPendingComponent??o,c=e.errorComponent??r.options.defaultErrorComponent;return a.createElement(Y.Provider,{value:t},e.route.options.wrapInSuspense??1?a.createElement(a.Suspense,{fallback:a.createElement(i,null)},a.createElement(nt,{key:e.route.id,errorComponent:c,match:e},a.createElement(s,{match:e}))):a.createElement(nt,{key:e.route.id,errorComponent:c,match:e},a.createElement(s,{match:e})))}class nt extends a.Component{state={error:!1,info:void 0};componentDidCatch(t,e){console.error(`Error in route match: ${this.props.match.id}`),console.error(t),this.setState({error:t,info:e})}render(){return a.createElement(it,s({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function it(t){const[e,r]=a.useState(t.errorState),o=tt(),s=t.errorComponent??ct,n=a.useRef("");return a.useEffect((()=>{e&&o.state.currentLocation.key!==n.current&&r({}),n.current=o.state.currentLocation.key}),[e,o.state.currentLocation.key]),a.useEffect((()=>{t.errorState.error&&r(t.errorState)}),[t.errorState.error]),t.errorState.error&&e.error?a.createElement(s,e):t.children}function ct({error:t}){return a.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},a.createElement("strong",{style:{fontSize:"1.2rem"}},"Something went wrong!"),a.createElement("div",{style:{height:".5rem"}}),a.createElement("div",null,a.createElement("pre",null,t.message?a.createElement("code",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".5rem",color:"red"}},t.message):null)))}t.DefaultErrorBoundary=ct,t.Link=X,t.MatchRoute=function(t){const e=ot()(t);return e?"function"==typeof t.children?t.children(e):e?t.children:null:null},t.Navigate=function(t){const e=tt();return a.useLayoutEffect((()=>{e.navigate(t)}),[]),null},t.Outlet=at,t.ReactRouter=class extends W{constructor(t){super({...t,loadComponent:async t=>(t.preload&&await t.preload(),t)})}},t.RootRoute=F,t.Route=T,t.RouteMatch=N,t.Router=W,t.RouterProvider=function({router:t,...e}){t.update(e);const r=V(t.store,(t=>t.currentMatches));return a.useEffect(t.mount,[t]),a.createElement(a.Fragment,null,a.createElement(Z.Provider,{value:{router:t}},a.createElement(Y.Provider,{value:[void 0,...r]},a.createElement(at,null))))},t.cleanPath=E,t.createBrowserHistory=u,t.createHashHistory=function(){return u({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=l,t.decode=I,t.defaultFetchServerDataFn=q,t.defaultParseSearch=B,t.defaultStringifySearch=H,t.encode=j,t.functionalUpdate=y,t.interpolatePath=M,t.invariant=n,t.isPlainObject=w,t.joinPaths=L,t.last=f,t.lazy=function(t){const e=a.lazy(t);return e.preload=async()=>{await t()},e},t.matchByPath=O,t.matchPathname=k,t.matchesContext=Y,t.parsePathname=_,t.parseSearchWith=U,t.partialDeepEqual=b,t.pick=g,t.replaceEqualDeep=v,t.resolvePath=C,t.rootRouteId=A,t.routerContext=Z,t.stringifySearchWith=z,t.trimPath=R,t.trimPathLeft=P,t.trimPathRight=x,t.useLinkProps=Q,t.useMatch=rt,t.useMatchRoute=ot,t.useMatches=et,t.useNavigate=function(t){const e=tt();return a.useCallback((r=>e.navigate({...t,...r})),[])},t.useParams=function(t){const e=tt();return V(e.store,(e=>{const r=f(e.currentMatches)?.params;return t?.track?.(r)??r}),!0),f(e.state.currentMatches)?.params},t.useRoute=function(t){const e=tt().getRoute(t);return n(e),e},t.useRouter=function(t,e){const r=tt();return V(r.store,t,e),r},t.useRouterContext=tt,t.useSearch=function(t){const e=rt(t);return V(e.store,(e=>t?.track?.(e.search)??e.search),!0),e.state.search},t.useStore=V,t.warning=m,Object.defineProperty(t,"__esModule",{value:!0})}));
41
+ */function G(t,e=(t=>t),o){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,o?Q:void 0)}function Q(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let o=0;o<r.length;o++)if(!Object.prototype.hasOwnProperty.call(e,r[o])||!Object.is(t[r[o]],e[r[o]]))return!1;return!0}function X(t){const e=et(),{type:r,children:o,target:a,activeProps:n=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:h,hash:u,search:l,params:d,to:p=".",preload:f,preloadDelay:m,replace:g,style:v,className:w,onClick:S,onFocus:b,onMouseEnter:L,onMouseLeave:E,onTouchStart:P,...x}=t,C=e.buildLink(t);if("external"===C.type){const{href:t}=C;return{href:t}}const{handleClick:R,handleFocus:_,handleEnter:M,handleLeave:k,handleTouchStart:O,isActive:j,next:$}=C,I=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},A=j?y(n,{})??{}:{},T=j?{}:y(i,{})??{};return{...A,...T,...x,href:h?void 0:$.href,onClick:I([S,t=>{s.startTransition?s.startTransition((()=>{R(t)})):R(t)}]),onFocus:I([b,_]),onMouseEnter:I([L,M]),onMouseLeave:I([E,k]),onTouchStart:I([P,O]),target:a,style:{...v,...A.style,...T.style},className:[w,A.className,T.className].filter(Boolean).join(" ")||void 0,...h?{role:"link","aria-disabled":!0}:void 0,"data-status":j?"active":void 0}}const Y=s.forwardRef(((t,e)=>{const r=X(t);return s.createElement("a",a({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))}));const Z=s.createContext(null),tt=s.createContext(null);function et(){const t=s.useContext(tt);return G(t.router.store),t.router}function rt(){return s.useContext(Z)}function ot(t){const e=et(),r=rt()[0],o=t?.from?e.state.currentMatches.find((e=>e.route.id===t?.from)):r;return n(o,t?.from&&t.from),(t?.strict??1)&&n(r.route.id==o?.route.id,(o?.route.id,r.route.id,o?.route.id,o?.route.id)),G(o.store,(e=>t?.track?.(o)??o),t?.shallow),o}function st(){const t=et();return s.useCallback((e=>{const{pending:r,caseSensitive:o,...s}=e;return t.matchRoute(s,{pending:r,caseSensitive:o})}),[])}function at(){const t=rt().slice(1),e=t[0];return e?s.createElement(nt,{matches:t,match:e}):null}function nt({matches:t,match:e}){const r=et();G(e.store,(t=>[t.status,t.error]),!0);const o=s.useCallback((()=>null),[]),a=s.useCallback((t=>{if("error"===t.match.state.status)throw t.match.state.error;if("success"===t.match.state.status)return s.createElement(t.match.component??r.options.defaultComponent??at);if("pending"===t.match.state.status)throw t.match.__loadPromise;n(!1)}),[]),i=e.pendingComponent??r.options.defaultPendingComponent??o,c=e.errorComponent??r.options.defaultErrorComponent,h=e.route.options.wrapInSuspense??1?s.Suspense:it,u=c?ct:it;return s.createElement(Z.Provider,{value:t},s.createElement(h,{fallback:s.createElement(i,null)},s.createElement(u,{key:e.route.id,errorComponent:c,onCatch:()=>{e.id}},s.createElement(a,{match:e}))))}function it(t){return s.createElement(s.Fragment,null,t.children)}class ct extends s.Component{state={error:!1,info:void 0};componentDidCatch(t,e){this.props.onCatch(t,e),console.error(t),this.setState({error:t,info:e})}render(){return s.createElement(ht,a({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function ht(t){const[e,r]=s.useState(t.errorState),o=et(),a=t.errorComponent??ut,n=s.useRef("");return s.useEffect((()=>{e&&o.state.currentLocation.key!==n.current&&r({}),n.current=o.state.currentLocation.key}),[e,o.state.currentLocation.key]),s.useEffect((()=>{t.errorState.error&&r(t.errorState)}),[t.errorState.error]),t.errorState.error&&e.error?s.createElement(a,e):t.children}function ut({error:t}){return s.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},s.createElement("strong",{style:{fontSize:"1.2rem"}},"Something went wrong!"),s.createElement("div",{style:{height:".5rem"}}),s.createElement("div",null,s.createElement("pre",null,t.message?s.createElement("code",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".5rem",color:"red"}},t.message):null)))}t.ErrorComponent=ut,t.Link=Y,t.MatchRoute=function(t){const e=st()(t);return e?"function"==typeof t.children?t.children(e):e?t.children:null:null},t.Navigate=function(t){const e=et();return s.useLayoutEffect((()=>{e.navigate(t)}),[]),null},t.Outlet=at,t.ReactRouter=class extends z{constructor(t){super({...t,loadComponent:async t=>(t.preload&&await t.preload(),t)})}},t.RootRoute=F,t.Route=T,t.RouteMatch=V,t.Router=z,t.RouterProvider=function({router:t,...e}){t.update(e);const r=G(t.store,(t=>t.currentMatches));return s.useEffect(t.mount,[t]),s.createElement(tt.Provider,{value:{router:t}},s.createElement(Z.Provider,{value:[void 0,...r]},s.createElement(ct,{errorComponent:ut,onCatch:()=>{}},s.createElement(at,null))))},t.cleanPath=E,t.createBrowserHistory=l,t.createHashHistory=function(){return l({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=d,t.decode=I,t.defaultFetchServerDataFn=U,t.defaultParseSearch=D,t.defaultStringifySearch=N,t.encode=j,t.functionalUpdate=y,t.interpolatePath=M,t.invariant=n,t.isPlainObject=w,t.isRedirect=K,t.joinPaths=L,t.last=m,t.lazy=function(t){const e=s.lazy(t);return e.preload=async()=>{await t()},e},t.matchByPath=O,t.matchPathname=k,t.matchesContext=Z,t.parsePathname=_,t.parseSearchWith=B,t.partialDeepEqual=b,t.pick=g,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=v,t.resolvePath=R,t.rootRouteId=A,t.routerContext=tt,t.stringifySearchWith=H,t.trimPath=C,t.trimPathLeft=P,t.trimPathRight=x,t.useLinkProps=X,t.useMatch=ot,t.useMatchRoute=st,t.useMatches=rt,t.useNavigate=function(t){const e=et();return s.useCallback((r=>e.navigate({...t,...r})),[])},t.useParams=function(t){const e=et();return G(e.store,(e=>{const r=m(e.currentMatches)?.params;return t?.track?.(r)??r}),!0),m(e.state.currentMatches)?.params},t.useRoute=function(t){const e=et().getRoute(t);return n(e),e},t.useRouter=function(t,e){const r=et();return G(r.store,t,e),r},t.useRouterContext=et,t.useSearch=function(t){const e=ot(t);return G(e.store,(e=>t?.track?.(e.search)??e.search),!0),e.state.search},t.useStore=G,t.warning=i,Object.defineProperty(t,"__esModule",{value:!0})}));
42
42
  //# sourceMappingURL=index.production.js.map