@remix-run/router
Advanced tools
Comparing version 0.0.0-experimental-cf9637ce to 0.0.0-experimental-e7e9ce6e
# `@remix-run/router` | ||
## 1.3.3-pre.1 | ||
### Patch Changes | ||
- Correctly perform a "hard" redirect for same-origin absolute URLs outside of the router basename ([#10076](https://github.com/remix-run/react-router/pull/10076)) | ||
## 1.3.3-pre.0 | ||
### Patch Changes | ||
- Change `invariant` to an `UNSAFE_` export since it's only intended for internal use ([#10066](https://github.com/remix-run/react-router/pull/10066)) | ||
- Ensure status code and headers are maintained for `defer` loader responses in `createStaticHandler`'s `query()` method ([#10077](https://github.com/remix-run/react-router/pull/10077)) | ||
- Add internal API for custom HMR implementations ([#9996](https://github.com/remix-run/react-router/pull/9996)) | ||
## 1.3.2 | ||
@@ -4,0 +18,0 @@ |
export type { ActionFunction, ActionFunctionArgs, AgnosticDataIndexRouteObject, AgnosticDataNonIndexRouteObject, AgnosticDataRouteMatch, AgnosticDataRouteObject, AgnosticIndexRouteObject, AgnosticNonIndexRouteObject, AgnosticRouteMatch, AgnosticRouteObject, TrackedPromise, FormEncType, FormMethod, JsonFunction, LoaderFunction, LoaderFunctionArgs, ParamParseKey, Params, PathMatch, PathPattern, RedirectFunction, ShouldRevalidateFunction, Submission, } from "./utils"; | ||
export { AbortedDeferredError, ErrorResponse, defer, generatePath, getToPathname, isRouteErrorResponse, joinPaths, json, matchPath, matchRoutes, normalizePathname, redirect, resolvePath, resolveTo, stripBasename, warning, } from "./utils"; | ||
export type { BrowserHistory, BrowserHistoryOptions, HashHistory, HashHistoryOptions, History, InitialEntry, Location, MemoryHistory, MemoryHistoryOptions, Path, To, } from "./history"; | ||
export { Action, createBrowserHistory, createPath, createHashHistory, createMemoryHistory, invariant, parsePath, } from "./history"; | ||
export { Action, createBrowserHistory, createPath, createHashHistory, createMemoryHistory, parsePath, } from "./history"; | ||
export * from "./router"; | ||
/** @internal */ | ||
export { DeferredData as UNSAFE_DeferredData, convertRoutesToDataRoutes as UNSAFE_convertRoutesToDataRoutes, getPathContributingMatches as UNSAFE_getPathContributingMatches, } from "./utils"; | ||
export { invariant as UNSAFE_invariant } from "./history"; |
/** | ||
* @remix-run/router v0.0.0-experimental-cf9637ce | ||
* @remix-run/router v0.0.0-experimental-e7e9ce6e | ||
* | ||
@@ -11,3 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RemixRouter={})}(this,(function(e){"use strict";function t(){return t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},t.apply(this,arguments)}var r;e.Action=void 0,(r=e.Action||(e.Action={})).Pop="POP",r.Push="PUSH",r.Replace="REPLACE";const a="popstate";function n(e,t){if(!1===e||null==e)throw new Error(t)}function o(e,t){if(!e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(e){}}}function i(e,t){return{usr:e.state,key:e.key,idx:t}}function s(e,r,a,n){return void 0===a&&(a=null),t({pathname:"string"==typeof e?e:e.pathname,search:"",hash:""},"string"==typeof r?c(r):r,{state:a,key:r&&r.key||n||Math.random().toString(36).substr(2,8)})}function l(e){let{pathname:t="/",search:r="",hash:a=""}=e;return r&&"?"!==r&&(t+="?"===r.charAt(0)?r:"?"+r),a&&"#"!==a&&(t+="#"===a.charAt(0)?a:"#"+a),t}function c(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substr(r),e=e.substr(0,r));let a=e.indexOf("?");a>=0&&(t.search=e.substr(a),e=e.substr(0,a)),e&&(t.pathname=e)}return t}function d(r,o,c,d){void 0===d&&(d={});let{window:u=document.defaultView,v5Compat:h=!1}=d,f=u.history,p=e.Action.Pop,m=null,g=v();function v(){return(f.state||{idx:null}).idx}function y(){p=e.Action.Pop;let t=v(),r=null==t?null:t-g;g=t,m&&m({action:p,location:w.location,delta:r})}function b(e){let t="null"!==u.location.origin?u.location.origin:u.location.href,r="string"==typeof e?e:l(e);return n(t,"No window.location.(origin|href) available to create URL for href: "+r),new URL(r,t)}null==g&&(g=0,f.replaceState(t({},f.state,{idx:g}),""));let w={get action(){return p},get location(){return r(u,f)},listen(e){if(m)throw new Error("A history only accepts one active listener");return u.addEventListener(a,y),m=e,()=>{u.removeEventListener(a,y),m=null}},createHref:e=>o(u,e),createURL:b,encodeLocation(e){let t=b(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(t,r){p=e.Action.Push;let a=s(w.location,t,r);c&&c(a,t),g=v()+1;let n=i(a,g),o=w.createHref(a);try{f.pushState(n,"",o)}catch(e){u.location.assign(o)}h&&m&&m({action:p,location:w.location,delta:1})},replace:function(t,r){p=e.Action.Replace;let a=s(w.location,t,r);c&&c(a,t),g=v();let n=i(a,g),o=w.createHref(a);f.replaceState(n,"",o),h&&m&&m({action:p,location:w.location,delta:0})},go:e=>f.go(e)};return w}let u;function h(e,r,a){return void 0===r&&(r=[]),void 0===a&&(a=new Set),e.map(((e,o)=>{let i=[...r,o],s="string"==typeof e.id?e.id:i.join("-");if(n(!0!==e.index||!e.children,"Cannot specify children on an index route"),n(!a.has(s),'Found a route id collision on id "'+s+"\". Route id's must be globally unique within Data Router usages"),a.add(s),function(e){return!0===e.index}(e)){return t({},e,{id:s})}return t({},e,{id:s,children:e.children?h(e.children,i,a):void 0})}))}function f(e,t,r){void 0===r&&(r="/");let a=A(("string"==typeof t?c(t):t).pathname||"/",r);if(null==a)return null;let n=p(e);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){return e.length===t.length&&e.slice(0,-1).every(((e,r)=>e===t[r]))?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(n);let o=null;for(let e=0;null==o&&e<n.length;++e)o=b(n[e],D(a));return o}function p(e,t,r,a){void 0===t&&(t=[]),void 0===r&&(r=[]),void 0===a&&(a="");let o=(e,o,i)=>{let s={relativePath:void 0===i?e.path||"":i,caseSensitive:!0===e.caseSensitive,childrenIndex:o,route:e};s.relativePath.startsWith("/")&&(n(s.relativePath.startsWith(a),'Absolute route path "'+s.relativePath+'" nested under path "'+a+'" is not valid. An absolute child route path must start with the combined path of all its parent routes.'),s.relativePath=s.relativePath.slice(a.length));let l=L([a,s.relativePath]),c=r.concat(s);e.children&&e.children.length>0&&(n(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'+l+'".'),p(e.children,t,c,l)),(null!=e.path||e.index)&&t.push({path:l,score:y(l,e.index),routesMeta:c})};return e.forEach(((e,t)=>{var r;if(""!==e.path&&null!=(r=e.path)&&r.includes("?"))for(let r of m(e.path))o(e,t,r);else o(e,t)})),t}function m(e){let t=e.split("/");if(0===t.length)return[];let[r,...a]=t,n=r.endsWith("?"),o=r.replace(/\?$/,"");if(0===a.length)return n?[o,""]:[o];let i=m(a.join("/")),s=[];return s.push(...i.map((e=>""===e?o:[o,e].join("/")))),n&&s.push(...i),s.map((t=>e.startsWith("/")&&""===t?"/":t))}!function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(u||(u={}));const g=/^:\w+$/,v=e=>"*"===e;function y(e,t){let r=e.split("/"),a=r.length;return r.some(v)&&(a+=-2),t&&(a+=2),r.filter((e=>!v(e))).reduce(((e,t)=>e+(g.test(t)?3:""===t?1:10)),a)}function b(e,t){let{routesMeta:r}=e,a={},n="/",o=[];for(let e=0;e<r.length;++e){let i=r[e],s=e===r.length-1,l="/"===n?t:t.slice(n.length)||"/",c=w({path:i.relativePath,caseSensitive:i.caseSensitive,end:s},l);if(!c)return null;Object.assign(a,c.params);let d=i.route;o.push({params:a,pathname:L([n,c.pathname]),pathnameBase:k(L([n,c.pathnameBase])),route:d}),"/"!==c.pathnameBase&&(n=L([n,c.pathnameBase]))}return o}function w(e,t){"string"==typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[r,a]=function(e,t,r){void 0===t&&(t=!1);void 0===r&&(r=!0);R("*"===e||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were "'+e.replace(/\*$/,"/*")+'" because the `*` character must always follow a `/` in the pattern. To get rid of this warning, please change the route path to "'+e.replace(/\*$/,"/*")+'".');let a=[],n="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/\/:(\w+)/g,((e,t)=>(a.push(t),"/([^\\/]+)")));e.endsWith("*")?(a.push("*"),n+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?n+="\\/*$":""!==e&&"/"!==e&&(n+="(?:(?=\\/|$))");return[new RegExp(n,t?void 0:"i"),a]}(e.path,e.caseSensitive,e.end),n=t.match(r);if(!n)return null;let o=n[0],i=o.replace(/(.)\/+$/,"$1"),s=n.slice(1);return{params:a.reduce(((e,t,r)=>{if("*"===t){let e=s[r]||"";i=o.slice(0,o.length-e.length).replace(/(.)\/+$/,"$1")}return e[t]=function(e,t){try{return decodeURIComponent(e)}catch(r){return R(!1,'The value for the URL param "'+t+'" will not be decoded because the string "'+e+'" is a malformed URL segment. This is probably due to a bad percent encoding ('+r+")."),e}}(s[r]||"",t),e}),{}),pathname:o,pathnameBase:i,pattern:e}}function D(e){try{return decodeURI(e)}catch(t){return R(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent encoding ('+t+")."),e}}function A(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,a=e.charAt(r);return a&&"/"!==a?null:e.slice(r)||"/"}function R(e,t){if(!e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(e){}}}function E(e,t){void 0===t&&(t="/");let{pathname:r,search:a="",hash:n=""}="string"==typeof e?c(e):e,o=r?r.startsWith("/")?r:function(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach((e=>{".."===e?r.length>1&&r.pop():"."!==e&&r.push(e)})),r.length>1?r.join("/"):"/"}(r,t):t;return{pathname:o,search:x(a),hash:C(n)}}function P(e,t,r,a){return"Cannot include a '"+e+"' character in a manually specified `to."+t+"` field ["+JSON.stringify(a)+"]. Please separate it out to the `to."+r+'` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.'}function S(e){return e.filter(((e,t)=>0===t||e.route.path&&e.route.path.length>0))}function M(e,r,a,o){let i;void 0===o&&(o=!1),"string"==typeof e?i=c(e):(i=t({},e),n(!i.pathname||!i.pathname.includes("?"),P("?","pathname","search",i)),n(!i.pathname||!i.pathname.includes("#"),P("#","pathname","hash",i)),n(!i.search||!i.search.includes("#"),P("#","search","hash",i)));let s,l=""===e||""===i.pathname,d=l?"/":i.pathname;if(o||null==d)s=a;else{let e=r.length-1;if(d.startsWith("..")){let t=d.split("/");for(;".."===t[0];)t.shift(),e-=1;i.pathname=t.join("/")}s=e>=0?r[e]:"/"}let u=E(i,s),h=d&&"/"!==d&&d.endsWith("/"),f=(l||"."===d)&&a.endsWith("/");return u.pathname.endsWith("/")||!h&&!f||(u.pathname+="/"),u}const L=e=>e.join("/").replace(/\/\/+/g,"/"),k=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),x=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",C=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";class U extends Error{}class T{constructor(e,t){let r;this.pendingKeysSet=new Set,this.subscribers=new Set,this.deferredKeys=[],n(e&&"object"==typeof e&&!Array.isArray(e),"defer() only accepts plain objects"),this.abortPromise=new Promise(((e,t)=>r=t)),this.controller=new AbortController;let a=()=>r(new U("Deferred data aborted"));this.unlistenAbortSignal=()=>this.controller.signal.removeEventListener("abort",a),this.controller.signal.addEventListener("abort",a),this.data=Object.entries(e).reduce(((e,t)=>{let[r,a]=t;return Object.assign(e,{[r]:this.trackPromise(r,a)})}),{}),this.done&&this.unlistenAbortSignal(),this.init=t}trackPromise(e,t){if(!(t instanceof Promise))return t;this.deferredKeys.push(e),this.pendingKeysSet.add(e);let r=Promise.race([t,this.abortPromise]).then((t=>this.onSettle(r,e,null,t)),(t=>this.onSettle(r,e,t)));return r.catch((()=>{})),Object.defineProperty(r,"_tracked",{get:()=>!0}),r}onSettle(e,t,r,a){return this.controller.signal.aborted&&r instanceof U?(this.unlistenAbortSignal(),Object.defineProperty(e,"_error",{get:()=>r}),Promise.reject(r)):(this.pendingKeysSet.delete(t),this.done&&this.unlistenAbortSignal(),r?(Object.defineProperty(e,"_error",{get:()=>r}),this.emit(!1,t),Promise.reject(r)):(Object.defineProperty(e,"_data",{get:()=>a}),this.emit(!1,t),a))}emit(e,t){this.subscribers.forEach((r=>r(e,t)))}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}cancel(){this.controller.abort(),this.pendingKeysSet.forEach(((e,t)=>this.pendingKeysSet.delete(t))),this.emit(!0)}async resolveData(e){let t=!1;if(!this.done){let r=()=>this.cancel();e.addEventListener("abort",r),t=await new Promise((t=>{this.subscribe((a=>{e.removeEventListener("abort",r),(a||this.done)&&t(a)}))}))}return t}get done(){return 0===this.pendingKeysSet.size}get unwrappedData(){return n(null!==this.data&&this.done,"Can only unwrap data on initialized and settled deferreds"),Object.entries(this.data).reduce(((e,t)=>{let[r,a]=t;return Object.assign(e,{[r]:j(a)})}),{})}get pendingKeys(){return Array.from(this.pendingKeysSet)}}function j(e){if(!function(e){return e instanceof Promise&&!0===e._tracked}(e))return e;if(e._error)throw e._error;return e._data}class O{constructor(e,t,r,a){void 0===a&&(a=!1),this.status=e,this.statusText=t||"",this.internal=a,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}}function _(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"boolean"==typeof e.internal&&"data"in e}const H=["post","put","patch","delete"],F=new Set(H),I=["get",...H],q=new Set(I),W=new Set([301,302,303,307,308]),$=new Set([307,308]),N={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},B={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},z={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},K=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Y="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,J=!Y;const V=Symbol("deferred");function G(e,t,r){void 0===r&&(r=!1);let a,n="string"==typeof e?e:l(e);if(!t||!function(e){return null!=e&&"formData"in e}(t))return{path:n};if(t.formMethod&&!ve(t.formMethod))return{path:n,error:ce(405,{method:t.formMethod})};if(t.formData&&(a={formMethod:t.formMethod||"get",formAction:ue(n),formEncType:t&&t.formEncType||"application/x-www-form-urlencoded",formData:t.formData},ye(a.formMethod)))return{path:n,submission:a};let o=c(n),i=ae(t.formData);return r&&o.search&&De(o.search)&&i.append("index",""),o.search="?"+i,{path:l(o),submission:a}}function X(e,t){let r=e;if(t){let a=e.findIndex((e=>e.route.id===t));a>=0&&(r=e.slice(0,a))}return r}function Q(e,r,a,n,o,i,s,l,c,d,u,h,p){let m=p?Object.values(p)[0]:h?Object.values(h)[0]:void 0,g=e.createURL(r.location),v=e.createURL(o),y=i||g.toString()===v.toString()||g.search!==v.search,b=p?Object.keys(p)[0]:void 0,w=X(a,b).filter(((e,a)=>{if(null==e.route.loader)return!1;if(function(e,t,r){let a=!t||r.route.id!==t.route.id,n=void 0===e[r.route.id];return a||n}(r.loaderData,r.matches[a],e)||s.some((t=>t===e.route.id)))return!0;let o=r.matches[a],i=e;return ee(e,t({currentUrl:g,currentParams:o.params,nextUrl:v,nextParams:i.params},n,{actionResult:m,defaultShouldRevalidate:y||Z(o,i)}))})),D=[];return c.forEach(((e,o)=>{if(!a.some((t=>t.route.id===e.routeId)))return;let i=f(d,e.path,u);if(!i)return void D.push(t({key:o},e,{matches:null,match:null}));let s=Re(i,e.path);(l.includes(o)||ee(s,t({currentUrl:g,currentParams:r.matches[r.matches.length-1].params,nextUrl:v,nextParams:a[a.length-1].params},n,{actionResult:m,defaultShouldRevalidate:y})))&&D.push(t({key:o,matches:i,match:s},e))})),[w,D]}function Z(e,t){let r=e.route.path;return e.pathname!==t.pathname||null!=r&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function ee(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if("boolean"==typeof r)return r}return t.defaultShouldRevalidate}async function te(e,t,r,a,o,i,s,c){let d,h,f;void 0===o&&(o="/"),void 0===i&&(i=!1),void 0===s&&(s=!1);let p=new Promise(((e,t)=>f=t)),m=()=>f();t.signal.addEventListener("abort",m);try{let a=r.route[e];n(a,"Could not find the "+e+' to run on the "'+r.route.id+'" route'),h=await Promise.race([a({request:t,params:r.params,context:c}),p]),n(void 0!==h,"You defined "+("action"===e?"an action":"a loader")+' for route "'+r.route.id+"\" but didn't return anything from your `"+e+"` function. Please return a value or `null`.")}catch(e){d=u.error,h=e}finally{t.signal.removeEventListener("abort",m)}if(me(h)){let e,c=h.status;if(W.has(c)){let e=h.headers.get("Location");if(n(e,"Redirects returned/thrown from loaders/actions must have a Location header"),K.test(e)){if(!i){let r=new URL(t.url),a=e.startsWith("//")?new URL(r.protocol+e):new URL(e);a.origin===r.origin&&(e=a.pathname+a.search+a.hash)}}else{let i=M(e,S(a.slice(0,a.indexOf(r)+1)).map((e=>e.pathnameBase)),new URL(t.url).pathname);if(n(l(i),"Unable to resolve redirect location: "+e),o){let e=i.pathname;i.pathname="/"===e?o:L([o,e])}e=l(i)}if(i)throw h.headers.set("Location",e),h;return{type:u.redirect,status:c,location:e,revalidate:null!==h.headers.get("X-Remix-Revalidate")}}if(s)throw{type:d||u.data,response:h};let f=h.headers.get("Content-Type");return e=f&&/\bapplication\/json\b/.test(f)?await h.json():await h.text(),d===u.error?{type:d,error:new O(c,h.statusText,e),headers:h.headers}:{type:u.data,data:e,statusCode:h.status,headers:h.headers}}return d===u.error?{type:d,error:h}:h instanceof T?{type:u.deferred,deferredData:h,statusCode:null==(g=h.init)?void 0:g.status,headers:(null==(v=h.init)?void 0:v.headers)&&new Headers(h.init.headers)}:{type:u.data,data:h};var g,v}function re(e,t,r,a){let n=e.createURL(ue(t)).toString(),o={signal:r};if(a&&ye(a.formMethod)){let{formMethod:e,formEncType:t,formData:r}=a;o.method=e.toUpperCase(),o.body="application/x-www-form-urlencoded"===t?ae(r):r}return new Request(n,o)}function ae(e){let t=new URLSearchParams;for(let[r,a]of e.entries())t.append(r,a instanceof File?a.name:a);return t}function ne(e,t,r,a,o){let i,s={},l=null,c=!1,d={};return r.forEach(((r,u)=>{let h=t[u].route.id;if(n(!pe(r),"Cannot handle redirect results in processLoaderData"),fe(r)){let t=se(e,h),n=r.error;a&&(n=Object.values(a)[0],a=void 0),l=l||{},null==l[t.route.id]&&(l[t.route.id]=n),s[h]=void 0,c||(c=!0,i=_(r.error)?r.error.status:500),r.headers&&(d[h]=r.headers)}else he(r)?(o.set(h,r.deferredData),s[h]=r.deferredData.data):s[h]=r.data,null==r.statusCode||200===r.statusCode||c||(i=r.statusCode),r.headers&&(d[h]=r.headers)})),a&&(l=a,s[Object.keys(a)[0]]=void 0),{loaderData:s,errors:l,statusCode:i||200,loaderHeaders:d}}function oe(e,r,a,o,i,s,l,c){let{loaderData:d,errors:u}=ne(r,a,o,i,c);for(let r=0;r<s.length;r++){let{key:a,match:o}=s[r];n(void 0!==l&&void 0!==l[r],"Did not find corresponding fetcher result");let i=l[r];if(fe(i)){let r=se(e.matches,null==o?void 0:o.route.id);u&&u[r.route.id]||(u=t({},u,{[r.route.id]:i.error})),e.fetchers.delete(a)}else if(pe(i))n(!1,"Unhandled fetcher revalidation redirect");else if(he(i))n(!1,"Unhandled fetcher deferred data");else{let t={state:"idle",data:i.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};e.fetchers.set(a,t)}}return{loaderData:d,errors:u}}function ie(e,r,a,n){let o=t({},r);for(let t of a){let a=t.route.id;if(r.hasOwnProperty(a)?void 0!==r[a]&&(o[a]=r[a]):void 0!==e[a]&&t.route.loader&&(o[a]=e[a]),n&&n.hasOwnProperty(a))break}return o}function se(e,t){return(t?e.slice(0,e.findIndex((e=>e.route.id===t))+1):[...e]).reverse().find((e=>!0===e.route.hasErrorBoundary))||e[0]}function le(e){let t=e.find((e=>e.index||!e.path||"/"===e.path))||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function ce(e,t){let{pathname:r,routeId:a,method:n,type:o}=void 0===t?{}:t,i="Unknown Server Error",s="Unknown @remix-run/router error";return 400===e?(i="Bad Request",n&&r&&a?s="You made a "+n+' request to "'+r+'" but did not provide a `loader` for route "'+a+'", so there is no way to handle the request.':"defer-action"===o&&(s="defer() is not supported in actions")):403===e?(i="Forbidden",s='Route "'+a+'" does not match URL "'+r+'"'):404===e?(i="Not Found",s='No route matches URL "'+r+'"'):405===e&&(i="Method Not Allowed",n&&r&&a?s="You made a "+n.toUpperCase()+' request to "'+r+'" but did not provide an `action` for route "'+a+'", so there is no way to handle the request.':n&&(s='Invalid request method "'+n.toUpperCase()+'"')),new O(e||500,i,new Error(s),!0)}function de(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if(pe(r))return r}}function ue(e){return l(t({},"string"==typeof e?c(e):e,{hash:""}))}function he(e){return e.type===u.deferred}function fe(e){return e.type===u.error}function pe(e){return(e&&e.type)===u.redirect}function me(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"object"==typeof e.headers&&void 0!==e.body}function ge(e){if(!me(e))return!1;let t=e.status,r=e.headers.get("Location");return t>=300&&t<=399&&null!=r}function ve(e){return q.has(e)}function ye(e){return F.has(e)}async function be(e,t,r,a,n,o){for(let i=0;i<r.length;i++){let s=r[i],l=t[i];if(!l)continue;let c=e.find((e=>e.route.id===l.route.id)),d=null!=c&&!Z(c,l)&&void 0!==(o&&o[l.route.id]);he(s)&&(n||d)&&await we(s,a,n).then((e=>{e&&(r[i]=e||r[i])}))}}async function we(e,t,r){if(void 0===r&&(r=!1),!await e.deferredData.resolveData(t)){if(r)try{return{type:u.data,data:e.deferredData.unwrappedData}}catch(e){return{type:u.error,error:e}}return{type:u.data,data:e.deferredData.data}}}function De(e){return new URLSearchParams(e).getAll("index").some((e=>""===e))}function Ae(e,t){let{route:r,pathname:a,params:n}=e;return{id:r.id,pathname:a,params:n,data:t[r.id],handle:r.handle}}function Re(e,t){let r="string"==typeof t?c(t).search:t.search;if(e[e.length-1].route.index&&De(r||""))return e[e.length-1];let a=S(e);return a[a.length-1]}e.AbortedDeferredError=U,e.ErrorResponse=O,e.IDLE_BLOCKER=z,e.IDLE_FETCHER=B,e.IDLE_NAVIGATION=N,e.UNSAFE_DEFERRED_SYMBOL=V,e.UNSAFE_DeferredData=T,e.UNSAFE_convertRoutesToDataRoutes=h,e.UNSAFE_getPathContributingMatches=S,e.createBrowserHistory=function(e){return void 0===e&&(e={}),d((function(e,t){let{pathname:r,search:a,hash:n}=e.location;return s("",{pathname:r,search:a,hash:n},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){return"string"==typeof t?t:l(t)}),null,e)},e.createHashHistory=function(e){return void 0===e&&(e={}),d((function(e,t){let{pathname:r="/",search:a="",hash:n=""}=c(e.location.hash.substr(1));return s("",{pathname:r,search:a,hash:n},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){let r=e.document.querySelector("base"),a="";if(r&&r.getAttribute("href")){let t=e.location.href,r=t.indexOf("#");a=-1===r?t:t.slice(0,r)}return a+"#"+("string"==typeof t?t:l(t))}),(function(e,t){o("/"===e.pathname.charAt(0),"relative pathnames are not supported in hash history.push("+JSON.stringify(t)+")")}),e)},e.createMemoryHistory=function(t){void 0===t&&(t={});let r,{initialEntries:a=["/"],initialIndex:n,v5Compat:i=!1}=t;r=a.map(((e,t)=>m(e,"string"==typeof e?null:e.state,0===t?"default":void 0)));let d=f(null==n?r.length-1:n),u=e.Action.Pop,h=null;function f(e){return Math.min(Math.max(e,0),r.length-1)}function p(){return r[d]}function m(e,t,a){void 0===t&&(t=null);let n=s(r?p().pathname:"/",e,t,a);return o("/"===n.pathname.charAt(0),"relative pathnames are not supported in memory history: "+JSON.stringify(e)),n}function g(e){return"string"==typeof e?e:l(e)}return{get index(){return d},get action(){return u},get location(){return p()},createHref:g,createURL:e=>new URL(g(e),"http://localhost"),encodeLocation(e){let t="string"==typeof e?c(e):e;return{pathname:t.pathname||"",search:t.search||"",hash:t.hash||""}},push(t,a){u=e.Action.Push;let n=m(t,a);d+=1,r.splice(d,r.length,n),i&&h&&h({action:u,location:n,delta:1})},replace(t,a){u=e.Action.Replace;let n=m(t,a);r[d]=n,i&&h&&h({action:u,location:n,delta:0})},go(t){u=e.Action.Pop;let a=f(d+t),n=r[a];d=a,h&&h({action:u,location:n,delta:t})},listen:e=>(h=e,()=>{h=null})}},e.createPath=l,e.createRouter=function(r){n(r.routes.length>0,"You must provide a non-empty routes array to createRouter");let a,o=h(r.routes),i=null,l=new Set,c=null,d=null,p=null,m=null!=r.hydrationData,g=f(o,r.history.location,r.basename),v=null;if(null==g){let e=ce(404,{pathname:r.history.location.pathname}),{matches:t,route:a}=le(o);g=t,v={[a.id]:e}}let y,b,w=!g.some((e=>e.route.loader))||null!=r.hydrationData,D={historyAction:r.history.action,location:r.history.location,matches:g,initialized:w,navigation:N,restoreScrollPosition:null==r.hydrationData&&null,preventScrollReset:!1,revalidation:"idle",loaderData:r.hydrationData&&r.hydrationData.loaderData||{},actionData:r.hydrationData&&r.hydrationData.actionData||null,errors:r.hydrationData&&r.hydrationData.errors||v,fetchers:new Map,blockers:new Map},A=e.Action.Pop,E=!1,P=!1,S=!1,M=[],L=[],k=new Map,x=0,C=-1,U=new Map,T=new Set,j=new Map,O=new Map,_=new Map,H=!1;function F(e){D=t({},D,e),l.forEach((e=>e(D)))}function I(n,i){var s,l;let c,d=null!=D.actionData&&null!=D.navigation.formMethod&&ye(D.navigation.formMethod)&&"loading"===D.navigation.state&&!0!==(null==(s=n.state)?void 0:s._isRedirect);c=i.actionData?Object.keys(i.actionData).length>0?i.actionData:null:d?D.actionData:null;let u=i.loaderData?ie(D.loaderData,i.loaderData,i.matches||[],i.errors):D.loaderData;for(let[e]of _)ge(e);let h=!0===E||null!=D.navigation.formMethod&&ye(D.navigation.formMethod)&&!0!==(null==(l=n.state)?void 0:l._isRedirect);a&&(o=a,a=void 0),F(t({},i,{actionData:c,loaderData:u,historyAction:A,location:n,initialized:!0,navigation:N,revalidation:"idle",restoreScrollPosition:Pe(n,i.matches||D.matches),preventScrollReset:h,blockers:new Map(D.blockers)})),P||A===e.Action.Pop||(A===e.Action.Push?r.history.push(n,n.state):A===e.Action.Replace&&r.history.replace(n,n.state)),A=e.Action.Pop,E=!1,P=!1,S=!1,M=[],L=[]}async function q(i,s,l){b&&b.abort(),b=null,A=i,P=!0===(l&&l.startUninterruptedRevalidation),function(e,t){if(c&&d&&p){let r=t.map((e=>Ae(e,D.loaderData))),a=d(e,r)||e.key;c[a]=p()}}(D.location,D.matches),E=!0===(l&&l.preventScrollReset);let h=a||o,m=l&&l.overrideNavigation,g=f(h,s,r.basename);if(!g){let e=ce(404,{pathname:s.pathname}),{matches:t,route:r}=le(h);return Ee(),void I(s,{matches:t,loaderData:{},errors:{[r.id]:e}})}if(!(v=D.location,w=s,v.pathname!==w.pathname||v.search!==w.search||v.hash===w.hash||l&&l.submission&&ye(l.submission.formMethod)))return void I(s,{matches:g});var v,w;b=new AbortController;let R,U,_=re(r.history,s,b.signal,l&&l.submission);if(l&&l.pendingError)U={[se(g).route.id]:l.pendingError};else if(l&&l.submission&&ye(l.submission.formMethod)){let r=await async function(r,a,n,o,i){let s;Z(),F({navigation:t({state:"submitting",location:a},n)});let l=Re(o,a);if(l.route.action){if(s=await te("action",r,l,o,y.basename),r.signal.aborted)return{shortCircuited:!0}}else s={type:u.error,error:ce(405,{method:r.method,pathname:a.pathname,routeId:l.route.id})};if(pe(s)){let e;return e=i&&null!=i.replace?i.replace:s.location===D.location.pathname+D.location.search,await V(D,s,{submission:n,replace:e}),{shortCircuited:!0}}if(fe(s)){let t=se(o,l.route.id);return!0!==(i&&i.replace)&&(A=e.Action.Push),{pendingActionData:{},pendingActionError:{[t.route.id]:s.error}}}if(he(s))throw ce(400,{type:"defer-action"});return{pendingActionData:{[l.route.id]:s.data}}}(_,s,l.submission,g,{replace:l.replace});if(r.shortCircuited)return;R=r.pendingActionData,U=r.pendingActionError,m=t({state:"loading",location:s},l.submission),_=new Request(_.url,{signal:_.signal})}let{shortCircuited:H,loaderData:q,errors:W}=await async function(e,i,s,l,c,d,u,h){let f=l;if(!f){f=t({state:"loading",location:i,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},c)}let p=c||(f.formMethod&&f.formAction&&f.formData&&f.formEncType?{formMethod:f.formMethod,formAction:f.formAction,formData:f.formData,formEncType:f.formEncType}:void 0),m=a||o,[g,v]=Q(r.history,D,s,p,i,S,M,L,j,m,r.basename,u,h);if(Ee((e=>!(s&&s.some((t=>t.route.id===e)))||g&&g.some((t=>t.route.id===e)))),0===g.length&&0===v.length)return I(i,t({matches:s,loaderData:{},errors:h||null},u?{actionData:u}:{})),{shortCircuited:!0};if(!P){v.forEach((e=>{let t=D.fetchers.get(e.key),r={state:"loading",data:t&&t.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};D.fetchers.set(e.key,r)}));let e=u||D.actionData;F(t({navigation:f},e?0===Object.keys(e).length?{actionData:null}:{actionData:e}:{},v.length>0?{fetchers:new Map(D.fetchers)}:{}))}C=++x,v.forEach((e=>k.set(e.key,b)));let{results:y,loaderResults:w,fetcherResults:A}=await X(D.matches,s,g,v,e);if(e.signal.aborted)return{shortCircuited:!0};v.forEach((e=>k.delete(e.key)));let R=de(y);if(R)return await V(D,R,{replace:d}),{shortCircuited:!0};let{loaderData:E,errors:U}=oe(D,s,g,w,h,v,A,O);O.forEach(((e,t)=>{e.subscribe((r=>{(r||e.done)&&O.delete(t)}))})),function(){let e=[];for(let t of T){let r=D.fetchers.get(t);n(r,"Expected fetcher: "+t),"loading"===r.state&&(T.delete(t),e.push(t))}ue(e)}();let _=me(C);return t({loaderData:E,errors:U},_||v.length>0?{fetchers:new Map(D.fetchers)}:{})}(_,s,g,m,l&&l.submission,l&&l.replace,R,U);H||(b=null,I(s,t({matches:g},R?{actionData:R}:{},{loaderData:q,errors:W})))}function W(e){return D.fetchers.get(e)||B}async function V(a,o,i){var l;let{submission:c,replace:d,isFetchActionRedirect:u}=void 0===i?{}:i;o.revalidate&&(S=!0);let h=s(a.location,o.location,t({_isRedirect:!0},u?{_isFetchActionRedirect:!0}:{}));if(n(h,"Expected a location on the redirect navigation"),K.test(o.location)&&Y&&void 0!==(null==(l=window)?void 0:l.location)){let e=r.history.createURL(o.location).origin;if(window.location.origin!==e)return void(d?window.location.replace(o.location):window.location.assign(o.location))}b=null;let f=!0===d?e.Action.Replace:e.Action.Push,{formMethod:p,formAction:m,formEncType:g,formData:v}=a.navigation;!c&&p&&m&&v&&g&&(c={formMethod:p,formAction:m,formEncType:g,formData:v}),$.has(o.status)&&c&&ye(c.formMethod)?await q(f,h,{submission:t({},c,{formAction:o.location}),preventScrollReset:E}):await q(f,h,{overrideNavigation:{state:"loading",location:h,formMethod:c?c.formMethod:void 0,formAction:c?c.formAction:void 0,formEncType:c?c.formEncType:void 0,formData:c?c.formData:void 0},preventScrollReset:E})}async function X(e,t,a,n,o){let i=await Promise.all([...a.map((e=>te("loader",o,e,t,y.basename))),...n.map((e=>{if(e.matches&&e.match)return te("loader",re(r.history,e.path,o.signal),e.match,e.matches,y.basename);return{type:u.error,error:ce(404,{pathname:e.path})}}))]),s=i.slice(0,a.length),l=i.slice(a.length);return await Promise.all([be(e,a,s,o.signal,!1,D.loaderData),be(e,n.map((e=>e.match)),l,o.signal,!0)]),{results:i,loaderResults:s,fetcherResults:l}}function Z(){S=!0,M.push(...Ee()),j.forEach(((e,t)=>{k.has(t)&&(L.push(t),ne(t))}))}function ee(e,t,r){let a=se(D.matches,t);ae(e),F({errors:{[a.route.id]:r},fetchers:new Map(D.fetchers)})}function ae(e){k.has(e)&&ne(e),j.delete(e),U.delete(e),T.delete(e),D.fetchers.delete(e)}function ne(e){let t=k.get(e);n(t,"Expected fetch controller: "+e),t.abort(),k.delete(e)}function ue(e){for(let t of e){let e={state:"idle",data:W(t).data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};D.fetchers.set(t,e)}}function me(e){let t=[];for(let[r,a]of U)if(a<e){let e=D.fetchers.get(r);n(e,"Expected fetcher: "+r),"loading"===e.state&&(ne(r),U.delete(r),t.push(r))}return ue(t),t.length>0}function ge(e){D.blockers.delete(e),_.delete(e)}function ve(e,t){let r=D.blockers.get(e)||z;n("unblocked"===r.state&&"blocked"===t.state||"blocked"===r.state&&"blocked"===t.state||"blocked"===r.state&&"proceeding"===t.state||"blocked"===r.state&&"unblocked"===t.state||"proceeding"===r.state&&"unblocked"===t.state,"Invalid blocker state transition: "+r.state+" -> "+t.state),D.blockers.set(e,t),F({blockers:new Map(D.blockers)})}function De(e){let{currentLocation:t,nextLocation:r,historyAction:a}=e;if(0===_.size)return;_.size>1&&R(!1,"A router only supports one blocker at a time");let n=Array.from(_.entries()),[o,i]=n[n.length-1],s=D.blockers.get(o);return s&&"proceeding"===s.state?void 0:i({currentLocation:t,nextLocation:r,historyAction:a})?o:void 0}function Ee(e){let t=[];return O.forEach(((r,a)=>{e&&!e(a)||(r.cancel(),t.push(a),O.delete(a))})),t}function Pe(e,t){if(c&&d&&p){let r=t.map((e=>Ae(e,D.loaderData))),a=d(e,r)||e.key,n=c[a];if("number"==typeof n)return n}return null}return y={get basename(){return r.basename},get state(){return D},get routes(){return o},initialize:function(){return i=r.history.listen((e=>{let{action:t,location:a,delta:n}=e;if(H)return void(H=!1);R(0===_.size||null!=n,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let o=De({currentLocation:D.location,nextLocation:a,historyAction:t});return o&&null!=n?(H=!0,r.history.go(-1*n),void ve(o,{state:"blocked",location:a,proceed(){ve(o,{state:"proceeding",proceed:void 0,reset:void 0,location:a}),r.history.go(n)},reset(){ge(o),F({blockers:new Map(y.state.blockers)})}})):q(t,a)})),D.initialized||q(e.Action.Pop,D.location),y},subscribe:function(e){return l.add(e),()=>l.delete(e)},enableScrollRestoration:function(e,t,r){if(c=e,p=t,d=r||(e=>e.key),!m&&D.navigation===N){m=!0;let e=Pe(D.location,D.matches);null!=e&&F({restoreScrollPosition:e})}return()=>{c=null,p=null,d=null}},navigate:async function a(n,o){if("number"==typeof n)return void r.history.go(n);let{path:i,submission:l,error:c}=G(n,o),d=D.location,u=s(D.location,i,o&&o.state);u=t({},u,r.history.encodeLocation(u));let h=o&&null!=o.replace?o.replace:void 0,f=e.Action.Push;!0===h?f=e.Action.Replace:!1===h||null!=l&&ye(l.formMethod)&&l.formAction===D.location.pathname+D.location.search&&(f=e.Action.Replace);let p=o&&"preventScrollReset"in o?!0===o.preventScrollReset:void 0,m=De({currentLocation:d,nextLocation:u,historyAction:f});if(!m)return await q(f,u,{submission:l,pendingError:c,preventScrollReset:p,replace:o&&o.replace});ve(m,{state:"blocked",location:u,proceed(){ve(m,{state:"proceeding",proceed:void 0,reset:void 0,location:u}),a(n,o)},reset(){ge(m),F({blockers:new Map(D.blockers)})}})},fetch:function(e,i,s,l){if(J)throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");k.has(e)&&ne(e);let c=f(a||o,s,r.basename);if(!c)return void ee(e,i,ce(404,{pathname:s}));let{path:d,submission:u}=G(s,l,!0),h=Re(c,d);E=!0===(l&&l.preventScrollReset),u&&ye(u.formMethod)?async function(e,i,s,l,c,d){if(Z(),j.delete(e),!l.route.action){let t=ce(405,{method:d.formMethod,pathname:s,routeId:i});return void ee(e,i,t)}let u=D.fetchers.get(e),h=t({state:"submitting"},d,{data:u&&u.data," _hasFetcherDoneAnything ":!0});D.fetchers.set(e,h),F({fetchers:new Map(D.fetchers)});let p=new AbortController,m=re(r.history,s,p.signal,d);k.set(e,p);let g=await te("action",m,l,c,y.basename);if(m.signal.aborted)return void(k.get(e)===p&&k.delete(e));if(pe(g)){k.delete(e),T.add(e);let r=t({state:"loading"},d,{data:void 0," _hasFetcherDoneAnything ":!0});return D.fetchers.set(e,r),F({fetchers:new Map(D.fetchers)}),V(D,g,{isFetchActionRedirect:!0})}if(fe(g))return void ee(e,i,g.error);if(he(g))throw ce(400,{type:"defer-action"});let v=D.navigation.location||D.location,w=re(r.history,v,p.signal),R=a||o,E="idle"!==D.navigation.state?f(R,D.navigation.location,r.basename):D.matches;n(E,"Didn't find any matches after fetcher action");let P=++x;U.set(e,P);let _=t({state:"loading",data:g.data},d,{" _hasFetcherDoneAnything ":!0});D.fetchers.set(e,_);let[H,q]=Q(r.history,D,E,d,v,S,M,L,j,R,r.basename,{[l.route.id]:g.data},void 0);q.filter((t=>t.key!==e)).forEach((e=>{let t=e.key,r=D.fetchers.get(t),a={state:"loading",data:r&&r.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};D.fetchers.set(t,a),k.set(t,p)})),F({fetchers:new Map(D.fetchers)});let{results:W,loaderResults:$,fetcherResults:N}=await X(D.matches,E,H,q,w);if(p.signal.aborted)return;U.delete(e),k.delete(e),q.forEach((e=>k.delete(e.key)));let B=de(W);if(B)return V(D,B);let{loaderData:z,errors:K}=oe(D,D.matches,H,$,void 0,q,N,O),Y={state:"idle",data:g.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};D.fetchers.set(e,Y);let J=me(P);"loading"===D.navigation.state&&P>C?(n(A,"Expected pending action"),b&&b.abort(),I(D.navigation.location,{matches:E,loaderData:z,errors:K,fetchers:new Map(D.fetchers)})):(F(t({errors:K,loaderData:ie(D.loaderData,z,E,K)},J?{fetchers:new Map(D.fetchers)}:{})),S=!1)}(e,i,d,h,c,u):(j.set(e,{routeId:i,path:d}),async function(e,a,o,i,s,l){let c=D.fetchers.get(e),d=t({state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},l,{data:c&&c.data," _hasFetcherDoneAnything ":!0});D.fetchers.set(e,d),F({fetchers:new Map(D.fetchers)});let u=new AbortController,h=re(r.history,o,u.signal);k.set(e,u);let f=await te("loader",h,i,s,y.basename);he(f)&&(f=await we(f,h.signal,!0)||f);k.get(e)===u&&k.delete(e);if(h.signal.aborted)return;if(pe(f))return void await V(D,f);if(fe(f)){let t=se(D.matches,a);return D.fetchers.delete(e),void F({fetchers:new Map(D.fetchers),errors:{[t.route.id]:f.error}})}n(!he(f),"Unhandled fetcher deferred data");let p={state:"idle",data:f.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};D.fetchers.set(e,p),F({fetchers:new Map(D.fetchers)})}(e,i,d,h,c,u))},revalidate:function(){Z(),F({revalidation:"loading"}),"submitting"!==D.navigation.state&&("idle"!==D.navigation.state?q(A||D.historyAction,D.navigation.location,{overrideNavigation:D.navigation}):q(D.historyAction,D.location,{startUninterruptedRevalidation:!0}))},createHref:e=>r.history.createHref(e),encodeLocation:e=>r.history.encodeLocation(e),getFetcher:W,deleteFetcher:ae,dispose:function(){i&&i(),l.clear(),b&&b.abort(),D.fetchers.forEach(((e,t)=>ae(t))),D.blockers.forEach(((e,t)=>ge(t)))},getBlocker:function(e,t){let r=D.blockers.get(e)||z;return _.get(e)!==t&&_.set(e,t),r},deleteBlocker:ge,_internalFetchControllers:k,_internalActiveDeferreds:O,_internalSetRoutes:function(e){a=e}},y},e.createStaticHandler=function(e,r){n(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let a=h(e),o=(r?r.basename:null)||"/";async function i(e,r,a,i,s){n(e.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(ye(e.method.toLowerCase())){let n=await async function(e,r,a,n,i){let s;if(a.route.action){if(s=await te("action",e,a,r,o,!0,i,n),e.signal.aborted){throw new Error((i?"queryRoute":"query")+"() call aborted")}}else{let t=ce(405,{method:e.method,pathname:new URL(e.url).pathname,routeId:a.route.id});if(i)throw t;s={type:u.error,error:t}}if(pe(s))throw new Response(null,{status:s.status,headers:{Location:s.location}});if(he(s)){let e=ce(400,{type:"defer-action"});if(i)throw e;s={type:u.error,error:e}}if(i){if(fe(s))throw s.error;return{matches:[a],loaderData:{},actionData:{[a.route.id]:s.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}if(fe(s)){let o=se(r,a.route.id);return t({},await c(e,r,n,void 0,{[o.route.id]:s.error}),{statusCode:_(s.error)?s.error.status:500,actionData:null,actionHeaders:t({},s.headers?{[a.route.id]:s.headers}:{})})}let l=new Request(e.url,{headers:e.headers,redirect:e.redirect,signal:e.signal});return t({},await c(l,r,n),s.statusCode?{statusCode:s.statusCode}:{},{actionData:{[a.route.id]:s.data},actionHeaders:t({},s.headers?{[a.route.id]:s.headers}:{})})}(e,a,s||Re(a,r),i,null!=s);return n}let n=await c(e,a,i,s);return me(n)?n:t({},n,{actionData:null,actionHeaders:{}})}catch(e){if((l=e)&&me(l.response)&&(l.type===u.data||u.error)){if(e.type===u.error&&!ge(e.response))throw e.response;return e.response}if(ge(e))return e;throw e}var l}async function c(e,r,a,n,i){let s=null!=n;if(s&&(null==n||!n.route.loader))throw ce(400,{method:e.method,pathname:new URL(e.url).pathname,routeId:null==n?void 0:n.route.id});let l=(n?[n]:X(r,Object.keys(i||{})[0])).filter((e=>e.route.loader));if(0===l.length)return{matches:r,loaderData:r.reduce(((e,t)=>Object.assign(e,{[t.route.id]:null})),{}),errors:i||null,statusCode:200,loaderHeaders:{},activeDeferreds:null};let c=await Promise.all([...l.map((t=>te("loader",e,t,r,o,!0,s,a)))]);if(e.signal.aborted){throw new Error((s?"queryRoute":"query")+"() call aborted")}let d=new Map,u=ne(r,l,c,i,d),h=new Set(l.map((e=>e.route.id)));return r.forEach((e=>{h.has(e.route.id)||(u.loaderData[e.route.id]=null)})),t({},u,{matches:r,activeDeferreds:d.size>0?Object.fromEntries(d.entries()):null})}return{dataRoutes:a,query:async function(e,r){let{requestContext:n}=void 0===r?{}:r,c=new URL(e.url),d=e.method.toLowerCase(),u=s("",l(c),null,"default"),h=f(a,u,o);if(!ve(d)&&"head"!==d){let e=ce(405,{method:d}),{matches:t,route:r}=le(a);return{basename:o,location:u,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}if(!h){let e=ce(404,{pathname:u.pathname}),{matches:t,route:r}=le(a);return{basename:o,location:u,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}let p=await i(e,u,h,n);return me(p)?p:t({location:u,basename:o},p)},queryRoute:async function(e,t){let{routeId:r,requestContext:n}=void 0===t?{}:t,c=new URL(e.url),d=e.method.toLowerCase(),u=s("",l(c),null,"default"),h=f(a,u,o);if(!ve(d)&&"head"!==d&&"options"!==d)throw ce(405,{method:d});if(!h)throw ce(404,{pathname:u.pathname});let p=r?h.find((e=>e.route.id===r)):Re(h,u);if(r&&!p)throw ce(403,{pathname:u.pathname,routeId:r});if(!p)throw ce(404,{pathname:u.pathname});let m=await i(e,u,h,n,p);if(me(m))return m;let g=m.errors?Object.values(m.errors)[0]:void 0;if(void 0!==g)throw g;if(m.actionData)return Object.values(m.actionData)[0];if(m.loaderData){var v;let e=Object.values(m.loaderData)[0];return null!=(v=m.activeDeferreds)&&v[p.route.id]&&(e[V]=m.activeDeferreds[p.route.id]),e}}}},e.defer=function(e,t){return void 0===t&&(t={}),new T(e,"number"==typeof t?{status:t}:t)},e.generatePath=function(e,t){void 0===t&&(t={});let r=e;return r.endsWith("*")&&"*"!==r&&!r.endsWith("/*")&&(R(!1,'Route path "'+r+'" will be treated as if it were "'+r.replace(/\*$/,"/*")+'" because the `*` character must always follow a `/` in the pattern. To get rid of this warning, please change the route path to "'+r.replace(/\*$/,"/*")+'".'),r=r.replace(/\*$/,"/*")),r.replace(/^:(\w+)(\??)/g,((e,r,a)=>{let o=t[r];return"?"===a?null==o?"":o:(null==o&&n(!1,'Missing ":'+r+'" param'),o)})).replace(/\/:(\w+)(\??)/g,((e,r,a)=>{let o=t[r];return"?"===a?null==o?"":"/"+o:(null==o&&n(!1,'Missing ":'+r+'" param'),"/"+o)})).replace(/\?/g,"").replace(/(\/?)\*/,((e,r,a,n)=>null==t["*"]?"/*"===n?"/":"":""+r+t["*"]))},e.getStaticContextFromError=function(e,r,a){return t({},r,{statusCode:500,errors:{[r._deepestRenderedBoundaryId||e[0].id]:a}})},e.getToPathname=function(e){return""===e||""===e.pathname?"/":"string"==typeof e?c(e).pathname:e.pathname},e.invariant=n,e.isRouteErrorResponse=_,e.joinPaths=L,e.json=function(e,r){void 0===r&&(r={});let a="number"==typeof r?{status:r}:r,n=new Headers(a.headers);return n.has("Content-Type")||n.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify(e),t({},a,{headers:n}))},e.matchPath=w,e.matchRoutes=f,e.normalizePathname=k,e.parsePath=c,e.redirect=function(e,r){void 0===r&&(r=302);let a=r;"number"==typeof a?a={status:a}:void 0===a.status&&(a.status=302);let n=new Headers(a.headers);return n.set("Location",e),new Response(null,t({},a,{headers:n}))},e.resolvePath=E,e.resolveTo=M,e.stripBasename=A,e.warning=R,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RemixRouter={})}(this,(function(e){"use strict";function t(){return t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},t.apply(this,arguments)}var r;e.Action=void 0,(r=e.Action||(e.Action={})).Pop="POP",r.Push="PUSH",r.Replace="REPLACE";const a="popstate";function n(e,t){if(!1===e||null==e)throw new Error(t)}function o(e,t){if(!e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(e){}}}function i(e,t){return{usr:e.state,key:e.key,idx:t}}function s(e,r,a,n){return void 0===a&&(a=null),t({pathname:"string"==typeof e?e:e.pathname,search:"",hash:""},"string"==typeof r?c(r):r,{state:a,key:r&&r.key||n||Math.random().toString(36).substr(2,8)})}function l(e){let{pathname:t="/",search:r="",hash:a=""}=e;return r&&"?"!==r&&(t+="?"===r.charAt(0)?r:"?"+r),a&&"#"!==a&&(t+="#"===a.charAt(0)?a:"#"+a),t}function c(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substr(r),e=e.substr(0,r));let a=e.indexOf("?");a>=0&&(t.search=e.substr(a),e=e.substr(0,a)),e&&(t.pathname=e)}return t}function d(r,o,c,d){void 0===d&&(d={});let{window:u=document.defaultView,v5Compat:h=!1}=d,f=u.history,p=e.Action.Pop,m=null,g=v();function v(){return(f.state||{idx:null}).idx}function y(){p=e.Action.Pop;let t=v(),r=null==t?null:t-g;g=t,m&&m({action:p,location:w.location,delta:r})}function b(e){let t="null"!==u.location.origin?u.location.origin:u.location.href,r="string"==typeof e?e:l(e);return n(t,"No window.location.(origin|href) available to create URL for href: "+r),new URL(r,t)}null==g&&(g=0,f.replaceState(t({},f.state,{idx:g}),""));let w={get action(){return p},get location(){return r(u,f)},listen(e){if(m)throw new Error("A history only accepts one active listener");return u.addEventListener(a,y),m=e,()=>{u.removeEventListener(a,y),m=null}},createHref:e=>o(u,e),createURL:b,encodeLocation(e){let t=b(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(t,r){p=e.Action.Push;let a=s(w.location,t,r);c&&c(a,t),g=v()+1;let n=i(a,g),o=w.createHref(a);try{f.pushState(n,"",o)}catch(e){u.location.assign(o)}h&&m&&m({action:p,location:w.location,delta:1})},replace:function(t,r){p=e.Action.Replace;let a=s(w.location,t,r);c&&c(a,t),g=v();let n=i(a,g),o=w.createHref(a);f.replaceState(n,"",o),h&&m&&m({action:p,location:w.location,delta:0})},go:e=>f.go(e)};return w}let u;function h(e,r,a){return void 0===r&&(r=[]),void 0===a&&(a=new Set),e.map(((e,o)=>{let i=[...r,o],s="string"==typeof e.id?e.id:i.join("-");if(n(!0!==e.index||!e.children,"Cannot specify children on an index route"),n(!a.has(s),'Found a route id collision on id "'+s+"\". Route id's must be globally unique within Data Router usages"),a.add(s),function(e){return!0===e.index}(e)){return t({},e,{id:s})}return t({},e,{id:s,children:e.children?h(e.children,i,a):void 0})}))}function f(e,t,r){void 0===r&&(r="/");let a=A(("string"==typeof t?c(t):t).pathname||"/",r);if(null==a)return null;let n=p(e);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){return e.length===t.length&&e.slice(0,-1).every(((e,r)=>e===t[r]))?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(n);let o=null;for(let e=0;null==o&&e<n.length;++e)o=b(n[e],D(a));return o}function p(e,t,r,a){void 0===t&&(t=[]),void 0===r&&(r=[]),void 0===a&&(a="");let o=(e,o,i)=>{let s={relativePath:void 0===i?e.path||"":i,caseSensitive:!0===e.caseSensitive,childrenIndex:o,route:e};s.relativePath.startsWith("/")&&(n(s.relativePath.startsWith(a),'Absolute route path "'+s.relativePath+'" nested under path "'+a+'" is not valid. An absolute child route path must start with the combined path of all its parent routes.'),s.relativePath=s.relativePath.slice(a.length));let l=L([a,s.relativePath]),c=r.concat(s);e.children&&e.children.length>0&&(n(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'+l+'".'),p(e.children,t,c,l)),(null!=e.path||e.index)&&t.push({path:l,score:y(l,e.index),routesMeta:c})};return e.forEach(((e,t)=>{var r;if(""!==e.path&&null!=(r=e.path)&&r.includes("?"))for(let r of m(e.path))o(e,t,r);else o(e,t)})),t}function m(e){let t=e.split("/");if(0===t.length)return[];let[r,...a]=t,n=r.endsWith("?"),o=r.replace(/\?$/,"");if(0===a.length)return n?[o,""]:[o];let i=m(a.join("/")),s=[];return s.push(...i.map((e=>""===e?o:[o,e].join("/")))),n&&s.push(...i),s.map((t=>e.startsWith("/")&&""===t?"/":t))}!function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(u||(u={}));const g=/^:\w+$/,v=e=>"*"===e;function y(e,t){let r=e.split("/"),a=r.length;return r.some(v)&&(a+=-2),t&&(a+=2),r.filter((e=>!v(e))).reduce(((e,t)=>e+(g.test(t)?3:""===t?1:10)),a)}function b(e,t){let{routesMeta:r}=e,a={},n="/",o=[];for(let e=0;e<r.length;++e){let i=r[e],s=e===r.length-1,l="/"===n?t:t.slice(n.length)||"/",c=w({path:i.relativePath,caseSensitive:i.caseSensitive,end:s},l);if(!c)return null;Object.assign(a,c.params);let d=i.route;o.push({params:a,pathname:L([n,c.pathname]),pathnameBase:k(L([n,c.pathnameBase])),route:d}),"/"!==c.pathnameBase&&(n=L([n,c.pathnameBase]))}return o}function w(e,t){"string"==typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[r,a]=function(e,t,r){void 0===t&&(t=!1);void 0===r&&(r=!0);R("*"===e||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were "'+e.replace(/\*$/,"/*")+'" because the `*` character must always follow a `/` in the pattern. To get rid of this warning, please change the route path to "'+e.replace(/\*$/,"/*")+'".');let a=[],n="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/\/:(\w+)/g,((e,t)=>(a.push(t),"/([^\\/]+)")));e.endsWith("*")?(a.push("*"),n+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?n+="\\/*$":""!==e&&"/"!==e&&(n+="(?:(?=\\/|$))");return[new RegExp(n,t?void 0:"i"),a]}(e.path,e.caseSensitive,e.end),n=t.match(r);if(!n)return null;let o=n[0],i=o.replace(/(.)\/+$/,"$1"),s=n.slice(1);return{params:a.reduce(((e,t,r)=>{if("*"===t){let e=s[r]||"";i=o.slice(0,o.length-e.length).replace(/(.)\/+$/,"$1")}return e[t]=function(e,t){try{return decodeURIComponent(e)}catch(r){return R(!1,'The value for the URL param "'+t+'" will not be decoded because the string "'+e+'" is a malformed URL segment. This is probably due to a bad percent encoding ('+r+")."),e}}(s[r]||"",t),e}),{}),pathname:o,pathnameBase:i,pattern:e}}function D(e){try{return decodeURI(e)}catch(t){return R(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent encoding ('+t+")."),e}}function A(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,a=e.charAt(r);return a&&"/"!==a?null:e.slice(r)||"/"}function R(e,t){if(!e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(e){}}}function E(e,t){void 0===t&&(t="/");let{pathname:r,search:a="",hash:n=""}="string"==typeof e?c(e):e,o=r?r.startsWith("/")?r:function(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach((e=>{".."===e?r.length>1&&r.pop():"."!==e&&r.push(e)})),r.length>1?r.join("/"):"/"}(r,t):t;return{pathname:o,search:x(a),hash:C(n)}}function P(e,t,r,a){return"Cannot include a '"+e+"' character in a manually specified `to."+t+"` field ["+JSON.stringify(a)+"]. Please separate it out to the `to."+r+'` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.'}function S(e){return e.filter(((e,t)=>0===t||e.route.path&&e.route.path.length>0))}function M(e,r,a,o){let i;void 0===o&&(o=!1),"string"==typeof e?i=c(e):(i=t({},e),n(!i.pathname||!i.pathname.includes("?"),P("?","pathname","search",i)),n(!i.pathname||!i.pathname.includes("#"),P("#","pathname","hash",i)),n(!i.search||!i.search.includes("#"),P("#","search","hash",i)));let s,l=""===e||""===i.pathname,d=l?"/":i.pathname;if(o||null==d)s=a;else{let e=r.length-1;if(d.startsWith("..")){let t=d.split("/");for(;".."===t[0];)t.shift(),e-=1;i.pathname=t.join("/")}s=e>=0?r[e]:"/"}let u=E(i,s),h=d&&"/"!==d&&d.endsWith("/"),f=(l||"."===d)&&a.endsWith("/");return u.pathname.endsWith("/")||!h&&!f||(u.pathname+="/"),u}const L=e=>e.join("/").replace(/\/\/+/g,"/"),k=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),x=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",C=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";class U extends Error{}class T{constructor(e,t){let r;this.pendingKeysSet=new Set,this.subscribers=new Set,this.deferredKeys=[],n(e&&"object"==typeof e&&!Array.isArray(e),"defer() only accepts plain objects"),this.abortPromise=new Promise(((e,t)=>r=t)),this.controller=new AbortController;let a=()=>r(new U("Deferred data aborted"));this.unlistenAbortSignal=()=>this.controller.signal.removeEventListener("abort",a),this.controller.signal.addEventListener("abort",a),this.data=Object.entries(e).reduce(((e,t)=>{let[r,a]=t;return Object.assign(e,{[r]:this.trackPromise(r,a)})}),{}),this.done&&this.unlistenAbortSignal(),this.init=t}trackPromise(e,t){if(!(t instanceof Promise))return t;this.deferredKeys.push(e),this.pendingKeysSet.add(e);let r=Promise.race([t,this.abortPromise]).then((t=>this.onSettle(r,e,null,t)),(t=>this.onSettle(r,e,t)));return r.catch((()=>{})),Object.defineProperty(r,"_tracked",{get:()=>!0}),r}onSettle(e,t,r,a){return this.controller.signal.aborted&&r instanceof U?(this.unlistenAbortSignal(),Object.defineProperty(e,"_error",{get:()=>r}),Promise.reject(r)):(this.pendingKeysSet.delete(t),this.done&&this.unlistenAbortSignal(),r?(Object.defineProperty(e,"_error",{get:()=>r}),this.emit(!1,t),Promise.reject(r)):(Object.defineProperty(e,"_data",{get:()=>a}),this.emit(!1,t),a))}emit(e,t){this.subscribers.forEach((r=>r(e,t)))}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}cancel(){this.controller.abort(),this.pendingKeysSet.forEach(((e,t)=>this.pendingKeysSet.delete(t))),this.emit(!0)}async resolveData(e){let t=!1;if(!this.done){let r=()=>this.cancel();e.addEventListener("abort",r),t=await new Promise((t=>{this.subscribe((a=>{e.removeEventListener("abort",r),(a||this.done)&&t(a)}))}))}return t}get done(){return 0===this.pendingKeysSet.size}get unwrappedData(){return n(null!==this.data&&this.done,"Can only unwrap data on initialized and settled deferreds"),Object.entries(this.data).reduce(((e,t)=>{let[r,a]=t;return Object.assign(e,{[r]:j(a)})}),{})}get pendingKeys(){return Array.from(this.pendingKeysSet)}}function j(e){if(!function(e){return e instanceof Promise&&!0===e._tracked}(e))return e;if(e._error)throw e._error;return e._data}class O{constructor(e,t,r,a){void 0===a&&(a=!1),this.status=e,this.statusText=t||"",this.internal=a,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}}function _(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"boolean"==typeof e.internal&&"data"in e}const F=["post","put","patch","delete"],H=new Set(F),I=["get",...F],q=new Set(I),W=new Set([301,302,303,307,308]),$=new Set([307,308]),N={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},B={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},z={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},K=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Y="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,J=!Y;const V=Symbol("deferred");function G(e,t,r){void 0===r&&(r=!1);let a,n="string"==typeof e?e:l(e);if(!t||!function(e){return null!=e&&"formData"in e}(t))return{path:n};if(t.formMethod&&!ve(t.formMethod))return{path:n,error:ce(405,{method:t.formMethod})};if(t.formData&&(a={formMethod:t.formMethod||"get",formAction:ue(n),formEncType:t&&t.formEncType||"application/x-www-form-urlencoded",formData:t.formData},ye(a.formMethod)))return{path:n,submission:a};let o=c(n),i=ae(t.formData);return r&&o.search&&De(o.search)&&i.append("index",""),o.search="?"+i,{path:l(o),submission:a}}function X(e,t){let r=e;if(t){let a=e.findIndex((e=>e.route.id===t));a>=0&&(r=e.slice(0,a))}return r}function Q(e,r,a,n,o,i,s,l,c,d,u,h,p){let m=p?Object.values(p)[0]:h?Object.values(h)[0]:void 0,g=e.createURL(r.location),v=e.createURL(o),y=i||g.toString()===v.toString()||g.search!==v.search,b=p?Object.keys(p)[0]:void 0,w=X(a,b).filter(((e,a)=>{if(null==e.route.loader)return!1;if(function(e,t,r){let a=!t||r.route.id!==t.route.id,n=void 0===e[r.route.id];return a||n}(r.loaderData,r.matches[a],e)||s.some((t=>t===e.route.id)))return!0;let o=r.matches[a],i=e;return ee(e,t({currentUrl:g,currentParams:o.params,nextUrl:v,nextParams:i.params},n,{actionResult:m,defaultShouldRevalidate:y||Z(o,i)}))})),D=[];return c.forEach(((e,o)=>{if(!a.some((t=>t.route.id===e.routeId)))return;let i=f(d,e.path,u);if(!i)return void D.push(t({key:o},e,{matches:null,match:null}));let s=Re(i,e.path);(l.includes(o)||ee(s,t({currentUrl:g,currentParams:r.matches[r.matches.length-1].params,nextUrl:v,nextParams:a[a.length-1].params},n,{actionResult:m,defaultShouldRevalidate:y})))&&D.push(t({key:o,matches:i,match:s},e))})),[w,D]}function Z(e,t){let r=e.route.path;return e.pathname!==t.pathname||null!=r&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function ee(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if("boolean"==typeof r)return r}return t.defaultShouldRevalidate}async function te(e,t,r,a,o,i,s,c){let d,h,f;void 0===o&&(o="/"),void 0===i&&(i=!1),void 0===s&&(s=!1);let p=new Promise(((e,t)=>f=t)),m=()=>f();t.signal.addEventListener("abort",m);try{let a=r.route[e];n(a,"Could not find the "+e+' to run on the "'+r.route.id+'" route'),h=await Promise.race([a({request:t,params:r.params,context:c}),p]),n(void 0!==h,"You defined "+("action"===e?"an action":"a loader")+' for route "'+r.route.id+"\" but didn't return anything from your `"+e+"` function. Please return a value or `null`.")}catch(e){d=u.error,h=e}finally{t.signal.removeEventListener("abort",m)}if(me(h)){let e,c=h.status;if(W.has(c)){let e=h.headers.get("Location");if(n(e,"Redirects returned/thrown from loaders/actions must have a Location header"),K.test(e)){if(!i){let r=new URL(t.url),a=e.startsWith("//")?new URL(r.protocol+e):new URL(e),n=null!=A(a.pathname,o);a.origin===r.origin&&n&&(e=a.pathname+a.search+a.hash)}}else{let i=M(e,S(a.slice(0,a.indexOf(r)+1)).map((e=>e.pathnameBase)),new URL(t.url).pathname);if(n(l(i),"Unable to resolve redirect location: "+e),o){let e=i.pathname;i.pathname="/"===e?o:L([o,e])}e=l(i)}if(i)throw h.headers.set("Location",e),h;return{type:u.redirect,status:c,location:e,revalidate:null!==h.headers.get("X-Remix-Revalidate")}}if(s)throw{type:d||u.data,response:h};let f=h.headers.get("Content-Type");return e=f&&/\bapplication\/json\b/.test(f)?await h.json():await h.text(),d===u.error?{type:d,error:new O(c,h.statusText,e),headers:h.headers}:{type:u.data,data:e,statusCode:h.status,headers:h.headers}}return d===u.error?{type:d,error:h}:h instanceof T?{type:u.deferred,deferredData:h,statusCode:null==(g=h.init)?void 0:g.status,headers:(null==(v=h.init)?void 0:v.headers)&&new Headers(h.init.headers)}:{type:u.data,data:h};var g,v}function re(e,t,r,a){let n=e.createURL(ue(t)).toString(),o={signal:r};if(a&&ye(a.formMethod)){let{formMethod:e,formEncType:t,formData:r}=a;o.method=e.toUpperCase(),o.body="application/x-www-form-urlencoded"===t?ae(r):r}return new Request(n,o)}function ae(e){let t=new URLSearchParams;for(let[r,a]of e.entries())t.append(r,a instanceof File?a.name:a);return t}function ne(e,t,r,a,o){let i,s={},l=null,c=!1,d={};return r.forEach(((r,u)=>{let h=t[u].route.id;if(n(!pe(r),"Cannot handle redirect results in processLoaderData"),fe(r)){let t=se(e,h),n=r.error;a&&(n=Object.values(a)[0],a=void 0),l=l||{},null==l[t.route.id]&&(l[t.route.id]=n),s[h]=void 0,c||(c=!0,i=_(r.error)?r.error.status:500),r.headers&&(d[h]=r.headers)}else he(r)?(o.set(h,r.deferredData),s[h]=r.deferredData.data):s[h]=r.data,null==r.statusCode||200===r.statusCode||c||(i=r.statusCode),r.headers&&(d[h]=r.headers)})),a&&(l=a,s[Object.keys(a)[0]]=void 0),{loaderData:s,errors:l,statusCode:i||200,loaderHeaders:d}}function oe(e,r,a,o,i,s,l,c){let{loaderData:d,errors:u}=ne(r,a,o,i,c);for(let r=0;r<s.length;r++){let{key:a,match:o}=s[r];n(void 0!==l&&void 0!==l[r],"Did not find corresponding fetcher result");let i=l[r];if(fe(i)){let r=se(e.matches,null==o?void 0:o.route.id);u&&u[r.route.id]||(u=t({},u,{[r.route.id]:i.error})),e.fetchers.delete(a)}else if(pe(i))n(!1,"Unhandled fetcher revalidation redirect");else if(he(i))n(!1,"Unhandled fetcher deferred data");else{let t={state:"idle",data:i.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};e.fetchers.set(a,t)}}return{loaderData:d,errors:u}}function ie(e,r,a,n){let o=t({},r);for(let t of a){let a=t.route.id;if(r.hasOwnProperty(a)?void 0!==r[a]&&(o[a]=r[a]):void 0!==e[a]&&t.route.loader&&(o[a]=e[a]),n&&n.hasOwnProperty(a))break}return o}function se(e,t){return(t?e.slice(0,e.findIndex((e=>e.route.id===t))+1):[...e]).reverse().find((e=>!0===e.route.hasErrorBoundary))||e[0]}function le(e){let t=e.find((e=>e.index||!e.path||"/"===e.path))||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function ce(e,t){let{pathname:r,routeId:a,method:n,type:o}=void 0===t?{}:t,i="Unknown Server Error",s="Unknown @remix-run/router error";return 400===e?(i="Bad Request",n&&r&&a?s="You made a "+n+' request to "'+r+'" but did not provide a `loader` for route "'+a+'", so there is no way to handle the request.':"defer-action"===o&&(s="defer() is not supported in actions")):403===e?(i="Forbidden",s='Route "'+a+'" does not match URL "'+r+'"'):404===e?(i="Not Found",s='No route matches URL "'+r+'"'):405===e&&(i="Method Not Allowed",n&&r&&a?s="You made a "+n.toUpperCase()+' request to "'+r+'" but did not provide an `action` for route "'+a+'", so there is no way to handle the request.':n&&(s='Invalid request method "'+n.toUpperCase()+'"')),new O(e||500,i,new Error(s),!0)}function de(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if(pe(r))return r}}function ue(e){return l(t({},"string"==typeof e?c(e):e,{hash:""}))}function he(e){return e.type===u.deferred}function fe(e){return e.type===u.error}function pe(e){return(e&&e.type)===u.redirect}function me(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"object"==typeof e.headers&&void 0!==e.body}function ge(e){if(!me(e))return!1;let t=e.status,r=e.headers.get("Location");return t>=300&&t<=399&&null!=r}function ve(e){return q.has(e)}function ye(e){return H.has(e)}async function be(e,t,r,a,n,o){for(let i=0;i<r.length;i++){let s=r[i],l=t[i];if(!l)continue;let c=e.find((e=>e.route.id===l.route.id)),d=null!=c&&!Z(c,l)&&void 0!==(o&&o[l.route.id]);he(s)&&(n||d)&&await we(s,a,n).then((e=>{e&&(r[i]=e||r[i])}))}}async function we(e,t,r){if(void 0===r&&(r=!1),!await e.deferredData.resolveData(t)){if(r)try{return{type:u.data,data:e.deferredData.unwrappedData}}catch(e){return{type:u.error,error:e}}return{type:u.data,data:e.deferredData.data}}}function De(e){return new URLSearchParams(e).getAll("index").some((e=>""===e))}function Ae(e,t){let{route:r,pathname:a,params:n}=e;return{id:r.id,pathname:a,params:n,data:t[r.id],handle:r.handle}}function Re(e,t){let r="string"==typeof t?c(t).search:t.search;if(e[e.length-1].route.index&&De(r||""))return e[e.length-1];let a=S(e);return a[a.length-1]}e.AbortedDeferredError=U,e.ErrorResponse=O,e.IDLE_BLOCKER=z,e.IDLE_FETCHER=B,e.IDLE_NAVIGATION=N,e.UNSAFE_DEFERRED_SYMBOL=V,e.UNSAFE_DeferredData=T,e.UNSAFE_convertRoutesToDataRoutes=h,e.UNSAFE_getPathContributingMatches=S,e.UNSAFE_invariant=n,e.createBrowserHistory=function(e){return void 0===e&&(e={}),d((function(e,t){let{pathname:r,search:a,hash:n}=e.location;return s("",{pathname:r,search:a,hash:n},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){return"string"==typeof t?t:l(t)}),null,e)},e.createHashHistory=function(e){return void 0===e&&(e={}),d((function(e,t){let{pathname:r="/",search:a="",hash:n=""}=c(e.location.hash.substr(1));return s("",{pathname:r,search:a,hash:n},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){let r=e.document.querySelector("base"),a="";if(r&&r.getAttribute("href")){let t=e.location.href,r=t.indexOf("#");a=-1===r?t:t.slice(0,r)}return a+"#"+("string"==typeof t?t:l(t))}),(function(e,t){o("/"===e.pathname.charAt(0),"relative pathnames are not supported in hash history.push("+JSON.stringify(t)+")")}),e)},e.createMemoryHistory=function(t){void 0===t&&(t={});let r,{initialEntries:a=["/"],initialIndex:n,v5Compat:i=!1}=t;r=a.map(((e,t)=>m(e,"string"==typeof e?null:e.state,0===t?"default":void 0)));let d=f(null==n?r.length-1:n),u=e.Action.Pop,h=null;function f(e){return Math.min(Math.max(e,0),r.length-1)}function p(){return r[d]}function m(e,t,a){void 0===t&&(t=null);let n=s(r?p().pathname:"/",e,t,a);return o("/"===n.pathname.charAt(0),"relative pathnames are not supported in memory history: "+JSON.stringify(e)),n}function g(e){return"string"==typeof e?e:l(e)}return{get index(){return d},get action(){return u},get location(){return p()},createHref:g,createURL:e=>new URL(g(e),"http://localhost"),encodeLocation(e){let t="string"==typeof e?c(e):e;return{pathname:t.pathname||"",search:t.search||"",hash:t.hash||""}},push(t,a){u=e.Action.Push;let n=m(t,a);d+=1,r.splice(d,r.length,n),i&&h&&h({action:u,location:n,delta:1})},replace(t,a){u=e.Action.Replace;let n=m(t,a);r[d]=n,i&&h&&h({action:u,location:n,delta:0})},go(t){u=e.Action.Pop;let a=f(d+t),n=r[a];d=a,h&&h({action:u,location:n,delta:t})},listen:e=>(h=e,()=>{h=null})}},e.createPath=l,e.createRouter=function(r){n(r.routes.length>0,"You must provide a non-empty routes array to createRouter");let a,o=h(r.routes),i=null,l=new Set,c=null,d=null,p=null,m=null!=r.hydrationData,g=f(o,r.history.location,r.basename),v=null;if(null==g){let e=ce(404,{pathname:r.history.location.pathname}),{matches:t,route:a}=le(o);g=t,v={[a.id]:e}}let y,b,w=!g.some((e=>e.route.loader))||null!=r.hydrationData,D={historyAction:r.history.action,location:r.history.location,matches:g,initialized:w,navigation:N,restoreScrollPosition:null==r.hydrationData&&null,preventScrollReset:!1,revalidation:"idle",loaderData:r.hydrationData&&r.hydrationData.loaderData||{},actionData:r.hydrationData&&r.hydrationData.actionData||null,errors:r.hydrationData&&r.hydrationData.errors||v,fetchers:new Map,blockers:new Map},E=e.Action.Pop,P=!1,S=!1,M=!1,L=[],k=[],x=new Map,C=0,U=-1,T=new Map,j=new Set,O=new Map,_=new Map,F=new Map,H=!1;function I(e){D=t({},D,e),l.forEach((e=>e(D)))}function q(n,i){var s,l;let c,d=null!=D.actionData&&null!=D.navigation.formMethod&&ye(D.navigation.formMethod)&&"loading"===D.navigation.state&&!0!==(null==(s=n.state)?void 0:s._isRedirect);c=i.actionData?Object.keys(i.actionData).length>0?i.actionData:null:d?D.actionData:null;let u=i.loaderData?ie(D.loaderData,i.loaderData,i.matches||[],i.errors):D.loaderData;for(let[e]of F)ve(e);let h=!0===P||null!=D.navigation.formMethod&&ye(D.navigation.formMethod)&&!0!==(null==(l=n.state)?void 0:l._isRedirect);a&&(o=a,a=void 0),I(t({},i,{actionData:c,loaderData:u,historyAction:E,location:n,initialized:!0,navigation:N,revalidation:"idle",restoreScrollPosition:Se(n,i.matches||D.matches),preventScrollReset:h,blockers:new Map(D.blockers)})),S||E===e.Action.Pop||(E===e.Action.Push?r.history.push(n,n.state):E===e.Action.Replace&&r.history.replace(n,n.state)),E=e.Action.Pop,P=!1,S=!1,M=!1,L=[],k=[]}async function W(i,s,l){b&&b.abort(),b=null,E=i,S=!0===(l&&l.startUninterruptedRevalidation),function(e,t){if(c&&d&&p){let r=t.map((e=>Ae(e,D.loaderData))),a=d(e,r)||e.key;c[a]=p()}}(D.location,D.matches),P=!0===(l&&l.preventScrollReset);let h=a||o,m=l&&l.overrideNavigation,g=f(h,s,r.basename);if(!g){let e=ce(404,{pathname:s.pathname}),{matches:t,route:r}=le(h);return Pe(),void q(s,{matches:t,loaderData:{},errors:{[r.id]:e}})}if(!(v=D.location,w=s,v.pathname!==w.pathname||v.search!==w.search||v.hash===w.hash||l&&l.submission&&ye(l.submission.formMethod)))return void q(s,{matches:g});var v,w;b=new AbortController;let A,R,T=re(r.history,s,b.signal,l&&l.submission);if(l&&l.pendingError)R={[se(g).route.id]:l.pendingError};else if(l&&l.submission&&ye(l.submission.formMethod)){let r=await async function(r,a,n,o,i){let s;ee(),I({navigation:t({state:"submitting",location:a},n)});let l=Re(o,a);if(l.route.action){if(s=await te("action",r,l,o,y.basename),r.signal.aborted)return{shortCircuited:!0}}else s={type:u.error,error:ce(405,{method:r.method,pathname:a.pathname,routeId:l.route.id})};if(pe(s)){let e;return e=i&&null!=i.replace?i.replace:s.location===D.location.pathname+D.location.search,await X(D,s,{submission:n,replace:e}),{shortCircuited:!0}}if(fe(s)){let t=se(o,l.route.id);return!0!==(i&&i.replace)&&(E=e.Action.Push),{pendingActionData:{},pendingActionError:{[t.route.id]:s.error}}}if(he(s))throw ce(400,{type:"defer-action"});return{pendingActionData:{[l.route.id]:s.data}}}(T,s,l.submission,g,{replace:l.replace});if(r.shortCircuited)return;A=r.pendingActionData,R=r.pendingActionError,m=t({state:"loading",location:s},l.submission),T=new Request(T.url,{signal:T.signal})}let{shortCircuited:F,loaderData:H,errors:W}=await async function(e,i,s,l,c,d,u,h){let f=l;if(!f){f=t({state:"loading",location:i,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},c)}let p=c||(f.formMethod&&f.formAction&&f.formData&&f.formEncType?{formMethod:f.formMethod,formAction:f.formAction,formData:f.formData,formEncType:f.formEncType}:void 0),m=a||o,[g,v]=Q(r.history,D,s,p,i,M,L,k,O,m,r.basename,u,h);if(Pe((e=>!(s&&s.some((t=>t.route.id===e)))||g&&g.some((t=>t.route.id===e)))),0===g.length&&0===v.length)return q(i,t({matches:s,loaderData:{},errors:h||null},u?{actionData:u}:{})),{shortCircuited:!0};if(!S){v.forEach((e=>{let t=D.fetchers.get(e.key),r={state:"loading",data:t&&t.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};D.fetchers.set(e.key,r)}));let e=u||D.actionData;I(t({navigation:f},e?0===Object.keys(e).length?{actionData:null}:{actionData:e}:{},v.length>0?{fetchers:new Map(D.fetchers)}:{}))}U=++C,v.forEach((e=>x.set(e.key,b)));let{results:y,loaderResults:w,fetcherResults:A}=await Z(D.matches,s,g,v,e);if(e.signal.aborted)return{shortCircuited:!0};v.forEach((e=>x.delete(e.key)));let R=de(y);if(R)return await X(D,R,{replace:d}),{shortCircuited:!0};let{loaderData:E,errors:P}=oe(D,s,g,w,h,v,A,_);_.forEach(((e,t)=>{e.subscribe((r=>{(r||e.done)&&_.delete(t)}))})),function(){let e=[];for(let t of j){let r=D.fetchers.get(t);n(r,"Expected fetcher: "+t),"loading"===r.state&&(j.delete(t),e.push(t))}me(e)}();let T=ge(U);return t({loaderData:E,errors:P},T||v.length>0?{fetchers:new Map(D.fetchers)}:{})}(T,s,g,m,l&&l.submission,l&&l.replace,A,R);F||(b=null,q(s,t({matches:g},A?{actionData:A}:{},{loaderData:H,errors:W})))}function V(e){return D.fetchers.get(e)||B}async function X(a,o,i){var l;let{submission:c,replace:d,isFetchActionRedirect:u}=void 0===i?{}:i;o.revalidate&&(M=!0);let h=s(a.location,o.location,t({_isRedirect:!0},u?{_isFetchActionRedirect:!0}:{}));if(n(h,"Expected a location on the redirect navigation"),K.test(o.location)&&Y&&void 0!==(null==(l=window)?void 0:l.location)){let e=r.history.createURL(o.location),t=null==A(e.pathname,r.basename||"/");if(window.location.origin!==e.origin||t)return void(d?window.location.replace(o.location):window.location.assign(o.location))}b=null;let f=!0===d?e.Action.Replace:e.Action.Push,{formMethod:p,formAction:m,formEncType:g,formData:v}=a.navigation;!c&&p&&m&&v&&g&&(c={formMethod:p,formAction:m,formEncType:g,formData:v}),$.has(o.status)&&c&&ye(c.formMethod)?await W(f,h,{submission:t({},c,{formAction:o.location}),preventScrollReset:P}):await W(f,h,{overrideNavigation:{state:"loading",location:h,formMethod:c?c.formMethod:void 0,formAction:c?c.formAction:void 0,formEncType:c?c.formEncType:void 0,formData:c?c.formData:void 0},preventScrollReset:P})}async function Z(e,t,a,n,o){let i=await Promise.all([...a.map((e=>te("loader",o,e,t,y.basename))),...n.map((e=>{if(e.matches&&e.match)return te("loader",re(r.history,e.path,o.signal),e.match,e.matches,y.basename);return{type:u.error,error:ce(404,{pathname:e.path})}}))]),s=i.slice(0,a.length),l=i.slice(a.length);return await Promise.all([be(e,a,s,o.signal,!1,D.loaderData),be(e,n.map((e=>e.match)),l,o.signal,!0)]),{results:i,loaderResults:s,fetcherResults:l}}function ee(){M=!0,L.push(...Pe()),O.forEach(((e,t)=>{x.has(t)&&(k.push(t),ue(t))}))}function ae(e,t,r){let a=se(D.matches,t);ne(e),I({errors:{[a.route.id]:r},fetchers:new Map(D.fetchers)})}function ne(e){x.has(e)&&ue(e),O.delete(e),T.delete(e),j.delete(e),D.fetchers.delete(e)}function ue(e){let t=x.get(e);n(t,"Expected fetch controller: "+e),t.abort(),x.delete(e)}function me(e){for(let t of e){let e={state:"idle",data:V(t).data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};D.fetchers.set(t,e)}}function ge(e){let t=[];for(let[r,a]of T)if(a<e){let e=D.fetchers.get(r);n(e,"Expected fetcher: "+r),"loading"===e.state&&(ue(r),T.delete(r),t.push(r))}return me(t),t.length>0}function ve(e){D.blockers.delete(e),F.delete(e)}function De(e,t){let r=D.blockers.get(e)||z;n("unblocked"===r.state&&"blocked"===t.state||"blocked"===r.state&&"blocked"===t.state||"blocked"===r.state&&"proceeding"===t.state||"blocked"===r.state&&"unblocked"===t.state||"proceeding"===r.state&&"unblocked"===t.state,"Invalid blocker state transition: "+r.state+" -> "+t.state),D.blockers.set(e,t),I({blockers:new Map(D.blockers)})}function Ee(e){let{currentLocation:t,nextLocation:r,historyAction:a}=e;if(0===F.size)return;F.size>1&&R(!1,"A router only supports one blocker at a time");let n=Array.from(F.entries()),[o,i]=n[n.length-1],s=D.blockers.get(o);return s&&"proceeding"===s.state?void 0:i({currentLocation:t,nextLocation:r,historyAction:a})?o:void 0}function Pe(e){let t=[];return _.forEach(((r,a)=>{e&&!e(a)||(r.cancel(),t.push(a),_.delete(a))})),t}function Se(e,t){if(c&&d&&p){let r=t.map((e=>Ae(e,D.loaderData))),a=d(e,r)||e.key,n=c[a];if("number"==typeof n)return n}return null}return y={get basename(){return r.basename},get state(){return D},get routes(){return o},initialize:function(){return i=r.history.listen((e=>{let{action:t,location:a,delta:n}=e;if(H)return void(H=!1);R(0===F.size||null!=n,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let o=Ee({currentLocation:D.location,nextLocation:a,historyAction:t});return o&&null!=n?(H=!0,r.history.go(-1*n),void De(o,{state:"blocked",location:a,proceed(){De(o,{state:"proceeding",proceed:void 0,reset:void 0,location:a}),r.history.go(n)},reset(){ve(o),I({blockers:new Map(y.state.blockers)})}})):W(t,a)})),D.initialized||W(e.Action.Pop,D.location),y},subscribe:function(e){return l.add(e),()=>l.delete(e)},enableScrollRestoration:function(e,t,r){if(c=e,p=t,d=r||(e=>e.key),!m&&D.navigation===N){m=!0;let e=Se(D.location,D.matches);null!=e&&I({restoreScrollPosition:e})}return()=>{c=null,p=null,d=null}},navigate:async function a(n,o){if("number"==typeof n)return void r.history.go(n);let{path:i,submission:l,error:c}=G(n,o),d=D.location,u=s(D.location,i,o&&o.state);u=t({},u,r.history.encodeLocation(u));let h=o&&null!=o.replace?o.replace:void 0,f=e.Action.Push;!0===h?f=e.Action.Replace:!1===h||null!=l&&ye(l.formMethod)&&l.formAction===D.location.pathname+D.location.search&&(f=e.Action.Replace);let p=o&&"preventScrollReset"in o?!0===o.preventScrollReset:void 0,m=Ee({currentLocation:d,nextLocation:u,historyAction:f});if(!m)return await W(f,u,{submission:l,pendingError:c,preventScrollReset:p,replace:o&&o.replace});De(m,{state:"blocked",location:u,proceed(){De(m,{state:"proceeding",proceed:void 0,reset:void 0,location:u}),a(n,o)},reset(){ve(m),I({blockers:new Map(D.blockers)})}})},fetch:function(e,i,s,l){if(J)throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");x.has(e)&&ue(e);let c=f(a||o,s,r.basename);if(!c)return void ae(e,i,ce(404,{pathname:s}));let{path:d,submission:u}=G(s,l,!0),h=Re(c,d);P=!0===(l&&l.preventScrollReset),u&&ye(u.formMethod)?async function(e,i,s,l,c,d){if(ee(),O.delete(e),!l.route.action){let t=ce(405,{method:d.formMethod,pathname:s,routeId:i});return void ae(e,i,t)}let u=D.fetchers.get(e),h=t({state:"submitting"},d,{data:u&&u.data," _hasFetcherDoneAnything ":!0});D.fetchers.set(e,h),I({fetchers:new Map(D.fetchers)});let p=new AbortController,m=re(r.history,s,p.signal,d);x.set(e,p);let g=await te("action",m,l,c,y.basename);if(m.signal.aborted)return void(x.get(e)===p&&x.delete(e));if(pe(g)){x.delete(e),j.add(e);let r=t({state:"loading"},d,{data:void 0," _hasFetcherDoneAnything ":!0});return D.fetchers.set(e,r),I({fetchers:new Map(D.fetchers)}),X(D,g,{isFetchActionRedirect:!0})}if(fe(g))return void ae(e,i,g.error);if(he(g))throw ce(400,{type:"defer-action"});let v=D.navigation.location||D.location,w=re(r.history,v,p.signal),A=a||o,R="idle"!==D.navigation.state?f(A,D.navigation.location,r.basename):D.matches;n(R,"Didn't find any matches after fetcher action");let P=++C;T.set(e,P);let S=t({state:"loading",data:g.data},d,{" _hasFetcherDoneAnything ":!0});D.fetchers.set(e,S);let[F,H]=Q(r.history,D,R,d,v,M,L,k,O,A,r.basename,{[l.route.id]:g.data},void 0);H.filter((t=>t.key!==e)).forEach((e=>{let t=e.key,r=D.fetchers.get(t),a={state:"loading",data:r&&r.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};D.fetchers.set(t,a),x.set(t,p)})),I({fetchers:new Map(D.fetchers)});let{results:W,loaderResults:$,fetcherResults:N}=await Z(D.matches,R,F,H,w);if(p.signal.aborted)return;T.delete(e),x.delete(e),H.forEach((e=>x.delete(e.key)));let B=de(W);if(B)return X(D,B);let{loaderData:z,errors:K}=oe(D,D.matches,F,$,void 0,H,N,_),Y={state:"idle",data:g.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};D.fetchers.set(e,Y);let J=ge(P);"loading"===D.navigation.state&&P>U?(n(E,"Expected pending action"),b&&b.abort(),q(D.navigation.location,{matches:R,loaderData:z,errors:K,fetchers:new Map(D.fetchers)})):(I(t({errors:K,loaderData:ie(D.loaderData,z,R,K)},J?{fetchers:new Map(D.fetchers)}:{})),M=!1)}(e,i,d,h,c,u):(O.set(e,{routeId:i,path:d}),async function(e,a,o,i,s,l){let c=D.fetchers.get(e),d=t({state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},l,{data:c&&c.data," _hasFetcherDoneAnything ":!0});D.fetchers.set(e,d),I({fetchers:new Map(D.fetchers)});let u=new AbortController,h=re(r.history,o,u.signal);x.set(e,u);let f=await te("loader",h,i,s,y.basename);he(f)&&(f=await we(f,h.signal,!0)||f);x.get(e)===u&&x.delete(e);if(h.signal.aborted)return;if(pe(f))return void await X(D,f);if(fe(f)){let t=se(D.matches,a);return D.fetchers.delete(e),void I({fetchers:new Map(D.fetchers),errors:{[t.route.id]:f.error}})}n(!he(f),"Unhandled fetcher deferred data");let p={state:"idle",data:f.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};D.fetchers.set(e,p),I({fetchers:new Map(D.fetchers)})}(e,i,d,h,c,u))},revalidate:function(){ee(),I({revalidation:"loading"}),"submitting"!==D.navigation.state&&("idle"!==D.navigation.state?W(E||D.historyAction,D.navigation.location,{overrideNavigation:D.navigation}):W(D.historyAction,D.location,{startUninterruptedRevalidation:!0}))},createHref:e=>r.history.createHref(e),encodeLocation:e=>r.history.encodeLocation(e),getFetcher:V,deleteFetcher:ne,dispose:function(){i&&i(),l.clear(),b&&b.abort(),D.fetchers.forEach(((e,t)=>ne(t))),D.blockers.forEach(((e,t)=>ve(t)))},getBlocker:function(e,t){let r=D.blockers.get(e)||z;return F.get(e)!==t&&F.set(e,t),r},deleteBlocker:ve,_internalFetchControllers:x,_internalActiveDeferreds:_,_internalSetRoutes:function(e){a=e}},y},e.createStaticHandler=function(e,r){n(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let a=h(e),o=(r?r.basename:null)||"/";async function i(e,r,a,i,s){n(e.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(ye(e.method.toLowerCase())){let n=await async function(e,r,a,n,i){let s;if(a.route.action){if(s=await te("action",e,a,r,o,!0,i,n),e.signal.aborted){throw new Error((i?"queryRoute":"query")+"() call aborted")}}else{let t=ce(405,{method:e.method,pathname:new URL(e.url).pathname,routeId:a.route.id});if(i)throw t;s={type:u.error,error:t}}if(pe(s))throw new Response(null,{status:s.status,headers:{Location:s.location}});if(he(s)){let e=ce(400,{type:"defer-action"});if(i)throw e;s={type:u.error,error:e}}if(i){if(fe(s))throw s.error;return{matches:[a],loaderData:{},actionData:{[a.route.id]:s.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}if(fe(s)){let o=se(r,a.route.id);return t({},await c(e,r,n,void 0,{[o.route.id]:s.error}),{statusCode:_(s.error)?s.error.status:500,actionData:null,actionHeaders:t({},s.headers?{[a.route.id]:s.headers}:{})})}let l=new Request(e.url,{headers:e.headers,redirect:e.redirect,signal:e.signal});return t({},await c(l,r,n),s.statusCode?{statusCode:s.statusCode}:{},{actionData:{[a.route.id]:s.data},actionHeaders:t({},s.headers?{[a.route.id]:s.headers}:{})})}(e,a,s||Re(a,r),i,null!=s);return n}let n=await c(e,a,i,s);return me(n)?n:t({},n,{actionData:null,actionHeaders:{}})}catch(e){if((l=e)&&me(l.response)&&(l.type===u.data||u.error)){if(e.type===u.error&&!ge(e.response))throw e.response;return e.response}if(ge(e))return e;throw e}var l}async function c(e,r,a,n,i){let s=null!=n;if(s&&(null==n||!n.route.loader))throw ce(400,{method:e.method,pathname:new URL(e.url).pathname,routeId:null==n?void 0:n.route.id});let l=(n?[n]:X(r,Object.keys(i||{})[0])).filter((e=>e.route.loader));if(0===l.length)return{matches:r,loaderData:r.reduce(((e,t)=>Object.assign(e,{[t.route.id]:null})),{}),errors:i||null,statusCode:200,loaderHeaders:{},activeDeferreds:null};let c=await Promise.all([...l.map((t=>te("loader",e,t,r,o,!0,s,a)))]);if(e.signal.aborted){throw new Error((s?"queryRoute":"query")+"() call aborted")}let d=new Map,u=ne(r,l,c,i,d),h=new Set(l.map((e=>e.route.id)));return r.forEach((e=>{h.has(e.route.id)||(u.loaderData[e.route.id]=null)})),t({},u,{matches:r,activeDeferreds:d.size>0?Object.fromEntries(d.entries()):null})}return{dataRoutes:a,query:async function(e,r){let{requestContext:n}=void 0===r?{}:r,c=new URL(e.url),d=e.method.toLowerCase(),u=s("",l(c),null,"default"),h=f(a,u,o);if(!ve(d)&&"head"!==d){let e=ce(405,{method:d}),{matches:t,route:r}=le(a);return{basename:o,location:u,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}if(!h){let e=ce(404,{pathname:u.pathname}),{matches:t,route:r}=le(a);return{basename:o,location:u,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}let p=await i(e,u,h,n);return me(p)?p:t({location:u,basename:o},p)},queryRoute:async function(e,t){let{routeId:r,requestContext:n}=void 0===t?{}:t,c=new URL(e.url),d=e.method.toLowerCase(),u=s("",l(c),null,"default"),h=f(a,u,o);if(!ve(d)&&"head"!==d&&"options"!==d)throw ce(405,{method:d});if(!h)throw ce(404,{pathname:u.pathname});let p=r?h.find((e=>e.route.id===r)):Re(h,u);if(r&&!p)throw ce(403,{pathname:u.pathname,routeId:r});if(!p)throw ce(404,{pathname:u.pathname});let m=await i(e,u,h,n,p);if(me(m))return m;let g=m.errors?Object.values(m.errors)[0]:void 0;if(void 0!==g)throw g;if(m.actionData)return Object.values(m.actionData)[0];if(m.loaderData){var v;let e=Object.values(m.loaderData)[0];return null!=(v=m.activeDeferreds)&&v[p.route.id]&&(e[V]=m.activeDeferreds[p.route.id]),e}}}},e.defer=function(e,t){return void 0===t&&(t={}),new T(e,"number"==typeof t?{status:t}:t)},e.generatePath=function(e,t){void 0===t&&(t={});let r=e;return r.endsWith("*")&&"*"!==r&&!r.endsWith("/*")&&(R(!1,'Route path "'+r+'" will be treated as if it were "'+r.replace(/\*$/,"/*")+'" because the `*` character must always follow a `/` in the pattern. To get rid of this warning, please change the route path to "'+r.replace(/\*$/,"/*")+'".'),r=r.replace(/\*$/,"/*")),r.replace(/^:(\w+)(\??)/g,((e,r,a)=>{let o=t[r];return"?"===a?null==o?"":o:(null==o&&n(!1,'Missing ":'+r+'" param'),o)})).replace(/\/:(\w+)(\??)/g,((e,r,a)=>{let o=t[r];return"?"===a?null==o?"":"/"+o:(null==o&&n(!1,'Missing ":'+r+'" param'),"/"+o)})).replace(/\?/g,"").replace(/(\/?)\*/,((e,r,a,n)=>null==t["*"]?"/*"===n?"/":"":""+r+t["*"]))},e.getStaticContextFromError=function(e,r,a){return t({},r,{statusCode:500,errors:{[r._deepestRenderedBoundaryId||e[0].id]:a}})},e.getToPathname=function(e){return""===e||""===e.pathname?"/":"string"==typeof e?c(e).pathname:e.pathname},e.isRouteErrorResponse=_,e.joinPaths=L,e.json=function(e,r){void 0===r&&(r={});let a="number"==typeof r?{status:r}:r,n=new Headers(a.headers);return n.has("Content-Type")||n.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify(e),t({},a,{headers:n}))},e.matchPath=w,e.matchRoutes=f,e.normalizePathname=k,e.parsePath=c,e.redirect=function(e,r){void 0===r&&(r=302);let a=r;"number"==typeof a?a={status:a}:void 0===a.status&&(a.status=302);let n=new Headers(a.headers);return n.set("Location",e),new Response(null,t({},a,{headers:n}))},e.resolvePath=E,e.resolveTo=M,e.stripBasename=A,e.warning=R,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=router.umd.min.js.map |
@@ -66,3 +66,2 @@ export type { | ||
createMemoryHistory, | ||
invariant, | ||
parsePath, | ||
@@ -86,1 +85,3 @@ } from "./history"; | ||
} from "./utils"; | ||
export { invariant as UNSAFE_invariant } from "./history"; |
{ | ||
"name": "@remix-run/router", | ||
"version": "0.0.0-experimental-cf9637ce", | ||
"version": "0.0.0-experimental-e7e9ce6e", | ||
"description": "Nested/Data-driven/Framework-agnostic Routing", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1871226
16846