/** * @remix-run/router v1.7.2 * * 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=0&&(t.hash=e.substr(r),e=e.substr(0,r));let o=e.indexOf("?");o>=0&&(t.search=e.substr(o),e=e.substr(0,o)),e&&(t.pathname=e)}return t}function d(r,n,c,d){void 0===d&&(d={});let{window:u=document.defaultView,v5Compat:h=!1}=d,f=u.history,p=e.Action.Pop,m=null,y=v();function v(){return(f.state||{idx:null}).idx}function g(){p=e.Action.Pop;let t=v(),r=null==t?null:t-y;y=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 a(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 r(u,f)},listen(e){if(m)throw new Error("A history only accepts one active listener");return u.addEventListener(o,g),m=e,()=>{u.removeEventListener(o,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(t,r){p=e.Action.Push;let o=s(w.location,t,r);c&&c(o,t),y=v()+1;let a=i(o,y),n=w.createHref(o);try{f.pushState(a,"",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(t,r){p=e.Action.Replace;let o=s(w.location,t,r);c&&c(o,t),y=v();let a=i(o,y),n=w.createHref(o);f.replaceState(a,"",n),h&&m&&m({action:p,location:w.location,delta:0})},go:e=>f.go(e)};return w}let u;!function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(u||(u={}));const h=new Set(["lazy","caseSensitive","path","id","index","children"]);function f(e,r,o,n){return void 0===o&&(o=[]),void 0===n&&(n={}),e.map(((e,i)=>{let s=[...o,i],l="string"==typeof e.id?e.id:s.join("-");if(a(!0!==e.index||!e.children,"Cannot specify children on an index route"),a(!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 o=t({},e,r(e),{id:l});return n[l]=o,o}{let o=t({},e,r(e),{id:l,children:void 0});return n[l]=o,e.children&&(o.children=f(e.children,r,s,n)),o}}))}function p(e,t,r){void 0===r&&(r="/");let o=E(("string"==typeof t?c(t):t).pathname||"/",r);if(null==o)return null;let a=m(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)))))}(a);let n=null;for(let e=0;null==n&&e{let s={relativePath:void 0===i?e.path||"":i,caseSensitive:!0===e.caseSensitive,childrenIndex:n,route:e};s.relativePath.startsWith("/")&&(a(s.relativePath.startsWith(o),'Absolute route path "'+s.relativePath+'" nested under path "'+o+'" is not valid. An absolute child route path must start with the combined path of all its parent routes.'),s.relativePath=s.relativePath.slice(o.length));let l=M([o,s.relativePath]),c=r.concat(s);e.children&&e.children.length>0&&(a(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'+l+'".'),m(e.children,t,c,l)),(null!=e.path||e.index)&&t.push({path:l,score:b(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 y(e.path))n(e,t,r);else n(e,t)})),t}function y(e){let t=e.split("/");if(0===t.length)return[];let[r,...o]=t,a=r.endsWith("?"),n=r.replace(/\?$/,"");if(0===o.length)return a?[n,""]:[n];let i=y(o.join("/")),s=[];return s.push(...i.map((e=>""===e?n:[n,e].join("/")))),a&&s.push(...i),s.map((t=>e.startsWith("/")&&""===t?"/":t))}const v=/^:\w+$/,g=e=>"*"===e;function b(e,t){let r=e.split("/"),o=r.length;return r.some(g)&&(o+=-2),t&&(o+=2),r.filter((e=>!g(e))).reduce(((e,t)=>e+(v.test(t)?3:""===t?1:10)),o)}function w(e,t){let{routesMeta:r}=e,o={},a="/",n=[];for(let e=0;e(o.push(t),"/([^\\/]+)")));e.endsWith("*")?(o.push("*"),a+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":""!==e&&"/"!==e&&(a+="(?:(?=\\/|$))");return[new RegExp(a,t?void 0:"i"),o]}(e.path,e.caseSensitive,e.end),a=t.match(r);if(!a)return null;let i=a[0],s=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:o.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 R(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 E(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,o=e.charAt(r);return o&&"/"!==o?null:e.slice(r)||"/"}function A(e,t){void 0===t&&(t="/");let{pathname:r,search:o="",hash:a=""}="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:j(o),hash:k(a)}}function x(e,t,r,o){return"Cannot include a '"+e+"' character in a manually specified `to."+t+"` field ["+JSON.stringify(o)+"]. Please separate it out to the `to."+r+'` field. Alternatively you may provide the full path as a string in 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 P(e,r,o,n){let i;void 0===n&&(n=!1),"string"==typeof e?i=c(e):(i=t({},e),a(!i.pathname||!i.pathname.includes("?"),x("?","pathname","search",i)),a(!i.pathname||!i.pathname.includes("#"),x("#","pathname","hash",i)),a(!i.search||!i.search.includes("#"),x("#","search","hash",i)));let s,l=""===e||""===i.pathname,d=l?"/":i.pathname;if(n||null==d)s=o;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=A(i,s),h=d&&"/"!==d&&d.endsWith("/"),f=(l||"."===d)&&o.endsWith("/");return u.pathname.endsWith("/")||!h&&!f||(u.pathname+="/"),u}const M=e=>e.join("/").replace(/\/\/+/g,"/"),L=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),j=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",k=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";class C extends Error{}class U{constructor(e,t){let r;this.pendingKeysSet=new Set,this.subscribers=new Set,this.deferredKeys=[],a(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 o=()=>r(new C("Deferred data aborted"));this.unlistenAbortSignal=()=>this.controller.signal.removeEventListener("abort",o),this.controller.signal.addEventListener("abort",o),this.data=Object.entries(e).reduce(((e,t)=>{let[r,o]=t;return Object.assign(e,{[r]:this.trackPromise(r,o)})}),{}),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,o){if(this.controller.signal.aborted&&r instanceof C)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===o){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===o?(Object.defineProperty(e,"_error",{get:()=>r}),this.emit(!1,t),Promise.reject(r)):(Object.defineProperty(e,"_data",{get:()=>o}),this.emit(!1,t),o)}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((o=>{e.removeEventListener("abort",r),(o||this.done)&&t(o)}))}))}return t}get done(){return 0===this.pendingKeysSet.size}get unwrappedData(){return a(null!==this.data&&this.done,"Can only unwrap data on initialized and settled deferreds"),Object.entries(this.data).reduce(((e,t)=>{let[r,o]=t;return Object.assign(e,{[r]:T(o)})}),{})}get pendingKeys(){return Array.from(this.pendingKeysSet)}}function T(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,o){void 0===o&&(o=!1),this.status=e,this.statusText=t||"",this.internal=o,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 I=["post","put","patch","delete"],q=new Set(I),z=["get",...I],F=new Set(z),H=new Set([301,302,303,307,308]),B=new Set([307,308]),N={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},$={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},W={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},K=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Y=e=>({hasErrorBoundary:Boolean(e.hasErrorBoundary)});const J=Symbol("deferred");function V(e,t,r,o,a,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=P(a||".",S(s).map((e=>e.pathnameBase)),E(e.pathname,r)||e.pathname,"path"===i);return null==a&&(d.search=e.search,d.hash=e.hash),null!=a&&""!==a&&"."!==a||!c||!c.route.index||Ae(d.search)||(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),o&&"/"!==r&&(d.pathname="/"===d.pathname?r:M([r,d.pathname])),l(d)}function G(e,t,r,o){if(!o||!function(e){return null!=e&&("formData"in e&&null!=e.formData||"body"in e&&void 0!==e.body)}(o))return{path:r};if(o.formMethod&&!we(o.formMethod))return{path:r,error:ue(405,{method:o.formMethod})};let n,i,s=()=>({path:r,error:ue(400,{type:"invalid-body"})}),d=o.formMethod||"get",u=e?d.toUpperCase():d.toLowerCase(),h=fe(r);if(void 0!==o.body){if("text/plain"===o.formEncType){if(!De(u))return s();let e="string"==typeof o.body?o.body:o.body instanceof FormData||o.body instanceof URLSearchParams?Array.from(o.body.entries()).reduce(((e,t)=>{let[r,o]=t;return""+e+r+"="+o+"\n"}),""):String(o.body);return{path:r,submission:{formMethod:u,formAction:h,formEncType:o.formEncType,formData:void 0,json:void 0,text:e}}}if("application/json"===o.formEncType){if(!De(u))return s();try{let e="string"==typeof o.body?JSON.parse(o.body):o.body;return{path:r,submission:{formMethod:u,formAction:h,formEncType:o.formEncType,formData:void 0,json:e,text:void 0}}}catch(e){return s()}}}if(a("function"==typeof FormData,"FormData is not available in this environment"),o.formData)n=ae(o.formData),i=o.formData;else if(o.body instanceof FormData)n=ae(o.body),i=o.body;else if(o.body instanceof URLSearchParams)n=o.body,i=ne(n);else if(null==o.body)n=new URLSearchParams,i=new FormData;else try{n=new URLSearchParams(o.body),i=ne(n)}catch(e){return s()}let f={formMethod:u,formAction:h,formEncType:o&&o.formEncType||"application/x-www-form-urlencoded",formData:i,json:void 0,text:void 0};if(De(f.formMethod))return{path:r,submission:f};let p=c(r);return t&&p.search&&Ae(p.search)&&n.append("index",""),p.search="?"+n,{path:l(p),submission:f}}function X(e,t){let r=e;if(t){let o=e.findIndex((e=>e.route.id===t));o>=0&&(r=e.slice(0,o))}return r}function Q(e,r,o,a,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=X(o,b).filter(((e,o)=>{if(e.route.lazy)return!0;if(null==e.route.loader)return!1;if(function(e,t,r){let o=!t||r.route.id!==t.route.id,a=void 0===e[r.route.id];return o||a}(r.loaderData,r.matches[o],e)||s.some((t=>t===e.route.id)))return!0;let n=r.matches[o],l=e;return ee(e,t({currentUrl:v,currentParams:n.params,nextUrl:g,nextParams:l.params},a,{actionResult:y,defaultShouldRevalidate:i||v.pathname+v.search===g.pathname+g.search||v.search!==g.search||Z(n,l)}))})),D=[];return c.forEach(((e,n)=>{if(!o.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=xe(s,e.path),m=!1;m=!d.has(n)&&(!!l.includes(n)||(c&&"idle"!==c.state&&void 0===c.data?i:ee(f,t({currentUrl:v,currentParams:r.matches[r.matches.length-1].params,nextUrl:g,nextParams:o[o.length-1].params},a,{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 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,r,o){if(!e.lazy)return;let i=await e.lazy();if(!e.lazy)return;let s=o[e.id];a(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 re(e,t,r,o,n,i,s,l){let c,d,h;void 0===l&&(l={});let f=e=>{let o,a=new Promise(((e,t)=>o=t));return h=()=>o(),t.signal.addEventListener("abort",h),Promise.race([e({request:t,params:r.params,context:l.requestContext}),a])};try{let o=r.route[e];if(r.route.lazy)if(o){d=(await Promise.all([f(o),te(r.route,i,n)]))[0]}else{if(await te(r.route,i,n),o=r.route[e],!o){if("action"===e){let e=new URL(t.url),o=e.pathname+e.search;throw ue(405,{method:t.method,pathname:o,routeId:r.route.id})}return{type:u.data,data:void 0}}d=await f(o)}else{if(!o){let e=new URL(t.url);throw ue(404,{pathname:e.pathname+e.search})}d=await f(o)}a(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(ge(d)){let e,n=d.status;if(H.has(n)){let e=d.headers.get("Location");if(a(e,"Redirects returned/thrown from loaders/actions must have a Location header"),K.test(e)){if(!l.isStaticRequest){let r=new URL(t.url),o=e.startsWith("//")?new URL(r.protocol+e):new URL(e),a=null!=E(o.pathname,s);o.origin===r.origin&&a&&(e=o.pathname+o.search+o.hash)}}else e=V(new URL(t.url),o.slice(0,o.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")}}if(l.isRouteRequest)throw{type:c||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 O(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}:ve(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 oe(e,t,r,o){let a=e.createURL(fe(t)).toString(),n={signal:r};if(o&&De(o.formMethod)){let{formMethod:e,formEncType:t}=o;n.method=e.toUpperCase(),"application/json"===t?(n.headers=new Headers({"Content-Type":t}),n.body=JSON.stringify(o.json)):"text/plain"===t?n.body=o.text:"application/x-www-form-urlencoded"===t&&o.formData?n.body=ae(o.formData):n.body=o.formData}return new Request(a,n)}function ae(e){let t=new URLSearchParams;for(let[r,o]of e.entries())t.append(r,"string"==typeof o?o:o.name);return t}function ne(e){let t=new FormData;for(let[r,o]of e.entries())t.append(r,o);return t}function ie(e,t,r,o,n){let i,s={},l=null,c=!1,d={};return r.forEach(((r,u)=>{let h=t[u].route.id;if(a(!ye(r),"Cannot handle redirect results in processLoaderData"),me(r)){let t=ce(e,h),a=r.error;o&&(a=Object.values(o)[0],o=void 0),l=l||{},null==l[t.route.id]&&(l[t.route.id]=a),s[h]=void 0,c||(c=!0,i=_(r.error)?r.error.status:500),r.headers&&(d[h]=r.headers)}else pe(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)})),o&&(l=o,s[Object.keys(o)[0]]=void 0),{loaderData:s,errors:l,statusCode:i||200,loaderHeaders:d}}function se(e,r,o,n,i,s,l,c){let{loaderData:d,errors:u}=ie(r,o,n,i,c);for(let r=0;re.route.id===t))+1):[...e]).reverse().find((e=>!0===e.route.hasErrorBoundary))||e[0]}function de(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 ue(e,t){let{pathname:r,routeId:o,method:a,type:n}=void 0===t?{}:t,i="Unknown Server Error",s="Unknown @remix-run/router error";return 400===e?(i="Bad Request",a&&r&&o?s="You made a "+a+' request to "'+r+'" but did not provide a `loader` for route "'+o+'", 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 "'+o+'" does not match URL "'+r+'"'):404===e?(i="Not Found",s='No route matches URL "'+r+'"'):405===e&&(i="Method Not Allowed",a&&r&&o?s="You made a "+a.toUpperCase()+' request to "'+r+'" but did not provide an `action` for route "'+o+'", so there is no way to handle the request.':a&&(s='Invalid request method "'+a.toUpperCase()+'"')),new O(e||500,i,new Error(s),!0)}function he(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if(ye(r))return{result:r,idx:t}}}function fe(e){return l(t({},"string"==typeof e?c(e):e,{hash:""}))}function pe(e){return e.type===u.deferred}function me(e){return e.type===u.error}function ye(e){return(e&&e.type)===u.redirect}function ve(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 ge(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"object"==typeof e.headers&&void 0!==e.body}function be(e){if(!ge(e))return!1;let t=e.status,r=e.headers.get("Location");return t>=300&&t<=399&&null!=r}function we(e){return F.has(e.toLowerCase())}function De(e){return q.has(e.toLowerCase())}async function Re(e,t,r,o,n,i){for(let s=0;se.route.id===c.route.id)),u=null!=d&&!Z(d,c)&&void 0!==(i&&i[c.route.id]);if(pe(l)&&(n||u)){let e=o[s];a(e,"Expected an AbortSignal for revalidating fetcher deferred result"),await Ee(l,e,n).then((e=>{e&&(r[s]=e||r[s])}))}}}async function Ee(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 Ae(e){return new URLSearchParams(e).getAll("index").some((e=>""===e))}function xe(e,t){let r="string"==typeof t?c(t).search:t.search;if(e[e.length-1].route.index&&Ae(r||""))return e[e.length-1];let o=S(e);return o[o.length-1]}function Se(e){let{formMethod:t,formAction:r,formEncType:o,text:a,formData:n,json:i}=e;if(t&&r&&o)return null!=a?{formMethod:t,formAction:r,formEncType:o,formData:void 0,json:void 0,text:a}:null!=n?{formMethod:t,formAction:r,formEncType:o,formData:n,json:void 0,text:void 0}:void 0!==i?{formMethod:t,formAction:r,formEncType:o,formData:void 0,json:i,text:void 0}:void 0}function Pe(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 Me(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 Le(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," _hasFetcherDoneAnything ":!0}}return{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t," _hasFetcherDoneAnything ":!0}}function je(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e," _hasFetcherDoneAnything ":!0}}e.AbortedDeferredError=C,e.ErrorResponse=O,e.IDLE_BLOCKER=W,e.IDLE_FETCHER=$,e.IDLE_NAVIGATION=N,e.UNSAFE_DEFERRED_SYMBOL=J,e.UNSAFE_DeferredData=U,e.UNSAFE_convertRoutesToDataRoutes=f,e.UNSAFE_getPathContributingMatches=S,e.UNSAFE_invariant=a,e.UNSAFE_warning=n,e.createBrowserHistory=function(e){return void 0===e&&(e={}),d((function(e,t){let{pathname:r,search:o,hash:a}=e.location;return s("",{pathname:r,search:o,hash:a},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:o="",hash:a=""}=c(e.location.hash.substr(1));return s("",{pathname:r,search:o,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){let r=e.document.querySelector("base"),o="";if(r&&r.getAttribute("href")){let t=e.location.href,r=t.indexOf("#");o=-1===r?t:t.slice(0,r)}return o+"#"+("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(t){void 0===t&&(t={});let r,{initialEntries:o=["/"],initialIndex:a,v5Compat:i=!1}=t;r=o.map(((e,t)=>m(e,"string"==typeof e?null:e.state,0===t?"default":void 0)));let d=f(null==a?r.length-1:a),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,o){void 0===t&&(t=null);let a=s(r?p().pathname:"/",e,t,o);return n("/"===a.pathname.charAt(0),"relative pathnames are not supported in memory history: "+JSON.stringify(e)),a}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(t,o){u=e.Action.Push;let a=m(t,o);d+=1,r.splice(d,r.length,a),i&&h&&h({action:u,location:a,delta:1})},replace(t,o){u=e.Action.Replace;let a=m(t,o);r[d]=a,i&&h&&h({action:u,location:a,delta:0})},go(t){u=e.Action.Pop;let o=f(d+t),a=r[o];d=o,h&&h({action:u,location:a,delta:t})},listen:e=>(h=e,()=>{h=null})}},e.createPath=l,e.createRouter=function(r){const o=r.window?r.window:"undefined"!=typeof window?window:void 0,i=void 0!==o&&void 0!==o.document&&void 0!==o.document.createElement,l=!i;let c;if(a(r.routes.length>0,"You must provide a non-empty routes array to createRouter"),r.mapRouteProperties)c=r.mapRouteProperties;else if(r.detectErrorBoundary){let e=r.detectErrorBoundary;c=t=>({hasErrorBoundary:e(t)})}else c=Y;let d,h={},m=f(r.routes,c,void 0,h),y=r.basename||"/",v=t({v7_normalizeFormMethod:!1,v7_prependBasename:!1},r.future),g=null,b=new Set,w=null,D=null,R=null,A=null!=r.hydrationData,x=p(m,r.history.location,y),S=null;if(null==x){let e=ue(404,{pathname:r.history.location.pathname}),{matches:t,route:o}=de(m);x=t,S={[o.id]:e}}let P,M,L=!(x.some((e=>e.route.lazy))||x.some((e=>e.route.loader))&&null==r.hydrationData),j={historyAction:r.history.action,location:r.history.location,matches:x,initialized:L,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||S,fetchers:new Map,blockers:new Map},k=e.Action.Pop,C=!1,U=!1,T=!1,O=[],_=[],I=new Map,q=0,z=-1,F=new Map,H=new Set,J=new Map,X=new Map,Z=new Map,ee=!1;function te(e){j=t({},j,e),b.forEach((e=>e(j)))}function ae(o,a){var n,i;let s,l=null!=j.actionData&&null!=j.navigation.formMethod&&De(j.navigation.formMethod)&&"loading"===j.navigation.state&&!0!==(null==(n=o.state)?void 0:n._isRedirect);s=a.actionData?Object.keys(a.actionData).length>0?a.actionData:null:l?j.actionData:null;let c=a.loaderData?le(j.loaderData,a.loaderData,a.matches||[],a.errors):j.loaderData,u=j.blockers;u.size>0&&(u=new Map(u),u.forEach(((e,t)=>u.set(t,W))));let h=!0===C||null!=j.navigation.formMethod&&De(j.navigation.formMethod)&&!0!==(null==(i=o.state)?void 0:i._isRedirect);d&&(m=d,d=void 0),U||k===e.Action.Pop||(k===e.Action.Push?r.history.push(o,o.state):k===e.Action.Replace&&r.history.replace(o,o.state)),te(t({},a,{actionData:s,loaderData:c,historyAction:k,location:o,initialized:!0,navigation:N,revalidation:"idle",restoreScrollPosition:ze(o,a.matches||j.matches),preventScrollReset:h,blockers:u})),k=e.Action.Pop,C=!1,U=!1,T=!1,O=[],_=[]}async function ne(o,a,n){M&&M.abort(),M=null,k=o,U=!0===(n&&n.startUninterruptedRevalidation),function(e,t){if(w&&R){let r=qe(e,t);w[r]=R()}}(j.location,j.matches),C=!0===(n&&n.preventScrollReset);let i=d||m,s=n&&n.overrideNavigation,l=p(i,a,y);if(!l){let e=ue(404,{pathname:a.pathname}),{matches:t,route:r}=de(i);return Ie(),void ae(a,{matches:t,loaderData:{},errors:{[r.id]:e}})}if(j.initialized&&!T&&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}(j.location,a)&&!(n&&n.submission&&De(n.submission.formMethod)))return void ae(a,{matches:l});M=new AbortController;let f,v,g=oe(r.history,a,M.signal,n&&n.submission);if(n&&n.pendingError)v={[ce(l).route.id]:n.pendingError};else if(n&&n.submission&&De(n.submission.formMethod)){let t=await async function(t,r,o,a,n){void 0===n&&(n={});let i;ge(),te({navigation:Me(r,o)});let s=xe(a,r);if(s.route.action||s.route.lazy){if(i=await re("action",t,s,a,h,c,y),t.signal.aborted)return{shortCircuited:!0}}else i={type:u.error,error:ue(405,{method:t.method,pathname:r.pathname,routeId:s.route.id})};if(ye(i)){let e;return e=n&&null!=n.replace?n.replace:i.location===j.location.pathname+j.location.search,await fe(j,i,{submission:o,replace:e}),{shortCircuited:!0}}if(me(i)){let t=ce(a,s.route.id);return!0!==(n&&n.replace)&&(k=e.Action.Push),{pendingActionData:{},pendingActionError:{[t.route.id]:i.error}}}if(pe(i))throw ue(400,{type:"defer-action"});return{pendingActionData:{[s.route.id]:i.data}}}(g,a,n.submission,l,{replace:n.replace});if(t.shortCircuited)return;f=t.pendingActionData,v=t.pendingActionError,s=Pe(a,n.submission),g=new Request(g.url,{signal:g.signal})}let{shortCircuited:b,loaderData:D,errors:E}=await async function(e,o,a,n,i,s,l,c,u){let h=n||Pe(o,i),f=i||s||Se(h),p=d||m,[v,g]=Q(r.history,j,a,f,o,T,O,_,J,H,p,y,c,u);if(Ie((e=>!(a&&a.some((t=>t.route.id===e)))||v&&v.some((t=>t.route.id===e)))),z=++q,0===v.length&&0===g.length){let e=Ce();return ae(o,t({matches:a,loaderData:{},errors:u||null},c?{actionData:c}:{},e?{fetchers:new Map(j.fetchers)}:{})),{shortCircuited:!0}}if(!U){g.forEach((e=>{let t=j.fetchers.get(e.key),r=Le(void 0,t?t.data:void 0);j.fetchers.set(e.key,r)}));let e=c||j.actionData;te(t({navigation:h},e?0===Object.keys(e).length?{actionData:null}:{actionData:e}:{},g.length>0?{fetchers:new Map(j.fetchers)}:{}))}g.forEach((e=>{I.has(e.key)&&Ae(e.key),e.controller&&I.set(e.key,e.controller)}));let b=()=>g.forEach((e=>Ae(e.key)));M&&M.signal.addEventListener("abort",b);let{results:w,loaderResults:D,fetcherResults:R}=await ve(j.matches,a,v,g,e);if(e.signal.aborted)return{shortCircuited:!0};M&&M.signal.removeEventListener("abort",b);g.forEach((e=>I.delete(e.key)));let E=he(w);if(E){if(E.idx>=v.length){let e=g[E.idx-v.length].key;H.add(e)}return await fe(j,E.result,{replace:l}),{shortCircuited:!0}}let{loaderData:A,errors:x}=se(j,a,v,D,u,g,R,X);X.forEach(((e,t)=>{e.subscribe((r=>{(r||e.done)&&X.delete(t)}))}));let S=Ce(),P=Ue(z),L=S||P||g.length>0;return t({loaderData:A,errors:x},L?{fetchers:new Map(j.fetchers)}:{})}(g,a,l,s,n&&n.submission,n&&n.fetcherSubmission,n&&n.replace,f,v);b||(M=null,ae(a,t({matches:l},f?{actionData:f}:{},{loaderData:D,errors:E})))}function ie(e){return j.fetchers.get(e)||$}async function fe(n,l,c){let{submission:d,replace:u,isFetchActionRedirect:h}=void 0===c?{}:c;l.revalidate&&(T=!0);let f=s(n.location,l.location,t({_isRedirect:!0},h?{_isFetchActionRedirect:!0}:{}));if(a(f,"Expected a location on the redirect navigation"),K.test(l.location)&&i){let e=r.history.createURL(l.location),t=null==E(e.pathname,y);if(o.location.origin!==e.origin||t)return void(u?o.location.replace(l.location):o.location.assign(l.location))}M=null;let p=!0===u?e.Action.Replace:e.Action.Push,m=d||Se(n.navigation);if(B.has(l.status)&&m&&De(m.formMethod))await ne(p,f,{submission:t({},m,{formAction:l.location}),preventScrollReset:C});else if(h)await ne(p,f,{overrideNavigation:Pe(f),fetcherSubmission:m,preventScrollReset:C});else{let e=Pe(f,m);await ne(p,f,{overrideNavigation:e,preventScrollReset:C})}}async function ve(e,t,o,a,n){let i=await Promise.all([...o.map((e=>re("loader",n,e,t,h,c,y))),...a.map((e=>{if(e.matches&&e.match&&e.controller)return re("loader",oe(r.history,e.path,e.controller.signal),e.match,e.matches,h,c,y);return{type:u.error,error:ue(404,{pathname:e.path})}}))]),s=i.slice(0,o.length),l=i.slice(o.length);return await Promise.all([Re(e,o,s,s.map((()=>n.signal)),!1,j.loaderData),Re(e,a.map((e=>e.match)),l,a.map((e=>e.controller?e.controller.signal:null)),!0)]),{results:i,loaderResults:s,fetcherResults:l}}function ge(){T=!0,O.push(...Ie()),J.forEach(((e,t)=>{I.has(t)&&(_.push(t),Ae(t))}))}function be(e,t,r){let o=ce(j.matches,t);we(e),te({errors:{[o.route.id]:r},fetchers:new Map(j.fetchers)})}function we(e){let t=j.fetchers.get(e);!I.has(e)||t&&"loading"===t.state&&F.has(e)||Ae(e),J.delete(e),F.delete(e),H.delete(e),j.fetchers.delete(e)}function Ae(e){let t=I.get(e);a(t,"Expected fetch controller: "+e),t.abort(),I.delete(e)}function ke(e){for(let t of e){let e=je(ie(t).data);j.fetchers.set(t,e)}}function Ce(){let e=[],t=!1;for(let r of H){let o=j.fetchers.get(r);a(o,"Expected fetcher: "+r),"loading"===o.state&&(H.delete(r),e.push(r),t=!0)}return ke(e),t}function Ue(e){let t=[];for(let[r,o]of F)if(o0}function Te(e){j.blockers.delete(e),Z.delete(e)}function Oe(e,t){let r=j.blockers.get(e)||W;a("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 o=new Map(j.blockers);o.set(e,t),te({blockers:o})}function _e(e){let{currentLocation:t,nextLocation:r,historyAction:o}=e;if(0===Z.size)return;Z.size>1&&n(!1,"A router only supports one blocker at a time");let a=Array.from(Z.entries()),[i,s]=a[a.length-1],l=j.blockers.get(i);return l&&"proceeding"===l.state?void 0:s({currentLocation:t,nextLocation:r,historyAction:o})?i:void 0}function Ie(e){let t=[];return X.forEach(((r,o)=>{e&&!e(o)||(r.cancel(),t.push(o),X.delete(o))})),t}function qe(e,t){if(D){return D(e,t.map((e=>function(e,t){let{route:r,pathname:o,params:a}=e;return{id:r.id,pathname:o,params:a,data:t[r.id],handle:r.handle}}(e,j.loaderData))))||e.key}return e.key}function ze(e,t){if(w){let r=qe(e,t),o=w[r];if("number"==typeof o)return o}return null}return P={get basename(){return y},get state(){return j},get routes(){return m},initialize:function(){return g=r.history.listen((e=>{let{action:t,location:o,delta:a}=e;if(ee)return void(ee=!1);n(0===Z.size||null!=a,"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=_e({currentLocation:j.location,nextLocation:o,historyAction:t});return i&&null!=a?(ee=!0,r.history.go(-1*a),void Oe(i,{state:"blocked",location:o,proceed(){Oe(i,{state:"proceeding",proceed:void 0,reset:void 0,location:o}),r.history.go(a)},reset(){let e=new Map(j.blockers);e.set(i,W),te({blockers:e})}})):ne(t,o)})),j.initialized||ne(e.Action.Pop,j.location),P},subscribe:function(e){return b.add(e),()=>b.delete(e)},enableScrollRestoration:function(e,t,r){if(w=e,R=t,D=r||null,!A&&j.navigation===N){A=!0;let e=ze(j.location,j.matches);null!=e&&te({restoreScrollPosition:e})}return()=>{w=null,R=null,D=null}},navigate:async function o(a,n){if("number"==typeof a)return void r.history.go(a);let i=V(j.location,j.matches,y,v.v7_prependBasename,a,null==n?void 0:n.fromRouteId,null==n?void 0:n.relative),{path:l,submission:c,error:d}=G(v.v7_normalizeFormMethod,!1,i,n),u=j.location,h=s(j.location,l,n&&n.state);h=t({},h,r.history.encodeLocation(h));let f=n&&null!=n.replace?n.replace:void 0,p=e.Action.Push;!0===f?p=e.Action.Replace:!1===f||null!=c&&De(c.formMethod)&&c.formAction===j.location.pathname+j.location.search&&(p=e.Action.Replace);let m=n&&"preventScrollReset"in n?!0===n.preventScrollReset:void 0,g=_e({currentLocation:u,nextLocation:h,historyAction:p});if(!g)return await ne(p,h,{submission:c,pendingError:d,preventScrollReset:m,replace:n&&n.replace});Oe(g,{state:"blocked",location:h,proceed(){Oe(g,{state:"proceeding",proceed:void 0,reset:void 0,location:h}),o(a,n)},reset(){let e=new Map(j.blockers);e.set(g,W),te({blockers:e})}})},fetch:function(e,o,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.");I.has(e)&&Ae(e);let s=d||m,u=V(j.location,j.matches,y,v.v7_prependBasename,n,o,null==i?void 0:i.relative),f=p(s,u,y);if(!f)return void be(e,o,ue(404,{pathname:u}));let{path:g,submission:b,error:w}=G(v.v7_normalizeFormMethod,!0,u,i);if(w)return void be(e,o,w);let D=xe(f,g);C=!0===(i&&i.preventScrollReset),b&&De(b.formMethod)?async function(e,o,n,i,s,l){if(ge(),J.delete(e),!i.route.action&&!i.route.lazy){let t=ue(405,{method:l.formMethod,pathname:n,routeId:o});return void be(e,o,t)}let u=j.fetchers.get(e),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," _hasFetcherDoneAnything ":!0}}(l,u);j.fetchers.set(e,f),te({fetchers:new Map(j.fetchers)});let v=new AbortController,g=oe(r.history,n,v.signal,l);I.set(e,v);let b=q,w=await re("action",g,i,s,h,c,y);if(g.signal.aborted)return void(I.get(e)===v&&I.delete(e));if(ye(w)){if(I.delete(e),z>b){let t=je(void 0);return j.fetchers.set(e,t),void te({fetchers:new Map(j.fetchers)})}{H.add(e);let t=Le(l);return j.fetchers.set(e,t),te({fetchers:new Map(j.fetchers)}),fe(j,w,{submission:l,isFetchActionRedirect:!0})}}if(me(w))return void be(e,o,w.error);if(pe(w))throw ue(400,{type:"defer-action"});let D=j.navigation.location||j.location,R=oe(r.history,D,v.signal),E=d||m,A="idle"!==j.navigation.state?p(E,j.navigation.location,y):j.matches;a(A,"Didn't find any matches after fetcher action");let x=++q;F.set(e,x);let S=Le(l,w.data);j.fetchers.set(e,S);let[P,L]=Q(r.history,j,A,l,D,T,O,_,J,H,E,y,{[i.route.id]:w.data},void 0);L.filter((t=>t.key!==e)).forEach((e=>{let t=e.key,r=j.fetchers.get(t),o=Le(void 0,r?r.data:void 0);j.fetchers.set(t,o),I.has(t)&&Ae(t),e.controller&&I.set(t,e.controller)})),te({fetchers:new Map(j.fetchers)});let C=()=>L.forEach((e=>Ae(e.key)));v.signal.addEventListener("abort",C);let{results:U,loaderResults:B,fetcherResults:N}=await ve(j.matches,A,P,L,R);if(v.signal.aborted)return;v.signal.removeEventListener("abort",C),F.delete(e),I.delete(e),L.forEach((e=>I.delete(e.key)));let $=he(U);if($){if($.idx>=P.length){let e=L[$.idx-P.length].key;H.add(e)}return fe(j,$.result)}let{loaderData:W,errors:K}=se(j,j.matches,P,B,void 0,L,N,X);if(j.fetchers.has(e)){let t=je(w.data);j.fetchers.set(e,t)}let Y=Ue(x);"loading"===j.navigation.state&&x>z?(a(k,"Expected pending action"),M&&M.abort(),ae(j.navigation.location,{matches:A,loaderData:W,errors:K,fetchers:new Map(j.fetchers)})):(te(t({errors:K,loaderData:le(j.loaderData,W,A,K)},Y||L.length>0?{fetchers:new Map(j.fetchers)}:{})),T=!1)}(e,o,g,D,f,b):(J.set(e,{routeId:o,path:g}),async function(e,t,o,n,i,s){let l=j.fetchers.get(e),d=Le(s,l?l.data:void 0);j.fetchers.set(e,d),te({fetchers:new Map(j.fetchers)});let u=new AbortController,f=oe(r.history,o,u.signal);I.set(e,u);let p=q,m=await re("loader",f,n,i,h,c,y);pe(m)&&(m=await Ee(m,f.signal,!0)||m);I.get(e)===u&&I.delete(e);if(f.signal.aborted)return;if(ye(m)){if(z>p){let t=je(void 0);return j.fetchers.set(e,t),void te({fetchers:new Map(j.fetchers)})}return H.add(e),void await fe(j,m)}if(me(m)){let r=ce(j.matches,t);return j.fetchers.delete(e),void te({fetchers:new Map(j.fetchers),errors:{[r.route.id]:m.error}})}a(!pe(m),"Unhandled fetcher deferred data");let v=je(m.data);j.fetchers.set(e,v),te({fetchers:new Map(j.fetchers)})}(e,o,g,D,f,b))},revalidate:function(){ge(),te({revalidation:"loading"}),"submitting"!==j.navigation.state&&("idle"!==j.navigation.state?ne(k||j.historyAction,j.navigation.location,{overrideNavigation:j.navigation}):ne(j.historyAction,j.location,{startUninterruptedRevalidation:!0}))},createHref:e=>r.history.createHref(e),encodeLocation:e=>r.history.encodeLocation(e),getFetcher:ie,deleteFetcher:we,dispose:function(){g&&g(),b.clear(),M&&M.abort(),j.fetchers.forEach(((e,t)=>we(t))),j.blockers.forEach(((e,t)=>Te(t)))},getBlocker:function(e,t){let r=j.blockers.get(e)||W;return Z.get(e)!==t&&Z.set(e,t),r},deleteBlocker:Te,_internalFetchControllers:I,_internalActiveDeferreds:X,_internalSetRoutes:function(e){h={},d=f(e,c,void 0,h)}},P},e.createStaticHandler=function(e,r){a(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let o,n={},i=(r?r.basename:null)||"/";if(null!=r&&r.mapRouteProperties)o=r.mapRouteProperties;else if(null!=r&&r.detectErrorBoundary){let e=r.detectErrorBoundary;o=t=>({hasErrorBoundary:e(t)})}else o=Y;let c=f(e,o,void 0,n);async function d(e,r,s,l,c){a(e.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(De(e.method.toLowerCase())){let a=await async function(e,r,a,s,l){let c;if(a.route.action||a.route.lazy){if(c=await re("action",e,a,r,n,o,i,{isStaticRequest:!0,isRouteRequest:l,requestContext:s}),e.signal.aborted){throw new Error((l?"queryRoute":"query")+"() call aborted")}}else{let t=ue(405,{method:e.method,pathname:new URL(e.url).pathname,routeId:a.route.id});if(l)throw t;c={type:u.error,error:t}}if(ye(c))throw new Response(null,{status:c.status,headers:{Location:c.location}});if(pe(c)){let e=ue(400,{type:"defer-action"});if(l)throw e;c={type:u.error,error:e}}if(l){if(me(c))throw c.error;return{matches:[a],loaderData:{},actionData:{[a.route.id]:c.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}if(me(c)){let o=ce(r,a.route.id);return t({},await h(e,r,s,void 0,{[o.route.id]:c.error}),{statusCode:_(c.error)?c.error.status:500,actionData:null,actionHeaders:t({},c.headers?{[a.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:{[a.route.id]:c.data},actionHeaders:t({},c.headers?{[a.route.id]:c.headers}:{})})}(e,s,c||xe(s,r),l,null!=c);return a}let a=await h(e,s,l,c);return ge(a)?a:t({},a,{actionData:null,actionHeaders:{}})}catch(e){if((d=e)&&ge(d.response)&&(d.type===u.data||u.error)){if(e.type===u.error&&!be(e.response))throw e.response;return e.response}if(be(e))return e;throw e}var d}async function h(e,r,a,s,l){let c=null!=s;if(c&&(null==s||!s.route.loader)&&(null==s||!s.route.lazy))throw ue(400,{method:e.method,pathname:new URL(e.url).pathname,routeId:null==s?void 0:s.route.id});let d=(s?[s]:X(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=>re("loader",e,t,r,n,o,i,{isStaticRequest:!0,isRouteRequest:c,requestContext:a})))]);if(e.signal.aborted){throw new Error((c?"queryRoute":"query")+"() call aborted")}let h=new Map,f=ie(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:o}=void 0===r?{}:r,a=new URL(e.url),n=e.method,u=s("",l(a),null,"default"),h=p(c,u,i);if(!we(n)&&"HEAD"!==n){let e=ue(405,{method:n}),{matches:t,route:r}=de(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=ue(404,{pathname:u.pathname}),{matches:t,route:r}=de(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,o);return ge(f)?f:t({location:u,basename:i},f)},queryRoute:async function(e,t){let{routeId:r,requestContext:o}=void 0===t?{}:t,a=new URL(e.url),n=e.method,u=s("",l(a),null,"default"),h=p(c,u,i);if(!we(n)&&"HEAD"!==n&&"OPTIONS"!==n)throw ue(405,{method:n});if(!h)throw ue(404,{pathname:u.pathname});let f=r?h.find((e=>e.route.id===r)):xe(h,u);if(r&&!f)throw ue(403,{pathname:u.pathname,routeId:r});if(!f)throw ue(404,{pathname:u.pathname});let m=await d(e,u,h,o,f);if(ge(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[J]=m.activeDeferreds[f.route.id]),e}}}},e.defer=function(e,t){return void 0===t&&(t={}),new U(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 o=r.startsWith("/")?"/":"",i=e=>null==e?"":"string"==typeof e?e:String(e);return o+r.split(/\/+/).map(((e,r,o)=>{if(r===o.length-1&&"*"===e){return i(t["*"])}const n=e.match(/^:(\w+)(\??)$/);if(n){const[,e,r]=n;let o=t[e];return a("?"===r||null!=o,'Missing ":'+e+'" param'),i(o)}return e.replace(/\?$/g,"")})).filter((e=>!!e)).join("/")},e.getStaticContextFromError=function(e,r,o){return t({},r,{statusCode:500,errors:{[r._deepestRenderedBoundaryId||e[0].id]:o}})},e.getToPathname=function(e){return""===e||""===e.pathname?"/":"string"==typeof e?c(e).pathname:e.pathname},e.isDeferredData=ve,e.isRouteErrorResponse=_,e.joinPaths=M,e.json=function(e,r){void 0===r&&(r={});let o="number"==typeof r?{status:r}:r,a=new Headers(o.headers);return a.has("Content-Type")||a.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify(e),t({},o,{headers:a}))},e.matchPath=D,e.matchRoutes=p,e.normalizePathname=L,e.parsePath=c,e.redirect=function(e,r){void 0===r&&(r=302);let o=r;"number"==typeof o?o={status:o}:void 0===o.status&&(o.status=302);let a=new Headers(o.headers);return a.set("Location",e),new Response(null,t({},o,{headers:a}))},e.resolvePath=A,e.resolveTo=P,e.stripBasename=E,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=router.umd.min.js.map