UNPKG

@bonhomie/react-security

Version:

A frontend security layer for React: devtools detection, screenshot blocking, anti-iframe, tamper detection, watermarking, and more.

2 lines 213 kB
var nc=Object.create;var Vr=Object.defineProperty;var oc=Object.getOwnPropertyDescriptor;var ic=Object.getOwnPropertyNames;var sc=Object.getPrototypeOf,lc=Object.prototype.hasOwnProperty;var Yr=(e,t)=>()=>(e&&(t=e(e=0)),t);var tn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),rn=(e,t)=>{for(var r in t)Vr(e,r,{get:t[r],enumerable:!0})},oi=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ic(t))!lc.call(e,n)&&n!==r&&Vr(e,n,{get:()=>t[n],enumerable:!(a=oc(t,n))||a.enumerable});return e};var ne=(e,t,r)=>(r=e!=null?nc(sc(e)):{},oi(t||!e||!e.__esModule?Vr(r,"default",{value:e,enumerable:!0}):r,e)),an=e=>oi(Vr({},"__esModule",{value:!0}),e);function Ni(e={}){let{initialEntries:t=["/"],initialIndex:r,v5Compat:a=!1}=e,n;n=t.map((h,m)=>d(h,typeof h=="string"?null:h.state,m===0?"default":void 0));let o=l(r??n.length-1),i="POP",s=null;function l(h){return Math.min(Math.max(h,0),n.length-1)}function u(){return n[o]}function d(h,m=null,v){let p=ot(n?u().pathname:"/",h,m,v);return Q(p.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(h)}`),p}function c(h){return typeof h=="string"?h:pe(h)}return{get index(){return o},get action(){return i},get location(){return u()},createHref:c,createURL(h){return new URL(c(h),"http://localhost")},encodeLocation(h){let m=typeof h=="string"?Te(h):h;return{pathname:m.pathname||"",search:m.search||"",hash:m.hash||""}},push(h,m){i="PUSH";let v=d(h,m);o+=1,n.splice(o,n.length,v),a&&s&&s({action:i,location:v,delta:1})},replace(h,m){i="REPLACE";let v=d(h,m);n[o]=v,a&&s&&s({action:i,location:v,delta:0})},go(h){i="POP";let m=l(o+h),v=n[m];o=m,s&&s({action:i,location:v,delta:h})},listen(h){return s=h,()=>{s=null}}}}function Lt(e={}){function t(a,n){let{pathname:o,search:i,hash:s}=a.location;return ot("",{pathname:o,search:i,hash:s},n.state&&n.state.usr||null,n.state&&n.state.key||"default")}function r(a,n){return typeof n=="string"?n:pe(n)}return Hi(t,r,null,e)}function Ii(e={}){function t(n,o){let{pathname:i="/",search:s="",hash:l=""}=Te(n.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),ot("",{pathname:i,search:s,hash:l},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function r(n,o){let i=n.document.querySelector("base"),s="";if(i&&i.getAttribute("href")){let l=n.location.href,u=l.indexOf("#");s=u===-1?l:l.slice(0,u)}return s+"#"+(typeof o=="string"?o:pe(o))}function a(n,o){Q(n.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return Hi(t,r,a,e)}function A(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Q(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function dc(){return Math.random().toString(36).substring(2,10)}function ui(e,t){return{usr:e.state,key:e.key,idx:t}}function ot(e,t,r=null,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Te(t):t,state:r,key:t&&t.key||a||dc()}}function pe({pathname:e="/",search:t="",hash:r=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function Te(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substring(r),e=e.substring(0,r));let a=e.indexOf("?");a>=0&&(t.search=e.substring(a),e=e.substring(0,a)),e&&(t.pathname=e)}return t}function Hi(e,t,r,a={}){let{window:n=document.defaultView,v5Compat:o=!1}=a,i=n.history,s="POP",l=null,u=d();u==null&&(u=0,i.replaceState({...i.state,idx:u},""));function d(){return(i.state||{idx:null}).idx}function c(){s="POP";let p=d(),R=p==null?null:p-u;u=p,l&&l({action:s,location:v.location,delta:R})}function f(p,R){s="PUSH";let w=ot(v.location,p,R);r&&r(w,p),u=d()+1;let x=ui(w,u),P=v.createHref(w);try{i.pushState(x,"",P)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;n.location.assign(P)}o&&l&&l({action:s,location:v.location,delta:1})}function h(p,R){s="REPLACE";let w=ot(v.location,p,R);r&&r(w,p),u=d();let x=ui(w,u),P=v.createHref(w);i.replaceState(x,"",P),o&&l&&l({action:s,location:v.location,delta:0})}function m(p){return $i(p)}let v={get action(){return s},get location(){return e(n,i)},listen(p){if(l)throw new Error("A history only accepts one active listener");return n.addEventListener(li,c),l=p,()=>{n.removeEventListener(li,c),l=null}},createHref(p){return t(n,p)},createURL:m,encodeLocation(p){let R=m(p);return{pathname:R.pathname,search:R.search,hash:R.hash}},push:f,replace:h,go(p){return i.go(p)}};return v}function $i(e,t=!1){let r="http://localhost";typeof window<"u"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),A(r,"No window.location.(origin|href) available to create URL");let a=typeof e=="string"?e:pe(e);return a=a.replace(/ $/,"%20"),!t&&a.startsWith("//")&&(a=r+a),new URL(a,r)}function sa(e){return{defaultValue:e}}function hc(e){return fc.has(e)}function pc(e){return mc.has(e)}function yc(e){return e.index===!0}function it(e,t,r=[],a={},n=!1){return e.map((o,i)=>{let s=[...r,String(i)],l=typeof o.id=="string"?o.id:s.join("-");if(A(o.index!==!0||!o.children,"Cannot specify children on an index route"),A(n||!a[l],`Found a route id collision on id "${l}". Route id's must be globally unique within Data Router usages`),yc(o)){let u={...o,id:l};return a[l]=ci(u,t(u)),u}else{let u={...o,id:l,children:void 0};return a[l]=ci(u,t(u)),o.children&&(u.children=it(o.children,t,s,a,n)),u}})}function ci(e,t){return Object.assign(e,{...t,...typeof t.lazy=="object"&&t.lazy!=null?{lazy:{...e.lazy,...t.lazy}}:{}})}function be(e,t,r="/"){return mr(e,t,r,!1)}function mr(e,t,r,a){let n=typeof t=="string"?Te(t):t,o=ue(n.pathname||"/",r);if(o==null)return null;let i=ji(e);vc(i);let s=null;for(let l=0;s==null&&l<i.length;++l){let u=Vi(o);s=Pc(i[l],u,a)}return s}function Ui(e,t){let{route:r,pathname:a,params:n}=e;return{id:r.id,pathname:a,params:n,data:t[r.id],loaderData:t[r.id],handle:r.handle}}function ji(e,t=[],r=[],a="",n=!1){let o=(i,s,l=n,u)=>{let d={relativePath:u===void 0?i.path||"":u,caseSensitive:i.caseSensitive===!0,childrenIndex:s,route:i};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(a)&&l)return;A(d.relativePath.startsWith(a),`Absolute route path "${d.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(a.length)}let c=Ge([a,d.relativePath]),f=r.concat(d);i.children&&i.children.length>0&&(A(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${c}".`),ji(i.children,t,f,c,l)),!(i.path==null&&!i.index)&&t.push({path:c,score:xc(c,i.index),routesMeta:f})};return e.forEach((i,s)=>{if(i.path===""||!i.path?.includes("?"))o(i,s);else for(let l of zi(i.path))o(i,s,!0,l)}),t}function zi(e){let t=e.split("/");if(t.length===0)return[];let[r,...a]=t,n=r.endsWith("?"),o=r.replace(/\?$/,"");if(a.length===0)return n?[o,""]:[o];let i=zi(a.join("/")),s=[];return s.push(...i.map(l=>l===""?o:[o,l].join("/"))),n&&s.push(...i),s.map(l=>e.startsWith("/")&&l===""?"/":l)}function vc(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:Cc(t.routesMeta.map(a=>a.childrenIndex),r.routesMeta.map(a=>a.childrenIndex)))}function xc(e,t){let r=e.split("/"),a=r.length;return r.some(di)&&(a+=Sc),t&&(a+=wc),r.filter(n=>!di(n)).reduce((n,o)=>n+(Rc.test(o)?gc:o===""?Ec:bc),a)}function Cc(e,t){return e.length===t.length&&e.slice(0,-1).every((a,n)=>a===t[n])?e[e.length-1]-t[t.length-1]:0}function Pc(e,t,r=!1){let{routesMeta:a}=e,n={},o="/",i=[];for(let s=0;s<a.length;++s){let l=a[s],u=s===a.length-1,d=o==="/"?t:t.slice(o.length)||"/",c=Dt({path:l.relativePath,caseSensitive:l.caseSensitive,end:u},d),f=l.route;if(!c&&u&&r&&!a[a.length-1].route.index&&(c=Dt({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},d)),!c)return null;Object.assign(n,c.params),i.push({params:n,pathname:Ge([o,c.pathname]),pathnameBase:_c(Ge([o,c.pathnameBase])),route:f}),c.pathnameBase!=="/"&&(o=Ge([o,c.pathnameBase]))}return i}function Bi(e,t={}){let r=e;r.endsWith("*")&&r!=="*"&&!r.endsWith("/*")&&(Q(!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(/\*$/,"/*"));let a=r.startsWith("/")?"/":"",n=i=>i==null?"":typeof i=="string"?i:String(i),o=r.split(/\/+/).map((i,s,l)=>{if(s===l.length-1&&i==="*")return n(t["*"]);let d=i.match(/^:([\w-]+)(\??)$/);if(d){let[,c,f]=d,h=t[c];return A(f==="?"||h!=null,`Missing ":${c}" param`),encodeURIComponent(n(h))}return i.replace(/\?$/g,"")}).filter(i=>!!i);return a+o.join("/")}function Dt(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,a]=Wi(e.path,e.caseSensitive,e.end),n=t.match(r);if(!n)return null;let o=n[0],i=o.replace(/(.)\/+$/,"$1"),s=n.slice(1);return{params:a.reduce((u,{paramName:d,isOptional:c},f)=>{if(d==="*"){let m=s[f]||"";i=o.slice(0,o.length-m.length).replace(/(.)\/+$/,"$1")}let h=s[f];return c&&!h?u[d]=void 0:u[d]=(h||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:i,pattern:e}}function Wi(e,t=!1,r=!0){Q(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let a=[],n="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,s,l)=>(a.push({paramName:s,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(a.push({paramName:"*"}),n+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?n+="\\/*$":e!==""&&e!=="/"&&(n+="(?:(?=\\/|$))"),[new RegExp(n,t?void 0:"i"),a]}function Vi(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Q(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function ue(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 Dc({basename:e,pathname:t}){return t==="/"?e:Ge([e,t])}function Pn(e,t="/"){let{pathname:r,search:a="",hash:n=""}=typeof e=="string"?Te(e):e,o;if(r)if(la(r))o=r;else{if(r.includes("//")){let i=r;r=r.replace(/\/\/+/g,"/"),Q(!1,`Pathnames cannot have embedded double slashes - normalizing ${i} -> ${r}`)}r.startsWith("/")?o=fi(r.substring(1),"/"):o=fi(r,t)}else o=t;return{pathname:o,search:kc(a),hash:Tc(n)}}function fi(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(n=>{n===".."?r.length>1&&r.pop():n!=="."&&r.push(n)}),r.length>1?r.join("/"):"/"}function on(e,t,r,a){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(a)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Yi(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function ua(e){let t=Yi(e);return t.map((r,a)=>a===t.length-1?r.pathname:r.pathnameBase)}function ca(e,t,r,a=!1){let n;typeof e=="string"?n=Te(e):(n={...e},A(!n.pathname||!n.pathname.includes("?"),on("?","pathname","search",n)),A(!n.pathname||!n.pathname.includes("#"),on("#","pathname","hash",n)),A(!n.search||!n.search.includes("#"),on("#","search","hash",n)));let o=e===""||n.pathname==="",i=o?"/":n.pathname,s;if(i==null)s=r;else{let c=t.length-1;if(!a&&i.startsWith("..")){let f=i.split("/");for(;f[0]==="..";)f.shift(),c-=1;n.pathname=f.join("/")}s=c>=0?t[c]:"/"}let l=Pn(n,s),u=i&&i!=="/"&&i.endsWith("/"),d=(o||i===".")&&r.endsWith("/");return!l.pathname.endsWith("/")&&(u||d)&&(l.pathname+="/"),l}function Dn(e,t){return new Oc(e,typeof t=="number"?{status:t}:t)}function oe(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function jt(e){return e.filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}function Ji(e,t){let r={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};e.forEach(n=>n({id:t.id,index:t.index,path:t.path,instrument(o){let i=Object.keys(r);for(let s of i)o[s]&&r[s].push(o[s])}}));let a={};if(typeof t.lazy=="function"&&r.lazy.length>0){let n=Pt(r.lazy,t.lazy,()=>{});n&&(a.lazy=n)}if(typeof t.lazy=="object"){let n=t.lazy;["middleware","loader","action"].forEach(o=>{let i=n[o],s=r[`lazy.${o}`];if(typeof i=="function"&&s.length>0){let l=Pt(s,i,()=>{});l&&(a.lazy=Object.assign(a.lazy||{},{[o]:l}))}})}return["loader","action"].forEach(n=>{let o=t[n];if(typeof o=="function"&&r[n].length>0){let i=o[mt]??o,s=Pt(r[n],i,(...l)=>hi(l[0]));s&&(s[mt]=i,a[n]=s)}}),t.middleware&&t.middleware.length>0&&r.middleware.length>0&&(a.middleware=t.middleware.map(n=>{let o=n[mt]??n,i=Pt(r.middleware,o,(...s)=>hi(s[0]));return i?(i[mt]=o,i):n})),a}function Mc(e,t){let r={navigate:[],fetch:[]};if(t.forEach(a=>a({instrument(n){let o=Object.keys(n);for(let i of o)n[i]&&r[i].push(n[i])}})),r.navigate.length>0){let a=e.navigate[mt]??e.navigate,n=Pt(r.navigate,a,(...o)=>{let[i,s]=o;return{to:typeof i=="number"||typeof i=="string"?i:i?pe(i):".",...mi(e,s??{})}});n&&(n[mt]=a,e.navigate=n)}if(r.fetch.length>0){let a=e.fetch[mt]??e.fetch,n=Pt(r.fetch,a,(...o)=>{let[i,,s,l]=o;return{href:s??".",fetcherKey:i,...mi(e,l??{})}});n&&(n[mt]=a,e.fetch=n)}return e}function Ki(e,t){let r={request:[]};t.forEach(n=>n({instrument(o){let i=Object.keys(o);for(let s of i)o[s]&&r[s].push(o[s])}}));let a=e;return r.request.length>0&&(a=Pt(r.request,e,(...n)=>{let[o,i]=n;return{request:Xi(o),context:i!=null?qi(i):i}})),a}function Pt(e,t,r){return e.length===0?null:async(...a)=>{let n=await Gi(e,r(...a),()=>t(...a),e.length-1);if(n.type==="error")throw n.value;return n.value}}async function Gi(e,t,r,a){let n=e[a],o;if(n){let i,s=async()=>(i?console.error("You cannot call instrumented handlers more than once"):i=Gi(e,t,r,a-1),o=await i,A(o,"Expected a result"),o.type==="error"&&o.value instanceof Error?{status:"error",error:o.value}:{status:"success",error:void 0});try{await n(s,t)}catch(l){console.error("An instrumentation function threw an error:",l)}i||await s(),await i}else try{o={type:"success",value:await r()}}catch(i){o={type:"error",value:i}}return o||{type:"error",value:new Error("No result assigned in instrumentation chain.")}}function hi(e){let{request:t,context:r,params:a,unstable_pattern:n}=e;return{request:Xi(t),params:{...a},unstable_pattern:n,context:qi(r)}}function mi(e,t){return{currentUrl:pe(e.state.location),..."formMethod"in t?{formMethod:t.formMethod}:{},..."formEncType"in t?{formEncType:t.formEncType}:{},..."formData"in t?{formData:t.formData}:{},..."body"in t?{body:t.body}:{}}}function Xi(e){return{method:e.method,url:e.url,headers:{get:(...t)=>e.headers.get(...t)}}}function qi(e){if(Fc(e)){let t={...e};return Object.freeze(t),t}else return{get:t=>e.get(t)}}function Fc(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getOwnPropertyNames(t).sort().join("\0")===Ac}function vt(e){let t=e.window?e.window:typeof window<"u"?window:void 0,r=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u";A(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let a=e.hydrationRouteProperties||[],n=e.mapRouteProperties||es,o=n;if(e.unstable_instrumentations){let y=e.unstable_instrumentations;o=E=>({...n(E),...Ji(y.map(b=>b.route).filter(Boolean),E)})}let i={},s=it(e.routes,o,void 0,i),l,u=e.basename||"/";u.startsWith("/")||(u=`/${u}`);let d=e.dataStrategy||Vc,c={...e.future},f=null,h=new Set,m=null,v=null,p=null,R=e.hydrationData!=null,w=be(s,e.history.location,u),x=!1,P=null,C;if(w==null&&!e.patchRoutesOnNavigation){let y=le(404,{pathname:e.history.location.pathname}),{matches:E,route:b}=Ut(s);C=!0,w=E,P={[b.id]:y}}else if(w&&!e.hydrationData&&Ur(w,s,e.history.location.pathname).active&&(w=null),w)if(w.some(y=>y.route.lazy))C=!1;else if(!w.some(y=>kn(y.route)))C=!0;else{let y=e.hydrationData?e.hydrationData.loaderData:null,E=e.hydrationData?e.hydrationData.errors:null;if(E){let b=w.findIndex(D=>E[D.route.id]!==void 0);C=w.slice(0,b+1).every(D=>!fn(D.route,y,E))}else C=w.every(b=>!fn(b.route,y,E))}else{C=!1,w=[];let y=Ur(null,s,e.history.location.pathname);y.active&&y.matches&&(x=!0,w=y.matches)}let S,g={historyAction:e.history.action,location:e.history.location,matches:w,initialized:C,navigation:zt,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||P,fetchers:new Map,blockers:new Map},T="POP",O=!1,F,H=!1,G=new Map,Z=null,Y=!1,q=!1,ve=new Set,X=new Map,Ae=0,_e=-1,ze=new Map,ke=new Set,Fe=new Map,Ye=new Map,Je=new Set,wt=new Map,Hr,nr=null;function Uu(){if(f=e.history.listen(({action:y,location:E,delta:b})=>{if(Hr){Hr(),Hr=void 0;return}Q(wt.size===0||b!=null,"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 D=ei({currentLocation:g.location,nextLocation:E,historyAction:y});if(D&&b!=null){let _=new Promise(U=>{Hr=U});e.history.go(b*-1),$r(D,{state:"blocked",location:E,proceed(){$r(D,{state:"proceeding",proceed:void 0,reset:void 0,location:E}),_.then(()=>e.history.go(b))},reset(){let U=new Map(g.blockers);U.set(D,at),ge({blockers:U})}});return}return Et(y,E)}),r){Qc(t,G);let y=()=>Zc(t,G);t.addEventListener("pagehide",y),Z=()=>t.removeEventListener("pagehide",y)}return g.initialized||Et("POP",g.location,{initialHydration:!0}),S}function ju(){f&&f(),Z&&Z(),h.clear(),F&&F.abort(),g.fetchers.forEach((y,E)=>Qa(E)),g.blockers.forEach((y,E)=>Zo(E))}function zu(y){return h.add(y),()=>h.delete(y)}function ge(y,E={}){y.matches&&(y.matches=y.matches.map(_=>{let U=i[_.route.id],j=_.route;return j.element!==U.element||j.errorElement!==U.errorElement||j.hydrateFallbackElement!==U.hydrateFallbackElement?{..._,route:U}:_})),g={...g,...y};let b=[],D=[];g.fetchers.forEach((_,U)=>{_.state==="idle"&&(Je.has(U)?b.push(U):D.push(U))}),Je.forEach(_=>{!g.fetchers.has(_)&&!X.has(_)&&b.push(_)}),[...h].forEach(_=>_(g,{deletedFetchers:b,viewTransitionOpts:E.viewTransitionOpts,flushSync:E.flushSync===!0})),b.forEach(_=>Qa(_)),D.forEach(_=>g.fetchers.delete(_))}function It(y,E,{flushSync:b}={}){let D=g.actionData!=null&&g.navigation.formMethod!=null&&me(g.navigation.formMethod)&&g.navigation.state==="loading"&&y.state?._isRedirect!==!0,_;E.actionData?Object.keys(E.actionData).length>0?_=E.actionData:_=null:D?_=g.actionData:_=null;let U=E.loaderData?Pi(g.loaderData,E.loaderData,E.matches||[],E.errors):g.loaderData,j=g.blockers;j.size>0&&(j=new Map(j),j.forEach((B,W)=>j.set(W,at)));let I=Y?!1:ri(y,E.matches||g.matches),z=O===!0||g.navigation.formMethod!=null&&me(g.navigation.formMethod)&&y.state?._isRedirect!==!0;l&&(s=l,l=void 0),Y||T==="POP"||(T==="PUSH"?e.history.push(y,y.state):T==="REPLACE"&&e.history.replace(y,y.state));let V;if(T==="POP"){let B=G.get(g.location.pathname);B&&B.has(y.pathname)?V={currentLocation:g.location,nextLocation:y}:G.has(y.pathname)&&(V={currentLocation:y,nextLocation:g.location})}else if(H){let B=G.get(g.location.pathname);B?B.add(y.pathname):(B=new Set([y.pathname]),G.set(g.location.pathname,B)),V={currentLocation:g.location,nextLocation:y}}ge({...E,actionData:_,loaderData:U,historyAction:T,location:y,initialized:!0,navigation:zt,revalidation:"idle",restoreScrollPosition:I,preventScrollReset:z,blockers:j},{viewTransitionOpts:V,flushSync:b===!0}),T="POP",O=!1,H=!1,Y=!1,q=!1,nr?.resolve(),nr=null}async function Yo(y,E){if(typeof y=="number"){e.history.go(y);return}let b=dn(g.location,g.matches,u,y,E?.fromRouteId,E?.relative),{path:D,submission:_,error:U}=yi(!1,b,E),j=g.location,I=ot(g.location,D,E&&E.state);I={...I,...e.history.encodeLocation(I)};let z=E&&E.replace!=null?E.replace:void 0,V="PUSH";z===!0?V="REPLACE":z===!1||_!=null&&me(_.formMethod)&&_.formAction===g.location.pathname+g.location.search&&(V="REPLACE");let B=E&&"preventScrollReset"in E?E.preventScrollReset===!0:void 0,W=(E&&E.flushSync)===!0,J=ei({currentLocation:j,nextLocation:I,historyAction:V});if(J){$r(J,{state:"blocked",location:I,proceed(){$r(J,{state:"proceeding",proceed:void 0,reset:void 0,location:I}),Yo(y,E)},reset(){let re=new Map(g.blockers);re.set(J,at),ge({blockers:re})}});return}await Et(V,I,{submission:_,pendingError:U,preventScrollReset:B,replace:E&&E.replace,enableViewTransition:E&&E.viewTransition,flushSync:W})}function Bu(){nr||(nr=ed()),qa(),ge({revalidation:"loading"});let y=nr.promise;return g.navigation.state==="submitting"?y:g.navigation.state==="idle"?(Et(g.historyAction,g.location,{startUninterruptedRevalidation:!0}),y):(Et(T||g.historyAction,g.navigation.location,{overrideNavigation:g.navigation,enableViewTransition:H===!0}),y)}async function Et(y,E,b){F&&F.abort(),F=null,T=y,Y=(b&&b.startUninterruptedRevalidation)===!0,ec(g.location,g.matches),O=(b&&b.preventScrollReset)===!0,H=(b&&b.enableViewTransition)===!0;let D=l||s,_=b&&b.overrideNavigation,U=b?.initialHydration&&g.matches&&g.matches.length>0&&!x?g.matches:be(D,E,u),j=(b&&b.flushSync)===!0;if(U&&g.initialized&&!q&&Jc(g.location,E)&&!(b&&b.submission&&me(b.submission.formMethod))){It(E,{matches:U},{flushSync:j});return}let I=Ur(U,D,E.pathname);if(I.active&&I.matches&&(U=I.matches),!U){let{error:de,notFoundMatches:ee,route:te}=Za(E.pathname);It(E,{matches:ee,loaderData:{},errors:{[te.id]:de}},{flushSync:j});return}F=new AbortController;let z=$t(e.history,E,F.signal,b&&b.submission),V=e.getContext?await e.getContext():new Ue,B;if(b&&b.pendingError)B=[$e(U).route.id,{type:"error",error:b.pendingError}];else if(b&&b.submission&&me(b.submission.formMethod)){let de=await Wu(z,E,b.submission,U,V,I.active,b&&b.initialHydration===!0,{replace:b.replace,flushSync:j});if(de.shortCircuited)return;if(de.pendingActionResult){let[ee,te]=de.pendingActionResult;if(he(te)&&oe(te.error)&&te.error.status===404){F=null,It(E,{matches:de.matches,loaderData:{},errors:{[ee]:te.error}});return}}U=de.matches||U,B=de.pendingActionResult,_=sn(E,b.submission),j=!1,I.active=!1,z=$t(e.history,z.url,z.signal)}let{shortCircuited:W,matches:J,loaderData:re,errors:ce}=await Vu(z,E,U,V,I.active,_,b&&b.submission,b&&b.fetcherSubmission,b&&b.replace,b&&b.initialHydration===!0,j,B);W||(F=null,It(E,{matches:J||U,...Di(B),loaderData:re,errors:ce}))}async function Wu(y,E,b,D,_,U,j,I={}){qa();let z=Xc(E,b);if(ge({navigation:z},{flushSync:I.flushSync===!0}),U){let W=await jr(D,E.pathname,y.signal);if(W.type==="aborted")return{shortCircuited:!0};if(W.type==="error"){if(W.partialMatches.length===0){let{matches:re,route:ce}=Ut(s);return{matches:re,pendingActionResult:[ce.id,{type:"error",error:W.error}]}}let J=$e(W.partialMatches).route.id;return{matches:W.partialMatches,pendingActionResult:[J,{type:"error",error:W.error}]}}else if(W.matches)D=W.matches;else{let{notFoundMatches:J,error:re,route:ce}=Za(E.pathname);return{matches:J,pendingActionResult:[ce.id,{type:"error",error:re}]}}}let V,B=Bt(D,E);if(!B.route.action&&!B.route.lazy)V={type:"error",error:le(405,{method:y.method,pathname:E.pathname,routeId:B.route.id})};else{let W=yt(o,i,y,D,B,j?[]:a,_),J=await or(y,W,_,null);if(V=J[B.route.id],!V){for(let re of D)if(J[re.route.id]){V=J[re.route.id];break}}if(y.signal.aborted)return{shortCircuited:!0}}if(pt(V)){let W;return I&&I.replace!=null?W=I.replace:W=Si(V.response.headers.get("Location"),new URL(y.url),u)===g.location.pathname+g.location.search,await bt(y,V,!0,{submission:b,replace:W}),{shortCircuited:!0}}if(he(V)){let W=$e(D,B.route.id);return(I&&I.replace)!==!0&&(T="PUSH"),{matches:D,pendingActionResult:[W.route.id,V,B.route.id]}}return{matches:D,pendingActionResult:[B.route.id,V]}}async function Vu(y,E,b,D,_,U,j,I,z,V,B,W){let J=U||sn(E,j),re=j||I||Li(J),ce=!Y&&!V;if(_){if(ce){let we=Jo(W);ge({navigation:J,...we!==void 0?{actionData:we}:{}},{flushSync:B})}let K=await jr(b,E.pathname,y.signal);if(K.type==="aborted")return{shortCircuited:!0};if(K.type==="error"){if(K.partialMatches.length===0){let{matches:Ht,route:Ct}=Ut(s);return{matches:Ht,loaderData:{},errors:{[Ct.id]:K.error}}}let we=$e(K.partialMatches).route.id;return{matches:K.partialMatches,loaderData:{},errors:{[we]:K.error}}}else if(K.matches)b=K.matches;else{let{error:we,notFoundMatches:Ht,route:Ct}=Za(E.pathname);return{matches:Ht,loaderData:{},errors:{[Ct.id]:we}}}}let de=l||s,{dsMatches:ee,revalidatingFetchers:te}=vi(y,D,o,i,e.history,g,b,re,E,V?[]:a,V===!0,q,ve,Je,Fe,ke,de,u,e.patchRoutesOnNavigation!=null,W);if(_e=++Ae,!e.dataStrategy&&!ee.some(K=>K.shouldLoad)&&!ee.some(K=>K.route.middleware&&K.route.middleware.length>0)&&te.length===0){let K=qo();return It(E,{matches:b,loaderData:{},errors:W&&he(W[1])?{[W[0]]:W[1].error}:null,...Di(W),...K?{fetchers:new Map(g.fetchers)}:{}},{flushSync:B}),{shortCircuited:!0}}if(ce){let K={};if(!_){K.navigation=J;let we=Jo(W);we!==void 0&&(K.actionData=we)}te.length>0&&(K.fetchers=Yu(te)),ge(K,{flushSync:B})}te.forEach(K=>{tt(K.key),K.controller&&X.set(K.key,K.controller)});let St=()=>te.forEach(K=>tt(K.key));F&&F.signal.addEventListener("abort",St);let{loaderResults:ir,fetcherResults:ft}=await Ko(ee,te,y,D);if(y.signal.aborted)return{shortCircuited:!0};F&&F.signal.removeEventListener("abort",St),te.forEach(K=>X.delete(K.key));let Ke=Gr(ir);if(Ke)return await bt(y,Ke.result,!0,{replace:z}),{shortCircuited:!0};if(Ke=Gr(ft),Ke)return ke.add(Ke.key),await bt(y,Ke.result,!0,{replace:z}),{shortCircuited:!0};let{loaderData:en,errors:sr}=Ci(g,b,ir,W,te,ft);V&&g.errors&&(sr={...g.errors,...sr});let xt=qo(),zr=Qo(_e),Br=xt||zr||te.length>0;return{matches:b,loaderData:en,errors:sr,...Br?{fetchers:new Map(g.fetchers)}:{}}}function Jo(y){if(y&&!he(y[1]))return{[y[0]]:y[1].data};if(g.actionData)return Object.keys(g.actionData).length===0?null:g.actionData}function Yu(y){return y.forEach(E=>{let b=g.fetchers.get(E.key),D=dr(void 0,b?b.data:void 0);g.fetchers.set(E.key,D)}),new Map(g.fetchers)}async function Ju(y,E,b,D){tt(y);let _=(D&&D.flushSync)===!0,U=l||s,j=dn(g.location,g.matches,u,b,E,D?.relative),I=be(U,j,u),z=Ur(I,U,j);if(z.active&&z.matches&&(I=z.matches),!I){et(y,E,le(404,{pathname:j}),{flushSync:_});return}let{path:V,submission:B,error:W}=yi(!0,j,D);if(W){et(y,E,W,{flushSync:_});return}let J=e.getContext?await e.getContext():new Ue,re=(D&&D.preventScrollReset)===!0;if(B&&me(B.formMethod)){await Ku(y,E,V,I,J,z.active,_,re,B);return}Fe.set(y,{routeId:E,path:V}),await Gu(y,E,V,I,J,z.active,_,re,B)}async function Ku(y,E,b,D,_,U,j,I,z){qa(),Fe.delete(y);let V=g.fetchers.get(y);Ze(y,qc(z,V),{flushSync:j});let B=new AbortController,W=$t(e.history,b,B.signal,z);if(U){let ie=await jr(D,new URL(W.url).pathname,W.signal,y);if(ie.type==="aborted")return;if(ie.type==="error"){et(y,E,ie.error,{flushSync:j});return}else if(ie.matches)D=ie.matches;else{et(y,E,le(404,{pathname:b}),{flushSync:j});return}}let J=Bt(D,b);if(!J.route.action&&!J.route.lazy){let ie=le(405,{method:z.formMethod,pathname:b,routeId:E});et(y,E,ie,{flushSync:j});return}X.set(y,B);let re=Ae,ce=yt(o,i,W,D,J,a,_),de=await or(W,ce,_,y),ee=de[J.route.id];if(!ee){for(let ie of ce)if(de[ie.route.id]){ee=de[ie.route.id];break}}if(W.signal.aborted){X.get(y)===B&&X.delete(y);return}if(Je.has(y)){if(pt(ee)||he(ee)){Ze(y,rt(void 0));return}}else{if(pt(ee))if(X.delete(y),_e>re){Ze(y,rt(void 0));return}else return ke.add(y),Ze(y,dr(z)),bt(W,ee,!1,{fetcherSubmission:z,preventScrollReset:I});if(he(ee)){et(y,E,ee.error);return}}let te=g.navigation.location||g.location,St=$t(e.history,te,B.signal),ir=l||s,ft=g.navigation.state!=="idle"?be(ir,g.navigation.location,u):g.matches;A(ft,"Didn't find any matches after fetcher action");let Ke=++Ae;ze.set(y,Ke);let en=dr(z,ee.data);g.fetchers.set(y,en);let{dsMatches:sr,revalidatingFetchers:xt}=vi(St,_,o,i,e.history,g,ft,z,te,a,!1,q,ve,Je,Fe,ke,ir,u,e.patchRoutesOnNavigation!=null,[J.route.id,ee]);xt.filter(ie=>ie.key!==y).forEach(ie=>{let Wr=ie.key,ni=g.fetchers.get(Wr),ac=dr(void 0,ni?ni.data:void 0);g.fetchers.set(Wr,ac),tt(Wr),ie.controller&&X.set(Wr,ie.controller)}),ge({fetchers:new Map(g.fetchers)});let zr=()=>xt.forEach(ie=>tt(ie.key));B.signal.addEventListener("abort",zr);let{loaderResults:Br,fetcherResults:K}=await Ko(sr,xt,St,_);if(B.signal.aborted)return;if(B.signal.removeEventListener("abort",zr),ze.delete(y),X.delete(y),xt.forEach(ie=>X.delete(ie.key)),g.fetchers.has(y)){let ie=rt(ee.data);g.fetchers.set(y,ie)}let we=Gr(Br);if(we)return bt(St,we.result,!1,{preventScrollReset:I});if(we=Gr(K),we)return ke.add(we.key),bt(St,we.result,!1,{preventScrollReset:I});let{loaderData:Ht,errors:Ct}=Ci(g,ft,Br,void 0,xt,K);Qo(Ke),g.navigation.state==="loading"&&Ke>_e?(A(T,"Expected pending action"),F&&F.abort(),It(g.navigation.location,{matches:ft,loaderData:Ht,errors:Ct,fetchers:new Map(g.fetchers)})):(ge({errors:Ct,loaderData:Pi(g.loaderData,Ht,ft,Ct),fetchers:new Map(g.fetchers)}),q=!1)}async function Gu(y,E,b,D,_,U,j,I,z){let V=g.fetchers.get(y);Ze(y,dr(z,V?V.data:void 0),{flushSync:j});let B=new AbortController,W=$t(e.history,b,B.signal);if(U){let te=await jr(D,new URL(W.url).pathname,W.signal,y);if(te.type==="aborted")return;if(te.type==="error"){et(y,E,te.error,{flushSync:j});return}else if(te.matches)D=te.matches;else{et(y,E,le(404,{pathname:b}),{flushSync:j});return}}let J=Bt(D,b);X.set(y,B);let re=Ae,ce=yt(o,i,W,D,J,a,_),ee=(await or(W,ce,_,y))[J.route.id];if(X.get(y)===B&&X.delete(y),!W.signal.aborted){if(Je.has(y)){Ze(y,rt(void 0));return}if(pt(ee))if(_e>re){Ze(y,rt(void 0));return}else{ke.add(y),await bt(W,ee,!1,{preventScrollReset:I});return}if(he(ee)){et(y,E,ee.error);return}Ze(y,rt(ee.data))}}async function bt(y,E,b,{submission:D,fetcherSubmission:_,preventScrollReset:U,replace:j}={}){E.response.headers.has("X-Remix-Revalidate")&&(q=!0);let I=E.response.headers.get("Location");A(I,"Expected a Location header on the redirect Response"),I=Si(I,new URL(y.url),u);let z=ot(g.location,I,{_isRedirect:!0});if(r){let ce=!1;if(E.response.headers.has("X-Remix-Reload-Document"))ce=!0;else if(la(I)){let de=$i(I,!0);ce=de.origin!==t.location.origin||ue(de.pathname,u)==null}if(ce){j?t.location.replace(I):t.location.assign(I);return}}F=null;let V=j===!0||E.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:B,formAction:W,formEncType:J}=g.navigation;!D&&!_&&B&&W&&J&&(D=Li(g.navigation));let re=D||_;if($c.has(E.response.status)&&re&&me(re.formMethod))await Et(V,z,{submission:{...re,formAction:I},preventScrollReset:U||O,enableViewTransition:b?H:void 0});else{let ce=sn(z,D);await Et(V,z,{overrideNavigation:ce,fetcherSubmission:_,preventScrollReset:U||O,enableViewTransition:b?H:void 0})}}async function or(y,E,b,D){let _,U={};try{_=await ls(d,y,E,D,b,!1)}catch(j){return E.filter(I=>I.shouldLoad).forEach(I=>{U[I.route.id]={type:"error",error:j}}),U}if(y.signal.aborted)return U;for(let[j,I]of Object.entries(_))if(ps(I)){let z=I.result;U[j]={type:"redirect",response:ds(z,y,j,E,u)}}else U[j]=await cs(I);return U}async function Ko(y,E,b,D){let _=or(b,y,D,null),U=Promise.all(E.map(async z=>{if(z.matches&&z.match&&z.request&&z.controller){let B=(await or(z.request,z.matches,D,z.key))[z.match.route.id];return{[z.key]:B}}else return Promise.resolve({[z.key]:{type:"error",error:le(404,{pathname:z.path})}})})),j=await _,I=(await U).reduce((z,V)=>Object.assign(z,V),{});return{loaderResults:j,fetcherResults:I}}function qa(){q=!0,Fe.forEach((y,E)=>{X.has(E)&&ve.add(E),tt(E)})}function Ze(y,E,b={}){g.fetchers.set(y,E),ge({fetchers:new Map(g.fetchers)},{flushSync:(b&&b.flushSync)===!0})}function et(y,E,b,D={}){let _=$e(g.matches,E);Qa(y),ge({errors:{[_.route.id]:b},fetchers:new Map(g.fetchers)},{flushSync:(D&&D.flushSync)===!0})}function Go(y){return Ye.set(y,(Ye.get(y)||0)+1),Je.has(y)&&Je.delete(y),g.fetchers.get(y)||wr}function Xu(y,E){tt(y,E?.reason),Ze(y,rt(null))}function Qa(y){let E=g.fetchers.get(y);X.has(y)&&!(E&&E.state==="loading"&&ze.has(y))&&tt(y),Fe.delete(y),ze.delete(y),ke.delete(y),Je.delete(y),ve.delete(y),g.fetchers.delete(y)}function qu(y){let E=(Ye.get(y)||0)-1;E<=0?(Ye.delete(y),Je.add(y)):Ye.set(y,E),ge({fetchers:new Map(g.fetchers)})}function tt(y,E){let b=X.get(y);b&&(b.abort(E),X.delete(y))}function Xo(y){for(let E of y){let b=Go(E),D=rt(b.data);g.fetchers.set(E,D)}}function qo(){let y=[],E=!1;for(let b of ke){let D=g.fetchers.get(b);A(D,`Expected fetcher: ${b}`),D.state==="loading"&&(ke.delete(b),y.push(b),E=!0)}return Xo(y),E}function Qo(y){let E=[];for(let[b,D]of ze)if(D<y){let _=g.fetchers.get(b);A(_,`Expected fetcher: ${b}`),_.state==="loading"&&(tt(b),ze.delete(b),E.push(b))}return Xo(E),E.length>0}function Qu(y,E){let b=g.blockers.get(y)||at;return wt.get(y)!==E&&wt.set(y,E),b}function Zo(y){g.blockers.delete(y),wt.delete(y)}function $r(y,E){let b=g.blockers.get(y)||at;A(b.state==="unblocked"&&E.state==="blocked"||b.state==="blocked"&&E.state==="blocked"||b.state==="blocked"&&E.state==="proceeding"||b.state==="blocked"&&E.state==="unblocked"||b.state==="proceeding"&&E.state==="unblocked",`Invalid blocker state transition: ${b.state} -> ${E.state}`);let D=new Map(g.blockers);D.set(y,E),ge({blockers:D})}function ei({currentLocation:y,nextLocation:E,historyAction:b}){if(wt.size===0)return;wt.size>1&&Q(!1,"A router only supports one blocker at a time");let D=Array.from(wt.entries()),[_,U]=D[D.length-1],j=g.blockers.get(_);if(!(j&&j.state==="proceeding")&&U({currentLocation:y,nextLocation:E,historyAction:b}))return _}function Za(y){let E=le(404,{pathname:y}),b=l||s,{matches:D,route:_}=Ut(b);return{notFoundMatches:D,route:_,error:E}}function Zu(y,E,b){if(m=y,p=E,v=b||null,!R&&g.navigation===zt){R=!0;let D=ri(g.location,g.matches);D!=null&&ge({restoreScrollPosition:D})}return()=>{m=null,p=null,v=null}}function ti(y,E){return v&&v(y,E.map(D=>Ui(D,g.loaderData)))||y.key}function ec(y,E){if(m&&p){let b=ti(y,E);m[b]=p()}}function ri(y,E){if(m){let b=ti(y,E),D=m[b];if(typeof D=="number")return D}return null}function Ur(y,E,b){if(e.patchRoutesOnNavigation)if(y){if(Object.keys(y[0].params).length>0)return{active:!0,matches:mr(E,b,u,!0)}}else return{active:!0,matches:mr(E,b,u,!0)||[]};return{active:!1,matches:null}}async function jr(y,E,b,D){if(!e.patchRoutesOnNavigation)return{type:"success",matches:y};let _=y;for(;;){let U=l==null,j=l||s,I=i;try{await e.patchRoutesOnNavigation({signal:b,path:E,matches:_,fetcherKey:D,patch:(B,W)=>{b.aborted||Ri(B,W,j,I,o,!1)}})}catch(B){return{type:"error",error:B,partialMatches:_}}finally{U&&!b.aborted&&(s=[...s])}if(b.aborted)return{type:"aborted"};let z=be(j,E,u),V=null;if(z){if(Object.keys(z[0].params).length===0)return{type:"success",matches:z};if(V=mr(j,E,u,!0),!(V&&_.length<V.length&&ai(_,V.slice(0,_.length))))return{type:"success",matches:z}}if(V||(V=mr(j,E,u,!0)),!V||ai(_,V))return{type:"success",matches:null};_=V}}function ai(y,E){return y.length===E.length&&y.every((b,D)=>b.route.id===E[D].route.id)}function tc(y){i={},l=it(y,o,void 0,i)}function rc(y,E,b=!1){let D=l==null;Ri(y,E,l||s,i,o,b),D&&(s=[...s],ge({}))}return S={get basename(){return u},get future(){return c},get state(){return g},get routes(){return s},get window(){return t},initialize:Uu,subscribe:zu,enableScrollRestoration:Zu,navigate:Yo,fetch:Ju,revalidate:Bu,createHref:y=>e.history.createHref(y),encodeLocation:y=>e.history.encodeLocation(y),getFetcher:Go,resetFetcher:Xu,deleteFetcher:qu,dispose:ju,getBlocker:Qu,deleteBlocker:Zo,patchRoutes:rc,_internalFetchControllers:X,_internalSetRoutes:tc,_internalSetStateDoNotUseOrYouWillBreakYourApp(y){ge(y)}},e.unstable_instrumentations&&(S=Mc(S,e.unstable_instrumentations.map(y=>y.router).filter(Boolean))),S}function Ln(e,t){A(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let r={},a=(t?t.basename:null)||"/",n=t?.mapRouteProperties||es,o=n;if(t?.unstable_instrumentations){let h=t.unstable_instrumentations;o=m=>({...n(m),...Ji(h.map(v=>v.route).filter(Boolean),m)})}let i=it(e,o,void 0,r);async function s(h,{requestContext:m,filterMatchesToLoad:v,skipLoaderErrorBubbling:p,skipRevalidation:R,dataStrategy:w,generateMiddlewareResponse:x}={}){let P=new URL(h.url),C=h.method,S=ot("",pe(P),null,"default"),g=be(i,S,a);if(m=m??new Ue,!yn(C)&&C!=="HEAD"){let O=le(405,{method:C}),{matches:F,route:H}=Ut(i),G={basename:a,location:S,matches:F,loaderData:{},actionData:null,errors:{[H.id]:O},statusCode:O.status,loaderHeaders:{},actionHeaders:{}};return x?x(()=>Promise.resolve(G)):G}else if(!g){let O=le(404,{pathname:S.pathname}),{matches:F,route:H}=Ut(i),G={basename:a,location:S,matches:F,loaderData:{},actionData:null,errors:{[H.id]:O},statusCode:O.status,loaderHeaders:{},actionHeaders:{}};return x?x(()=>Promise.resolve(G)):G}if(x){A(m instanceof Ue,"When using middleware in `staticHandler.query()`, any provided `requestContext` must be an instance of `RouterContextProvider`");try{await Ei(g,r,o);let O,F=await bi({request:h,unstable_pattern:jt(g.map(H=>H.route.path)),matches:g,params:g[0].params,context:m},async()=>await x(async(G,Z={})=>{let Y=await u(G,S,g,m,w||null,p===!0,null,"filterMatchesToLoad"in Z?Z.filterMatchesToLoad??null:v??null,R===!0);return ae(Y)?Y:(O={location:S,basename:a,...Y},O)}),async(H,G)=>{if(vr(H))return H;if(ae(H))try{H=new se(H.status,H.statusText,await us(H))}catch(Z){H=Z}if(nt(H)&&(H=Kc(H)),O){G in O.loaderData&&(O.loaderData[G]=void 0);let Z=_n(i,O,H,p?G:$e(g,G).route.id);return x(()=>Promise.resolve(Z))}else{let Z=p?G:$e(g,g.find(q=>q.route.id===G||q.route.loader)?.route.id||G).route.id,Y={matches:g,location:S,basename:a,loaderData:{},actionData:null,errors:{[Z]:H},statusCode:oe(H)?H.status:500,actionHeaders:{},loaderHeaders:{}};return x(()=>Promise.resolve(Y))}});return A(ae(F),"Expected a response in query()"),F}catch(O){if(ae(O))return O;throw O}}let T=await u(h,S,g,m,w||null,p===!0,null,v||null,R===!0);return ae(T)?T:{location:S,basename:a,...T}}async function l(h,{routeId:m,requestContext:v,dataStrategy:p,generateMiddlewareResponse:R}={}){let w=new URL(h.url),x=h.method,P=ot("",pe(w),null,"default"),C=be(i,P,a);if(v=v??new Ue,!yn(x)&&x!=="HEAD"&&x!=="OPTIONS")throw le(405,{method:x});if(!C)throw le(404,{pathname:P.pathname});let S=m?C.find(O=>O.route.id===m):Bt(C,P);if(m&&!S)throw le(403,{pathname:P.pathname,routeId:m});if(!S)throw le(404,{pathname:P.pathname});if(R)return A(v instanceof Ue,"When using middleware in `staticHandler.queryRoute()`, any provided `requestContext` must be an instance of `RouterContextProvider`"),await Ei(C,r,o),await bi({request:h,unstable_pattern:jt(C.map(F=>F.route.path)),matches:C,params:C[0].params,context:v},async()=>await R(async H=>{let G=await u(H,P,C,v,p||null,!1,S,null,!1),Z=T(G);return ae(Z)?Z:typeof Z=="string"?new Response(Z):Response.json(Z)}),F=>{if(nt(F))return Promise.resolve(pn(F));if(ae(F))return Promise.resolve(F);throw F});let g=await u(h,P,C,v,p||null,!1,S,null,!1);return T(g);function T(O){if(ae(O))return O;let F=O.errors?Object.values(O.errors)[0]:void 0;if(F!==void 0)throw F;if(O.actionData)return Object.values(O.actionData)[0];if(O.loaderData)return Object.values(O.loaderData)[0]}}async function u(h,m,v,p,R,w,x,P,C){A(h.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(me(h.method))return await d(h,v,x||Bt(v,m),p,R,w,x!=null,P,C);let S=await c(h,v,p,R,w,x,P);return ae(S)?S:{...S,actionData:null,actionHeaders:{}}}catch(S){if(ms(S)&&ae(S.result)){if(S.type==="error")throw S.result;return S.result}if(vr(S))return S;throw S}}async function d(h,m,v,p,R,w,x,P,C){let S;if(!v.route.action&&!v.route.lazy){let O=le(405,{method:h.method,pathname:new URL(h.url).pathname,routeId:v.route.id});if(x)throw O;S={type:"error",error:O}}else{let O=yt(o,r,h,m,v,[],p);S=(await f(h,O,x,p,R))[v.route.id],h.signal.aborted&&pi(h,x)}if(pt(S))throw new Response(null,{status:S.response.status,headers:{Location:S.response.headers.get("Location")}});if(x){if(he(S))throw S.error;return{matches:[v],loaderData:{},actionData:{[v.route.id]:S.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{}}}if(C)if(he(S)){let O=w?v:$e(m,v.route.id);return{statusCode:oe(S.error)?S.error.status:S.statusCode!=null?S.statusCode:500,actionData:null,actionHeaders:{...S.headers?{[v.route.id]:S.headers}:{}},matches:m,loaderData:{},errors:{[O.route.id]:S.error},loaderHeaders:{}}}else return{actionData:{[v.route.id]:S.data},actionHeaders:S.headers?{[v.route.id]:S.headers}:{},matches:m,loaderData:{},errors:null,statusCode:S.statusCode||200,loaderHeaders:{}};let g=new Request(h.url,{headers:h.headers,redirect:h.redirect,signal:h.signal});if(he(S)){let O=w?v:$e(m,v.route.id);return{...await c(g,m,p,R,w,null,P,[O.route.id,S]),statusCode:oe(S.error)?S.error.status:S.statusCode!=null?S.statusCode:500,actionData:null,actionHeaders:{...S.headers?{[v.route.id]:S.headers}:{}}}}return{...await c(g,m,p,R,w,null,P),actionData:{[v.route.id]:S.data},...S.statusCode?{statusCode:S.statusCode}:{},actionHeaders:S.headers?{[v.route.id]:S.headers}:{}}}async function c(h,m,v,p,R,w,x,P){let C=w!=null;if(C&&!w?.route.loader&&!w?.route.lazy)throw le(400,{method:h.method,pathname:new URL(h.url).pathname,routeId:w?.route.id});let S;if(w)S=yt(o,r,h,m,w,[],v);else{let O=P&&he(P[1])?m.findIndex(H=>H.route.id===P[0])-1:void 0,F=jt(m.map(H=>H.route.path));S=m.map((H,G)=>O!=null&&G>O?yr(o,r,h,F,H,[],v,!1):yr(o,r,h,F,H,[],v,(H.route.loader||H.route.lazy)!=null&&(!x||x(H))))}if(!p&&!S.some(O=>O.shouldLoad))return{matches:m,loaderData:{},errors:P&&he(P[1])?{[P[0]]:P[1].error}:null,statusCode:200,loaderHeaders:{}};let g=await f(h,S,C,v,p);return h.signal.aborted&&pi(h,C),{...fs(m,g,P,!0,R),matches:m}}async function f(h,m,v,p,R){let w=await ls(R||hn,h,m,null,p,!0),x={};return await Promise.all(m.map(async P=>{if(!(P.route.id in w))return;let C=w[P.route.id];if(ps(C)){let S=C.result;throw ds(S,h,P.route.id,m,a)}if(v){if(ae(C.result))throw C;if(nt(C.result))throw pn(C.result)}x[P.route.id]=await cs(C)})),x}return{dataRoutes:i,query:s,queryRoute:l}}function _n(e,t,r,a){let n=a||t._deepestRenderedBoundaryId||e[0].id;return{...t,statusCode:oe(r)?r.status:500,errors:{[n]:r}}}function pi(e,t){if(e.signal.reason!==void 0)throw e.signal.reason;let r=t?"queryRoute":"query";throw new Error(`${r}() call aborted without an \`AbortSignal.reason\`: ${e.method} ${e.url}`)}function Uc(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function dn(e,t,r,a,n,o){let i,s;if(n){i=[];for(let u of t)if(i.push(u),u.route.id===n){s=u;break}}else i=t,s=t[t.length-1];let l=ca(a||".",ua(i),ue(e.pathname,r)||e.pathname,o==="path");if(a==null&&(l.search=e.search,l.hash=e.hash),(a==null||a===""||a===".")&&s){let u=On(l.search);if(s.route.index&&!u)l.search=l.search?l.search.replace(/^\?/,"?index&"):"?index";else if(!s.route.index&&u){let d=new URLSearchParams(l.search),c=d.getAll("index");d.delete("index"),c.filter(h=>h).forEach(h=>d.append("index",h));let f=d.toString();l.search=f?`?${f}`:""}}return r!=="/"&&(l.pathname=Dc({basename:r,pathname:l.pathname})),pe(l)}function yi(e,t,r){if(!r||!Uc(r))return{path:t};if(r.formMethod&&!yn(r.formMethod))return{path:t,error:le(405,{method:r.formMethod})};let a=()=>({path:t,error:le(400,{type:"invalid-body"})}),o=(r.formMethod||"get").toUpperCase(),i=hs(t);if(r.body!==void 0){if(r.formEncType==="text/plain"){if(!me(o))return a();let c=typeof r.body=="string"?r.body:r.body instanceof FormData||r.body instanceof URLSearchParams?Array.from(r.body.entries()).reduce((f,[h,m])=>`${f}${h}=${m} `,""):String(r.body);return{path:t,submission:{formMethod:o,formAction:i,formEncType:r.formEncType,formData:void 0,json:void 0,text:c}}}else if(r.formEncType==="application/json"){if(!me(o))return a();try{let c=typeof r.body=="string"?JSON.parse(r.body):r.body;return{path:t,submission:{formMethod:o,formAction:i,formEncType:r.formEncType,formData:void 0,json:c,text:void 0}}}catch{return a()}}}A(typeof FormData=="function","FormData is not available in this environment");let s,l;if(r.formData)s=mn(r.formData),l=r.formData;else if(r.body instanceof FormData)s=mn(r.body),l=r.body;else if(r.body instanceof URLSearchParams)s=r.body,l=xi(s);else if(r.body==null)s=new URLSearchParams,l=new FormData;else try{s=new URLSearchParams(r.body),l=xi(s)}catch{return a()}let u={formMethod:o,formAction:i,formEncType:r&&r.formEncType||"application/x-www-form-urlencoded",formData:l,json:void 0,text:void 0};if(me(u.formMethod))return{path:t,submission:u};let d=Te(t);return e&&d.search&&On(d.search)&&s.append("index",""),d.search=`?${s}`,{path:pe(d),submission:u}}function vi(e,t,r,a,n,o,i,s,l,u,d,c,f,h,m,v,p,R,w,x){let P=x?he(x[1])?x[1].error:x[1].data:void 0,C=n.createURL(o.location),S=n.createURL(l),g;if(d&&o.errors){let Y=Object.keys(o.errors)[0];g=i.findIndex(q=>q.route.id===Y)}else if(x&&he(x[1])){let Y=x[0];g=i.findIndex(q=>q.route.id===Y)-1}let T=x?x[1].statusCode:void 0,O=T&&T>=400,F={currentUrl:C,currentParams:o.matches[0]?.params||{},nextUrl:S,nextParams:i[0].params,...s,actionResult:P,actionStatus:T},H=jt(i.map(Y=>Y.route.path)),G=i.map((Y,q)=>{let{route:ve}=Y,X=null;if(g!=null&&q>g?X=!1:ve.lazy?X=!0:kn(ve)?d?X=fn(ve,o.loaderData,o.errors):jc(o.loaderData,o.matches[q],Y)&&(X=!0):X=!1,X!==null)return yr(r,a,e,H,Y,u,t,X);let Ae=O?!1:c||C.pathname+C.search===S.pathname+S.search||C.search!==S.search||zc(o.matches[q],Y),_e={...F,defaultShouldRevalidate:Ae},ze=aa(Y,_e);return yr(r,a,e,H,Y,u,t,ze,_e)}),Z=[];return m.forEach((Y,q)=>{if(d||!i.some(Ye=>Ye.route.id===Y.routeId)||h.has(q))return;let ve=o.fetchers.get(q),X=ve&&ve.state!=="idle"&&ve.data===void 0,Ae=be(p,Y.path,R);if(!Ae){if(w&&X)return;Z.push({key:q,routeId:Y.routeId,path:Y.path,matches:null,match:null,request:null,controller:null});return}if(v.has(q))return;let _e=Bt(Ae,Y.path),ze=new AbortController,ke=$t(n,Y.path,ze.signal),Fe=null;if(f.has(q))f.delete(q),Fe=yt(r,a,ke,Ae,_e,u,t);else if(X)c&&(Fe=yt(r,a,ke,Ae,_e,u,t));else{let Ye={...F,defaultShouldRevalidate:O?!1:c};aa(_e,Ye)&&(Fe=yt(r,a,ke,Ae,_e,u,t,Ye))}Fe&&Z.push({key:q,routeId:Y.routeId,path:Y.path,matches:Fe,match:_e,request:ke,controller:ze})}),{dsMatches:G,revalidatingFetchers:Z}}function kn(e){return e.loader!=null||e.middleware!=null&&e.middleware.length>0}function fn(e,t,r){if(e.lazy)return!0;if(!kn(e))return!1;let a=t!=null&&e.id in t,n=r!=null&&r[e.id]!==void 0;return!a&&n?!1:typeof e.loader=="function"&&e.loader.hydrate===!0?!0:!a&&!n}function jc(e,t,r){let a=!t||r.route.id!==t.route.id,n=!e.hasOwnProperty(r.route.id);return a||n}function zc(e,t){let r=e.route.path;return e.pathname!==t.pathname||r!=null&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function aa(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if(typeof r=="boolean")return r}return t.defaultShouldRevalidate}function Ri(e,t,r,a,n,o){let i;if(e){let u=a[e];A(u,`No route found to patch children into: routeId = ${e}`),u.children||(u.children=[]),i=u.children}else i=r;let s=[],l=[];if(t.forEach(u=>{let d=i.find(c=>as(u,c));d?l.push({existingRoute:d,newRoute:u}):s.push(u)}),s.length>0){let u=it(s,n,[e||"_","patch",String(i?.length||"0")],a);i.push(...u)}if(o&&l.length>0)for(let u=0;u<l.length;u++){let{existingRoute:d,newRoute:c}=l[u],f=d,[h]=it([c],n,[],{},!0);Object.assign(f,{element:h.element?h.element:f.element,errorElement:h.errorElement?h.errorElement:f.errorElement,hydrateFallbackElement:h.hydrateFallbackElement?h.hydrateFallbackElement:f.hydrateFallbackElement})}}function as(e,t){return"id"in e&&"id"in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children.every((r,a)=>t.children?.some(n=>as(r,n))):!1}function Bc(e,t,r,a,n){let o=r[e.id];if(A(o,"No route found in manifest"),!e.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof e.lazy=="function"){let d=wi.get(o);if(d)return{lazyRoutePromise:d,lazyHandlerPromise:d};let c=(async()=>{A(typeof e.lazy=="function","No lazy route function found");let f=await e.lazy(),h={};for(let m in f){let v=f[m];if(v===void 0)continue;let p=pc(m),w=o[m]!==void 0&&m!=="hasErrorBoundary";p?Q(!p,"Route property "+m+" is not a supported property to be returned from a lazy route function. This property will be ignored."):w?Q(!w,`Route "${o.id}" has a static property "${m}" defined but its lazy function is also returning a value for this property. The lazy route property "${m}" will be ignored.`):h[m]=v}Object.assign(o,h),Object.assign(o,{...a(o),lazy:void 0})})();return wi.set(o,c),c.catch(()=>{}),{lazyRoutePromise:c,lazyHandlerPromise:c}}let i=Object.keys(e.lazy),s=[],l;for(let d of i){if(n&&n.includes(d))continue;let c=Tn({key:d,route:e,manifest:r,mapRouteProperties:a});c&&(s.push(c),d===t&&(l=c))}let u=s.length>0?Promise.all(s).then(()=>{}):void 0;return u?.catch(()=>{}),l?.catch(()=>{}),{lazyRoutePromise:u,lazyHandlerPromise:l}}function Wc(e){return e!==void 0}function Ei(e,t,r){let a=e.map(({route:n})=>{if(!(typeof n.lazy!="object"||!n.lazy.middleware))return Tn({key:"middleware",route:n,manifest:t,mapRouteProperties:r})}).filter(Wc);return a.length>0?Promise.all(a):void 0}async function hn(e){let t=e.matches.filter(n=>n.shouldLoad),r={};return(await Promise.all(