@tanstack/react-router 0.0.1-beta.38 → 0.0.1-beta.39
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/_virtual/_rollupPluginBabelHelpers.js +0 -13
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/index.js +306 -241
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +296 -252
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +87 -56
- package/build/types/index.d.ts +50 -42
- package/build/umd/index.development.js +1368 -858
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +3 -2
- package/src/index.tsx +468 -421
- package/src/uSES/useSyncExternalStore.ts +16 -0
- package/src/uSES/useSyncExternalStoreShim.ts +20 -0
- package/src/uSES/useSyncExternalStoreShimClient.ts +87 -0
- package/src/uSES/useSyncExternalStoreShimServer.ts +20 -0
|
@@ -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")):"function"==typeof define&&define.amd?define(["exports","react","use-sync-external-store/shim"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReactRouter={},t.React,t.shim)}(this,(function(t,e,
|
|
11
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("use-sync-external-store/shim")):"function"==typeof define&&define.amd?define(["exports","react","use-sync-external-store/shim"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ReactRouter={},t.React,t.shim)}(this,(function(t,e,r){"use strict";function n(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var o=n(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 n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},a.apply(this,arguments)}var s,i=void 0,c=null,l=0,u=null,h=class{value;fn;observers=null;sources=null;state;effect;cleanups=null;alwaysUpdate=!1;constructor(t,e){0!=e?(this.fn=t,this.value=void 0,this.state=2,s?s.push(this):console.error("Memos and effects must be wrapped in a createRoot"),this.effect=2==e,this.effect&&this.update()):(this.fn=void 0,this.value=t,this.state=0,this.effect=!1)}get(){return i&&(!c&&i.sources&&i.sources[l]==this?l++:c?c.push(this):c=[this]),this.fn&&this.updateIfNecessary(),this.value}set(t){const e=!u,r="function"==typeof t?t(this.value):t;if((this.value!==r||this.alwaysUpdate)&&this.observers)for(let t=0;t<this.observers.length;t++)this.observers[t].stale(2);return this.value=r,e&&d(),r}stale(t){if(this.state<t&&(0===this.state&&this.effect&&(u?u.push(this):u=[this]),this.state=t,this.observers))for(let t=0;t<this.observers.length;t++)this.observers[t].stale(1)}update(){const t=this.value,e=i,r=c,n=l;i=this,c=null,l=0;try{if(this.cleanups&&(this.cleanups.forEach((t=>t())),this.cleanups=null),this.value=this.fn(),c){if(this.removeParentObservers(l),this.sources&&l>0){this.sources.length=l+c.length;for(let t=0;t<c.length;t++)this.sources[l+t]=c[t]}else this.sources=c;for(let t=l;t<this.sources.length;t++){const e=this.sources[t];e.observers?e.observers.push(this):e.observers=[this]}}else this.sources&&l<this.sources.length&&(this.removeParentObservers(l),this.sources.length=l)}finally{c=r,i=e,l=n}if((t!==this.value||this.alwaysUpdate)&&this.observers)for(let t=0;t<this.observers.length;t++)this.observers[t].state=2;this.state=0}updateIfNecessary(){if(1===this.state)for(const t of this.sources)if(t.updateIfNecessary(),2===this.state)break;2===this.state&&this.update(),this.state=0}removeParentObservers(t){if(this.sources)for(let e=t;e<this.sources.length;e++){const t=this.sources[e],r=t.observers.findIndex((t=>t===this));t.observers[r]=t.observers[t.observers.length-1],t.observers.pop()}}destroy(){this.cleanups&&(this.cleanups.forEach((t=>t())),this.cleanups=null),this.removeParentObservers(0)}};function d(){if(u){for(let t=0;t<u.length;t++)u[t].get();u=null}}function f(t){const e=new h(t,2);return e.get.bind(e)}function p(t){let e=[];return s=e,t(),s=null,()=>{e&&(e.forEach((t=>t.destroy())),e=null)}}function m(t){u=[];let e=t();return d(),e}function v(t){const e=i;i=void 0;try{return t()}finally{i=e}}var g=Symbol("store-raw"),y=Symbol("track"),b=Symbol("store-proxy"),w=Symbol("store-node");function P(t){let e=t[b];if(!e&&(Object.defineProperty(t,b,{value:e=new Proxy(t,I)}),!Array.isArray(t))){const r=Object.keys(t),n=Object.getOwnPropertyDescriptors(t);for(let o=0,a=r.length;o<a;o++){const a=r[o];if(n[a].get){const r=n[a].get.bind(e);Object.defineProperty(t,a,{enumerable:n[a].enumerable,get:r})}}}return e}function E(t){let e;return null!=t&&"object"==typeof t&&(t[b]||!(e=Object.getPrototypeOf(t))||e===Object.prototype||Array.isArray(t))}function _(t,e=new Set){let r,n,o,a;if(r=null!=t&&t[g])return r;if(!E(t)||e.has(t))return t;if(Array.isArray(t)){Object.isFrozen(t)?t=t.slice(0):e.add(t);for(let r=0,a=t.length;r<a;r++)o=t[r],(n=_(o,e))!==o&&(t[r]=n)}else{Object.isFrozen(t)?t=Object.assign({},t):e.add(t);const r=Object.keys(t),s=Object.getOwnPropertyDescriptors(t);for(let i=0,c=r.length;i<c;i++)a=r[i],s[a].get||(o=t[a],(n=_(o,e))!==o&&(t[a]=n))}return t}function M(t){let e=t[w];return e||Object.defineProperty(t,w,{value:e={}}),e}function L(t,e,r){return t[e]||(t[e]=x(r))}function S(t){if(i){const e=M(t);(e._||(e._=x())).get()}}function x(t){const e=new h(t,0);return e.alwaysUpdate=!0,e}var R,A=!1,I={get(t,e,r){if(e===g)return t;if(e===b)return r;if(e===y)return S(t),r;const n=M(t),o=n.hasOwnProperty(e);let a=o?n[e].get():t[e];if(e===w||"__proto__"===e)return a;if(!o){const r=Object.getOwnPropertyDescriptor(t,e);!i||"function"==typeof a&&!t.hasOwnProperty(e)||r&&r.get||(a=L(n,e,a).get())}return E(a)?P(a):a},has(t,e){return e===g||e===b||e===y||e===w||"__proto__"===e||(this.get(t,e,t),e in t)},set:(t,e,r)=>(A&&O(t,e,_(r)),!0),deleteProperty:(t,e)=>(A&&O(t,e,void 0,!0),!0),ownKeys:function(t){return S(t),Reflect.ownKeys(t)},getOwnPropertyDescriptor:function(t,e){const r=Reflect.getOwnPropertyDescriptor(t,e);return r&&!r.get&&r.configurable&&e!==b&&e!==w?(delete r.value,delete r.writable,r.get=()=>t[b][e],r):r}};function O(t,e,r,n=!1){if(!n&&t[e]===r)return;const o=t[e],a=t.length;n?delete t[e]:t[e]=r;const s=M(t);let i;(i=L(s,e,o))&&i.set((()=>r)),Array.isArray(t)&&t.length!==a&&(i=L(s,"length",a))&&i.set(t.length),(i=s._)&&i.set()}function C(t){const e=P(_(t));return[e,t=>{m((()=>{try{A=!0,t(e)}finally{A=!1}}))}]}function k(){return k=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},k.apply(this,arguments)}!function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"}(R||(R={}));var j="beforeunload",D="popstate";function F(t){void 0===t&&(t={});var e=t.window,r=void 0===e?document.defaultView:e,n=r.history;function o(){var t=r.location,e=t.pathname,o=t.search,a=t.hash,s=n.state||{};return[s.idx,{pathname:e,search:o,hash:a,state:s.usr||null,key:s.key||"default"}]}var a=null;r.addEventListener(D,(function(){if(a)h.call(a),a=null;else{var t=R.Pop,e=o(),r=e[0],n=e[1];if(h.length){if(null!=r){var s=c-r;s&&(a={action:t,location:n,retry:function(){g(-1*s)}},g(s))}}else v(t)}}));var s=R.Pop,i=o(),c=i[0],l=i[1],u=U(),h=U();function d(t){return"string"==typeof t?t:z(t)}function f(t,e){return void 0===e&&(e=null),k({pathname:l.pathname,hash:"",search:""},"string"==typeof t?H(t):t,{state:e,key:B()})}function p(t,e){return[{usr:t.state,key:t.key,idx:e},d(t)]}function m(t,e,r){return!h.length||(h.call({action:t,location:e,retry:r}),!1)}function v(t){s=t;var e=o();c=e[0],l=e[1],u.call({action:s,location:l})}function g(t){n.go(t)}null==c&&(c=0,n.replaceState(k({},n.state,{idx:c}),""));var y={get action(){return s},get location(){return l},createHref:d,push:function t(e,o){var a=R.Push,s=f(e,o);if(m(a,s,(function(){t(e,o)}))){var i=p(s,c+1),l=i[0],u=i[1];try{n.pushState(l,"",u)}catch(t){r.location.assign(u)}v(a)}},replace:function t(e,r){var o=R.Replace,a=f(e,r);if(m(o,a,(function(){t(e,r)}))){var s=p(a,c),i=s[0],l=s[1];n.replaceState(i,"",l),v(o)}},go:g,back:function(){g(-1)},forward:function(){g(1)},listen:function(t){return u.push(t)},block:function(t){var e=h.push(t);return 1===h.length&&r.addEventListener(j,$),function(){e(),h.length||r.removeEventListener(j,$)}}};return y}function N(t){void 0===t&&(t={});var e=t,r=e.initialEntries,n=void 0===r?["/"]:r,o=e.initialIndex,a=n.map((function(t){return k({pathname:"/",search:"",hash:"",state:null,key:B()},"string"==typeof t?H(t):t)})),s=T(null==o?a.length-1:o,0,a.length-1),i=R.Pop,c=a[s],l=U(),u=U();function h(t,e){return void 0===e&&(e=null),k({pathname:c.pathname,search:"",hash:""},"string"==typeof t?H(t):t,{state:e,key:B()})}function d(t,e,r){return!u.length||(u.call({action:t,location:e,retry:r}),!1)}function f(t,e){i=t,c=e,l.call({action:i,location:c})}function p(t){var e=T(s+t,0,a.length-1),r=R.Pop,n=a[e];d(r,n,(function(){p(t)}))&&(s=e,f(r,n))}var m={get index(){return s},get action(){return i},get location(){return c},createHref:function(t){return"string"==typeof t?t:z(t)},push:function t(e,r){var n=R.Push,o=h(e,r);d(n,o,(function(){t(e,r)}))&&(s+=1,a.splice(s,a.length,o),f(n,o))},replace:function t(e,r){var n=R.Replace,o=h(e,r);d(n,o,(function(){t(e,r)}))&&(a[s]=o,f(n,o))},go:p,back:function(){p(-1)},forward:function(){p(1)},listen:function(t){return l.push(t)},block:function(t){return u.push(t)}};return m}function T(t,e,r){return Math.min(Math.max(t,e),r)}function $(t){t.preventDefault(),t.returnValue=""}function U(){var t=[];return{get length(){return t.length},push:function(e){return t.push(e),function(){t=t.filter((function(t){return t!==e}))}},call:function(e){t.forEach((function(t){return t&&t(e)}))}}}function B(){return Math.random().toString(36).substr(2,8)}function z(t){var e=t.pathname,r=void 0===e?"/":e,n=t.search,o=void 0===n?"":n,a=t.hash,s=void 0===a?"":a;return o&&"?"!==o&&(r+="?"===o.charAt(0)?o:"?"+o),s&&"#"!==s&&(r+="#"===s.charAt(0)?s:"#"+s),r}function H(t){var e={};if(t){var r=t.indexOf("#");r>=0&&(e.hash=t.substr(r),t=t.substr(0,r));var n=t.indexOf("?");n>=0&&(e.search=t.substr(n),t=t.substr(0,n)),t&&(e.pathname=t)}return e}function G(t,e){if(!t)throw new Error("Invariant failed")}
|
|
12
12
|
/**
|
|
13
13
|
* router-core
|
|
14
14
|
*
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
* LICENSE.md file in the root directory of this source tree.
|
|
19
19
|
*
|
|
20
20
|
* @license MIT
|
|
21
|
-
*/function _(t,e){if(t===e)return t;const a=Array.isArray(t)&&Array.isArray(e);if(a||L(t)&&L(e)){const n=a?t.length:Object.keys(t).length,r=a?e:Object.keys(e),o=r.length,s=a?[]:{};let i=0;for(let n=0;n<o;n++){const o=a?n:r[n];s[o]=_(t[o],e[o]),s[o]===t[o]&&i++}return n===o&&i===n?t:s}return e}function L(t){if(!P(t))return!1;const e=t.constructor;if(void 0===e)return!0;const a=e.prototype;return!!P(a)&&!!a.hasOwnProperty("isPrototypeOf")}function P(t){return"[object Object]"===Object.prototype.toString.call(t)}function w(t){return t[t.length-1]}function E(t,e){if(t){"undefined"!=typeof console&&console.warn(e);try{throw new Error(e)}catch(t){}}return!0}function M(t,e){return"function"==typeof t?t(e):t}function x(t,e){return e.reduce(((e,a)=>(e[a]=t[a],e)),{})}function R(t){return S(t.filter(Boolean).join("/"))}function S(t){return t.replace(/\/{2,}/g,"/")}function I(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function A(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function C(t){return A(I(t))}function k(t,e,a){e=e.replace(new RegExp("^"+t),"/"),a=a.replace(new RegExp("^"+t),"/");let n=O(e);const r=O(a);r.forEach(((t,e)=>{if("/"===t.value)e?e===r.length-1&&n.push(t):n=[t];else if(".."===t.value){var a;n.length>1&&"/"===(null==(a=w(n))?void 0:a.value)&&n.pop(),n.pop()}else{if("."===t.value)return;n.push(t)}}));return S(R([t,...n.map((t=>t.value))]))}function O(t){if(!t)return[];const e=[];if("/"===(t=S(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const a=t.split("/").filter(Boolean);return e.push(...a.map((t=>t.startsWith("*")?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function D(t,e,a){return R(O(t).map((t=>{return"*"!==t.value||a?"param"===t.type?null!=(n=e[t.value.substring(1)])?n:"":t.value:"";var n})))}function j(t,e,a){const n=F(t,e,a);if(!a.to||n)return null!=n?n:{}}function F(t,e,a){var n;if(!e.startsWith(t))return;const r=O(e="/"!=t?e.substring(t.length):e),o=O(""+(null!=(n=a.to)?n:"*")),s={};return(()=>{for(let t=0;t<Math.max(r.length,o.length);t++){const e=r[t],n=o[t],i=t===o.length-1,c=t===r.length-1;if(n){if("wildcard"===n.type)return!(null==e||!e.value)&&(s["*"]=R(r.slice(t).map((t=>t.value))),!0);if("pathname"===n.type){if("/"===n.value&&(null==e||!e.value))return!0;if(e)if(a.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("/"===(null==e?void 0:e.value))return!1;"$"!==e.value.charAt(0)&&(s[n.value.substring(1)]=e.value)}}if(i&&!c)return!!a.fuzzy}return!0})()?s:void 0}function T(t,e){var a,n,r,o="";for(a in t)if(void 0!==(r=t[a]))if(Array.isArray(r))for(n=0;n<r.length;n++)o&&(o+="&"),o+=encodeURIComponent(a)+"="+encodeURIComponent(r[n]);else o&&(o+="&"),o+=encodeURIComponent(a)+"="+encodeURIComponent(r);return(e||"")+o}function N(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function B(t){for(var e,a,n={},r=t.split("&");e=r.shift();)void 0!==n[a=(e=e.split("=")).shift()]?n[a]=[].concat(n[a],N(e.shift())):n[a]=N(e.shift());return n}function U(){return U=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},U.apply(this,arguments)}function H(t,e,a,n){const{id:r,routeId:o,path:s,fullPath:i}=t,c=n.state.actions[r]||(n.state.actions[r]={submissions:[],submit:async(t,e)=>{var a;if(!u)return;const r=null==(a=null==e?void 0:e.invalidate)||a;null!=e&&e.multi||(c.submissions=c.submissions.filter((t=>t.isMulti)));const o={submittedAt:Date.now(),status:"pending",submission:t,isMulti:!(null==e||!e.multi)};c.current=o,c.latest=o,c.submissions.push(o),n.notify();try{const e=await(null==u.options.action?void 0:u.options.action(t));return o.data=e,r&&(n.invalidateRoute({to:".",fromCurrent:!0}),await n.reload()),o.status="success",e}catch(t){console.error(t),o.error=t,o.status="error"}finally{n.notify()}}},n.state.actions[r]),l=n.state.loaders[r]||(n.state.loaders[r]={pending:[],fetch:async t=>{if(!u)return;const e={loadedAt:Date.now(),loaderContext:t};l.current=e,l.latest=e,l.pending.push(e),n.notify();try{return await(null==u.options.loader?void 0:u.options.loader(t))}finally{l.pending=l.pending.filter((t=>t!==e)),n.notify()}}},n.state.loaders[r]);let u={routeInfo:void 0,routeId:r,routeRouteId:o,routePath:s,fullPath:i,options:e,router:n,childRoutes:void 0,parentRoute:a,action:c,loader:l,buildLink:t=>n.buildLink(U({},t,{from:i})),navigate:t=>n.navigate(U({},t,{from:i})),matchRoute:(t,e)=>n.matchRoute(U({},t,{from:i}),e)};return null==n.options.createRoute||n.options.createRoute({router:n,route:u}),u}const z="__root__",G=["component","errorComponent","pendingComponent"];function W(t,e,a){const n=U({},e,a,{router:t,routeSearch:{},search:{},childMatches:[],status:"idle",routeLoaderData:{},loaderData:{},isFetching:!1,isInvalid:!1,invalidAt:1/0,getIsInvalid:()=>{const t=Date.now();return n.isInvalid||n.invalidAt<t},__:{abortController:new AbortController,latestId:"",resolve:()=>{},notify:()=>{n.__.resolve(),n.router.notify()},validate:()=>{var e,a;const r=null!=(e=null==(a=n.parentMatch)?void 0:a.search)?e:t.state.currentLocation.search;try{var o;const t=n.routeSearch,e="object"==typeof n.options.validateSearch?n.options.validateSearch.parse:n.options.validateSearch;let a=_(t,null!=(o=null==e?void 0:e(r))?o:{});t!==a&&(n.isInvalid=!0),n.routeSearch=a,n.search=_(r,U({},r,a)),G.map((async t=>{const e=n.options[t];"function"!=typeof n.__[t]&&(n.__[t]=e)}))}catch(t){console.error(t);const e=new Error("Invalid search params found",{cause:t});return e.code="INVALID_SEARCH_PARAMS",n.status="error",void(n.error=e)}}},cancel:()=>{var t;null==(t=n.__.abortController)||t.abort()},invalidate:()=>{n.isInvalid=!0},hasLoaders:()=>!(!e.options.loader&&!G.some((t=>{var a;return null==(a=e.options[t])?void 0:a.preload}))),load:async e=>{const a=Date.now(),r=null!=e&&e.preload?Math.max(null==e?void 0:e.maxAge,null==e?void 0:e.gcMaxAge):0;if(null!=e&&e.preload&&r>0){if(t.state.currentMatches.find((t=>t.matchId===n.matchId)))return;t.matchCache[n.matchId]={gc:a+e.gcMaxAge,match:n}}if("success"===n.status&&n.getIsInvalid()||"error"===n.status||"idle"===n.status){const t=null!=e&&e.preload?null==e?void 0:e.maxAge:void 0;await n.fetch({maxAge:t})}},fetch:async e=>{const a=""+Date.now()+Math.random();n.__.latestId=a;const r=async()=>{if(a!==n.__.latestId)return new Promise((()=>{}))};"idle"===n.status&&(n.status="loading"),n.isInvalid=!1,n.__.loadPromise=new Promise((async a=>{n.isFetching=!0,n.__.resolve=a,n.__.componentsPromise=(async()=>{await Promise.all(G.map((async e=>{var a;const r=n.options[e];null!=(a=n.__[e])&&a.preload&&(n.__[e]=await t.options.loadComponent(r))})))})(),n.__.dataPromise=Promise.resolve().then((async()=>{try{var a,o,s;if(n.options.loader){const e=await t.loadMatchData(n);await r(),n.routeLoaderData=_(n.routeLoaderData,e)}return n.error=void 0,n.status="success",n.updatedAt=Date.now(),n.invalidAt=n.updatedAt+(null!=(a=null!=(o=null!=(s=null==e?void 0:e.maxAge)?s:n.options.loaderMaxAge)?o:t.options.defaultLoaderMaxAge)?a:0),n.routeLoaderData}catch(t){throw await r(),n.error=t,n.status="error",n.updatedAt=Date.now(),t}}));const o=async()=>{await r(),n.isFetching=!1,delete n.__.loadPromise,n.__.notify()};try{await Promise.all([n.__.componentsPromise,n.__.dataPromise.catch((()=>{}))]),o()}catch(t){o()}})),await n.__.loadPromise,await r()}});return n.hasLoaders()||(n.status="success"),n}const q=V(JSON.parse),K=$(JSON.stringify);function V(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let a=B(e);for(let e in a){const n=a[e];if("string"==typeof n)try{a[e]=t(n)}catch(t){}}return a}}function $(t){return e=>{(e=U({},e))&&Object.keys(e).forEach((a=>{const n=e[a];if(void 0===n||void 0===n)delete e[a];else if(n&&"object"==typeof n&&null!==n)try{e[a]=t(n)}catch(t){}}));const a=T(e).toString();return a?"?"+a:""}}var J;const X="undefined"==typeof window||!(null!=(J=window.document)&&J.createElement);function Q(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],actions:{},loaders:{},lastUpdated:Date.now(),isFetching:!1,isPreloading:!1}}function Y(t){var e,a;const n=(null==t?void 0:t.history)||(X?d():h()),r=U({defaultLoaderGcMaxAge:3e5,defaultLoaderMaxAge:0,defaultPreloadMaxAge:2e3,defaultPreloadDelay:50,context:void 0},t,{stringifySearch:null!=(e=null==t?void 0:t.stringifySearch)?e:K,parseSearch:null!=(a=null==t?void 0:t.parseSearch)?a:q});let o={types:void 0,history:n,options:r,listeners:[],basepath:"",routeTree:void 0,routesById:{},resolveNavigation:()=>{},matchCache:{},state:Q(),reset:()=>{o.state=Q(),o.notify()},startedLoadingAt:Date.now(),subscribe:t=>(o.listeners.push(t),()=>{o.listeners=o.listeners.filter((e=>e!==t))}),getRoute:t=>o.routesById[t],notify:()=>{const t="loading"===o.state.status||o.state.currentMatches.some((t=>t.isFetching)),e=Object.values(o.matchCache).some((t=>t.match.isFetching&&!o.state.currentMatches.find((e=>e.matchId===t.match.matchId))));o.state.isFetching===t&&o.state.isPreloading===e||(o.state=U({},o.state,{isFetching:t,isPreloading:e})),Z(o.state.currentMatches),o.listeners.forEach((t=>t(o)))},dehydrate:()=>({state:U({},x(o.state,["latestLocation","currentLocation","status","lastUpdated"]),{currentMatches:o.state.currentMatches.map((t=>x(t,["matchId","status","routeLoaderData","loaderData","isInvalid","invalidAt"])))}),context:o.options.context}),hydrate:t=>{o.state.latestLocation=t.state.latestLocation,o.state.currentLocation=t.state.currentLocation,o.options.context=t.context;const e=o.matchRoutes(o.state.latestLocation.pathname,{strictParseParams:!0});e.forEach(((e,a)=>{const n=t.state.currentMatches[a];b(n),Object.assign(e,n)})),e.forEach((t=>t.__.validate())),o.state=U({},o.state,t,{currentMatches:e})},mount:()=>{o.state.currentMatches.length||o.load();const t=o.history.listen((t=>{o.load(o.__.parseLocation(t.location,o.state.latestLocation))}));return!X&&window.addEventListener&&(window.addEventListener("visibilitychange",o.onFocus,!1),window.addEventListener("focus",o.onFocus,!1)),()=>{t(),!X&&window.removeEventListener&&(window.removeEventListener("visibilitychange",o.onFocus),window.removeEventListener("focus",o.onFocus))}},onFocus:()=>{o.load()},update:t=>{var e;const a=(null==t?void 0:t.history)!==o.history;o.state.latestLocation&&!a||(null!=t&&t.history&&(o.history=t.history),o.state.latestLocation=o.__.parseLocation(o.history.location),o.state.currentLocation=o.state.latestLocation),Object.assign(o.options,t);const{basepath:n,routeConfig:r}=o.options;return o.basepath="/"+(null!=(e=C(null!=n?n:""))?e:""),r&&(o.routesById={},o.routeTree=o.__.buildRouteTree(r)),o},cancelMatches:()=>{var t;[...o.state.currentMatches,...null!=(t=o.state.pendingMatches)?t:[]].forEach((t=>{t.cancel()}))},load:async t=>{const e=Math.random();o.startedLoadingAt=e,t&&(o.state.latestLocation=t),o.cancelMatches();const a=o.matchRoutes(o.state.latestLocation.pathname,{strictParseParams:!0});"undefined"!=typeof document?o.state=U({},o.state,{status:"loading",pendingMatches:a,pendingLocation:o.state.latestLocation}):o.state=U({},o.state,{status:"loading",currentMatches:a,currentLocation:o.state.latestLocation}),o.notify();try{await o.loadMatches(a)}catch(t){console.log(t),b(!1)}if(o.startedLoadingAt!==e)return o.navigationPromise;const n=o.state.currentMatches,r=[],s=[];n.forEach((t=>{a.find((e=>e.matchId===t.matchId))?s.push(t):r.push(t)}));const i=a.filter((t=>!n.find((e=>e.matchId===t.matchId)))),c=Date.now();r.forEach((t=>{var e,a,n,r;null==t.__.onExit||t.__.onExit({params:t.params,search:t.routeSearch}),"error"!==t.status||t.isFetching||(t.status="idle",t.error=void 0);const s=Math.max(null!=(e=null!=(a=t.options.loaderGcMaxAge)?a:o.options.defaultLoaderGcMaxAge)?e:0,null!=(n=null!=(r=t.options.loaderMaxAge)?r:o.options.defaultLoaderMaxAge)?n:0);s>0&&(o.matchCache[t.matchId]={gc:s==1/0?Number.MAX_SAFE_INTEGER:c+s,match:t})})),s.forEach((t=>{null==t.options.onTransition||t.options.onTransition({params:t.params,search:t.routeSearch})})),i.forEach((t=>{t.__.onExit=null==t.options.onLoaded?void 0:t.options.onLoaded({params:t.params,search:t.search}),delete o.matchCache[t.matchId]})),o.startedLoadingAt===e&&(a.forEach((t=>{t.action&&(t.action.current=void 0,t.action.submissions=[])})),o.state=U({},o.state,{status:"idle",currentLocation:o.state.latestLocation,currentMatches:a,pendingLocation:void 0,pendingMatches:void 0}),o.notify(),o.resolveNavigation())},cleanMatchCache:()=>{const t=Date.now();Object.keys(o.matchCache).forEach((e=>{const a=o.matchCache[e];"loading"!==a.match.status&&(a.gc>0&&a.gc>t||delete o.matchCache[e])}))},loadRoute:async function(t){void 0===t&&(t=o.state.latestLocation);const e=o.buildNext(t),a=o.matchRoutes(e.pathname,{strictParseParams:!0});return await o.loadMatches(a),a},preloadRoute:async function(t,e){var a,n,r,s,i,c;void 0===t&&(t=o.state.latestLocation);const l=o.buildNext(t),u=o.matchRoutes(l.pathname,{strictParseParams:!0});return await o.loadMatches(u,{preload:!0,maxAge:null!=(a=null!=(n=null!=(r=e.maxAge)?r:o.options.defaultPreloadMaxAge)?n:o.options.defaultLoaderMaxAge)?a:0,gcMaxAge:null!=(s=null!=(i=null!=(c=e.gcMaxAge)?c:o.options.defaultPreloadGcMaxAge)?i:o.options.defaultLoaderGcMaxAge)?s:0}),u},matchRoutes:(t,e)=>{var a;o.cleanMatchCache();const n=[];if(!o.routeTree)return n;const r=[...o.state.currentMatches,...null!=(a=o.state.pendingMatches)?a:[]],s=async a=>{var i,c,l;const u=w(n);let h=null!=(i=null==u?void 0:u.params)?i:{};const d=null!=(c=null==o.options.filterRoutes?void 0:o.options.filterRoutes(a))?c:a;let f=[];const p=(a,n)=>(n.some((n=>{var r,s,i;if(!n.routePath&&null!=(r=n.childRoutes)&&r.length)return p([...f,n],n.childRoutes);const c=!!("/"!==n.routePath||null!=(s=n.childRoutes)&&s.length),l=j(o.basepath,t,{to:n.fullPath,fuzzy:c,caseSensitive:null!=(i=n.options.caseSensitive)?i:o.options.caseSensitive});if(l){let t;try{var u;t=null!=(u=null==n.options.parseParams?void 0:n.options.parseParams(l))?u:l}catch(t){if(null!=e&&e.strictParseParams)throw t}h=U({},h,t)}return l&&(f=[...a,n]),!!f.length})),!!f.length);if(p([],d),!f.length)return;f.forEach((t=>{var e;const a=D(t.routePath,h),s=D(t.routeId,h,!0),i=r.find((t=>t.matchId===s))||(null==(e=o.matchCache[s])?void 0:e.match)||W(o,t,{parentMatch:u,matchId:s,params:h,pathname:R([o.basepath,a])});n.push(i)}));const m=w(f);null!=(l=m.childRoutes)&&l.length&&s(m.childRoutes)};return s([o.routeTree]),Z(n),n},loadMatches:async(t,e)=>{t.forEach((async t=>{t.__.validate()})),await Promise.all(t.map((async t=>{try{await(null==t.options.beforeLoad?void 0:t.options.beforeLoad({router:o,match:t}))}catch(a){throw null!=e&&e.preload||null==t.options.onLoadError||t.options.onLoadError(a),a}})));const a=t.map((async t=>{var a;const n=t.search;null!=(a=n.__data)&&a.matchId&&n.__data.matchId!==t.matchId||(t.load(e),"success"!==t.status&&t.__.loadPromise&&await t.__.loadPromise)}));o.notify(),await Promise.all(a)},loadMatchData:async t=>{var e;if(X||!o.options.useServerData)return null!=(e=await(null==t.options.loader?void 0:t.options.loader({params:t.params,search:t.routeSearch,signal:t.__.abortController.signal})))?e:{};{const e=o.buildNext({to:".",search:e=>U({},null!=e?e:{},{__data:{matchId:t.matchId}})}),a=await fetch(e.href,{method:"GET"});if(a.ok)return a.json();throw new Error("Failed to fetch match data")}},invalidateRoute:t=>{var e;const a=o.buildNext(t),n=o.matchRoutes(a.pathname).map((t=>t.matchId));[...o.state.currentMatches,...null!=(e=o.state.pendingMatches)?e:[]].forEach((t=>{n.includes(t.matchId)&&t.invalidate()}))},reload:()=>o.__.navigate({fromCurrent:!0,replace:!0,search:!0}),resolvePath:(t,e)=>k(o.basepath,t,S(e)),matchRoute:(t,e)=>{var a;t=U({},t,{to:t.to?o.resolvePath(null!=(a=t.from)?a:"",t.to):void 0});const n=o.buildNext(t);return null!=e&&e.pending?!!o.state.pendingLocation&&!!j(o.basepath,o.state.pendingLocation.pathname,U({},e,{to:n.pathname})):!!j(o.basepath,o.state.currentLocation.pathname,U({},e,{to:n.pathname}))},navigate:async t=>{let{from:e,to:a=".",search:n,hash:r,replace:s,params:i}=t;const c=String(a),l=String(e);let u;try{new URL(""+c),u=!0}catch(t){}return b(!u),o.__.navigate({from:l,to:c,search:n,hash:r,replace:s,params:i})},buildLink:t=>{var e,a;let{from:n,to:r=".",search:s,params:i,hash:c,target:l,replace:u,activeOptions:h,preload:d,preloadMaxAge:f,preloadGcMaxAge:p,preloadDelay:m,disabled:v}=t;try{return new URL(""+r),{type:"external",href:r}}catch(t){}const g={from:n,to:r,search:s,params:i,hash:c,replace:u},y=o.buildNext(g);d=null!=(e=d)?e:o.options.defaultPreload;const b=null!=(a=null!=m?m:o.options.defaultPreloadDelay)?a:0,_=o.state.currentLocation.pathname===y.pathname,L=o.state.currentLocation.pathname.split("/"),P=y.pathname.split("/").every(((t,e)=>t===L[e])),w=o.state.currentLocation.hash===y.hash,E=null!=h&&h.exact?_:P,M=null==h||!h.includeHash||w;return{type:"internal",next:y,handleFocus:t=>{d&&o.preloadRoute(g,{maxAge:f,gcMaxAge:p}).catch((t=>{console.log(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{v||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||l&&"_self"!==l||0!==t.button||(t.preventDefault(),!_||s||c||o.invalidateRoute(g),o.__.navigate(g))},handleEnter:t=>{const e=t.target||{};if(d){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,o.preloadRoute(g,{maxAge:f,gcMaxAge:p}).catch((t=>{console.log(t),console.warn("Error preloading route! ☝️")}))}),b)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},isActive:E&&M,disabled:v}},buildNext:t=>{const e=o.__.buildLocation(t),a=o.matchRoutes(e.pathname),n=a.map((t=>{var e;return null!=(e=t.options.preSearchFilters)?e:[]})).flat().filter(Boolean),r=a.map((t=>{var e;return null!=(e=t.options.postSearchFilters)?e:[]})).flat().filter(Boolean);return o.__.buildLocation(U({},t,{__preSearchFilters:n,__postSearchFilters:r}))},__:{buildRouteTree:t=>{const e=(t,a)=>t.map((t=>{const n=H(t,t.options,a,o);if(o.routesById[n.routeId])throw new Error;o.routesById[n.routeId]=n;const r=t.children;return n.childRoutes=null!=r&&r.length?e(r,n):void 0,n}));return e([t])[0]},parseLocation:(t,e)=>{var a;const n=o.options.parseSearch(t.search);return{pathname:t.pathname,searchStr:t.search,search:_(null==e?void 0:e.search,n),hash:null!=(a=t.hash.split("#").reverse()[0])?a:"",href:""+t.pathname+t.search+t.hash,state:t.state,key:t.key}},navigate:t=>{const e=o.buildNext(t);return o.__.commitLocation(e,t.replace)},buildLocation:function(t){var e,a,n,r,s,i,c,l,u;void 0===t&&(t={});const h=t.fromCurrent?o.state.latestLocation.pathname:null!=(e=t.from)?e:o.state.latestLocation.pathname;let d=k(null!=(a=o.basepath)?a:"/",h,""+(null!=(n=t.to)?n:"."));const f=o.matchRoutes(o.state.latestLocation.pathname,{strictParseParams:!0}),p=o.matchRoutes(d),m=U({},null==(r=w(f))?void 0:r.params);let v=!0===(null==(s=t.params)||s)?m:M(t.params,m);v&&p.map((t=>t.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},v,t(v))})),d=D(d,null!=v?v:{});const g=null!=(i=t.__preSearchFilters)&&i.length?t.__preSearchFilters.reduce(((t,e)=>e(t)),o.state.latestLocation.search):o.state.latestLocation.search,y=!0===t.search?g:t.search?null!=(c=M(t.search,g))?c:{}:null!=(l=t.__preSearchFilters)&&l.length?g:{},b=null!=(u=t.__postSearchFilters)&&u.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),y):y,L=_(o.state.latestLocation.search,b),P=o.options.stringifySearch(L);let E=!0===t.hash?o.state.latestLocation.hash:M(t.hash,o.state.latestLocation.hash);return E=E?"#"+E:"",{pathname:d,search:L,searchStr:P,state:o.state.latestLocation.state,hash:E,href:""+d+P+E,key:t.key}},commitLocation:(t,e)=>{const a=""+Date.now()+Math.random();o.navigateTimeout&&clearTimeout(o.navigateTimeout);let r="replace";e||(r="push");return o.__.parseLocation(n.location).href===t.href&&!t.key&&(r="replace"),"replace"===r?n.replace({pathname:t.pathname,hash:t.hash,search:t.searchStr},U({id:a},t.state)):n.push({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:a}),o.navigationPromise=new Promise((t=>{const e=o.resolveNavigation;o.resolveNavigation=()=>{e(),t(),delete o.navigationPromise}})),o.navigationPromise}}};return o.update(t),null==o.options.createRouter||o.options.createRouter(o),o}function Z(t){t.forEach(((e,a)=>{const n=t[a-1];n&&(e.loaderData=_(e.loaderData,U({},n.loaderData,e.routeLoaderData)))}))}const tt=["type","children","target","activeProps","inactiveProps","activeOptions","disabled","hash","search","params","to","preload","preloadDelay","preloadMaxAge","replace","style","className","onClick","onFocus","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd"],et=["pending","caseSensitive","children"],at=["router"];const nt=o.createContext(null),rt=o.createContext(null);function ot(t){return o.createElement(nt.Provider,t)}const st=t=>{a.useSyncExternalStore((e=>t.subscribe((()=>e()))),(()=>t.state),(()=>t.state))};function it(){const t=o.useContext(rt);return E(!t,"useRouter must be used inside a <Router> component!"),st(t.router),t.router}function ct(){return o.useContext(nt)}function lt(){const t=ct()[0];return b(t),t}function ut(){var t,e,a;const n=it(),r=ct().slice(1),s=r[0],i=o.useCallback((()=>null),[]);if(!s)return null;const c=null!=(t=null!=(e=s.__.pendingComponent)?e:n.options.defaultPendingComponent)?t:i,l=null!=(a=s.__.errorComponent)?a:n.options.defaultErrorComponent;return o.createElement(ot,{value:r},o.createElement(o.Suspense,{fallback:o.createElement(c,null)},o.createElement(ht,{key:s.routeId,errorComponent:l,match:s},(()=>{if("error"===s.status)throw s.error;var t,e;if("success"===s.status)return o.createElement(null!=(t=null!=(e=s.__.component)?e:n.options.defaultComponent)?t:ut);throw s.__.loadPromise})())))}class ht extends o.Component{constructor(){super(...arguments),this.state={error:!1,info:void 0}}componentDidCatch(t,e){console.error("Error in route match: "+this.props.match.matchId),console.error(t),this.setState({error:t,info:e})}render(){return o.createElement(dt,s({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function dt(t){var e;const[a,n]=o.useState(t.errorState),r=it(),s=null!=(e=t.errorComponent)?e:ft;return o.useEffect((()=>{if(a){let t=r.state.currentLocation.key;return r.subscribe((()=>{r.state.currentLocation.key!==t&&(t=r.state.currentLocation.key,n({}))}))}}),[a]),o.useEffect((()=>{t.errorState.error&&n(t.errorState),t.reset()}),[t.errorState.error]),a.error?o.createElement(s,a):t.children}function ft(t){let{error:e}=t;return o.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},o.createElement("strong",{style:{fontSize:"1.2rem"}},"Something went wrong!"),o.createElement("div",{style:{height:".5rem"}}),o.createElement("div",null,o.createElement("pre",null,e.message?o.createElement("code",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".5rem",color:"red"}},e.message):null)))}function pt(t,e){const a=it();o.useEffect((()=>{if(!e)return;let n=a.history.block((e=>{window.confirm(t)?(n(),e.retry()):a.state.currentLocation.pathname=window.location.pathname}));return n}),[e,t])}t.DefaultErrorBoundary=ft,t.Link=function(t){const e=it();return o.createElement(e.Link,t)},t.MatchRoute=function(t){const e=it();return o.createElement(e.MatchRoute,t)},t.MatchesProvider=ot,t.Outlet=ut,t.Prompt=function(t){let{message:e,when:a,children:n}=t;return pt(e,null==a||a),null!=n?n:null},t.RouterProvider=function(t){let{router:e}=t,a=i(t,at);return e.update(a),st(e),o.useEffect((()=>e.mount()),[e]),o.createElement(o.Fragment,null,o.createElement(rt.Provider,{value:{router:e}},o.createElement(ot,{value:[void 0,...e.state.currentMatches]},o.createElement(ut,null))))},t.cleanPath=S,t.createBrowserHistory=h,t.createHashHistory=function(t){void 0===t&&(t={});var e=t.window,a=void 0===e?document.defaultView:e,n=a.history;function o(){var t=y(a.location.hash.substr(1)),e=t.pathname,r=void 0===e?"/":e,o=t.search,s=void 0===o?"":o,i=t.hash,c=void 0===i?"":i,l=n.state||{};return[l.idx,{pathname:r,search:s,hash:c,state:l.usr||null,key:l.key||"default"}]}var s=null;function i(){if(s)L.call(s),s=null;else{var t=r.Pop,e=o(),a=e[0],n=e[1];if(L.length){if(null!=a){var i=f-a;i&&(s={action:t,location:n,retry:function(){R(-1*i)}},R(i))}}else x(t)}}a.addEventListener(u,i),a.addEventListener("hashchange",(function(){g(o()[1])!==g(b)&&i()}));var h=r.Pop,d=o(),f=d[0],b=d[1],_=m(),L=m();function P(t){return function(){var t=document.querySelector("base"),e="";if(t&&t.getAttribute("href")){var n=a.location.href,r=n.indexOf("#");e=-1===r?n:n.slice(0,r)}return e}()+"#"+("string"==typeof t?t:g(t))}function w(t,e){return void 0===e&&(e=null),c({pathname:b.pathname,hash:"",search:""},"string"==typeof t?y(t):t,{state:e,key:v()})}function E(t,e){return[{usr:t.state,key:t.key,idx:e},P(t)]}function M(t,e,a){return!L.length||(L.call({action:t,location:e,retry:a}),!1)}function x(t){h=t;var e=o();f=e[0],b=e[1],_.call({action:h,location:b})}function R(t){n.go(t)}null==f&&(f=0,n.replaceState(c({},n.state,{idx:f}),""));var S={get action(){return h},get location(){return b},createHref:P,push:function t(e,o){var s=r.Push,i=w(e,o);if(M(s,i,(function(){t(e,o)}))){var c=E(i,f+1),l=c[0],u=c[1];try{n.pushState(l,"",u)}catch(t){a.location.assign(u)}x(s)}},replace:function t(e,a){var o=r.Replace,s=w(e,a);if(M(o,s,(function(){t(e,a)}))){var i=E(s,f),c=i[0],l=i[1];n.replaceState(c,"",l),x(o)}},go:R,back:function(){R(-1)},forward:function(){R(1)},listen:function(t){return _.push(t)},block:function(t){var e=L.push(t);return 1===L.length&&a.addEventListener(l,p),function(){e(),L.length||a.removeEventListener(l,p)}}};return S},t.createMemoryHistory=d,t.createReactRouter=function(t){const e=(t,e)=>({useRoute:function(a){void 0===a&&(a=".");const n=e.resolvePath(t.routeId,a),r=e.getRoute(n);return st(e),b(r),r},linkProps:e=>{var a,n;const{target:r,activeProps:c=(()=>({className:"active"})),inactiveProps:l=(()=>({})),disabled:u,style:h,className:d,onClick:f,onFocus:p,onMouseEnter:m,onMouseLeave:v}=e,g=i(e,tt),y=t.buildLink(e);if("external"===y.type){const{href:t}=y;return{href:t}}const{handleClick:b,handleFocus:_,handleEnter:L,handleLeave:P,isActive:w,next:E}=y,x=t=>e=>{e.persist&&e.persist(),t.forEach((t=>{e.defaultPrevented||t&&t(e)}))},R=w&&null!=(a=M(c,{}))?a:{},S=w?{}:null!=(n=M(l,{}))?n:{};return s({},R,S,g,{href:u?void 0:E.href,onClick:x([t=>{o.startTransition?o.startTransition((()=>{b(t)})):b(t)},f]),onFocus:x([_,p]),onMouseEnter:x([L,m]),onMouseLeave:x([P,v]),target:r,style:s({},h,R.style,S.style),className:[d,R.className,S.className].filter(Boolean).join(" ")||void 0},u?{role:"link","aria-disabled":!0}:void 0,{"data-status":w?"active":void 0})},Link:o.forwardRef(((a,n)=>{const r=t.linkProps(a);return st(e),o.createElement("a",s({ref:n},r,{children:"function"==typeof a.children?a.children({isActive:"active"===r["data-status"]}):a.children}))})),MatchRoute:e=>{const{pending:a,caseSensitive:n}=e,r=i(e,et),o=t.matchRoute(r,{pending:a,caseSensitive:n});return o?"function"==typeof e.children?e.children(o):e.children:null}}),a=Y(s({},t,{createRouter:t=>{const a={useState:()=>(st(t),t.state),useMatch:(e,a)=>{var n;st(t);const r=lt(),o=t.state.currentMatches.find((t=>t.routeId===e));return(null==(n=null==a?void 0:a.strict)||n)&&(b(o),b(r.routeId==(null==o?void 0:o.routeId),(null==o||o.routeId,r.routeId,null==o||o.routeId,null==o||o.routeId))),o}},n=e(t.getRoute(z),t);Object.assign(t,a,n)},createRoute:t=>{let{router:a,route:n}=t;const r=e(n,a);Object.assign(n,r)},loadComponent:async t=>(t.preload&&"undefined"!=typeof document&&t.preload(),t)}));return a},t.createRoute=H,t.createRouteConfig=function t(e,a,n,r,o){void 0===e&&(e={}),void 0===n&&(n=!0),n&&(e.path=z),r===z&&(r="");let s=n?z:e.path;s&&"/"!==s&&(s=C(s));const i=s||e.id;let c=R([r,i]);s===z&&(s="/"),c!==z&&(c=R(["/",c]));const l=c===z?"/":A(R([o,s]));return{id:c,routeId:i,path:s,fullPath:l,options:e,children:a,addChildren:a=>t(e,a,!1,r,o),createRoute:e=>t(e,void 0,!1,c,l),generate:()=>{b(!1)}}},t.createRouteMatch=W,t.createRouter=Y,t.decode=B,t.defaultParseSearch=q,t.defaultStringifySearch=K,t.encode=T,t.functionalUpdate=M,t.interpolatePath=D,t.invariant=b,t.joinPaths=R,t.last=w,t.lazy=function(t){const e=o.lazy(t);let a,n;const r=o.forwardRef(((t,a)=>{const r=o.useRef(n||e);return o.createElement(r.current,s({},a?{ref:a}:{},t))}));return r.preload=()=>(a||(a=t().then((t=>(n=t.default,n)))),a),r},t.linkProps=function(t){return it().linkProps(t)},t.matchByPath=F,t.matchPathname=j,t.matchesContext=nt,t.parsePathname=O,t.parseSearchWith=V,t.pick=x,t.replaceEqualDeep=_,t.resolvePath=k,t.rootRouteId=z,t.routerContext=rt,t.stringifySearchWith=$,t.trimPath=C,t.trimPathLeft=I,t.trimPathRight=A,t.useMatch=function(t,e){return it().useMatch(t,e)},t.useMatches=ct,t.useNearestMatch=lt,t.useParams=function(){var t;return null==(t=w(it().state.currentMatches))?void 0:t.params},t.usePrompt=pt,t.useRoute=function(t){return it().useRoute(t)},t.useRouter=it,t.useSearch=function(){return it().state.currentLocation.search},t.warning=E,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
21
|
+
*/function K(t){return t[t.length-1]}function W(t,e){if(t){"undefined"!=typeof console&&console.warn(e);try{throw new Error(e)}catch{}}return!0}function V(t,e){return"function"==typeof t?t(e):t}function q(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function J(t){return X(t.filter(Boolean).join("/"))}function X(t){return t.replace(/\/{2,}/g,"/")}function Q(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function Y(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function Z(t){return Y(Q(t))}function tt(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let n=et(e);const o=et(r);o.forEach(((t,e)=>{if("/"===t.value)e?e===o.length-1&&n.push(t):n=[t];else if(".."===t.value){var r;n.length>1&&"/"===(null==(r=K(n))?void 0:r.value)&&n.pop(),n.pop()}else{if("."===t.value)return;n.push(t)}}));return X(J([t,...n.map((t=>t.value))]))}function et(t){if(!t)return[];const e=[];if("/"===(t=X(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.startsWith("*")?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function rt(t,e,r){return J(et(t).map((t=>"*"!==t.value||r?"param"===t.type?e[t.value.substring(1)]??"":t.value:"")))}function nt(t,e,r){const n=ot(t,e,r);if(!r.to||n)return n??{}}function ot(t,e,r){if(!e.startsWith(t))return;const n=et(e="/"!=t?e.substring(t.length):e),o=et(`${r.to??"*"}`),a={};return(()=>{for(let t=0;t<Math.max(n.length,o.length);t++){const e=n[t],s=o[t],i=t===o.length-1,c=t===n.length-1;if(s){if("wildcard"===s.type)return!(null==e||!e.value)&&(a["*"]=J(n.slice(t).map((t=>t.value))),!0);if("pathname"===s.type){if("/"===s.value&&(null==e||!e.value))return!0;if(e)if(r.caseSensitive){if(s.value!==e.value)return!1}else if(s.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===s.type){if("/"===(null==e?void 0:e.value))return!1;"$"!==e.value.charAt(0)&&(a[s.value.substring(1)]=e.value)}}if(i&&!c)return!!r.fuzzy}return!0})()?a:void 0}function at(t,e){var r,n,o,a="";for(r in t)if(void 0!==(o=t[r]))if(Array.isArray(o))for(n=0;n<o.length;n++)a&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(o[n]);else a&&(a+="&"),a+=encodeURIComponent(r)+"="+encodeURIComponent(o);return(e||"")+a}function st(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function it(t){for(var e,r,n={},o=t.split("&");e=o.shift();)void 0!==n[r=(e=e.split("=")).shift()]?n[r]=[].concat(n[r],st(e.shift())):n[r]=st(e.shift());return n}function ct(t,e,r,n,o){const{id:a,routeId:s,path:i,fullPath:c}=t;let l={routeInfo:void 0,routeId:a,routeRouteId:s,originalIndex:r,routePath:i,fullPath:c,options:e,router:o,childRoutes:void 0,parentRoute:n,get action(){let t=o.store.actions[a]||(o.setStore((e=>{e.actions[a]={submissions:[],submit:async(e,r)=>{if(!l)return;const n=(null==r?void 0:r.invalidate)??!0,[s,i]=C({submittedAt:Date.now(),status:"pending",submission:e,isMulti:!(null==r||!r.multi)});o.setStore((e=>{null!=r&&r.multi||(e.actions[a].submissions=t.submissions.filter((t=>t.isMulti))),e.actions[a].current=s,e.actions[a].latest=s,e.actions[a].submissions.push(s)}));try{const t=await(null==l.options.action?void 0:l.options.action(e));return i((e=>{e.data=t})),n&&(o.invalidateRoute({to:".",fromCurrent:!0}),await o.reload()),i((t=>{t.status="success"})),t}catch(t){console.error(t),i((e=>{e.error=t,e.status="error"}))}}}})),o.store.actions[a]);return t},get loader(){return o.store.loaders[a]||(o.setStore((t=>{t.loaders[a]={pending:[],fetch:async t=>{if(!l)return;const e={loadedAt:Date.now(),loaderContext:t};o.setStore((t=>{t.loaders[a].current=e,t.loaders[a].latest=e,t.loaders[a].pending.push(e)}));try{return await(null==l.options.loader?void 0:l.options.loader(t))}finally{o.setStore((t=>{t.loaders[a].pending=t.loaders[a].pending.filter((t=>t!==e))}))}}}})),o.store.loaders[a])}};return null==o.options.createRoute||o.options.createRoute({router:o,route:l}),l}const lt="__root__",ut=function(t,e,r,n,o){void 0===t&&(t={}),void 0===r&&(r=!0),r&&(t.path=lt),n===lt&&(n="");let a=r?lt:t.path;a&&"/"!==a&&(a=Z(a));const s=a||t.id;let i=J([n,s]);a===lt&&(a="/"),i!==lt&&(i=J(["/",i]));const c=i===lt?"/":Y(J([o,a]));return{id:i,routeId:s,path:a,fullPath:c,options:t,children:e,addChildren:e=>ut(t,e,!1,n,o),createRoute:t=>ut(t,void 0,!1,i,c),generate:()=>{G(!1)}}};function ht(t,e,r){const n=new Map;return function t(e,r){if(e===r)return e;if(n.has(r))return n.get(r);const o=Array.isArray(e),a=Array.isArray(r),s=dt(e),i=dt(r),c=o&&a;if(c||s&&i){const o=c?e.length:Object.keys(e).length,a=c?r:Object.keys(r),s=a.length,i=c?[]:{};let l=0;for(let t=0;t<s;t++){const r=c?t:a[t];i[r]===e[r]&&l++}if(o===s&&l===o)return n.set(r,e),e;n.set(r,i);for(let n=0;n<s;n++){const o=c?n:a[n];"function"==typeof a[n]?i[o]=e[o]:i[o]=t(e[o],r[o]),i[o]===e[o]&&l++}return i}if(a){const e=[];n.set(r,e);for(let n=0;n<r.length;n++)e[n]=t(void 0,r[n]);return e}if(i){const e={};n.set(r,e);const o=Object.keys(r);for(let n=0;n<o.length;n++){const a=o[n];e[a]=t(void 0,r[a])}return e}return r}(t,e)}function dt(t){if(!ft(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!ft(r)&&!!r.hasOwnProperty("isPrototypeOf")}function ft(t){return"[object Object]"===Object.prototype.toString.call(t)}const pt=["component","errorComponent","pendingComponent"];function mt(t,e,r){let n,o,a="",s=()=>{};function i(){l((t=>{var e;t.loaderData=ht(t.loaderData,{...null==(e=c.parentMatch)?void 0:e.store.loaderData,...t.routeLoaderData})}))}const[c,l]=C({routeSearch:{},search:{},status:"idle",routeLoaderData:{},loaderData:{},isFetching:!1,invalid:!1,invalidAt:1/0,get isInvalid(){const t=Date.now();return this.invalid||this.invalidAt<t}}),u={...e,...r,store:c,router:t,childMatches:[],__:{setParentMatch:t=>{m((()=>{l((e=>{e.parentMatch=t})),i()}))},abortController:new AbortController,validate:()=>{var e;const r=(null==(e=c.parentMatch)?void 0:e.store.search)??t.store.currentLocation.search;try{const t=c.routeSearch,e="object"==typeof u.options.validateSearch?u.options.validateSearch.parse:u.options.validateSearch;let n=ht(t,(null==e?void 0:e(r))??{});m((()=>{t!==n&&l((t=>t.invalid=!0)),l((t=>{t.routeSearch=n,t.search=ht(r,{...r,...n})}))})),pt.map((async t=>{const e=u.options[t];"function"!=typeof u.__[t]&&(u.__[t]=e)}))}catch(t){console.error(t);const e=new Error("Invalid search params found",{cause:t});return e.code="INVALID_SEARCH_PARAMS",void l((t=>{t.status="error",t.error=e}))}}},cancel:()=>{var t;null==(t=u.__.abortController)||t.abort()},invalidate:()=>{l((t=>t.invalid=!0))},hasLoaders:()=>!(!e.options.loader&&!pt.some((t=>{var r;return null==(r=e.options[t])?void 0:r.preload}))),load:async e=>{const r=Date.now(),n=null!=e&&e.preload?Math.max(null==e?void 0:e.maxAge,null==e?void 0:e.gcMaxAge):0;if(null!=e&&e.preload&&n>0){if(t.store.currentMatches.find((t=>t.matchId===u.matchId)))return;t.store.matchCache[u.matchId]={gc:r+e.gcMaxAge,match:u}}if("success"===c.status&&c.isInvalid||"error"===c.status||"idle"===c.status){const t=null!=e&&e.preload?null==e?void 0:e.maxAge:void 0;await u.fetch({maxAge:t})}},fetch:async e=>{const r=""+Date.now()+Math.random();a=r;const h=async()=>{if(r!==a)return new Promise((()=>{}))};m((()=>{"idle"===c.status&&l((t=>t.status="loading")),l((t=>t.invalid=!1))})),u.__.loadPromise=new Promise((async r=>{l((t=>t.isFetching=!0)),s=r,n=(async()=>{await Promise.all(pt.map((async e=>{var r;const n=u.options[e];null!=(r=u.__[e])&&r.preload&&(u.__[e]=await t.options.loadComponent(n))})))})(),o=Promise.resolve().then((async()=>{try{if(u.options.loader){const e=await t.loadMatchData(u);await h(),r=e,m((()=>{l((t=>{t.routeLoaderData=ht(t.routeLoaderData,r)})),i()}))}return l((r=>{r.error=void 0,r.status="success",r.updatedAt=Date.now(),r.invalidAt=r.updatedAt+((null==e?void 0:e.maxAge)??u.options.loaderMaxAge??t.options.defaultLoaderMaxAge??0)})),c.routeLoaderData}catch(t){throw await h(),l((e=>{e.error=t,e.status="error",e.updatedAt=Date.now()})),t}var r}));const a=async()=>{await h(),l((t=>t.isFetching=!1)),delete u.__.loadPromise,s()};try{await Promise.all([n,o.catch((()=>{}))]),a()}catch{a()}})),await u.__.loadPromise,await h()}};return u.hasLoaders()||l((t=>t.status="success")),u}const vt=yt(JSON.parse),gt=bt(JSON.stringify);function yt(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=it(e);for(let e in r){const n=r[e];if("string"==typeof n)try{r[e]=t(n)}catch(t){}}return r}}function bt(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const n=e[r];if(void 0===n||void 0===n)delete e[r];else if(n&&"object"==typeof n&&null!==n)try{e[r]=t(n)}catch(t){}}));const r=at(e).toString();return r?`?${r}`:""}}var wt;const Pt="undefined"==typeof window||!(null!=(wt=window.document)&&wt.createElement);function Et(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],actions:{},loaders:{},lastUpdated:Date.now(),matchCache:{},get isFetching(){return"loading"===this.status||this.currentMatches.some((t=>t.store.isFetching))},get isPreloading(){return Object.values(this.matchCache).some((t=>t.match.store.isFetching&&!this.currentMatches.find((e=>e.matchId===t.match.matchId))))}}}function _t(t){const e={defaultLoaderGcMaxAge:3e5,defaultLoaderMaxAge:0,defaultPreloadMaxAge:2e3,defaultPreloadDelay:50,context:void 0,...t,stringifySearch:(null==t?void 0:t.stringifySearch)??gt,parseSearch:(null==t?void 0:t.parseSearch)??vt},[r,n]=C(Et());let o,a=Date.now(),s=()=>{};function i(){h.load()}function c(t,e){const r=h.options.parseSearch(t.search);return{pathname:t.pathname,searchStr:t.search,search:ht(null==e?void 0:e.search,r),hash:t.hash.split("#").reverse()[0]??"",href:`${t.pathname}${t.search}${t.hash}`,state:t.state,key:t.key}}function l(t){return function(t,e){const r=""+Date.now()+Math.random();let n="replace";e||(n="push");c(h.history.location).href!==t.href||t.key||(n="replace");return h.history[n]({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:r,...t.state}),o=new Promise((t=>{const e=s;s=()=>{e(),t()}}))}(h.buildNext(t),t.replace)}function u(t){var e,n,o,a;void 0===t&&(t={});const s=t.fromCurrent?r.latestLocation.pathname:t.from??r.latestLocation.pathname;let i=tt(h.basepath??"/",s,`${t.to??"."}`);const c=h.matchRoutes(r.latestLocation.pathname,{strictParseParams:!0}),l=h.matchRoutes(i),u={...null==(e=K(c))?void 0:e.params};let d=!0===(t.params??!0)?u:V(t.params,u);d&&l.map((t=>t.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},d,t(d))})),i=rt(i,d??{});const f=null!=(n=t.__preSearchFilters)&&n.length?t.__preSearchFilters.reduce(((t,e)=>e(t)),r.latestLocation.search):r.latestLocation.search,p=!0===t.search?f:t.search?V(t.search,f)??{}:null!=(o=t.__preSearchFilters)&&o.length?f:{},m=null!=(a=t.__postSearchFilters)&&a.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),p):p,v=ht(r.latestLocation.search,m),g=h.options.stringifySearch(v);let y=!0===t.hash?r.latestLocation.hash:V(t.hash,r.latestLocation.hash);return y=y?`#${y}`:"",{pathname:i,search:v,searchStr:g,state:r.latestLocation.state,hash:y,href:`${i}${g}${y}`,key:t.key}}const h={types:void 0,history:(null==t?void 0:t.history)||(Pt?N():F()),store:r,setStore:n,options:e,basepath:"",routeTree:void 0,routesById:{},reset:()=>{n((t=>Object.assign(t,Et())))},getRoute:t=>h.routesById[t],dehydrate:()=>({store:{...q(r,["latestLocation","currentLocation","status","lastUpdated"]),currentMatches:r.currentMatches.map((t=>({matchId:t.matchId,store:q(t.store,["status","routeLoaderData","isInvalid","invalidAt"])})))},context:h.options.context}),hydrate:t=>{n((e=>{h.options.context=t.context;const r=h.matchRoutes(t.store.latestLocation.pathname,{strictParseParams:!0});r.forEach(((e,r)=>{const n=t.store.currentMatches[r];G(n&&n.matchId===e.matchId),Object.assign(e,n)})),r.forEach((t=>t.__.validate())),Object.assign(e,{...t.store,currentMatches:r})}))},mount:()=>{if(!Pt){r.currentMatches.length||h.load();const t=h.history.listen((t=>{h.load(c(t.location,r.latestLocation))}));return window.addEventListener&&(window.addEventListener("visibilitychange",i,!1),window.addEventListener("focus",i,!1)),()=>{t(),window.removeEventListener&&(window.removeEventListener("visibilitychange",i),window.removeEventListener("focus",i))}}return()=>{}},update:t=>{const e=(null==t?void 0:t.history)!==h.history;r.latestLocation&&!e||(null!=t&&t.history&&(h.history=t.history),n((t=>{t.latestLocation=c(h.history.location),t.currentLocation=t.latestLocation}))),Object.assign(h.options,t);const{basepath:o,routeConfig:a}=h.options;return h.basepath=`/${Z(o??"")??""}`,a&&(h.routesById={},h.routeTree=function(t){const e=(t,r)=>t.map(((t,n)=>{const o=ct(t,t.options,n,r,h);if(h.routesById[o.routeId])throw new Error;h.routesById[o.routeId]=o;const a=t.children;return o.childRoutes=null!=a&&a.length?e(a,o):void 0,o}));return e([t])[0]}(a)),h},cancelMatches:()=>{[...r.currentMatches,...r.pendingMatches||[]].forEach((t=>{t.cancel()}))},load:async t=>{let e=Date.now();const i=e;let c;a=i,h.cancelMatches(),m((()=>{t&&n((e=>{e.latestLocation=t})),c=h.matchRoutes(r.latestLocation.pathname,{strictParseParams:!0}),console.log("set loading",c),n((t=>{t.status="loading",t.pendingMatches=c,t.pendingLocation=r.latestLocation}))}));try{await h.loadMatches(c)}catch(t){console.log(t),G(!1)}if(a!==i)return o;const l=r.currentMatches,u=[],d=[];l.forEach((t=>{c.find((e=>e.matchId===t.matchId))?d.push(t):u.push(t)}));const f=c.filter((t=>!l.find((e=>e.matchId===t.matchId))));e=Date.now(),u.forEach((t=>{null==t.__.onExit||t.__.onExit({params:t.params,search:t.store.routeSearch}),"error"!==t.store.status||t.store.isFetching||(t.store.status="idle",t.store.error=void 0);const n=Math.max(t.options.loaderGcMaxAge??h.options.defaultLoaderGcMaxAge??0,t.options.loaderMaxAge??h.options.defaultLoaderMaxAge??0);n>0&&(r.matchCache[t.matchId]={gc:n==1/0?Number.MAX_SAFE_INTEGER:e+n,match:t})})),d.forEach((t=>{null==t.options.onTransition||t.options.onTransition({params:t.params,search:t.store.routeSearch})})),f.forEach((t=>{t.__.onExit=null==t.options.onLoaded?void 0:t.options.onLoaded({params:t.params,search:t.store.search}),delete r.matchCache[t.matchId]})),a===i&&(c.forEach((t=>{t.action&&(t.action.current=void 0,t.action.submissions=[])})),n((t=>{console.log("set",c),Object.assign(t,{status:"idle",currentLocation:r.latestLocation,currentMatches:c,pendingLocation:void 0,pendingMatches:void 0})})),s())},cleanMatchCache:()=>{const t=Date.now();n((e=>{Object.keys(e.matchCache).forEach((r=>{const n=e.matchCache[r];"loading"!==n.match.store.status&&(n.gc>0&&n.gc>t||delete e.matchCache[r])}))}))},loadRoute:async function(t){void 0===t&&(t=r.latestLocation);const e=h.buildNext(t),n=h.matchRoutes(e.pathname,{strictParseParams:!0});return await h.loadMatches(n),n},preloadRoute:async function(t,e){void 0===t&&(t=r.latestLocation);const n=h.buildNext(t),o=h.matchRoutes(n.pathname,{strictParseParams:!0});return await h.loadMatches(o,{preload:!0,maxAge:e.maxAge??h.options.defaultPreloadMaxAge??h.options.defaultLoaderMaxAge??0,gcMaxAge:e.gcMaxAge??h.options.defaultPreloadGcMaxAge??h.options.defaultLoaderGcMaxAge??0}),o},matchRoutes:(t,e)=>{h.cleanMatchCache();const n=[];if(!h.routeTree)return n;const o=[...r.currentMatches,...r.pendingMatches??[]],a=async s=>{var i;const c=K(n);let l=(null==c?void 0:c.params)??{};const u=(null==h.options.filterRoutes?void 0:h.options.filterRoutes(s))??s;let d=[];const f=(r,n)=>(n.some((n=>{var o,a;if(!n.routePath&&null!=(o=n.childRoutes)&&o.length)return f([...d,n],n.childRoutes);const s=!!("/"!==n.routePath||null!=(a=n.childRoutes)&&a.length),i=nt(h.basepath,t,{to:n.fullPath,fuzzy:s,caseSensitive:n.options.caseSensitive??h.options.caseSensitive});if(i){let t;try{t=(null==n.options.parseParams?void 0:n.options.parseParams(i))??i}catch(t){if(null!=e&&e.strictParseParams)throw t}l={...l,...t}}return i&&(d=[...r,n]),!!d.length})),!!d.length);if(f([],u),!d.length)return;d.forEach((t=>{var e;const a=rt(t.routePath,l),s=rt(t.routeId,l,!0),i=o.find((t=>t.matchId===s))||(null==(e=r.matchCache[s])?void 0:e.match)||mt(h,t,{parentMatch:c,matchId:s,params:l,pathname:J([h.basepath,a])});n.push(i)}));const p=K(d);null!=(i=p.childRoutes)&&i.length&&a(p.childRoutes)};return a([h.routeTree]),function(t){t.forEach(((e,r)=>{const n=t[r-1];n?e.__.setParentMatch(n):e.__.setParentMatch(void 0)}))}(n),n},loadMatches:async(t,e)=>{t.forEach((async t=>{t.__.validate()})),await Promise.all(t.map((async t=>{try{await(null==t.options.beforeLoad?void 0:t.options.beforeLoad({router:h,match:t}))}catch(r){throw null!=e&&e.preload||null==t.options.onLoadError||t.options.onLoadError(r),r}})));const r=t.map((async t=>{var r;const n=t.store.search;null!=(r=n.__data)&&r.matchId&&n.__data.matchId!==t.matchId||(t.load(e),"success"!==t.store.status&&t.__.loadPromise&&await t.__.loadPromise)}));await Promise.all(r)},loadMatchData:async t=>{if(Pt||!h.options.useServerData)return await(null==t.options.loader?void 0:t.options.loader({params:t.params,search:t.store.routeSearch,signal:t.__.abortController.signal}))||{};{const e=h.buildNext({to:".",search:e=>({...e??{},__data:{matchId:t.matchId}})}),r=await fetch(e.href,{method:"GET"});if(r.ok)return r.json();throw new Error("Failed to fetch match data")}},invalidateRoute:t=>{const e=h.buildNext(t),n=h.matchRoutes(e.pathname).map((t=>t.matchId));[...r.currentMatches,...r.pendingMatches??[]].forEach((t=>{n.includes(t.matchId)&&t.invalidate()}))},reload:()=>l({fromCurrent:!0,replace:!0,search:!0}),resolvePath:(t,e)=>tt(h.basepath,t,X(e)),matchRoute:(t,e)=>{t={...t,to:t.to?h.resolvePath(t.from??"",t.to):void 0};const n=h.buildNext(t);return null!=e&&e.pending?!!r.pendingLocation&&!!nt(h.basepath,r.pendingLocation.pathname,{...e,to:n.pathname}):nt(h.basepath,r.currentLocation.pathname,{...e,to:n.pathname})},navigate:async t=>{let{from:e,to:r=".",search:n,hash:o,replace:a,params:s}=t;const i=String(r),c=String(e);let u;try{new URL(`${i}`),u=!0}catch(t){}return G(!u),l({from:c,to:i,search:n,hash:o,replace:a,params:s})},buildLink:t=>{let{from:e,to:n=".",search:o,params:a,hash:s,target:i,replace:c,activeOptions:u,preload:d,preloadMaxAge:f,preloadGcMaxAge:p,preloadDelay:m,disabled:v}=t;try{return new URL(`${n}`),{type:"external",href:n}}catch(t){}const g={from:e,to:n,search:o,params:a,hash:s,replace:c},y=h.buildNext(g);d=d??h.options.defaultPreload;const b=m??h.options.defaultPreloadDelay??0,w=r.currentLocation.pathname===y.pathname,P=r.currentLocation.pathname.split("/"),E=y.pathname.split("/").every(((t,e)=>t===P[e])),_=r.currentLocation.hash===y.hash,M=null!=u&&u.exact?w:E,L=null==u||!u.includeHash||_;return{type:"internal",next:y,handleFocus:t=>{d&&h.preloadRoute(g,{maxAge:f,gcMaxAge:p}).catch((t=>{console.log(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{v||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||i&&"_self"!==i||0!==t.button||(t.preventDefault(),!w||o||s||h.invalidateRoute(g),l(g))},handleEnter:t=>{const e=t.target||{};if(d){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,h.preloadRoute(g,{maxAge:f,gcMaxAge:p}).catch((t=>{console.log(t),console.warn("Error preloading route! ☝️")}))}),b)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},isActive:M&&L,disabled:v}},buildNext:t=>{const e=u(t),r=h.matchRoutes(e.pathname),n=r.map((t=>t.options.preSearchFilters??[])).flat().filter(Boolean),o=r.map((t=>t.options.postSearchFilters??[])).flat().filter(Boolean);return u({...t,__preSearchFilters:n,__postSearchFilters:o})}};return h.update(t),null==h.options.createRouter||h.options.createRouter(h),h}function Mt(t){const e=Ct(),{type:r,children:n,target:a,activeProps:s=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:l,hash:u,search:h,params:d,to:f,preload:p,preloadDelay:m,preloadMaxAge:v,replace:g,style:y,className:b,onClick:w,onFocus:P,onMouseEnter:E,onMouseLeave:_,onTouchStart:M,onTouchEnd:L,...S}=t,x=e.buildLink(t);if("external"===x.type){const{href:t}=x;return{href:t}}const{handleClick:R,handleFocus:A,handleEnter:I,handleLeave:O,isActive:C,next:k}=x,j=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},D=C?V(s,{})??{}:{},F=C?{}:V(i,{})??{};return{...D,...F,...S,href:l?void 0:k.href,onClick:j([w,t=>{o.startTransition?o.startTransition((()=>{R(t)})):R(t)}]),onFocus:j([P,A]),onMouseEnter:j([E,I]),onMouseLeave:j([_,O]),target:a,style:{...y,...D.style,...F.style},className:[b,D.className,F.className].filter(Boolean).join(" ")||void 0,...l?{role:"link","aria-disabled":!0}:void 0,"data-status":C?"active":void 0}}const Lt=o.forwardRef(((t,e)=>{const r=Mt(t);return o.createElement("a",a({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))})),St=o.createContext(null),xt=o.createContext(null),Rt={},At=(t,e)=>{const n=o.useRef(Rt),a=()=>e?e(v((()=>t()))):t();n.current===Rt&&(n.current=ht(void 0,a()));const s=o.useCallback((()=>n.current),[]),i=o.useCallback((t=>p((()=>{f((()=>{n.current=_(ht(n.current,a())),t()}))}))),[]);return r.useSyncExternalStore(i,s,s)},[It,Ot]=C({foo:"foo",bar:{baz:"baz"}});function Ct(){const t=o.useContext(xt);return W(!t,"useRouter must be used inside a <Router> component!"),t.router}function kt(){return o.useContext(St)}function jt(t){const e=Ct(),r=kt()[0],n=null!=t&&t.from?e.store.currentMatches.find((e=>e.routeId===(null==t?void 0:t.from))):r;return G(n,null!=t&&t.from&&t.from),((null==t?void 0:t.strict)??1)&&G(r.routeId==(null==n?void 0:n.routeId),(null==n||n.routeId,r.routeId,null==n||n.routeId,null==n||n.routeId)),At((()=>n.store)),n}function Dt(t){const e=Ct().getRoute(t);return G(e),e}function Ft(){const t=Ct();return e=>{const{pending:r,caseSensitive:n,...o}=e;return t.matchRoute(o,{pending:r,caseSensitive:n})}}function Nt(){const t=Ct(),e=kt().slice(1),r=e[0],n=o.useCallback((()=>null),[]);At((()=>null==r?void 0:r.store));const a=o.useCallback((e=>{if("error"===e.match.store.status)throw e.match.store.error;if("success"===e.match.store.status)return o.createElement(e.match.__.component??t.options.defaultComponent??Nt);if("loading"===e.match.store.status)throw e.match.__.loadPromise;G(!1)}),[]);if(!r)return null;const s=r.__.pendingComponent??t.options.defaultPendingComponent??n,i=r.__.errorComponent??t.options.defaultErrorComponent;return o.createElement(St.Provider,{value:e},o.createElement(o.Suspense,{fallback:o.createElement(s,null)},o.createElement(Tt,{key:r.routeId,errorComponent:i,match:r},o.createElement(a,{match:r}))))}p((()=>{let t;f((()=>{console.log("effect");const e=ht(t,It);console.log(e),t=v((()=>e))}))})),Ot((t=>{t.foo="1"})),Ot((t=>{t.bar.baz="2"}));class Tt extends o.Component{state={error:!1,info:void 0};componentDidCatch(t,e){console.error(`Error in route match: ${this.props.match.matchId}`),console.error(t),this.setState({error:t,info:e})}render(){return o.createElement($t,a({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function $t(t){const[e,r]=o.useState(t.errorState),n=Ct(),a=t.errorComponent??Ut;return o.useEffect((()=>{if(e){let t=n.store.currentLocation.key;return p((()=>f((()=>{n.store.currentLocation.key!==t&&(t=n.store.currentLocation.key,r({}))}))))}}),[e]),o.useEffect((()=>{t.errorState.error&&r(t.errorState),t.reset()}),[t.errorState.error]),t.errorState.error?o.createElement(a,e):t.children}function Ut(t){let{error:e}=t;return o.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},o.createElement("strong",{style:{fontSize:"1.2rem"}},"Something went wrong!"),o.createElement("div",{style:{height:".5rem"}}),o.createElement("div",null,o.createElement("pre",null,e.message?o.createElement("code",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".5rem",color:"red"}},e.message):null)))}function Bt(t,e){const r=Ct();o.useEffect((()=>{if(!e)return;let n=r.history.block((e=>{window.confirm(t)?(n(),e.retry()):r.store.currentLocation.pathname=window.location.pathname}));return n}),[e,t])}t.DefaultErrorBoundary=Ut,t.Link=Lt,t.MatchRoute=function(t){const e=Ft()(t);return e?o.createElement("function"==typeof t.children?t.children(e):t.children,t):null},t.Outlet=Nt,t.Prompt=function(t){let{message:e,when:r,children:n}=t;return Bt(e,r??!0),n??null},t.RouterProvider=function(t){let{router:e,...r}=t;e.update(r);const[,,n]=At((()=>e.store),(t=>[t.status,t.pendingMatches,t.currentMatches]));return o.useEffect(e.mount,[e]),console.log("current",n),o.createElement(o.Fragment,null,o.createElement(xt.Provider,{value:{router:e}},o.createElement(St.Provider,{value:[void 0,...n]},o.createElement(Nt,null))))},t.__useStoreValue=At,t.batch=m,t.cleanPath=X,t.createBrowserHistory=F,t.createEffect=f,t.createHashHistory=function(t){void 0===t&&(t={});var e=t.window,r=void 0===e?document.defaultView:e,n=r.history;function o(){var t=H(r.location.hash.substr(1)),e=t.pathname,o=void 0===e?"/":e,a=t.search,s=void 0===a?"":a,i=t.hash,c=void 0===i?"":i,l=n.state||{};return[l.idx,{pathname:o,search:s,hash:c,state:l.usr||null,key:l.key||"default"}]}var a=null;function s(){if(a)d.call(a),a=null;else{var t=R.Pop,e=o(),r=e[0],n=e[1];if(d.length){if(null!=r){var s=l-r;s&&(a={action:t,location:n,retry:function(){y(-1*s)}},y(s))}}else g(t)}}r.addEventListener(D,s),r.addEventListener("hashchange",(function(){z(o()[1])!==z(u)&&s()}));var i=R.Pop,c=o(),l=c[0],u=c[1],h=U(),d=U();function f(t){return function(){var t=document.querySelector("base"),e="";if(t&&t.getAttribute("href")){var n=r.location.href,o=n.indexOf("#");e=-1===o?n:n.slice(0,o)}return e}()+"#"+("string"==typeof t?t:z(t))}function p(t,e){return void 0===e&&(e=null),k({pathname:u.pathname,hash:"",search:""},"string"==typeof t?H(t):t,{state:e,key:B()})}function m(t,e){return[{usr:t.state,key:t.key,idx:e},f(t)]}function v(t,e,r){return!d.length||(d.call({action:t,location:e,retry:r}),!1)}function g(t){i=t;var e=o();l=e[0],u=e[1],h.call({action:i,location:u})}function y(t){n.go(t)}null==l&&(l=0,n.replaceState(k({},n.state,{idx:l}),""));var b={get action(){return i},get location(){return u},createHref:f,push:function t(e,o){var a=R.Push,s=p(e,o);if(v(a,s,(function(){t(e,o)}))){var i=m(s,l+1),c=i[0],u=i[1];try{n.pushState(c,"",u)}catch(t){r.location.assign(u)}g(a)}},replace:function t(e,r){var o=R.Replace,a=p(e,r);if(v(o,a,(function(){t(e,r)}))){var s=m(a,l),i=s[0],c=s[1];n.replaceState(i,"",c),g(o)}},go:y,back:function(){y(-1)},forward:function(){y(1)},listen:function(t){return h.push(t)},block:function(t){var e=d.push(t);return 1===d.length&&r.addEventListener(j,$),function(){e(),d.length||r.removeEventListener(j,$)}}};return b},t.createMemo=function(t){const e=new h(t,1);return e.get.bind(e)},t.createMemoryHistory=N,t.createReactRouter=function(t){return _t({...t,loadComponent:async t=>(t.preload&&await t.preload(),t)})},t.createRoot=p,t.createRoute=ct,t.createRouteConfig=ut,t.createRouteMatch=mt,t.createRouter=_t,t.createSignal=function(t,e){const r=new h(t,0);return void 0!==e?.equals&&(r.alwaysUpdate=!0),[r.get.bind(r),r.set.bind(r)]},t.createStore=C,t.decode=it,t.defaultParseSearch=vt,t.defaultStringifySearch=gt,t.encode=at,t.functionalUpdate=V,t.interpolatePath=rt,t.invariant=G,t.isWrappable=E,t.joinPaths=J,t.last=K,t.lazy=function(t){const e=o.lazy(t);return e.preload=async()=>{await t()},e},t.matchByPath=ot,t.matchPathname=nt,t.matchesContext=St,t.onCleanup=function(t){i?i.cleanups?i.cleanups.push(t):i.cleanups=[t]:console.error("onCleanup must be called from within a memo or effect")},t.parsePathname=et,t.parseSearchWith=yt,t.pick=q,t.resolvePath=tt,t.rootRouteId=lt,t.routerContext=xt,t.sharedClone=ht,t.stringifySearchWith=bt,t.trimPath=Z,t.trimPathLeft=Q,t.trimPathRight=Y,t.untrack=v,t.unwrap=_,t.useAction=function(t){const e=Dt(t.from).action;return At((()=>e)),e},t.useLinkProps=Mt,t.useLoaderData=function(t){const e=jt(t);return At((()=>null==e?void 0:e.store.loaderData),null==t?void 0:t.select)},t.useMatch=jt,t.useMatchRoute=Ft,t.useMatches=kt,t.useNavigate=function(t){return e=>Ct().navigate({...t,...e})},t.useParams=function(t){const e=Ct();return At((()=>{var t;return null==(t=K(e.store.currentMatches))?void 0:t.params}),null==t?void 0:t.select)},t.usePrompt=Bt,t.useRoute=Dt,t.useRouter=Ct,t.useRouterStore=function(t){const e=Ct();return At((()=>e.store),t)},t.useSearch=function(t){const e=jt(t);return At((()=>null==e?void 0:e.store.search),null==t?void 0:t.select)},t.warning=W,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
22
22
|
//# sourceMappingURL=index.production.js.map
|