1import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{et as r,j as i,q as a,t as o}from"./chunk-OB3PAWPO-CF8jOINB.js";import{Q as s,x as c}from"./String-COYjB6j6.js";import{t as l}from"./AssertUnreachable-DSZC2_uz.js";var u=e(t()),d=n(),f=Object.create(null),p=(0,u.createContext)(f);p.displayName=`BrowserRouter`;function m(e){let{isInMemory:t,children:n,basename:s}=e,[f]=(0,u.useState)(()=>t?r({v5Compat:!0,initialEntries:e.initialLocation===void 0?void 0:[e.initialLocation]}):a({v5Compat:!0})),[m]=(0,u.useState)(()=>(...e)=>typeof e[0]==`number`?f.go(e[0]):e[1]?.replace?f.replace(e[0]):f.push(e[0])),[h,_]=(0,u.useState)({action:f.action,location:f.location}),y=(0,u.useRef)(new Map),b=(0,u.useRef)(new Map),x=(0,u.useMemo)(()=>({block:e=>{let t=Symbol();return y.current.set(t,e),()=>y.current.delete(t)},listen:e=>{let t=Symbol();return b.current.set(t,e),()=>b.current.delete(t)},navigate:m,historyRef:f}),[m,f]);return(0,u.useLayoutEffect)(()=>{let e=!1,t=f.location,n=f.listen(n=>{let r=g(n),i=!1,a=y.current.values(),s=b.current.values();if(!e){let e=()=>i=!0;for(let t of a)if(t(r,e),i)break}if(i){e=!0;let n=r.action;switch(n){case o.Push:f.go(-1);break;case o.Replace:f.replace(t);break;case o.Pop:f.push(t);break;default:l(n,null)}}else{if(!e){for(let e of s)e(r);_(e=>r.action===o.Replace&&v(r.location,e.location)||c(r,e)?e:r)}e=!1,t=r.location}});return()=>n()},[f]),(0,d.jsx)(i,{location:h.location,navigationType:h.action,navigator:f,basename:s,useTransitions:!1,children:(0,d.jsx)(p.Provider,{value:x,children:n})})}function h(){let e=(0,u.useContext)(p);if(e===f)throw Error(`useBrowserRouter must be used within a BrowserRouter`);let t=s(_(e.historyRef));return(0,u.useMemo)(()=>({...e,listen:n=>{let r=_(e.historyRef);return c(r,t.current)||n(r),e.listen(n)}}),[e,t])}function g(e){return{action:e.action,location:e.location}}function _(e){return{action:e.action,location:e.location}}function v(e,t){return c({...e,key:void 0},{...t,key:void 0})}export{h as n,m as t}; 2//# sourceMappingURL=BrowserRouter-DIo7lP4D.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.