@tanstack/react-router 0.0.1-beta.5 → 0.0.1-beta.51
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/LICENSE +21 -0
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -18
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/cjs/index.js +466 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/useStore.js +64 -0
- package/build/cjs/useStore.js.map +1 -0
- package/build/esm/index.js +386 -2802
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +59 -49
- package/build/stats-react.json +122 -35
- package/build/types/index.d.ts +90 -46
- package/build/umd/index.development.js +1825 -2422
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +3 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +7 -5
- package/src/index.tsx +632 -466
- package/src/useStore.ts +70 -0
- package/build/cjs/react-router/src/index.js +0 -465
- package/build/cjs/react-router/src/index.js.map +0 -1
- package/build/cjs/router-core/build/esm/index.js +0 -2502
- package/build/cjs/router-core/build/esm/index.js.map +0 -1
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
!function(e
|
|
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")}function i(t){for(var e=arguments.length,r=Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=arguments[o];throw Error("[Immer] minified error nr: "+t+(r.length?" "+r.map((function(t){return"'"+t+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function c(t){return!!t&&!!t[J]}function u(t){var e;return!!t&&(function(t){if(!t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);if(null===e)return!0;var r=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return r===Object||"function"==typeof r&&Function.toString.call(r)===q}(t)||Array.isArray(t)||!!t[G]||!!(null===(e=t.constructor)||void 0===e?void 0:e[G])||p(t)||m(t))}function h(t,e,r){void 0===r&&(r=!1),0===l(t)?(r?Object.keys:X)(t).forEach((function(o){r&&"symbol"==typeof o||e(o,t[o],t)})):t.forEach((function(r,o){return e(o,r,t)}))}function l(t){var e=t[J];return e?e.i>3?e.i-4:e.i:Array.isArray(t)?1:p(t)?2:m(t)?3:0}function d(t,e){return 2===l(t)?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function f(t,e,r){var o=l(t);2===o?t.set(e,r):3===o?(t.delete(e),t.add(r)):t[e]=r}function p(t){return U&&t instanceof Map}function m(t){return H&&t instanceof Set}function g(t){return t.o||t.t}function v(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var e=V(t);delete e[J];for(var r=X(e),o=0;o<r.length;o++){var a=r[o],s=e[a];!1===s.writable&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(e[a]={configurable:!0,writable:!0,enumerable:s.enumerable,value:t[a]})}return Object.create(Object.getPrototypeOf(t),e)}function y(t,e){return void 0===e&&(e=!1),w(t)||c(t)||!u(t)||(l(t)>1&&(t.set=t.add=t.clear=t.delete=b),Object.freeze(t),e&&h(t,(function(t,e){return y(e,!0)}),!0)),t}function b(){i(2)}function w(t){return null==t||"object"!=typeof t||Object.isFrozen(t)}function S(t){var e=Q[t];return e||i(18,t),e}function P(){return z}function L(t,e){e&&(S("Patches"),t.u=[],t.s=[],t.v=e)}function E(t){M(t),t.p.forEach(x),t.p=null}function M(t){t===z&&(z=t.l)}function A(t){return z={p:[],l:z,h:t,m:!0,_:0}}function x(t){var e=t[J];0===e.i||1===e.i?e.j():e.O=!0}function _(t,e){e._=e.p.length;var r=e.p[0],o=void 0!==t&&t!==r;return e.h.g||S("ES5").S(e,t,o),o?(r[J].P&&(E(e),i(4)),u(t)&&(t=O(e,t),e.l||D(e,t)),e.u&&S("Patches").M(r[J].t,t,e.u,e.s)):t=O(e,r,[]),E(e),e.u&&e.v(e.u,e.s),t!==W?t:void 0}function O(t,e,r){if(w(e))return e;var o=e[J];if(!o)return h(e,(function(a,s){return R(t,o,e,a,s,r)}),!0),e;if(o.A!==t)return e;if(!o.P)return D(t,o.t,!0),o.t;if(!o.I){o.I=!0,o.A._--;var a=4===o.i||5===o.i?o.o=v(o.k):o.o;h(3===o.i?new Set(a):a,(function(e,s){return R(t,o,a,e,s,r)})),D(t,a,!1),r&&t.u&&S("Patches").R(o,r,t.u,t.s)}return o.o}function R(t,e,r,o,a,s){if(c(a)){var n=O(t,a,s&&e&&3!==e.i&&!d(e.D,o)?s.concat(o):void 0);if(f(r,o,n),!c(n))return;t.m=!1}if(u(a)&&!w(a)){if(!t.h.F&&t._<1)return;O(t,a),e&&e.A.l||D(t,a)}}function D(t,e,r){void 0===r&&(r=!1),t.h.F&&t.m&&y(e,r)}function j(t,e){var r=t[J];return(r?g(r):t)[e]}function C(t,e){if(e in t)for(var r=Object.getPrototypeOf(t);r;){var o=Object.getOwnPropertyDescriptor(r,e);if(o)return o;r=Object.getPrototypeOf(r)}}function k(t){t.P||(t.P=!0,t.l&&k(t.l))}function F(t){t.o||(t.o=v(t.t))}function I(t,e,r){var o=p(e)?S("MapSet").N(e,r):m(e)?S("MapSet").T(e,r):t.g?function(t,e){var r=Array.isArray(t),o={i:r?1:0,A:e?e.A:P(),P:!1,I:!1,D:{},l:e,t:t,k:null,o:null,j:null,C:!1},a=o,s=Y;r&&(a=[o],s=Z);var n=Proxy.revocable(a,s),i=n.revoke,c=n.proxy;return o.k=c,o.j=i,c}(e,r):S("ES5").J(e,r);return(r?r.A:P()).p.push(o),o}function $(t){return c(t)||i(22,t),function t(e){if(!u(e))return e;var r,o=e[J],a=l(e);if(o){if(!o.P&&(o.i<4||!S("ES5").K(o)))return o.t;o.I=!0,r=N(e,a),o.I=!1}else r=N(e,a);return h(r,(function(e,a){o&&function(t,e){return 2===l(t)?t.get(e):t[e]}(o.t,e)===a||f(r,e,t(a))})),3===a?new Set(r):r}(t)}function N(t,e){switch(e){case 2:return new Map(t);case 3:return Array.from(t)}return v(t)}var T,z,B="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),U="undefined"!=typeof Map,H="undefined"!=typeof Set,K="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,W=B?Symbol.for("immer-nothing"):((T={})["immer-nothing"]=!0,T),G=B?Symbol.for("immer-draftable"):"__$immer_draftable",J=B?Symbol.for("immer-state"):"__$immer_state",q=""+Object.prototype.constructor,X="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Object.getOwnPropertyNames,V=Object.getOwnPropertyDescriptors||function(t){var e={};return X(t).forEach((function(r){e[r]=Object.getOwnPropertyDescriptor(t,r)})),e},Q={},Y={get:function(t,e){if(e===J)return t;var r=g(t);if(!d(r,e))return function(t,e,r){var o,a=C(e,r);return a?"value"in a?a.value:null===(o=a.get)||void 0===o?void 0:o.call(t.k):void 0}(t,r,e);var o=r[e];return t.I||!u(o)?o:o===j(t.t,e)?(F(t),t.o[e]=I(t.A.h,o,t)):o},has:function(t,e){return e in g(t)},ownKeys:function(t){return Reflect.ownKeys(g(t))},set:function(t,e,r){var o=C(g(t),e);if(null==o?void 0:o.set)return o.set.call(t.k,r),!0;if(!t.P){var a=j(g(t),e),s=null==a?void 0:a[J];if(s&&s.t===r)return t.o[e]=r,t.D[e]=!1,!0;if(function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}(r,a)&&(void 0!==r||d(t.t,e)))return!0;F(t),k(t)}return t.o[e]===r&&"number"!=typeof r&&(void 0!==r||e in t.o)||(t.o[e]=r,t.D[e]=!0,!0)},deleteProperty:function(t,e){return void 0!==j(t.t,e)||e in t.t?(t.D[e]=!1,F(t),k(t)):delete t.D[e],t.o&&delete t.o[e],!0},getOwnPropertyDescriptor:function(t,e){var r=g(t),o=Reflect.getOwnPropertyDescriptor(r,e);return o?{writable:!0,configurable:1!==t.i||"length"!==e,enumerable:o.enumerable,value:r[e]}:o},defineProperty:function(){i(11)},getPrototypeOf:function(t){return Object.getPrototypeOf(t.t)},setPrototypeOf:function(){i(12)}},Z={};h(Y,(function(t,e){Z[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}})),Z.deleteProperty=function(t,e){return Z.set.call(this,t,e,void 0)},Z.set=function(t,e,r){return Y.set.call(this,t[0],e,r,t[0])};var tt=function(){function t(t){var e=this;this.g=K,this.F=!0,this.produce=function(t,r,o){if("function"==typeof t&&"function"!=typeof r){var a=r;r=t;var s=e;return function(t){var e=this;void 0===t&&(t=a);for(var o=arguments.length,n=Array(o>1?o-1:0),i=1;i<o;i++)n[i-1]=arguments[i];return s.produce(t,(function(t){var o;return(o=r).call.apply(o,[e,t].concat(n))}))}}var n;if("function"!=typeof r&&i(6),void 0!==o&&"function"!=typeof o&&i(7),u(t)){var c=A(e),h=I(e,t,void 0),l=!0;try{n=r(h),l=!1}finally{l?E(c):M(c)}return"undefined"!=typeof Promise&&n instanceof Promise?n.then((function(t){return L(c,o),_(t,c)}),(function(t){throw E(c),t})):(L(c,o),_(n,c))}if(!t||"object"!=typeof t){if(void 0===(n=r(t))&&(n=t),n===W&&(n=void 0),e.F&&y(n,!0),o){var d=[],f=[];S("Patches").M(t,n,d,f),o(d,f)}return n}i(21,t)},this.produceWithPatches=function(t,r){if("function"==typeof t)return function(r){for(var o=arguments.length,a=Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return e.produceWithPatches(r,(function(e){return t.apply(void 0,[e].concat(a))}))};var o,a,s=e.produce(t,r,(function(t,e){o=t,a=e}));return"undefined"!=typeof Promise&&s instanceof Promise?s.then((function(t){return[t,o,a]})):[s,o,a]},"boolean"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),"boolean"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var e=t.prototype;return e.createDraft=function(t){u(t)||i(8),c(t)&&(t=$(t));var e=A(this),r=I(this,t,void 0);return r[J].C=!0,M(e),r},e.finishDraft=function(t,e){var r=(t&&t[J]).A;return L(r,e),_(void 0,r)},e.setAutoFreeze=function(t){this.F=t},e.setUseProxies=function(t){t&&!K&&i(20),this.g=t},e.applyPatches=function(t,e){var r;for(r=e.length-1;r>=0;r--){var o=e[r];if(0===o.path.length&&"replace"===o.op){t=o.value;break}}r>-1&&(e=e.slice(r+1));var a=S("Patches").$;return c(t)?a(t,e):this.produce(t,(function(t){return a(t,e)}))},t}(),et=new tt,rt=et.produce;et.produceWithPatches.bind(et);var ot=et.setAutoFreeze.bind(et);et.setUseProxies.bind(et),et.applyPatches.bind(et),et.createDraft.bind(et),et.finishDraft.bind(et);
|
|
12
12
|
/**
|
|
13
13
|
* router-core
|
|
14
14
|
*
|
|
@@ -18,5 +18,6 @@
|
|
|
18
18
|
* LICENSE.md file in the root directory of this source tree.
|
|
19
19
|
*
|
|
20
20
|
* @license MIT
|
|
21
|
-
*/function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},l.apply(this,arguments)}!function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"}(o||(o={}));var c="beforeunload",u="popstate";function d(e){void 0===e&&(e={});var t=e.window,n=void 0===t?document.defaultView:t,a=n.history;function r(){var e=n.location,t=e.pathname,o=e.search,r=e.hash,i=a.state||{};return[i.idx,{pathname:t,search:o,hash:r,state:i.usr||null,key:i.key||"default"}]}var i=null;n.addEventListener(u,(function(){if(i)P.call(i),i=null;else{var e=o.Pop,t=r(),n=t[0],a=t[1];if(P.length){if(null!=n){var s=h-n;s&&(i={action:e,location:a,retry:function(){M(-1*s)}},M(s))}}else R(e)}}));var s=o.Pop,d=r(),h=d[0],f=d[1],_=m(),P=m();function b(e){return"string"==typeof e?e:g(e)}function w(e,t){return void 0===t&&(t=null),l({pathname:f.pathname,hash:"",search:""},"string"==typeof e?y(e):e,{state:t,key:v()})}function E(e,t){return[{usr:e.state,key:e.key,idx:t},b(e)]}function x(e,t,n){return!P.length||(P.call({action:e,location:t,retry:n}),!1)}function R(e){s=e;var t=r();h=t[0],f=t[1],_.call({action:s,location:f})}function M(e){a.go(e)}null==h&&(h=0,a.replaceState(l({},a.state,{idx:h}),""));var A={get action(){return s},get location(){return f},createHref:b,push:function e(t,r){var i=o.Push,s=w(t,r);if(x(i,s,(function(){e(t,r)}))){var l=E(s,h+1),c=l[0],u=l[1];try{a.pushState(c,"",u)}catch(e){n.location.assign(u)}R(i)}},replace:function e(t,n){var r=o.Replace,i=w(t,n);if(x(r,i,(function(){e(t,n)}))){var s=E(i,h),l=s[0],c=s[1];a.replaceState(l,"",c),R(r)}},go:M,back:function(){M(-1)},forward:function(){M(1)},listen:function(e){return _.push(e)},block:function(e){var t=P.push(e);return 1===P.length&&n.addEventListener(c,p),function(){t(),P.length||n.removeEventListener(c,p)}}};return A}function h(e){void 0===e&&(e={});var t=e,n=t.initialEntries,a=void 0===n?["/"]:n,r=t.initialIndex,i=a.map((function(e){return l({pathname:"/",search:"",hash:"",state:null,key:v()},"string"==typeof e?y(e):e)})),s=f(null==r?i.length-1:r,0,i.length-1),c=o.Pop,u=i[s],d=m(),h=m();function p(e,t){return void 0===t&&(t=null),l({pathname:u.pathname,search:"",hash:""},"string"==typeof e?y(e):e,{state:t,key:v()})}function _(e,t,n){return!h.length||(h.call({action:e,location:t,retry:n}),!1)}function P(e,t){c=e,u=t,d.call({action:c,location:u})}function b(e){var t=f(s+e,0,i.length-1),n=o.Pop,a=i[t];_(n,a,(function(){b(e)}))&&(s=t,P(n,a))}var w={get index(){return s},get action(){return c},get location(){return u},createHref:function(e){return"string"==typeof e?e:g(e)},push:function e(t,n){var a=o.Push,r=p(t,n);_(a,r,(function(){e(t,n)}))&&(s+=1,i.splice(s,i.length,r),P(a,r))},replace:function e(t,n){var a=o.Replace,r=p(t,n);_(a,r,(function(){e(t,n)}))&&(i[s]=r,P(a,r))},go:b,back:function(){b(-1)},forward:function(){b(1)},listen:function(e){return d.push(e)},block:function(e){return h.push(e)}};return w}function f(e,t,n){return Math.min(Math.max(e,t),n)}function p(e){e.preventDefault(),e.returnValue=""}function m(){var e=[];return{get length(){return e.length},push:function(t){return e.push(t),function(){e=e.filter((function(e){return e!==t}))}},call:function(t){e.forEach((function(e){return e&&e(t)}))}}}function v(){return Math.random().toString(36).substr(2,8)}function g(e){var t=e.pathname,n=void 0===t?"/":t,a=e.search,o=void 0===a?"":a,r=e.hash,i=void 0===r?"":r;return o&&"?"!==o&&(n+="?"===o.charAt(0)?o:"?"+o),i&&"#"!==i&&(n+="#"===i.charAt(0)?i:"#"+i),n}function y(e){var t={};if(e){var n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));var a=e.indexOf("?");a>=0&&(t.search=e.substr(a),e=e.substr(0,a)),e&&(t.pathname=e)}return t}function _(e,t){if(!e)throw new Error("Invariant failed")}function P(e,t){if(e===t)return e;const n=Array.isArray(e)&&Array.isArray(t);if(n||b(e)&&b(t)){const a=n?e.length:Object.keys(e).length,o=n?t:Object.keys(t),r=o.length,i=n?[]:{};let s=0;for(let a=0;a<r;a++){const r=n?a:o[a];i[r]=P(e[r],t[r]),i[r]===e[r]&&s++}return a===r&&s===a?e:i}return t}function b(e){if(!w(e))return!1;const t=e.constructor;if(void 0===t)return!0;const n=t.prototype;return!!w(n)&&!!n.hasOwnProperty("isPrototypeOf")}function w(e){return"[object Object]"===Object.prototype.toString.call(e)}function E(e){return e[e.length-1]}function x(e,t){if(e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(e){}}return!0}function R(e,t){return"function"==typeof e?e(t):e}function M(e){return A(e.filter(Boolean).join("/"))}function A(e){return e.replace(/\/{2,}/g,"/")}function S(e){return"/"===e?e:e.replace(/^\/{1,}/,"")}function I(e){return"/"===e?e:e.replace(/\/{1,}$/,"")}function L(e){return I(S(e))}function C(e,t,n){t=t.replace(new RegExp("^"+e),"/"),n=n.replace(new RegExp("^"+e),"/");let a=k(t);const o=k(n);o.forEach(((e,t)=>{if("/"===e.value)t?t===o.length-1&&a.push(e):a=[e];else if(".."===e.value){var n;a.length>1&&"/"===(null==(n=E(a))?void 0:n.value)&&a.pop(),a.pop()}else{if("."===e.value)return;a.push(e)}}));return A(M([e,...a.map((e=>e.value))]))}function k(e){if(!e)return[];const t=[];if("/"===(e=A(e)).slice(0,1)&&(e=e.substring(1),t.push({type:"pathname",value:"/"})),!e)return t;const n=e.split("/").filter(Boolean);return t.push(...n.map((e=>e.startsWith("*")?{type:"wildcard",value:e}:":"===e.charAt(0)?{type:"param",value:e}:{type:"pathname",value:e}))),"/"===e.slice(-1)&&(e=e.substring(1),t.push({type:"pathname",value:"/"})),t}function O(e,t,n){return M(k(e).map((e=>{return"*"!==e.value||n?"param"===e.type?null!=(a=t[e.value.substring(1)])?a:"":e.value:"";var a})))}function j(e,t){const n=T(e,t);if(!t.to||n)return null!=n?n:{}}function T(e,t){var n;const a=k(e),o=k(""+(null!=(n=t.to)?n:"*")),r={};return(()=>{for(let e=0;e<Math.max(a.length,o.length);e++){const n=a[e],i=o[e],s=e===o.length-1,l=e===a.length-1;if(i){if("wildcard"===i.type)return!(null==n||!n.value)&&(r["*"]=M(a.slice(e).map((e=>e.value))),!0);if("pathname"===i.type){if("/"===i.value&&(null==n||!n.value))return!0;if(n)if(t.caseSensitive){if(i.value!==n.value)return!1}else if(i.value.toLowerCase()!==n.value.toLowerCase())return!1}if(!n)return!1;if("param"===i.type){if("/"===(null==n?void 0:n.value))return!1;n.value.startsWith(":")||(r[i.value.substring(1)]=n.value)}}if(s&&!l)return!!t.fuzzy}return!0})()?r:void 0}function D(e,t){var n,a,o,r="";for(n in e)if(void 0!==(o=e[n]))if(Array.isArray(o))for(a=0;a<o.length;a++)r&&(r+="&"),r+=encodeURIComponent(n)+"="+encodeURIComponent(o[a]);else r&&(r+="&"),r+=encodeURIComponent(n)+"="+encodeURIComponent(o);return(t||"")+r}function F(e){if(!e)return"";var t=decodeURIComponent(e);return"false"!==t&&("true"===t||("0"===t.charAt(0)?t:0*+t==0?+t:t))}function N(e){for(var t,n,a={},o=e.split("&");t=o.shift();)void 0!==a[n=(t=t.split("=")).shift()]?a[n]=[].concat(a[n],F(t.shift())):a[n]=F(t.shift());return a}function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},B.apply(this,arguments)}function H(e,t,n,a){const{id:o,routeId:r,path:i,fullPath:s}=e,l=a.state.actions[o]||(a.state.actions[o]={pending:[],submit:async(e,t)=>{var n;if(!u)return;const o=null==(n=null==t?void 0:t.invalidate)||n,r={submittedAt:Date.now(),status:"pending",submission:e};l.current=r,l.latest=r,l.pending.push(r),a.state=B({},a.state,{currentAction:r,latestAction:r}),a.notify();try{const t=await(null==u.options.action?void 0:u.options.action(e));return r.data=t,o&&(a.invalidateRoute({to:".",fromCurrent:!0}),await a.reload()),r.status="success",t}catch(e){console.error(e),r.error=e,r.status="error"}finally{l.pending=l.pending.filter((e=>e!==r)),a.removeActionQueue.push({action:l,actionState:r}),a.notify()}}},a.state.actions[o]),c=a.state.loaders[o]||(a.state.loaders[o]={pending:[],fetch:async e=>{if(!u)return;const t={loadedAt:Date.now(),loaderContext:e};c.current=t,c.latest=t,c.pending.push(t),a.notify();try{return await(null==u.options.loader?void 0:u.options.loader(e))}finally{c.pending=c.pending.filter((e=>e!==t)),a.notify()}}},a.state.loaders[o]);let u={routeId:o,routeRouteId:r,routePath:i,fullPath:s,options:t,router:a,childRoutes:void 0,parentRoute:n,action:l,loader:c,buildLink:e=>a.buildLink(B({},e,{from:s})),navigate:e=>a.navigate(B({},e,{from:s})),matchRoute:(e,t)=>a.matchRoute(B({},e,{from:s}),t)};return null==a.options.createRoute||a.options.createRoute({router:a,route:u}),u}function U(e){e.forEach(((t,n)=>{const a=e[n-1];a&&(t.loaderData=P(t.loaderData,B({},a.loaderData,t.routeLoaderData)))}))}const z="__root__",G=["element","errorElement","catchElement","pendingElement"];function W(e,t,n){const a=B({},t,n,{router:e,routeSearch:{},search:{},childMatches:[],status:"idle",routeLoaderData:{},loaderData:{},isPending:!1,isFetching:!1,isInvalid:!1,invalidAt:1/0,getIsInvalid:()=>{const e=Date.now();return a.isInvalid||a.invalidAt<e},__:{abortController:new AbortController,latestId:"",resolve:()=>{},notify:()=>{a.__.resolve(),a.router.notify()},startPending:()=>{var t,n;const o=null!=(t=a.options.pendingMs)?t:e.options.defaultPendingMs,r=null!=(n=a.options.pendingMinMs)?n:e.options.defaultPendingMinMs;a.__.pendingTimeout||"loading"!==a.status||void 0===o||(a.__.pendingTimeout=setTimeout((()=>{a.isPending=!0,a.__.resolve(),void 0!==r&&(a.__.pendingMinPromise=new Promise((e=>a.__.pendingMinTimeout=setTimeout(e,r))))}),o))},cancelPending:()=>{a.isPending=!1,clearTimeout(a.__.pendingTimeout),clearTimeout(a.__.pendingMinTimeout),delete a.__.pendingMinPromise},validate:()=>{var t,n;const o=null!=(t=null==(n=a.parentMatch)?void 0:n.search)?t:e.location.search;try{const e=a.routeSearch,t="object"==typeof a.options.validateSearch?a.options.validateSearch.parse:a.options.validateSearch;let n=P(e,null==t?void 0:t(o));e!==n&&(a.isInvalid=!0),a.routeSearch=n,a.search=P(o,B({},o,n))}catch(e){console.error(e);const t=new Error("Invalid search params found",{cause:e});return t.code="INVALID_SEARCH_PARAMS",a.status="error",void(a.error=t)}}},cancel:()=>{var e;null==(e=a.__.abortController)||e.abort(),a.__.cancelPending()},invalidate:()=>{a.isInvalid=!0},hasLoaders:()=>!(!t.options.loader&&!G.some((e=>"function"==typeof t.options[e]))),load:async t=>{const n=Date.now(),o=null!=t&&t.preload?Math.max(null==t?void 0:t.maxAge,null==t?void 0:t.gcMaxAge):0;if(null!=t&&t.preload&&o>0){if(e.state.matches.find((e=>e.matchId===a.matchId)))return;e.matchCache[a.matchId]={gc:n+t.gcMaxAge,match:a}}if("success"===a.status&&a.getIsInvalid()||"error"===a.status||"idle"===a.status){const e=null!=t&&t.preload?null==t?void 0:t.maxAge:void 0;a.fetch({maxAge:e})}},fetch:async t=>{const n=""+Date.now()+Math.random();return a.__.latestId=n,"idle"===a.status&&(a.status="loading"),a.isInvalid=!1,a.__.loadPromise=new Promise((async o=>{a.isFetching=!0,a.__.resolve=o;const r=(async()=>{a.__.elementsPromise=(async()=>{await Promise.all(G.map((async t=>{const n=a.options[t];a.__[t]||(a.__[t]=await e.options.createElement(n))})))})(),a.__.dataPromise=Promise.resolve().then((async()=>{try{var o,r,i;if(a.options.loader){const e=await a.options.loader({params:a.params,search:a.routeSearch,signal:a.__.abortController.signal});if(n!==a.__.latestId)return a.__.loaderPromise;a.routeLoaderData=P(a.routeLoaderData,e)}a.error=void 0,a.status="success",a.updatedAt=Date.now(),a.invalidAt=a.updatedAt+(null!=(o=null!=(r=null!=(i=null==t?void 0:t.maxAge)?i:a.options.loaderMaxAge)?r:e.options.defaultLoaderMaxAge)?o:0)}catch(e){if(n!==a.__.latestId)return a.__.loaderPromise;a.error=e,a.status="error",a.updatedAt=Date.now()}}));try{if(await Promise.all([a.__.elementsPromise,a.__.dataPromise]),n!==a.__.latestId)return a.__.loaderPromise;a.__.pendingMinPromise&&(await a.__.pendingMinPromise,delete a.__.pendingMinPromise)}finally{if(n!==a.__.latestId)return a.__.loaderPromise;a.__.cancelPending(),a.isPending=!1,a.isFetching=!1,a.__.notify()}})();if(a.__.loaderPromise=r,await r,n!==a.__.latestId)return a.__.loaderPromise;delete a.__.loaderPromise})),await a.__.loadPromise}});return a.hasLoaders()||(a.status="success"),a}const q=Q(JSON.parse),K=V(JSON.stringify);function Q(e){return t=>{"?"===t.substring(0,1)&&(t=t.substring(1));let n=N(t);for(let t in n){const a=n[t];if("string"==typeof a)try{n[t]=e(a)}catch(e){}}return n}}function V(e){return t=>{(t=B({},t))&&Object.keys(t).forEach((n=>{const a=t[n];if(void 0===a||void 0===a)delete t[n];else if(a&&"object"==typeof a&&null!==a)try{t[n]=e(a)}catch(e){}}));const n=D(t).toString();return n?"?"+n:""}}var J;const X="undefined"==typeof window||!(null!=(J=window.document)&&J.createElement);function Y(e){var t,n;const a=(null==e?void 0:e.history)||(X?h():d()),o=B({defaultLoaderGcMaxAge:3e5,defaultLoaderMaxAge:0,defaultPreloadMaxAge:2e3,defaultPreloadDelay:50},e,{stringifySearch:null!=(t=null==e?void 0:e.stringifySearch)?t:K,parseSearch:null!=(n=null==e?void 0:e.parseSearch)?n:q});let r={history:a,options:o,listeners:[],removeActionQueue:[],basepath:"",routeTree:void 0,routesById:{},location:void 0,allRouteInfo:void 0,navigationPromise:Promise.resolve(),resolveNavigation:()=>{},matchCache:{},state:{status:"idle",location:null,matches:[],actions:{},loaders:{},lastUpdated:Date.now(),isFetching:!1,isPreloading:!1},startedLoadingAt:Date.now(),subscribe:e=>(r.listeners.push(e),()=>{r.listeners=r.listeners.filter((t=>t!==e))}),getRoute:e=>r.routesById[e],notify:()=>{r.state=B({},r.state,{isFetching:"loading"===r.state.status||r.state.matches.some((e=>e.isFetching)),isPreloading:Object.values(r.matchCache).some((e=>e.match.isFetching&&!r.state.matches.find((t=>t.matchId===e.match.matchId))))}),U(r.state.matches),r.listeners.forEach((e=>e(r)))},mount:()=>{const e=r.__.buildLocation({to:".",search:!0,hash:!0});e.href!==r.location.href&&r.__.commitLocation(e,!0),r.loadLocation();const t=r.history.listen((e=>{console.log(e.location),r.loadLocation(r.__.parseLocation(e.location,r.location))}));return!X&&window.addEventListener&&(window.addEventListener("visibilitychange",r.onFocus,!1),window.addEventListener("focus",r.onFocus,!1)),()=>{t(),window.removeEventListener("visibilitychange",r.onFocus),window.removeEventListener("focus",r.onFocus)}},onFocus:()=>{r.loadLocation()},update:e=>{const t=(null==e?void 0:e.history)!==r.history;r.location&&!t||(null!=e&&e.history&&(r.history=e.history),r.location=r.__.parseLocation(r.history.location),r.state.location=r.location),Object.assign(r.options,e);const{basepath:n,routeConfig:a}=r.options;return r.basepath=A("/"+(null!=n?n:"")),a&&(r.routesById={},r.routeTree=r.__.buildRouteTree(a)),r},cancelMatches:()=>{var e,t;[...r.state.matches,...null!=(e=null==(t=r.state.pending)?void 0:t.matches)?e:[]].forEach((e=>{e.cancel()}))},loadLocation:async e=>{const t=Math.random();r.startedLoadingAt=t,e&&(r.location=e),r.removeActionQueue.forEach((e=>{let{action:t,actionState:n}=e;r.state.currentAction===n&&(r.state.currentAction=void 0),t.current===n&&(t.current=void 0)})),r.removeActionQueue=[],r.cancelMatches();const n=r.matchRoutes(r.location.pathname,{strictParseParams:!0});if(r.state=B({},r.state,{pending:{matches:n,location:r.location},status:"loading"}),r.notify(),await r.loadMatches(n,{withPending:!0}),r.startedLoadingAt!==t)return r.navigationPromise;const a=r.state.matches,o=[],i=[];a.forEach((e=>{n.find((t=>t.matchId===e.matchId))?i.push(e):o.push(e)}));const s=Date.now();o.forEach((e=>{var t,n,a,o;null==e.__.onExit||e.__.onExit({params:e.params,search:e.routeSearch}),"error"!==e.status||e.isFetching||(e.status="idle",e.error=void 0);const i=Math.max(null!=(t=null!=(n=e.options.loaderGcMaxAge)?n:r.options.defaultLoaderGcMaxAge)?t:0,null!=(a=null!=(o=e.options.loaderMaxAge)?o:r.options.defaultLoaderMaxAge)?a:0);i>0&&(r.matchCache[e.matchId]={gc:i==1/0?Number.MAX_SAFE_INTEGER:s+i,match:e})})),i.forEach((e=>{null==e.options.onTransition||e.options.onTransition({params:e.params,search:e.routeSearch})}));n.filter((e=>!a.find((t=>t.matchId===e.matchId)))).forEach((e=>{e.__.onExit=null==e.options.onMatch?void 0:e.options.onMatch({params:e.params,search:e.search}),delete r.matchCache[e.matchId]})),n.some((e=>"loading"===e.status))&&(r.notify(),await Promise.all(n.map((e=>e.__.loaderPromise||Promise.resolve())))),r.startedLoadingAt===t&&(r.state=B({},r.state,{location:r.location,matches:n,pending:void 0,status:"idle"}),r.notify(),r.resolveNavigation())},cleanMatchCache:()=>{const e=Date.now();Object.keys(r.matchCache).forEach((t=>{const n=r.matchCache[t];"loading"!==n.match.status&&(n.gc>0&&n.gc>e||delete r.matchCache[t])}))},loadRoute:async function(e){void 0===e&&(e=r.location);const t=r.buildNext(e),n=r.matchRoutes(t.pathname,{strictParseParams:!0});return await r.loadMatches(n),n},preloadRoute:async function(e,t){var n,a,o,i,s,l;void 0===e&&(e=r.location);const c=r.buildNext(e),u=r.matchRoutes(c.pathname,{strictParseParams:!0});return await r.loadMatches(u,{preload:!0,maxAge:null!=(n=null!=(a=null!=(o=t.maxAge)?o:r.options.defaultPreloadMaxAge)?a:r.options.defaultLoaderMaxAge)?n:0,gcMaxAge:null!=(i=null!=(s=null!=(l=t.gcMaxAge)?l:r.options.defaultPreloadGcMaxAge)?s:r.options.defaultLoaderGcMaxAge)?i:0}),u},matchRoutes:(e,t)=>{var n,a;r.cleanMatchCache();const o=[];if(!r.routeTree)return o;const i=[...r.state.matches,...null!=(n=null==(a=r.state.pending)?void 0:a.matches)?n:[]],s=async n=>{var a,l,c;const u=E(o);let d=null!=(a=null==u?void 0:u.params)?a:{};const h=null!=(l=null==r.options.filterRoutes?void 0:r.options.filterRoutes(n))?l:n;let f=[];const p=(n,a)=>(a.some((a=>{var o,i,s;if(!a.routePath&&null!=(o=a.childRoutes)&&o.length)return p([...f,a],a.childRoutes);const l=!!("/"!==a.routePath||null!=(i=a.childRoutes)&&i.length),c=j(e,{to:a.fullPath,fuzzy:l,caseSensitive:null!=(s=a.options.caseSensitive)?s:r.options.caseSensitive});if(c){let e;try{var u;e=null!=(u=null==a.options.parseParams?void 0:a.options.parseParams(c))?u:c}catch(e){if(null!=t&&t.strictParseParams)throw e}d=B({},d,e)}return c&&(f=[...n,a]),!!f.length})),!!f.length);if(p([],h),!f.length)return;f.forEach((t=>{var n;const a=O(t.routePath,d),s=O(t.routeId,d,!0),l=i.find((e=>e.matchId===s))||(null==(n=r.matchCache[s])?void 0:n.match)||W(r,t,{matchId:s,params:d,pathname:M([e,a])});o.push(l)}));const m=E(f);null!=(c=m.childRoutes)&&c.length&&s(m.childRoutes)};return s([r.routeTree]),U(o),o},loadMatches:async(e,t)=>{const n=e.map((async e=>{e.__.validate(),e.load(t),"loading"===e.status&&(null!=t&&t.withPending&&e.__.startPending(),await e.__.loadPromise)}));r.notify(),await Promise.all(n)},invalidateRoute:e=>{var t,n;const a=r.buildNext(e),o=r.matchRoutes(a.pathname).map((e=>e.matchId));[...r.state.matches,...null!=(t=null==(n=r.state.pending)?void 0:n.matches)?t:[]].forEach((e=>{o.includes(e.matchId)&&e.invalidate()}))},reload:()=>r.__.navigate({fromCurrent:!0,replace:!0,search:!0}),resolvePath:(e,t)=>C(r.basepath,e,A(t)),matchRoute:(e,t)=>{var n;e=B({},e,{to:e.to?r.resolvePath(null!=(n=e.from)?n:"",e.to):void 0});const a=r.buildNext(e);var o;return null!=t&&t.pending?!(null==(o=r.state.pending)||!o.location)&&!!j(r.state.pending.location.pathname,B({},t,{to:a.pathname})):!!j(r.state.location.pathname,B({},t,{to:a.pathname}))},navigate:async e=>{let{from:t,to:n=".",search:a,hash:o,replace:i,params:s}=e;const l=String(n),c=String(t);let u;try{new URL(""+l),u=!0}catch(e){}return _(!u),r.__.navigate({from:c,to:l,search:a,hash:o,replace:i,params:s})},buildLink:e=>{var t,n;let{from:a,to:o=".",search:i,params:s,hash:l,target:c,replace:u,activeOptions:d,preload:h,preloadMaxAge:f,preloadGcMaxAge:p,preloadDelay:m,disabled:v}=e;try{return new URL(""+o),{type:"external",href:o}}catch(e){}const g={from:a,to:o,search:i,params:s,hash:l,replace:u},y=r.buildNext(g);h=null!=(t=h)?t:r.options.defaultPreload;const _=null!=(n=null!=m?m:r.options.defaultPreloadDelay)?n:0,P=r.state.location.pathname===y.pathname,b=r.state.location.pathname.split("/"),w=y.pathname.split("/").every(((e,t)=>e===b[t])),E=r.state.location.hash===y.hash,x=null!=d&&d.exact?P:w,R=null==d||!d.includeHash||E;return{type:"internal",next:y,handleFocus:e=>{h&&r.preloadRoute(g,{maxAge:f,gcMaxAge:p})},handleClick:e=>{v||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)||e.defaultPrevented||c&&"_self"!==c||0!==e.button||(e.preventDefault(),!P||i||l||r.invalidateRoute(g),r.__.navigate(g))},handleEnter:e=>{const t=e.target||{};if(h){if(t.preloadTimeout)return;t.preloadTimeout=setTimeout((()=>{t.preloadTimeout=null,r.preloadRoute(g,{maxAge:f,gcMaxAge:p})}),_)}},handleLeave:e=>{const t=e.target||{};t.preloadTimeout&&(clearTimeout(t.preloadTimeout),t.preloadTimeout=null)},isActive:x&&R,disabled:v}},buildNext:e=>{const t=r.__.buildLocation(e),n=r.matchRoutes(t.pathname),a=n.map((e=>{var t;return null!=(t=e.options.preSearchFilters)?t:[]})).flat().filter(Boolean),o=n.map((e=>{var t;return null!=(t=e.options.postSearchFilters)?t:[]})).flat().filter(Boolean);return r.__.buildLocation(B({},e,{__preSearchFilters:a,__postSearchFilters:o}))},__:{buildRouteTree:e=>{const t=(e,n)=>e.map((e=>{const a=H(e,e.options,n,r);if(r.routesById[a.routeId])throw new Error;r.routesById[a.routeId]=a;const o=e.children;return a.childRoutes=null!=o&&o.length?t(o,a):void 0,a}));return t([e])[0]},parseLocation:(e,t)=>{var n;const a=r.options.parseSearch(e.search);return{pathname:e.pathname,searchStr:e.search,search:P(null==t?void 0:t.search,a),hash:null!=(n=e.hash.split("#").reverse()[0])?n:"",href:""+e.pathname+e.search+e.hash,state:e.state,key:e.key}},navigate:e=>{const t=r.buildNext(e);return r.__.commitLocation(t,e.replace)},buildLocation:function(e){var t,n,a,o,i,s,l,c,u;void 0===e&&(e={});const d=e.fromCurrent?r.location.pathname:null!=(t=e.from)?t:r.location.pathname;let h=C(null!=(n=r.basepath)?n:"/",d,""+(null!=(a=e.to)?a:"."));const f=r.matchRoutes(r.location.pathname,{strictParseParams:!0}),p=r.matchRoutes(h),m=B({},null==(o=E(f))?void 0:o.params);let v=!0===(null==(i=e.params)||i)?m:R(e.params,m);v&&p.map((e=>e.options.stringifyParams)).filter(Boolean).forEach((e=>{Object.assign({},v,e(v))})),h=O(h,null!=v?v:{});const g=null!=(s=e.__preSearchFilters)&&s.length?e.__preSearchFilters.reduce(((e,t)=>t(e)),r.location.search):r.location.search,y=!0===e.search?g:e.search?null!=(l=R(e.search,g))?l:{}:null!=(c=e.__preSearchFilters)&&c.length?g:{},_=null!=(u=e.__postSearchFilters)&&u.length?e.__postSearchFilters.reduce(((e,t)=>t(e)),y):y,b=P(r.location.search,_),w=r.options.stringifySearch(b);let x=!0===e.hash?r.location.hash:R(e.hash,r.location.hash);return x=x?"#"+x:"",{pathname:h,search:b,searchStr:w,state:r.location.state,hash:x,href:""+h+w+x,key:e.key}},commitLocation:(e,t)=>{const n=""+Date.now()+Math.random();r.navigateTimeout&&clearTimeout(r.navigateTimeout);let o="replace";t||(o="push");return r.__.parseLocation(a.location).href===e.href&&!e.key&&(o="replace"),"replace"===o?a.replace({pathname:e.pathname,hash:e.hash,search:e.searchStr},{id:n}):a.push({pathname:e.pathname,hash:e.hash,search:e.searchStr},{id:n}),r.navigationPromise=new Promise((e=>{const t=r.resolveNavigation;r.resolveNavigation=()=>{t(),e()}})),r.navigationPromise}}};return r.update(e),null==r.options.createRouter||r.options.createRouter(r),r}const $=["type","children","target","activeProps","inactiveProps","activeOptions","disabled","hash","search","params","to","preload","preloadDelay","preloadMaxAge","replace","style","className","onClick","onFocus","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd"],Z=["pending","caseSensitive","children"],ee=["children","router"],te=r.createContext(null),ne=r.createContext(null),ae=Boolean("undefined"!=typeof window&&window.document&&window.document.createElement)?r.useLayoutEffect:r.useEffect;function oe(e){return r.createElement(te.Provider,e)}const re=e=>{n.useSyncExternalStore((t=>e.subscribe((()=>t()))),(()=>e.state),(()=>e.state))};function ie(){const e=r.useContext(ne);return x(!e,"useRouter must be used inside a <Router> component!"),re(e.router),e.router}function se(){return r.useContext(te)}function le(){var e;const t=ie(),[,...n]=se(),a=n[0];if(!a)return null;const o=(()=>{var e,n;if(!a)return null;const o=null!=(e=a.__.errorElement)?e:t.options.defaultErrorElement;if("error"===a.status){if(o)return o;if(a.options.useErrorBoundary||t.options.useErrorBoundary)throw a.error;return r.createElement(ue,{error:a.error})}if("loading"===a.status||"idle"===a.status){if(a.isPending){var i;const e=null!=(i=a.__.pendingElement)?i:t.options.defaultPendingElement;var s;if(a.options.pendingMs||e)return null!=(s=e)?s:null}return null}return null!=(n=a.__.element)?n:t.options.defaultElement})(),i=null!=(e=null==a?void 0:a.options.catchElement)?e:t.options.defaultCatchElement;return r.createElement(oe,{value:n,key:a.matchId},r.createElement(ce,{catchElement:i},o))}class ce extends r.Component{constructor(){super(...arguments),this.state={error:!1},this.reset=()=>{this.setState({error:!1,info:!1})}}componentDidCatch(e,t){console.error(e),this.setState({error:e,info:t})}render(){var e;const t=null!=(e=this.props.catchElement)?e:ue;return this.state.error?"function"==typeof t?t(this.state):t:this.props.children}}function ue(e){let{error:t}=e;return r.createElement("div",{style:{padding:".5rem",maxWidth:"100%"}},r.createElement("strong",{style:{fontSize:"1.2rem"}},"Something went wrong!"),r.createElement("div",{style:{height:".5rem"}}),r.createElement("div",null,r.createElement("pre",null,t.message?r.createElement("code",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".5rem",color:"red"}},t.message):null)),r.createElement("div",{style:{height:"1rem"}}),r.createElement("div",{style:{fontSize:".8em",borderLeft:"3px solid rgba(127, 127, 127, 1)",paddingLeft:".5rem",opacity:.5}},"If you are the owner of this website, it's highly recommended that you configure your own custom Catch/Error boundaries for the router. You can optionally configure a boundary for each route."))}function de(e,t){const n=ie();r.useEffect((()=>{if(!t)return;let a=n.history.block((t=>{window.confirm(e)?(a(),t.retry()):n.location.pathname=window.location.pathname}));return a}),[t,location,e])}e.DefaultErrorBoundary=ue,e.MatchesProvider=oe,e.Outlet=le,e.Prompt=function(e){let{message:t,when:n,children:a}=e;return de(t,null==n||n),null!=a?a:null},e.RouterProvider=function(e){let{children:t,router:n}=e,a=s(e,ee);return n.update(a),re(n),ae((()=>n.mount()),[n]),r.createElement(ne.Provider,{value:{router:n}},r.createElement(oe,{value:n.state.matches},null!=t?t:r.createElement(le,null)))},e.cascadeLoaderData=U,e.cleanPath=A,e.createBrowserHistory=d,e.createHashHistory=function(e){void 0===e&&(e={});var t=e.window,n=void 0===t?document.defaultView:t,a=n.history;function r(){var e=y(n.location.hash.substr(1)),t=e.pathname,o=void 0===t?"/":t,r=e.search,i=void 0===r?"":r,s=e.hash,l=void 0===s?"":s,c=a.state||{};return[c.idx,{pathname:o,search:i,hash:l,state:c.usr||null,key:c.key||"default"}]}var i=null;function s(){if(i)b.call(i),i=null;else{var e=o.Pop,t=r(),n=t[0],a=t[1];if(b.length){if(null!=n){var s=f-n;s&&(i={action:e,location:a,retry:function(){A(-1*s)}},A(s))}}else M(e)}}n.addEventListener(u,s),n.addEventListener("hashchange",(function(){g(r()[1])!==g(_)&&s()}));var d=o.Pop,h=r(),f=h[0],_=h[1],P=m(),b=m();function w(e){return function(){var e=document.querySelector("base"),t="";if(e&&e.getAttribute("href")){var a=n.location.href,o=a.indexOf("#");t=-1===o?a:a.slice(0,o)}return t}()+"#"+("string"==typeof e?e:g(e))}function E(e,t){return void 0===t&&(t=null),l({pathname:_.pathname,hash:"",search:""},"string"==typeof e?y(e):e,{state:t,key:v()})}function x(e,t){return[{usr:e.state,key:e.key,idx:t},w(e)]}function R(e,t,n){return!b.length||(b.call({action:e,location:t,retry:n}),!1)}function M(e){d=e;var t=r();f=t[0],_=t[1],P.call({action:d,location:_})}function A(e){a.go(e)}null==f&&(f=0,a.replaceState(l({},a.state,{idx:f}),""));var S={get action(){return d},get location(){return _},createHref:w,push:function e(t,r){var i=o.Push,s=E(t,r);if(R(i,s,(function(){e(t,r)}))){var l=x(s,f+1),c=l[0],u=l[1];try{a.pushState(c,"",u)}catch(e){n.location.assign(u)}M(i)}},replace:function e(t,n){var r=o.Replace,i=E(t,n);if(R(r,i,(function(){e(t,n)}))){var s=x(i,f),l=s[0],c=s[1];a.replaceState(l,"",c),M(r)}},go:A,back:function(){A(-1)},forward:function(){A(1)},listen:function(e){return P.push(e)},block:function(e){var t=b.push(e);return 1===b.length&&n.addEventListener(c,p),function(){t(),b.length||n.removeEventListener(c,p)}}};return S},e.createMemoryHistory=h,e.createReactRouter=function(e){const t=(e,t)=>({useRoute:function(n){void 0===n&&(n=".");const a=t.resolvePath(e.routeId,n),o=t.getRoute(a);return re(t),_(o),o},linkProps:t=>{var n,a;const{target:o,activeProps:r=(()=>({className:"active"})),inactiveProps:l=(()=>({})),disabled:c,style:u,className:d,onClick:h,onFocus:f,onMouseEnter:p,onMouseLeave:m}=t,v=s(t,$),g=e.buildLink(t);if("external"===g.type){const{href:e}=g;return{href:e}}const{handleClick:y,handleFocus:_,handleEnter:P,handleLeave:b,isActive:w,next:E}=g,x=e=>t=>{t.persist(),e.forEach((e=>{e&&e(t)}))},M=w&&null!=(n=R(r,{}))?n:{},A=w?{}:null!=(a=R(l,{}))?a:{};return i({},M,A,v,{href:c?void 0:E.href,onClick:x([y,h]),onFocus:x([_,f]),onMouseEnter:x([P,p]),onMouseLeave:x([b,m]),target:o,style:i({},u,M.style,A.style),className:[d,M.className,A.className].filter(Boolean).join(" ")||void 0},c?{role:"link","aria-disabled":!0}:void 0,{"data-status":w?"active":void 0})},Link:r.forwardRef(((n,a)=>{const o=e.linkProps(n);return re(t),r.createElement("a",i({ref:a},o,{children:"function"==typeof n.children?n.children({isActive:"active"===o["data-status"]}):n.children}))})),MatchRoute:t=>{const{pending:n,caseSensitive:a}=t,o=s(t,Z),r=e.matchRoute(o,{pending:n,caseSensitive:a});return r?"function"==typeof t.children?t.children(r):t.children:null}});return Y(i({},e,{createRouter:e=>{const n={useState:()=>(re(e),e.state),useMatch:t=>{re(e),_(t!==z);const n=null==(a=se())?void 0:a[0];var a;const o=e.state.matches.find((e=>e.routeId===t));return _(o),_(n.routeId==(null==o?void 0:o.routeId),(null==o||o.routeId,n.routeId,null==o||o.routeId)),o||_("Match not found!"),o}},a=t(e.getRoute("/"),e);Object.assign(e,n,a)},createRoute:e=>{let{router:n,route:a}=e;const o=t(a,n);Object.assign(a,o)},createElement:async e=>{if("function"==typeof e){const t=await e();return"object"==typeof t&&t.default?r.createElement(t.default):t}return e}}))},e.createRoute=H,e.createRouteConfig=function e(t,n,a,o,r){void 0===t&&(t={}),void 0===a&&(a=!0),a&&(t.path=z),o===z&&(o="");let i=a?z:t.path;i&&"/"!==i&&(i=L(i));const s=i||t.id;let l=M([o,s]);i===z&&(i="/"),l!==z&&(l=M(["/",l]));const c=l===z?"/":I(M([r,i]));return{id:l,routeId:s,path:i,fullPath:c,options:t,children:n,createChildren:n=>e(t,n((t=>e(t,void 0,!1,l,c))),!1,o,r),addChildren:n=>e(t,n,!1,o,r),createRoute:t=>e(t,void 0,!1,l,c)}},e.createRouteMatch=W,e.createRouter=Y,e.decode=N,e.defaultParseSearch=q,e.defaultStringifySearch=K,e.encode=D,e.functionalUpdate=R,e.interpolatePath=O,e.invariant=_,e.joinPaths=M,e.last=E,e.matchByPath=T,e.matchPathname=j,e.parsePathname=k,e.parseSearchWith=Q,e.replaceEqualDeep=P,e.resolvePath=C,e.rootRouteId=z,e.stringifySearchWith=V,e.trimPath=L,e.trimPathLeft=S,e.trimPathRight=I,e.usePrompt=de,e.warning=x,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
21
|
+
*/
|
|
22
|
+
const at="popstate";function st(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 nt(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),r=t?.createHref??(t=>t);return st({getLocation:()=>ct(e(),history.state),listener:t=>(window.addEventListener(at,t),()=>{window.removeEventListener(at,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:ut()},"",r(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:ut()},"",r(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t)})}function it(t={initialEntries:["/"]}){const e=t.initialEntries;let r=t.initialIndex??e.length-1,o={};return st({getLocation:()=>ct(e[r],o),listener:t=>(window.addEventListener(at,t),()=>{window.removeEventListener(at,t)}),pushState:(t,a)=>{o={...a,key:ut()},e.push(t),r++},replaceState:(t,a)=>{o={...a,key:ut()},e[r]=t},back:()=>{r--},forward:()=>{r=Math.min(r+1,e.length-1)},go:t=>window.history.go(t)})}function ct(t,e){let r=t.indexOf("#"),o=t.indexOf("?");const a=Math.min(r,o);return{href:t,pathname:a>-1?t.substring(0,a):t,hash:r>-1?t.substring(r,o):"",search:o>-1?t.substring(o):"",state:e}}function ut(){return(Math.random()+1).toString(36).substring(7)}function ht(t){return t[t.length-1]}function lt(t,e){if(t){"undefined"!=typeof console&&console.warn(e);try{throw new Error(e)}catch{}}return!0}function dt(t,e){return function(t){return"function"==typeof t}(t)?t(e):t}function ft(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function pt(t){return mt(t.filter(Boolean).join("/"))}function mt(t){return t.replace(/\/{2,}/g,"/")}function gt(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function vt(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function yt(t){return vt(gt(t))}function bt(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let o=wt(e);const a=wt(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&&"/"===ht(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));const s=pt([t,...o.map((t=>t.value))]);return mt(s)}function wt(t){if(!t)return[];const e=[];if("/"===(t=mt(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 St(t,e,r){return pt(wt(t).map((t=>"*"!==t.value||r?"param"===t.type?e[t.value.substring(1)]??"":t.value:"")))}function Pt(t,e,r){const o=Lt(t,e,r);if(!r.to||o)return o??{}}function Lt(t,e,r){if(!e.startsWith(t))return;const o=wt(e="/"!=t?e.substring(t.length):e),a=wt(`${r.to??"*"}`),s={};let n=(()=>{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["*"]=pt(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})();return n?s:void 0}function Et(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 Mt(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function At(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],Mt(e.shift())):o[r]=Mt(e.shift());return o}class xt{constructor(t,e,r,o,a){Object.assign(this,{...t,originalIndex:r,options:e,getRouter:()=>a,childRoutes:void 0,getParentRoute:()=>o}),a.options.createRoute?.({router:a,route:this})}}const _t="__root__",Ot=(t={},e=[],r=!0,o,a)=>{r&&(t.path=_t),o===_t&&(o="");let s=r?_t:t.path;s&&"/"!==s&&(s=yt(s));const i=s||t.id;let c=pt([o,i]);s===_t&&(s="/"),c!==_t&&(c=pt(["/",c]));const u=c===_t?"/":vt(pt([a,s]));return{id:c,routeId:i,path:s,fullPath:u,options:t,children:e,addChildren:e=>Ot(t,e,!1,o,a),createRoute:t=>Ot(t,void 0,!1,c,u),generate:()=>{n(!1)}}};ot(!1);let Rt=[],Dt=!1;function jt(){Dt||(Rt.forEach((t=>t())),Rt=[])}function Ct(t,e){const r=new Set,o={state:t,subscribe:t=>(r.add(t),()=>r.delete(t)),setState:t=>{const a=o.state;o.state=rt((e=>{t(e)}))(a),e&&console.log(o.state),Rt.push((()=>r.forEach((t=>t(o.state,a))))),jt()}};return o}function kt(t){Dt=!0,t(),Dt=!1,jt()}function Ft(t,e){if(t===e)return t;const r=e,o=Array.isArray(t)&&Array.isArray(r);if(o||It(t)&&It(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]=Ft(t[s],r[s]),n[s]===t[s]&&i++}return e===s&&i===e?t:n}return r}function It(t){if(!$t(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!$t(r)&&!!r.hasOwnProperty("isPrototypeOf")}function $t(t){return"[object Object]"===Object.prototype.toString.call(t)}const Nt=["component","errorComponent","pendingComponent"];class Tt{abortController=new AbortController;#t="";#e=()=>{};onLoaderDataListeners=new Set;constructor(t,e,r){Object.assign(this,{route:e,router:t,id:r.id,pathname:r.pathname,params:r.params,store:Ct({routeSearch:{},search:{},status:"idle",routeLoaderData:{},loaderData:{},isFetching:!1,invalid:!1,invalidAt:1/0})}),this.__hasLoaders()||this.store.setState((t=>t.status="success"))}#r=t=>{kt((()=>{this.store.setState((e=>{e.routeLoaderData=t})),this.#o()}))};cancel=()=>{this.abortController?.abort()};load=async t=>{const e=Date.now(),r=t?.preload?Math.max(t?.maxAge,t?.gcMaxAge):0;if(t?.preload&&r>0){if(this.router.store.state.currentMatches.find((t=>t.id===this.id)))return;this.router.store.setState((r=>{r.matchCache[this.id]={gc:e+t.gcMaxAge,match:this}}))}if("success"===this.store.state.status&&this.getIsInvalid()||"error"===this.store.state.status||"idle"===this.store.state.status){const e=t?.preload?t?.maxAge:void 0;await this.fetch({maxAge:e})}};fetch=async t=>(this.__loadPromise=new Promise((async e=>{const r=""+Date.now()+Math.random();this.#t=r;const o=()=>r!==this.#t?this.__loadPromise?.then((()=>e())):void 0;let a;kt((()=>{"idle"===this.store.state.status&&this.store.setState((t=>t.status="loading")),this.store.setState((t=>t.invalid=!1))})),this.store.setState((t=>t.isFetching=!0)),this.#e=e;const s=(async()=>{await Promise.all(Nt.map((async t=>{const e=this.route.options[t];this[t]?.preload&&(this[t]=await this.router.options.loadComponent(e))})))})(),n=Promise.resolve().then((async()=>{try{if(this.route.options.loader){const t=await this.router.loadMatchData(this);if(a=o())return a;this.#r(t)}return this.store.setState((e=>{e.error=void 0,e.status="success",e.updatedAt=Date.now(),e.invalidAt=e.updatedAt+(t?.maxAge??this.route.options.loaderMaxAge??this.router.options.defaultLoaderMaxAge??0)})),this.store.state.routeLoaderData}catch(t){if(a=o())return a;throw this.store.setState((e=>{e.error=t,e.status="error",e.updatedAt=Date.now()})),t}})),i=async()=>{if(a=o())return a;this.store.setState((t=>t.isFetching=!1)),this.#e(),delete this.__loadPromise};try{await Promise.all([s,n.catch((()=>{}))]),i()}catch{i()}})),this.__loadPromise);invalidate=async()=>{this.store.setState((t=>t.invalid=!0)),this.router.store.state.currentMatches.find((t=>t.id===this.id))&&await this.load()};__hasLoaders=()=>!(!this.route.options.loader&&!Nt.some((t=>this.route.options[t]?.preload)));getIsInvalid=()=>{const t=Date.now();return this.store.state.invalid||this.store.state.invalidAt<t};#o=()=>{this.store.setState((t=>{t.loaderData=Ft(t.loaderData,{...this.parentMatch?.store.state.loaderData,...t.routeLoaderData})})),this.onLoaderDataListeners.forEach((t=>t()))};__setParentMatch=t=>{!this.parentMatch&&t&&(this.parentMatch=t,this.parentMatch.__onLoaderData((()=>{this.#o()})))};__onLoaderData=t=>{this.onLoaderDataListeners.add(t)};__validate=()=>{const t=this.parentMatch?.store.state.search??this.router.store.state.latestLocation.search;try{const e=this.store.state.routeSearch;let r=("object"==typeof this.route.options.validateSearch?this.route.options.validateSearch.parse:this.route.options.validateSearch)?.(t)??{};kt((()=>{e!==r&&this.store.setState((t=>t.invalid=!0)),this.store.setState((e=>{e.routeSearch=r,e.search={...t,...r}}))})),Nt.map((async t=>{const e=this.route.options[t];"function"!=typeof this[t]&&(this[t]=e)}))}catch(t){console.error(t);const e=new Error("Invalid search params found",{cause:t});return e.code="INVALID_SEARCH_PARAMS",void this.store.setState((t=>{t.status="error",t.error=e}))}}}const zt=Ut(JSON.parse),Bt=Ht(JSON.stringify);function Ut(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=At(e);for(let e in r){const o=r[e];if("string"==typeof o)try{r[e]=t(o)}catch(t){}}return r}}function Ht(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=Et(e).toString();return r?`?${r}`:""}}const Kt=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 Wt{startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultLoaderGcMaxAge:3e5,defaultLoaderMaxAge:0,defaultPreloadMaxAge:2e3,defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??Bt,parseSearch:t?.parseSearch??zt,fetchServerDataFn:t?.fetchServerDataFn??Kt},this.store=Ct(Jt()),this.basepath="",this.update(t),this.options.Router?.(this)}reset=()=>{this.store.setState((t=>Object.assign(t,Jt())))};mount=()=>{if(!Gt){this.store.state.currentMatches.length||this.load();const t=this.history.listen((()=>{this.load(this.#a(this.store.state.latestLocation))})),e="visibilitychange",r="focus";return window.addEventListener&&(window.addEventListener(e,this.#s,!1),window.addEventListener(r,this.#s,!1)),()=>{t(),window.removeEventListener&&(window.removeEventListener(e,this.#s),window.removeEventListener(r,this.#s))}}return()=>{}};update=t=>{Object.assign(this.options,t),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options?.history??Gt?it():nt(),this.store.setState((t=>{t.latestLocation=this.#a(),t.currentLocation=t.latestLocation})));const{basepath:e,routeConfig:r}=this.options;return this.basepath=`/${yt(e??"")??""}`,r&&(this.routesById={},this.routeTree=this.#n(r)),this};buildNext=t=>{const e=this.#i(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.#i({...t,__preSearchFilters:o,__postSearchFilters:a})};cancelMatches=()=>{[...this.store.state.currentMatches,...this.store.state.pendingMatches||[]].forEach((t=>{t.cancel()}))};load=async t=>{let e=Date.now();const r=e;let o;this.startedLoadingAt=r,this.cancelMatches(),kt((()=>{t&&this.store.setState((e=>{e.latestLocation=t})),o=this.matchRoutes(this.store.state.latestLocation.pathname,{strictParseParams:!0}),this.store.setState((t=>{t.status="loading",t.pendingMatches=o,t.pendingLocation=this.store.state.latestLocation}))}));try{await this.loadMatches(o)}catch(t){console.warn(t),n(!1)}if(this.startedLoadingAt!==r)return this.navigationPromise;const a=this.store.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.store.state.routeSearch}),"error"!==t.store.state.status||t.store.state.isFetching||t.store.setState((t=>{t.status="idle",t.error=void 0}));const r=Math.max(t.route.options.loaderGcMaxAge??this.options.defaultLoaderGcMaxAge??0,t.route.options.loaderMaxAge??this.options.defaultLoaderMaxAge??0);r>0&&this.store.setState((o=>{o.matchCache[t.id]={gc:r==1/0?Number.MAX_SAFE_INTEGER:e+r,match:t}}))})),i.forEach((t=>{t.route.options.onTransition?.({params:t.params,search:t.store.state.routeSearch})})),c.forEach((t=>{t.__onExit=t.route.options.onLoaded?.({params:t.params,search:t.store.state.search}),delete this.store.state.matchCache[t.id]})),this.store.setState((t=>{Object.assign(t,{status:"idle",currentLocation:this.store.state.latestLocation,currentMatches:o,pendingLocation:void 0,pendingMatches:void 0})})),this.options.onRouteChange?.(),this.resolveNavigation()};cleanMatchCache=()=>{const t=Date.now();this.store.setState((e=>{Object.keys(e.matchCache).forEach((r=>{const o=e.matchCache[r];"loading"!==o.match.store.state.status&&(o.gc>0&&o.gc>t||delete e.matchCache[r])}))}))};getRoute=t=>{const e=this.routesById[t];return n(e),e};loadRoute=async(t=this.store.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r),r};preloadRoute=async(t=this.store.state.latestLocation,e)=>{const r=this.buildNext(t),o=this.matchRoutes(r.pathname,{strictParseParams:!0});return await this.loadMatches(o,{preload:!0,maxAge:e.maxAge??this.options.defaultPreloadMaxAge??this.options.defaultLoaderMaxAge??0,gcMaxAge:e.gcMaxAge??this.options.defaultPreloadGcMaxAge??this.options.defaultLoaderGcMaxAge??0}),o};matchRoutes=(t,e)=>{const r=[];if(!this.routeTree)return r;const o=[...this.store.state.currentMatches,...this.store.state.pendingMatches??[]],a=async s=>{let n=ht(r)?.params??{};const i=this.options.filterRoutes?.(s)??s;let c=[];const u=(r,o)=>(o.some((o=>{if(!o.path&&o.childRoutes?.length)return u([...c,o],o.childRoutes);const a=!("/"===o.path&&!o.childRoutes?.length),s=Pt(this.basepath,t,{to:o.fullPath,fuzzy:a,caseSensitive:o.options.caseSensitive??this.options.caseSensitive});if(s){let t;try{t=o.options.parseParams?.(s)??s}catch(t){if(e?.strictParseParams)throw t}n={...n,...t}}return s&&(c=[...r,o]),!!c.length})),!!c.length);if(u([],i),!c.length)return;c.forEach((t=>{const e=St(t.path,n),a=St(t.id,n,!0),s=o.find((t=>t.id===a))||this.store.state.matchCache[a]?.match||new Tt(this,t,{id:a,params:n,pathname:pt([this.basepath,e])});r.push(s)}));const h=ht(c);h.childRoutes?.length&&a(h.childRoutes)};return a([this.routeTree]),function(t){t.forEach(((e,r)=>{const o=t[r-1];o&&e.__setParentMatch(o)}))}(r),r};loadMatches=async(t,e)=>{this.cleanMatchCache(),t.forEach((async t=>{t.__validate()})),await Promise.all(t.map((async t=>{try{await(t.route.options.beforeLoad?.({router:this,match:t}))}catch(r){throw e?.preload||t.route.options.onLoadError?.(r),r}})));const r=t.map((async(r,o)=>{const a=t[1],s=r.store.state.search;s.__data?.matchId&&s.__data.matchId!==r.id||(r.load(e),"success"!==r.store.state.status&&r.__loadPromise&&await r.__loadPromise,a&&await a.__loadPromise)}));await Promise.all(r)};loadMatchData=async t=>{if(Gt||!this.options.useServerData)return await(t.route.options.loader?.({params:t.params,search:t.store.state.routeSearch,signal:t.abortController.signal}))||{};return await this.options.fetchServerDataFn({router:this,routeMatch:t})};invalidateRoute=async t=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname).map((t=>t.id));await Promise.allSettled([...this.store.state.currentMatches,...this.store.state.pendingMatches??[]].map((async t=>{if(r.includes(t.id))return t.invalidate()})))};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>bt(this.basepath,t,mt(e));navigate=async({from:t,to:e=".",search:r,hash:o,replace:a,params:s})=>{const i=String(e),c=String(t);let u;try{new URL(`${i}`),u=!0}catch(t){}return n(!u),this.#c({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);return e?.pending?!!this.store.state.pendingLocation&&Pt(this.basepath,this.store.state.pendingLocation.pathname,{...e,to:r.pathname}):Pt(this.basepath,this.store.state.currentLocation.pathname,{...e,to:r.pathname})};buildLink=({from:t,to:e=".",search:r,params:o,hash:a,target:s,replace:n,activeOptions:i,preload:c,preloadMaxAge:u,preloadGcMaxAge:h,preloadDelay:l,disabled:d})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const f={from:t,to:e,search:r,params:o,hash:a,replace:n},p=this.buildNext(f);c=c??this.options.defaultPreload;const m=l??this.options.defaultPreloadDelay??0,g=this.store.state.currentLocation.pathname===p.pathname,v=this.store.state.currentLocation.pathname.split("/"),y=p.pathname.split("/").every(((t,e)=>t===v[e])),b=this.store.state.currentLocation.hash===p.hash;return{type:"internal",next:p,handleFocus:t=>{c&&this.preloadRoute(f,{maxAge:u,gcMaxAge:h}).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{d||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||s&&"_self"!==s||0!==t.button||(t.preventDefault(),!g||r||a||this.invalidateRoute(f),this.#c(f))},handleEnter:t=>{const e=t.target||{};if(c){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(f,{maxAge:u,gcMaxAge:h}).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),m)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},isActive:(i?.exact?g:y)&&(!i?.includeHash||b),disabled:d}};dehydrate=()=>({state:{...ft(this.store.state,["latestLocation","currentLocation","status","lastUpdated"]),currentMatches:this.store.state.currentMatches.map((t=>({id:t.id,state:{...ft(t.store.state,["status","routeLoaderData","invalidAt","invalid"])}})))},context:this.options.context});hydrate=t=>{this.store.setState((e=>{this.options.context=t.context;const r=this.matchRoutes(t.state.latestLocation.pathname,{strictParseParams:!0});r.forEach(((e,r)=>{const o=t.state.currentMatches[r];n(o&&o.id===e.id),Object.assign(e,o)})),r.forEach((t=>t.__validate())),Object.assign(e,{...t.state,currentMatches:r})}))};getLoader=t=>{const e=t.from||"/",r=this.getRoute(e);if(!r)return;let o=this.store.state.loaders[e]||(()=>(this.store.setState((t=>{t.loaders[e]={pending:[],fetch:async t=>{if(!r)return;const o={loadedAt:Date.now(),loaderContext:t};this.store.setState((t=>{t.loaders[e].current=o,t.loaders[e].latest=o,t.loaders[e].pending.push(o)}));try{return await(r.options.loader?.(t))}finally{this.store.setState((t=>{t.loaders[e].pending=t.loaders[e].pending.filter((t=>t!==o))}))}}}})),this.store.state.loaders[e]))();return o};#n=t=>{const e=(t,r)=>t.map(((t,o)=>{const a=t.options,s=new xt(t,a,o,r,this);if(this.routesById[s.id])throw new Error;this.routesById[s.id]=s;const n=t.children;return s.childRoutes=n.length?e(n,s):void 0,s}));return e([t])[0]};#a=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:Ft(t?.search,s),hash:o.split("#").reverse()[0]??"",href:`${e}${r}${o}`,state:a,key:a?.key||"__init__"}};#s=()=>{this.load()};#i=(t={})=>{const e=t.fromCurrent?this.store.state.latestLocation.pathname:t.from??this.store.state.latestLocation.pathname;let r=bt(this.basepath??"/",e,`${t.to??"."}`);const o=this.matchRoutes(this.store.state.latestLocation.pathname,{strictParseParams:!0}),a=this.matchRoutes(r),s={...ht(o)?.params};let n=!0===(t.params??!0)?s:dt(t.params,s);n&&a.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},n,t(n))})),r=St(r,n??{});const i=t.__preSearchFilters?.length?t.__preSearchFilters?.reduce(((t,e)=>e(t)),this.store.state.latestLocation.search):this.store.state.latestLocation.search,c=!0===t.search?i:t.search?dt(t.search,i)??{}:t.__preSearchFilters?.length?i:{},u=t.__postSearchFilters?.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),c):c,h=Ft(this.store.state.latestLocation.search,u),l=this.options.stringifySearch(h);let d=!0===t.hash?this.store.state.latestLocation.hash:dt(t.hash,this.store.state.latestLocation.hash);return d=d?`#${d}`:"",{pathname:r,search:h,searchStr:l,state:this.store.state.latestLocation.state,hash:d,href:`${r}${l}${d}`,key:t.key}};#c=t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let o="replace";t.replace||(o="push");this.store.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 Gt="undefined"==typeof window||!window.document.createElement;function Jt(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],loaders:{},lastUpdated:Date.now(),matchCache:{},get isFetching(){return"loading"===this.status||this.currentMatches.some((t=>t.store.state.isFetching))},get isPreloading(){return Object.values(this.matchCache).some((t=>t.match.store.state.isFetching&&!this.currentMatches.find((e=>e.id===t.match.id))))}}}function qt(t,e=(t=>t),o){return r.useSyncExternalStoreWithSelector(t.subscribe,(()=>t.state),(()=>t.state),e,o?Xt:void 0)}function Xt(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 Vt(t){const e=te(),{type:r,children:o,target:s,activeProps:n=(()=>({className:"active"})),inactiveProps:i=(()=>({})),activeOptions:c,disabled:u,hash:h,search:l,params:d,to:f=".",preload:p,preloadDelay:m,preloadMaxAge:g,replace:v,style:y,className:b,onClick:w,onFocus:S,onMouseEnter:P,onMouseLeave:L,onTouchStart:E,onTouchEnd:M,...A}=t,x=e.buildLink(t);if("external"===x.type){const{href:t}=x;return{href:t}}const{handleClick:_,handleFocus:O,handleEnter:R,handleLeave:D,isActive:j,next:C}=x,k=t=>e=>{e.persist&&e.persist(),t.filter(Boolean).forEach((t=>{e.defaultPrevented||t(e)}))},F=j?dt(n,{})??{}:{},I=j?{}:dt(i,{})??{};return{...F,...I,...A,href:u?void 0:C.href,onClick:k([w,t=>{a.startTransition?a.startTransition((()=>{_(t)})):_(t)}]),onFocus:k([S,O]),onMouseEnter:k([P,R]),onMouseLeave:k([L,D]),target:s,style:{...y,...F.style,...I.style},className:[b,F.className,I.className].filter(Boolean).join(" ")||void 0,...u?{role:"link","aria-disabled":!0}:void 0,"data-status":j?"active":void 0}}const Qt=a.forwardRef(((t,e)=>{const r=Vt(t);return a.createElement("a",s({ref:e},r,{children:"function"==typeof t.children?t.children({isActive:"active"===r["data-status"]}):t.children}))})),Yt=a.createContext(null),Zt=a.createContext(null);function te(){const t=a.useContext(Zt);return lt(!t,"useRouter must be used inside a <Router> component!"),t.router}function ee(){return a.useContext(Yt)}function re(t){const e=te(),r=ee()[0],o=t?.from?e.store.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)),qt(o.store,(e=>t?.track?.(o)??o),t?.shallow),o}function oe(){const t=te();return e=>{const{pending:r,caseSensitive:o,...a}=e;return t.matchRoute(a,{pending:r,caseSensitive:o})}}function ae(){const t=ee().slice(1),e=t[0];return e?a.createElement(se,{matches:t,match:e}):null}function se({matches:t,match:e}){const r=te();qt(e.store);const o=a.useCallback((()=>null),[]),s=a.useCallback((t=>{if("error"===t.match.store.state.status)throw t.match.store.state.error;if("success"===t.match.store.state.status)return a.createElement(t.match.component??r.options.defaultComponent??ae);if("loading"===t.match.store.state.status)throw t.match.__loadPromise;n(!1)}),[]),i=e.pendingComponent??r.options.defaultPendingComponent??o,c=e.errorComponent??r.options.defaultErrorComponent;return a.createElement(Yt.Provider,{value:t},a.createElement(a.Suspense,{fallback:a.createElement(i,null)},a.createElement(ne,{key:e.route.id,errorComponent:c,match:e},a.createElement(s,{match:e}))))}class ne 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(ie,s({},this.props,{errorState:this.state,reset:()=>this.setState({})}))}}function ie(t){const[e,r]=a.useState(t.errorState);te();const o=t.errorComponent??ce;return a.useEffect((()=>{t.errorState.error&&r(t.errorState),t.reset()}),[t.errorState.error]),t.errorState.error?a.createElement(o,e):t.children}function ce({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=ce,t.Link=Qt,t.MatchRoute=function(t){const e=oe()(t);return e?"function"==typeof t.children?t.children(e):e?t.children:null:null},t.Outlet=ae,t.ReactRouter=class extends Wt{constructor(t){super({...t,loadComponent:async t=>(t.preload&&await t.preload(),t)})}},t.Route=xt,t.RouteMatch=Tt,t.Router=Wt,t.RouterProvider=function({router:t,...e}){t.update(e);const r=qt(t.store,(t=>t.currentMatches),void 0);return a.useEffect(t.mount,[t]),a.createElement(a.Fragment,null,a.createElement(Zt.Provider,{value:{router:t}},a.createElement(Yt.Provider,{value:[void 0,...r]},a.createElement(ae,null))))},t.batch=kt,t.cleanPath=mt,t.createAction=function(t){const e=Ct({submissions:[]},t.debug);return{options:t,store:e,reset:()=>{e.setState((t=>{t.submissions=[]}))},submit:async r=>{const o={submittedAt:Date.now(),status:"pending",payload:r,invalidate:()=>{a((t=>{t.isInvalid=!0}))},getIsLatest:()=>e.state.submissions[e.state.submissions.length-1]?.submittedAt===o.submittedAt},a=t=>{e.setState((e=>{const r=e.submissions.find((t=>t.submittedAt===o.submittedAt));n(r),t(r)}))};e.setState((e=>{e.submissions.push(o),e.submissions.reverse(),e.submissions=e.submissions.slice(0,t.maxSubmissions??10),e.submissions.reverse()}));const s=async()=>{t.onEachSettled?.(o),o.getIsLatest()&&await(t.onLatestSettled?.(o))};try{const e=await(t.action?.(o.payload));return a((t=>{t.response=e})),await(t.onEachSuccess?.(o)),o.getIsLatest()&&await(t.onLatestSuccess?.(o)),await s(),a((t=>{t.status="success"})),e}catch(e){throw console.error(e),a((t=>{t.error=e})),await(t.onEachError?.(o)),o.getIsLatest()&&await(t.onLatestError?.(o)),await s(),a((t=>{t.status="error"})),e}}}},t.createBrowserHistory=nt,t.createHashHistory=function(){return nt({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=it,t.createRouteConfig=Ot,t.createStore=Ct,t.decode=At,t.defaultFetchServerDataFn=Kt,t.defaultParseSearch=zt,t.defaultStringifySearch=Bt,t.encode=Et,t.functionalUpdate=dt,t.interpolatePath=St,t.invariant=n,t.joinPaths=pt,t.last=ht,t.lazy=function(t){const e=a.lazy(t);return e.preload=async()=>{await t()},e},t.matchByPath=Lt,t.matchPathname=Pt,t.matchesContext=Yt,t.parsePathname=wt,t.parseSearchWith=Ut,t.pick=ft,t.replaceEqualDeep=Ft,t.resolvePath=bt,t.rootRouteId=_t,t.routerContext=Zt,t.stringifySearchWith=Ht,t.trackDeep=function(t){const e=new Set;return JSON.stringify(t,((t,r)=>{if("function"!=typeof r){if("object"==typeof r&&null!==r){if(e.has(r))return;e.add(r)}return r}})),t},t.trimPath=yt,t.trimPathLeft=gt,t.trimPathRight=vt,t.useAction=function(t,e){qt(t.store,(t=>e?.track?.(t)??t),!0);const[r]=a.useState({});return Object.assign(r,{...t,latestSubmission:t.store.state.submissions[t.store.state.submissions.length-1],pendingSubmissions:a.useMemo((()=>t.store.state.submissions.filter((t=>"pending"===t.status))),[t.store.state.submissions])}),r},t.useLinkProps=Vt,t.useLoaderData=function(t){const e=re(t);return n(e,t?.from&&t.from),qt(e.store,(e=>t?.track?.(e.loaderData)??e.loaderData)),e.store.state.loaderData},t.useMatch=re,t.useMatchRoute=oe,t.useMatches=ee,t.useNavigate=function(t){const e=te();return r=>e.navigate({...t,...r})},t.useParams=function(t){const e=te();return qt(e.store,(e=>{const r=ht(e.currentMatches)?.params;return t?.track?.(r)??r})),ht(e.store.state.currentMatches)?.params},t.useRoute=function(t){const e=te().getRoute(t);return n(e),e},t.useRouter=te,t.useRouterStore=function(t,e){return qt(te().store,t,e)},t.useSearch=function(t){const e=re(t);return qt(e.store,(e=>t?.track?.(e.search)??e.search)),e.store.state.search},t.useStore=qt,t.warning=lt,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
22
23
|
//# sourceMappingURL=index.production.js.map
|