/** * @remix-run/router v1.22.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(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t{c.removeEventListener(a,g),m=null}},createHref:e=>n(c,e),createURL:D,encodeLocation(e){let t=D(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:b,replace:w,go:e=>f.go(e)};return S}((function(e,t){let{pathname:r,search:a,hash:n}=e.location;return l("",{pathname:r,search:a,hash:n},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){return"string"==typeof t?t:d(t)}),0,r)}function o(e,t){if(!1===e||null==e)throw new Error(t)}function i(e,t){if(!e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(r){}}}function s(e,t){return{usr:e.state,key:e.key,idx:t}}function l(t,r,a,n){return void 0===a&&(a=null),e({pathname:"string"==typeof t?t:t.pathname,search:"",hash:""},"string"==typeof r?u(r):r,{state:a,key:r&&r.key||n||Math.random().toString(36).substr(2,8)})}function d(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 u(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}var c,h;(h=c||(c={})).data="data",h.deferred="deferred",h.redirect="redirect",h.error="error";const f=new Set(["lazy","caseSensitive","path","id","index","children"]);function p(t,r,a,n){return void 0===a&&(a=[]),void 0===n&&(n={}),t.map(((t,i)=>{let s=[...a,String(i)],l="string"==typeof t.id?t.id:s.join("-");if(o(!0!==t.index||!t.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}(t)){let a=e({},t,r(t),{id:l});return n[l]=a,a}{let a=e({},t,r(t),{id:l,children:void 0});return n[l]=a,t.children&&(a.children=p(t.children,r,s,n)),a}}))}function m(e,t,r){return void 0===r&&(r="/"),y(e,t,r,!1)}function y(e,t,r,a){let n=j(("string"==typeof t?u(t):t).pathname||"/",r);if(null==n)return null;let o=g(e);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){let r=e.length===t.length&&e.slice(0,-1).every(((e,r)=>e===t[r]));return r?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(o);let i=null;for(let s=0;null==i&&s{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=_([a,s.relativePath]),d=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+'".'),g(e.children,t,d,l)),(null!=e.path||e.index)&&t.push({path:l,score:L(l,e.index),routesMeta:d})};return e.forEach(((e,t)=>{var r;if(""!==e.path&&null!=(r=e.path)&&r.includes("?"))for(let a of b(e.path))n(e,t,a);else n(e,t)})),t}function b(e){let t=e.split("/");if(0===t.length)return[];let[r,...a]=t,n=r.endsWith("?"),o=r.replace(/\?$/,"");if(0===a.length)return n?[o,""]:[o];let i=b(a.join("/")),s=[];return s.push(...i.map((e=>""===e?o:[o,e].join("/")))),n&&s.push(...i),s.map((t=>e.startsWith("/")&&""===t?"/":t))}const w=/^:[\w-]+$/,D=3,S=2,R=1,E=10,x=-2,P=e=>"*"===e;function L(e,t){let r=e.split("/"),a=r.length;return r.some(P)&&(a+=x),t&&(a+=S),r.filter((e=>!P(e))).reduce(((e,t)=>e+(w.test(t)?D:""===t?R:E)),a)}function M(e,t,r){void 0===r&&(r=!1);let{routesMeta:a}=e,n={},o="/",i=[];for(let s=0;s(a.push({paramName:t,isOptional:null!=r}),r?"/?([^\\/]+)?":"/([^\\/]+)")));e.endsWith("*")?(a.push({paramName:"*"}),n+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?n+="\\/*$":""!==e&&"/"!==e&&(n+="(?:(?=\\/|$))");let o=new RegExp(n,t?void 0:"i");return[o,a]}(e.path,e.caseSensitive,e.end),n=t.match(r);if(!n)return null;let o=n[0],s=o.replace(/(.)\/+$/,"$1"),l=n.slice(1);return{params:a.reduce(((e,t,r)=>{let{paramName:a,isOptional:n}=t;if("*"===a){let e=l[r]||"";s=o.slice(0,o.length-e.length).replace(/(.)\/+$/,"$1")}const i=l[r];return e[a]=n&&!i?void 0:(i||"").replace(/%2F/g,"/"),e}),{}),pathname:o,pathnameBase:s,pattern:e}}function A(e){try{return e.split("/").map((e=>decodeURIComponent(e).replace(/\//g,"%2F"))).join("/")}catch(t){return i(!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 j(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 C(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 and the router will parse it for you.'}function T(e){return e.filter(((e,t)=>0===t||e.route.path&&e.route.path.length>0))}function O(e,t){let r=T(e);return t?r.map(((e,t)=>t===r.length-1?e.pathname:e.pathnameBase)):r.map((e=>e.pathnameBase))}function U(t,r,a,n){let i;void 0===n&&(n=!1),"string"==typeof t?i=u(t):(i=e({},t),o(!i.pathname||!i.pathname.includes("?"),C("?","pathname","search",i)),o(!i.pathname||!i.pathname.includes("#"),C("#","pathname","hash",i)),o(!i.search||!i.search.includes("#"),C("#","search","hash",i)));let s,l=""===t||""===i.pathname,d=l?"/":i.pathname;if(null==d)s=a;else{let e=r.length-1;if(!n&&d.startsWith("..")){let t=d.split("/");for(;".."===t[0];)t.shift(),e-=1;i.pathname=t.join("/")}s=e>=0?r[e]:"/"}let c=function(e,t){void 0===t&&(t="/");let{pathname:r,search:a="",hash:n=""}="string"==typeof e?u(e):e,o=r?r.startsWith("/")?r:function(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach((e=>{".."===e?r.length>1&&r.pop():"."!==e&&r.push(e)})),r.length>1?r.join("/"):"/"}(r,t):t;return{pathname:o,search:I(a),hash:z(n)}}(i,s),h=d&&"/"!==d&&d.endsWith("/"),f=(l||"."===d)&&a.endsWith("/");return c.pathname.endsWith("/")||!h&&!f||(c.pathname+="/"),c}const _=e=>e.join("/").replace(/\/\/+/g,"/"),H=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),I=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",z=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"",B=function(t,r){void 0===r&&(r={});let a="number"==typeof r?{status:r}:r,n=new Headers(a.headers);return n.has("Content-Type")||n.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify(t),e({},a,{headers:n}))};class F{constructor(e,t){this.type="DataWithResponseInit",this.data=e,this.init=t||null}}function q(e,t){return new F(e,"number"==typeof t?{status:t}:t)}class N extends Error{}class W{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 N("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 N)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]:$(a)})}),{})}get pendingKeys(){return Array.from(this.pendingKeysSet)}}function $(e){if(!function(e){return e instanceof Promise&&!0===e._tracked}(e))return e;if(e._error)throw e._error;return e._data}const K=function(e,t){return void 0===t&&(t={}),new W(e,"number"==typeof t?{status:t}:t)},Y=function(t,r){void 0===r&&(r=302);let a=r;"number"==typeof a?a={status:a}:void 0===a.status&&(a.status=302);let n=new Headers(a.headers);return n.set("Location",t),new Response(null,e({},a,{headers:n}))},J=(e,t)=>{let r=Y(e,t);return r.headers.set("X-Remix-Reload-Document","true"),r},V=(e,t)=>{let r=Y(e,t);return r.headers.set("X-Remix-Replace","true"),r};class X{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 G(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"boolean"==typeof e.internal&&"data"in e}const Q=["post","put","patch","delete"],Z=new Set(Q),ee=["get",...Q],te=new Set(ee),re=new Set([301,302,303,307,308]),ae=new Set([307,308]),ne={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},oe={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},ie={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},se=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,le=e=>({hasErrorBoundary:Boolean(e.hasErrorBoundary)}),de="remix-router-transitions";function ue(r){const a=r.window?r.window:"undefined"!=typeof window?window:void 0,n=void 0!==a&&void 0!==a.document&&void 0!==a.document.createElement,s=!n;let d;if(o(r.routes.length>0,"You must provide a non-empty routes array to createRouter"),r.mapRouteProperties)d=r.mapRouteProperties;else if(r.detectErrorBoundary){let e=r.detectErrorBoundary;d=t=>({hasErrorBoundary:e(t)})}else d=le;let u,h,f,g={},b=p(r.routes,d,void 0,g),w=r.basename||"/",D=r.dataStrategy||Ee,S=r.patchRoutesOnNavigation,R=e({v7_fetcherPersist:!1,v7_normalizeFormMethod:!1,v7_partialHydration:!1,v7_prependBasename:!1,v7_relativeSplatPath:!1,v7_skipActionErrorRevalidation:!1},r.future),E=null,x=new Set,P=null,L=null,M=null,k=null!=r.hydrationData,A=m(b,r.history.location,w),C=!1,T=null;if(null==A&&!S){let e=Ie(404,{pathname:r.history.location.pathname}),{matches:t,route:a}=He(b);A=t,T={[a.id]:e}}if(A&&!r.hydrationData){ut(A,b,r.history.location.pathname).active&&(A=null)}if(A)if(A.some((e=>e.route.lazy)))h=!1;else if(A.some((e=>e.route.loader)))if(R.v7_partialHydration){let e=r.hydrationData?r.hydrationData.loaderData:null,t=r.hydrationData?r.hydrationData.errors:null;if(t){let r=A.findIndex((e=>void 0!==t[e.route.id]));h=A.slice(0,r+1).every((r=>!be(r.route,e,t)))}else h=A.every((r=>!be(r.route,e,t)))}else h=null!=r.hydrationData;else h=!0;else if(h=!1,A=[],R.v7_partialHydration){let e=ut(null,b,r.history.location.pathname);e.active&&e.matches&&(C=!0,A=e.matches)}let O,U,_={historyAction:r.history.action,location:r.history.location,matches:A,initialized:h,navigation:ne,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||T,fetchers:new Map,blockers:new Map},H=t.Pop,I=!1,z=!1,B=new Map,F=null,q=!1,N=!1,W=[],$=new Set,K=new Map,Y=0,J=-1,V=new Map,X=new Set,Q=new Map,Z=new Map,ee=new Set,te=new Map,re=new Map;function ue(t,r){void 0===r&&(r={}),_=e({},_,t);let a=[],n=[];R.v7_fetcherPersist&&_.fetchers.forEach(((e,t)=>{"idle"===e.state&&(ee.has(t)?n.push(t):a.push(t))})),ee.forEach((e=>{_.fetchers.has(e)||K.has(e)||n.push(e)})),[...x].forEach((e=>e(_,{deletedFetchers:n,viewTransitionOpts:r.viewTransitionOpts,flushSync:!0===r.flushSync}))),R.v7_fetcherPersist?(a.forEach((e=>_.fetchers.delete(e))),n.forEach((e=>Ce(e)))):n.forEach((e=>ee.delete(e)))}function ce(a,n,o){var i,s;let l,{flushSync:d}=void 0===o?{}:o,c=null!=_.actionData&&null!=_.navigation.formMethod&&Je(_.navigation.formMethod)&&"loading"===_.navigation.state&&!0!==(null==(i=a.state)?void 0:i._isRedirect);l=n.actionData?Object.keys(n.actionData).length>0?n.actionData:null:c?_.actionData:null;let h=n.loaderData?Oe(_.loaderData,n.loaderData,n.matches||[],n.errors):_.loaderData,f=_.blockers;f.size>0&&(f=new Map(f),f.forEach(((e,t)=>f.set(t,ie))));let p,m=!0===I||null!=_.navigation.formMethod&&Je(_.navigation.formMethod)&&!0!==(null==(s=a.state)?void 0:s._isRedirect);if(u&&(b=u,u=void 0),q||H===t.Pop||(H===t.Push?r.history.push(a,a.state):H===t.Replace&&r.history.replace(a,a.state)),H===t.Pop){let e=B.get(_.location.pathname);e&&e.has(a.pathname)?p={currentLocation:_.location,nextLocation:a}:B.has(a.pathname)&&(p={currentLocation:a,nextLocation:_.location})}else if(z){let e=B.get(_.location.pathname);e?e.add(a.pathname):(e=new Set([a.pathname]),B.set(_.location.pathname,e)),p={currentLocation:_.location,nextLocation:a}}ue(e({},n,{actionData:l,loaderData:h,historyAction:H,location:a,initialized:!0,navigation:ne,revalidation:"idle",restoreScrollPosition:dt(a,n.matches||_.matches),preventScrollReset:m,blockers:f}),{viewTransitionOpts:p,flushSync:!0===d}),H=t.Pop,I=!1,z=!1,q=!1,N=!1,W=[]}async function he(a,n,o){O&&O.abort(),O=null,H=a,q=!0===(o&&o.startUninterruptedRevalidation),function(e,t){if(P&&M){let r=lt(e,t);P[r]=M()}}(_.location,_.matches),I=!0===(o&&o.preventScrollReset),z=!0===(o&&o.enableViewTransition);let i=u||b,s=o&&o.overrideNavigation,l=null!=o&&o.initialHydration&&_.matches&&_.matches.length>0&&!C?_.matches:m(i,n,w),d=!0===(o&&o.flushSync),h=ut(l,i,n.pathname);if(h.active&&h.matches&&(l=h.matches),!l){let{error:e,notFoundMatches:t,route:r}=it(n.pathname);return void ce(n,{matches:t,loaderData:{},errors:{[r.id]:e}},{flushSync:d})}if(_.initialized&&!N&&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}(_.location,n)&&!(o&&o.submission&&Je(o.submission.formMethod)))return void ce(n,{matches:l},{flushSync:d});O=new AbortController;let f,p=ke(r.history,n,O.signal,o&&o.submission);if(o&&o.pendingError)f=[_e(l).route.id,{type:c.error,error:o.pendingError}];else if(o&&o.submission&&Je(o.submission.formMethod)){let e=await async function(e,r,a,n,o,i){void 0===i&&(i={});De();let s,l=function(e,t){let r={state:"submitting",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text};return r}(r,a);if(ue({navigation:l},{flushSync:!0===i.flushSync}),o){let t=await ct(n,r.pathname,e.signal);if("aborted"===t.type)return{shortCircuited:!0};if("error"===t.type){let e=_e(t.partialMatches).route.id;return{matches:t.partialMatches,pendingActionResult:[e,{type:c.error,error:t.error}]}}if(!t.matches){let{notFoundMatches:e,error:t,route:a}=it(r.pathname);return{matches:e,pendingActionResult:[a.id,{type:c.error,error:t}]}}n=t.matches}let d=Ze(n,r);if(d.route.action||d.route.lazy){if(s=(await ve("action",_,e,[d],n,null))[d.route.id],e.signal.aborted)return{shortCircuited:!0}}else s={type:c.error,error:Ie(405,{method:e.method,pathname:r.pathname,routeId:d.route.id})};if(We(s)){let t;if(i&&null!=i.replace)t=i.replace;else{t=Me(s.response.headers.get("Location"),new URL(e.url),w)===_.location.pathname+_.location.search}return await pe(e,s,!0,{submission:a,replace:t}),{shortCircuited:!0}}if(qe(s))throw Ie(400,{type:"defer-action"});if(Ne(s)){let e=_e(n,d.route.id);return!0!==(i&&i.replace)&&(H=t.Push),{matches:n,pendingActionResult:[e.route.id,s]}}return{matches:n,pendingActionResult:[d.route.id,s]}}(p,n,o.submission,l,h.active,{replace:o.replace,flushSync:d});if(e.shortCircuited)return;if(e.pendingActionResult){let[t,r]=e.pendingActionResult;if(Ne(r)&&G(r.error)&&404===r.error.status)return O=null,void ce(n,{matches:e.matches,loaderData:{},errors:{[t]:r.error}})}l=e.matches||l,f=e.pendingActionResult,s=tt(n,o.submission),d=!1,h.active=!1,p=ke(r.history,p.url,p.signal)}let{shortCircuited:y,matches:v,loaderData:g,errors:D}=await async function(t,a,n,o,i,s,l,d,c,h,f){let p=i||tt(a,s),m=s||l||et(p),y=!(q||R.v7_partialHydration&&c);if(o){if(y){let t=fe(f);ue(e({navigation:p},void 0!==t?{actionData:t}:{}),{flushSync:h})}let r=await ct(n,a.pathname,t.signal);if("aborted"===r.type)return{shortCircuited:!0};if("error"===r.type){let e=_e(r.partialMatches).route.id;return{matches:r.partialMatches,loaderData:{},errors:{[e]:r.error}}}if(!r.matches){let{error:e,notFoundMatches:t,route:r}=it(a.pathname);return{matches:t,loaderData:{},errors:{[r.id]:e}}}n=r.matches}let v=u||b,[g,D]=ge(r.history,_,n,m,a,R.v7_partialHydration&&!0===c,R.v7_skipActionErrorRevalidation,N,W,$,ee,Q,X,v,w,f);if(st((e=>!(n&&n.some((t=>t.route.id===e)))||g&&g.some((t=>t.route.id===e)))),J=++Y,0===g.length&&0===D.length){let t=Ke();return ce(a,e({matches:n,loaderData:{},errors:f&&Ne(f[1])?{[f[0]]:f[1].error}:null},Ue(f),t?{fetchers:new Map(_.fetchers)}:{}),{flushSync:h}),{shortCircuited:!0}}if(y){let e={};if(!o){e.navigation=p;let t=fe(f);void 0!==t&&(e.actionData=t)}D.length>0&&(e.fetchers=function(e){return e.forEach((e=>{let t=_.fetchers.get(e.key),r=rt(void 0,t?t.data:void 0);_.fetchers.set(e.key,r)})),new Map(_.fetchers)}(D)),ue(e,{flushSync:h})}D.forEach((e=>{Be(e.key),e.controller&&K.set(e.key,e.controller)}));let S=()=>D.forEach((e=>Be(e.key)));O&&O.signal.addEventListener("abort",S);let{loaderResults:E,fetcherResults:x}=await we(_,n,g,D,t);if(t.signal.aborted)return{shortCircuited:!0};O&&O.signal.removeEventListener("abort",S);D.forEach((e=>K.delete(e.key)));let P=ze(E);if(P)return await pe(t,P.result,!0,{replace:d}),{shortCircuited:!0};if(P=ze(x),P)return X.add(P.key),await pe(t,P.result,!0,{replace:d}),{shortCircuited:!0};let{loaderData:L,errors:M}=Te(_,n,E,f,D,x,te);te.forEach(((e,t)=>{e.subscribe((r=>{(r||e.done)&&te.delete(t)}))})),R.v7_partialHydration&&c&&_.errors&&(M=e({},_.errors,M));let k=Ke(),A=Ye(J),j=k||A||D.length>0;return e({matches:n,loaderData:L,errors:M},j?{fetchers:new Map(_.fetchers)}:{})}(p,n,l,h.active,s,o&&o.submission,o&&o.fetcherSubmission,o&&o.replace,o&&!0===o.initialHydration,d,f);y||(O=null,ce(n,e({matches:v||l},Ue(f),{loaderData:g,errors:D})))}function fe(e){return e&&!Ne(e[1])?{[e[0]]:e[1].data}:_.actionData?0===Object.keys(_.actionData).length?null:_.actionData:void 0}async function pe(i,s,d,u){let{submission:c,fetcherSubmission:h,preventScrollReset:f,replace:p}=void 0===u?{}:u;s.response.headers.has("X-Remix-Revalidate")&&(N=!0);let m=s.response.headers.get("Location");o(m,"Expected a Location header on the redirect Response"),m=Me(m,new URL(i.url),w);let y=l(_.location,m,{_isRedirect:!0});if(n){let e=!1;if(s.response.headers.has("X-Remix-Reload-Document"))e=!0;else if(se.test(m)){const t=r.history.createURL(m);e=t.origin!==a.location.origin||null==j(t.pathname,w)}if(e)return void(p?a.location.replace(m):a.location.assign(m))}O=null;let v=!0===p||s.response.headers.has("X-Remix-Replace")?t.Replace:t.Push,{formMethod:g,formAction:b,formEncType:D}=_.navigation;!c&&!h&&g&&b&&D&&(c=et(_.navigation));let S=c||h;if(ae.has(s.response.status)&&S&&Je(S.formMethod))await he(v,y,{submission:e({},S,{formAction:m}),preventScrollReset:f||I,enableViewTransition:d?z:void 0});else{let e=tt(y,c);await he(v,y,{overrideNavigation:e,fetcherSubmission:h,preventScrollReset:f||I,enableViewTransition:d?z:void 0})}}async function ve(e,t,r,a,n,o){let i,s={};try{i=await xe(D,e,t,r,a,n,o,g,d)}catch(l){return a.forEach((e=>{s[e.route.id]={type:c.error,error:l}})),s}for(let[d,u]of Object.entries(i))if(Fe(u)){let e=u.result;s[d]={type:c.redirect,response:Le(e,r,d,n,w,R.v7_relativeSplatPath)}}else s[d]=await Pe(u);return s}async function we(e,t,a,n,o){let i=e.matches,s=ve("loader",e,o,a,t,null),l=Promise.all(n.map((async t=>{if(t.matches&&t.match&&t.controller){let a=(await ve("loader",e,ke(r.history,t.path,t.controller.signal),[t.match],t.matches,t.key))[t.match.route.id];return{[t.key]:a}}return Promise.resolve({[t.key]:{type:c.error,error:Ie(404,{pathname:t.path})}})}))),d=await s,u=(await l).reduce(((e,t)=>Object.assign(e,t)),{});return await Promise.all([Ve(t,d,o.signal,i,e.loaderData),Xe(t,u,n)]),{loaderResults:d,fetcherResults:u}}function De(){N=!0,W.push(...st()),Q.forEach(((e,t)=>{K.has(t)&&$.add(t),Be(t)}))}function Re(e,t,r){void 0===r&&(r={}),_.fetchers.set(e,t),ue({fetchers:new Map(_.fetchers)},{flushSync:!0===(r&&r.flushSync)})}function Ae(e,t,r,a){void 0===a&&(a={});let n=_e(_.matches,t);Ce(e),ue({errors:{[n.route.id]:r},fetchers:new Map(_.fetchers)},{flushSync:!0===(a&&a.flushSync)})}function je(e){return Z.set(e,(Z.get(e)||0)+1),ee.has(e)&&ee.delete(e),_.fetchers.get(e)||oe}function Ce(e){let t=_.fetchers.get(e);!K.has(e)||t&&"loading"===t.state&&V.has(e)||Be(e),Q.delete(e),V.delete(e),X.delete(e),R.v7_fetcherPersist&&ee.delete(e),$.delete(e),_.fetchers.delete(e)}function Be(e){let t=K.get(e);t&&(t.abort(),K.delete(e))}function $e(e){for(let t of e){let e=at(je(t).data);_.fetchers.set(t,e)}}function Ke(){let e=[],t=!1;for(let r of X){let a=_.fetchers.get(r);o(a,"Expected fetcher: "+r),"loading"===a.state&&(X.delete(r),e.push(r),t=!0)}return $e(e),t}function Ye(e){let t=[];for(let[r,a]of V)if(a0}function Qe(e){_.blockers.delete(e),re.delete(e)}function nt(e,t){let r=_.blockers.get(e)||ie;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(_.blockers);a.set(e,t),ue({blockers:a})}function ot(e){let{currentLocation:t,nextLocation:r,historyAction:a}=e;if(0===re.size)return;re.size>1&&i(!1,"A router only supports one blocker at a time");let n=Array.from(re.entries()),[o,s]=n[n.length-1],l=_.blockers.get(o);return l&&"proceeding"===l.state?void 0:s({currentLocation:t,nextLocation:r,historyAction:a})?o:void 0}function it(e){let t=Ie(404,{pathname:e}),r=u||b,{matches:a,route:n}=He(r);return st(),{notFoundMatches:a,route:n,error:t}}function st(e){let t=[];return te.forEach(((r,a)=>{e&&!e(a)||(r.cancel(),t.push(a),te.delete(a))})),t}function lt(e,t){if(L){return L(e,t.map((e=>v(e,_.loaderData))))||e.key}return e.key}function dt(e,t){if(P){let r=lt(e,t),a=P[r];if("number"==typeof a)return a}return null}function ut(e,t,r){if(S){if(!e){return{active:!0,matches:y(t,r,w,!0)||[]}}if(Object.keys(e[0].params).length>0){return{active:!0,matches:y(t,r,w,!0)}}}return{active:!1,matches:null}}async function ct(e,t,r){if(!S)return{type:"success",matches:e};let a=e;for(;;){let e=null==u,o=u||b,i=g;try{await S({signal:r,path:t,matches:a,patch:(e,t)=>{r.aborted||Se(e,t,o,i,d)}})}catch(n){return{type:"error",error:n,partialMatches:a}}finally{e&&!r.aborted&&(b=[...b])}if(r.aborted)return{type:"aborted"};let s=m(o,t,w);if(s)return{type:"success",matches:s};let l=y(o,t,w,!0);if(!l||a.length===l.length&&a.every(((e,t)=>e.route.id===l[t].route.id)))return{type:"success",matches:null};a=l}}return f={get basename(){return w},get future(){return R},get state(){return _},get routes(){return b},get window(){return a},initialize:function(){if(E=r.history.listen((e=>{let{action:t,location:a,delta:n}=e;if(U)return U(),void(U=void 0);i(0===re.size||null!=n,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let o=ot({currentLocation:_.location,nextLocation:a,historyAction:t});if(o&&null!=n){let e=new Promise((e=>{U=e}));return r.history.go(-1*n),void nt(o,{state:"blocked",location:a,proceed(){nt(o,{state:"proceeding",proceed:void 0,reset:void 0,location:a}),e.then((()=>r.history.go(n)))},reset(){let e=new Map(_.blockers);e.set(o,ie),ue({blockers:e})}})}return he(t,a)})),n){!function(e,t){try{let r=e.sessionStorage.getItem(de);if(r){let e=JSON.parse(r);for(let[r,a]of Object.entries(e||{}))a&&Array.isArray(a)&&t.set(r,new Set(a||[]))}}catch(r){}}(a,B);let e=()=>function(e,t){if(t.size>0){let a={};for(let[e,r]of t)a[e]=[...r];try{e.sessionStorage.setItem(de,JSON.stringify(a))}catch(r){i(!1,"Failed to save applied view transitions in sessionStorage ("+r+").")}}}(a,B);a.addEventListener("pagehide",e),F=()=>a.removeEventListener("pagehide",e)}return _.initialized||he(t.Pop,_.location,{initialHydration:!0}),f},subscribe:function(e){return x.add(e),()=>x.delete(e)},enableScrollRestoration:function(e,t,r){if(P=e,M=t,L=r||null,!k&&_.navigation===ne){k=!0;let e=dt(_.location,_.matches);null!=e&&ue({restoreScrollPosition:e})}return()=>{P=null,M=null,L=null}},navigate:async function a(n,o){if("number"==typeof n)return void r.history.go(n);let i=me(_.location,_.matches,w,R.v7_prependBasename,n,R.v7_relativeSplatPath,null==o?void 0:o.fromRouteId,null==o?void 0:o.relative),{path:s,submission:d,error:u}=ye(R.v7_normalizeFormMethod,!1,i,o),c=_.location,h=l(_.location,s,o&&o.state);h=e({},h,r.history.encodeLocation(h));let f=o&&null!=o.replace?o.replace:void 0,p=t.Push;!0===f?p=t.Replace:!1===f||null!=d&&Je(d.formMethod)&&d.formAction===_.location.pathname+_.location.search&&(p=t.Replace);let m=o&&"preventScrollReset"in o?!0===o.preventScrollReset:void 0,y=!0===(o&&o.flushSync),v=ot({currentLocation:c,nextLocation:h,historyAction:p});if(!v)return await he(p,h,{submission:d,pendingError:u,preventScrollReset:m,replace:o&&o.replace,enableViewTransition:o&&o.viewTransition,flushSync:y});nt(v,{state:"blocked",location:h,proceed(){nt(v,{state:"proceeding",proceed:void 0,reset:void 0,location:h}),a(n,o)},reset(){let e=new Map(_.blockers);e.set(v,ie),ue({blockers:e})}})},fetch:function(e,t,a,n){if(s)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.");Be(e);let i=!0===(n&&n.flushSync),l=u||b,d=me(_.location,_.matches,w,R.v7_prependBasename,a,R.v7_relativeSplatPath,t,null==n?void 0:n.relative),c=m(l,d,w),h=ut(c,l,d);if(h.active&&h.matches&&(c=h.matches),!c)return void Ae(e,t,Ie(404,{pathname:d}),{flushSync:i});let{path:f,submission:p,error:y}=ye(R.v7_normalizeFormMethod,!0,d,n);if(y)return void Ae(e,t,y,{flushSync:i});let v=Ze(c,f),g=!0===(n&&n.preventScrollReset);p&&Je(p.formMethod)?async function(e,t,a,n,i,s,l,d,c){function h(r){if(!r.route.action&&!r.route.lazy){let r=Ie(405,{method:c.formMethod,pathname:a,routeId:t});return Ae(e,t,r,{flushSync:l}),!0}return!1}if(De(),Q.delete(e),!s&&h(n))return;let f=_.fetchers.get(e);Re(e,function(e,t){let r={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};return r}(c,f),{flushSync:l});let p=new AbortController,y=ke(r.history,a,p.signal,c);if(s){let r=await ct(i,new URL(y.url).pathname,y.signal);if("aborted"===r.type)return;if("error"===r.type)return void Ae(e,t,r.error,{flushSync:l});if(!r.matches)return void Ae(e,t,Ie(404,{pathname:a}),{flushSync:l});if(h(n=Ze(i=r.matches,a)))return}K.set(e,p);let v=Y,g=await ve("action",_,y,[n],i,e),D=g[n.route.id];if(y.signal.aborted)return void(K.get(e)===p&&K.delete(e));if(R.v7_fetcherPersist&&ee.has(e)){if(We(D)||Ne(D))return void Re(e,at(void 0))}else{if(We(D))return K.delete(e),J>v?void Re(e,at(void 0)):(X.add(e),Re(e,rt(c)),pe(y,D,!1,{fetcherSubmission:c,preventScrollReset:d}));if(Ne(D))return void Ae(e,t,D.error)}if(qe(D))throw Ie(400,{type:"defer-action"});let S=_.navigation.location||_.location,E=ke(r.history,S,p.signal),x=u||b,P="idle"!==_.navigation.state?m(x,_.navigation.location,w):_.matches;o(P,"Didn't find any matches after fetcher action");let L=++Y;V.set(e,L);let M=rt(c,D.data);_.fetchers.set(e,M);let[k,A]=ge(r.history,_,P,c,S,!1,R.v7_skipActionErrorRevalidation,N,W,$,ee,Q,X,x,w,[n.route.id,D]);A.filter((t=>t.key!==e)).forEach((e=>{let t=e.key,r=_.fetchers.get(t),a=rt(void 0,r?r.data:void 0);_.fetchers.set(t,a),Be(t),e.controller&&K.set(t,e.controller)})),ue({fetchers:new Map(_.fetchers)});let j=()=>A.forEach((e=>Be(e.key)));p.signal.addEventListener("abort",j);let{loaderResults:C,fetcherResults:T}=await we(_,P,k,A,E);if(p.signal.aborted)return;p.signal.removeEventListener("abort",j),V.delete(e),K.delete(e),A.forEach((e=>K.delete(e.key)));let U=ze(C);if(U)return pe(E,U.result,!1,{preventScrollReset:d});if(U=ze(T),U)return X.add(U.key),pe(E,U.result,!1,{preventScrollReset:d});let{loaderData:I,errors:z}=Te(_,P,C,void 0,A,T,te);if(_.fetchers.has(e)){let t=at(D.data);_.fetchers.set(e,t)}Ye(L),"loading"===_.navigation.state&&L>J?(o(H,"Expected pending action"),O&&O.abort(),ce(_.navigation.location,{matches:P,loaderData:I,errors:z,fetchers:new Map(_.fetchers)})):(ue({errors:z,loaderData:Oe(_.loaderData,I,P,z),fetchers:new Map(_.fetchers)}),N=!1)}(e,t,f,v,c,h.active,i,g,p):(Q.set(e,{routeId:t,path:f}),async function(e,t,a,n,i,s,l,d,u){let c=_.fetchers.get(e);Re(e,rt(u,c?c.data:void 0),{flushSync:l});let h=new AbortController,f=ke(r.history,a,h.signal);if(s){let r=await ct(i,new URL(f.url).pathname,f.signal);if("aborted"===r.type)return;if("error"===r.type)return void Ae(e,t,r.error,{flushSync:l});if(!r.matches)return void Ae(e,t,Ie(404,{pathname:a}),{flushSync:l});n=Ze(i=r.matches,a)}K.set(e,h);let p=Y,m=await ve("loader",_,f,[n],i,e),y=m[n.route.id];qe(y)&&(y=await Ge(y,f.signal,!0)||y);K.get(e)===h&&K.delete(e);if(f.signal.aborted)return;if(ee.has(e))return void Re(e,at(void 0));if(We(y))return J>p?void Re(e,at(void 0)):(X.add(e),void(await pe(f,y,!1,{preventScrollReset:d})));if(Ne(y))return void Ae(e,t,y.error);o(!qe(y),"Unhandled fetcher deferred data"),Re(e,at(y.data))}(e,t,f,v,c,h.active,i,g,p))},revalidate:function(){De(),ue({revalidation:"loading"}),"submitting"!==_.navigation.state&&("idle"!==_.navigation.state?he(H||_.historyAction,_.navigation.location,{overrideNavigation:_.navigation,enableViewTransition:!0===z}):he(_.historyAction,_.location,{startUninterruptedRevalidation:!0}))},createHref:e=>r.history.createHref(e),encodeLocation:e=>r.history.encodeLocation(e),getFetcher:je,deleteFetcher:function(e){let t=(Z.get(e)||0)-1;t<=0?(Z.delete(e),ee.add(e),R.v7_fetcherPersist||Ce(e)):Z.set(e,t),ue({fetchers:new Map(_.fetchers)})},dispose:function(){E&&E(),F&&F(),x.clear(),O&&O.abort(),_.fetchers.forEach(((e,t)=>Ce(t))),_.blockers.forEach(((e,t)=>Qe(t)))},getBlocker:function(e,t){let r=_.blockers.get(e)||ie;return re.get(e)!==t&&re.set(e,t),r},deleteBlocker:Qe,patchRoutes:function(e,t){let r=null==u;Se(e,t,u||b,g,d),r&&(b=[...b],ue({}))},_internalFetchControllers:K,_internalActiveDeferreds:te,_internalSetRoutes:function(e){g={},u=p(e,d,void 0,g)}},f}const ce=Symbol("deferred");function he(t,r){o(t.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=le;let s=e({v7_relativeSplatPath:!1,v7_throwAbortReason:!1},r?r.future:null),u=p(t,a,void 0,n);async function h(t,r,a,n,i,l,d){o(t.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(Je(t.method.toLowerCase())){let o=await async function(t,r,a,n,o,i,l){let d;if(a.route.action||a.route.lazy){d=(await y("action",t,[a],r,l,n,o))[a.route.id],t.signal.aborted&&pe(t,l,s)}else{let e=Ie(405,{method:t.method,pathname:new URL(t.url).pathname,routeId:a.route.id});if(l)throw e;d={type:c.error,error:e}}if(We(d))throw new Response(null,{status:d.response.status,headers:{Location:d.response.headers.get("Location")}});if(qe(d)){let e=Ie(400,{type:"defer-action"});if(l)throw e;d={type:c.error,error:e}}if(l){if(Ne(d))throw d.error;return{matches:[a],loaderData:{},actionData:{[a.route.id]:d.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}let u=new Request(t.url,{headers:t.headers,redirect:t.redirect,signal:t.signal});if(Ne(d)){let t=i?a:_e(r,a.route.id);return e({},await f(u,r,n,o,i,null,[t.route.id,d]),{statusCode:G(d.error)?d.error.status:null!=d.statusCode?d.statusCode:500,actionData:null,actionHeaders:e({},d.headers?{[a.route.id]:d.headers}:{})})}let h=await f(u,r,n,o,i,null);return e({},h,{actionData:{[a.route.id]:d.data}},d.statusCode?{statusCode:d.statusCode}:{},{actionHeaders:d.headers?{[a.route.id]:d.headers}:{}})}(t,a,d||Ze(a,r),n,i,l,null!=d);return o}let o=await f(t,a,n,i,l,d);return Ke(o)?o:e({},o,{actionData:null,actionHeaders:{}})}catch(h){if(null!=(u=h)&&"object"==typeof u&&"type"in u&&"result"in u&&(u.type===c.data||u.type===c.error)&&Ke(h.result)){if(h.type===c.error)throw h.result;return h.result}if(function(e){if(!Ke(e))return!1;let t=e.status,r=e.headers.get("Location");return t>=300&&t<=399&&null!=r}(h))return h;throw h}var u}async function f(t,r,a,n,o,i,l){let d=null!=i;if(d&&(null==i||!i.route.loader)&&(null==i||!i.route.lazy))throw Ie(400,{method:t.method,pathname:new URL(t.url).pathname,routeId:null==i?void 0:i.route.id});let u=(i?[i]:l&&Ne(l[1])?ve(r,l[0]):r).filter((e=>e.route.loader||e.route.lazy));if(0===u.length)return{matches:r,loaderData:r.reduce(((e,t)=>Object.assign(e,{[t.route.id]:null})),{}),errors:l&&Ne(l[1])?{[l[0]]:l[1].error}:null,statusCode:200,loaderHeaders:{},activeDeferreds:null};let c=await y("loader",t,u,r,d,a,n);t.signal.aborted&&pe(t,d,s);let h=new Map,f=Ce(r,c,l,h,o),p=new Set(u.map((e=>e.route.id)));return r.forEach((e=>{p.has(e.route.id)||(f.loaderData[e.route.id]=null)})),e({},f,{matches:r,activeDeferreds:h.size>0?Object.fromEntries(h.entries()):null})}async function y(e,t,r,o,l,d,u){let c=await xe(u||Ee,e,null,t,r,o,null,n,a,d),h={};return await Promise.all(o.map((async e=>{if(!(e.route.id in c))return;let r=c[e.route.id];if(Fe(r)){throw Le(r.result,t,e.route.id,o,i,s.v7_relativeSplatPath)}if(Ke(r.result)&&l)throw r;h[e.route.id]=await Pe(r)}))),h}return{dataRoutes:u,query:async function(t,r){let{requestContext:a,skipLoaderErrorBubbling:n,dataStrategy:o}=void 0===r?{}:r,s=new URL(t.url),c=t.method,f=l("",d(s),null,"default"),p=m(u,f,i);if(!Ye(c)&&"HEAD"!==c){let e=Ie(405,{method:c}),{matches:t,route:r}=He(u);return{basename:i,location:f,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}if(!p){let e=Ie(404,{pathname:f.pathname}),{matches:t,route:r}=He(u);return{basename:i,location:f,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}let y=await h(t,f,p,a,o||null,!0===n,null);return Ke(y)?y:e({location:f,basename:i},y)},queryRoute:async function(e,t){let{routeId:r,requestContext:a,dataStrategy:n}=void 0===t?{}:t,o=new URL(e.url),s=e.method,c=l("",d(o),null,"default"),f=m(u,c,i);if(!Ye(s)&&"HEAD"!==s&&"OPTIONS"!==s)throw Ie(405,{method:s});if(!f)throw Ie(404,{pathname:c.pathname});let p=r?f.find((e=>e.route.id===r)):Ze(f,c);if(r&&!p)throw Ie(403,{pathname:c.pathname,routeId:r});if(!p)throw Ie(404,{pathname:c.pathname});let y=await h(e,c,f,a,n||null,!1,p);if(Ke(y))return y;let v=y.errors?Object.values(y.errors)[0]:void 0;if(void 0!==v)throw v;if(y.actionData)return Object.values(y.actionData)[0];if(y.loaderData){var g;let e=Object.values(y.loaderData)[0];return null!=(g=y.activeDeferreds)&&g[p.route.id]&&(e[ce]=y.activeDeferreds[p.route.id]),e}}}}function fe(t,r,a){return e({},r,{statusCode:G(a)?a.status:500,errors:{[r._deepestRenderedBoundaryId||t[0].id]:a}})}function pe(e,t,r){if(r.v7_throwAbortReason&&void 0!==e.signal.reason)throw e.signal.reason;throw new Error((t?"queryRoute":"query")+"() call aborted: "+e.method+" "+e.url)}function me(e,t,r,a,n,o,i,s){let l,u;if(i){l=[];for(let e of t)if(l.push(e),e.route.id===i){u=e;break}}else l=t,u=t[t.length-1];let c=U(n||".",O(l,o),j(e.pathname,r)||e.pathname,"path"===s);if(null==n&&(c.search=e.search,c.hash=e.hash),(null==n||""===n||"."===n)&&u){let e=Qe(c.search);if(u.route.index&&!e)c.search=c.search?c.search.replace(/^\?/,"?index&"):"?index";else if(!u.route.index&&e){let e=new URLSearchParams(c.search),t=e.getAll("index");e.delete("index"),t.filter((e=>e)).forEach((t=>e.append("index",t)));let r=e.toString();c.search=r?"?"+r:""}}return a&&"/"!==r&&(c.pathname="/"===c.pathname?r:_([r,c.pathname])),d(c)}function ye(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&&!Ye(a.formMethod))return{path:r,error:Ie(405,{method:a.formMethod})};let n,i,s=()=>({path:r,error:Ie(400,{type:"invalid-body"})}),l=a.formMethod||"get",c=e?l.toUpperCase():l.toLowerCase(),h=Be(r);if(void 0!==a.body){if("text/plain"===a.formEncType){if(!Je(c))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:c,formAction:h,formEncType:a.formEncType,formData:void 0,json:void 0,text:e}}}if("application/json"===a.formEncType){if(!Je(c))return s();try{let e="string"==typeof a.body?JSON.parse(a.body):a.body;return{path:r,submission:{formMethod:c,formAction:h,formEncType:a.formEncType,formData:void 0,json:e,text:void 0}}}catch(m){return s()}}}if(o("function"==typeof FormData,"FormData is not available in this environment"),a.formData)n=Ae(a.formData),i=a.formData;else if(a.body instanceof FormData)n=Ae(a.body),i=a.body;else if(a.body instanceof URLSearchParams)n=a.body,i=je(n);else if(null==a.body)n=new URLSearchParams,i=new FormData;else try{n=new URLSearchParams(a.body),i=je(n)}catch(m){return s()}let f={formMethod:c,formAction:h,formEncType:a&&a.formEncType||"application/x-www-form-urlencoded",formData:i,json:void 0,text:void 0};if(Je(f.formMethod))return{path:r,submission:f};let p=u(r);return t&&p.search&&Qe(p.search)&&n.append("index",""),p.search="?"+n,{path:d(p),submission:f}}function ve(e,t,r){void 0===r&&(r=!1);let a=e.findIndex((e=>e.route.id===t));return a>=0?e.slice(0,r?a+1:a):e}function ge(t,r,a,n,o,i,s,l,d,u,c,h,f,p,y,v){let g=v?Ne(v[1])?v[1].error:v[1].data:void 0,b=t.createURL(r.location),w=t.createURL(o),D=a;i&&r.errors?D=ve(a,Object.keys(r.errors)[0],!0):v&&Ne(v[1])&&(D=ve(a,v[0]));let S=v?v[1].statusCode:void 0,R=s&&S&&S>=400,E=D.filter(((t,a)=>{let{route:o}=t;if(o.lazy)return!0;if(null==o.loader)return!1;if(i)return be(o,r.loaderData,r.errors);if(function(e,t,r){let a=!t||r.route.id!==t.route.id,n=void 0===e[r.route.id];return a||n}(r.loaderData,r.matches[a],t)||d.some((e=>e===t.route.id)))return!0;let s=r.matches[a],u=t;return De(t,e({currentUrl:b,currentParams:s.params,nextUrl:w,nextParams:u.params},n,{actionResult:g,actionStatus:S,defaultShouldRevalidate:!R&&(l||b.pathname+b.search===w.pathname+w.search||b.search!==w.search||we(s,u))}))})),x=[];return h.forEach(((t,o)=>{if(i||!a.some((e=>e.route.id===t.routeId))||c.has(o))return;let s=m(p,t.path,y);if(!s)return void x.push({key:o,routeId:t.routeId,path:t.path,matches:null,match:null,controller:null});let d=r.fetchers.get(o),h=Ze(s,t.path),v=!1;f.has(o)?v=!1:u.has(o)?(u.delete(o),v=!0):v=d&&"idle"!==d.state&&void 0===d.data?l:De(h,e({currentUrl:b,currentParams:r.matches[r.matches.length-1].params,nextUrl:w,nextParams:a[a.length-1].params},n,{actionResult:g,actionStatus:S,defaultShouldRevalidate:!R&&l})),v&&x.push({key:o,routeId:t.routeId,path:t.path,matches:s,match:h,controller:new AbortController})})),[E,x]}function be(e,t,r){if(e.lazy)return!0;if(!e.loader)return!1;let a=null!=t&&void 0!==t[e.id],n=null!=r&&void 0!==r[e.id];return!(!a&&n)&&("function"==typeof e.loader&&!0===e.loader.hydrate||!a&&!n)}function we(e,t){let r=e.route.path;return e.pathname!==t.pathname||null!=r&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function De(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if("boolean"==typeof r)return r}return t.defaultShouldRevalidate}function Se(e,t,r,a,n){var i;let s;if(e){let t=a[e];o(t,"No route found to patch children into: routeId = "+e),t.children||(t.children=[]),s=t.children}else s=r;let l=p(t.filter((e=>!s.some((t=>Re(e,t))))),n,[e||"_","patch",String((null==(i=s)?void 0:i.length)||"0")],a);s.push(...l)}function Re(e,t){return"id"in e&&"id"in t&&e.id===t.id||e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive&&(!(e.children&&0!==e.children.length||t.children&&0!==t.children.length)||e.children.every(((e,r)=>{var a;return null==(a=t.children)?void 0:a.some((t=>Re(e,t)))})))}async function Ee(e){let{matches:t}=e,r=t.filter((e=>e.shouldLoad));return(await Promise.all(r.map((e=>e.resolve())))).reduce(((e,t,a)=>Object.assign(e,{[r[a].route.id]:t})),{})}async function xe(t,r,a,n,s,l,d,u,h,p){let m=l.map((t=>t.route.lazy?async function(t,r,a){if(!t.lazy)return;let n=await t.lazy();if(!t.lazy)return;let s=a[t.id];o(s,"No route found in manifest");let l={};for(let e in n){let t=void 0!==s[e]&&"hasErrorBoundary"!==e;i(!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||f.has(e)||(l[e]=n[e])}Object.assign(s,l),Object.assign(s,e({},r(s),{lazy:void 0}))}(t.route,h,u):void 0)),y=l.map(((t,a)=>{let i=m[a],l=s.some((e=>e.route.id===t.route.id));return e({},t,{shouldLoad:l,resolve:async e=>(e&&"GET"===n.method&&(t.route.lazy||t.route.loader)&&(l=!0),l?async function(e,t,r,a,n,i){let s,l,d=a=>{let o,s=new Promise(((e,t)=>o=t));l=()=>o(),t.signal.addEventListener("abort",l);let d=n=>"function"!=typeof a?Promise.reject(new Error('You cannot call the handler for a route which defines a boolean "'+e+'" [routeId: '+r.route.id+"]")):a({request:t,params:r.params,context:i},...void 0!==n?[n]:[]),u=(async()=>{try{return{type:"data",result:await(n?n((e=>d(e))):d())}}catch(e){return{type:"error",result:e}}})();return Promise.race([u,s])};try{let n=r.route[e];if(a)if(n){let e,[t]=await Promise.all([d(n).catch((t=>{e=t})),a]);if(void 0!==e)throw e;s=t}else{if(await a,n=r.route[e],!n){if("action"===e){let e=new URL(t.url),a=e.pathname+e.search;throw Ie(405,{method:t.method,pathname:a,routeId:r.route.id})}return{type:c.data,result:void 0}}s=await d(n)}else{if(!n){let e=new URL(t.url);throw Ie(404,{pathname:e.pathname+e.search})}s=await d(n)}o(void 0!==s.result,"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(u){return{type:c.error,result:u}}finally{l&&t.signal.removeEventListener("abort",l)}return s}(r,n,t,i,e,p):Promise.resolve({type:c.data,result:void 0}))})})),v=await t({matches:y,request:n,params:l[0].params,fetcherKey:d,context:p});try{await Promise.all(m)}catch(g){}return v}async function Pe(e){let{result:t,type:r}=e;if(Ke(t)){let e;try{let r=t.headers.get("Content-Type");e=r&&/\bapplication\/json\b/.test(r)?null==t.body?null:await t.json():await t.text()}catch(h){return{type:c.error,error:h}}return r===c.error?{type:c.error,error:new X(t.status,t.statusText,e),statusCode:t.status,headers:t.headers}:{type:c.data,data:e,statusCode:t.status,headers:t.headers}}var a,n,o,i,s,l,d,u;return r===c.error?$e(t)?t.data instanceof Error?{type:c.error,error:t.data,statusCode:null==(o=t.init)?void 0:o.status,headers:null!=(i=t.init)&&i.headers?new Headers(t.init.headers):void 0}:{type:c.error,error:new X((null==(a=t.init)?void 0:a.status)||500,void 0,t.data),statusCode:G(t)?t.status:void 0,headers:null!=(n=t.init)&&n.headers?new Headers(t.init.headers):void 0}:{type:c.error,error:t,statusCode:G(t)?t.status:void 0}:function(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}(t)?{type:c.deferred,deferredData:t,statusCode:null==(s=t.init)?void 0:s.status,headers:(null==(l=t.init)?void 0:l.headers)&&new Headers(t.init.headers)}:$e(t)?{type:c.data,data:t.data,statusCode:null==(d=t.init)?void 0:d.status,headers:null!=(u=t.init)&&u.headers?new Headers(t.init.headers):void 0}:{type:c.data,data:t}}function Le(e,t,r,a,n,i){let s=e.headers.get("Location");if(o(s,"Redirects returned/thrown from loaders/actions must have a Location header"),!se.test(s)){let o=a.slice(0,a.findIndex((e=>e.route.id===r))+1);s=me(new URL(t.url),o,n,!0,s,i),e.headers.set("Location",s)}return e}function Me(e,t,r){if(se.test(e)){let a=e,n=a.startsWith("//")?new URL(t.protocol+a):new URL(a),o=null!=j(n.pathname,r);if(n.origin===t.origin&&o)return n.pathname+n.search+n.hash}return e}function ke(e,t,r,a){let n=e.createURL(Be(t)).toString(),o={signal:r};if(a&&Je(a.formMethod)){let{formMethod:e,formEncType:t}=a;o.method=e.toUpperCase(),"application/json"===t?(o.headers=new Headers({"Content-Type":t}),o.body=JSON.stringify(a.json)):"text/plain"===t?o.body=a.text:"application/x-www-form-urlencoded"===t&&a.formData?o.body=Ae(a.formData):o.body=a.formData}return new Request(n,o)}function Ae(e){let t=new URLSearchParams;for(let[r,a]of e.entries())t.append(r,"string"==typeof a?a:a.name);return t}function je(e){let t=new FormData;for(let[r,a]of e.entries())t.append(r,a);return t}function Ce(e,t,r,a,n){let i,s={},l=null,d=!1,u={},c=r&&Ne(r[1])?r[1].error:void 0;return e.forEach((r=>{if(!(r.route.id in t))return;let h=r.route.id,f=t[h];if(o(!We(f),"Cannot handle redirect results in processLoaderData"),Ne(f)){let t=f.error;if(void 0!==c&&(t=c,c=void 0),l=l||{},n)l[h]=t;else{let r=_e(e,h);null==l[r.route.id]&&(l[r.route.id]=t)}s[h]=void 0,d||(d=!0,i=G(f.error)?f.error.status:500),f.headers&&(u[h]=f.headers)}else qe(f)?(a.set(h,f.deferredData),s[h]=f.deferredData.data,null==f.statusCode||200===f.statusCode||d||(i=f.statusCode),f.headers&&(u[h]=f.headers)):(s[h]=f.data,f.statusCode&&200!==f.statusCode&&!d&&(i=f.statusCode),f.headers&&(u[h]=f.headers))})),void 0!==c&&r&&(l={[r[0]]:c},s[r[0]]=void 0),{loaderData:s,errors:l,statusCode:i||200,loaderHeaders:u}}function Te(t,r,a,n,i,s,l){let{loaderData:d,errors:u}=Ce(r,a,n,l,!1);return i.forEach((r=>{let{key:a,match:n,controller:i}=r,l=s[a];if(o(l,"Did not find corresponding fetcher result"),!i||!i.signal.aborted)if(Ne(l)){let r=_e(t.matches,null==n?void 0:n.route.id);u&&u[r.route.id]||(u=e({},u,{[r.route.id]:l.error})),t.fetchers.delete(a)}else if(We(l))o(!1,"Unhandled fetcher revalidation redirect");else if(qe(l))o(!1,"Unhandled fetcher deferred data");else{let e=at(l.data);t.fetchers.set(a,e)}})),{loaderData:d,errors:u}}function Oe(t,r,a,n){let o=e({},r);for(let e of a){let a=e.route.id;if(r.hasOwnProperty(a)?void 0!==r[a]&&(o[a]=r[a]):void 0!==t[a]&&e.route.loader&&(o[a]=t[a]),n&&n.hasOwnProperty(a))break}return o}function Ue(e){return e?Ne(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function _e(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=1===e.length?e[0]:e.find((e=>e.index||!e.path||"/"===e.path))||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function Ie(e,t){let{pathname:r,routeId:a,method:n,type:o,message:i}=void 0===t?{}:t,s="Unknown Server Error",l="Unknown @remix-run/router error";return 400===e?(s="Bad Request",n&&r&&a?l="You made a "+n+' request to "'+r+'" but did not provide a `loader` for route "'+a+'", so there is no way to handle the request.':"defer-action"===o?l="defer() is not supported in actions":"invalid-body"===o&&(l="Unable to encode submission body")):403===e?(s="Forbidden",l='Route "'+a+'" does not match URL "'+r+'"'):404===e?(s="Not Found",l='No route matches URL "'+r+'"'):405===e&&(s="Method Not Allowed",n&&r&&a?l="You made a "+n.toUpperCase()+' request to "'+r+'" but did not provide an `action` for route "'+a+'", so there is no way to handle the request.':n&&(l='Invalid request method "'+n.toUpperCase()+'"')),new X(e||500,s,new Error(l),!0)}function ze(e){let t=Object.entries(e);for(let r=t.length-1;r>=0;r--){let[e,a]=t[r];if(We(a))return{key:e,result:a}}}function Be(t){return d(e({},"string"==typeof t?u(t):t,{hash:""}))}function Fe(e){return Ke(e.result)&&re.has(e.result.status)}function qe(e){return e.type===c.deferred}function Ne(e){return e.type===c.error}function We(e){return(e&&e.type)===c.redirect}function $e(e){return"object"==typeof e&&null!=e&&"type"in e&&"data"in e&&"init"in e&&"DataWithResponseInit"===e.type}function Ke(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"object"==typeof e.headers&&void 0!==e.body}function Ye(e){return te.has(e.toLowerCase())}function Je(e){return Z.has(e.toLowerCase())}async function Ve(e,t,r,a,n){let o=Object.entries(t);for(let i=0;i(null==e?void 0:e.route.id)===s));if(!d)continue;let u=a.find((e=>e.route.id===d.route.id)),c=null!=u&&!we(u,d)&&void 0!==(n&&n[d.route.id]);qe(l)&&c&&await Ge(l,r,!1).then((e=>{e&&(t[s]=e)}))}}async function Xe(e,t,r){for(let a=0;a(null==e?void 0:e.route.id)===i))&&(qe(l)&&(o(s,"Expected an AbortController for revalidating fetcher deferred result"),await Ge(l,s.signal,!0).then((e=>{e&&(t[n]=e)}))))}}async function Ge(e,t,r){if(void 0===r&&(r=!1),!(await e.deferredData.resolveData(t))){if(r)try{return{type:c.data,data:e.deferredData.unwrappedData}}catch(a){return{type:c.error,error:a}}return{type:c.data,data:e.deferredData.data}}}function Qe(e){return new URLSearchParams(e).getAll("index").some((e=>""===e))}function Ze(e,t){let r="string"==typeof t?u(t).search:t.search;if(e[e.length-1].route.index&&Qe(r||""))return e[e.length-1];let a=T(e);return a[a.length-1]}function et(e){let{formMethod:t,formAction:r,formEncType:a,text:n,formData:o,json:i}=e;if(t&&r&&a)return null!=n?{formMethod:t,formAction:r,formEncType:a,formData:void 0,json:void 0,text:n}:null!=o?{formMethod:t,formAction:r,formEncType:a,formData:o,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 tt(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 rt(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 at(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}export{t as A,W as D,X as E,oe as I,ce as U,n as a,J as b,ue as c,K as d,V as e,q as f,o as g,_ as h,G as i,B as j,N as k,O as l,m,U as n,v as o,u as p,d as q,Y as r,j as s,k as t,he as u,fe as v};