amis-rpc-design/node_modules/@remix-run/router/dist/router.umd.min.js
2023-10-07 19:42:30 +08:00

13 lines
47 KiB
JavaScript

/**
* @remix-run/router v1.9.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
!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)}let r=function(e){return e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE",e}({});const a="popstate";function o(e,t){if(!1===e||null==e)throw new Error(t)}function n(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,o){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||o||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(e,n,c,d){void 0===d&&(d={});let{window:u=document.defaultView,v5Compat:h=!1}=d,f=u.history,p=r.Pop,m=null,y=v();function v(){return(f.state||{idx:null}).idx}function g(){p=r.Pop;let e=v(),t=null==e?null:e-y;y=e,m&&m({action:p,location:w.location,delta:t})}function b(e){let t="null"!==u.location.origin?u.location.origin:u.location.href,r="string"==typeof e?e:l(e);return o(t,"No window.location.(origin|href) available to create URL for href: "+r),new URL(r,t)}null==y&&(y=0,f.replaceState(t({},f.state,{idx:y}),""));let w={get action(){return p},get location(){return e(u,f)},listen(e){if(m)throw new Error("A history only accepts one active listener");return u.addEventListener(a,g),m=e,()=>{u.removeEventListener(a,g),m=null}},createHref:e=>n(u,e),createURL:b,encodeLocation(e){let t=b(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(e,t){p=r.Push;let a=s(w.location,e,t);c&&c(a,e),y=v()+1;let o=i(a,y),n=w.createHref(a);try{f.pushState(o,"",n)}catch(e){if(e instanceof DOMException&&"DataCloneError"===e.name)throw e;u.location.assign(n)}h&&m&&m({action:p,location:w.location,delta:1})},replace:function(e,t){p=r.Replace;let a=s(w.location,e,t);c&&c(a,e),y=v();let o=i(a,y),n=w.createHref(a);f.replaceState(o,"",n),h&&m&&m({action:p,location:w.location,delta:0})},go:e=>f.go(e)};return w}let u=function(e){return e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error",e}({});const h=new Set(["lazy","caseSensitive","path","id","index","children"]);function f(e,r,a,n){return void 0===a&&(a=[]),void 0===n&&(n={}),e.map(((e,i)=>{let s=[...a,i],l="string"==typeof e.id?e.id:s.join("-");if(o(!0!==e.index||!e.children,"Cannot specify children on an index route"),o(!n[l],'Found a route id collision on id "'+l+"\". Route id's must be globally unique within Data Router usages"),function(e){return!0===e.index}(e)){let a=t({},e,r(e),{id:l});return n[l]=a,a}{let a=t({},e,r(e),{id:l,children:void 0});return n[l]=a,e.children&&(a.children=f(e.children,r,s,n)),a}}))}function p(e,t,r){void 0===r&&(r="/");let a=x(("string"==typeof t?c(t):t).pathname||"/",r);if(null==a)return null;let o=y(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)))))}(o);let n=null;for(let e=0;null==n&&e<o.length;++e)n=D(o[e],E(a));return n}function m(e,t){let{route:r,pathname:a,params:o}=e;return{id:r.id,pathname:a,params:o,data:t[r.id],handle:r.handle}}function y(e,t,r,a){void 0===t&&(t=[]),void 0===r&&(r=[]),void 0===a&&(a="");let n=(e,n,i)=>{let s={relativePath:void 0===i?e.path||"":i,caseSensitive:!0===e.caseSensitive,childrenIndex:n,route:e};s.relativePath.startsWith("/")&&(o(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&&(o(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'+l+'".'),y(e.children,t,c,l)),(null!=e.path||e.index)&&t.push({path:l,score:w(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 v(e.path))n(e,t,r);else n(e,t)})),t}function v(e){let t=e.split("/");if(0===t.length)return[];let[r,...a]=t,o=r.endsWith("?"),n=r.replace(/\?$/,"");if(0===a.length)return o?[n,""]:[n];let i=v(a.join("/")),s=[];return s.push(...i.map((e=>""===e?n:[n,e].join("/")))),o&&s.push(...i),s.map((t=>e.startsWith("/")&&""===t?"/":t))}const g=/^:\w+$/,b=e=>"*"===e;function w(e,t){let r=e.split("/"),a=r.length;return r.some(b)&&(a+=-2),t&&(a+=2),r.filter((e=>!b(e))).reduce(((e,t)=>e+(g.test(t)?3:""===t?1:10)),a)}function D(e,t){let{routesMeta:r}=e,a={},o="/",n=[];for(let e=0;e<r.length;++e){let i=r[e],s=e===r.length-1,l="/"===o?t:t.slice(o.length)||"/",c=R({path:i.relativePath,caseSensitive:i.caseSensitive,end:s},l);if(!c)return null;Object.assign(a,c.params);let d=i.route;n.push({params:a,pathname:L([o,c.pathname]),pathnameBase:j(L([o,c.pathnameBase])),route:d}),"/"!==c.pathnameBase&&(o=L([o,c.pathnameBase]))}return n}function R(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);n("*"===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=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/\/:(\w+)/g,((e,t)=>(a.push(t),"/([^\\/]+)")));e.endsWith("*")?(a.push("*"),o+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?o+="\\/*$":""!==e&&"/"!==e&&(o+="(?:(?=\\/|$))");return[new RegExp(o,t?void 0:"i"),a]}(e.path,e.caseSensitive,e.end),o=t.match(r);if(!o)return null;let i=o[0],s=i.replace(/(.)\/+$/,"$1"),l=o.slice(1);return{params:a.reduce(((e,t,r)=>{if("*"===t){let e=l[r]||"";s=i.slice(0,i.length-e.length).replace(/(.)\/+$/,"$1")}return e[t]=function(e,t){try{return decodeURIComponent(e)}catch(r){return n(!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}}(l[r]||"",t),e}),{}),pathname:i,pathnameBase:s,pattern:e}}function E(e){try{return decodeURI(e)}catch(t){return n(!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 x(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 S(e,t){void 0===t&&(t="/");let{pathname:r,search:a="",hash:o=""}="string"==typeof e?c(e):e,n=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:n,search:k(a),hash:C(o)}}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 M(e){return e.filter(((e,t)=>0===t||e.route.path&&e.route.path.length>0))}function A(e,r,a,n){let i;void 0===n&&(n=!1),"string"==typeof e?i=c(e):(i=t({},e),o(!i.pathname||!i.pathname.includes("?"),P("?","pathname","search",i)),o(!i.pathname||!i.pathname.includes("#"),P("#","pathname","hash",i)),o(!i.search||!i.search.includes("#"),P("#","search","hash",i)));let s,l=""===e||""===i.pathname,d=l?"/":i.pathname;if(n||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=S(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,"/"),j=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),k=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=[],o(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,void 0,t)),(t=>this.onSettle(r,e,t)));return r.catch((()=>{})),Object.defineProperty(r,"_tracked",{get:()=>!0}),r}onSettle(e,t,r,a){if(this.controller.signal.aborted&&r instanceof U)return this.unlistenAbortSignal(),Object.defineProperty(e,"_error",{get:()=>r}),Promise.reject(r);if(this.pendingKeysSet.delete(t),this.done&&this.unlistenAbortSignal(),void 0===r&&void 0===a){let r=new Error('Deferred data for key "'+t+'" resolved/rejected with `undefined`, you must resolve/reject with a value or `null`.');return Object.defineProperty(e,"_error",{get:()=>r}),this.emit(!1,t),Promise.reject(r)}return void 0===a?(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 o(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]:O(a)})}),{})}get pendingKeys(){return Array.from(this.pendingKeysSet)}}function O(e){if(!function(e){return e instanceof Promise&&!0===e._tracked}(e))return e;if(e._error)throw e._error;return e._data}const _=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 o=new Headers(a.headers);return o.set("Location",e),new Response(null,t({},a,{headers:o}))};class I{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 q(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"boolean"==typeof e.internal&&"data"in e}const z=["post","put","patch","delete"],H=new Set(z),B=["get",...z],F=new Set(B),N=new Set([301,302,303,307,308]),W=new Set([307,308]),$={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},K={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Y={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},J=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,X=e=>({hasErrorBoundary:Boolean(e.hasErrorBoundary)});const V=Symbol("deferred");function G(e,t,r,a,o,n,i){let s,c;if(null!=n&&"path"!==i){s=[];for(let e of t)if(s.push(e),e.route.id===n){c=e;break}}else s=t,c=t[t.length-1];let d=A(o||".",M(s).map((e=>e.pathnameBase)),x(e.pathname,r)||e.pathname,"path"===i);return null==o&&(d.search=e.search,d.hash=e.hash),null!=o&&""!==o&&"."!==o||!c||!c.route.index||Se(d.search)||(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),a&&"/"!==r&&(d.pathname="/"===d.pathname?r:L([r,d.pathname])),l(d)}function Q(e,t,r,a){if(!a||!function(e){return null!=e&&("formData"in e&&null!=e.formData||"body"in e&&void 0!==e.body)}(a))return{path:r};if(a.formMethod&&!De(a.formMethod))return{path:r,error:fe(405,{method:a.formMethod})};let n,i,s=()=>({path:r,error:fe(400,{type:"invalid-body"})}),d=a.formMethod||"get",u=e?d.toUpperCase():d.toLowerCase(),h=me(r);if(void 0!==a.body){if("text/plain"===a.formEncType){if(!Re(u))return s();let e="string"==typeof a.body?a.body:a.body instanceof FormData||a.body instanceof URLSearchParams?Array.from(a.body.entries()).reduce(((e,t)=>{let[r,a]=t;return""+e+r+"="+a+"\n"}),""):String(a.body);return{path:r,submission:{formMethod:u,formAction:h,formEncType:a.formEncType,formData:void 0,json:void 0,text:e}}}if("application/json"===a.formEncType){if(!Re(u))return s();try{let e="string"==typeof a.body?JSON.parse(a.body):a.body;return{path:r,submission:{formMethod:u,formAction:h,formEncType:a.formEncType,formData:void 0,json:e,text:void 0}}}catch(e){return s()}}}if(o("function"==typeof FormData,"FormData is not available in this environment"),a.formData)n=ie(a.formData),i=a.formData;else if(a.body instanceof FormData)n=ie(a.body),i=a.body;else if(a.body instanceof URLSearchParams)n=a.body,i=se(n);else if(null==a.body)n=new URLSearchParams,i=new FormData;else try{n=new URLSearchParams(a.body),i=se(n)}catch(e){return s()}let f={formMethod:u,formAction:h,formEncType:a&&a.formEncType||"application/x-www-form-urlencoded",formData:i,json:void 0,text:void 0};if(Re(f.formMethod))return{path:r,submission:f};let p=c(r);return t&&p.search&&Se(p.search)&&n.append("index",""),p.search="?"+n,{path:l(p),submission:f}}function Z(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 ee(e,r,a,o,n,i,s,l,c,d,u,h,f,m){let y=m?Object.values(m)[0]:f?Object.values(f)[0]:void 0,v=e.createURL(r.location),g=e.createURL(n),b=m?Object.keys(m)[0]:void 0,w=Z(a,b).filter(((e,a)=>{if(e.route.lazy)return!0;if(null==e.route.loader)return!1;if(function(e,t,r){let a=!t||r.route.id!==t.route.id,o=void 0===e[r.route.id];return a||o}(r.loaderData,r.matches[a],e)||s.some((t=>t===e.route.id)))return!0;let n=r.matches[a],l=e;return re(e,t({currentUrl:v,currentParams:n.params,nextUrl:g,nextParams:l.params},o,{actionResult:y,defaultShouldRevalidate:i||v.pathname+v.search===g.pathname+g.search||v.search!==g.search||te(n,l)}))})),D=[];return c.forEach(((e,n)=>{if(!a.some((t=>t.route.id===e.routeId)))return;let s=p(u,e.path,h);if(!s)return void D.push({key:n,routeId:e.routeId,path:e.path,matches:null,match:null,controller:null});let c=r.fetchers.get(n),f=Pe(s,e.path),m=!1;m=!d.has(n)&&(!!l.includes(n)||(c&&"idle"!==c.state&&void 0===c.data?i:re(f,t({currentUrl:v,currentParams:r.matches[r.matches.length-1].params,nextUrl:g,nextParams:a[a.length-1].params},o,{actionResult:y,defaultShouldRevalidate:i})))),m&&D.push({key:n,routeId:e.routeId,path:e.path,matches:s,match:f,controller:new AbortController})})),[w,D]}function te(e,t){let r=e.route.path;return e.pathname!==t.pathname||null!=r&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function re(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if("boolean"==typeof r)return r}return t.defaultShouldRevalidate}async function ae(e,r,a){if(!e.lazy)return;let i=await e.lazy();if(!e.lazy)return;let s=a[e.id];o(s,"No route found in manifest");let l={};for(let e in i){let t=void 0!==s[e]&&"hasErrorBoundary"!==e;n(!t,'Route "'+s.id+'" has a static property "'+e+'" defined but its lazy function is also returning a value for this property. The lazy route property "'+e+'" will be ignored.'),t||h.has(e)||(l[e]=i[e])}Object.assign(s,l),Object.assign(s,t({},r(s),{lazy:void 0}))}async function oe(e,t,r,a,n,i,s,l){let c,d,h;void 0===l&&(l={});let f=e=>{let a,o=new Promise(((e,t)=>a=t));return h=()=>a(),t.signal.addEventListener("abort",h),Promise.race([e({request:t,params:r.params,context:l.requestContext}),o])};try{let a=r.route[e];if(r.route.lazy)if(a){let e,t=await Promise.all([f(a).catch((t=>{e=t})),ae(r.route,i,n)]);if(e)throw e;d=t[0]}else{if(await ae(r.route,i,n),a=r.route[e],!a){if("action"===e){let e=new URL(t.url),a=e.pathname+e.search;throw fe(405,{method:t.method,pathname:a,routeId:r.route.id})}return{type:u.data,data:void 0}}d=await f(a)}else{if(!a){let e=new URL(t.url);throw fe(404,{pathname:e.pathname+e.search})}d=await f(a)}o(void 0!==d,"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){c=u.error,d=e}finally{h&&t.signal.removeEventListener("abort",h)}if(we(d)){let e,n=d.status;if(N.has(n)){let e=d.headers.get("Location");if(o(e,"Redirects returned/thrown from loaders/actions must have a Location header"),J.test(e)){if(!l.isStaticRequest){let r=new URL(t.url),a=e.startsWith("//")?new URL(r.protocol+e):new URL(e),o=null!=x(a.pathname,s);a.origin===r.origin&&o&&(e=a.pathname+a.search+a.hash)}}else e=G(new URL(t.url),a.slice(0,a.indexOf(r)+1),s,!0,e);if(l.isStaticRequest)throw d.headers.set("Location",e),d;return{type:u.redirect,status:n,location:e,revalidate:null!==d.headers.get("X-Remix-Revalidate"),reloadDocument:null!==d.headers.get("X-Remix-Reload-Document")}}if(l.isRouteRequest){throw{type:c===u.error?u.error:u.data,response:d}}let i=d.headers.get("Content-Type");return e=i&&/\bapplication\/json\b/.test(i)?await d.json():await d.text(),c===u.error?{type:c,error:new I(n,d.statusText,e),headers:d.headers}:{type:u.data,data:e,statusCode:d.status,headers:d.headers}}return c===u.error?{type:c,error:d}:be(d)?{type:u.deferred,deferredData:d,statusCode:null==(p=d.init)?void 0:p.status,headers:(null==(m=d.init)?void 0:m.headers)&&new Headers(d.init.headers)}:{type:u.data,data:d};var p,m}function ne(e,t,r,a){let o=e.createURL(me(t)).toString(),n={signal:r};if(a&&Re(a.formMethod)){let{formMethod:e,formEncType:t}=a;n.method=e.toUpperCase(),"application/json"===t?(n.headers=new Headers({"Content-Type":t}),n.body=JSON.stringify(a.json)):"text/plain"===t?n.body=a.text:"application/x-www-form-urlencoded"===t&&a.formData?n.body=ie(a.formData):n.body=a.formData}return new Request(o,n)}function ie(e){let t=new URLSearchParams;for(let[r,a]of e.entries())t.append(r,"string"==typeof a?a:a.name);return t}function se(e){let t=new FormData;for(let[r,a]of e.entries())t.append(r,a);return t}function le(e,t,r,a,n){let i,s={},l=null,c=!1,d={};return r.forEach(((r,u)=>{let h=t[u].route.id;if(o(!ge(r),"Cannot handle redirect results in processLoaderData"),ve(r)){let t=ue(e,h),o=r.error;a&&(o=Object.values(a)[0],a=void 0),l=l||{},null==l[t.route.id]&&(l[t.route.id]=o),s[h]=void 0,c||(c=!0,i=q(r.error)?r.error.status:500),r.headers&&(d[h]=r.headers)}else ye(r)?(n.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 ce(e,r,a,n,i,s,l,c){let{loaderData:d,errors:u}=le(r,a,n,i,c);for(let r=0;r<s.length;r++){let{key:a,match:n,controller:i}=s[r];o(void 0!==l&&void 0!==l[r],"Did not find corresponding fetcher result");let c=l[r];if(!i||!i.signal.aborted)if(ve(c)){let r=ue(e.matches,null==n?void 0:n.route.id);u&&u[r.route.id]||(u=t({},u,{[r.route.id]:c.error})),e.fetchers.delete(a)}else if(ge(c))o(!1,"Unhandled fetcher revalidation redirect");else if(ye(c))o(!1,"Unhandled fetcher deferred data");else{let t=ke(c.data);e.fetchers.set(a,t)}}return{loaderData:d,errors:u}}function de(e,r,a,o){let n=t({},r);for(let t of a){let a=t.route.id;if(r.hasOwnProperty(a)?void 0!==r[a]&&(n[a]=r[a]):void 0!==e[a]&&t.route.loader&&(n[a]=e[a]),o&&o.hasOwnProperty(a))break}return n}function ue(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 he(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 fe(e,t){let{pathname:r,routeId:a,method:o,type:n}=void 0===t?{}:t,i="Unknown Server Error",s="Unknown @remix-run/router error";return 400===e?(i="Bad Request",o&&r&&a?s="You made a "+o+' request to "'+r+'" but did not provide a `loader` for route "'+a+'", so there is no way to handle the request.':"defer-action"===n?s="defer() is not supported in actions":"invalid-body"===n&&(s="Unable to encode submission body")):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",o&&r&&a?s="You made a "+o.toUpperCase()+' request to "'+r+'" but did not provide an `action` for route "'+a+'", so there is no way to handle the request.':o&&(s='Invalid request method "'+o.toUpperCase()+'"')),new I(e||500,i,new Error(s),!0)}function pe(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if(ge(r))return{result:r,idx:t}}}function me(e){return l(t({},"string"==typeof e?c(e):e,{hash:""}))}function ye(e){return e.type===u.deferred}function ve(e){return e.type===u.error}function ge(e){return(e&&e.type)===u.redirect}function be(e){let t=e;return t&&"object"==typeof t&&"object"==typeof t.data&&"function"==typeof t.subscribe&&"function"==typeof t.cancel&&"function"==typeof t.resolveData}function we(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"object"==typeof e.headers&&void 0!==e.body}function De(e){return F.has(e.toLowerCase())}function Re(e){return H.has(e.toLowerCase())}async function Ee(e,t,r,a,n,i){for(let s=0;s<r.length;s++){let l=r[s],c=t[s];if(!c)continue;let d=e.find((e=>e.route.id===c.route.id)),u=null!=d&&!te(d,c)&&void 0!==(i&&i[c.route.id]);if(ye(l)&&(n||u)){let e=a[s];o(e,"Expected an AbortSignal for revalidating fetcher deferred result"),await xe(l,e,n).then((e=>{e&&(r[s]=e||r[s])}))}}}async function xe(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 Se(e){return new URLSearchParams(e).getAll("index").some((e=>""===e))}function Pe(e,t){let r="string"==typeof t?c(t).search:t.search;if(e[e.length-1].route.index&&Se(r||""))return e[e.length-1];let a=M(e);return a[a.length-1]}function Me(e){let{formMethod:t,formAction:r,formEncType:a,text:o,formData:n,json:i}=e;if(t&&r&&a)return null!=o?{formMethod:t,formAction:r,formEncType:a,formData:void 0,json:void 0,text:o}:null!=n?{formMethod:t,formAction:r,formEncType:a,formData:n,json:void 0,text:void 0}:void 0!==i?{formMethod:t,formAction:r,formEncType:a,formData:void 0,json:i,text:void 0}:void 0}function Ae(e,t){if(t){return{state:"loading",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}return{state:"loading",location:e,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function Le(e,t){return{state:"submitting",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}function je(e,t){if(e){return{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}}return{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function ke(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}e.AbortedDeferredError=U,e.Action=r,e.IDLE_BLOCKER=Y,e.IDLE_FETCHER=K,e.IDLE_NAVIGATION=$,e.UNSAFE_DEFERRED_SYMBOL=V,e.UNSAFE_DeferredData=T,e.UNSAFE_ErrorResponseImpl=I,e.UNSAFE_convertRouteMatchToUiMatch=m,e.UNSAFE_convertRoutesToDataRoutes=f,e.UNSAFE_getPathContributingMatches=M,e.UNSAFE_invariant=o,e.UNSAFE_warning=n,e.createBrowserHistory=function(e){return void 0===e&&(e={}),d((function(e,t){let{pathname:r,search:a,hash:o}=e.location;return s("",{pathname:r,search:a,hash:o},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:o=""}=c(e.location.hash.substr(1));return r.startsWith("/")||r.startsWith(".")||(r="/"+r),s("",{pathname:r,search:a,hash:o},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){n("/"===e.pathname.charAt(0),"relative pathnames are not supported in hash history.push("+JSON.stringify(t)+")")}),e)},e.createMemoryHistory=function(e){void 0===e&&(e={});let t,{initialEntries:a=["/"],initialIndex:o,v5Compat:i=!1}=e;t=a.map(((e,t)=>m(e,"string"==typeof e?null:e.state,0===t?"default":void 0)));let d=f(null==o?t.length-1:o),u=r.Pop,h=null;function f(e){return Math.min(Math.max(e,0),t.length-1)}function p(){return t[d]}function m(e,r,a){void 0===r&&(r=null);let o=s(t?p().pathname:"/",e,r,a);return n("/"===o.pathname.charAt(0),"relative pathnames are not supported in memory history: "+JSON.stringify(e)),o}function y(e){return"string"==typeof e?e:l(e)}return{get index(){return d},get action(){return u},get location(){return p()},createHref:y,createURL:e=>new URL(y(e),"http://localhost"),encodeLocation(e){let t="string"==typeof e?c(e):e;return{pathname:t.pathname||"",search:t.search||"",hash:t.hash||""}},push(e,a){u=r.Push;let o=m(e,a);d+=1,t.splice(d,t.length,o),i&&h&&h({action:u,location:o,delta:1})},replace(e,a){u=r.Replace;let o=m(e,a);t[d]=o,i&&h&&h({action:u,location:o,delta:0})},go(e){u=r.Pop;let a=f(d+e),o=t[a];d=a,h&&h({action:u,location:o,delta:e})},listen:e=>(h=e,()=>{h=null})}},e.createPath=l,e.createRouter=function(e){const a=e.window?e.window:"undefined"!=typeof window?window:void 0,i=void 0!==a&&void 0!==a.document&&void 0!==a.document.createElement,l=!i;let c;if(o(e.routes.length>0,"You must provide a non-empty routes array to createRouter"),e.mapRouteProperties)c=e.mapRouteProperties;else if(e.detectErrorBoundary){let t=e.detectErrorBoundary;c=e=>({hasErrorBoundary:t(e)})}else c=X;let d,h={},y=f(e.routes,c,void 0,h),v=e.basename||"/",g=t({v7_normalizeFormMethod:!1,v7_prependBasename:!1},e.future),b=null,w=new Set,D=null,R=null,E=null,S=null!=e.hydrationData,P=p(y,e.history.location,v),M=null;if(null==P){let t=fe(404,{pathname:e.history.location.pathname}),{matches:r,route:a}=he(y);P=r,M={[a.id]:t}}let A,L,j=!(P.some((e=>e.route.lazy))||P.some((e=>e.route.loader))&&null==e.hydrationData),k={historyAction:e.history.action,location:e.history.location,matches:P,initialized:j,navigation:$,restoreScrollPosition:null==e.hydrationData&&null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||M,fetchers:new Map,blockers:new Map},C=r.Pop,U=!1,T=!1,O=!1,_=[],I=[],q=new Map,z=0,H=-1,B=new Map,F=new Set,N=new Map,V=new Map,Z=new Map,te=!1;function re(e){k=t({},k,e),w.forEach((e=>e(k)))}function ae(a,o){var n,i;let s,l=null!=k.actionData&&null!=k.navigation.formMethod&&Re(k.navigation.formMethod)&&"loading"===k.navigation.state&&!0!==(null==(n=a.state)?void 0:n._isRedirect);s=o.actionData?Object.keys(o.actionData).length>0?o.actionData:null:l?k.actionData:null;let c=o.loaderData?de(k.loaderData,o.loaderData,o.matches||[],o.errors):k.loaderData,u=k.blockers;u.size>0&&(u=new Map(u),u.forEach(((e,t)=>u.set(t,Y))));let h=!0===U||null!=k.navigation.formMethod&&Re(k.navigation.formMethod)&&!0!==(null==(i=a.state)?void 0:i._isRedirect);d&&(y=d,d=void 0),T||C===r.Pop||(C===r.Push?e.history.push(a,a.state):C===r.Replace&&e.history.replace(a,a.state)),re(t({},o,{actionData:s,loaderData:c,historyAction:C,location:a,initialized:!0,navigation:$,revalidation:"idle",restoreScrollPosition:He(a,o.matches||k.matches),preventScrollReset:h,blockers:u})),C=r.Pop,U=!1,T=!1,O=!1,_=[],I=[]}async function ie(a,o,n){L&&L.abort(),L=null,C=a,T=!0===(n&&n.startUninterruptedRevalidation),function(e,t){if(D&&E){let r=ze(e,t);D[r]=E()}}(k.location,k.matches),U=!0===(n&&n.preventScrollReset);let i=d||y,s=n&&n.overrideNavigation,l=p(i,o,v);if(!l){let e=fe(404,{pathname:o.pathname}),{matches:t,route:r}=he(i);return qe(),void ae(o,{matches:t,loaderData:{},errors:{[r.id]:e}})}if(k.initialized&&!O&&function(e,t){if(e.pathname!==t.pathname||e.search!==t.search)return!1;if(""===e.hash)return""!==t.hash;if(e.hash===t.hash)return!0;if(""!==t.hash)return!0;return!1}(k.location,o)&&!(n&&n.submission&&Re(n.submission.formMethod)))return void ae(o,{matches:l});L=new AbortController;let f,m,g=ne(e.history,o,L.signal,n&&n.submission);if(n&&n.pendingError)m={[ue(l).route.id]:n.pendingError};else if(n&&n.submission&&Re(n.submission.formMethod)){let e=await async function(e,t,a,o,n){void 0===n&&(n={});let i;be(),re({navigation:Le(t,a)});let s=Pe(o,t);if(s.route.action||s.route.lazy){if(i=await oe("action",e,s,o,h,c,v),e.signal.aborted)return{shortCircuited:!0}}else i={type:u.error,error:fe(405,{method:e.method,pathname:t.pathname,routeId:s.route.id})};if(ge(i)){let e;return e=n&&null!=n.replace?n.replace:i.location===k.location.pathname+k.location.search,await le(k,i,{submission:a,replace:e}),{shortCircuited:!0}}if(ve(i)){let e=ue(o,s.route.id);return!0!==(n&&n.replace)&&(C=r.Push),{pendingActionData:{},pendingActionError:{[e.route.id]:i.error}}}if(ye(i))throw fe(400,{type:"defer-action"});return{pendingActionData:{[s.route.id]:i.data}}}(g,o,n.submission,l,{replace:n.replace});if(e.shortCircuited)return;f=e.pendingActionData,m=e.pendingActionError,s=Ae(o,n.submission),g=new Request(g.url,{signal:g.signal})}let{shortCircuited:b,loaderData:w,errors:R}=await async function(r,a,o,n,i,s,l,c,u){let h=n||Ae(a,i),f=i||s||Me(h),p=d||y,[m,g]=ee(e.history,k,o,f,a,O,_,I,N,F,p,v,c,u);if(qe((e=>!(o&&o.some((t=>t.route.id===e)))||m&&m.some((t=>t.route.id===e)))),H=++z,0===m.length&&0===g.length){let e=Ue();return ae(a,t({matches:o,loaderData:{},errors:u||null},c?{actionData:c}:{},e?{fetchers:new Map(k.fetchers)}:{})),{shortCircuited:!0}}if(!T){g.forEach((e=>{let t=k.fetchers.get(e.key),r=je(void 0,t?t.data:void 0);k.fetchers.set(e.key,r)}));let e=c||k.actionData;re(t({navigation:h},e?0===Object.keys(e).length?{actionData:null}:{actionData:e}:{},g.length>0?{fetchers:new Map(k.fetchers)}:{}))}g.forEach((e=>{q.has(e.key)&&Se(e.key),e.controller&&q.set(e.key,e.controller)}));let b=()=>g.forEach((e=>Se(e.key)));L&&L.signal.addEventListener("abort",b);let{results:w,loaderResults:D,fetcherResults:R}=await me(k.matches,o,m,g,r);if(r.signal.aborted)return{shortCircuited:!0};L&&L.signal.removeEventListener("abort",b);g.forEach((e=>q.delete(e.key)));let E=pe(w);if(E){if(E.idx>=m.length){let e=g[E.idx-m.length].key;F.add(e)}return await le(k,E.result,{replace:l}),{shortCircuited:!0}}let{loaderData:x,errors:S}=ce(k,o,m,D,u,g,R,V);V.forEach(((e,t)=>{e.subscribe((r=>{(r||e.done)&&V.delete(t)}))}));let P=Ue(),M=Te(H),A=P||M||g.length>0;return t({loaderData:x,errors:S},A?{fetchers:new Map(k.fetchers)}:{})}(g,o,l,s,n&&n.submission,n&&n.fetcherSubmission,n&&n.replace,f,m);b||(L=null,ae(o,t({matches:l},f?{actionData:f}:{},{loaderData:w,errors:R})))}function se(e){return k.fetchers.get(e)||K}async function le(n,l,c){let{submission:d,fetcherSubmission:u,replace:h}=void 0===c?{}:c;l.revalidate&&(O=!0);let f=s(n.location,l.location,{_isRedirect:!0});if(o(f,"Expected a location on the redirect navigation"),i){let t=!1;if(l.reloadDocument)t=!0;else if(J.test(l.location)){const r=e.history.createURL(l.location);t=r.origin!==a.location.origin||null==x(r.pathname,v)}if(t)return void(h?a.location.replace(l.location):a.location.assign(l.location))}L=null;let p=!0===h?r.Replace:r.Push,{formMethod:m,formAction:y,formEncType:g}=n.navigation;!d&&!u&&m&&y&&g&&(d=Me(n.navigation));let b=d||u;if(W.has(l.status)&&b&&Re(b.formMethod))await ie(p,f,{submission:t({},b,{formAction:l.location}),preventScrollReset:U});else{let e=Ae(f,d);await ie(p,f,{overrideNavigation:e,fetcherSubmission:u,preventScrollReset:U})}}async function me(t,r,a,o,n){let i=await Promise.all([...a.map((e=>oe("loader",n,e,r,h,c,v))),...o.map((t=>{if(t.matches&&t.match&&t.controller)return oe("loader",ne(e.history,t.path,t.controller.signal),t.match,t.matches,h,c,v);return{type:u.error,error:fe(404,{pathname:t.path})}}))]),s=i.slice(0,a.length),l=i.slice(a.length);return await Promise.all([Ee(t,a,s,s.map((()=>n.signal)),!1,k.loaderData),Ee(t,o.map((e=>e.match)),l,o.map((e=>e.controller?e.controller.signal:null)),!0)]),{results:i,loaderResults:s,fetcherResults:l}}function be(){O=!0,_.push(...qe()),N.forEach(((e,t)=>{q.has(t)&&(I.push(t),Se(t))}))}function we(e,t,r){let a=ue(k.matches,t);De(e),re({errors:{[a.route.id]:r},fetchers:new Map(k.fetchers)})}function De(e){let t=k.fetchers.get(e);!q.has(e)||t&&"loading"===t.state&&B.has(e)||Se(e),N.delete(e),B.delete(e),F.delete(e),k.fetchers.delete(e)}function Se(e){let t=q.get(e);o(t,"Expected fetch controller: "+e),t.abort(),q.delete(e)}function Ce(e){for(let t of e){let e=ke(se(t).data);k.fetchers.set(t,e)}}function Ue(){let e=[],t=!1;for(let r of F){let a=k.fetchers.get(r);o(a,"Expected fetcher: "+r),"loading"===a.state&&(F.delete(r),e.push(r),t=!0)}return Ce(e),t}function Te(e){let t=[];for(let[r,a]of B)if(a<e){let e=k.fetchers.get(r);o(e,"Expected fetcher: "+r),"loading"===e.state&&(Se(r),B.delete(r),t.push(r))}return Ce(t),t.length>0}function Oe(e){k.blockers.delete(e),Z.delete(e)}function _e(e,t){let r=k.blockers.get(e)||Y;o("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);let a=new Map(k.blockers);a.set(e,t),re({blockers:a})}function Ie(e){let{currentLocation:t,nextLocation:r,historyAction:a}=e;if(0===Z.size)return;Z.size>1&&n(!1,"A router only supports one blocker at a time");let o=Array.from(Z.entries()),[i,s]=o[o.length-1],l=k.blockers.get(i);return l&&"proceeding"===l.state?void 0:s({currentLocation:t,nextLocation:r,historyAction:a})?i:void 0}function qe(e){let t=[];return V.forEach(((r,a)=>{e&&!e(a)||(r.cancel(),t.push(a),V.delete(a))})),t}function ze(e,t){if(R){return R(e,t.map((e=>m(e,k.loaderData))))||e.key}return e.key}function He(e,t){if(D){let r=ze(e,t),a=D[r];if("number"==typeof a)return a}return null}return A={get basename(){return v},get state(){return k},get routes(){return y},initialize:function(){return b=e.history.listen((t=>{let{action:r,location:a,delta:o}=t;if(te)return void(te=!1);n(0===Z.size||null!=o,"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 i=Ie({currentLocation:k.location,nextLocation:a,historyAction:r});return i&&null!=o?(te=!0,e.history.go(-1*o),void _e(i,{state:"blocked",location:a,proceed(){_e(i,{state:"proceeding",proceed:void 0,reset:void 0,location:a}),e.history.go(o)},reset(){let e=new Map(k.blockers);e.set(i,Y),re({blockers:e})}})):ie(r,a)})),k.initialized||ie(r.Pop,k.location),A},subscribe:function(e){return w.add(e),()=>w.delete(e)},enableScrollRestoration:function(e,t,r){if(D=e,E=t,R=r||null,!S&&k.navigation===$){S=!0;let e=He(k.location,k.matches);null!=e&&re({restoreScrollPosition:e})}return()=>{D=null,E=null,R=null}},navigate:async function a(o,n){if("number"==typeof o)return void e.history.go(o);let i=G(k.location,k.matches,v,g.v7_prependBasename,o,null==n?void 0:n.fromRouteId,null==n?void 0:n.relative),{path:l,submission:c,error:d}=Q(g.v7_normalizeFormMethod,!1,i,n),u=k.location,h=s(k.location,l,n&&n.state);h=t({},h,e.history.encodeLocation(h));let f=n&&null!=n.replace?n.replace:void 0,p=r.Push;!0===f?p=r.Replace:!1===f||null!=c&&Re(c.formMethod)&&c.formAction===k.location.pathname+k.location.search&&(p=r.Replace);let m=n&&"preventScrollReset"in n?!0===n.preventScrollReset:void 0,y=Ie({currentLocation:u,nextLocation:h,historyAction:p});if(!y)return await ie(p,h,{submission:c,pendingError:d,preventScrollReset:m,replace:n&&n.replace});_e(y,{state:"blocked",location:h,proceed(){_e(y,{state:"proceeding",proceed:void 0,reset:void 0,location:h}),a(o,n)},reset(){let e=new Map(k.blockers);e.set(y,Y),re({blockers:e})}})},fetch:function(r,a,n,i){if(l)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.");q.has(r)&&Se(r);let s=d||y,u=G(k.location,k.matches,v,g.v7_prependBasename,n,a,null==i?void 0:i.relative),f=p(s,u,v);if(!f)return void we(r,a,fe(404,{pathname:u}));let{path:m,submission:b,error:w}=Q(g.v7_normalizeFormMethod,!0,u,i);if(w)return void we(r,a,w);let D=Pe(f,m);U=!0===(i&&i.preventScrollReset),b&&Re(b.formMethod)?async function(r,a,n,i,s,l){if(be(),N.delete(r),!i.route.action&&!i.route.lazy){let e=fe(405,{method:l.formMethod,pathname:n,routeId:a});return void we(r,a,e)}let u=k.fetchers.get(r),f=function(e,t){return{state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}(l,u);k.fetchers.set(r,f),re({fetchers:new Map(k.fetchers)});let m=new AbortController,g=ne(e.history,n,m.signal,l);q.set(r,m);let b=z,w=await oe("action",g,i,s,h,c,v);if(g.signal.aborted)return void(q.get(r)===m&&q.delete(r));if(ge(w)){if(q.delete(r),H>b){let e=ke(void 0);return k.fetchers.set(r,e),void re({fetchers:new Map(k.fetchers)})}{F.add(r);let e=je(l);return k.fetchers.set(r,e),re({fetchers:new Map(k.fetchers)}),le(k,w,{fetcherSubmission:l})}}if(ve(w))return void we(r,a,w.error);if(ye(w))throw fe(400,{type:"defer-action"});let D=k.navigation.location||k.location,R=ne(e.history,D,m.signal),E=d||y,x="idle"!==k.navigation.state?p(E,k.navigation.location,v):k.matches;o(x,"Didn't find any matches after fetcher action");let S=++z;B.set(r,S);let P=je(l,w.data);k.fetchers.set(r,P);let[M,A]=ee(e.history,k,x,l,D,O,_,I,N,F,E,v,{[i.route.id]:w.data},void 0);A.filter((e=>e.key!==r)).forEach((e=>{let t=e.key,r=k.fetchers.get(t),a=je(void 0,r?r.data:void 0);k.fetchers.set(t,a),q.has(t)&&Se(t),e.controller&&q.set(t,e.controller)})),re({fetchers:new Map(k.fetchers)});let j=()=>A.forEach((e=>Se(e.key)));m.signal.addEventListener("abort",j);let{results:U,loaderResults:T,fetcherResults:W}=await me(k.matches,x,M,A,R);if(m.signal.aborted)return;m.signal.removeEventListener("abort",j),B.delete(r),q.delete(r),A.forEach((e=>q.delete(e.key)));let $=pe(U);if($){if($.idx>=M.length){let e=A[$.idx-M.length].key;F.add(e)}return le(k,$.result)}let{loaderData:K,errors:Y}=ce(k,k.matches,M,T,void 0,A,W,V);if(k.fetchers.has(r)){let e=ke(w.data);k.fetchers.set(r,e)}let J=Te(S);"loading"===k.navigation.state&&S>H?(o(C,"Expected pending action"),L&&L.abort(),ae(k.navigation.location,{matches:x,loaderData:K,errors:Y,fetchers:new Map(k.fetchers)})):(re(t({errors:Y,loaderData:de(k.loaderData,K,x,Y)},J||A.length>0?{fetchers:new Map(k.fetchers)}:{})),O=!1)}(r,a,m,D,f,b):(N.set(r,{routeId:a,path:m}),async function(t,r,a,n,i,s){let l=k.fetchers.get(t),d=je(s,l?l.data:void 0);k.fetchers.set(t,d),re({fetchers:new Map(k.fetchers)});let u=new AbortController,f=ne(e.history,a,u.signal);q.set(t,u);let p=z,m=await oe("loader",f,n,i,h,c,v);ye(m)&&(m=await xe(m,f.signal,!0)||m);q.get(t)===u&&q.delete(t);if(f.signal.aborted)return;if(ge(m)){if(H>p){let e=ke(void 0);return k.fetchers.set(t,e),void re({fetchers:new Map(k.fetchers)})}return F.add(t),void await le(k,m)}if(ve(m)){let e=ue(k.matches,r);return k.fetchers.delete(t),void re({fetchers:new Map(k.fetchers),errors:{[e.route.id]:m.error}})}o(!ye(m),"Unhandled fetcher deferred data");let y=ke(m.data);k.fetchers.set(t,y),re({fetchers:new Map(k.fetchers)})}(r,a,m,D,f,b))},revalidate:function(){be(),re({revalidation:"loading"}),"submitting"!==k.navigation.state&&("idle"!==k.navigation.state?ie(C||k.historyAction,k.navigation.location,{overrideNavigation:k.navigation}):ie(k.historyAction,k.location,{startUninterruptedRevalidation:!0}))},createHref:t=>e.history.createHref(t),encodeLocation:t=>e.history.encodeLocation(t),getFetcher:se,deleteFetcher:De,dispose:function(){b&&b(),w.clear(),L&&L.abort(),k.fetchers.forEach(((e,t)=>De(t))),k.blockers.forEach(((e,t)=>Oe(t)))},getBlocker:function(e,t){let r=k.blockers.get(e)||Y;return Z.get(e)!==t&&Z.set(e,t),r},deleteBlocker:Oe,_internalFetchControllers:q,_internalActiveDeferreds:V,_internalSetRoutes:function(e){h={},d=f(e,c,void 0,h)}},A},e.createStaticHandler=function(e,r){o(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let a,n={},i=(r?r.basename:null)||"/";if(null!=r&&r.mapRouteProperties)a=r.mapRouteProperties;else if(null!=r&&r.detectErrorBoundary){let e=r.detectErrorBoundary;a=t=>({hasErrorBoundary:e(t)})}else a=X;let c=f(e,a,void 0,n);async function d(e,r,s,l,c){o(e.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(Re(e.method.toLowerCase())){let o=await async function(e,r,o,s,l){let c;if(o.route.action||o.route.lazy){if(c=await oe("action",e,o,r,n,a,i,{isStaticRequest:!0,isRouteRequest:l,requestContext:s}),e.signal.aborted){throw new Error((l?"queryRoute":"query")+"() call aborted: "+e.method+" "+e.url)}}else{let t=fe(405,{method:e.method,pathname:new URL(e.url).pathname,routeId:o.route.id});if(l)throw t;c={type:u.error,error:t}}if(ge(c))throw new Response(null,{status:c.status,headers:{Location:c.location}});if(ye(c)){let e=fe(400,{type:"defer-action"});if(l)throw e;c={type:u.error,error:e}}if(l){if(ve(c))throw c.error;return{matches:[o],loaderData:{},actionData:{[o.route.id]:c.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}if(ve(c)){let a=ue(r,o.route.id);return t({},await h(e,r,s,void 0,{[a.route.id]:c.error}),{statusCode:q(c.error)?c.error.status:500,actionData:null,actionHeaders:t({},c.headers?{[o.route.id]:c.headers}:{})})}let d=new Request(e.url,{headers:e.headers,redirect:e.redirect,signal:e.signal});return t({},await h(d,r,s),c.statusCode?{statusCode:c.statusCode}:{},{actionData:{[o.route.id]:c.data},actionHeaders:t({},c.headers?{[o.route.id]:c.headers}:{})})}(e,s,c||Pe(s,r),l,null!=c);return o}let o=await h(e,s,l,c);return we(o)?o:t({},o,{actionData:null,actionHeaders:{}})}catch(e){if((d=e)&&we(d.response)&&(d.type===u.data||d.type===u.error)){if(e.type===u.error)throw e.response;return e.response}if(function(e){if(!we(e))return!1;let t=e.status,r=e.headers.get("Location");return t>=300&&t<=399&&null!=r}(e))return e;throw e}var d}async function h(e,r,o,s,l){let c=null!=s;if(c&&(null==s||!s.route.loader)&&(null==s||!s.route.lazy))throw fe(400,{method:e.method,pathname:new URL(e.url).pathname,routeId:null==s?void 0:s.route.id});let d=(s?[s]:Z(r,Object.keys(l||{})[0])).filter((e=>e.route.loader||e.route.lazy));if(0===d.length)return{matches:r,loaderData:r.reduce(((e,t)=>Object.assign(e,{[t.route.id]:null})),{}),errors:l||null,statusCode:200,loaderHeaders:{},activeDeferreds:null};let u=await Promise.all([...d.map((t=>oe("loader",e,t,r,n,a,i,{isStaticRequest:!0,isRouteRequest:c,requestContext:o})))]);if(e.signal.aborted){throw new Error((c?"queryRoute":"query")+"() call aborted: "+e.method+" "+e.url)}let h=new Map,f=le(r,d,u,l,h),p=new Set(d.map((e=>e.route.id)));return r.forEach((e=>{p.has(e.route.id)||(f.loaderData[e.route.id]=null)})),t({},f,{matches:r,activeDeferreds:h.size>0?Object.fromEntries(h.entries()):null})}return{dataRoutes:c,query:async function(e,r){let{requestContext:a}=void 0===r?{}:r,o=new URL(e.url),n=e.method,u=s("",l(o),null,"default"),h=p(c,u,i);if(!De(n)&&"HEAD"!==n){let e=fe(405,{method:n}),{matches:t,route:r}=he(c);return{basename:i,location:u,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}if(!h){let e=fe(404,{pathname:u.pathname}),{matches:t,route:r}=he(c);return{basename:i,location:u,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}let f=await d(e,u,h,a);return we(f)?f:t({location:u,basename:i},f)},queryRoute:async function(e,t){let{routeId:r,requestContext:a}=void 0===t?{}:t,o=new URL(e.url),n=e.method,u=s("",l(o),null,"default"),h=p(c,u,i);if(!De(n)&&"HEAD"!==n&&"OPTIONS"!==n)throw fe(405,{method:n});if(!h)throw fe(404,{pathname:u.pathname});let f=r?h.find((e=>e.route.id===r)):Pe(h,u);if(r&&!f)throw fe(403,{pathname:u.pathname,routeId:r});if(!f)throw fe(404,{pathname:u.pathname});let m=await d(e,u,h,a,f);if(we(m))return m;let y=m.errors?Object.values(m.errors)[0]:void 0;if(void 0!==y)throw y;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[f.route.id]&&(e[V]=m.activeDeferreds[f.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;r.endsWith("*")&&"*"!==r&&!r.endsWith("/*")&&(n(!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(/\*$/,"/*"));const a=r.startsWith("/")?"/":"",i=e=>null==e?"":"string"==typeof e?e:String(e);return a+r.split(/\/+/).map(((e,r,a)=>{if(r===a.length-1&&"*"===e){return i(t["*"])}const n=e.match(/^:(\w+)(\??)$/);if(n){const[,e,r]=n;let a=t[e];return o("?"===r||null!=a,'Missing ":'+e+'" param'),i(a)}return e.replace(/\?$/g,"")})).filter((e=>!!e)).join("/")},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.isDeferredData=be,e.isRouteErrorResponse=q,e.joinPaths=L,e.json=function(e,r){void 0===r&&(r={});let a="number"==typeof r?{status:r}:r,o=new Headers(a.headers);return o.has("Content-Type")||o.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify(e),t({},a,{headers:o}))},e.matchPath=R,e.matchRoutes=p,e.normalizePathname=j,e.parsePath=c,e.redirect=_,e.redirectDocument=(e,t)=>{let r=_(e,t);return r.headers.set("X-Remix-Reload-Document","true"),r},e.resolvePath=S,e.resolveTo=A,e.stripBasename=x,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=router.umd.min.js.map