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