13 lines
32 KiB
JavaScript
13 lines
32 KiB
JavaScript
import{r as i}from"./vendor-react-core-DRQGgXXF.js";/**
|
|
* react-router v7.9.5
|
|
*
|
|
* 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
|
|
*/var le="popstate";function Se(e={}){function t(r,a){let{pathname:o,search:l,hash:c}=r.location;return G("",{pathname:o,search:l,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function n(r,a){return typeof a=="string"?a:B(a)}return $e(t,n,null,e)}function R(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function L(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function ke(){return Math.random().toString(36).substring(2,10)}function ie(e,t){return{usr:e.state,key:e.key,idx:t}}function G(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?I(t):t,state:n,key:t&&t.key||r||ke()}}function B({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function I(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function $e(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:o=!1}=r,l=a.history,c="POP",u=null,s=f();s==null&&(s=0,l.replaceState({...l.state,idx:s},""));function f(){return(l.state||{idx:null}).idx}function d(){c="POP";let h=f(),y=h==null?null:h-s;s=h,u&&u({action:c,location:w.location,delta:y})}function m(h,y){c="PUSH";let x=G(w.location,h,y);s=f()+1;let p=ie(x,s),E=w.createHref(x);try{l.pushState(p,"",E)}catch(b){if(b instanceof DOMException&&b.name==="DataCloneError")throw b;a.location.assign(E)}o&&u&&u({action:c,location:w.location,delta:1})}function g(h,y){c="REPLACE";let x=G(w.location,h,y);s=f();let p=ie(x,s),E=w.createHref(x);l.replaceState(p,"",E),o&&u&&u({action:c,location:w.location,delta:0})}function v(h){return Fe(h)}let w={get action(){return c},get location(){return e(a,l)},listen(h){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(le,d),u=h,()=>{a.removeEventListener(le,d),u=null}},createHref(h){return t(a,h)},createURL:v,encodeLocation(h){let y=v(h);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:m,replace:g,go(h){return l.go(h)}};return w}function Fe(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),R(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:B(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function fe(e,t,n="/"){return Ne(e,t,n,!1)}function Ne(e,t,n,r){let a=typeof t=="string"?I(t):t,o=$(a.pathname||"/",n);if(o==null)return null;let l=de(e);Ie(l);let c=null;for(let u=0;c==null&&u<l.length;++u){let s=je(o);c=He(l[u],s,r)}return c}function de(e,t=[],n=[],r="",a=!1){let o=(l,c,u=a,s)=>{let f={relativePath:s===void 0?l.path||"":s,caseSensitive:l.caseSensitive===!0,childrenIndex:c,route:l};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(r)&&u)return;R(f.relativePath.startsWith(r),`Absolute route path "${f.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),f.relativePath=f.relativePath.slice(r.length)}let d=k([r,f.relativePath]),m=n.concat(f);l.children&&l.children.length>0&&(R(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${d}".`),de(l.children,t,m,d,u)),!(l.path==null&&!l.index)&&t.push({path:d,score:We(d,l.index),routesMeta:m})};return e.forEach((l,c)=>{var u;if(l.path===""||!((u=l.path)!=null&&u.includes("?")))o(l,c);else for(let s of he(l.path))o(l,c,!0,s)}),t}function he(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),o=n.replace(/\?$/,"");if(r.length===0)return a?[o,""]:[o];let l=he(r.join("/")),c=[];return c.push(...l.map(u=>u===""?o:[o,u].join("/"))),a&&c.push(...l),c.map(u=>e.startsWith("/")&&u===""?"/":u)}function Ie(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ue(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Te=/^:[\w-]+$/,De=3,Me=2,Oe=1,Be=10,Ae=-2,ue=e=>e==="*";function We(e,t){let n=e.split("/"),r=n.length;return n.some(ue)&&(r+=Ae),t&&(r+=Me),n.filter(a=>!ue(a)).reduce((a,o)=>a+(Te.test(o)?De:o===""?Oe:Be),r)}function Ue(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function He(e,t,n=!1){let{routesMeta:r}=e,a={},o="/",l=[];for(let c=0;c<r.length;++c){let u=r[c],s=c===r.length-1,f=o==="/"?t:t.slice(o.length)||"/",d=z({path:u.relativePath,caseSensitive:u.caseSensitive,end:s},f),m=u.route;if(!d&&s&&n&&!r[r.length-1].route.index&&(d=z({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},f)),!d)return null;Object.assign(a,d.params),l.push({params:a,pathname:k([o,d.pathname]),pathnameBase:Ke(k([o,d.pathnameBase])),route:m}),d.pathnameBase!=="/"&&(o=k([o,d.pathnameBase]))}return l}function z(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=_e(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let o=a[0],l=o.replace(/(.)\/+$/,"$1"),c=a.slice(1);return{params:r.reduce((s,{paramName:f,isOptional:d},m)=>{if(f==="*"){let v=c[m]||"";l=o.slice(0,o.length-v.length).replace(/(.)\/+$/,"$1")}const g=c[m];return d&&!g?s[f]=void 0:s[f]=(g||"").replace(/%2F/g,"/"),s},{}),pathname:o,pathnameBase:l,pattern:e}}function _e(e,t=!1,n=!0){L(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 r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,c,u)=>(r.push({paramName:c,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function je(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return L(!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 $(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function Ve(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?I(e):e;return{pathname:n?n.startsWith("/")?n:ze(n,t):t,search:Ye(r),hash:qe(a)}}function ze(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function Y(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Je(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Q(e){let t=Je(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Z(e,t,n,r=!1){let a;typeof e=="string"?a=I(e):(a={...e},R(!a.pathname||!a.pathname.includes("?"),Y("?","pathname","search",a)),R(!a.pathname||!a.pathname.includes("#"),Y("#","pathname","hash",a)),R(!a.search||!a.search.includes("#"),Y("#","search","hash",a)));let o=e===""||a.pathname==="",l=o?"/":a.pathname,c;if(l==null)c=n;else{let d=t.length-1;if(!r&&l.startsWith("..")){let m=l.split("/");for(;m[0]==="..";)m.shift(),d-=1;a.pathname=m.join("/")}c=d>=0?t[d]:"/"}let u=Ve(a,c),s=l&&l!=="/"&&l.endsWith("/"),f=(o||l===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(s||f)&&(u.pathname+="/"),u}var k=e=>e.join("/").replace(/\/\/+/g,"/"),Ke=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ye=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,qe=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Ge(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var pe=["POST","PUT","PATCH","DELETE"];new Set(pe);var Xe=["GET",...pe];new Set(Xe);var T=i.createContext(null);T.displayName="DataRouter";var J=i.createContext(null);J.displayName="DataRouterState";i.createContext(!1);var me=i.createContext({isTransitioning:!1});me.displayName="ViewTransition";var Qe=i.createContext(new Map);Qe.displayName="Fetchers";var Ze=i.createContext(null);Ze.displayName="Await";var S=i.createContext(null);S.displayName="Navigation";var A=i.createContext(null);A.displayName="Location";var C=i.createContext({outlet:null,matches:[],isDataRoute:!1});C.displayName="Route";var ee=i.createContext(null);ee.displayName="RouteError";function et(e,{relative:t}={}){R(D(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=i.useContext(S),{hash:a,pathname:o,search:l}=W(e,{relative:t}),c=o;return n!=="/"&&(c=o==="/"?n:k([n,o])),r.createHref({pathname:c,search:l,hash:a})}function D(){return i.useContext(A)!=null}function F(){return R(D(),"useLocation() may be used only in the context of a <Router> component."),i.useContext(A).location}var ye="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function ge(e){i.useContext(S).static||i.useLayoutEffect(e)}function ve(){let{isDataRoute:e}=i.useContext(C);return e?mt():tt()}function tt(){R(D(),"useNavigate() may be used only in the context of a <Router> component.");let e=i.useContext(T),{basename:t,navigator:n}=i.useContext(S),{matches:r}=i.useContext(C),{pathname:a}=F(),o=JSON.stringify(Q(r)),l=i.useRef(!1);return ge(()=>{l.current=!0}),i.useCallback((u,s={})=>{if(L(l.current,ye),!l.current)return;if(typeof u=="number"){n.go(u);return}let f=Z(u,JSON.parse(o),a,s.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:k([t,f.pathname])),(s.replace?n.replace:n.push)(f,s.state,s)},[t,n,o,a,e])}var nt=i.createContext(null);function rt(e){let t=i.useContext(C).outlet;return i.useMemo(()=>t&&i.createElement(nt.Provider,{value:e},t),[t,e])}function Xt(){let{matches:e}=i.useContext(C),t=e[e.length-1];return t?t.params:{}}function W(e,{relative:t}={}){let{matches:n}=i.useContext(C),{pathname:r}=F(),a=JSON.stringify(Q(n));return i.useMemo(()=>Z(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function at(e,t){return we(e,t)}function we(e,t,n,r,a){var x;R(D(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=i.useContext(S),{matches:l}=i.useContext(C),c=l[l.length-1],u=c?c.params:{},s=c?c.pathname:"/",f=c?c.pathnameBase:"/",d=c&&c.route;{let p=d&&d.path||"";xe(s,!d||p.endsWith("*")||p.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${p}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
|
|
Please change the parent <Route path="${p}"> to <Route path="${p==="/"?"*":`${p}/*`}">.`)}let m=F(),g;if(t){let p=typeof t=="string"?I(t):t;R(f==="/"||((x=p.pathname)==null?void 0:x.startsWith(f)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${f}" but pathname "${p.pathname}" was given in the \`location\` prop.`),g=p}else g=m;let v=g.pathname||"/",w=v;if(f!=="/"){let p=f.replace(/^\//,"").split("/");w="/"+v.replace(/^\//,"").split("/").slice(p.length).join("/")}let h=fe(e,{pathname:w});L(d||h!=null,`No routes matched location "${g.pathname}${g.search}${g.hash}" `),L(h==null||h[h.length-1].route.element!==void 0||h[h.length-1].route.Component!==void 0||h[h.length-1].route.lazy!==void 0,`Matched leaf route at location "${g.pathname}${g.search}${g.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let y=st(h&&h.map(p=>Object.assign({},p,{params:Object.assign({},u,p.params),pathname:k([f,o.encodeLocation?o.encodeLocation(p.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:p.pathname]),pathnameBase:p.pathnameBase==="/"?f:k([f,o.encodeLocation?o.encodeLocation(p.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:p.pathnameBase])})),l,n,r,a);return t&&y?i.createElement(A.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...g},navigationType:"POP"}},y):y}function ot(){let e=pt(),t=Ge(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},o={padding:"2px 4px",backgroundColor:r},l=null;return console.error("Error handled by React Router default ErrorBoundary:",e),l=i.createElement(i.Fragment,null,i.createElement("p",null,"💿 Hey developer 👋"),i.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",i.createElement("code",{style:o},"ErrorBoundary")," or"," ",i.createElement("code",{style:o},"errorElement")," prop on your route.")),i.createElement(i.Fragment,null,i.createElement("h2",null,"Unexpected Application Error!"),i.createElement("h3",{style:{fontStyle:"italic"}},t),n?i.createElement("pre",{style:a},n):null,l)}var lt=i.createElement(ot,null),it=class extends i.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.unstable_onError?this.props.unstable_onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?i.createElement(C.Provider,{value:this.props.routeContext},i.createElement(ee.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function ut({routeContext:e,match:t,children:n}){let r=i.useContext(T);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),i.createElement(C.Provider,{value:e},n)}function st(e,t=[],n=null,r=null,a=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,l=n==null?void 0:n.errors;if(l!=null){let s=o.findIndex(f=>f.route.id&&(l==null?void 0:l[f.route.id])!==void 0);R(s>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),o=o.slice(0,Math.min(o.length,s+1))}let c=!1,u=-1;if(n)for(let s=0;s<o.length;s++){let f=o[s];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(u=s),f.route.id){let{loaderData:d,errors:m}=n,g=f.route.loader&&!d.hasOwnProperty(f.route.id)&&(!m||m[f.route.id]===void 0);if(f.route.lazy||g){c=!0,u>=0?o=o.slice(0,u+1):o=[o[0]];break}}}return o.reduceRight((s,f,d)=>{let m,g=!1,v=null,w=null;n&&(m=l&&f.route.id?l[f.route.id]:void 0,v=f.route.errorElement||lt,c&&(u<0&&d===0?(xe("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,w=null):u===d&&(g=!0,w=f.route.hydrateFallbackElement||null)));let h=t.concat(o.slice(0,d+1)),y=()=>{let x;return m?x=v:g?x=w:f.route.Component?x=i.createElement(f.route.Component,null):f.route.element?x=f.route.element:x=s,i.createElement(ut,{match:f,routeContext:{outlet:s,matches:h,isDataRoute:n!=null},children:x})};return n&&(f.route.ErrorBoundary||f.route.errorElement||d===0)?i.createElement(it,{location:n.location,revalidation:n.revalidation,component:v,error:m,children:y(),routeContext:{outlet:null,matches:h,isDataRoute:!0},unstable_onError:r}):y()},null)}function te(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ct(e){let t=i.useContext(T);return R(t,te(e)),t}function ft(e){let t=i.useContext(J);return R(t,te(e)),t}function dt(e){let t=i.useContext(C);return R(t,te(e)),t}function ne(e){let t=dt(e),n=t.matches[t.matches.length-1];return R(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function ht(){return ne("useRouteId")}function pt(){var r;let e=i.useContext(ee),t=ft("useRouteError"),n=ne("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function mt(){let{router:e}=ct("useNavigate"),t=ne("useNavigate"),n=i.useRef(!1);return ge(()=>{n.current=!0}),i.useCallback(async(a,o={})=>{L(n.current,ye),n.current&&(typeof a=="number"?e.navigate(a):await e.navigate(a,{fromRouteId:t,...o}))},[e,t])}var se={};function xe(e,t,n){!t&&!se[e]&&(se[e]=!0,L(!1,n))}i.memo(yt);function yt({routes:e,future:t,state:n,unstable_onError:r}){return we(e,void 0,n,r,t)}function Qt({to:e,replace:t,state:n,relative:r}){R(D(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=i.useContext(S);L(!a,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:o}=i.useContext(C),{pathname:l}=F(),c=ve(),u=Z(e,Q(o),l,r==="path"),s=JSON.stringify(u);return i.useEffect(()=>{c(JSON.parse(s),{replace:t,state:n,relative:r})},[c,s,r,t,n]),null}function Zt(e){return rt(e.context)}function gt(e){R(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function vt({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:o=!1}){R(!D(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=e.replace(/^\/*/,"/"),c=i.useMemo(()=>({basename:l,navigator:a,static:o,future:{}}),[l,a,o]);typeof n=="string"&&(n=I(n));let{pathname:u="/",search:s="",hash:f="",state:d=null,key:m="default"}=n,g=i.useMemo(()=>{let v=$(u,l);return v==null?null:{location:{pathname:v,search:s,hash:f,state:d,key:m},navigationType:r}},[l,u,s,f,d,m,r]);return L(g!=null,`<Router basename="${l}"> is not able to match the URL "${u}${s}${f}" because it does not start with the basename, so the <Router> won't render anything.`),g==null?null:i.createElement(S.Provider,{value:c},i.createElement(A.Provider,{children:t,value:g}))}function en({children:e,location:t}){return at(X(e),t)}function X(e,t=[]){let n=[];return i.Children.forEach(e,(r,a)=>{if(!i.isValidElement(r))return;let o=[...t,a];if(r.type===i.Fragment){n.push.apply(n,X(r.props.children,o));return}R(r.type===gt,`[${typeof r.type=="string"?r.type:r.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),R(!r.props.index||!r.props.children,"An index route cannot have child routes.");let l={id:r.props.id||o.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=X(r.props.children,o)),n.push(l)}),n}var j="get",V="application/x-www-form-urlencoded";function K(e){return e!=null&&typeof e.tagName=="string"}function wt(e){return K(e)&&e.tagName.toLowerCase()==="button"}function xt(e){return K(e)&&e.tagName.toLowerCase()==="form"}function Rt(e){return K(e)&&e.tagName.toLowerCase()==="input"}function Et(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Ct(e,t){return e.button===0&&(!t||t==="_self")&&!Et(e)}var _=null;function bt(){if(_===null)try{new FormData(document.createElement("form"),0),_=!1}catch{_=!0}return _}var Pt=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function q(e){return e!=null&&!Pt.has(e)?(L(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${V}"`),null):e}function Lt(e,t){let n,r,a,o,l;if(xt(e)){let c=e.getAttribute("action");r=c?$(c,t):null,n=e.getAttribute("method")||j,a=q(e.getAttribute("enctype"))||V,o=new FormData(e)}else if(wt(e)||Rt(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let u=e.getAttribute("formaction")||c.getAttribute("action");if(r=u?$(u,t):null,n=e.getAttribute("formmethod")||c.getAttribute("method")||j,a=q(e.getAttribute("formenctype"))||q(c.getAttribute("enctype"))||V,o=new FormData(c,e),!bt()){let{name:s,type:f,value:d}=e;if(f==="image"){let m=s?`${s}.`:"";o.append(`${m}x`,"0"),o.append(`${m}y`,"0")}else s&&o.append(s,d)}}else{if(K(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=j,r=null,a=V,l=e}return o&&a==="text/plain"&&(l=o,o=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:o,body:l}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function re(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function St(e,t,n){let r=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return r.pathname==="/"?r.pathname=`_root.${n}`:t&&$(r.pathname,t)==="/"?r.pathname=`${t.replace(/\/$/,"")}/_root.${n}`:r.pathname=`${r.pathname.replace(/\/$/,"")}.${n}`,r}async function kt(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(n){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(n),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function $t(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function Ft(e,t,n){let r=await Promise.all(e.map(async a=>{let o=t.routes[a.route.id];if(o){let l=await kt(o,n);return l.links?l.links():[]}return[]}));return Dt(r.flat(1).filter($t).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function ce(e,t,n,r,a,o){let l=(u,s)=>n[s]?u.route.id!==n[s].route.id:!0,c=(u,s)=>{var f;return n[s].pathname!==u.pathname||((f=n[s].route.path)==null?void 0:f.endsWith("*"))&&n[s].params["*"]!==u.params["*"]};return o==="assets"?t.filter((u,s)=>l(u,s)||c(u,s)):o==="data"?t.filter((u,s)=>{var d;let f=r.routes[u.route.id];if(!f||!f.hasLoader)return!1;if(l(u,s)||c(u,s))return!0;if(u.route.shouldRevalidate){let m=u.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:((d=n[0])==null?void 0:d.params)||{},nextUrl:new URL(e,window.origin),nextParams:u.params,defaultShouldRevalidate:!0});if(typeof m=="boolean")return m}return!0}):[]}function Nt(e,t,{includeHydrateFallback:n}={}){return It(e.map(r=>{let a=t.routes[r.route.id];if(!a)return[];let o=[a.module];return a.clientActionModule&&(o=o.concat(a.clientActionModule)),a.clientLoaderModule&&(o=o.concat(a.clientLoaderModule)),n&&a.hydrateFallbackModule&&(o=o.concat(a.hydrateFallbackModule)),a.imports&&(o=o.concat(a.imports)),o}).flat(1))}function It(e){return[...new Set(e)]}function Tt(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Dt(e,t){let n=new Set;return new Set(t),e.reduce((r,a)=>{let o=JSON.stringify(Tt(a));return n.has(o)||(n.add(o),r.push({key:o,link:a})),r},[])}function Re(){let e=i.useContext(T);return re(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Mt(){let e=i.useContext(J);return re(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var ae=i.createContext(void 0);ae.displayName="FrameworkContext";function Ee(){let e=i.useContext(ae);return re(e,"You must render this element inside a <HydratedRouter> element"),e}function Ot(e,t){let n=i.useContext(ae),[r,a]=i.useState(!1),[o,l]=i.useState(!1),{onFocus:c,onBlur:u,onMouseEnter:s,onMouseLeave:f,onTouchStart:d}=t,m=i.useRef(null);i.useEffect(()=>{if(e==="render"&&l(!0),e==="viewport"){let w=y=>{y.forEach(x=>{l(x.isIntersecting)})},h=new IntersectionObserver(w,{threshold:.5});return m.current&&h.observe(m.current),()=>{h.disconnect()}}},[e]),i.useEffect(()=>{if(r){let w=setTimeout(()=>{l(!0)},100);return()=>{clearTimeout(w)}}},[r]);let g=()=>{a(!0)},v=()=>{a(!1),l(!1)};return n?e!=="intent"?[o,m,{}]:[o,m,{onFocus:O(c,g),onBlur:O(u,v),onMouseEnter:O(s,g),onMouseLeave:O(f,v),onTouchStart:O(d,g)}]:[!1,m,{}]}function O(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function Bt({page:e,...t}){let{router:n}=Re(),r=i.useMemo(()=>fe(n.routes,e,n.basename),[n.routes,e,n.basename]);return r?i.createElement(Wt,{page:e,matches:r,...t}):null}function At(e){let{manifest:t,routeModules:n}=Ee(),[r,a]=i.useState([]);return i.useEffect(()=>{let o=!1;return Ft(e,t,n).then(l=>{o||a(l)}),()=>{o=!0}},[e,t,n]),r}function Wt({page:e,matches:t,...n}){let r=F(),{manifest:a,routeModules:o}=Ee(),{basename:l}=Re(),{loaderData:c,matches:u}=Mt(),s=i.useMemo(()=>ce(e,t,u,a,r,"data"),[e,t,u,a,r]),f=i.useMemo(()=>ce(e,t,u,a,r,"assets"),[e,t,u,a,r]),d=i.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let v=new Set,w=!1;if(t.forEach(y=>{var p;let x=a.routes[y.route.id];!x||!x.hasLoader||(!s.some(E=>E.route.id===y.route.id)&&y.route.id in c&&((p=o[y.route.id])!=null&&p.shouldRevalidate)||x.hasClientLoader?w=!0:v.add(y.route.id))}),v.size===0)return[];let h=St(e,l,"data");return w&&v.size>0&&h.searchParams.set("_routes",t.filter(y=>v.has(y.route.id)).map(y=>y.route.id).join(",")),[h.pathname+h.search]},[l,c,r,a,s,t,e,o]),m=i.useMemo(()=>Nt(f,a),[f,a]),g=At(f);return i.createElement(i.Fragment,null,d.map(v=>i.createElement("link",{key:v,rel:"prefetch",as:"fetch",href:v,...n})),m.map(v=>i.createElement("link",{key:v,rel:"modulepreload",href:v,...n})),g.map(({key:v,link:w})=>i.createElement("link",{key:v,nonce:n.nonce,...w})))}function Ut(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Ce=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Ce&&(window.__reactRouterVersion="7.9.5")}catch{}function tn({basename:e,children:t,window:n}){let r=i.useRef();r.current==null&&(r.current=Se({window:n,v5Compat:!0}));let a=r.current,[o,l]=i.useState({action:a.action,location:a.location}),c=i.useCallback(u=>{i.startTransition(()=>l(u))},[l]);return i.useLayoutEffect(()=>a.listen(c),[a,c]),i.createElement(vt,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a})}var be=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Pe=i.forwardRef(function({onClick:t,discover:n="render",prefetch:r="none",relative:a,reloadDocument:o,replace:l,state:c,target:u,to:s,preventScrollReset:f,viewTransition:d,...m},g){let{basename:v}=i.useContext(S),w=typeof s=="string"&&be.test(s),h,y=!1;if(typeof s=="string"&&w&&(h=s,Ce))try{let P=new URL(window.location.href),N=s.startsWith("//")?new URL(P.protocol+s):new URL(s),oe=$(N.pathname,v);N.origin===P.origin&&oe!=null?s=oe+N.search+N.hash:y=!0}catch{L(!1,`<Link to="${s}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}let x=et(s,{relative:a}),[p,E,b]=Ot(r,m),U=Vt(s,{replace:l,state:c,target:u,preventScrollReset:f,relative:a,viewTransition:d});function M(P){t&&t(P),P.defaultPrevented||U(P)}let H=i.createElement("a",{...m,...b,href:h||x,onClick:y||o?t:M,ref:Ut(g,E),target:u,"data-discover":!w&&n==="render"?"true":void 0});return p&&!w?i.createElement(i.Fragment,null,H,i.createElement(Bt,{page:x})):H});Pe.displayName="Link";var Ht=i.forwardRef(function({"aria-current":t="page",caseSensitive:n=!1,className:r="",end:a=!1,style:o,to:l,viewTransition:c,children:u,...s},f){let d=W(l,{relative:s.relative}),m=F(),g=i.useContext(J),{navigator:v,basename:w}=i.useContext(S),h=g!=null&&qt(d)&&c===!0,y=v.encodeLocation?v.encodeLocation(d).pathname:d.pathname,x=m.pathname,p=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;n||(x=x.toLowerCase(),p=p?p.toLowerCase():null,y=y.toLowerCase()),p&&w&&(p=$(p,w)||p);const E=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let b=x===y||!a&&x.startsWith(y)&&x.charAt(E)==="/",U=p!=null&&(p===y||!a&&p.startsWith(y)&&p.charAt(y.length)==="/"),M={isActive:b,isPending:U,isTransitioning:h},H=b?t:void 0,P;typeof r=="function"?P=r(M):P=[r,b?"active":null,U?"pending":null,h?"transitioning":null].filter(Boolean).join(" ");let N=typeof o=="function"?o(M):o;return i.createElement(Pe,{...s,"aria-current":H,className:P,ref:f,style:N,to:l,viewTransition:c},typeof u=="function"?u(M):u)});Ht.displayName="NavLink";var _t=i.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:a,state:o,method:l=j,action:c,onSubmit:u,relative:s,preventScrollReset:f,viewTransition:d,...m},g)=>{let v=Kt(),w=Yt(c,{relative:s}),h=l.toLowerCase()==="get"?"get":"post",y=typeof c=="string"&&be.test(c),x=p=>{if(u&&u(p),p.defaultPrevented)return;p.preventDefault();let E=p.nativeEvent.submitter,b=(E==null?void 0:E.getAttribute("formmethod"))||l;v(E||p.currentTarget,{fetcherKey:t,method:b,navigate:n,replace:a,state:o,relative:s,preventScrollReset:f,viewTransition:d})};return i.createElement("form",{ref:g,method:h,action:w,onSubmit:r?u:x,...m,"data-discover":!y&&e==="render"?"true":void 0})});_t.displayName="Form";function jt(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Le(e){let t=i.useContext(T);return R(t,jt(e)),t}function Vt(e,{target:t,replace:n,state:r,preventScrollReset:a,relative:o,viewTransition:l}={}){let c=ve(),u=F(),s=W(e,{relative:o});return i.useCallback(f=>{if(Ct(f,t)){f.preventDefault();let d=n!==void 0?n:B(u)===B(s);c(e,{replace:d,state:r,preventScrollReset:a,relative:o,viewTransition:l})}},[u,c,s,n,r,t,e,a,o,l])}var zt=0,Jt=()=>`__${String(++zt)}__`;function Kt(){let{router:e}=Le("useSubmit"),{basename:t}=i.useContext(S),n=ht();return i.useCallback(async(r,a={})=>{let{action:o,method:l,encType:c,formData:u,body:s}=Lt(r,t);if(a.navigate===!1){let f=a.fetcherKey||Jt();await e.fetch(f,n,a.action||o,{preventScrollReset:a.preventScrollReset,formData:u,body:s,formMethod:a.method||l,formEncType:a.encType||c,flushSync:a.flushSync})}else await e.navigate(a.action||o,{preventScrollReset:a.preventScrollReset,formData:u,body:s,formMethod:a.method||l,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[e,t,n])}function Yt(e,{relative:t}={}){let{basename:n}=i.useContext(S),r=i.useContext(C);R(r,"useFormAction must be used inside a RouteContext");let[a]=r.matches.slice(-1),o={...W(e||".",{relative:t})},l=F();if(e==null){o.search=l.search;let c=new URLSearchParams(o.search),u=c.getAll("index");if(u.some(f=>f==="")){c.delete("index"),u.filter(d=>d).forEach(d=>c.append("index",d));let f=c.toString();o.search=f?`?${f}`:""}}return(!e||e===".")&&a.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(o.pathname=o.pathname==="/"?n:k([n,o.pathname])),B(o)}function qt(e,{relative:t}={}){let n=i.useContext(me);R(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Le("useViewTransitionState"),a=W(e,{relative:t});if(!n.isTransitioning)return!1;let o=$(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=$(n.nextLocation.pathname,r)||n.nextLocation.pathname;return z(a.pathname,l)!=null||z(a.pathname,o)!=null}export{tn as B,Pe as L,Qt as N,Zt as O,en as R,gt as a,ve as b,Xt as c,F as u};
|